26CTextileAngleInterlock::CTextileAngleInterlock(
int iNumXYarns,
int iNumYYarns,
double dXSpacing,
double dYSpacing,
double dXHeight,
double dYHeight)
27:
CTextile3DWeave( iNumXYarns, iNumYYarns, dXSpacing, dYSpacing, dXHeight, dYHeight)
49 TGERROR(
"Unable to set binder position, index out of range: " << x <<
", " << y);
52 vector<PATTERN3D> &Cell =
GetCell(x, y);
53 int size = Cell.size();
55 int BinderPos = (size-1) - 2;
74 int size = Cell.size();
75 for (
int j = 0; j < size; j+=2 )
90 if ( iNumWarpLayers != iNumWeftLayers-1 )
92 TGERROR(
"Unable to set up layers, number of warp layers should be one less than weft layers: warp layers " << iNumWarpLayers <<
", weft layers " << iNumWeftLayers);
98 while( iNumWeftLayers > 0 )
101 if ( iNumWarpLayers > 0 )
126 TGERROR(
"Cannot build textile - incorrect yarn setup");
153 for (k=0; k<(int)Cell.size(); ++k)
167 for (k=0; k<(int)Cell.size(); ++k)
177 if ( (z - dHalfHeight) <
m_dMinZ )
184 dHalfHeight =
m_XYarnData[NextCellIndex].dHeight / 2.0;
249 for (k=0; k<(int)Cell.size(); ++k)
262 for (k=0; k<(int)Cell.size(); ++k)
319 vector<int>::iterator itpYarn;
320 double dWidth, dHeight;
328 for (itpYarn =
m_XYarns[i].begin(); itpYarn !=
m_XYarns[i].end(); ++itpYarn)
340 for (itpYarn =
m_YYarns[i].begin(); itpYarn !=
m_YYarns[i].end(); ++itpYarn)
351 vector<CYarn>::iterator itYarn;
356 itYarn->AddRepeat(
XYZ(dWidth, 0, 0));
357 itYarn->AddRepeat(
XYZ(0, dHeight, 0));
382 const vector<PATTERN3D> &Cell =
GetCell(i,j);
387 int iMaxIndex = Cell.size() - 1;
389 XYZ WeftBelowNode, WeftAboveNode;
390 int iStartNode = CurrentNode;
399 if ( BinderYarnIndex == -1 )
402 int WeftAboveIndex, WeftBelowIndex;
405 if ( iIndex < (
int)Cell.size() - 1 )
408 WeftAboveNode =
m_Yarns[WeftAboveIndex].GetNode( j )->GetPosition();
416 WeftBelowNode =
m_Yarns[WeftBelowIndex].GetNode( j )->GetPosition();
421 XYZ BinderNode =
m_Yarns[BinderYarnIndex].GetNode( CurrentNode )->GetPosition();
426 if ( YarnSection ==
NULL )
431 XYZ NewNode = WeftBelowNode;
435 if ( !( iIndex < iMaxIndex && NextCell[iIndex+2] ==
PATTERN3D_XYARN ) )
441 else if ( iIndex < iMaxIndex && PrevCell[iIndex+2] ==
PATTERN3D_XYARN )
445 if ( YarnSection ==
NULL )
449 XYZ NewNode = WeftAboveNode;
451 NewNode = WeftAboveNode;
460 if ( iStartNode == 0 )
462 XYZ NewNode =
m_Yarns[BinderYarnIndex].GetNode(0)->GetPosition();
471 if ( YarnSection ==
NULL )
475 XYZ NewNode = WeftBelowNode;
478 if ( !( iIndex < iMaxIndex && PrevCell[iIndex+2] ==
PATTERN3D_XYARN ) )
488 if ( YarnSection ==
NULL )
492 XYZ NewNode = WeftAboveNode;
508 int i = 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.
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
bool CheckCells() const
Check that all cells are populated.
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
virtual double GetWidth() const
Get the width of the unit cell.
void AddYLayers(int x, int iNumberLayers)
Add given number of yarns parallel to the Y axis, with given index x.
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
virtual void PopulateTiXmlElement(TiXmlElement &Element, OUTPUT_TYPE OutputType)
Used for saving data to XML.
void SetBinderYarnPositions(int x, int y)
void ShapeBinderYarns() const
Shape the binder yarns around the adjacent weft yarns.
CTextileAngleInterlock(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 FindBinderHeight(const vector< PATTERN3D > &Cell) const
void SetBinderPosition(int z, vector< PATTERN3D > &Cell)
virtual ~CTextileAngleInterlock(void)
virtual void SetupLayers(int iNumWarpLayers, int iNumWeftLayers, int iNumBinderLayers=1)
Find min and max z values for the textile.
int AddBinderNodes(int CurrentNode, int i, int j) const
Add extra nodes to binder yarns to match shape of adjacent weft yarns.
virtual bool BuildTextile() const
Build the textile.
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.
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.