26CTextileOffsetAngleInterlock::CTextileOffsetAngleInterlock(
int iNumXYarns,
int iNumYYarns,
double dXSpacing,
double dYSpacing,
double dXHeight,
double dYHeight)
27:
CTextile3DWeave( iNumXYarns, iNumYYarns*2, dXSpacing, dYSpacing, dXHeight, dYHeight)
49 TGERROR(
"Unable to set binder position, index out of range: " << x <<
", " << y);
55 TGERROR(
"Binder positions may only be set on top layer yarns");
58 vector<PATTERN3D> &Cell =
GetCell(x, y);
59 int size = (int)Cell.size();
61 int BinderPos = (size-1) - 1;
82 int size = (int)Cell.size();
83 for (
int j = 0; j < size; j++ )
124 int NextYCellIndex, NextXCellIndex;
131 for (
int k=0; k<(int)Cell.size(); ++k)
139 if ( (z - dHalfHeight) < dMinZ )
140 dMinZ = z - dHalfHeight;
165 if ( k != (
int)Cell.size()-1 )
178 if ( iNumWarpLayers != iNumWeftLayers-1 )
180 TGERROR(
"Unable to set up layers, number of warp layers should be one less than weft layers: warp layers " << iNumWarpLayers <<
", weft layers " << iNumWeftLayers);
186 while( iNumWeftLayers > 0 )
189 if ( iNumWarpLayers > 0 )
234 int NextYCellIndex, NextXCellIndex;
242 for (k=0; k<(int)Cell.size(); ++k)
256 for (k=0; k<(int)Cell.size(); ++k)
264 if ( (z - dHalfHeight) <
m_dMinZ )
269 dHalfHeight =
m_YYarnData[NextYCellIndex].dHeight / 2.0;
315 int NextYCellIndex, NextXCellIndex;
323 for (k=0; k<(int)Cell.size(); ++k)
336 for (k=0; k<(int)Cell.size(); ++k)
379 vector<int>::iterator itpYarn;
380 double dWidth, dHeight;
389 for (itpYarn =
m_XYarns[i].begin(); itpYarn !=
m_XYarns[i].end(); ++itpYarn)
402 for (itpYarn =
m_YYarns[i].begin(); itpYarn !=
m_YYarns[i].end(); ++itpYarn)
412 vector<CYarn>::iterator itYarn;
417 itYarn->AddRepeat(
XYZ(dWidth, 0, 0));
418 itYarn->AddRepeat(
XYZ(0, dHeight, 0));
443 const vector<PATTERN3D> &Cell =
GetCell(i,j);
445 int iMaxIndex = (int)Cell.size() - 1;
458 if ( BinderYarnIndex == -1 || WeftYarnIndex == -1 )
461 XYZ WeftNode =
m_Yarns[WeftYarnIndex].GetNode( j )->GetPosition();
462 XYZ BinderNode =
m_Yarns[BinderYarnIndex].GetNode( CurrentNode )->GetPosition();
466 if ( YarnSection ==
NULL )
471 XYZ NewNode = WeftNode;
473 SectionPoint = YarnSection->
GetPoint(0.45);
474 NewNode.
x = NewNode.
x + SectionPoint.
x;
475 NewNode.
z = NewNode.
z + SectionPoint.
y + dBinderOffset +
m_dGapSize;
477 m_Yarns[BinderYarnIndex].InsertNode( NewNode, CurrentNode);
479 if ( CurrentNode == 0 )
492 XYZ NewNode = WeftNode;
507 if ( BinderYarnIndex == -1 || WeftYarnIndex == -1 )
512 if ( YarnSection ==
NULL )
515 XYZ WeftNode =
m_Yarns[WeftYarnIndex].GetNode( j )->GetPosition();
516 XYZ BinderNode =
m_Yarns[BinderYarnIndex].GetNode( CurrentNode )->GetPosition();
520 XYZ NewNode = WeftNode;
521 SectionPoint = YarnSection->
GetPoint(0.55);
522 NewNode.
x = NewNode.
x + SectionPoint.
x;
523 NewNode.
z = NewNode.
z + SectionPoint.
y - dBinderOffset -
m_dGapSize;
524 m_Yarns[BinderYarnIndex].InsertNode( NewNode, CurrentNode);
526 if ( CurrentNode == 0 )
540 XYZ NewNode = WeftNode;
556 int i = (int)Cell.size() - 1;
#define TGLOGINDENT(MESSAGE)
Combines the TGLOG macro and TGLOGAUTOINDENT macro in one.
#define TGERROR(MESSAGE)
Macros used to report the file name and line number to the TexGenError and TexGenLog functions.
Bezier interpolation for yarn paths.
Represents a point on the centreline of a yarn.
void AssignSectionMesh(const CSectionMesh &SectionMesh)
Assign a mesh to the section.
XY GetPoint(double t) const
Get a point lying on the perimeter correspending to parametric value t.
Represents a 3D woven textile.
void AddNoYarnLayer()
Add empty layer.
void ReplaceLastNode(int BinderYarnIndex, XYZ &NewNode, XYZ &BinderNode) const
Replace last node with node offset to match node 0.
vector< YARNDATA > m_XYarnData
vector< vector< int > > m_XYarns
int GetYarnIndex(int x, int y, int z) const
void CheckUpVectors(int WarpIndex, bool Yarn=PATTERN3D_XYARN, bool bYarnsIndex=false) const
void AddYYarn(int x, PATTERN3D Pattern)
Add yarn of type XYARN or NOTYARN parallel to the Y axis.
bool Valid() const
Check that the weave pattern contained in m_Pattern is valid.
double GetHeight() const
Get the height of the unit cell.
CSectionPowerEllipse * GetWeftCrossSection(int WeftYarnIndex) const
Adjust cross section shapes to correct interference.
int FindNextCellIndex(int index) const
Find next cell in y direction which isn't a binder yarn.
bool IsBinderYarn(int index) const
Check if X yarn is binder or warp. Returns true if binder.
vector< YARNDATA > m_YYarnData
void AddBinderLayer()
Add yarns parallel to the X axis in binder yarn positions, no yarns in warp positions.
void AddWarpLayer()
Add yarns parallel to the X axis in warp yarn positions, no yarns in binder positions.
vector< vector< int > > m_YYarns
void InsertBinderNode(CSectionPowerEllipse *YarnSection, double t, XYZ &WeftNode, int &CurrentNode, int BinderYarnIndex, double Offset, bool bInsert=true) const
Calculates a point at given point on power ellipse cross section and inserts into binder yarn.
virtual void PopulateTiXmlElement(TiXmlElement &Element, OUTPUT_TYPE OutputType)
Used for saving data to XML.
const vector< PATTERN3D > & GetCell(int x, int y) const
CObjectContainer< CSectionMesh > m_pSectionMesh
vector< CYarn > m_Yarns
Vector of yarns contained within this cell.
string GetName() const
Get the name associated with this textile.
int AddYarn(const CYarn &Yarn)
Add a Yarn to the textile.
bool m_bNeedsBuilding
Variable which keeps track of wether the textile needs building or not.
virtual void FindMinMaxZ(double &dMinZ, double &dMaxZ)
Find min and max z values for the textile.
virtual ~CTextileOffsetAngleInterlock(void)
int FindBinderHeight(const vector< PATTERN3D > &Cell) const
void SetBinderPosition(int z, vector< PATTERN3D > &Cell)
virtual void PopulateTiXmlElement(TiXmlElement &Element, OUTPUT_TYPE OutputType)
Used for saving data to XML.
virtual double GetWidth() const
Get the width of the unit cell.
void SetBinderYarnPositions(int x, int y)
CTextileOffsetAngleInterlock(int iNumXYarns, int iNumYYarns, double dXSpacing, double dYSpacing, double dXHeight, double dYHeight)
Build a weave unit cell of given width, height, number of layers, yarn spacing and fabric thickness.
int AddBinderNodes(int CurrentNode, int i, int j) const
Add extra nodes to binder yarns to match shape of adjacent weft yarns.
void ShapeBinderYarns() const
Shape the binder yarns around the adjacent weft yarns.
virtual void SetupLayers(int iNumWarpLayers, int iNumWeftLayers, int iNumBinderLayers=1)
Setup the layers given a specified number of layers.
void AddYLayer(bool bOffset)
virtual bool BuildTextile() const
Build the textile.
Represents a yarn consisting of master nodes, section and interpolation function.
Creates a section which is constant all along the yarn.
Namespace containing a series of customised math operations not found in the standard c++ library.
Struct for representing points in 2D space.
Struct for representing points in 3D space.