libsurf
Programmer's Documentation

topology.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_TOPOLOGY_H
16 #define SURF_TOPOLOGY_H
17 
18 #include "forward.h"
19 #include "topoedge.h"
20 #include "topoface.h"
21 #include "topovertex.h"
22 
30 class Topology
31 {
32 public:
33 
35  Topology() {}
36 
38  uint nfaces() const {return m_faces.size();}
39 
41  uint nedges() const {return m_edges.size();}
42 
44  uint appendFace(SurfacePtr psf, bool uperiodic=false, bool vperiodic=false);
45 
47  uint appendFace(const TopoFace &f);
48 
50  uint appendEdge(uint iface, uint a, uint b);
51 
53  uint appendEdge(const TopoEdge &edg);
54 
56  uint appendVertex(uint iface, const Vct2 &uvp);
57 
59  uint appendVertex(uint ifa, const Vct2 &uva,
60  uint ifb, const Vct2 &uvb);
61 
63  bool shareEdge(uint i, uint j) const;
64 
66  void connectEdge(uint fa, uint ea,
67  AbstractUvCurvePtr pcv, bool isHole=false);
68 
70  bool connectFaces(uint a, uint b, uint ea, uint eb, Real tol=gmepsilon);
71 
73  bool connectFaces(uint fa, uint fb, Real tol=gmepsilon);
74 
76  bool vEnchain(uint a, uint b, Real tol=gmepsilon);
77 
79  bool vEnchain(const SurfaceArray &surfaces);
80 
82  uint fillPlaneBoundary(uint ebound);
83 
85  const TopoVertex &vertex(uint k) const {
86  assert(k < m_vertices.size());
87  return m_vertices[k];
88  }
89 
91  TopoVertex &vertex(uint k) {
92  assert(k < m_vertices.size());
93  return m_vertices[k];
94  }
95 
97  uint findVertex(uint iface, const Vct2 & uvp);
98 
100  uint findConnection(uint iface, const Vct2 &pa, const Vct2 &pb,
101  Real tol = gmepsilon) const
102  {
103  return face(iface).findConnection(*this, pa, pb, tol);
104  }
105 
107  uint findConnection(uint iface, uint sideTag, Real tol = gmepsilon) const;
108 
110  const TopoFace &face(uint k) const {
111  assert(k < m_faces.size());
112  return m_faces[k];
113  }
114 
116  TopoFace &face(uint k) {
117  assert(k < m_faces.size());
118  return m_faces[k];
119  }
120 
122  const TopoEdge &edge(uint k) const {
123  assert(k < m_edges.size());
124  return m_edges[k];
125  }
126 
128  TopoEdge &edge(uint k) {
129  assert(k < m_edges.size());
130  return m_edges[k];
131  }
132 
134  void meshEdges();
135 
137  void meshFaces(bool allowConstraintSplit=false);
138 
140  void mergeFaceMeshes(TriMesh &globMesh) const;
141 
143  void intersect(TopoIsecArray &segm) const;
144 
146  void toMx(MxMesh &mx) const;
147 
149  void print(std::ostream &os) const;
150 
151 private:
152 
154  std::vector<TopoVertex> m_vertices;
155 
157  std::vector<TopoFace> m_faces;
158 
160  std::vector<TopoEdge> m_edges;
161 };
162 
163 #endif // TOPOLOGY_H
Topological face.
Definition: topoface.h:52
void connectEdge(uint fa, uint ea, AbstractUvCurvePtr pcv, bool isHole=false)
introduce connections between face fa and edge ea
Definition: topology.cpp:200
bool shareEdge(uint i, uint j) const
test whether face i is adjacent to face j
Definition: topology.cpp:185
TopoVertex & vertex(uint k)
access vertex by index
Definition: topology.h:91
uint nedges() const
number of edges defined
Definition: topology.h:41
void intersect(TopoIsecArray &segm) const
compute intersections between faces which do not share an edge
Definition: topology.cpp:455
TopoFace & face(uint k)
access face by index
Definition: topology.h:116
Topological edge, connecting two or more faces.
Definition: topoedge.h:30
std::vector< TopoVertex > m_vertices
topological vertices
Definition: topology.h:154
void mergeFaceMeshes(TriMesh &globMesh) const
merge meshes of all faces into one global mesh
Definition: topology.cpp:446
std::vector< TopoEdge > m_edges
edges
Definition: topology.h:160
const TopoEdge & edge(uint k) const
access edge by index
Definition: topology.h:122
void toMx(MxMesh &mx) const
join face meshes for debugging
Definition: topology.cpp:493
Topological vertex.
Definition: topovertex.h:26
uint findConnection(const Topology &topo, const Vct2 &q1, const Vct2 &q2, Real tol=gmepsilon) const
identify the edge (global index) of this face which connects q1 and q2
Definition: topoface.cpp:409
uint appendVertex(uint iface, const Vct2 &uvp)
add a topological vertex
Definition: topology.cpp:35
uint findVertex(uint iface, const Vct2 &uvp)
linear search for vertex
Definition: topology.cpp:65
void meshFaces(bool allowConstraintSplit=false)
discretize all faces
Definition: topology.cpp:390
uint fillPlaneBoundary(uint ebound)
construct a plane closing surface inside a closed-curve edge, return face index
Definition: topology.cpp:346
uint nfaces() const
number of faces defined
Definition: topology.h:38
Topology()
create empty topology object
Definition: topology.h:35
Container for topology information.
Definition: topology.h:30
const TopoVertex & vertex(uint k) const
access vertex by index
Definition: topology.h:85
uint appendEdge(uint iface, uint a, uint b)
generate a plain edge between vertices a,b
Definition: topology.cpp:97
bool vEnchain(uint a, uint b, Real tol=gmepsilon)
connect v = 1 of a to v = 0 of b
Definition: topology.cpp:299
uint appendFace(SurfacePtr psf, bool uperiodic=false, bool vperiodic=false)
add surface, generate four boundary edges by default
Definition: topology.cpp:113
const TopoFace & face(uint k) const
access face by index
Definition: topology.h:110
bool connectFaces(uint a, uint b, uint ea, uint eb, Real tol=gmepsilon)
connect face fa with face fb along edge ea/eb, return true on success
Definition: topology.cpp:209
void meshEdges()
discretize all edges
Definition: topology.cpp:382
void print(std::ostream &os) const
plain text output for debugging
Definition: topology.cpp:504
uint findConnection(uint iface, const Vct2 &pa, const Vct2 &pb, Real tol=gmepsilon) const
find global index of edge connecting pa and pb on face i
Definition: topology.h:100
std::vector< TopoFace > m_faces
faces (one for each surface)
Definition: topology.h:157
TopoEdge & edge(uint k)
access edge by index
Definition: topology.h:128
Generated on Mon Jan 24 2022 03:03:16 for libsurf by   doxygen 1.8.5