G+Smo  25.01.0
Geometry + Simulation Modules
 
Loading...
Searching...
No Matches
gsSolidHalfEdge.h
Go to the documentation of this file.
1
14#pragma once
15
17
18namespace gismo {
19
20template <class T>
21class gsSolidHalfEdge : public gsSolidElement<T>
22{
23public:
24 typedef gsSolidElement<T> SolidElement;
25 typedef typename SolidElement::scalar_t scalar_t;
26 typedef gsSolidHeVertex<T> Vertex;
27 typedef gsSolidHalfEdge<T> HalfEdge;
28 typedef gsSolidHalfFace<T> HalfFace;
29/* typedef gsVector3d<T> gsVector;
30 typedef gsVector * gsVectorHandle; */
31
32public:
33
34 HalfEdge* mate;
35
36 Vertex* source;
37 HalfEdge* next;
38 HalfEdge* prev;
39 HalfFace* face;// parent face
40
41 //gsGeometry<T> * trim_curve;
42 bool is_convex;
43private:
44 int loopNum; // loop number
45
47public:
48 int loopN() const {return loopNum;}
49 Vertex* target() const {return mate->source;}
50
51public:
52 gsSolidHalfEdge() : SolidElement() { eps = 2.220446049250313e-16; }
53
54
55 gsSolidHalfEdge(Vertex* v, HalfFace* f, int i, bool conv)
56 : SolidElement(i), source(v), face(f), is_convex(conv)
57 {
58 mate = 0;
59 next = 0;
60 prev = 0;
61 loopNum = 0;
62 //trim_curve = 0;
63 eps = 2.220446049250313e-16;
64 }
65
66 gsSolidHalfEdge(Vertex* v, HalfFace* f, int i, bool conv, int loopN) :
67 SolidElement(i), source(v), face(f), is_convex(conv), loopNum(loopN)
68 {
69 mate = 0;
70 next = 0;
71 prev = 0;
72 eps = 2.220446049250313e-16;
73 }
74
75
76 explicit gsSolidHalfEdge(int i) : SolidElement(i) { }
77
79 bool isEquiv(HalfEdge* other, T tolFactor=1e-8) const
80 {
81 using std::abs;
82 T tol = tolFactor*eps;
83 return source->isEquiv(other->source, tol) && target()->isEquiv(other->target(), tol);
84 }
85
86 virtual ~gsSolidHalfEdge() { }
87
89 virtual std::ostream &print(std::ostream &os) const {
90 os<<"\ngsSolidHalfEdge number: " << this->getId() << " source:" << *source << " target: " << *target() << std::endl;
91 return os; }
92
93 T eps;
95 // TODO: get rid of the following, using the indexOfEdge instead
96 int trimLoopInd(T tolerance){ GISMO_UNUSED(tolerance); return this->face->indexOfEdge(this); }
97 int trimLoopInd();
98
100 HalfEdge* moveAlongEdge(int n = 1)
101 {
102 HalfEdge* edge = this;
103 for (int times = 0; times < n; times++)
104 {
105 edge = edge->next;
106 }
107
108 return edge;
109 }
110};
111
112//================================================================
113// Source
114//================================================================
115
117template<class T>
118std::ostream &operator<<(std::ostream &os, const gsSolidHalfEdge<T>& me)
119{return me.print(os); }
120
121template<class T>
122int gsSolidHalfEdge<T>::trimLoopInd()
123{
124 return trimLoopInd(eps);
125}
126
127
128} // namespace gismo
129
#define GISMO_UNUSED(x)
Definition gsDebug.h:112
Provides gsSolidElement class - interface for an element (vertex, edge or face) of a solid.
The G+Smo namespace, containing all definitions for the library.