G+Smo  24.08.0
Geometry + Simulation Modules
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
gsSolid.h
Go to the documentation of this file.
1 
14 #pragma once
15 
16 #include <gsCore/gsLinearAlgebra.h>
17 
19 
25 
26 namespace gismo {
27 
31 template <class T>
32 class GISMO_EXPORT gsSolid : public gsSolidElement<T>
33 {
34 public:
35  typedef memory::shared_ptr<gsSolid> Ptr;
36  typedef memory::unique_ptr<gsSolid> uPtr;
37 
38  typedef gsSolidElement<T> SolidElement;
39  typedef typename gsSolidElement<T>::scalar_t scalar_t;
40  typedef typename gsSolidElement<T>::gsSolidHeVertexHandle gsSolidHeVertexHandle;
41  typedef typename gsSolidElement<T>::gsSolidHalfEdgeHandle gsSolidHalfEdgeHandle;
42  typedef typename gsSolidElement<T>::gsSolidHalfFaceHandle gsSolidHalfFaceHandle;
43  typedef typename gsSolidElement<T>::gsVolumeHandle gsVolumeHandle;
44  typedef gsMatrix<T> gsMatrixT;
45 
47  typedef typename std::vector<gsSolidHalfFaceHandle*>::iterator face_iterator;
48  typedef typename std::vector<gsGeometry<T> *>::const_iterator const_face_iterator;
49 
50  typedef typename std::vector<gsSolidHalfEdgeHandle*>::iterator edge_iterator;
51  typedef typename std::vector<gsSolidHalfEdgeHandle*>::const_iterator const_edge_iterator;
52 
53  typedef typename std::vector<gsSolidHeVertexHandle*>::iterator vertex_iterator;
54  typedef typename std::vector<gsSolidHeVertexHandle*>::const_iterator const_vertex_iterator;
55 
56  typedef typename std::vector<gsVolumeHandle*>::iterator volume_iterator;
57  typedef typename std::vector<gsVolumeHandle*>::const_iterator const_volume_iterator;
58 
59 public:
60 
61  unsigned numVertices;
62  unsigned numHalfEdges;
63  unsigned numHalfFaces;
64  unsigned numVolumes;
65 
66  std::vector<gsSolidHeVertexHandle > vertex;
67  std::vector<gsSolidHalfEdgeHandle > edge;
68  std::vector<gsSolidHalfFaceHandle > face;
69  std::vector<gsVolumeHandle > volume;
70 
71  bool manifold;
72  bool initialized;
73 
74 protected:
75  gsBoundingBox<T> bb;
76  bool FaceCCW; // true if vertices of the outer loop of a face are ordered in a CCW fashion when viewing from infinity
77 
78 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
79 // Constructors
80 public:
81 
82  gsSolid(int const & i = 0) : SolidElement(i), initialized(false)
83  {
84  numHalfFaces = 0;
85  numVertices = 0;
86  numVolumes = 0;
87  numHalfEdges = 0;
88  manifold = true;
89  FaceCCW = true;
90  }
91 
92  virtual ~gsSolid();
93 
94 private: // disable copying (it can be done but is not implemented)
95  gsSolid( const gsSolid& );
96  gsSolid& operator=( const gsSolid& );
97 
98 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
99 // Accessors= iterators on vertices, faces, edges, boundingbox
100 public:
101  inline int nVolumes() const { return volume.size();}
102 
103  inline int nHalfFaces() const { return face.size();}
104 
105  inline int nVertices() const { return vertex.size();}
106 
107  inline size_t nHalfEdges() const { return edge.size();}
108 
109  inline bool isFaceCCW() const { return FaceCCW;}
110 
111  inline gsSolidHeVertexHandle getVertexFromID(int const & _id) const
112  {return *(vertex.begin()+_id);}
113 
114  inline gsSolidHalfEdgeHandle getHalfEdgeFromID(int const & _id) const
115  {return *(edge.begin()+_id);}
116 
117  inline gsSolidHalfFaceHandle getHalfFaceFromID(int const & _id) const
118  {return *(face.begin()+_id);}
119 
120  gsBoundingBox<T> getBoundingBox() const {return bb;}
121 
122 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
123 // Non-constant members
124 public:
126  void addHeVertex(scalar_t const& x, scalar_t const& y, scalar_t const& z=0);
127 
131  gsSolidHalfFaceHandle addFace(std::vector<gsSolidHeVertexHandle> V);
132 
133  gsSolidHalfFaceHandle addFace(std::vector<gsSolidHeVertexHandle> V,
134  gsTrimSurface<T> * tsurf);
135 
137  //
140  gsSolidHalfFaceHandle addFace(std::vector< std::vector<gsSolidHeVertexHandle> > loopV,
141  gsTrimSurface<T> * tsurf);
142 
143  gsSolidHalfFaceHandle addFace_PlanarPolygon(std::vector<gsSolidHeVertexHandle> V);
144 
146  gsSolidHalfFaceHandle addFace_4Vertices(gsSolidHeVertexHandle v0,
147  gsSolidHeVertexHandle v1,
148  gsSolidHeVertexHandle v2,
149  gsSolidHeVertexHandle v3)
150  {
151  std::vector<gsSolidHeVertexHandle> V(4);
152  V[0] = v0; V[1] = v1; V[2] = v2; V[3] = v3;
153  return addFace(V);
154  }
155 
161  gsSolidHalfFaceHandle splitFace(gsSolidHalfFaceHandle f,
162  gsSolidHeVertexHandle startVertex,
163  gsSolidHeVertexHandle endVertex,
164  gsBSpline<T> *domainSpline);
165 
167  void addVolume(gsVolumeHandle vol)
168  {
169  volume.push_back(vol);
170  vol->setId(numVolumes++);
171  }
172 
174  void addVolume(std::vector<gsSolidHalfFaceHandle> hfaces)
175  {
176  gsVolumeHandle vol = this->makeVolume(hfaces);
177  addVolume(vol);
178  }
179 
181  void setHeMate();
182 
184  std::vector<gsSolidHalfEdgeHandle> detectNonConvexEdges(std::vector<int> const & ncEdgeV1, std::vector<int> const & ncEdgeV2);
185 
188  gsVolumeBlock<T> *newVolume(gsSolidHalfFaceHandle startingFace);
189 
191  void checkStructure(bool checkVerts = false) const;
192 
195  gsSolidHalfFace<T> *addFaceWithMate(const std::vector<gsSolidHeVertexHandle> &Verts, gsTrimSurface<T> *surf);
196 
200  void insertNewVertex(gsSolidHalfEdgeHandle he);
201 
204  void handleImpedingEdges(gsSolidHalfEdgeHandle he);
205 
206  //void addPatch(gsPatch<T> *f) { this->addFace(f) ;};
207  //void addCurve(gsCurve<T> *f) { this->addEdge(f) ;};
208 
209 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
210 // Const members
211 public:
214  std::vector<gsSolidHalfEdgeHandle> impedingEdges(gsSolidHalfEdgeHandle he) const;
215 
217  gsMultiPatch<T> plotEdgeGraph();
218 
220  virtual std::ostream &print(std::ostream &os) const;
221 };
222 
223 } // namespace gismo
224 
225 #ifndef GISMO_BUILD_LIB
226 #include GISMO_HPP_HEADER(gsSolid.hpp)
227 #endif
Class for a trim surface.
Definition: gsTrimSurface.h:33
Provides gsVolumeBlock class.
Provides gsSolidHeVertex - a vertex of a gsSolid.
gsSolidHalfFaceHandle addFace_4Vertices(gsSolidHeVertexHandle v0, gsSolidHeVertexHandle v1, gsSolidHeVertexHandle v2, gsSolidHeVertexHandle v3)
add one face as a trimmed surface, the order of the vertices in V must be either CCW or CW when viewi...
Definition: gsSolid.h:146
A B-spline function of one argument, with arbitrary target dimension.
Definition: gsBSpline.h:50
void addVolume(std::vector< gsSolidHalfFaceHandle > hfaces)
add a volume using handles of its half faces
Definition: gsSolid.h:174
std::vector< gsSolidHalfFaceHandle * >::iterator face_iterator
Iterators.
Definition: gsSolid.h:47
Provides gsSolidElement class - interface for an element (vertex, edge or face) of a solid...
Container class for a set of geometry patches and their topology, that is, the interface connections ...
Definition: gsMultiPatch.h:33
void addVolume(gsVolumeHandle vol)
add a volume using its handle
Definition: gsSolid.h:167
Class for representing a solid made up of vertices, edges, faces, and volumes.
Definition: gsSolid.h:32
This is the main header file that collects wrappers of Eigen for linear algebra.
Provides gsSolidHalfEdge - a half-edge of a gsSolid.
Provides gsSolidHalfFace - a (half-)face of a gsSolid.
Provides gsBoundingBox class.