G+Smo  24.08.0
Geometry + Simulation Modules
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
gsSolidHalfEdge.h
Go to the documentation of this file.
1 
14 #pragma once
15 
17 
18 namespace gismo {
19 
20 template <class T>
21 class gsSolidHalfEdge : public gsSolidElement<T>
22 {
23 public:
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 
32 public:
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;
43 private:
44  int loopNum; // loop number
45 
47 public:
48  int loopN() const {return loopNum;}
49  Vertex* target() const {return mate->source;}
50 
51 public:
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 
117 template<class T>
118 std::ostream &operator<<(std::ostream &os, const gsSolidHalfEdge<T>& me)
119 {return me.print(os); }
120 
121 template<class T>
122 int gsSolidHalfEdge<T>::trimLoopInd()
123 {
124  return trimLoopInd(eps);
125 }
126 
127 
128 } // namespace gismo
129 
Provides gsSolidElement class - interface for an element (vertex, edge or face) of a solid...
#define GISMO_UNUSED(x)
Definition: gsDebug.h:112
EIGEN_STRONG_INLINE abs_expr< E > abs(const E &u)
Absolute value.
Definition: gsExpressions.h:4488