TexGen
BasicVolumes.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
22#include "Mesh.h"
23
24namespace TexGen
25{
26 using namespace std;
27
28// class CYarn;
29 class CTextile;
30
33 {
34 public:
35 CBasicVolumes(void);
36 ~CBasicVolumes(void);
37
38 bool CreateBasicVolumes(CTextile &Textile);
39 bool CreateBasicVolumes(string TextileName);
40
41 void SetSeed(double dSeed) { m_dSeed = dSeed; }
42 double GetSeed() { return m_dSeed; }
43
44 void SetPeriodic(bool bPeriodic) { m_bCreatePeriodic = bPeriodic; }
45 bool GetPeriodic() { return m_bCreatePeriodic; }
46
47 void SetDebug(bool bDebug) { m_bDebug = bDebug; }
48 bool GetDebug() { return m_bDebug; }
49
50 protected:
52 {
53 FORWARD = 1,
54 REVERSE = 2,
55 };
56
59 {
60 vector<int> SegmentIndices;
61 vector<int> YarnIndices;
62 vector<int> ContourNodes;
64 double dArea;
65 PROJECTED_REGION():dArea(0){}
66 };
67
69
73 {
74 bool operator()(const PROJECTED_REGION& left, const PROJECTED_REGION& right)
75 {
76 return left.dArea < right.dArea;
77 }
78 };
79
80 void SaveProjectedContoursToVTK(string Filename);
81 void SaveProjectedAreasToVTK(string Filename);
82 bool ValidProjectedMesh();
83 int SplitLinesByNodes(CMesh &Mesh);
84 int SplitLinesByLines(CMesh &Mesh);
85 int MergeStraightLines(CMesh &Mesh);
86 int RemoveDuplicateSegments(CMesh &Mesh);
87 int RemoveDegenerateSegments(CMesh &Mesh);
88 CMesh GetProjectedMesh(const CMesh &Mesh);
89 bool GetCommonEdgeIndices(int Indices1[3], int Indices2[3], int Common[2]);
90 bool CreateProjectedAreas();
91 bool SeedOuterBoundary();
92 bool RemoveOuterBoundary();
93 double GetRegionArea(const PROJECTED_REGION &Region);
94 bool CreateProjectedCenters();
95 bool PointInsideRegion(XYZ Point, int iRegion);
96 void CalculateYarnIndices();
97 bool MeshProjectedAreas();
110 bool GetMeshVerticalBounds(const CMesh &Mesh, XYZ Point, double &dMinZ, double &dMaxZ, bool bForceFind = false);
111
114 vector<CMesh> m_YarnMeshes;
115 vector<PROJECTED_REGION> m_ProjectedRegions;
116// vector<int> m_TriangleNeighbors;
117
118 // A map of triangle index to their region number
119 vector<int> m_TriangleRegions;
122 double m_dSeed;
125 };
126
127}; // namespace TexGen
128
129
130
131
132
133
134
135
136
137
138
139
140
#define CLASS_DECLSPEC
Definition: Misc.h:35
Class for meshing fabric unit cells.
Definition: BasicVolumes.h:33
vector< CMesh > m_YarnMeshes
Definition: BasicVolumes.h:114
vector< PROJECTED_REGION > m_ProjectedRegions
Definition: BasicVolumes.h:115
vector< int > m_TriangleRegions
Definition: BasicVolumes.h:119
void SetSeed(double dSeed)
Definition: BasicVolumes.h:41
void SetDebug(bool bDebug)
Definition: BasicVolumes.h:47
void SetPeriodic(bool bPeriodic)
Definition: BasicVolumes.h:44
Defines the nodes and elements of a surface or volume mesh.
Definition: Mesh.h:58
Represents a textile cell containing yarns.
Definition: Textile.h:39
Namespace containing a series of customised math operations not found in the standard c++ library.
Struct representing a region projected onto the XY plane.
Definition: BasicVolumes.h:59
Functor defining the < operator based on the projected region's area.
Definition: BasicVolumes.h:73
bool operator()(const PROJECTED_REGION &left, const PROJECTED_REGION &right)
Definition: BasicVolumes.h:74
Struct for representing points in 3D space.
Definition: mymath.h:56