26CTextileDeformer::CTextileDeformer(
void)
44 XYZ Pos, Disp, BestDisp;
46 double dAccuracy, dBestAccuracy;
47 vector<CSlaveNode>::const_iterator itNode;
48 vector<XYZ> Translations;
49 vector<XYZ>::iterator itTranslation;
63 for (itNode = Nodes.begin(); itNode != Nodes.end(); ++itNode)
66 for (itTranslation = Translations.begin(); itTranslation != Translations.end(); ++itTranslation)
68 dAccuracy =
GetDisplacement(itNode->GetPosition()+*itTranslation, i, NodeDisp);
69 if (itTranslation == Translations.begin() || dAccuracy>dBestAccuracy)
72 dBestAccuracy = dAccuracy;
73 BestDisp = NodeDisp-Adjust;
77 AdjustedInterp.
AddAdjustment(itNode->GetIndex(), itNode->GetT(), NodeDisp);
80 vector<pair<double, XY> > SectionAdjust;
81 const vector<XYZ> &SectionPoints = itNode->GetSectionPoints();
82 const int iSectionPoints = SectionPoints.size();
83 for (j=0; j<iSectionPoints; ++j)
85 double dU = j/double(iSectionPoints);
86 Pos = SectionPoints[j];
88 for (itTranslation = Translations.begin(); itTranslation != Translations.end(); ++itTranslation)
91 if (itTranslation == Translations.begin() || dAccuracy>dBestAccuracy)
94 dBestAccuracy = dAccuracy;
95 BestDisp = Disp-Adjust;
105 SectionAdjust.push_back(make_pair(dU, PlaneDisp));
107 if (!SectionAdjust.empty())
110 SectionAdjust.push_back(SectionAdjust.front());
111 SectionAdjust.back().first = 1.0;
112 AdjustedYarnSection.
AddAdjustment(itNode->GetIndex(), itNode->GetT(), SectionAdjust);
120 vector<XYZ>::iterator itRepeat;
121 for (itRepeat = Repeats.begin(); itRepeat != Repeats.end(); ++itRepeat)
141 string Name =
TEXGEN.AddTextile(*pCopy);
143 return TEXGEN.GetTextile(Name);
#define TEXGEN
Helper macro to get the texgen instance.
Abstract base class representing the domain in which a textile cell may lie.
virtual void Deform(CLinearTransformation Transformation)=0
Deform the domain by given linear transformation.
vector< XYZ > GetTranslations(const CYarn &Yarn) const
Get the translation vectors necessary to fully fill the domain.
Bezier interpolation for yarn paths.
void AddAdjustment(int iIndex, double t, XYZ Vector)
At given index and value t the position of the node should be adjusted by given vector.
void InitialiseIdentity(int iSize)
Represents a point on the centreline of a yarn.
virtual double GetDisplacement(XYZ Pos, int iYarn, XYZ &Disp) const =0
CTextile * GetDeformedCopyOfTextile(CTextile &Textile, bool bDeformDomain=true)
virtual void DeformTextile(CTextile &Textile, bool bDeformDomain=true)
virtual ~CTextileDeformer(void)
CLinearTransformation m_RepeatDeformation
Represents a textile cell containing yarns.
const CDomain * GetDomain() const
virtual CTextile * Copy() const
const CYarn * GetYarn(int iIndex) const
Represents a yarn consisting of master nodes, section and interpolation function.
const CInterpolation * GetInterpolation() const
void AssignInterpolation(const CInterpolation &Interpolation)
Assign an interpolation function to the yarn.
void SetRepeats(const vector< XYZ > &Repeats)
Set the repeat vectors.
void AssignSection(const CYarnSection &YarnSection)
Assign a section to the yarn.
const vector< CSlaveNode > & GetSlaveNodes(BUILD_TYPE Usage) const
Get the slave nodes and build them if necessary.
const CYarnSection * GetYarnSection() const
const vector< XYZ > & GetRepeats() const
Bezier interpolation for yarn paths.
void AddAdjustment(int iIndex, double t, const vector< pair< double, XY > > &SectionAdjust)
At given index and value t the position of the node should be adjusted by given vector.
Namespace containing a series of customised math operations not found in the standard c++ library.
double DotProduct(const XYZ &left, const XYZ &right)
Get the dot product of two vectors.
Struct for representing points in 2D space.
Struct for representing points in 3D space.