libsurf
Programmer's Documentation

topoedge.h (r6227/r5398)
1 
2 /* Copyright (C) 2015 David Eller <david@larosterna.com>
3  *
4  * Commercial License Usage
5  * Licensees holding valid commercial licenses may use this file in accordance
6  * with the terms contained in their respective non-exclusive license agreement.
7  * For further information contact david@larosterna.com .
8  *
9  * GNU General Public License Usage
10  * Alternatively, this file may be used under the terms of the GNU General
11  * Public License version 3.0 as published by the Free Software Foundation and
12  * appearing in the file gpl.txt included in the packaging of this file.
13  */
14 
15 #ifndef SURF_TOPOEDGE_H
16 #define SURF_TOPOEDGE_H
17 
18 #include "forward.h"
19 #include <genua/point.h>
20 
30 class TopoEdge
31 {
32 public:
33 
34  enum MatchResult { NoMatch, ForwardFit, ReverseFit,
35  ForwardOverlap, ReverseOverlap };
36 
37  enum Origin { Unknown, Specified, Intersection };
38 
40  TopoEdge() : m_orig(Unknown), m_bInjected(false) {}
41 
43  TopoEdge(uint a, uint b) : m_orig(Specified), m_bInjected(false) {
44  assign(a,b);
45  }
46 
48  TopoEdge(const Topology &topo, uint iface, uint a, uint b);
49 
51  void assign(uint a, uint b) {
52  if (a < b) {
53  m_vix[0] = a;
54  m_vix[1] = b;
55  } else {
56  m_vix[0] = b;
57  m_vix[1] = a;
58  }
59  }
60 
62  int edgeOrigin() const {return m_orig;}
63 
65  void edgeOrigin(Origin flag) {m_orig = flag;}
66 
68  uint source() const {return m_vix[0];}
69 
71  uint target() const {return m_vix[1];}
72 
74  bool operator< (const TopoEdge & e) const {
75  if (source() < e.source())
76  return true;
77  else if (e.source() > source())
78  return false;
79  else
80  return target() < e.target();
81  }
82 
84  bool operator== (const TopoEdge & e) const {
85  return (source() == e.source()) and (target() == e.target());
86  }
87 
89  Vct3 eval(uint lfi, Real t) const;
90 
92  int compare(const Topology &topo, const TopoEdge &e,
93  Real tol=gmepsilon) const;
94 
96  bool circular() const {return source() == target();}
97 
99  uint nfaces() const {return m_faces.size();}
100 
102  uint face(uint i) const {
103  assert(i < m_faces.size());
104  return m_faces[i];
105  }
106 
108  uint & face(uint i) {
109  assert(i < m_faces.size());
110  return m_faces[i];
111  }
112 
114  AbstractUvCurvePtr curve(uint k) const {
115  assert(k < m_pcv.size());
116  return m_pcv[k];
117  }
118 
120  uint findFace(uint fix) const {
121  const int nf = m_faces.size();
122  for (int i=0; i<nf; ++i)
123  if (m_faces[i] == fix)
124  return i;
125  return NotFound;
126  }
127 
129  uint attachFace(uint fix, AbstractUvCurvePtr pcv) {
130  // one edge can contain same face multiple times (with different curves)
131  m_faces.push_back(fix);
132  m_pcv.push_back(pcv);
133  return m_faces.size() - 1;
134  }
135 
137  bool detachFace(uint gfi) {
138  uint k = findFace(gfi);
139  if (k == NotFound)
140  return false;
141  m_faces.erase( m_faces.begin()+k );
142  m_pcv.erase( m_pcv.begin()+k );
143  return true;
144  }
145 
147  void detach();
148 
150  int connects(uint gfi, const Vct2 &q1, const Vct2 &q2, Real tol=gmepsilon) const;
151 
153  void split(Real t, uint v, TopoEdge &other);
154 
156  void enforcePoint(Real t);
157 
159  const Vector & discretize(const Topology &topo);
160 
162  const Vector & discretize(const DcMeshCritBase &mcrit);
163 
165  void discretize(const Vector &t) {m_tp = t; m_bInjected = false;}
166 
168  const Vector &pattern() const {return m_tp;}
169 
171  bool injectPoint(uint kf, const Vct2 &p, Real tol=gmepsilon);
172 
174  void injectIntersections(const Topology &topo, TopoEdge &e);
175 
177  bool pointInjected() const {return m_bInjected;}
178 
180  void pointInjected(bool flag) {m_bInjected = flag;}
181 
183  uint npoints() const {return m_tp.size();}
184 
186  Vct2 uvpoint(uint kface, uint ipoint) const;
187 
189  Vct3 point(uint ipoint) const;
190 
192  void toMx(MxMesh &mx) const;
193 
195  void print(uint k, std::ostream &os) const;
196 
198  void tabulate(const std::string &fn) const;
199 
201  static AbstractUvCurvePtr boundaryCurve(const Topology &topo,
202  uint iface, uint a, uint b);
203 
205  static bool intersects(uint fix, const TopoEdge &ea,
206  const TopoEdge &eb, Vct2 &t);
207 
208 private:
209 
211  void inject(const Topology &topo, uint iface, const Vector &ti);
212 
213 private:
214 
216  AbstractUvCurveArray m_pcv;
217 
219  Vector m_tp;
220 
222  Vector m_ftp;
223 
225  Indices m_faces;
226 
228  uint m_vix[2];
229 
231  Origin m_orig;
232 
235 };
236 
237 #endif // TOPOEDGE_H
void injectIntersections(const Topology &topo, TopoEdge &e)
make compatible with another edge - inject intersections
Definition: topoedge.cpp:302
void tabulate(const std::string &fn) const
write plain text table for debugging
Definition: topoedge.cpp:412
void print(uint k, std::ostream &os) const
plain text output for debugging
Definition: topoedge.cpp:394
int edgeOrigin() const
determine how edge was created
Definition: topoedge.h:62
Topological edge, connecting two or more faces.
Definition: topoedge.h:30
AbstractUvCurveArray m_pcv
continuous geometry representation in parameter space
Definition: topoedge.h:216
Base class for mesh quality criteria.
Definition: dcmeshcrit.h:30
const Vector & discretize(const Topology &topo)
discretize while satisfying mesh refinement criteria on all faces
Definition: topoedge.cpp:221
uint face(uint i) const
access face i
Definition: topoedge.h:102
bool detachFace(uint gfi)
drop face with global index fix from connectivity
Definition: topoedge.h:137
uint m_vix[2]
vertex indices
Definition: topoedge.h:228
uint npoints() const
number of points on discretized edge
Definition: topoedge.h:183
AbstractUvCurvePtr curve(uint k) const
access curve with local index k
Definition: topoedge.h:114
uint source() const
access source vertex
Definition: topoedge.h:68
Vct2 uvpoint(uint kface, uint ipoint) const
retrieve discrete points in (u,v) space of face k
Definition: topoedge.cpp:58
uint findFace(uint fix) const
return local index of face i
Definition: topoedge.h:120
void toMx(MxMesh &mx) const
generate lines for debugging
Definition: topoedge.cpp:378
uint target() const
access target vertex
Definition: topoedge.h:71
void assign(uint a, uint b)
assign vertices
Definition: topoedge.h:51
bool circular() const
a circular edge starts and ends at the same vertex
Definition: topoedge.h:96
Origin m_orig
tag which indicates how this edge was created
Definition: topoedge.h:231
Vector m_ftp
curve parameter points enforced in discretization
Definition: topoedge.h:222
bool pointInjected() const
determine whether a point was injected into edge after discretization
Definition: topoedge.h:177
void inject(const Topology &topo, uint iface, const Vector &ti)
inject a set of parameter values
Definition: topoedge.cpp:515
Indices m_faces
faces connected to this edge
Definition: topoedge.h:225
uint attachFace(uint fix, AbstractUvCurvePtr pcv)
connect with curve cv on face fix
Definition: topoedge.h:129
bool operator==(const TopoEdge &e) const
edge equality
Definition: topoedge.h:84
void enforcePoint(Real t)
enforce a point to be present in discretization
Definition: topoedge.cpp:214
TopoEdge()
create empty edge
Definition: topoedge.h:40
void edgeOrigin(Origin flag)
change origin flag
Definition: topoedge.h:65
void split(Real t, uint v, TopoEdge &other)
split edge by inserting vertex v, make this the edge (a,v) and other (v,b)
Definition: topoedge.cpp:182
void detach()
detach edge from all faces
Definition: topoedge.cpp:153
Container for topology information.
Definition: topology.h:30
static AbstractUvCurvePtr boundaryCurve(const Topology &topo, uint iface, uint a, uint b)
create default curve, straight in parameter space
Definition: topoedge.cpp:42
void discretize(const Vector &t)
enforce discretization
Definition: topoedge.h:165
TopoEdge(uint a, uint b)
create edge between existing vertices, not attached yet
Definition: topoedge.h:43
uint nfaces() const
number of connected faces
Definition: topoedge.h:99
bool injectPoint(uint kf, const Vct2 &p, Real tol=gmepsilon)
change discretization to include point p
Definition: topoedge.cpp:249
void pointInjected(bool flag)
reset injection status
Definition: topoedge.h:180
bool m_bInjected
flag indicating whether point was inserted on edge
Definition: topoedge.h:234
bool operator<(const TopoEdge &e) const
compare edges
Definition: topoedge.h:74
const Vector & pattern() const
access discretization pattern
Definition: topoedge.h:168
Vct3 eval(uint lfi, Real t) const
evaluate curve underlying this edge
Definition: topoedge.cpp:36
int connects(uint gfi, const Vct2 &q1, const Vct2 &q2, Real tol=gmepsilon) const
check whether this edge connects two points on global face gfi
Definition: topoedge.cpp:161
Vector m_tp
discretization in curve parameter space
Definition: topoedge.h:219
Vct3 point(uint ipoint) const
retrieve discrete point in 3D space
Definition: topoedge.cpp:64
uint & face(uint i)
access face i
Definition: topoedge.h:108
static bool intersects(uint fix, const TopoEdge &ea, const TopoEdge &eb, Vct2 &t)
test two edges for intersection in space of face index fix
Definition: topoedge.cpp:440
int compare(const Topology &topo, const TopoEdge &e, Real tol=gmepsilon) const
compare geometry with another edge
Definition: topoedge.cpp:79
Generated on Mon Jan 24 2022 03:03:16 for libsurf by   doxygen 1.8.5