TexGen
DomainPrism.h
Go to the documentation of this file.
1/*=============================================================================
2TexGen: Geometric textile modeller.
3Copyright (C) 2020 Louise Brown
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 "Domain.h"
22#include "Yarn.h"
23#include "Plane.h"
24
25namespace TexGen
26{
27 using namespace std;
28
30
36 {
37 public:
39
44 CDomainPrism(const vector<XY> &Points, XYZ &start, XYZ &end);
45 CDomainPrism(TiXmlElement &Element);
46 ~CDomainPrism(void);
47
48 CDomain* Copy() const { return new CDomainPrism(*this); }
49
50 void PopulateTiXmlElement(TiXmlElement &Element, OUTPUT_TYPE OutputType = OUTPUT_STANDARD) const;
51
54 vector<pair<int, int> > GetRepeatLimits(const CYarn &Yarn) const { return vector<pair<int, int> >(); }
56 vector<XYZ> GetTranslations(const CYarn &Yarn) const { return vector<XYZ>(); }
57
60 void ClipMeshToDomain(CMesh &Mesh, bool bFillGaps = true) const;
61
64 void ClipIntersectMeshToDomain(CMesh &Mesh, bool bFillGaps = true) const;
65
66 bool ClipMeshToDomain(CMesh &Mesh, vector<CMesh> &DomainMeshes, bool bFillGaps = true) const; //{ return false; }
67 bool ClipIntersectMeshToDomain(CMesh &Mesh, vector<CMesh> &DomainMeshes, bool bFillGaps) const;
68 string GetType() const { return "CDomainPrism"; }
69
70 const vector<XY> &GetPoints() const { return m_Points; }
71
73 void Grow(double dDistance) {};
75 void Rotate(WXYZ Rotation) {};
77 void Translate(XYZ Vector) {};
79 void Deform(CLinearTransformation Transformation) {};
80
82 bool PointInDomain(const XYZ &Point) const { return false; }
83
85 void GeneratePlanes();
86 void GetMeshWithPolygonEnd(CMesh &Mesh);
87
88 void GetPolygonLimits(XYZ &StartPoint, XYZ *SizeVecs);
89
90 protected:
92
100 //pair<double, double> GetLimits(XYZ RepeatVector, const CMesh &Mesh) const;
101
103
107 //bool MeshIntersectsDomain(const CMesh &Mesh) const;
108
110 void BuildMesh();
111
113 bool GetPlane(XYZ *points, PLANE &plane);
115 void RemoveDuplicatePlanes();
117 bool PlaneEqual(PLANE Plane1, PLANE Plane2);
118
121 static bool FillGaps(CMesh &Mesh, const PLANE &Plane, vector<int> &Polygon, bool bMeshGaps = true);
122
124 mutable CYarn m_Yarn;
125
127 vector<PLANE> m_ElementPlanes;
128
130 mutable vector<XY> m_Points;
131 };
132
133}; // namespace TexGen
#define CLASS_DECLSPEC
Definition: Misc.h:35
Abstract base class representing the domain in which a textile cell may lie.
Definition: Domain.h:34
Domain implementation described using extrusion of a polygon outline.
Definition: DomainPrism.h:36
vector< pair< int, int > > GetRepeatLimits(const CYarn &Yarn) const
Definition: DomainPrism.h:54
vector< PLANE > m_ElementPlanes
Planes corresponding to mesh elements.
Definition: DomainPrism.h:127
vector< XYZ > GetTranslations(const CYarn &Yarn) const
Get the translation vectors necessary to fully fill the domain.
Definition: DomainPrism.h:56
void Grow(double dDistance)
Move all the planes by given distance along their normal.
Definition: DomainPrism.h:73
string GetType() const
Derived class should return the class name.
Definition: DomainPrism.h:68
bool PointInDomain(const XYZ &Point) const
Check if a point lies within the domain.
Definition: DomainPrism.h:82
CDomain * Copy() const
Definition: DomainPrism.h:48
const vector< XY > & GetPoints() const
Definition: DomainPrism.h:70
void Rotate(WXYZ Rotation)
Rotate the domain by given rotation quaternion.
Definition: DomainPrism.h:75
CYarn m_Yarn
Create the domain as yarn with constant polygon section and two nodes.
Definition: DomainPrism.h:124
void Deform(CLinearTransformation Transformation)
Deform the domain by given linear transformation.
Definition: DomainPrism.h:79
void Translate(XYZ Vector)
Translate the domain by given vector.
Definition: DomainPrism.h:77
vector< XY > m_Points
Prism section points.
Definition: DomainPrism.h:130
Represents a linear transformation as a 3x3 matrix.
Defines the nodes and elements of a surface or volume mesh.
Definition: Mesh.h:58
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.
OUTPUT_TYPE
Definition: Misc.h:105
@ OUTPUT_STANDARD
Definition: Misc.h:107
Struct for representing a Plane.
Definition: Plane.h:25
Struct for representing a quaternion.
Definition: mymath.h:38
Struct for representing points in 3D space.
Definition: mymath.h:56