28CTextileWeave2D::CTextileWeave2D(
int iWidth,
int iHeight,
double dSpacing,
double dThickness,
bool bRefine,
bool bInPlaneTangents )
31, m_bInPlaneTangents(bInPlaneTangents)
53 m_bRefine = valueify<bool>(Element.Attribute(
"Refine"));
68 TGERROR(
"Unable to swap positions, index out of range: " << x <<
", " << y);
71 vector<bool> &Cell =
GetCell(x, y);
72 assert(Cell.size() == 2);
96 XYZ PrevXPos, NextXPos;
97 XYZ PrevYPos, NextYPos;
102 double dWidth, dHeight;
103 int iPrevYarnx, iPrevYarny;
104 int iNextYarnx, iNextYarny;
108 int iNumYarns, iYarnLength;
113 for (iDirection=0; iDirection<2; ++iDirection)
131 for ( i = start; i < iNumYarns; ++i)
137 iPrevYarnx += iNumYarns;
139 iNextYarnx = (i+1)%iNumYarns;
158 iPrevYarny += iNumYarns;
160 iNextYarny = (i+1)%iNumYarns;
184 for (j=0; j<iYarnLength; ++j)
189 y = iPrevYarny = iNextYarny = j;
194 x = iPrevYarnx = iNextYarnx = j;
197 if (
GetCell(iPrevYarnx, iPrevYarny) ==
GetCell(iNextYarnx, iNextYarny))
222 delete EllipseSection;
264 vector<int>::iterator itpYarn;
265 vector<CNode>::iterator itNode;
269 for (itpYarn =
m_XYarns[i].begin(); itpYarn !=
m_XYarns[i].end(); ++itpYarn)
271 vector<CNode> MasterNodes =
m_Yarns[*itpYarn].GetMasterNodes();
272 for (itNode = MasterNodes.begin(); itNode != MasterNodes.end(); ++itNode)
274 itNode->SetTangent(
XYZ(1, 0, 0));
280 for (itpYarn =
m_YYarns[i].begin(); itpYarn !=
m_YYarns[i].end(); ++itpYarn)
282 vector<CNode> MasterNodes =
m_Yarns[*itpYarn].GetMasterNodes();
283 for (itNode = MasterNodes.begin(); itNode != MasterNodes.end(); ++itNode)
285 itNode->SetTangent(
XYZ(0, 1, 0));
558 timer.
start(
"Timing Refine");
560 if ( bCorrectWidths )
565 if ( bCorrectInterference )
570 if ( bCorrectInterference )
573 timer.
check(
"End of Refine");
581 if (
GetType() !=
"CTextileWeave2D" )
583 Refine( bCorrectWidths, bCorrectInterference, bPeriodic );
598 vector<int>::iterator itpYarn;
603 for (itpYarn =
m_XYarns[i].begin(); itpYarn !=
m_XYarns[i].end(); ++itpYarn)
610 for (itpYarn =
m_YYarns[i].begin(); itpYarn !=
m_YYarns[i].end(); ++itpYarn)
620 if ( Interpolation->
GetType() ==
"CInterpolationCubic" )
#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.
Domain implementation described using planes, the simplest of which would be a box.
Bezier interpolation for yarn paths.
Cubic spline interpolation for yarn paths.
Abstract base class for describing the yarn path interpolations.
virtual string GetType() const =0
Derived class should return the class name.
Represents a point on the centreline of a yarn.
void AddRow(string Row)
Add a row representing one weft insertion '1' indicates warp up, '0' warp down and '2' no yarn.
CSection * Copy() const
Create a copy of the derived section and return a pointer to the newly created instance.
virtual CSection * Copy() const =0
Create a copy of the derived section and return a pointer to the newly created instance.
virtual string GetType() const =0
Derived class should return the class name.
Section which represents a rotation of another section angle given in radians.
vector< CYarn > m_Yarns
Vector of yarns contained within this cell.
string GetName() const
Get the name associated with this textile.
bool m_bNeedsBuilding
Variable which keeps track of wether the textile needs building or not.
virtual CDomainPlanes GetDefaultDomain(bool bSheared=false, bool bAddedDomainHeight=true)
Get a domain which describes 6 planes triming the textile to a unit cell.
void SwapPosition(int x, int y)
Swap the cross over order of yarns at given index.
void ConvertToPatternDraft()
void SetInPlaneTangents(bool bInPlaneTangents=true) const
Function to set interpolation so that in-plane tangents are forced at master nodes.
string GetDefaultName() const
Get the default name to assign to a textile.
string GetType() const
Derived class should return the class name.
void RefineTextile(bool bCorrectWidths=true, bool bCorrectInterference=true, bool bPeriodic=true)
Refine the textile to eliminate interference.
bool BuildTextile() const
Build the textile.
CTextileWeave2D(int iWidth, int iHeight, double dSpacing, double dThickness, bool bRefine=true, bool bInPlaneTangents=true)
Build a 2d weave unit cell of given width, height, yarn spacing and fabric thickness.
virtual void Refine(bool bCorrectWidths=true, bool bCorrectInterference=true, bool bPeriodic=true) const
void PopulateTiXmlElement(TiXmlElement &Element, OUTPUT_TYPE OutputType)
Used for saving data to XML.
void AdjustTangents() const
virtual bool AdjustSectionsForRotation(bool bPeriodic=true) const
void SwapAll()
Swap the cross over order of all yarns.
Represents a woven textile.
virtual void CorrectInterference() const
Adjust cross section shapes to correct interference.
virtual CDomainPlanes GetDefaultDomain(bool bSheared=false, bool bAddedHeight=true)
Get a domain which describes 6 planes triming the textile to a unit cell.
double m_dFabricThickness
void CorrectYarnWidths() const
Adjust cross section widths to avoid interference.
CPatternDraft m_PatternDraft
Class for generating pattern draft from weave pattern.
virtual bool BuildTextile() const
Build the textile.
const vector< PATTERN2D > & GetCell(int x, int y) const
vector< vector< int > > m_XYarns
vector< vector< int > > m_YYarns
virtual void PopulateTiXmlElement(TiXmlElement &Element, OUTPUT_TYPE OutputType)
Used for saving data to XML.
vector< YARNDATA > m_XYarnData
vector< YARNDATA > m_YYarnData
Class used to meaure the amount of time it takes to perform a certain task.
void stop(const char *msg=0)
Stop the timer and print an optional message.
void check(const char *msg=0)
void start(const char *msg=0)
Represents a yarn consisting of master nodes, section and interpolation function.
void AssignSection(const CYarnSection &YarnSection)
Assign a section to the yarn.
const CYarnSection * GetYarnSection() const
virtual CYarnSection * Copy() const =0
This is a function to allow copying of derived classes correctly.
virtual string GetType() const =0
Derived class should return the class name.
Creates a section which is linearly interpolated between sections defined at the nodes.
void ReplaceSection(int iIndex, const CSection &Section)
Replace a section at a node.
const CSection & GetNodeSection(int iIndex) const
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.
Struct for representing points in 3D space.