Shinya Kitaoka 810553
#pragma once
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#ifndef TSTROKES_DEFORMATIONS_H
Toshihiro Shimizu 890ddd
#define TSTROKES_DEFORMATIONS_H
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// #include "tstrokeutil.h"
Toshihiro Shimizu 890ddd
#include "tgeometry.h"
shun-iwasawa 5ddd75
#include <memory></memory>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#undef DVAPI
Toshihiro Shimizu 890ddd
#undef DVVAR
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#ifdef TVRENDER_EXPORTS
Toshihiro Shimizu 890ddd
#define DVAPI DV_EXPORT_API
Toshihiro Shimizu 890ddd
#define DVVAR DV_EXPORT_VAR
Toshihiro Shimizu 890ddd
#else
Toshihiro Shimizu 890ddd
#define DVAPI DV_IMPORT_API
Toshihiro Shimizu 890ddd
#define DVVAR DV_IMPORT_VAR
Toshihiro Shimizu 890ddd
#endif
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
class TStroke;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
/*!
Toshihiro Shimizu 890ddd
  TStrokeDeformation Abstract class to manage deformation
Toshihiro Shimizu 890ddd
    in stroke
Toshihiro Shimizu 890ddd
 */
Shinya Kitaoka 120a6e
class DVAPI TStrokeDeformation {
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  TStrokeDeformation() {}
Shinya Kitaoka 120a6e
  virtual ~TStrokeDeformation() {}
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  /*!
Shinya Kitaoka 120a6e
return displacement to use with function increaseControlPoints
Shinya Kitaoka 120a6e
\par stroke to test
Shinya Kitaoka 120a6e
\par w stroke parameter
Shinya Kitaoka 120a6e
\ret displacement to apply to obtain deformation
Shinya Kitaoka 120a6e
\sa increaseControlPoints
Shinya Kitaoka 120a6e
*/
Shinya Kitaoka 120a6e
  virtual TThickPoint getDisplacement(const TStroke &stroke,
Shinya Kitaoka 120a6e
                                      double w) const = 0;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  /*!
Shinya Kitaoka 120a6e
return displacement to use with function  modifyControlPoints
Shinya Kitaoka 120a6e
\par stroke to test
Shinya Kitaoka 120a6e
\par n control point to get
Shinya Kitaoka 120a6e
\ret displacement to apply to obtain deformation
Shinya Kitaoka 120a6e
\sa modifyControlPoints
Shinya Kitaoka 120a6e
*/
Shinya Kitaoka 120a6e
  virtual TThickPoint getDisplacementForControlPoint(const TStroke &stroke,
Shinya Kitaoka 120a6e
                                                     UINT n) const = 0;
Shinya Kitaoka 120a6e
  virtual TThickPoint getDisplacementForControlPointLen(const TStroke &stroke,
Shinya Kitaoka 120a6e
                                                        double cpLen) const = 0;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  /*!
Shinya Kitaoka 120a6e
| d getDisplacement() / dw  |
Shinya Kitaoka 120a6e
\par stroke to test
Shinya Kitaoka 120a6e
\par w stroke parameter
Shinya Kitaoka 120a6e
\ret | d getDisplacement() / dw  |
Shinya Kitaoka 120a6e
*/
Shinya Kitaoka 120a6e
  virtual double getDelta(const TStroke &stroke, double w) const = 0;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  /*!
Shinya Kitaoka 120a6e
Max diff of delta (This value indicates when it's necessary
Shinya Kitaoka 120a6e
  to insert control point)
Shinya Kitaoka 120a6e
\ret max displacement permitted
Shinya Kitaoka 120a6e
*/
Shinya Kitaoka 120a6e
  virtual double getMaxDiff() const = 0;
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
/*!
Toshihiro Shimizu 890ddd
    Manage the manipulation of a stroke using the metaball.
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
    Every tools have a constructor like:
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
    const TStroke *pStroke
Shinya Kitaoka 120a6e
    const TPointD &vect
Toshihiro Shimizu 890ddd
    ... list of parameter.
Toshihiro Shimizu 890ddd
 */
Shinya Kitaoka d1f6c4
class DVAPI TStrokePointDeformation final : public TStrokeDeformation {
Toshihiro Shimizu 890ddd
protected:
Shinya Kitaoka 120a6e
  struct Imp;
Shinya Kitaoka 120a6e
  std::unique_ptr<imp> m_imp;</imp>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  /*!
Shinya Kitaoka 120a6e
Use this constructor with increasePoints.
Shinya Kitaoka 120a6e
*/
Shinya Kitaoka 120a6e
  TStrokePointDeformation(const TPointD ¢er = TPointD(),
Shinya Kitaoka 120a6e
                          double radius         = 40.0);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  /*!
Shinya Kitaoka 120a6e
Use this constructor with modifyControlPoints.
Shinya Kitaoka 120a6e
*/
Shinya Kitaoka 120a6e
  TStrokePointDeformation(const TPointD &vect,
Shinya Kitaoka 120a6e
                          const TPointD ¢er = TPointD(),
Shinya Kitaoka 120a6e
                          double radius         = 40.0);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  virtual ~TStrokePointDeformation();
Shinya Kitaoka 120a6e
Shinya Kitaoka 473e70
  TThickPoint getDisplacement(const TStroke &stroke, double s) const override;
Shinya Kitaoka 38fd86
  TThickPoint getDisplacementForControlPoint(const TStroke &s,
Shinya Kitaoka 38fd86
                                             UINT n) const override;
Shinya Kitaoka 120a6e
  TThickPoint getDisplacementForControlPointLen(const TStroke &stroke,
Shinya Kitaoka 473e70
                                                double cpLen) const override;
Shinya Kitaoka 120a6e
Shinya Kitaoka 473e70
  double getDelta(const TStroke &stroke, double w) const override;
Shinya Kitaoka 473e70
  double getMaxDiff() const override;
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
/*!
Toshihiro Shimizu 890ddd
  Manage deformation of a stroke using a gaussian potential.
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
  Function is b*exp( -((x-a)^2)/c ).
Toshihiro Shimizu 890ddd
 */
Shinya Kitaoka d1f6c4
class DVAPI TStrokeParamDeformation final : public TStrokeDeformation {
Toshihiro Shimizu 890ddd
private:
Shinya Kitaoka 120a6e
  const TStroke *m_pRef;
Shinya Kitaoka 120a6e
  double m_startParameter;
Shinya Kitaoka 120a6e
  double m_lengthOfDeformation;
Shinya Kitaoka 120a6e
  TPointD *m_vect;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  /*
Shinya Kitaoka 120a6e
Use this constructor with increasePoints.
Shinya Kitaoka 120a6e
\param  stroke  reference to stroke to deform.
Shinya Kitaoka 120a6e
\param  vect size of movement.
Shinya Kitaoka 120a6e
\param  param parameter of nearest point in stroke.
Shinya Kitaoka 120a6e
\param  lengthOfDeformation  length of piece of stroke to move.
Shinya Kitaoka 120a6e
*/
Shinya Kitaoka 120a6e
  TStrokeParamDeformation(const TStroke *stroke, double parameterOfNearest,
Shinya Kitaoka 120a6e
                          double lengthOfDeformation = 100);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  /*!
Shinya Kitaoka 120a6e
Use this constructor with movePoints.
Shinya Kitaoka 120a6e
*/
Shinya Kitaoka 120a6e
  TStrokeParamDeformation(const TStroke *stroke, const TPointD &vect,
Shinya Kitaoka 120a6e
                          double parameterOfNearest,
Shinya Kitaoka 120a6e
                          double lengthOfDeformation = 100);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  virtual ~TStrokeParamDeformation();
Shinya Kitaoka 120a6e
Shinya Kitaoka 473e70
  TThickPoint getDisplacement(const TStroke &, double) const override;
Shinya Kitaoka 120a6e
  TThickPoint getDisplacementForControlPoint(const TStroke &stroke,
Shinya Kitaoka 473e70
                                             UINT n) const override;
Shinya Kitaoka 120a6e
  TThickPoint getDisplacementForControlPointLen(const TStroke &stroke,
Shinya Kitaoka 473e70
                                                double cpLen) const override;
Shinya Kitaoka 120a6e
Shinya Kitaoka 473e70
  double getDelta(const TStroke &, double) const override;
Shinya Kitaoka 120a6e
Shinya Kitaoka 473e70
  double getMaxDiff() const override;
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
/*!
Toshihiro Shimizu 890ddd
  Manage the deformation of thick in a stroke.
Toshihiro Shimizu 890ddd
 */
Shinya Kitaoka d1f6c4
class DVAPI TStrokeThicknessDeformation final : public TStrokeDeformation {
Toshihiro Shimizu 890ddd
private:
Shinya Kitaoka 120a6e
  double m_lengthOfDeformation;
Shinya Kitaoka 120a6e
  double m_startParameter;
Shinya Kitaoka 120a6e
  double m_versus;
Shinya Kitaoka 120a6e
  TPointD *m_vect;
Shinya Kitaoka 120a6e
  const TStroke *m_pRef;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  /*
Shinya Kitaoka 120a6e
Use this constructor with increasePoints.
Shinya Kitaoka 120a6e
\param  stroke  reference to stroke to deform.
Shinya Kitaoka 120a6e
\param  vect size of movement.
Shinya Kitaoka 120a6e
\param  param parameter of nearest point in stroke.
Shinya Kitaoka 120a6e
\param  lengthOfDeformation  length of piece of stroke to move.
Shinya Kitaoka 120a6e
*/
Shinya Kitaoka 120a6e
  TStrokeThicknessDeformation(const TStroke *stroke, double parameterOfNearest,
Shinya Kitaoka 120a6e
                              double lengthOfDeformation = 100);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  /*!
Shinya Kitaoka 120a6e
Use this constructor with movePoints.
Shinya Kitaoka 120a6e
*/
Shinya Kitaoka 120a6e
  TStrokeThicknessDeformation(const TStroke *stroke, const TPointD &vect,
Shinya Kitaoka 120a6e
                              double parameterOfNearest,
Shinya Kitaoka 120a6e
                              double lengthOfDeformation = 100,
Shinya Kitaoka 120a6e
                              double versus              = 1.0);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  virtual ~TStrokeThicknessDeformation();
Shinya Kitaoka 120a6e
Shinya Kitaoka 473e70
  TThickPoint getDisplacement(const TStroke &, double) const override;
Shinya Kitaoka 120a6e
  TThickPoint getDisplacementForControlPoint(const TStroke &stroke,
Shinya Kitaoka 473e70
                                             UINT n) const override;
Shinya Kitaoka 120a6e
  TThickPoint getDisplacementForControlPointLen(const TStroke &stroke,
Shinya Kitaoka 473e70
                                                double cpLen) const override;
Shinya Kitaoka 120a6e
Shinya Kitaoka 473e70
  double getDelta(const TStroke &, double) const override;
Shinya Kitaoka 120a6e
Shinya Kitaoka 473e70
  double getMaxDiff() const override;
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
/*!
Toshihiro Shimizu 890ddd
  Manage the bending of a stroke.
Toshihiro Shimizu 890ddd
 */
Shinya Kitaoka d1f6c4
class DVAPI TStrokeBenderDeformation final : public TStrokeDeformation {
Toshihiro Shimizu 890ddd
private:
Shinya Kitaoka 120a6e
  const TStroke *m_pRef;
Shinya Kitaoka 120a6e
  double m_startLength;
Shinya Kitaoka 120a6e
  double m_lengthOfDeformation;
Shinya Kitaoka 120a6e
  TPointD *m_vect;
Shinya Kitaoka 120a6e
  int m_versus;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  double m_angle;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  enum VERSUS { INNER = 0, OUTER };
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  /*!
Shinya Kitaoka 120a6e
Use this constructor with increasePoints.
Shinya Kitaoka 120a6e
 \param stroke a refernce to a stroke
Shinya Kitaoka 120a6e
 \param parameterOfNearest
Shinya Kitaoka 120a6e
 \param lengthOfDeformation
Shinya Kitaoka 120a6e
*/
Shinya Kitaoka 120a6e
  TStrokeBenderDeformation(const TStroke *stroke, double parameterOfNearest,
Shinya Kitaoka 120a6e
                           double lengthOfDeformation = 50);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  /*!
Shinya Kitaoka 120a6e
Use this constructor with movePoints.
Shinya Kitaoka 120a6e
*/
Shinya Kitaoka 120a6e
  TStrokeBenderDeformation(const TStroke *stroke, const TPointD ¢erOfRot,
Shinya Kitaoka 120a6e
                           double angle, double parameterOfNearest,
Shinya Kitaoka 120a6e
                           int innerOrOuter           = INNER,
Shinya Kitaoka 120a6e
                           double lengthOfDeformation = 50);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  virtual ~TStrokeBenderDeformation();
Shinya Kitaoka 120a6e
Shinya Kitaoka 473e70
  TThickPoint getDisplacement(const TStroke &, double s) const override;
Shinya Kitaoka 38fd86
  TThickPoint getDisplacementForControlPoint(const TStroke &,
Shinya Kitaoka 38fd86
                                             UINT n) const override;
Shinya Kitaoka 120a6e
  TThickPoint getDisplacementForControlPointLen(const TStroke &stroke,
Shinya Kitaoka 473e70
                                                double cpLen) const override;
Shinya Kitaoka 120a6e
Shinya Kitaoka 473e70
  double getDelta(const TStroke &, double) const override;
Shinya Kitaoka 473e70
  double getMaxDiff() const override;
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
/*!
Toshihiro Shimizu 890ddd
  Manage wirling of a stroke.
Toshihiro Shimizu 890ddd
 */
Shinya Kitaoka d1f6c4
class DVAPI TStrokeTwirlDeformation final : public TStrokeDeformation {
Toshihiro Shimizu 890ddd
private:
Shinya Kitaoka 120a6e
  TPointD m_center;
Shinya Kitaoka 120a6e
  double m_innerRadius2;
Shinya Kitaoka 120a6e
  TPointD m_vectorOfMovement;
Shinya Kitaoka 120a6e
  double m_outerRadius;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  /*!
Shinya Kitaoka 120a6e
Use this constructor with increasePoints.
Shinya Kitaoka 120a6e
 seg is the segment used to compute intersection .
Shinya Kitaoka 120a6e
*/
Shinya Kitaoka 120a6e
  TStrokeTwirlDeformation(const TPointD ¢er, double radius);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  TStrokeTwirlDeformation(const TPointD ¢er, double radius,
Shinya Kitaoka 120a6e
                          const TPointD &v);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  virtual ~TStrokeTwirlDeformation();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 473e70
  TThickPoint getDisplacement(const TStroke &, double s) const override;
Shinya Kitaoka 473e70
  double getDelta(const TStroke &, double) const override;
Shinya Kitaoka 473e70
  double getMaxDiff() const override;
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
/*!
Toshihiro Shimizu 890ddd
  New deformer class. NOT YET COMPLETED...
Toshihiro Shimizu 890ddd
 */
Shinya Kitaoka 120a6e
class DVAPI TPointDeformation {
Shinya Kitaoka 120a6e
  const TStroke *m_strokeRef;
Shinya Kitaoka 120a6e
  TPointD m_center;
Shinya Kitaoka 120a6e
  double m_radius;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  // return ratio density/length
Shinya Kitaoka 120a6e
  double getCPDensity(double s) const;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  TPointDeformation(const TStroke *, const TPointD &, double center);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  TPointDeformation();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  virtual ~TPointDeformation();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  TThickPoint getDisplacement(double s) const;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  // return integral of density in [s0,s1]
Shinya Kitaoka 120a6e
  /*
Shinya Kitaoka 120a6e
  / s1
Shinya Kitaoka 120a6e
 |     density( s ) ds
Shinya Kitaoka 120a6e
/
Shinya Kitaoka 120a6e
 s0
Shinya Kitaoka 120a6e
*/
Shinya Kitaoka 120a6e
  double getCPCountInRange(double s0, double s1) const;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  // ritorna il valode di densita' sopra il quale aggiunge punti di controllo
Shinya Kitaoka 120a6e
  double getMinCPDensity() const;
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
#endif  // TSTROKES_DEFORMATIONS_H