26CYarnSectionInterpNode::CYarnSectionInterpNode(
bool bRamped,
bool bPolar,
bool bConstMesh)
41 TiXmlElement* pSection = pNodeSection->FirstChildElement(
"Section");
50 pSection = pMidNodeSection->FirstChildElement(
"Section");
54 valueify<double>(pMidNodeSection->Attribute(
"t")),
71 TiXmlElement NodeSection(
"NodeSection");
72 NodeSection.SetAttribute(
"nodeindex", i);
73 TiXmlElement Section(
"Section");
74 m_Sections[i]->PopulateTiXmlElement(Section, OutputType);
75 NodeSection.InsertEndChild(Section);
80 TiXmlElement MidSideNode(
"MidNodeSection");
81 MidSideNode.SetAttribute(
"nodeindex", i);
83 TiXmlElement MidSection(
"Section");
85 MidSideNode.InsertEndChild(MidSection);
86 NodeSection.InsertEndChild(MidSideNode);
89 Element.InsertEndChild(NodeSection);
98 TGERROR(
"Unable to get section, the number of sections specified (" <<
m_Sections.size() <<
") is not equal to the number of nodes (" << PositionInfo.
SectionLengths.size()+1 <<
")");
103 const CSection *pSection1, *pSection2;
118 TGERROR(
"Unable to get section mesh, the number of sections specified (" <<
m_Sections.size() <<
") is not equal to the number of nodes (" << PositionInfo.
SectionLengths.size()+1 <<
")");
123 const CSection *pSection1, *pSection2;
141 if (iIndex < 0 || iIndex >= (
int)
m_Sections.size())
143 TGERROR(
"Unable to insert section, index out of range " << iIndex);
154 TGERROR(
"Unable to insert section, index out of range " << iIndex);
163 if (iIndex < 0 || iIndex >= (
int)
m_Sections.size())
165 TGERROR(
"Unable to replace section, index out of range " << iIndex);
173 assert(iIndex >= 0 && iIndex < (
int)
m_Sections.size());
195 vector<pair<double, CObjectContainer<CSection> > >::const_iterator itSection;
196 int iMidSection1 = -1, iMidSection2 = -1;
206 u1 = itSection->first;
211 u2 = itSection->first;
215 if (iMidSection1 != -1 && iMidSection2 != -1)
221 else if (iMidSection1 != -1)
226 else if (iMidSection2 != -1)
240 int iMaxLayers = iNumLayers;
243 if ( iNumLayers != -1 )
246 for ( i = 1; i < iNumSections; ++i )
258 if ( i == iNumSections )
263 for (
int i = 0; i < iNumSections; ++i )
267 if ( iNumLayers > iMaxLayers )
268 iMaxLayers = iNumLayers;
270 if ( i < iNumSections-1 )
275 if ( iNumLayers > iMaxLayers )
276 iMaxLayers = iNumLayers;
280 if ( iMaxLayers != -1 )
282 for (
int i = 0; i < (int)
m_Sections.size(); ++i )
288 if ( i < iNumSections-1 )
304 if (iIndex < 0 || iIndex >= (
int)
m_Sections.size())
306 TGERROR(
"Unable to delete section, index out of range " << iIndex);
315 if ( iIndex < 0 || iIndex >= (
int)
m_Sections.size())
317 TGERROR(
"Unable to get number of mid node sections, index out of range " << iIndex );
325 assert(iNodeIndex >= 0 && iNodeIndex < (
int)
m_Sections.size());
333 if (iNodeIndex < 0 || iNodeIndex >= (
int)
m_Sections.size())
335 TGERROR(
"Unable to replace mid section, index out of range " << iNodeIndex);
340 TGERROR(
"Unable to replace mid section, mid index out of range " << iIndex);
#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.
Object container to help handle memory management issues.
Abstract base class respresenting a yarn cross-section.
static CObjectContainer< CSection > CreateSection(TiXmlElement &Element)
Create a section from TiXmlElement.
void SetSectionMeshLayers(int iNum)
Specify number of layers for associated section mesh.
int GetSectionMeshLayers()
Get the number of layers for associated section mesh.
Abstract base class to handle interpolation for derived classes.
virtual void PopulateTiXmlElement(TiXmlElement &Element, OUTPUT_TYPE OutputType) const
Used for saving data to XML.
int CalculateNumberofLayers(const vector< XY > &Section) const
bool GetInterpedSection(const CSection &Section1, const CSection &Section2, double u, int iNumPoints, bool bEquiSpaced, vector< XY > &Points) const
bool GetInterpedSectionMesh(const CSection &Section1, const CSection &Section2, double u, int iNumPoints, bool bEquiSpaced, CMesh &Mesh) const
void ReplaceMidSection(int iNodeIndex, int iIndex, const CSection &Section)
Replace a mid node section.
double GetMidNodeSectionPos(int iNodeIndex, int iIndex) const
void ReplaceSection(int iIndex, const CSection &Section)
Replace a section at a node.
void AddSection(const CSection &Section)
Add a section at a node.
~CYarnSectionInterpNode(void)
CMesh GetSectionMesh(const YARN_POSITION_INFORMATION PositionInfo, int iNumPoints, bool bEquiSpaced) const
This function must be implemented by derived classes.
void GetSectionsToInterp(const YARN_POSITION_INFORMATION PositionInfo, const CSection *&pSection1, const CSection *&pSection2, double &u) const
vector< vector< pair< double, CObjectContainer< CSection > > > > m_MidNodeSections
const CSection & GetNodeSection(int iIndex) const
vector< CObjectContainer< CSection > > m_Sections
void InsertSection(int iIndex, const CSection &Section)
Insert a section at a node.
vector< XY > GetSection(const YARN_POSITION_INFORMATION PositionInfo, int iNumPoints, bool bEquiSpaced=false) const
This function must be implemented by derived classes.
void DeleteSection(int iIndex)
Delete a section at a node.
void PopulateTiXmlElement(TiXmlElement &Element, OUTPUT_TYPE OutputType) const
Used for saving data to XML.
int GetNumMidNodeSections(int iIndex) const
CYarnSectionInterpNode(bool bRamped=true, bool bPolar=false, bool bConstMesh=true)
void SetSectionMeshLayersEqual(int iNumPoints) const
Function to set the number of layers equal for all sections in a given yarn.
Namespace containing a series of customised math operations not found in the standard c++ library.
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.
Used to sort double-objectref pairs.
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...
vector< double > SectionLengths
This contains a list of lengths representing the length of each section.