TexGen
Textile.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 "Textile.h"
22#include "Domain.h"
23#include "TexGen.h"
24
25using namespace TexGen;
26
27#define TOL 1e-10
28
29CTextile::CTextile(void)
30: m_bNeedsBuilding(true)
31{
32}
33
34CTextile::CTextile(const vector<CYarn> &Yarns)
35: m_Yarns(Yarns.size())
36{
37 copy(Yarns.begin(), Yarns.end(), m_Yarns.begin());
38}
39
41: CPropertiesTextile(CopyMe)
42{
43 *this = CopyMe;
44}
45
47{
48}
49
51{
52 m_Yarns = CopyMe.m_Yarns;
54 m_pDomain = CopyMe.m_pDomain;
55
56 // Yarns need to be reparented
57 vector<CYarn>::iterator itYarn;
58 for (itYarn = m_Yarns.begin(); itYarn != m_Yarns.end(); ++itYarn)
59 {
60 itYarn->SetParent(this);
61 }
62 return *this;
63}
64
65CTextile::CTextile(TiXmlElement &Element)
66:CPropertiesTextile(Element),m_bNeedsBuilding(true)
67{
68 TiXmlElement* pDomain = Element.FirstChildElement("Domain");
69 if (pDomain)
70 {
71 const string* pType = pDomain->Attribute(string("type"));
72 if (pType)
73 {
74 if (*pType == "CDomainPlanes")
75 m_pDomain = CDomainPlanes(*pDomain);
76 else if (*pType == "CDomainPrism")
77 m_pDomain = CDomainPrism(*pDomain);
78 }
79 }
80 m_bNeedsBuilding = valueify<bool>(Element.Attribute("NeedsBuilding"));
81 FOR_EACH_TIXMLELEMENT(pYarn, Element, "Yarn")
82 {
83 AddYarn(CYarn(*pYarn));
84 }
85}
86
87void CTextile::PopulateTiXmlElement(TiXmlElement &Element, OUTPUT_TYPE OutputType)
88{
90
91 Element.SetAttribute("type", GetType());
92
93 if (m_pDomain)
94 {
95 TiXmlElement Domain("Domain");
96 m_pDomain->PopulateTiXmlElement(Domain, OutputType);
97 Element.InsertEndChild(Domain);
98 }
99
100 // Output the yarns if minimal output hasn't been selected or
101 // if this instance of the textile is not derived from (otherwise
102 // the output file will be useless)
103 if (OutputType != OUTPUT_MINIMAL || GetType() == "CTextile")
104 {
105 Element.SetAttribute("NeedsBuilding", 0);
107 int i;
108 for (i=0; i<(int)m_Yarns.size(); ++i)
109 {
110 TiXmlElement Yarn("Yarn");
111 Yarn.SetAttribute("index", i);
112 m_Yarns[i].PopulateTiXmlElement(Yarn, OutputType);
113 Element.InsertEndChild(Yarn);
114 }
115 }
116 else
117 {
118 Element.SetAttribute("NeedsBuilding", 1);
119 }
120}
121
122int CTextile::AddYarn(const CYarn &Yarn)
123{
124 // This call may result in the CYarn copy constructor being invoked
125 // This is not effecient but more importantly all the parent pointers
126 // are reset to NULL
127 m_Yarns.push_back(Yarn);
128 // Make sure the parent pointers are reset correctly
129 vector<CYarn>::iterator itYarn;
130 for (itYarn = m_Yarns.begin(); itYarn != m_Yarns.end(); ++itYarn)
131 {
132 itYarn->SetParent(this);
133 }
134 return m_Yarns.size()-1;
135}
136
137int CTextile::AddYarn(const CYarn &Yarn) const
138{
139 // This call may result in the CYarn copy constructor being invoked
140 // This is not effecient but more importantly all the parent pointers
141 // are reset to NULL
142 m_Yarns.push_back(Yarn);
143 // Make sure the parent pointers are reset correctly
144 vector<CYarn>::iterator itYarn;
145 for (itYarn = m_Yarns.begin(); itYarn != m_Yarns.end(); ++itYarn)
146 {
147 itYarn->SetParent(this);
148 }
149 return m_Yarns.size()-1;
150}
151
152bool CTextile::DeleteYarn(int iIndex)
153{
154 if (iIndex < 0 || iIndex >= (int)m_Yarns.size())
155 return false;
156 m_Yarns.erase(m_Yarns.begin()+iIndex);
157 return true;
158}
159
161{
162 m_Yarns.clear();
163}
164
166{
168 return;
169 vector<CYarn>::iterator itYarn;
170 for (itYarn = m_Yarns.begin(); itYarn != m_Yarns.end(); ++itYarn)
171 {
172 itYarn->AddNodesToMesh(Mesh);
173 }
174}
175
177{
179 return;
180 vector<CYarn>::iterator itYarn;
181 for (itYarn = m_Yarns.begin(); itYarn != m_Yarns.end(); ++itYarn)
182 {
183 itYarn->AddPathToMesh(Mesh);
184 }
185}
186
187void CTextile::AddSurfaceToMesh(CMesh &Mesh, bool bTrimToDomain)
188{
190 return;
191 vector<CYarn>::iterator itYarn;
192 for (itYarn = m_Yarns.begin(); itYarn != m_Yarns.end(); ++itYarn)
193 {
194 if (bTrimToDomain && m_pDomain)
195 itYarn->AddSurfaceToMesh(Mesh, *m_pDomain);
196 else
197 itYarn->AddSurfaceToMesh(Mesh);
198 }
199}
200
201bool CTextile::AddSurfaceToMesh(CMesh &Mesh, vector<CMesh> &DomainMeshes, bool bTrimToDomain)
202{
204 return false;
205 if ( !m_pDomain )
206 {
207 TGERROR("Textile has no domain assigned");
208 return false;
209 }
210 CMesh DomainMesh;
211
212 if (m_pDomain->GetType() != "CDomainPrism")
213 {
214 DomainMesh = m_pDomain->GetMesh();
215 // For the most part domain will be box in which case want the quad elements not the tris
216 DomainMesh.ConvertTriToQuad();
217 }
218 else
219 {
220 m_pDomain->GetPrismDomain()->GetMeshWithPolygonEnd( DomainMesh );
221 }
222
223 list<int>::const_iterator itIter;
224 int iNumNodes;
225
226 // Save each domain face as separate mesh & add to DomainMeshes vector
227 for ( int i = 0; i < CMesh::NUM_ELEMENT_TYPES; ++i)
228 {
229 const list<int> &Indices = DomainMesh.GetIndices((CMesh::ELEMENT_TYPE)i);
231 if (i != CMesh::POLYGON)
232 {
233 for (itIter = Indices.begin(); itIter != Indices.end(); )
234 {
235
236 CMesh FaceMesh;
237 vector<int> index;
238 for ( int j = 0; j < iNumNodes; ++j )
239 {
240 FaceMesh.AddNode( DomainMesh.GetNode(*(itIter++)));
241 index.push_back(j);
242 }
243 FaceMesh.AddElement( (CMesh::ELEMENT_TYPE)i, index );
244 DomainMeshes.push_back(FaceMesh);
245 }
246 }
247 else
248 {
249 int StartIndex;
250 for (itIter = Indices.begin(); itIter != Indices.end(); )
251 {
252 StartIndex = *itIter;
253 CMesh FaceMesh;
254 vector<int> index;
255 int j = 0;
256 do
257 {
258 FaceMesh.AddNode(DomainMesh.GetNode(*(itIter++)));
259 //index.push_back(*(itIter++));
260 index.push_back(j);
261 j++;
262 } while (*itIter != StartIndex);
263
264 FaceMesh.AddNode(DomainMesh.GetNode(*(itIter++)));
265 index.push_back(0);
266
267 FaceMesh.AddElement((CMesh::ELEMENT_TYPE)i, index);
268 DomainMeshes.push_back(FaceMesh);
269 }
270 }
271 }
272
273 vector<CYarn>::iterator itYarn;
274 for (itYarn = m_Yarns.begin(); itYarn != m_Yarns.end(); ++itYarn)
275 {
276 if (bTrimToDomain && m_pDomain)
277 {
278 if ( !itYarn->AddSurfaceToMesh(Mesh, *m_pDomain, DomainMeshes ) )
279 return false;
280 }
281 else
282 itYarn->AddSurfaceToMesh(Mesh);
283 }
284 return true;
285}
286
287void CTextile::AddVolumeToMesh(CMesh &Mesh, bool bTrimToDomain)
288{
290 return;
291 vector<CYarn>::iterator itYarn;
292 for (itYarn = m_Yarns.begin(); itYarn != m_Yarns.end(); ++itYarn)
293 {
294 if (bTrimToDomain && m_pDomain)
295 itYarn->AddVolumeToMesh(Mesh, *m_pDomain);
296 else
297 itYarn->AddVolumeToMesh(Mesh);
298 }
299}
300
301void CTextile::AddVolumeToMesh(vector<CMesh> &Mesh, bool bTrimToDomain)
302{
304 return;
305 Mesh.clear();
306 Mesh.resize(m_Yarns.size());
307
308 vector<CYarn>::iterator itYarn;
309 int i = 0;
310 for (itYarn = m_Yarns.begin(), i = 0; itYarn != m_Yarns.end(); ++itYarn, ++i)
311 {
312 if (bTrimToDomain && m_pDomain)
313 itYarn->AddVolumeToMesh(Mesh[i], *m_pDomain);
314 else
315 itYarn->AddVolumeToMesh(Mesh[i]);
316 }
317}
318
319void CTextile::AddCentrePlaneToMesh(CMesh &Mesh, bool bTrimToDomain)
320{
322 return;
323 vector<CYarn>::iterator itYarn;
324 for (itYarn = m_Yarns.begin(); itYarn != m_Yarns.end(); ++itYarn)
325 {
326 if (bTrimToDomain && m_pDomain)
327 itYarn->AddCentrePlaneToMesh(Mesh, *m_pDomain);
328 else
329 itYarn->AddCentrePlaneToMesh(Mesh);
330 }
331}
332
333void CTextile::Rotate(WXYZ Rotation, XYZ Origin)
334{
336 return;
337 vector<CYarn>::iterator itYarn;
338 for (itYarn = m_Yarns.begin(); itYarn != m_Yarns.end(); ++itYarn)
339 {
340 itYarn->Rotate(Rotation, Origin);
341 }
342}
343
345{
347 return;
348 vector<CYarn>::iterator itYarn;
349 for (itYarn = m_Yarns.begin(); itYarn != m_Yarns.end(); ++itYarn)
350 {
351 itYarn->Translate(Vector);
352 }
353}
354
355string CTextile::GetName() const
356{
357 return TEXGEN.GetName(this);
358}
359/*
360bool CTextile::OutputAbaqus(string FileName, double dInitialStrains)
361{
362 TGLOGINDENT("Outputing volume mesh to abaqus");
363 if (!BuildTextileIfNeeded())
364 return false;
365
366 CMesh Mesh, UndeformedMesh;
367 CYarn UndeformedYarn;
368 vector<CYarn>::iterator itYarn;
369 for (itYarn = m_Yarns.begin(); itYarn != m_Yarns.end(); ++itYarn)
370 {
371 itYarn->AddVolumeToMesh(Mesh);
372 if (dInitialStrains > 0)
373 {
374 UndeformedYarn = *itYarn;
375 UndeformedYarn.StraightenYarn(dInitialStrains);
376 UndeformedYarn.AddVolumeToMesh(UndeformedMesh);
377 }
378 }
379
380 ofstream Output(FileName.c_str());
381
382 if (!Output)
383 {
384 TGERROR("Unable to output mesh to abaqus file format, could not open file: " + FileName);
385 return false;
386 }
387
388 Output << "*HEADING" << endl;
389 Output << "TexGen generated file" << endl;
390
391 Output << "*NODE" << endl;
392 Mesh.OutputNodes(Output, 1);
393
394 int iStartIndex = 1;
395 Output << "*ELEMENT,TYPE=C3D6" << endl;
396 iStartIndex = Mesh.OutputElements(Output, CMesh::WEDGE, iStartIndex, 1);
397
398 Output << "*ELEMENT,TYPE=C3D8" << endl;
399 iStartIndex = Mesh.OutputElements(Output, CMesh::HEX, iStartIndex, 1);
400
401 if (dInitialStrains > 0)
402 {
403 Output << "*ORIGINALPOSITIONS" << endl;
404 UndeformedMesh.OutputNodes(Output, 1);
405 }
406
407 return true;
408}
409*/
410void CTextile::GetPointInformation(const vector<XYZ> &Points, vector<POINT_INFO> &PointsInfo, double dTolerance)
411{
412 //TGLOGINDENT("Getting information for " << (int)Points.size() << " points");
413 if (Points.empty())
414 return;
416 return;
417
418 PointsInfo.clear();
419 PointsInfo.resize(Points.size());
420 vector<XYZ>::const_iterator itPoint;
421 std::vector<XY>::iterator itLoc;
422 vector<POINT_INFO>::iterator itInfo;
423 POINT_INFO Info;
424
425 XYZ Min,Max;
426 for (itPoint = Points.begin(); itPoint != Points.end(); ++itPoint)
427 {
428 if (itPoint == Points.begin())
429 {
430 Min = Max = *itPoint;
431 }
432 else
433 {
434 Min = ::Min(Min, *itPoint);
435 Max = ::Max(Max, *itPoint);
436 }
437 }
438 XYZ Tangent;
439 XY Loc;
440 CDomainPlanes DomainPlanes(Min, Max);
441 vector<CYarn>::iterator itYarn;
442 int iIndex;
443 for (itYarn = m_Yarns.begin(), iIndex=0; itYarn != m_Yarns.end(); ++itYarn, ++iIndex)
444 {
445 vector<XYZ> Translations = DomainPlanes.GetTranslations(*itYarn);
446 for (itPoint = Points.begin(), itInfo = PointsInfo.begin(); itPoint != Points.end(); ++itPoint, ++itInfo)
447 {
448 if (itYarn->PointInsideYarn(*itPoint, Translations, &Info.YarnTangent,
449 &Info.Location, &Info.dVolumeFraction, &Info.dSurfaceDistance, dTolerance, &Info.Orientation, &Info.Up))
450 {
451 // If the point is inside several yarns, either because the yarns overlap or because
452 // the tolerance is set too high, the point is assigned the yarn which it lies deepest
453 // within. I.e. the one with the lowest surface distance (note that negative surface
454 // distance represents a point lying below the yarn surface).
455 if (itInfo->iYarnIndex == -1 || Info.dSurfaceDistance < itInfo->dSurfaceDistance)
456 {
457 *itInfo = Info;
458 itInfo->iYarnIndex = iIndex;
459 }
460 }
461 }
462 }
463}
464
465void CTextile::GetPointInformation(const vector<XYZ> &Points, vector<POINT_INFO> &PointsInfo, int iYarn, double dTolerance, bool bSurface)
466{
467 //TGLOGINDENT("Getting information for " << (int)Points.size() << " points");
468 if (Points.empty())
469 return;
471 return;
472
473 PointsInfo.clear();
474 PointsInfo.resize(Points.size());
475 vector<XYZ>::const_iterator itPoint;
476 std::vector<XY>::iterator itLoc;
477 vector<POINT_INFO>::iterator itInfo;
478 POINT_INFO Info;
479
480 XYZ Min,Max;
481 for (itPoint = Points.begin(); itPoint != Points.end(); ++itPoint)
482 {
483 if (itPoint == Points.begin())
484 {
485 Min = Max = *itPoint;
486 }
487 else
488 {
489 Min = ::Min(Min, *itPoint);
490 Max = ::Max(Max, *itPoint);
491 }
492 }
493 XYZ Tangent;
494 XY Loc;
495 CDomainPlanes DomainPlanes(Min, Max);
496 vector<CYarn>::iterator itYarn;
497
498 vector<XYZ> Translations = DomainPlanes.GetTranslations(m_Yarns[iYarn]);
499 for (itPoint = Points.begin(), itInfo = PointsInfo.begin(); itPoint != Points.end(); ++itPoint, ++itInfo)
500 {
501 if (m_Yarns[iYarn].PointInsideYarn(*itPoint, Translations, &Info.YarnTangent,
502 &Info.Location, &Info.dVolumeFraction, &Info.dSurfaceDistance, dTolerance, &Info.Orientation, &Info.Up, bSurface))
503 {
504 // If the point is inside several yarns, either because the yarns overlap or because
505 // the tolerance is set too high, the point is assigned the yarn which it lies deepest
506 // within. I.e. the one with the lowest surface distance (note that negative surface
507 // distance represents a point lying below the yarn surface).
508 if (itInfo->iYarnIndex == -1 )//|| Info.dSurfaceDistance < itInfo->dSurfaceDistance)
509 {
510 *itInfo = Info;
511 itInfo->iYarnIndex = iYarn;
512 }
513 }
514 else
515 {
516 }
517 }
518
519}
520
521void CTextile::SavePointInformationToVTK(string Filename, const CMesh &Mesh, double dTolerance)
522{
523 vector<POINT_INFO> PointsInfo;
524 GetPointInformation(Mesh.GetNodes(), PointsInfo, dTolerance);
525
526 CMeshData<char> YarnIndex("YarnIndex", CMeshDataBase::ELEMENT);
527 CMeshData<XYZ> YarnTangent("YarnTangent", CMeshDataBase::ELEMENT);
528 CMeshData<XY> Location("Location", CMeshDataBase::ELEMENT);
529 CMeshData<double> VolumeFraction("VolumeFraction", CMeshDataBase::ELEMENT);
530 CMeshData<double> SurfaceDistance("SurfaceDistance", CMeshDataBase::ELEMENT);
531 CMeshData<XYZ> Orientation("Orientation", CMeshDataBase::ELEMENT);
532
533 vector<POINT_INFO>::const_iterator itPointInfo;
534 for (itPointInfo = PointsInfo.begin(); itPointInfo != PointsInfo.end(); ++itPointInfo)
535 {
536 YarnIndex.m_Data.push_back(itPointInfo->iYarnIndex);
537 YarnTangent.m_Data.push_back(itPointInfo->YarnTangent);
538 Location.m_Data.push_back(itPointInfo->Location);
539 VolumeFraction.m_Data.push_back(itPointInfo->dVolumeFraction);
540 SurfaceDistance.m_Data.push_back(itPointInfo->dSurfaceDistance);
541 Orientation.m_Data.push_back(itPointInfo->Orientation);
542 }
543
544 vector<CMeshDataBase*> MeshData;
545
546 MeshData.push_back(&YarnIndex);
547 MeshData.push_back(&YarnTangent);
548 MeshData.push_back(&Location);
549 MeshData.push_back(&VolumeFraction);
550 MeshData.push_back(&SurfaceDistance);
551 MeshData.push_back(&Orientation);
552
553 Mesh.SaveToVTK(Filename, &MeshData);
554}
555
557{
559 return 0;
560
561 XYZ Min, Max, Pos;
562 vector<CYarn>::const_iterator itYarn;
563 vector<CNode>::const_iterator itNode;
564 for (itYarn = m_Yarns.begin(); itYarn != m_Yarns.end(); ++itYarn)
565 {
566 const vector<CNode> &Nodes = itYarn->GetMasterNodes();
567 for (itNode = Nodes.begin(); itNode != Nodes.end(); ++itNode)
568 {
569 Pos = itNode->GetPosition();
570 Min = ::Min(Min, Pos);
571 Max = ::Max(Max, Pos);
572 }
573 }
574 return GetLength(Min, Max);
575}
576
577int CTextile::DetectInterference(vector<float> &DistanceToSurface, vector<int> &YarnIndices, bool bTrimToDomain, CMesh *pInterferingPoints )
578{
580 return -1;
581
582 if ( bTrimToDomain && !m_pDomain )
583 {
584 TGERROR( "Cannot trim interference points to domain - no domain specified" );
585 return -1;
586 }
587
588 if (pInterferingPoints)
589 pInterferingPoints->Clear();
590
591 TGLOGINDENT("Detecting interference between yarns in textile \"" << GetName() << "\"");
592 int iIntersections = 0;
593 vector<CYarn>::iterator itYarn;
594 vector<CYarn>::iterator itYarnCompare;
595 vector<CSlaveNode>::const_iterator itSlaveNode;
596 vector<XYZ>::const_iterator itPoint;
597 pair<XYZ, XYZ> AABB1, AABB2;
598 // Parameters to send to PointInsideYarn. Only need because default parameters before pDistanceToSurface
599 XYZ pTangent;
600 XY pLoc;
601 double pVolumeFraction, pDistanceToSurface;
602 int iIndex;
603
604 for (itYarn = m_Yarns.begin(), iIndex = 0; itYarn != m_Yarns.end(); ++itYarn, ++iIndex)
605 {
606 for (itYarnCompare = m_Yarns.begin(); itYarnCompare != m_Yarns.end(); ++itYarnCompare)
607 {
608 if (itYarn == itYarnCompare)
609 continue;
610 if ( bTrimToDomain )
611 {
612 CMesh YarnMesh, CompareMesh;
613
614 itYarn->AddSurfaceToMesh(YarnMesh, m_pDomain);
615 AABB1 = YarnMesh.GetAABB();
616 itYarnCompare->AddSurfaceToMesh( CompareMesh, m_pDomain );
617 AABB2 = CompareMesh.GetAABB();
618 }
619 else
620 {
621 AABB1 = itYarn->GetAABB();
622 AABB2 = itYarnCompare->GetAABB();
623 }
624 if (!BoundingBoxIntersect(AABB1.first, AABB1.second, AABB2.first, AABB2.second, 1e-9))
625 continue;
626
627 vector<XYZ> YarnTranslations;
628 vector<XYZ> CompareTranslations;
629 if( bTrimToDomain )
630 {
631 YarnTranslations = m_pDomain->GetTranslations(*itYarn);
632 CompareTranslations = m_pDomain->GetTranslations(*itYarnCompare);
633 }
634 else
635 {
636 XYZ Translation(0,0,0);
637 YarnTranslations.push_back(Translation);
638 CompareTranslations.push_back(Translation);
639 }
640
641 const vector<CSlaveNode> &SlaveNodes = itYarn->GetSlaveNodes(CYarn::SURFACE);
642 for (itSlaveNode = SlaveNodes.begin(); itSlaveNode != SlaveNodes.end(); ++itSlaveNode)
643 {
644 for (itPoint = itSlaveNode->GetSectionPoints().begin(); itPoint != itSlaveNode->GetSectionPoints().end(); ++itPoint)
645 {
646 vector<XYZ>::const_iterator itXYZ;
647 for( itXYZ = YarnTranslations.begin(); itXYZ != YarnTranslations.end(); ++itXYZ )
648 {
649 if ( !bTrimToDomain || m_pDomain->PointInDomain( *itPoint + *itXYZ ) ) // Don't need to check for intersection if point outside domain
650 {
651 if (itYarnCompare->PointInsideYarn(*itPoint + *itXYZ, CompareTranslations, &pTangent, &pLoc, &pVolumeFraction, &pDistanceToSurface))
652 {
653 if (pInterferingPoints)
654 pInterferingPoints->AddNode(*itPoint + *itXYZ);
655 DistanceToSurface.push_back( (float)pDistanceToSurface );
656 YarnIndices.push_back( iIndex );
657
658 ++iIntersections;
659 }
660 }
661 }
662 }
663 }
664 }
665 }
666 TGLOG("Found " << iIntersections << " intersections between yarns in textile \"" << GetName() << "\"");
667 return iIntersections;
668}
669
670vector<CYarn> &CTextile::GetYarns()
671{
673 return m_Yarns;
674}
675
676const vector<CYarn> &CTextile::GetYarns() const
677{
679 return m_Yarns;
680}
681
683{
685 if (iIndex < 0 || iIndex >= (int)m_Yarns.size())
686 {
687 TGERROR("Unable to get yarn, invalid index: " << iIndex);
688 return NULL;
689 }
690 return &m_Yarns[iIndex];
691}
692
693const CYarn *CTextile::GetYarn(int iIndex) const
694{
696 if (iIndex < 0 || iIndex >= (int)m_Yarns.size())
697 {
698 TGERROR("Unable to get yarn, invalid index: " << iIndex);
699 return NULL;
700 }
701 return &m_Yarns[iIndex];
702}
703
705{
707 return (int)m_Yarns.size();
708}
709
711{
712 if (!m_bNeedsBuilding)
713 return true;
714 else
715 {
716 // Even if the build fails, we set this flag to false because if nothing happens
717 // which changes the textile between this call and the next call. The next call
718 // will also fail, thus there is no point to call it again.
719 m_bNeedsBuilding = false;
720 return BuildTextile();
721 }
722}
723
725{
726 m_pDomain = Domain;
727}
728
730{
731 m_pDomain.Clear();
732}
733
734double CTextile::GetYarnLength(string Units)
735{
737 return 0;
738 int i;
739 double dYarnLength = 0;
740 for (i=0; i<(int)m_Yarns.size(); ++i)
741 {
742 dYarnLength += m_Yarns[i].GetRealYarnLength(Units);
743 }
744 return dYarnLength;
745}
746
748{
750 return 0;
751 int i;
752 double dYarnLength = 0;
753 for (i=0; i<(int)m_Yarns.size(); ++i)
754 {
755 // If one of the yarns doesn't have correct repeat vectors then we
756 // cannot calculate an accurate value of length per unit area for the
757 // whole textile
758 if (m_Yarns[i].GetRawRepeatArea() == 0)
759 return 0;
760 dYarnLength += m_Yarns[i].GetYarnLengthPerUnitArea(Units);
761 }
762 return dYarnLength;
763}
764
765double CTextile::GetYarnVolume(string Units)
766{
768 return 0;
769 int i;
770 double dVolume = 0;
771 for (i=0; i<(int)m_Yarns.size(); ++i)
772 {
773 dVolume += m_Yarns[i].GetRealYarnVolume(Units);
774 }
775 return dVolume;
776}
777
779{
781 return 0;
782 int i;
783 double dVolPerUnitArea = 0;
784 for (i=0; i<(int)m_Yarns.size(); ++i)
785 {
786 // If one of the yarns doesn't have correct repeat vectors then we
787 // cannot calculate an accurate value of volume per unit area for the
788 // whole textile
789 if (m_Yarns[i].GetRawRepeatArea() == 0)
790 return 0;
791 dVolPerUnitArea += m_Yarns[i].GetYarnVolumePerUnitArea(Units);
792 }
793 return dVolPerUnitArea;
794}
795
796double CTextile::GetFibreVolume(string Units)
797{
799 return 0;
800 int i;
801 double dVolume = 0;
802 for (i=0; i<(int)m_Yarns.size(); ++i)
803 {
804 dVolume += m_Yarns[i].GetFibreVolume(Units);
805 }
806 return dVolume;
807}
808
810{
812 return 0;
813 // Try to calculate the fibre volume per unit area based on areal density
815 {
816 double dVolPerUnitArea = m_ArealDensity.GetSIValue()/m_FibreDensity.GetSIValue();
817 return ConvertUnits(dVolPerUnitArea, "m", Units);
818 }
819 // If areal density is missing then calculate it based on linear density of the yarns
820 else
821 {
822 int i;
823 double dVolPerUnitArea = 0;
824 for (i=0; i<(int)m_Yarns.size(); ++i)
825 {
826 // If one of the yarns doesn't have correct repeat vectors then we
827 // cannot calculate an accurate value fibre volume per unit area for the
828 // whole textile
829 if (m_Yarns[i].GetRawRepeatArea() == 0)
830 return 0;
831 dVolPerUnitArea += m_Yarns[i].GetFibreVolumePerUnitArea(Units);
832 }
833 return dVolPerUnitArea;
834 }
835 return 0;
836}
837
839{
841 return 0;
842 double dYarnVolumePerUnitArea = GetYarnVolumePerUnitArea();
843 if (dYarnVolumePerUnitArea)
844 return GetFibreVolumePerUnitArea()/dYarnVolumePerUnitArea;
845 else if (double dYarnVolume = GetYarnVolume())
846 {
847 return GetFibreVolume()/dYarnVolume;
848 }
849 return 0;
850}
851
853{
854 return dynamic_cast<CTextileWeave*>(this);
855}
856
858{
859 return dynamic_cast<CTextileWeave2D*>(this);
860}
861
863{
864 return dynamic_cast<CTextileLayered*>(this);
865}
866
868{
869 return dynamic_cast<CTextile3DWeave*>(this);
870}
871
873{
874 return dynamic_cast<CTextileOrthogonal*>(this);
875}
876
878{
879 return dynamic_cast<CTextileLayerToLayer*>(this);
880}
881
883{
884 return dynamic_cast<CTextileDecoupledLToL*>(this);
885}
886
888{
889 return dynamic_cast<CTextileAngleInterlock*>(this);
890}
891
892/*int CTextile::AdjustInterference(vector<float> &DistanceToSurface, CMesh *pInterferingPoints)
893{
894 if (!BuildTextileIfNeeded())
895 return -1;
896
897 if (pInterferingPoints)
898 pInterferingPoints->Clear();
899 TGLOGINDENT("Detecting interference between yarns in textile \"" << GetName() << "\"");
900 int iIntersections = 0;
901 vector<CYarn>::iterator itYarn;
902 vector<CYarn>::iterator itYarnCompare;
903 vector<CSlaveNode>::const_iterator itSlaveNode;
904 vector<XYZ>::const_iterator itPoint;
905 pair<XYZ, XYZ> AABB1, AABB2;
906 // Parameters to send to PointInsideYarn. Only need because default parameters before pDistanceToSurface
907 XYZ pTangent;
908 XY pLoc;
909 double pVolumeFraction, pDistanceToSurface;
910
911 for (itYarn = m_Yarns.begin(); itYarn != m_Yarns.end(); ++itYarn)
912 {
913 for (itYarnCompare = m_Yarns.begin(); itYarnCompare != m_Yarns.end(); ++itYarnCompare)
914 {
915 if (itYarn == itYarnCompare)
916 continue;
917 AABB1 = itYarn->GetAABB();
918 AABB2 = itYarnCompare->GetAABB();
919 if (!BoundingBoxIntersect(AABB1.first, AABB1.second, AABB2.first, AABB2.second, 1e-9))
920 continue;*/
921/* if (AABB1.second.x < AABB2.first.x || AABB1.second.y < AABB2.first.y || AABB1.second.z < AABB2.first.z ||
922 AABB2.second.x < AABB1.first.x || AABB2.second.y < AABB1.first.y || AABB2.second.z < AABB1.first.z)
923 continue;*/
924/* CDomainPlanes DomainPlanes(AABB1.first, AABB1.second);
925 vector<XYZ> Translations = DomainPlanes.GetTranslations(*itYarnCompare);
926 const vector<CSlaveNode> &SlaveNodes = itYarn->GetSlaveNodes(CYarn::SURFACE);
927 for (itSlaveNode = SlaveNodes.begin(); itSlaveNode != SlaveNodes.end(); ++itSlaveNode)
928 {
929 for (itPoint = itSlaveNode->GetSectionPoints().begin(); itPoint != itSlaveNode->GetSectionPoints().end(); ++itPoint)
930 {
931 if (itYarnCompare->PointInsideYarn(*itPoint, Translations, &pTangent, &pLoc, &pVolumeFraction, &pDistanceToSurface))
932 {
933 if (pInterferingPoints)
934 {
935 pInterferingPoints->AddNode(*itPoint);
936 DistanceToSurface.push_back( (float)pDistanceToSurface );
937 }
938 ++iIntersections;
939 }
940 }
941 }
942 }
943 }
944 TGLOG("Found " << iIntersections << " intersections between yarns in textile \"" << GetName() << "\"");
945 return iIntersections;
946}*/
947
948void CTextile::SetAllYarnsYoungsModulusX( double dValue, string Units)
949{
951 return;
952 vector<CYarn>::iterator itYarn;
953
954 for ( itYarn = m_Yarns.begin(); itYarn != m_Yarns.end(); ++itYarn )
955 {
956 itYarn->SetYoungsModulusX( dValue, Units );
957 }
958}
959
960void CTextile::SetAllYarnsYoungsModulusY( double dValue, string Units)
961{
963 return;
964 vector<CYarn>::iterator itYarn;
965
966 for ( itYarn = m_Yarns.begin(); itYarn != m_Yarns.end(); ++itYarn )
967 {
968 itYarn->SetYoungsModulusY( dValue, Units );
969 }
970}
971
972void CTextile::SetAllYarnsYoungsModulusZ( double dValue, string Units)
973{
975 return;
976 vector<CYarn>::iterator itYarn;
977
978 for ( itYarn = m_Yarns.begin(); itYarn != m_Yarns.end(); ++itYarn )
979 {
980 itYarn->SetYoungsModulusZ( dValue, Units );
981 }
982}
983
984void CTextile::SetAllYarnsShearModulusXY(double dValue, string Units)
985{
987 return;
988 vector<CYarn>::iterator itYarn;
989
990 for ( itYarn = m_Yarns.begin(); itYarn != m_Yarns.end(); ++itYarn )
991 {
992 itYarn->SetShearModulusXY( dValue, Units );
993 }
994}
995
996void CTextile::SetAllYarnsShearModulusXZ(double dValue, string Units)
997{
999 return;
1000 vector<CYarn>::iterator itYarn;
1001
1002 for ( itYarn = m_Yarns.begin(); itYarn != m_Yarns.end(); ++itYarn )
1003 {
1004 itYarn->SetShearModulusXZ( dValue, Units );
1005 }
1006}
1007
1008void CTextile::SetAllYarnsShearModulusYZ(double dValue, string Units)
1009{
1010 if (!BuildTextileIfNeeded())
1011 return;
1012 vector<CYarn>::iterator itYarn;
1013
1014 for ( itYarn = m_Yarns.begin(); itYarn != m_Yarns.end(); ++itYarn )
1015 {
1016 itYarn->SetShearModulusYZ( dValue, Units );
1017 }
1018}
1019
1020void CTextile::SetAllYarnsAlphaX( double dValue, string Units)
1021{
1022 if (!BuildTextileIfNeeded())
1023 return;
1024 vector<CYarn>::iterator itYarn;
1025
1026 for ( itYarn = m_Yarns.begin(); itYarn != m_Yarns.end(); ++itYarn )
1027 {
1028 itYarn->SetAlphaX( dValue, Units );
1029 }
1030}
1031
1032void CTextile::SetAllYarnsAlphaY( double dValue, string Units)
1033{
1034 if (!BuildTextileIfNeeded())
1035 return;
1036 vector<CYarn>::iterator itYarn;
1037
1038 for ( itYarn = m_Yarns.begin(); itYarn != m_Yarns.end(); ++itYarn )
1039 {
1040 itYarn->SetAlphaY( dValue, Units );
1041 }
1042}
1043
1044void CTextile::SetAllYarnsAlphaZ( double dValue, string Units)
1045{
1046 if (!BuildTextileIfNeeded())
1047 return;
1048 vector<CYarn>::iterator itYarn;
1049
1050 for ( itYarn = m_Yarns.begin(); itYarn != m_Yarns.end(); ++itYarn )
1051 {
1052 itYarn->SetAlphaZ( dValue, Units );
1053 }
1054}
1055
1057{
1058 if (!BuildTextileIfNeeded())
1059 return;
1060 vector<CYarn>::iterator itYarn;
1061
1062 for ( itYarn = m_Yarns.begin(); itYarn != m_Yarns.end(); ++itYarn )
1063 {
1064 itYarn->SetPoissonsRatioX( dValue );
1065 }
1066}
1067
1069{
1070 if (!BuildTextileIfNeeded())
1071 return;
1072 vector<CYarn>::iterator itYarn;
1073
1074 for ( itYarn = m_Yarns.begin(); itYarn != m_Yarns.end(); ++itYarn )
1075 {
1076 itYarn->SetPoissonsRatioY( dValue );
1077 }
1078}
1079
1081{
1082 if (!BuildTextileIfNeeded())
1083 return;
1084 vector<CYarn>::iterator itYarn;
1085
1086 for ( itYarn = m_Yarns.begin(); itYarn != m_Yarns.end(); ++itYarn )
1087 {
1088 itYarn->SetPoissonsRatioZ( dValue );
1089 }
1090}
1091
1093{
1094 if( !m_pDomain )
1095 {
1096 TGERROR("Cannot calculate volume fraction. No domain specified");
1097 return 0.0;
1098 }
1099
1100 if (!BuildTextileIfNeeded())
1101 return 0.0;
1102
1103 vector<CYarn>::iterator itYarn;
1104 double FibreVolume = 0.0;
1105
1106 int i = 0;
1107
1108 for ( itYarn = m_Yarns.begin(); itYarn != m_Yarns.end(); ++itYarn, ++i )
1109 {
1110 CMesh Mesh;
1111 double YarnVolume, YarnFibreVf;
1112 // Calculate volume of yarn within the domain
1113 itYarn->AddSurfaceToMesh( Mesh, m_pDomain );
1114 YarnVolume = Mesh.CalculateVolume();
1115
1116 YarnFibreVf = itYarn->GetFibreYarnVolumeFraction(); //Based on whole yarn
1117 if ( YarnFibreVf < TOL )
1118 {
1119 stringstream Message;
1120 Message << "No fibre data specified for yarn " << i << ". Using Vf = 1.0\n";
1121 TGERROR( Message.str() );
1122 YarnFibreVf = 1.0;
1123 }
1124 FibreVolume += YarnFibreVf * YarnVolume;
1125 }
1126
1127 return FibreVolume/m_pDomain->GetVolume();
1128}
1129
1131{
1132 if( !m_pDomain )
1133 {
1134 TGERROR("Cannot calculate volume fraction. No domain specified");
1135 return 0.0;
1136 }
1137
1138 if (!BuildTextileIfNeeded())
1139 return 0.0;
1140
1141 vector<CYarn>::iterator itYarn;
1142 double FibreVolume = 0.0;
1143 int i = 0;
1144
1145 for ( itYarn = m_Yarns.begin(); itYarn != m_Yarns.end(); ++itYarn, ++i )
1146 {
1147 CMesh Mesh;
1148 double YarnFibreVf;
1149 vector<XYZ> Centres;
1150 vector<XYZ>::iterator itCentres;
1151 XYZ Tangent;
1152 XY Loc;
1153 int i1, i2, i3, i4;
1154 const XYZ *p1, *p2, *p3, *p4;
1155 bool bDefaultVf = false;
1156
1157 // Create volume mesh for domain
1158 itYarn->AddVolumeToMesh( Mesh, *m_pDomain );
1159 Mesh.ConvertToTetMesh();
1160
1161 vector<XYZ> Translations = m_pDomain->GetTranslations(*itYarn);
1162 Centres = Mesh.GetElementCenters();
1163 list<int> &TetIndices = Mesh.GetIndices(CMesh::TET);
1164 list<int>::iterator itTetInd;
1165
1166 YarnFibreVf = itYarn->GetFibreYarnVolumeFraction();
1167 if ( YarnFibreVf < TOL )
1168 {
1169 stringstream Message;
1170 Message << "No fibre data specified for yarn " << i << ". Using Vf = 1.0\n";
1171 TGERROR( Message.str() );
1172 YarnFibreVf = 1.0;
1173 bDefaultVf = true;
1174 }
1175
1176 // Get fibre volume for each tet based on its area and local volume fraction
1177 for ( itCentres = Centres.begin(), itTetInd = TetIndices.begin(); itCentres != Centres.end(); ++itCentres )
1178 {
1179 XYZ Centre = *itCentres;
1180 if ( !bDefaultVf )
1181 {
1182 itYarn->PointInsideYarn( *itCentres, Translations, &Tangent, &Loc, &YarnFibreVf );
1183 }
1184 i1 = *(itTetInd++);
1185 i2 = *(itTetInd++);
1186 i3 = *(itTetInd++);
1187 i4 = *(itTetInd++);
1188
1189 p1 = &Mesh.GetNode(i1);
1190 p2 = &Mesh.GetNode(i2);
1191 p3 = &Mesh.GetNode(i3);
1192 p4 = &Mesh.GetNode(i4);
1193 double TetVolume = fabs( DotProduct(CrossProduct(((*p1)-(*p2)),((*p1)-(*p3))),((*p1)-(*p4))))/6.0;
1194 FibreVolume += YarnFibreVf * TetVolume;
1195 }
1196 }
1197
1198 return FibreVolume/m_pDomain->GetVolume();
1199}
1200
1202{
1203 vector<CYarn>::iterator itYarn;
1204
1205 for (itYarn = m_Yarns.begin(); itYarn != m_Yarns.end(); ++itYarn)
1206 {
1207 if ( !itYarn->ConvertToInterpNodes() )
1208 return false;
1209 }
1210 return true;
1211}
1212
1213bool CTextile::SetResolution(int Resolution)
1214{
1216 vector<CYarn>::iterator itYarn;
1217
1218 for (itYarn = m_Yarns.begin(); itYarn != m_Yarns.end(); ++itYarn)
1219 {
1220 if (!itYarn->SetResolution(Resolution))
1221 return false;
1222 }
1223 return true;
1224}
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
#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 TGLOG(MESSAGE)
Definition: Logger.h:36
#define FOR_EACH_TIXMLELEMENT(CHILDELEMENT, PARENTELEMENT, ELEMENTNAME)
Macro to enable looping over tinyxml easier.
Definition: Misc.h:45
#define NULL
Definition: ShinyConfig.h:50
#define TEXGEN
Helper macro to get the texgen instance.
Definition: TexGen.h:76
#define TOL
Definition: Textile.cpp:27
Abstract base class representing the domain in which a textile cell may lie.
Definition: Domain.h:34
vector< XYZ > GetTranslations(const CYarn &Yarn) const
Get the translation vectors necessary to fully fill the domain.
Definition: Domain.cpp:83
Domain implementation described using planes, the simplest of which would be a box.
Definition: DomainPlanes.h:37
Domain implementation described using extrusion of a polygon outline.
Definition: DomainPrism.h:36
vector< T > m_Data
Definition: MeshData.h:87
Defines the nodes and elements of a surface or volume mesh.
Definition: Mesh.h:58
bool AddElement(ELEMENT_TYPE Type, const vector< int > &Indices)
Add an element to the mesh of given type with node number checking.
Definition: Mesh.cpp:2565
int GetNumNodes() const
Return the number of nodes.
Definition: Mesh.cpp:2646
const vector< XYZ > & GetNodes() const
Get a const reference to the nodes.
Definition: Mesh.cpp:2656
const int AddNode(XYZ Node)
Append a node to the list of nodes, the integer returns the index of the node
Definition: Mesh.cpp:2624
const XYZ & GetNode(int iIndex) const
Get the node with given ID.
Definition: Mesh.cpp:2636
vector< XYZ > GetElementCenters() const
Get a vector of element centers, one entry for each element.
Definition: Mesh.cpp:1549
void ConvertTriToQuad(double Tolerance=1e-6)
Convert Triangel elements to Quads.
Definition: Mesh.cpp:606
void ConvertToTetMesh()
Definition: Mesh.cpp:584
bool SaveToVTK(string Filename, const vector< CMeshDataBase * > *pMeshData=NULL) const
Save the mesh to VTK unstructured grid file format (.vtu)
Definition: Mesh.cpp:2348
const list< int > & GetIndices(ELEMENT_TYPE ElemType) const
Get the element indices of a given element type.
Definition: Mesh.cpp:2671
ELEMENT_TYPE
Each element type is represented by a unique integer value.
Definition: Mesh.h:66
@ NUM_ELEMENT_TYPES
Definition: Mesh.h:77
@ POLYGON
Definition: Mesh.h:76
double CalculateVolume() const
Calculate the volume of the mesh.
Definition: Mesh.cpp:1519
pair< XYZ, XYZ > GetAABB(double dGrowDistance=0) const
Get an axis aligned bounding box for the mesh.
Definition: Mesh.cpp:340
void Clear()
Empty mesh nodes and indices.
Definition: Mesh.cpp:1448
CProperty m_FibreDensity
Definition: Properties.h:199
Class to store properties related to a textile.
virtual void PopulateTiXmlElement(TiXmlElement &Element, OUTPUT_TYPE OutputType)
Used for saving data to XML.
bool IsSet() const
Definition: Property.cpp:124
double GetSIValue() const
Definition: Property.cpp:61
Represents a 3D woven textile.
Represents a 3D angle interlock woven textile.
Represents a textile cell containing yarns.
Definition: Textile.h:39
CTextileWeave * GetWeave()
If this textile is a woven textile get a pointer of that type else return NULL.
Definition: Textile.cpp:852
bool SetResolution(int Resolution)
Set the resolution for all yarns in textile.
Definition: Textile.cpp:1213
void RemoveDomain()
Remove the domain.
Definition: Textile.cpp:729
void AddNodesToMesh(CMesh &Mesh)
Add the master nodes to the mesh.
Definition: Textile.cpp:165
void SetAllYarnsPoissonsRatioY(double dValue)
Definition: Textile.cpp:1068
virtual bool BuildTextile() const
Build the textile even if it is already built (virtual function which does nothing by default)
Definition: Textile.h:307
double GetYarnVolumePerUnitArea(string Units="m")
Calculate the total yarn volume per unit area.
Definition: Textile.cpp:778
CTextileOrthogonal * GetOrthogonalWeave()
Definition: Textile.cpp:872
CTextileLayerToLayer * GetLayerToLayerWeave()
Definition: Textile.cpp:877
void SavePointInformationToVTK(string Filename, const CMesh &Mesh, double dTolerance=1e-9)
Output point information to VTK.
Definition: Textile.cpp:521
bool DeleteYarn(int iIndex)
Delete an Yarn from the textile.
Definition: Textile.cpp:152
void SetAllYarnsYoungsModulusY(double dValue, string Units="MPa")
Definition: Textile.cpp:960
void SetAllYarnsPoissonsRatioZ(double dValue)
Definition: Textile.cpp:1080
double GetFibreVolume(string Units="m^3")
Calculate the volume of fibre in the yarn, for just the nodes specified.
Definition: Textile.cpp:796
CTextile3DWeave * Get3DWeave()
Definition: Textile.cpp:867
bool BuildTextileIfNeeded() const
Build the textile only if needed.
Definition: Textile.cpp:710
void DeleteYarns()
Delete all Yarns in the textile.
Definition: Textile.cpp:160
int GetNumYarns() const
Definition: Textile.cpp:704
void SetAllYarnsAlphaY(double dValue, string Units="/K")
Definition: Textile.cpp:1032
void AddVolumeToMesh(vector< CMesh > &YarnMeshes, bool bTrimToDomain=false)
Create volume mesh for each yarn in this textile and add to a vector of meshes.
Definition: Textile.cpp:301
void AddCentrePlaneToMesh(CMesh &Mesh, bool bTrimToDomain=false)
Create centre plane mesh for this textile and add it to the mesh object.
Definition: Textile.cpp:319
void SetAllYarnsAlphaZ(double dValue, string Units="/K")
Definition: Textile.cpp:1044
vector< CYarn > m_Yarns
Vector of yarns contained within this cell.
Definition: Textile.h:323
void SetAllYarnsPoissonsRatioX(double dValue)
Set the Poisson's ratio for all yarns in textile.
Definition: Textile.cpp:1056
CTextile & operator=(const CTextile &CopyMe)
Definition: Textile.cpp:50
void SetAllYarnsYoungsModulusX(double dValue, string Units="MPa")
Set the Youngs Modulus for all yarns in textile.
Definition: Textile.cpp:948
void Translate(XYZ Vector)
Translate the Textile by given vector.
Definition: Textile.cpp:344
void AddSurfaceToMesh(CMesh &Mesh, bool bTrimToDomain=false)
Create surface mesh for this textile and add it to the mesh object.
Definition: Textile.cpp:187
double GetFibreYarnVolumeFraction()
Calculates the total fibre volume fraction for all yarns.
Definition: Textile.cpp:838
void Rotate(WXYZ Rotation, XYZ Origin=XYZ(0, 0, 0))
Rotate the Textile by given quaternion.
Definition: Textile.cpp:333
bool ConvertToInterpNodes() const
Definition: Textile.cpp:1201
virtual string GetType() const
Derived class should return the class name.
Definition: Textile.h:51
void AssignDomain(const CDomain &Domain)
Assign a domain to the textile, will be used by default to trim the domain.
Definition: Textile.cpp:724
string GetName() const
Get the name associated with this textile.
Definition: Textile.cpp:355
void AddPathToMesh(CMesh &Mesh)
Add yarn centerline path to mesh.
Definition: Textile.cpp:176
void SetAllYarnsShearModulusYZ(double dValue, string Units="MPa")
Definition: Textile.cpp:1008
CTextileWeave2D * GetWeave2D()
Definition: Textile.cpp:857
double GetApproximateSize()
Get an approximate size for the textile.
Definition: Textile.cpp:556
virtual ~CTextile(void)
Definition: Textile.cpp:46
double GetFibreVolumePerUnitArea(string Units="m")
Calculate the volume of fibre per unit area.
Definition: Textile.cpp:809
virtual void PopulateTiXmlElement(TiXmlElement &Element, OUTPUT_TYPE OutputType)
Used for saving data to XML.
Definition: Textile.cpp:87
void SetAllYarnsShearModulusXZ(double dValue, string Units="MPa")
Definition: Textile.cpp:996
double GetYarnVolume(string Units="m^3")
Calculate the yarn volume.
Definition: Textile.cpp:765
double GetYarnLength(string Units="m")
Calculate the total yarn length.
Definition: Textile.cpp:734
int AddYarn(const CYarn &Yarn)
Add a Yarn to the textile.
Definition: Textile.cpp:122
void GetPointInformation(const vector< XYZ > &Points, vector< POINT_INFO > &PointsInfo, double dTolerance=1e-9)
Get useful information of a list of points.
Definition: Textile.cpp:410
void SetAllYarnsAlphaX(double dValue, string Units="/K")
Set the coefficient of thermal expansion for all yarns in textile.
Definition: Textile.cpp:1020
const vector< CYarn > & GetYarns() const
Definition: Textile.cpp:676
double GetQuickDomainVolumeFraction()
Calculates the fibre volume fraction for the domain.
Definition: Textile.cpp:1092
bool m_bNeedsBuilding
Variable which keeps track of wether the textile needs building or not.
Definition: Textile.h:330
CObjectContainer< CDomain > m_pDomain
Definition: Textile.h:332
CTextileDecoupledLToL * GetDecoupledLToLWeave()
Definition: Textile.cpp:882
const CYarn * GetYarn(int iIndex) const
Definition: Textile.cpp:693
CTextileLayered * GetLayeredTextile()
Definition: Textile.cpp:862
CTextileAngleInterlock * GetAngleInterlockWeave()
Definition: Textile.cpp:887
double GetDomainVolumeFraction()
Calculates the fibre volume fraction for the domain.
Definition: Textile.cpp:1130
int DetectInterference(vector< float > &DistanceToSurface, vector< int > &YarnIndex, bool bTrimToDomain, CMesh *pInterferingPoints=NULL)
Find out if any of the yarns are interfering with each other.
Definition: Textile.cpp:577
void SetAllYarnsYoungsModulusZ(double dValue, string Units="MPa")
Definition: Textile.cpp:972
double GetYarnLengthPerUnitArea(string Units="/m")
Calculate the total yarn length per unit area.
Definition: Textile.cpp:747
void SetAllYarnsShearModulusXY(double dValue, string Units="MPa")
Set the shear modulus for all yarns in textile.
Definition: Textile.cpp:984
Represents a textile made up from several layers of weaves.
Represents a 3D orthogonal woven textile.
Respresents a 2d woven textile.
Represents a woven textile.
Definition: TextileWeave.h:41
Represents a yarn consisting of master nodes, section and interpolation function.
Definition: Yarn.h:49
@ SURFACE
Definition: Yarn.h:60
Namespace containing a series of customised math operations not found in the standard c++ library.
OUTPUT_TYPE
Definition: Misc.h:105
@ OUTPUT_MINIMAL
Definition: Misc.h:106
double Max(XYZ &Vector)
Get maximum element of vector and return it.
Definition: mymath.h:642
double GetLength(const XYZ &Point1, const XYZ &Point2)
Get the length between two points.
Definition: mymath.h:540
XYZ Min(const XYZ &P1, const XYZ &P2)
Given two points, return a new point who's coordinates are the smaller of the two.
Definition: mymath.h:1142
bool BoundingBoxIntersect(const XYZ &BBox1Min, const XYZ &BBox1Max, const XYZ &BBox2Min, const XYZ &BBox2Max, double dTolerance=0)
Find if two AABBs intersect with given tolerance.
Definition: mymath.h:970
double DotProduct(const XYZ &left, const XYZ &right)
Get the dot product of two vectors.
Definition: mymath.h:512
XYZ CrossProduct(const XYZ &left, const XYZ &right)
Get the cross product of two vectors.
Definition: mymath.h:524
double ConvertUnits(double dValue, std::string SourceUnits, std::string TargetUnits)
Definition: Misc.cpp:63
Structure used to retreive information about a particular point in space.
Definition: Misc.h:217
double dSurfaceDistance
Returns the closest distance from the point to the surface of the yarn.
Definition: Misc.h:226
int iYarnIndex
Index of the yarn, -1 when the point is not inside a yarn.
Definition: Misc.h:218
XYZ Orientation
Local fibre orientation.
Definition: Misc.h:227
XY Location
Location of the point relative to the yarn centerline.
Definition: Misc.h:220
XYZ YarnTangent
Tangent of the yarn centreline.
Definition: Misc.h:219
XYZ Up
Local Up vector.
Definition: Misc.h:228
double dVolumeFraction
Definition: Misc.h:221
Struct for representing a quaternion.
Definition: mymath.h:38
Struct for representing points in 2D space.
Definition: mymath.h:103
Struct for representing points in 3D space.
Definition: mymath.h:56