Toshihiro Shimizu 890ddd
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"
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
 */
Toshihiro Shimizu 890ddd
class DVAPI TStrokeDeformation
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
public:
Toshihiro Shimizu 890ddd
	TStrokeDeformation() {}
Toshihiro Shimizu 890ddd
	virtual ~TStrokeDeformation() {}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	/*!
Toshihiro Shimizu 890ddd
      return displacement to use with function increaseControlPoints
Toshihiro Shimizu 890ddd
      \par stroke to test
Toshihiro Shimizu 890ddd
      \par w stroke parameter 
Toshihiro Shimizu 890ddd
      \ret displacement to apply to obtain deformation
Toshihiro Shimizu 890ddd
      \sa increaseControlPoints
Toshihiro Shimizu 890ddd
     */
Toshihiro Shimizu 890ddd
	virtual TThickPoint getDisplacement(const TStroke &stroke, double w) const = 0;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	/*!
Toshihiro Shimizu 890ddd
      return displacement to use with function  modifyControlPoints
Toshihiro Shimizu 890ddd
      \par stroke to test
Toshihiro Shimizu 890ddd
      \par n control point to get
Toshihiro Shimizu 890ddd
      \ret displacement to apply to obtain deformation
Toshihiro Shimizu 890ddd
      \sa modifyControlPoints
Toshihiro Shimizu 890ddd
     */
Toshihiro Shimizu 890ddd
	virtual TThickPoint getDisplacementForControlPoint(const TStroke &stroke, UINT n) const = 0;
Toshihiro Shimizu 890ddd
	virtual TThickPoint getDisplacementForControlPointLen(const TStroke &stroke, double cpLen) const = 0;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	/*!    
Toshihiro Shimizu 890ddd
      | d getDisplacement() / dw  |
Toshihiro Shimizu 890ddd
      \par stroke to test
Toshihiro Shimizu 890ddd
      \par w stroke parameter
Toshihiro Shimizu 890ddd
      \ret | d getDisplacement() / dw  |
Toshihiro Shimizu 890ddd
    */
Toshihiro Shimizu 890ddd
	virtual double getDelta(const TStroke &stroke, double w) const = 0;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	/*!
Toshihiro Shimizu 890ddd
      Max diff of delta (This value indicates when it's necessary
Toshihiro Shimizu 890ddd
        to insert control point)
Toshihiro Shimizu 890ddd
      \ret max displacement permitted
Toshihiro Shimizu 890ddd
    */
Toshihiro Shimizu 890ddd
	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
Toshihiro Shimizu 890ddd
    const TPointD &vect 
Toshihiro Shimizu 890ddd
    ... list of parameter.
Toshihiro Shimizu 890ddd
 */
Toshihiro Shimizu 890ddd
class DVAPI TStrokePointDeformation : public TStrokeDeformation
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
protected:
Toshihiro Shimizu 890ddd
	struct Imp;
Toshihiro Shimizu 890ddd
	Imp *m_imp;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Toshihiro Shimizu 890ddd
	/*!
Toshihiro Shimizu 890ddd
      Use this constructor with increasePoints.
Toshihiro Shimizu 890ddd
     */
Toshihiro Shimizu 890ddd
	TStrokePointDeformation(const TPointD ¢er = TPointD(),
Toshihiro Shimizu 890ddd
							double radius = 40.0);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	/*!
Toshihiro Shimizu 890ddd
      Use this constructor with modifyControlPoints.
Toshihiro Shimizu 890ddd
     */
Toshihiro Shimizu 890ddd
	TStrokePointDeformation(const TPointD &vect,
Toshihiro Shimizu 890ddd
							const TPointD ¢er = TPointD(),
Toshihiro Shimizu 890ddd
							double radius = 40.0);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	virtual ~TStrokePointDeformation();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	TThickPoint getDisplacement(const TStroke &stroke, double s) const;
Toshihiro Shimizu 890ddd
	TThickPoint getDisplacementForControlPoint(const TStroke &s, UINT n) const;
Toshihiro Shimizu 890ddd
	TThickPoint getDisplacementForControlPointLen(const TStroke &stroke, double cpLen) const;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	double getDelta(const TStroke &stroke, double w) const;
Toshihiro Shimizu 890ddd
	double getMaxDiff() const;
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
 */
Toshihiro Shimizu 890ddd
class DVAPI TStrokeParamDeformation : public TStrokeDeformation
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
private:
Toshihiro Shimizu 890ddd
	const TStroke *m_pRef;
Toshihiro Shimizu 890ddd
	double m_startParameter;
Toshihiro Shimizu 890ddd
	double m_lengthOfDeformation;
Toshihiro Shimizu 890ddd
	TPointD *m_vect;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Toshihiro Shimizu 890ddd
	/*
Toshihiro Shimizu 890ddd
      Use this constructor with increasePoints.
Toshihiro Shimizu 890ddd
      \param  stroke  reference to stroke to deform.
Toshihiro Shimizu 890ddd
      \param  vect size of movement.
Toshihiro Shimizu 890ddd
      \param  param parameter of nearest point in stroke.
Toshihiro Shimizu 890ddd
      \param  lengthOfDeformation  length of piece of stroke to move.
Toshihiro Shimizu 890ddd
     */
Toshihiro Shimizu 890ddd
	TStrokeParamDeformation(const TStroke *stroke,
Toshihiro Shimizu 890ddd
							double parameterOfNearest,
Toshihiro Shimizu 890ddd
							double lengthOfDeformation = 100);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	/*!
Toshihiro Shimizu 890ddd
      Use this constructor with movePoints.
Toshihiro Shimizu 890ddd
     */
Toshihiro Shimizu 890ddd
	TStrokeParamDeformation(const TStroke *stroke,
Toshihiro Shimizu 890ddd
							const TPointD &vect,
Toshihiro Shimizu 890ddd
							double parameterOfNearest,
Toshihiro Shimizu 890ddd
							double lengthOfDeformation = 100);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	virtual ~TStrokeParamDeformation();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	TThickPoint getDisplacement(const TStroke &, double) const;
Toshihiro Shimizu 890ddd
	TThickPoint getDisplacementForControlPoint(const TStroke &stroke, UINT n) const;
Toshihiro Shimizu 890ddd
	TThickPoint getDisplacementForControlPointLen(const TStroke &stroke, double cpLen) const;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	double getDelta(const TStroke &, double) const;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	double getMaxDiff() const;
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
 */
Toshihiro Shimizu 890ddd
class DVAPI TStrokeThicknessDeformation : public TStrokeDeformation
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
private:
Toshihiro Shimizu 890ddd
	double m_lengthOfDeformation;
Toshihiro Shimizu 890ddd
	double m_startParameter;
Toshihiro Shimizu 890ddd
	double m_versus;
Toshihiro Shimizu 890ddd
	TPointD *m_vect;
Toshihiro Shimizu 890ddd
	const TStroke *m_pRef;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Toshihiro Shimizu 890ddd
	/*
Toshihiro Shimizu 890ddd
      Use this constructor with increasePoints.
Toshihiro Shimizu 890ddd
      \param  stroke  reference to stroke to deform.
Toshihiro Shimizu 890ddd
      \param  vect size of movement.
Toshihiro Shimizu 890ddd
      \param  param parameter of nearest point in stroke.
Toshihiro Shimizu 890ddd
      \param  lengthOfDeformation  length of piece of stroke to move.
Toshihiro Shimizu 890ddd
     */
Toshihiro Shimizu 890ddd
	TStrokeThicknessDeformation(const TStroke *stroke,
Toshihiro Shimizu 890ddd
								double parameterOfNearest,
Toshihiro Shimizu 890ddd
								double lengthOfDeformation = 100);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	/*!
Toshihiro Shimizu 890ddd
      Use this constructor with movePoints.
Toshihiro Shimizu 890ddd
     */
Toshihiro Shimizu 890ddd
	TStrokeThicknessDeformation(const TStroke *stroke,
Toshihiro Shimizu 890ddd
								const TPointD &vect,
Toshihiro Shimizu 890ddd
								double parameterOfNearest,
Toshihiro Shimizu 890ddd
								double lengthOfDeformation = 100,
Toshihiro Shimizu 890ddd
								double versus = 1.0);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	virtual ~TStrokeThicknessDeformation();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	TThickPoint getDisplacement(const TStroke &, double) const;
Toshihiro Shimizu 890ddd
	TThickPoint getDisplacementForControlPoint(const TStroke &stroke, UINT n) const;
Toshihiro Shimizu 890ddd
	TThickPoint getDisplacementForControlPointLen(const TStroke &stroke, double cpLen) const;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	double getDelta(const TStroke &, double) const;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	double getMaxDiff() const;
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
/*!
Toshihiro Shimizu 890ddd
  Manage the bending of a stroke.
Toshihiro Shimizu 890ddd
 */
Toshihiro Shimizu 890ddd
class DVAPI TStrokeBenderDeformation : public TStrokeDeformation
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
private:
Toshihiro Shimizu 890ddd
	const TStroke *m_pRef;
Toshihiro Shimizu 890ddd
	double m_startLength;
Toshihiro Shimizu 890ddd
	double m_lengthOfDeformation;
Toshihiro Shimizu 890ddd
	TPointD *m_vect;
Toshihiro Shimizu 890ddd
	int m_versus;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	double m_angle;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Toshihiro Shimizu 890ddd
	enum VERSUS {
Toshihiro Shimizu 890ddd
		INNER = 0,
Toshihiro Shimizu 890ddd
		OUTER
Toshihiro Shimizu 890ddd
	};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	/*!
Toshihiro Shimizu 890ddd
      Use this constructor with increasePoints.
Toshihiro Shimizu 890ddd
       \param stroke a refernce to a stroke
Toshihiro Shimizu 890ddd
       \param parameterOfNearest
Toshihiro Shimizu 890ddd
       \param lengthOfDeformation 
Toshihiro Shimizu 890ddd
     */
Toshihiro Shimizu 890ddd
	TStrokeBenderDeformation(const TStroke *stroke,
Toshihiro Shimizu 890ddd
							 double parameterOfNearest,
Toshihiro Shimizu 890ddd
							 double lengthOfDeformation = 50);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	/*!
Toshihiro Shimizu 890ddd
      Use this constructor with movePoints.
Toshihiro Shimizu 890ddd
     */
Toshihiro Shimizu 890ddd
	TStrokeBenderDeformation(const TStroke *stroke,
Toshihiro Shimizu 890ddd
							 const TPointD ¢erOfRot,
Toshihiro Shimizu 890ddd
							 double angle,
Toshihiro Shimizu 890ddd
							 double parameterOfNearest,
Toshihiro Shimizu 890ddd
							 int innerOrOuter = INNER,
Toshihiro Shimizu 890ddd
							 double lengthOfDeformation = 50);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	virtual ~TStrokeBenderDeformation();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	TThickPoint getDisplacement(const TStroke &, double s) const;
Toshihiro Shimizu 890ddd
	TThickPoint getDisplacementForControlPoint(const TStroke &, UINT n) const;
Toshihiro Shimizu 890ddd
	TThickPoint getDisplacementForControlPointLen(const TStroke &stroke, double cpLen) const;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	double getDelta(const TStroke &, double) const;
Toshihiro Shimizu 890ddd
	double getMaxDiff() const;
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
 */
Toshihiro Shimizu 890ddd
class DVAPI TStrokeTwirlDeformation : public TStrokeDeformation
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
private:
Toshihiro Shimizu 890ddd
	TPointD m_center;
Toshihiro Shimizu 890ddd
	double m_innerRadius2;
Toshihiro Shimizu 890ddd
	TPointD m_vectorOfMovement;
Toshihiro Shimizu 890ddd
	double m_outerRadius;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Toshihiro Shimizu 890ddd
	/*!
Toshihiro Shimizu 890ddd
      Use this constructor with increasePoints.
Toshihiro Shimizu 890ddd
       seg is the segment used to compute intersection .
Toshihiro Shimizu 890ddd
     */
Toshihiro Shimizu 890ddd
	TStrokeTwirlDeformation(const TPointD ¢er, double radius);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	TStrokeTwirlDeformation(const TPointD ¢er, double radius, const TPointD &v);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	virtual ~TStrokeTwirlDeformation();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	TThickPoint getDisplacement(const TStroke &, double s) const;
Toshihiro Shimizu 890ddd
	double getDelta(const TStroke &, double) const;
Toshihiro Shimizu 890ddd
	double getMaxDiff() const;
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
 */
Toshihiro Shimizu 890ddd
class DVAPI TPointDeformation
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	const TStroke *m_strokeRef;
Toshihiro Shimizu 890ddd
	TPointD m_center;
Toshihiro Shimizu 890ddd
	double m_radius;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	// return ratio density/length
Toshihiro Shimizu 890ddd
	double getCPDensity(double s) const;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Toshihiro Shimizu 890ddd
	TPointDeformation(const TStroke *, const TPointD &, double center);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	TPointDeformation();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	virtual ~TPointDeformation();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	TThickPoint getDisplacement(double s) const;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	// return integral of density in [s0,s1]
Toshihiro Shimizu 890ddd
	/*
Toshihiro Shimizu 890ddd
        / s1
Toshihiro Shimizu 890ddd
       |     density( s ) ds 
Toshihiro Shimizu 890ddd
      /
Toshihiro Shimizu 890ddd
       s0
Toshihiro Shimizu 890ddd
     */
Toshihiro Shimizu 890ddd
	double getCPCountInRange(double s0, double s1) const;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	// ritorna il valode di densita' sopra il quale aggiunge punti di controllo
Toshihiro Shimizu 890ddd
	double getMinCPDensity() const;
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#endif //TSTROKES_DEFORMATIONS_H