21 template <
class T>
class gsSolidHalfEdge;
24 class gsSolidHeVertex :
public gsSolidElement<T>
27 # define Eigen gsEigen
28 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
31 typedef gsSolidElement<T> SolidElement;
32 typedef typename SolidElement::gsSolidHeVertexHandle gsSolidHeVertexHandle;
33 typedef typename SolidElement::gsSolidHalfEdgeHandle gsSolidHalfEdgeHandle;
34 typedef typename SolidElement::gsSolidHalfFaceHandle gsSolidHalfFaceHandle;
40 gsSolidHalfEdgeHandle hed;
43 gsSolidHeVertex(scalar_t x, scalar_t y, scalar_t z = 0) : SolidElement(), coords(x,y,z), hed(0) { }
44 gsSolidHeVertex(scalar_t x, scalar_t y, scalar_t z,
int i) : SolidElement(i), coords(x,y,z), hed(0) { }
46 virtual ~gsSolidHeVertex(){ }
49 void move(scalar_t dx, scalar_t dy, scalar_t dz) {coords.x() += dx;coords.y() += dy;coords.z() += dz;}
54 gsVector3d<T> getCoordinate()
const {
return coords;}
55 T x ()
const {
return coords(0); }
56 T y ()
const {
return coords(1); }
57 T z ()
const {
return coords(2); }
59 std::ostream &print(std::ostream &os)
const;
62 std::vector<gsSolidHalfFaceHandle> getHalfFaces()
const;
65 gsSolidHalfEdgeHandle getHalfEdge(gsSolidHeVertexHandle anotherVertex)
const;
68 bool hasHalfEdge(gsSolidHeVertexHandle anotherVertex)
const;
71 std::vector< gsSolidHalfFaceHandle > getFacesContaining2Vertices(gsSolidHeVertexHandle anotherVertex,
bool const & IsBoundaryHalfEdge=
false)
const;
74 gsSolidHalfEdgeHandle getHalfEdgeOnFace(gsSolidHalfFaceHandle f,
bool dest);
77 std::vector<gsSolidHalfEdgeHandle> halfEdges()
const;
81 bool isEquiv(gsSolidHeVertexHandle other, T tol)
const
82 {
using std::abs;
if (
abs(x()-other->x())<=tol &&
abs(y()-other->y())<=tol &&
abs(z()-other->z())<=tol )
return true;
return false; }
89 std::ostream &gsSolidHeVertex<T>::print(std::ostream &os)
const
91 os<<
"Vertex " << this->getId() <<
"( "<<coords.x() <<
" " << coords.y() <<
" " << coords.z() <<
" )\n";
96 std::vector<typename gsSolidHeVertex<T>::gsSolidHalfFaceHandle> gsSolidHeVertex<T>::getHalfFaces()
const
99 std::vector< gsSolidHalfFaceHandle > faceList;
100 gsSolidHalfEdgeHandle he1 = hed;
101 gsSolidHalfEdgeHandle instant_he = he1;
104 faceList.push_back(instant_he->face);
105 instant_he = instant_he->prev->mate;
106 }
while (instant_he!= he1);
111 typename gsSolidHeVertex<T>::gsSolidHalfEdgeHandle gsSolidHeVertex<T>::getHalfEdge(gsSolidHeVertexHandle anotherVertex)
const
116 const gsSolidHalfEdgeHandle he1 = hed;
117 gsSolidHalfEdgeHandle instant_he = he1;
121 if (instant_he->target()==anotherVertex)
123 instant_he = instant_he->prev->mate;
124 }
while (instant_he!=he1);
126 GISMO_ERROR(
"ERROR:gsSolidHeVertex.h: No HE is found while it is supposed to be existent");
130 bool gsSolidHeVertex<T>::hasHalfEdge(gsSolidHeVertexHandle anotherVertex)
const
132 gsSolidHalfEdgeHandle he1 = hed;
133 gsSolidHalfEdgeHandle instant_he = he1;
136 if (instant_he->target()==anotherVertex) {
return true;};
137 instant_he = instant_he->prev->mate;
138 }
while (instant_he!=he1);
143 std::vector< typename gsSolidHeVertex<T>::gsSolidHalfFaceHandle >
145 gsSolidHeVertex<T>::getFacesContaining2Vertices(gsSolidHeVertexHandle anotherVertex,
bool const & IsBoundaryHalfEdge)
const
147 std::vector<gsSolidHalfFaceHandle> faceList;
148 if (IsBoundaryHalfEdge)
150 gsSolidHalfEdgeHandle he = getHalfEdge(anotherVertex);
152 faceList.push_back(he->face);
153 faceList.push_back(he->mate->face);
158 std::vector<gsSolidHalfFaceHandle> faceList1;
159 std::vector<gsSolidHalfFaceHandle> faceList2;
160 faceList1 = getHalfFaces();
161 faceList2 = anotherVertex->getHalfFaces();
163 for (
unsigned i=0;i!=faceList1.size();i++)
165 for (
unsigned j=0;j!=faceList2.size();j++)
167 if (faceList1[i]==faceList2[j]) {faceList.push_back(faceList1[i]);
break;};
176 typename gsSolidHeVertex<T>::gsSolidHalfEdgeHandle gsSolidHeVertex<T>::getHalfEdgeOnFace(
typename gsSolidHeVertex<T>::gsSolidHalfFaceHandle f,
bool dest)
178 gsSolidHalfEdgeHandle currentEdge = hed;
181 if(!dest && currentEdge->face == f)
return currentEdge;
182 currentEdge = currentEdge->mate;
183 if(dest && currentEdge->face == f)
return currentEdge;
184 currentEdge = currentEdge->next;
185 assert(currentEdge != hed);
190 std::vector<typename gsSolidHeVertex<T>::gsSolidHalfEdgeHandle> gsSolidHeVertex<T>::halfEdges()
const
192 gsSolidHalfEdgeHandle he1 = hed;
193 gsSolidHalfEdgeHandle instant_he = he1;
194 std::vector<gsSolidHalfEdgeHandle> heSet;
197 heSet.push_back(instant_he);
198 instant_he = instant_he->prev->mate;
199 }
while (instant_he!=he1);
Provides gsSolidElement class - interface for an element (vertex, edge or face) of a solid...
#define GISMO_ERROR(message)
Definition: gsDebug.h:118
This is the main header file that collects wrappers of Eigen for linear algebra.
EIGEN_STRONG_INLINE abs_expr< E > abs(const E &u)
Absolute value.
Definition: gsExpressions.h:4486