TexGen
TextileWeave2D.cpp
Go to the documentation of this file.
1/*=============================================================================
2TexGen: Geometric textile modeller.
3Copyright (C) 2006 Martin Sherburn
4
5This program is free software; you can redistribute it and/or
6modify it under the terms of the GNU General Public License
7as published by the Free Software Foundation; either version 2
8of the License, or (at your option) any later version.
9
10This program is distributed in the hope that it will be useful,
11but WITHOUT ANY WARRANTY; without even the implied warranty of
12MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13GNU General Public License for more details.
14
15You should have received a copy of the GNU General Public License
16along with this program; if not, write to the Free Software
17Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18=============================================================================*/
19
20#include "PrecompiledHeaders.h"
21#include "TextileWeave2D.h"
22#include "SectionEllipse.h"
23#include "SectionRotated.h"
24#include "PatternDraft.h"
25
26using namespace TexGen;
27
28CTextileWeave2D::CTextileWeave2D(int iWidth, int iHeight, double dSpacing, double dThickness, bool bRefine, bool bInPlaneTangents )
29: CTextileWeave(iWidth, iHeight, dSpacing, dThickness)
30, m_bRefine(bRefine)
31, m_bInPlaneTangents(bInPlaneTangents)
32{
33 vector<bool> Cell;
34 Cell.push_back(PATTERN_YYARN);
35 Cell.push_back(PATTERN_XYARN);
36 int i, j;
37 for (i=0; i<m_iNumYYarns; ++i)
38 {
39 for (j=0; j<m_iNumXYarns; ++j)
40 {
41 GetCell(i, j) = Cell;
42 }
43 }
44}
45
47{
48}
49
51: CTextileWeave(Element)
52{
53 m_bRefine = valueify<bool>(Element.Attribute("Refine"));
54 m_bInPlaneTangents = valueify<bool>(Element.Attribute("InPlaneTangents"));
55}
56
57void CTextileWeave2D::PopulateTiXmlElement(TiXmlElement &Element, OUTPUT_TYPE OutputType)
58{
59 CTextileWeave::PopulateTiXmlElement(Element, OutputType);
60 Element.SetAttribute("Refine", stringify(m_bRefine));
61 Element.SetAttribute("InPlaneTangents", stringify(m_bInPlaneTangents));
62}
63
65{
66 if (x<0 || x>=m_iNumYYarns || y<0 || y>=m_iNumXYarns)
67 {
68 TGERROR("Unable to swap positions, index out of range: " << x << ", " << y);
69 return;
70 }
71 vector<bool> &Cell = GetCell(x, y);
72 assert(Cell.size() == 2);
73 Cell[0] = !Cell[0];
74 Cell[1] = !Cell[1];
75 m_bNeedsBuilding = true;
76}
77
79{
80 int i, j;
81 for (i=0; i<m_iNumYYarns; ++i)
82 {
83 for (j=0; j<m_iNumXYarns; ++j)
84 {
85 SwapPosition(i, j);
86 }
87 }
88 m_bNeedsBuilding = true;
89}
90
92{
93 int i, j;
94
95 CYarn *pYarn;
96 XYZ PrevXPos, NextXPos;
97 XYZ PrevYPos, NextYPos;
98 XYZ Up;
99 CNode NewNode;
100
101 // Assign more adequate cross sections
102 double dWidth, dHeight;
103 int iPrevYarnx, iPrevYarny;
104 int iNextYarnx, iNextYarny;
105// int iNextCrossx, iNextCrossy;
106
107 double dAngle;
108 int iNumYarns, iYarnLength;
109 int iDirection;
110 int x, y;
111
112 // First loop for Y yarns, second loop for X yarns
113 for (iDirection=0; iDirection<2; ++iDirection)
114 {
115 if (iDirection==0)
116 {
117 iNumYarns = m_iNumYYarns;
118 iYarnLength = m_iNumXYarns;
119 }
120 else
121 {
122 iNumYarns = m_iNumXYarns;
123 iYarnLength = m_iNumYYarns;
124 }
125 int start = 0;
126 if ( !bPeriodic )
127 {
128 start = 1;
129 }
130
131 for ( i = start; i < iNumYarns; ++i)
132 {
133 if (iDirection==0)
134 {
135 iPrevYarnx = i-1;
136 if (iPrevYarnx < 0)
137 iPrevYarnx += iNumYarns;
138 if ( bPeriodic )
139 iNextYarnx = (i+1)%iNumYarns;
140 else
141 iNextYarnx = i+1; // Assumes that one extra node than number of yarns
142
143 // The angle is the maximum rotation angle to apply to the yarn at points where it needs
144 // rotating, specified in radians.
145 dAngle = atan2(0.5*m_dFabricThickness, m_YYarnData[iPrevYarnx].dSpacing+m_YYarnData[i].dSpacing);
146 // Get the yarn width and height for this X yarn
147 dWidth = m_YYarnData[i].dWidth;
148 dHeight = m_YYarnData[i].dHeight;
149 // Get a pointer to the current yarn
150 pYarn = &m_Yarns[m_YYarns[i][0]];
151 // Used for getting the cell coordinates
152 x = i;
153 }
154 else
155 {
156 iPrevYarny = i-1;
157 if (iPrevYarny < 0)
158 iPrevYarny += iNumYarns;
159 if ( bPeriodic )
160 iNextYarny = (i+1)%iNumYarns; // Assumes that one extra node than number of yarns
161 else
162 iNextYarny = i+1;
163
164 // The angle is the maximum rotation angle to apply to the yarn at points where it needs
165 // rotating, specified in radians.
166 dAngle = atan2(0.5*m_dFabricThickness, m_XYarnData[iPrevYarny].dSpacing+m_XYarnData[i].dSpacing);
167 // Get the yarn width and height for this X yarn
168 dWidth = m_XYarnData[i].dWidth;
169 dHeight = m_XYarnData[i].dHeight;
170 // Get a pointer to the current yarn
171 pYarn = &m_Yarns[m_XYarns[i][0]];
172 // Used for getting the cell coordinates
173 y = i;
174 }
175
176 CSectionEllipse DefaultEllipseSection(dWidth, dHeight);
177
178 // Get a copy of the yarn sections that is applied to the nodes
179 if (pYarn->GetYarnSection()->GetType() != "CYarnSectionInterpNode")
180 return false;
182// CYarnSectionInterpNode YarnSection(true, true);
183 int iRot; // Should have 1 of three values (-1, 0 or 1). -1 (rotation to the right), 0 (no rotation), 1 (rotation to the left)
184 for (j=0; j<iYarnLength; ++j)
185 {
186 if (iDirection==0)
187 {
188 // Set the parameters which will be used by GetCell for traversing an X yarn
189 y = iPrevYarny = iNextYarny = j;
190 }
191 else
192 {
193 // Set the parameters which will be used by GetCell for traversing a Y yarn
194 x = iPrevYarnx = iNextYarnx = j;
195 }
196 // If the yarns on either side are the same then no rotation should occur
197 if (GetCell(iPrevYarnx, iPrevYarny) == GetCell(iNextYarnx, iNextYarny))
198 iRot = 0;
199 else if (GetCell(iPrevYarnx, iPrevYarny)[0] == PATTERN_YYARN)
200 iRot = -1; // Rotate to the right
201 else
202 iRot = 1; // Rotate to the left
203
204 CSectionEllipse* EllipseSection = NULL;
205 if ( pYarnSection->GetNodeSection(j).GetType() == "CSectionEllipse" )
206 EllipseSection = (CSectionEllipse*)pYarnSection->GetNodeSection(j).Copy();
207 else
208 EllipseSection = (CSectionEllipse*)DefaultEllipseSection.Copy();
209 // Assign section based on the rotation it should have
210 switch (iRot)
211 {
212 case 0:
213// pYarnSection->ReplaceSection(j, EllipseSection);
214 break;
215 case -1:
216 pYarnSection->ReplaceSection(j, CSectionRotated(*EllipseSection, -dAngle));
217 break;
218 case 1:
219 pYarnSection->ReplaceSection(j, CSectionRotated(*EllipseSection, dAngle));
220 break;
221 }
222 delete EllipseSection;
223 }
224
225 // Assign the same section to the end as at the start (periodic yarns)
226 if ( bPeriodic )
227 pYarnSection->ReplaceSection(j, pYarnSection->GetNodeSection(0));
228
229/* // Now additional sections will be added between cross overs
230 for (j=0; j<iYarnLength; ++j)
231 {
232 if (iDirection == 0)
233 {
234 // Set the parameters which will be used by GetCell for traversing an X yarn
235 y = iPrevYarny = iNextYarny = j;
236 iNextCrossx = x;
237 iNextCrossy = (y+1)%iYarnLength;
238 }
239 else
240 {
241 // Set the parameters which will be used by GetCell for traversing a Y yarn
242 x = iPrevYarnx = iNextYarnx = j;
243 iNextCrossx = (x+1)%iYarnLength;
244 iNextCrossy = y;
245 }
246 // If the yarn is going from the top to the bottom or vice versa, an additional section
247 // is placed half way between the two
248 if (GetCell(x, y) != GetCell(iNextCrossx, iNextCrossy))
249 {
250 YarnSection.InsertSection(j, 0.5, EllipseSection);
251 }
252 }*/
253
254 pYarn->AssignSection(*pYarnSection);
255 delete pYarnSection;
256 }
257 }
258
259 return true;
260}
261
263{
264 vector<int>::iterator itpYarn;
265 vector<CNode>::iterator itNode;
266 int i;
267 for (i=0; i<m_iNumXYarns; ++i)
268 {
269 for (itpYarn = m_XYarns[i].begin(); itpYarn != m_XYarns[i].end(); ++itpYarn)
270 {
271 vector<CNode> MasterNodes = m_Yarns[*itpYarn].GetMasterNodes();
272 for (itNode = MasterNodes.begin(); itNode != MasterNodes.end(); ++itNode)
273 {
274 itNode->SetTangent(XYZ(1, 0, 0));
275 }
276 }
277 }
278 for (i=0; i<m_iNumYYarns; ++i)
279 {
280 for (itpYarn = m_YYarns[i].begin(); itpYarn != m_YYarns[i].end(); ++itpYarn)
281 {
282 vector<CNode> MasterNodes = m_Yarns[*itpYarn].GetMasterNodes();
283 for (itNode = MasterNodes.begin(); itNode != MasterNodes.end(); ++itNode)
284 {
285 itNode->SetTangent(XYZ(0, 1, 0));
286 }
287 }
288 }
289}
290
292{
294 return false;
295
297 return true;
298
299 // Set interpolation to force in-plane tangents at node if m_bInPlaneTangents set
300 if ( m_bInPlaneTangents )
303
304 if ( !m_bRefine )
305 return true;
306
307 TGLOGINDENT("Refining textile 2d weave \"" << GetName() << "\"");
308
309 Refine();
310
311 // TODO: Create a new function that modifies the cross sections (i.e. rotated ones)
312 // Just get the yarn section of the yarn, replace the sections at the nodes without
313 // touching the mid node sections
314
315 // TODO: Then call correct interference again...
316
317// AssignRotatedSections();
318
319// CorrectInterference();
320
321/*
322 int i, j;
323
324 CYarn *Yarn;
325 XYZ PrevXPos, NextXPos;
326 XYZ PrevYPos, NextYPos;
327 XYZ Up;
328 CNode NewNode;
329
330 // Assign more adequate cross sections
331 double dWidth, dHeight;
332 int iPrevYarnx, iPrevYarny;
333 int iNextYarnx, iNextYarny;
334 int iNextCrossx, iNextCrossy;
335 int iNextCrossPrevYarnx, iNextCrossPrevYarny;
336 int iNextCrossNextYarnx, iNextCrossNextYarny;
337
338 double dAngle;
339 int iNumYarns, iYarnLength;
340 int iDirection;
341 int x, y;
342 int iNodeNum;
343
344 // First loop for X yarns, second loop for Y yarns
345 for (iDirection=0; iDirection<2; ++iDirection)
346 {
347 if (iDirection==0)
348 {
349 iNumYarns = m_iNumYYarns;
350 iYarnLength = m_iNumXYarns;
351 }
352 else
353 {
354 iNumYarns = m_iNumXYarns;
355 iYarnLength = m_iNumYYarns;
356 }
357 for (i=0; i<iNumYarns; ++i)
358 {
359 if (iDirection==0)
360 {
361 iPrevYarnx = i-1;
362 if (iPrevYarnx < 0)
363 iPrevYarnx += iNumYarns;
364 iNextYarnx = (i+1)%iNumYarns;
365
366 // The angle is the maximum rotation angle to apply to the yarn at points where it needs
367 // rotating, specified in radians.
368 dAngle = atan2(0.5*m_dFabricThickness, m_YYarnData[iPrevYarnx].dSpacing+m_YYarnData[i].dSpacing);
369 // Get the yarn width and height for this X yarn
370 dWidth = m_YYarnData[i].dWidth;
371 dHeight = m_YYarnData[i].dHeight;
372 // Get a pointer to the current yarn
373 Yarn = &m_Yarns[m_YYarns[i][0]];
374 // Used for getting the cell coordinates
375 x = i;
376 }
377 else
378 {
379 iPrevYarny = i-1;
380 if (iPrevYarny < 0)
381 iPrevYarny += iNumYarns;
382 iNextYarny = (i+1)%iNumYarns;
383
384 // The angle is the maximum rotation angle to apply to the yarn at points where it needs
385 // rotating, specified in radians.
386 dAngle = atan2(0.5*m_dFabricThickness, m_XYarnData[iPrevYarny].dSpacing+m_XYarnData[i].dSpacing);
387 // Get the yarn width and height for this X yarn
388 dWidth = m_XYarnData[i].dWidth;
389 dHeight = m_XYarnData[i].dHeight;
390 // Get a pointer to the current yarn
391 Yarn = &m_Yarns[m_XYarns[i][0]];
392 // Used for getting the cell coordinates
393 y = i;
394 }
395
396 // Create the relevant sections that may be needed add different points along the yarn
397 // NonContact will be used at cross over points where the yarn is not likely to interfere
398 // with crossing yarn
399 CSectionScaled NonContact(*m_pNonContact, XY(dWidth, dHeight));
400
401 // Contact is used where the section is likely to interfere with crossing yarn
402 // and no rotation is required. Also used half way between cross over points.
403 CSectionScaled Contact(*m_pContact, XY(dWidth, dHeight));
404
405 // RotatedContact is used where the section is likely to interfere with crossing yarn
406 // and rotation is required
407 CSectionScaled RotatedContact(*m_pRotatedContact, XY(dWidth, dHeight));
408
409 // Build a yarn sections that will be applied to the nodes
410 CYarnSectionInterpNode YarnSection(true, true);
411 int iRot; // Should have 1 of three values (-1, 0 or 1). -1 (rotation to the right), 0 (no rotation), 1 (rotation to the left)
412 for (j=0; j<iYarnLength; ++j)
413 {
414 if (iDirection==0)
415 {
416 // Set the parameters which will be used by GetCell for traversing an X yarn
417 y = iPrevYarny = iNextYarny = j;
418 }
419 else
420 {
421 // Set the parameters which will be used by GetCell for traversing a Y yarn
422 x = iPrevYarnx = iNextYarnx = j;
423 }
424 // If the yarn pattern is the same on either side of the yarn at this cross over then no interference is likely
425 // to occur thus assign a neutral cross section
426 if (GetCell(iPrevYarnx, iPrevYarny) == GetCell(x, y) && GetCell(iNextYarnx, iNextYarny) == GetCell(x, y))
427 {
428 YarnSection.AddSection(NonContact);
429 }
430 else
431 {
432 // If the yarns on either side are the same then no rotation should occur
433 if (GetCell(iPrevYarnx, iPrevYarny) == GetCell(iNextYarnx, iNextYarny))
434 iRot = 0;
435 else if (GetCell(iPrevYarnx, iPrevYarny)[0] == false)
436 iRot = -1; // Rotate to the right
437 else
438 iRot = 1; // Rotate to the left
439 // Determine weither the yarn is above or bellow
440 if ((GetCell(x, y)[0] == true && iDirection == 0) ||
441 (GetCell(x, y)[0] == false && iDirection == 1))
442 {
443 // Assign section based on the rotation it should have
444 switch (iRot)
445 {
446 case 0:
447 YarnSection.AddSection(CSectionHybrid(NonContact, Contact));
448 break;
449 case -1:
450 YarnSection.AddSection(CSectionRotated(CSectionHybrid(NonContact, RotatedContact), -dAngle));
451 break;
452 case 1:
453 YarnSection.AddSection(CSectionRotated(CSectionHybrid(NonContact, RotatedContact), dAngle));
454 break;
455 }
456 }
457 else
458 {
459 // Assign section based on the rotation it should have
460 switch (iRot)
461 {
462 case 0:
463 YarnSection.AddSection(CSectionHybrid(Contact, NonContact));
464 break;
465 case -1:
466 YarnSection.AddSection(CSectionRotated(CSectionHybrid(RotatedContact, NonContact), -dAngle));
467 break;
468 case 1:
469 YarnSection.AddSection(CSectionRotated(CSectionHybrid(RotatedContact, NonContact), dAngle));
470 break;
471 }
472 }
473 }
474 }
475
476 // Assign the same section to the end as at the start (periodic yarns)
477 YarnSection.AddSection(YarnSection.GetSection(0));
478 iNodeNum = 0;
479
480 // Now additional nodes will be added between cross overs to ensure the path is
481 // the way we want it
482 for (j=0; j<iYarnLength; ++j)
483 {
484 if (iDirection == 0)
485 {
486 // Set the parameters which will be used by GetCell for traversing an X yarn
487 y = iPrevYarny = iNextYarny = j;
488 iNextCrossx = x;
489 iNextCrossy = (y+1)%iYarnLength;
490 iNextCrossPrevYarnx = iPrevYarnx;
491 iNextCrossPrevYarny = iNextCrossy;
492 iNextCrossNextYarnx = iNextYarnx;
493 iNextCrossNextYarny = iNextCrossy;
494 }
495 else
496 {
497 // Set the parameters which will be used by GetCell for traversing a Y yarn
498 x = iPrevYarnx = iNextYarnx = j;
499 iNextCrossx = (x+1)%iYarnLength;
500 iNextCrossy = y;
501 iNextCrossPrevYarnx = iNextCrossx;
502 iNextCrossPrevYarny = iPrevYarny;
503 iNextCrossNextYarnx = iNextCrossx;
504 iNextCrossNextYarny = iNextYarny;
505 }
506 // If the yarn is going from the top to the bottom or vice versa, an additional node
507 // is placed half way between the two to ensure the path passes through that point
508 // reducing the risk of interference between other yarns.
509 if (GetCell(x, y) != GetCell(iNextCrossx, iNextCrossy))
510 {
511 // Insert a node
512 CNode NewNode(0.5*(Yarn->GetMasterNodes()[iNodeNum].GetPosition() + Yarn->GetMasterNodes()[iNodeNum+1].GetPosition()));
513 Yarn->InsertNode(NewNode, ++iNodeNum);
514
515 // Decide what each quadrant of the section should look like based on the
516 // pattern around the cross over
517 CSection *pTopRight = &NonContact;
518 CSection *pTopLeft = &NonContact;
519 CSection *pBottomLeft = &NonContact;
520 CSection *pBottomRight = &NonContact;
521 if (GetCell(x, y) != GetCell(iNextYarnx, iNextYarny))
522 pTopRight = &Contact;
523 if (GetCell(x, y) != GetCell(iPrevYarnx, iPrevYarny))
524 pTopLeft = &Contact;
525 if (GetCell(iNextCrossx, iNextCrossy) != GetCell(iNextCrossPrevYarnx, iNextCrossPrevYarny))
526 pBottomLeft = &Contact;
527 if (GetCell(iNextCrossx, iNextCrossy) != GetCell(iNextCrossNextYarnx, iNextCrossNextYarny))
528 pBottomRight = &Contact;
529 // Swap the upper and lower parts of the section
530 if ((GetCell(x, y)[0] == true && iDirection == 0) ||
531 (GetCell(x, y)[0] == false && iDirection == 1))
532 {
533 swap(pTopRight, pBottomRight);
534 swap(pTopLeft, pBottomLeft);
535 }
536 // Swap the side parts of the section
537 if (iDirection == 1)
538 {
539 swap(pTopRight, pTopLeft);
540 swap(pBottomRight, pBottomLeft);
541 }
542
543 CSectionHybrid Switch(*pTopRight, *pTopLeft, *pBottomLeft, *pBottomRight);
544 YarnSection.InsertSection(iNodeNum, Switch);
545 }
546 ++iNodeNum;
547 }
548 Yarn->AssignSection(YarnSection);
549 }
550 }
551*/
552 return true;
553}
554
555void CTextileWeave2D::Refine( bool bCorrectWidths, bool bCorrectInterference, bool bPeriodic ) const
556{
557 CTimer timer;
558 timer.start("Timing Refine");
559
560 if ( bCorrectWidths )
561 {
563 }
564
565 if ( bCorrectInterference )
567
568 AdjustSectionsForRotation( bPeriodic );
569
570 if ( bCorrectInterference )
572
573 timer.check("End of Refine");
574 timer.stop();
575}
576
577
578void CTextileWeave2D::RefineTextile( bool bCorrectWidths, bool bCorrectInterference, bool bPeriodic )
579{
580 //BuildTextileIfNeeded();
581 if ( GetType() != "CTextileWeave2D" )
582 return;
583 Refine( bCorrectWidths, bCorrectInterference, bPeriodic );
584 //m_bNeedsBuilding = true;
585}
586
587
588
590{
591 return "2DWeave(W:" + stringify(m_iNumYYarns) + ",H:" + stringify(m_iNumXYarns) + ")";
592}
593
594
596void CTextileWeave2D::SetInPlaneTangents( bool bInPlaneTangents ) const
597{
598 vector<int>::iterator itpYarn;
599
600 int i;
601 for (i=0; i<m_iNumXYarns; ++i)
602 {
603 for (itpYarn = m_XYarns[i].begin(); itpYarn != m_XYarns[i].end(); ++itpYarn)
604 {
605 SetInPlaneTangents(*itpYarn, bInPlaneTangents );
606 }
607 }
608 for (i=0; i<m_iNumYYarns; ++i)
609 {
610 for (itpYarn = m_YYarns[i].begin(); itpYarn != m_YYarns[i].end(); ++itpYarn)
611 {
612 SetInPlaneTangents(*itpYarn, bInPlaneTangents );
613 }
614 }
615}
616
617void CTextileWeave2D::SetInPlaneTangents( int Yarn, bool bInPlaneTangents ) const
618{
619 const CInterpolation* Interpolation = m_Yarns[Yarn].GetInterpolation();
620 if ( Interpolation->GetType() == "CInterpolationCubic" )
621 {
622 m_Yarns[Yarn].AssignInterpolation(CInterpolationCubic( true, false, bInPlaneTangents ));
623 }
624 else
625 {
626 m_Yarns[Yarn].AssignInterpolation(CInterpolationBezier( true, false, bInPlaneTangents ));
627 }
628}
629
630CDomainPlanes CTextileWeave2D::GetDefaultDomain( bool bSheared, bool bAddedDomainHeight )
631{
632 return CTextileWeave::GetDefaultDomain( bSheared, bAddedDomainHeight );
633}
634
635
636void CTextileWeave2D::ConvertToPatternDraft( /*CPatternDraft& PatternDraft*/ )
637{
639 for ( int i = m_iNumYYarns-1; i >=0; --i )
640 {
641 string Row;
642 for ( int j = m_iNumXYarns-1; j >= 0 ; --j )
643 {
644 if ( GetCell(i,j)[1] == PATTERN_XYARN )
645 Row.push_back('1');
646 else
647 Row.push_back('0');
648 }
649 m_PatternDraft.AddRow( Row );
650 }
651}
#define TGLOGINDENT(MESSAGE)
Combines the TGLOG macro and TGLOGAUTOINDENT macro in one.
Definition: Logger.h:68
#define TGERROR(MESSAGE)
Macros used to report the file name and line number to the TexGenError and TexGenLog functions.
Definition: Logger.h:29
#define NULL
Definition: ShinyConfig.h:50
Domain implementation described using planes, the simplest of which would be a box.
Definition: DomainPlanes.h:37
Bezier interpolation for yarn paths.
Cubic spline interpolation for yarn paths.
Abstract base class for describing the yarn path interpolations.
Definition: Interpolation.h:33
virtual string GetType() const =0
Derived class should return the class name.
Represents a point on the centreline of a yarn.
Definition: Node.h:28
void AddRow(string Row)
Add a row representing one weft insertion '1' indicates warp up, '0' warp down and '2' no yarn.
Elliptical Section.
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.
Definition: Textile.h:323
string GetName() const
Get the name associated with this textile.
Definition: Textile.cpp:355
bool m_bNeedsBuilding
Variable which keeps track of wether the textile needs building or not.
Definition: Textile.h:330
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 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.
virtual bool AdjustSectionsForRotation(bool bPeriodic=true) const
void SwapAll()
Swap the cross over order of all yarns.
Represents a woven textile.
Definition: TextileWeave.h:41
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.
void CorrectYarnWidths() const
Adjust cross section widths to avoid interference.
CPatternDraft m_PatternDraft
Class for generating pattern draft from weave pattern.
Definition: TextileWeave.h:203
virtual bool BuildTextile() const
Build the textile.
const vector< PATTERN2D > & GetCell(int x, int y) const
vector< vector< int > > m_XYarns
Definition: TextileWeave.h:225
vector< vector< int > > m_YYarns
Definition: TextileWeave.h:226
virtual void PopulateTiXmlElement(TiXmlElement &Element, OUTPUT_TYPE OutputType)
Used for saving data to XML.
vector< YARNDATA > m_XYarnData
Definition: TextileWeave.h:223
vector< YARNDATA > m_YYarnData
Definition: TextileWeave.h:224
Class used to meaure the amount of time it takes to perform a certain task.
Definition: Timer.h:12
void stop(const char *msg=0)
Stop the timer and print an optional message.
Definition: Timer.h:86
void check(const char *msg=0)
Definition: Timer.h:96
void start(const char *msg=0)
Definition: Timer.h:57
Represents a yarn consisting of master nodes, section and interpolation function.
Definition: Yarn.h:49
void AssignSection(const CYarnSection &YarnSection)
Assign a section to the yarn.
Definition: Yarn.cpp:649
const CYarnSection * GetYarnSection() const
Definition: Yarn.h:449
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.
@ PATTERN_XYARN
Definition: TextileWeave.h:33
@ PATTERN_YYARN
Definition: TextileWeave.h:34
OUTPUT_TYPE
Definition: Misc.h:105
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.
Definition: Misc.h:50
Struct for representing points in 3D space.
Definition: mymath.h:56