TexGen
TextileOrthogonal.h
Go to the documentation of this file.
1/*=============================================================================
2TexGen: Geometric textile modeller.
3Copyright (C) 2011 Louise Brown
4This program is free software; you can redistribute it and/or
5modify it under the terms of the GNU General Public License
6as published by the Free Software Foundation; either version 2
7of the License, or (at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License
15along with this program; if not, write to the Free Software
16Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17=============================================================================*/
18
19#pragma once
20#include "Textile3DWeave.h"
21#include "SectionPowerEllipse.h"
22#include "SectionEllipse.h"
23#include "SectionHybrid.h"
24
25namespace TexGen
26{
27 using namespace std;
28
29
32 {
33 public:
34
36
46 CTextileOrthogonal(int iNumXYarns, int iNumYYarns, double dXSpacing, double dYSpacing,
47 double dXHeight, double dYHeight, bool bRefine = false, bool bWeavePattern = false );
48 CTextileOrthogonal(TiXmlElement &Element);
49 virtual ~CTextileOrthogonal(void);
50
51 virtual CTextile* Copy() const { return new CTextileOrthogonal(*this); }
52 virtual string GetType() const { return "CTextileOrthogonal"; }
53 virtual void PopulateTiXmlElement(TiXmlElement &Element, OUTPUT_TYPE OutputType);
54
56
59 void SwapBinderPosition( int x, int y );
60
62 //virtual void FindMinMaxZ( double& dMinZ, double& dMaxZ );
63
65
70 virtual void SetupLayers( int iNumWarpLayers, int iNumWeftLayers, int iNumBinderLayers = 1 );
72
75 virtual bool BuildTextile() const;
76 void ShapeWeftYarns() const;
77
78 virtual void ConvertToPatternDraft( int iWeftOrder = BOTTOM_TO_TOP );
80 virtual void SetupWeftRow( vector<int>& Layers, vector<int>& Row, int NumWarps, int Weft );
81 void ConsolidateCells();
82
83 protected:
85 void CheckBinderWidths() const;
87 void ShapeBinderYarns() const;
89 int AddBinderNodes( int CurrentNode, int i, int j ) const;
91 void AdjustBinderYarns() const;
93 void AdjustBinderYarnSection( int i, int j ) const;
94 void AdjustBinderYarnSection( int i, int j, int BinderYarnIndex, int WeftYarnIndex, int OppositeWeftYarnIndex, bool IsTop ) const;
96 bool AdjustMidLayerHeights() const;
97
98 void AdjustOuterWeftYarns() const;
99
100 void ChangeWeftSection( CSection& TopHalf, CSection&BottomHalf, int YarnIndex, int Node, double Offset) const;
101 void AdjustWeftToFitBinderHeight( int i, int j, CSectionPowerEllipse& PowerEllipseSection, double& MaxWidth, double& TargetArea, double& MaxVolumeFraction, double& FibreArea ) const;
102 bool AdjustWeftHeight( CSectionPowerEllipse& PowerEllipseSection, double& MaxWidth, double& TargetArea, double& MaxVolumeFraction, double& FibreArea, double TargetHeight ) const;
103 void AdjustBinderPosition( int iCellIndex, int i, int j, double dHeight, bool bIsTop ) const;
104 void ChangeBinderSection( CSection& TopHalf, CSection&BottomHalf, int YarnIndex, int Node, double Offset) const;
106 void OffsetYarn( int i, int j, int k, double dHeight, int YarnType ) const;
107
109 double GetHybridHeight( CSectionHybrid* Section ) const;
111 double GetHybridWidth( CSectionHybrid* Section ) const;
113 void ReplaceYarnSection( int YarnIndex, int Node, CSection& Section ) const;
115 void ReplaceThroughBinderSection( int BinderYarnIndex, int Node, CSection& Section, map<pair<int, int>, YARNDATA>::iterator& itBinderData ) const;
116
117 void ChangePowerEllipseSection( double& TargetArea, CSectionPowerEllipse* YarnSection, double FibreArea ) const;
118
119 int FindNextBinderIndex( int StartIndex ) const;
120
122 int FindBinderHeight( const vector<PATTERN3D>& Cell ) const;
123
125 void MoveBinderYarnPosition( vector<PATTERN3D> &Cell );
126
128 XY GetSectionPoint( CSection* YarnSection, double t ) const;
129
131 void CorrectCrimpInterference( int i, int j, int WeftYarnIndex, bool IsTop) const;
133 double GetHybridSectionWidth( int WarpIndex, int WeftIndex ) const;
134
135 int GetWeavePatternYarnIndex(int x, int y, int z) const;
136
138
144 //int AddWeftNodes(int CurrentNode, int XNode, int i, int j) const;
145 int AddWeftNodes(int CurrentNode, int i, int j, int WeftIndex) const;
146
147 vector<int> &GetYarnCell(int x, int y);
148 const vector<int> &GetYarnCell(int x, int y) const;
149 void RemoveYarnCell(int x, int y);
150
152 int GetWeftYarnIndex(const vector<int> &YarnCell, int n) const;
154 int FindWeftYarnHeight(const vector<PATTERN3D>& YarnCell, int WeftIndex) const;
156
159 int FindWeftYarnIndex(int WeftIndex) const;
160
161 bool BuildWeavePatternTextile() const;
162 mutable int m_iYYarnOffset;
163
164
165 mutable map<pair<int, int>, YARNDATA> m_BinderData;
166
171 vector<vector<int> > m_WeftYarns;
172
173 //vector<vector<PATTERN3D> > m_Pattern;
174 //bool m_Consolidated = false;
175
176 };
177}; // namespace TexGen
#define CLASS_DECLSPEC
Definition: Misc.h:35
Abstract base class respresenting a yarn cross-section.
Definition: Section.h:31
Hybrid of any number of other sections.
Definition: SectionHybrid.h:29
Represents a 3D woven textile.
Represents a textile cell containing yarns.
Definition: Textile.h:39
Represents a 3D orthogonal woven textile.
virtual string GetType() const
Derived class should return the class name.
virtual CTextile * Copy() const
vector< vector< int > > m_WeftYarns
bool m_bWeavePattern
Indicates whether textile is loaded from weave pattern.
map< pair< int, int >, YARNDATA > m_BinderData
Namespace containing a series of customised math operations not found in the standard c++ library.
@ BOTTOM_TO_TOP
OUTPUT_TYPE
Definition: Misc.h:105
Struct for representing points in 2D space.
Definition: mymath.h:103
Data structure to keep track of yarn parameters.