TexGen
Textile3DWeave.h
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#pragma once
21#include "Textile.h"
22#include "DomainPlanes.h"
23#include "SectionPowerEllipse.h"
24#include "PatternDraft.h"
25
26
27namespace TexGen
28{
29 using namespace std;
30
31 class CPatternDraft;
32
33 enum
34 {
38 };
39
40 enum
41 {
44 WEFT
45 };
46
47 enum
48 {
52 };
53
54 typedef int PATTERN3D;
55
57 struct YARNDATA
58 {
59 double dWidth;
60 double dHeight;
61 double dSpacing;
62 //int iFibresPerYarn;
63 //double dFibreDiameter;
64 };
65
68 {
69 public:
70
72
81 CTextile3DWeave(int iNumXYarns, int iNumYYarns, double dXSpacing, double dYSpacing,
82 double dXHeight, double dYHeight, bool bRefine = false);
83 CTextile3DWeave(TiXmlElement &Element);
84 virtual ~CTextile3DWeave(void);
85
86 virtual CTextile* Copy() const { return new CTextile3DWeave(*this); }
87 virtual string GetType() const { return "CTextile3DWeave"; }
88 virtual void PopulateTiXmlElement(TiXmlElement &Element, OUTPUT_TYPE OutputType);
89
91
94 void SetThickness(double dThickness);
96 void SetMaxVolFraction( double dVolFraction );
98 void SetXYarnWidths(int iIndex, double dWidth);
100 void SetYYarnWidths(int iIndex, double dWidth);
102 void SetXYarnHeights(int iIndex, double dHeight);
104 void SetYYarnHeights(int iIndex, double dHeight);
106 void SetXYarnSpacings(int iIndex, double dSpacing);
108 void SetYYarnSpacings(int iIndex, double dSpacing);
109
110
112 double GetXYarnWidths(int iIndex) const;
114 double GetYYarnWidths(int iIndex) const;
116 double GetXYarnHeights(int iIndex) const;
118 double GetYYarnHeights(int iIndex) const;
120 double GetXYarnSpacings(int iIndex) const;
122 double GetYYarnSpacings(int iIndex) const;
124 double GetXYarnGapSize(int iIndex) const;
126 double GetYYarnGapSize(int iIndex) const;
127
129 void SetXYarnWidths(double dWidth);
131 void SetYYarnWidths(double dWidth);
133 void SetWarpYarnWidths( double dWidth );
135 void SetBinderYarnWidths( double dWidth );
137 void SetXYarnHeights(double dHeight);
139 void SetYYarnHeights(double dHeight);
141 void SetWarpYarnHeights( double dHeight );
143 void SetBinderYarnHeights( double dHeight );
145 void SetXYarnSpacings(double dSpacing);
147 void SetYYarnSpacings(double dSpacing);
149 void SetWarpYarnSpacings( double dWidth );
151 void SetBinderYarnSpacings( double dWidth );
153 void SetWeftYarnPower( double dPower ){ m_dWeftPower = dPower;}
155 void SetWarpYarnPower( double dPower ){ m_dWarpPower = dPower;}
157 void SetBinderYarnPower( double dPower ){ m_dBinderPower = dPower;}
158
160
164 void SetYarnLinearDensity( int iYarnType, double dValue, string Units = "kg/m" );
165
167
170 void SetFibreDensity(int iYarnType, double dValue, string Units = "kg/m^3" );
172
176 void SetFibreArea(int iYarnType, double dValue, string Units = "m^2" );
178
181 void SetFibresPerYarn( int iYarnType, int iNumFibres );
184
187 void SetFibreDiameter( int iYarnType, double dValue, string Units = "m" );
189
194 double GetFibreArea( int iYarnType, string Units );
195
197 void SetYarnWidths(double dWidth);
199 void SetYarnHeights(double dHeight);
201 void SetYarnSpacings(double dSpacing);
202
203
205 void AddYLayers(int x, int iNumberLayers);
207 void AddXLayers(int y, int iNumberLayers);
209 void AddYLayers(int iNumberLayers = 1);
211 void AddXLayers(int iNumberLayers = 1);
213 void AddXYarn(int y, PATTERN3D Pattern );
215 void AddYYarn( int x, PATTERN3D Pattern );
217 void AddWarpLayer();
219 void AddBinderLayer();
221 void AddNoYarnLayer();
223 void DeleteYLayers(int x, int iNumberLayers);
225 void DeleteXLayers(int y, int iNumberLayers);
227 void DeleteYLayers(int iNumberLayers = 1);
229 void DeleteXLayers(int iNumberLayers = 1);
231 void SwapPosition(int x, int y, int iLevel1, int iLevel2);
232
234 int GetNumYLayers(int x) const;
236 int GetNumXLayers(int y) const;
238 int GetMaxNumLayers() const;
240 virtual int GetNumBinderLayers() const;
241
243 void GetWarpYarnInfo( int& iNumBinderYarns, int& iNumWarpYarns, int& iBinderRatio, int& iWarpRatio, YARNDATA& AveWarp, YARNDATA& AveBinder ) const;
244
246 bool IsBinderYarn( int index ) const;
248 int GetXYarnIndex( int YarnInd );
249
251 int FindNextCellIndex( int index ) const;
253 int FindNextYCellIndex( int Starti, int j, int k ) const;
255 int FindPrevYCellIndex( int Starti, int j, int k ) const;
256
258 void SetWarpRatio( int iWarpRatio );
260 void SetBinderRatio( int iBinderRatio );
262 void SetBinderPattern();
264 void SetBinderPattern( vector<bool> &BinderPattern );
265
267 virtual void SetupLayers( int iNumWarpLayers, int iNumWeftLayers, int iNumBinderLayers = 1 );
268
270 void SetGapSize(double dGapSize);
271
273 void SetResolution(int iResolution);
274
276 void AssignSectionMesh(const CSectionMesh &SectionMesh);
277
279 CDomainPlanes GetDefaultDomain( bool bAddedDomainHeight = true );
280
282
285 void AssignDefaultDomain( bool bAddedDomainHeight = true );
286
287 void SetDomainZValues();
289 virtual void FindMinMaxZ( double& dMinZ, double& dMaxZ );
290
293 void CheckUpVectors( int WarpIndex, bool Yarn = PATTERN3D_XYARN, bool bYarnsIndex = false ) const;
294
295 virtual string GetDefaultName() const;
297
302 virtual void SetupWeftRow( vector<int>& Layers, vector<int>& Row, int NumWarps, int Weft );
303
306 void ShapeWeftYarns() const;
307
308 virtual void ConvertToPatternDraft( int iWeftOrder = BOTTOM_TO_TOP );
309 bool NoYarnCell( vector<PATTERN3D> &Cell );
310
311 // Accessor methods
312 virtual double GetWidth() const;
313 double GetHeight() const;
314 int GetNumXYarns() const { return m_iNumXYarns; }
315 int GetNumYYarns() const { return m_iNumYYarns; }
316 double GetFabricThickness() const { return m_dFabricThickness; }
317 double GetMaxVolFraction() const { return m_dMaxVolumeFraction; }
318 double GetGapSize() const { return m_dGapSize; }
319 double GetAverageYarnSpacing() const { return (GetWidth()+GetHeight())/(m_iNumXYarns+m_iNumYYarns); }
320 double GetAverageYarnWidth() const;
321 const vector<PATTERN3D> &GetCell(int x, int y) const;
322 int GetResolution() const { return m_iResolution; }
323 vector<CYarn*> GetXYarns(int iIndex);
324 vector<CYarn*> GetYYarns(int iIndex);
325 int GetYarnIndex(int x, int y, int z) const;
326 double GetWarpPower() const { return m_dWarpPower; }
327 double GetWeftPower() const { return m_dWeftPower; }
328 double GetBinderPower() const { return m_dBinderPower; }
329 bool GetRefine() const { return m_bRefine; }
330 virtual double GetAverageWeftYarnSpacing() const { return GetWidth()/m_iNumYYarns; }
331 double GetAverageWeftYarnWidth() const;
332 double GetAverageWeftYarnHeight() const;
333 vector<PATTERN3D> &GetCell(int x, int y);
334 void SetWeftRepeat( bool WeftRepeat ) { m_bWeftRepeat = WeftRepeat; }
335 CPatternDraft &GetPatternDraft() { return m_PatternDraft; }
336
337 void CalculateReedDesign( string Filename );
338
339 protected:
341 bool Valid() const;
342
344
357 virtual bool BuildTextile() const;
359
364 //void CorrectInterference() const;
365 //bool NeedsMidSection(int iYarn, int iSection) const;
366
367
369
371 CSectionPowerEllipse* GetWeftCrossSection( int WeftYarnIndex ) const;
373 CSection* GetCrossSection( int YarnIndex, int Node = -1 ) const;
374
376 XYZ GetUpVector( XYZ CheckNodes[], bool bYarn ) const;
378
383 void InsertBinderNode( CSectionPowerEllipse* YarnSection, double t, XYZ& WeftNode, int& CurrentNode, int BinderYarnIndex, double Offset, bool bInsert = true ) const;
384
386
391 void InsertBinderNode( CSection* YarnSection, double t, XYZ& WeftNode, int& CurrentNode, int BinderYarnIndex, double Offset, bool bInsert = true ) const;
392
394 void ReplaceLastNode( int BinderYarnIndex, XYZ& NewNode, XYZ& BinderNode ) const;
396
400 bool AdjustPowerEllipseSectionWidth( double &HeightReduction, double &MaxWidth, double TargetArea, CSectionPowerEllipse* YarnSection ) const;
401
402 void FindPowerEllipseSectionHeight( double& MaxHeight, double& TargetArea, CSectionPowerEllipse* YarnSection ) const;
403
404 bool AdjustPowerEllipsePower( double &HeightReduction, double TargetArea, CSectionPowerEllipse* YarnSection, double MinPower ) const;
405
406 void ReducePowerEllipseHeight( double& TargetArea, CSectionPowerEllipse* YarnSection ) const;
407
408 void SetYarnProperties( CYarn& Yarn, int iType ) const;
409
410 pair<int, int> GetCellCoordinates(int iIndex) const;
411
412 int FindWeftHeight( const vector<PATTERN3D>& Cell ) const;
413
414 int AddWeftNodes( int CurrentNode, int XNode, int i, int j ) const;
415
416 void InsertWeftNode( CSection* YarnSection, double t, XYZ& WarpNode, int& CurrentNode, int WeftYarnIndex, double Offset, bool bInsert = true ) const;
417
418 int FindWarpAboveIndex( const vector<PATTERN3D> &Cell, int iIndex ) const;
419 int FindWarpBelowIndex( const vector<PATTERN3D> &Cell, int iIndex ) const;
420
421 void RemoveCell( int x, int y);
423 bool CheckCells() const;
424
426 bool BinderYarns() const;
427
430
431 int m_iNumXYarns, m_iNumYYarns;
432 int m_iWarpRatio, m_iBinderRatio;
433 vector<bool> m_BinderPattern;
435 vector<vector<PATTERN3D> > m_Pattern;
441 mutable double m_dMinZ;
442 mutable double m_dMaxZ;
443 double m_dWarpPower, m_dWeftPower, m_dBinderPower;
445 CProperties m_Properties[3];
447
448 mutable vector<YARNDATA> m_XYarnData;
449 mutable vector<YARNDATA> m_YYarnData;
450 mutable vector<vector<int> > m_XYarns;
451 mutable vector<vector<int> > m_YYarns;
452 };
453}; // namespace TexGen
454
455
456
457
458
459
460
#define CLASS_DECLSPEC
Definition: Misc.h:35
Domain implementation described using planes, the simplest of which would be a box.
Definition: DomainPlanes.h:37
Object container to help handle memory management issues.
Class to store properties related to a textile and/or yarn.
Definition: Properties.h:102
Abstract base class respresenting a yarn cross-section.
Definition: Section.h:31
Abstract base class to create a 2D mesh of a section.
Definition: SectionMesh.h:33
Represents a 3D woven textile.
double GetAverageYarnSpacing() const
void SetWeftYarnPower(double dPower)
Set the power for power ellipse section for yarns parallel to Y axis.
vector< YARNDATA > m_XYarnData
vector< vector< int > > m_XYarns
double GetGapSize() const
void SetBinderYarnPower(double dPower)
Set the power for power ellipse section for yarns parallel to X axis in binder yarn positions.
void SetWarpYarnPower(double dPower)
Set the power for power ellipse section for yarns parallel to X axis in warp yarn positions.
double GetWarpPower() const
virtual string GetType() const
Derived class should return the class name.
void SetWeftRepeat(bool WeftRepeat)
vector< bool > m_BinderPattern
CPatternDraft & GetPatternDraft()
virtual double GetAverageWeftYarnSpacing() const
double GetBinderPower() const
vector< YARNDATA > m_YYarnData
vector< vector< PATTERN3D > > m_Pattern
virtual CTextile * Copy() const
vector< vector< int > > m_YYarns
double GetWeftPower() const
CPatternDraft m_PatternDraft
Class for generating pattern draft from weave pattern.
CObjectContainer< CSectionMesh > m_pSectionMesh
double GetMaxVolFraction() const
double GetFabricThickness() const
Represents a textile cell containing yarns.
Definition: Textile.h:39
Represents a yarn consisting of master nodes, section and interpolation function.
Definition: Yarn.h:49
Namespace containing a series of customised math operations not found in the standard c++ library.
@ TOP_TO_BOTTOM
@ BOTTOM_TO_TOP
@ ALTERNATE_WEFT_STACK
OUTPUT_TYPE
Definition: Misc.h:105
int PATTERN3D
@ PATTERN3D_NOYARN
@ PATTERN3D_XYARN
@ PATTERN3D_YYARN
Struct for representing points in 3D space.
Definition: mymath.h:56
Data structure to keep track of yarn parameters.