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