25CYarnSectionAdjusted::CYarnSectionAdjusted(
const CYarnSection &YarnSection)
26: m_pYarnSection(YarnSection)
39 vector<pair<double, SECTION_ADJUST> > Adjustments;
43 pAdjustmentSection->Attribute(
"T", &Adjustment.first);
46 pair<double, XY> AdjustmentPerimeter(0.0,
XY());
47 pAdjustmentPerimeter->Attribute(
"T", &AdjustmentPerimeter.first);
48 AdjustmentPerimeter.second = valueify<XY>(pAdjustmentPerimeter->Attribute(
"Vector"));
49 Adjustment.second.push_back(AdjustmentPerimeter);
51 Adjustments.push_back(Adjustment);
55 TiXmlElement* pYarnSection = Element.FirstChildElement(
"YarnSection");
66 TiXmlElement Adjustment(
"Adjustment");
67 Adjustment.SetAttribute(
"index", i);
70 TiXmlElement AdjustmentSection(
"AdjustmentSection");
74 TiXmlElement AdjustmentPerimeter(
"AdjustmentPerimeter");
77 AdjustmentSection.InsertEndChild(AdjustmentPerimeter);
79 Adjustment.InsertEndChild(AdjustmentSection);
81 Element.InsertEndChild(Adjustment);
83 TiXmlElement YarnSection(
"YarnSection");
85 Element.InsertEndChild(YarnSection);
90 vector<XY> SectionPoints =
m_pYarnSection->GetSection(PositionInfo, iNumPoints, bEquiSpaced);
94 TGERROR(
"Unable to adjust section. Index out of range: " << PositionInfo.
iSection);
98 pair<double, pair<SECTION_ADJUST, SECTION_ADJUST> > ClosestVals =
101 XY Disp, Disp1, Disp2;
102 vector<XY>::iterator itSecPt;
103 assert((
int)SectionPoints.size() == iNumPoints);
105 for (itSecPt = SectionPoints.begin(), i=0; itSecPt != SectionPoints.end(); ++itSecPt, ++i)
107 double dU = i/double(iNumPoints);
110 Disp = Disp1 + ClosestVals.first * (Disp2-Disp1);
114 return SectionPoints;
119 return m_pYarnSection->GetSectionMesh(PositionInfo, iNumPoints, bEquiSpaced);
126 TGERROR(
"Unable to add adjustment. Index out of range: " << iIndex);
133 m_Adjustments[iIndex].push_back(make_pair(t, SectionAdjust));
#define TGERROR(MESSAGE)
Macros used to report the file name and line number to the TexGenError and TexGenLog functions.
#define FOR_EACH_TIXMLELEMENT(CHILDELEMENT, PARENTELEMENT, ELEMENTNAME)
Macro to enable looping over tinyxml easier.
Defines the nodes and elements of a surface or volume mesh.
YARN_ADJUST m_Adjustments
Represents the adjustements to the interpolation.
~CYarnSectionAdjusted(void)
vector< pair< double, XY > > SECTION_ADJUST
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.
CMesh GetSectionMesh(const YARN_POSITION_INFORMATION PositionInfo, int iNumPoints, bool bEquiSpaced) const
This function must be implemented by derived classes.
CYarnSectionAdjusted(const CYarnSection &YarnSection)
vector< XY > GetSection(const YARN_POSITION_INFORMATION PositionInfo, int iNumPoints, bool bEquiSpaced=false) const
This function must be implemented by derived classes.
CObjectContainer< CYarnSection > m_pYarnSection
void PopulateTiXmlElement(TiXmlElement &Element, OUTPUT_TYPE OutputType) const
Used for saving data to XML.
Abstract base class used to define the sections along the length of a yarn.
virtual void PopulateTiXmlElement(TiXmlElement &Element, OUTPUT_TYPE OutputType) const
Used for saving data to XML.
static CObjectContainer< CYarnSection > CreateYarnSection(TiXmlElement &Element)
Create a yarn section from TiXmlElement.
Namespace containing a series of customised math operations not found in the standard c++ library.
std::pair< double, std::pair< T, T > > GetClosestValues(const std::vector< std::pair< double, T > > &InterpValues, double fraction)
Get the two closest values to fraction in the vector InterpValues.
T GetInterpedValue(const std::vector< std::pair< double, T > > &InterpValues, double fraction)
Get an interpolated value.
std::string stringify(const T &x, int iPrecision=12, bool bScientific=true)
Function to convert a value (e.g. int, double, etc...) to a string.
Struct for representing points in 2D space.
Structure used to represent the position along the length of a yarn.
double dSectionPosition
This variables varies linearly with distance from 0 to 1 from the start to the end of the current lin...
int iSection
This variable represents the index of the current section (where a section is defined as the part bet...