TexGen
TextileWeave.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 "PatternDraft.h"
24
25namespace TexGen
26{
27 using namespace std;
28
29 class CPatternDraft;
30
31 enum
32 {
35 };
36
37 typedef bool PATTERN2D;
38
41 {
42 public:
43
45 CTextileWeave(int iNumYYarns, int iNumXYarns, double dSpacing, double dThickness);
46 CTextileWeave(TiXmlElement &Element);
47 virtual ~CTextileWeave(void);
48
49 virtual CTextile* Copy() const { return new CTextileWeave(*this); }
50 virtual string GetType() const { return "CTextileWeave"; }
51 virtual void PopulateTiXmlElement(TiXmlElement &Element, OUTPUT_TYPE OutputType);
52
54
58 void SetThickness(double dThickness, bool bAdjustYarnHeights = true);
60 void SetXYarnWidths(int iIndex, double dWidth);
62 void SetYYarnWidths(int iIndex, double dWidth);
64 void SetXYarnHeights(int iIndex, double dHeight);
66 void SetYYarnHeights(int iIndex, double dHeight);
68 void SetXYarnSpacings(int iIndex, double dSpacing);
70 void SetYYarnSpacings(int iIndex, double dSpacing);
71
73 double GetXYarnWidths(int iIndex) const;
75 double GetYYarnWidths(int iIndex) const;
77 double GetXYarnHeights(int iIndex) const;
79 double GetYYarnHeights(int iIndex) const;
81 double GetXYarnSpacings(int iIndex) const;
83 double GetYYarnSpacings(int iIndex) const;
85 double GetXYarnGapSize(int iIndex) const;
87 double GetYYarnGapSize(int iIndex) const;
88
90 void SetXYarnWidths(double dWidth);
92 void SetYYarnWidths(double dWidth);
94 void SetXYarnHeights(double dHeight);
96 void SetYYarnHeights(double dHeight);
98 void SetXYarnSpacings(double dSpacing);
100 void SetYYarnSpacings(double dSpacing);
101
103 void SetYarnWidths(double dWidth);
105 void SetYarnHeights(double dHeight);
107 void SetYarnSpacings(double dSpacing);
108
110 void SetGapSize(double dGapSize);
111
113 void SetResolution(int iResolution);
114
116 void AssignSectionMesh(const CSectionMesh &SectionMesh);
117
119 virtual CDomainPlanes GetDefaultDomain( bool bSheared = false, bool bAddedHeight = true );
120
122
125 void AssignDefaultDomain( bool bSheared = false, bool bAddedHeight = true );
126
127 // Flatten the yarn
136 bool FlattenYarns(double dFlatLevel, int iUpDownBoth=0);
137
138 virtual string GetDefaultName() const;
139
141 virtual void RefineTextile( bool bCorrectWidths = true, bool bCorrectInterference = true, bool bPeriodic = true ){};
142 void CorrectEdgeInterference();
143
144 virtual void ConvertToPatternDraft( /*CPatternDraft& PatternDraft*/ ) {};
145
146 // Accessor methods
147 double GetWidth() const;
148 double GetHeight() const;
149 int GetNumXYarns() const { return m_iNumXYarns; }
150 int GetNumYYarns() const { return m_iNumYYarns; }
151 double GetFabricThickness() const { return m_dFabricThickness; }
152 double GetGapSize() const { return m_dGapSize; }
153 double GetAverageYarnSpacing() const { return (GetWidth()+GetHeight())/(m_iNumXYarns+m_iNumYYarns); }
154 double GetAverageYarnWidth() const;
155 const vector<PATTERN2D> &GetCell(int x, int y) const;
156 int GetResolution() const { return m_iResolution; }
157 vector<CYarn*> GetXYarns(int iIndex);
158 vector<CYarn*> GetYYarns(int iIndex);
159 int GetYarnIndex(int x, int y, int z) const;
160 CPatternDraft &GetPatternDraft() { return m_PatternDraft; }
161
162 protected:
164 bool Valid() const;
165
167
184 virtual bool BuildTextile() const;
186
191 virtual void CorrectInterference() const;
192 bool NeedsMidSection(int iYarn, int iSection) const;
193
195
200 void CorrectYarnWidths() const;
201
204
205 pair<int, int> GetCellCoordinates(int iIndex) const;
206 vector<PATTERN2D> &GetCell(int x, int y);
207
209 struct YARNDATA
210 {
211 double dWidth;
212 double dHeight;
213 double dSpacing;
214 };
215
216 int m_iNumXYarns, m_iNumYYarns;
217 vector<vector<PATTERN2D> > m_Pattern;
222
223 mutable vector<YARNDATA> m_XYarnData;
224 mutable vector<YARNDATA> m_YYarnData;
225 mutable vector<vector<int> > m_XYarns;
226 mutable vector<vector<int> > m_YYarns;
227 };
228}; // namespace TexGen
229
230
231
232
233
234
235
236
#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.
Abstract base class to create a 2D mesh of a section.
Definition: SectionMesh.h:33
Represents a textile cell containing yarns.
Definition: Textile.h:39
Represents a woven textile.
Definition: TextileWeave.h:41
int GetNumXYarns() const
Definition: TextileWeave.h:149
virtual string GetType() const
Derived class should return the class name.
Definition: TextileWeave.h:50
CObjectContainer< CSectionMesh > m_pSectionMesh
Definition: TextileWeave.h:221
virtual CTextile * Copy() const
Definition: TextileWeave.h:49
CPatternDraft m_PatternDraft
Class for generating pattern draft from weave pattern.
Definition: TextileWeave.h:203
vector< vector< PATTERN2D > > m_Pattern
Definition: TextileWeave.h:217
int GetResolution() const
Definition: TextileWeave.h:156
CPatternDraft & GetPatternDraft()
Definition: TextileWeave.h:160
double GetGapSize() const
Definition: TextileWeave.h:152
vector< vector< int > > m_XYarns
Definition: TextileWeave.h:225
vector< vector< int > > m_YYarns
Definition: TextileWeave.h:226
virtual void RefineTextile(bool bCorrectWidths=true, bool bCorrectInterference=true, bool bPeriodic=true)
Call refine functions for textile weave. Currently only defined for 2D weave to allow refinement afte...
Definition: TextileWeave.h:141
vector< YARNDATA > m_XYarnData
Definition: TextileWeave.h:223
double GetFabricThickness() const
Definition: TextileWeave.h:151
virtual void ConvertToPatternDraft()
Definition: TextileWeave.h:144
int GetNumYYarns() const
Definition: TextileWeave.h:150
double GetAverageYarnSpacing() const
Definition: TextileWeave.h:153
vector< YARNDATA > m_YYarnData
Definition: TextileWeave.h:224
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
bool PATTERN2D
Definition: TextileWeave.h:37
OUTPUT_TYPE
Definition: Misc.h:105
Data structure to keep track of yarn parameters.
Definition: TextileWeave.h:210