libsurf
Programmer's Documentation

topoface.h (r6227/r5798)
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_TOPOFACE_H
16 #define SURF_TOPOFACE_H
17 
18 #include "forward.h"
19 #include "surface.h"
20 #include "uvmapping.h"
21 #include "uvmapdelaunay.h"
22 #include <genua/trimesh.h>
23 
52 class TopoFace
53 {
54 public:
55 
56  enum MgBackend { DcMeshGen, JrsTriangle };
57 
59  TopoFace();
60 
62  explicit TopoFace(SurfacePtr psf, uint id);
63 
65  SurfacePtr surface() const {return m_psf;}
66 
68  void criterion(DcMeshCritBasePtr pmc);
69 
71  Real sqMergeTolerance() const;
72 
74  void iid(uint id) {m_iid = id;}
75 
77  DcMeshCritBasePtr criterion() const {return m_pmc;}
78 
80  const Indices & edges() const {return m_edges;}
81 
83  Vct3 eval(Real u, Real v) const { assert(m_psf); return m_psf->eval(u,v); }
84 
86  void plane(Real u, Real v, Vct3 &S, Vct3 &Su, Vct3 &Sv) const {
87  assert(m_psf);
88  m_psf->plane(u, v, S, Su, Sv);
89  }
90 
92  uint appendEdge(uint e, bool isHole = false) {
93  uint ke = findEdge(e);
94  if (ke == NotFound) {
95  m_edges.push_back(e);
96  m_edgeIsHole.push_back(isHole);
97  return m_edges.size() - 1;
98  } else {
99  m_edgeIsHole[ke] = isHole;
100  return ke;
101  }
102  }
103 
105  bool replaceEdge(uint a, uint b) {
106  const int ne = m_edges.size();
107  for (int i=0; i<ne; ++i) {
108  if (m_edges[i] == a) {
109  m_edges[i] = b;
110  return true;
111  }
112  }
113  return false;
114  }
115 
117  uint findEdge(uint e) const {
118  const int ne = m_edges.size();
119  for (int i=0; i<ne; ++i)
120  if (m_edges[i] == e)
121  return i;
122  return NotFound;
123  }
124 
126  uint detachEdge(uint e);
127 
129  uint findConnection(const Topology &topo, const Vct2 &q1,
130  const Vct2 &q2, Real tol=gmepsilon) const;
131 
133  void clearMesh();
134 
136  uint insertEdges(const Topology &topo, bool allowSplit = true);
137 
139  void pushSplitsToEdges(Topology &topo) const;
140 
142  bool keepExplicitMesh() const {return m_keepExplicitMesh;}
143 
145  uint generateMesh(const Topology &topo);
146 
148  uint generateMesh(const Topology &topo, const PointList<2> &pini);
149 
151  void importMesh(const PointList<2> &uvp, const Indices &tri,
152  bool keepExplicit=true);
153 
155  void replaceEdgeNodes(const Topology &topo, bool isecOnly=true);
156 
158  const TriMesh & mesh() const;
159 
161  TriMesh & mesh();
162 
164  const PointList<2> & uvVertices() const;
165 
167  void splitBoundaries(Topology &topo);
168 
170  void uvDump(const Topology &topo, const std::string &fname) const;
171 
173  void print(uint k, std::ostream &os) const;
174 
176  static void backend(int b);
177 
178 private:
179 
181  void constructMeshGen();
182 
184  bool carveHole(const TopoEdge &e);
185 
186 private:
187 
189  SurfacePtr m_psf;
190 
192  Indices m_edges;
193 
195  std::vector<bool> m_edgeIsHole;
196 
198  DcMeshCritBasePtr m_pmc;
199 
201  MeshGeneratorPtr m_mg;
202 
204  uint m_iid;
205 
208 
210  static int s_backend;
211 };
212 
213 #endif // TOPOFACE_H
Topological face.
Definition: topoface.h:52
static void backend(int b)
change backend to use for mesh generation
Definition: topoface.cpp:509
bool m_keepExplicitMesh
if true, keep externally/explicitely generated mesh
Definition: topoface.h:207
uint detachEdge(uint e)
eliminate edge with global index e from connectivity
Definition: topoface.cpp:397
const TriMesh & mesh() const
access mesh (once it has been generated)
Definition: topoface.cpp:208
DcMeshCritBasePtr m_pmc
criterion used for meshing
Definition: topoface.h:198
void iid(uint id)
change id
Definition: topoface.h:74
Topological edge, connecting two or more faces.
Definition: topoedge.h:30
uint insertEdges(const Topology &topo, bool allowSplit=true)
insert edge constraints into (u,v) mesh
Definition: topoface.cpp:291
bool keepExplicitMesh() const
indicates whether face wants to retain an externally generated mesh
Definition: topoface.h:142
TopoFace()
create undefined face
Definition: topoface.cpp:37
void plane(Real u, Real v, Vct3 &S, Vct3 &Su, Vct3 &Sv) const
evaluate point and derivatives on surface
Definition: topoface.h:86
SurfacePtr surface() const
access surface
Definition: topoface.h:65
bool carveHole(const TopoEdge &e)
remove triangles within internal hole edge k
Definition: topoface.cpp:227
SurfacePtr m_psf
each face is backed by exactly one surface
Definition: topoface.h:189
bool replaceEdge(uint a, uint b)
replace edge a with b, return true if successful
Definition: topoface.h:105
uint m_iid
integer id (index in Topology)
Definition: topoface.h:204
void clearMesh()
clear stored mesh, initialize (u,v) mapping if necessary
Definition: topoface.cpp:274
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
Vct3 eval(Real u, Real v) const
evaluate surface
Definition: topoface.h:83
Container for topology information.
Definition: topology.h:30
DcMeshCritBasePtr criterion() const
access discretization criterion
Definition: topoface.h:77
const PointList< 2 > & uvVertices() const
access mesh coordinates in (u,v) space
Definition: topoface.cpp:222
void replaceEdgeNodes(const Topology &topo, bool isecOnly=true)
replace edge vertices in order to make edge nodes match exactly
Definition: topoface.cpp:182
const Indices & edges() const
edges connected to this
Definition: topoface.h:80
void splitBoundaries(Topology &topo)
split edges which are intersected by newly introduced intersections
Definition: topoface.cpp:462
void constructMeshGen()
create internal mesh generator instance
Definition: topoface.cpp:49
std::vector< bool > m_edgeIsHole
indicates whether an edge is an internal boundary (a hole)
Definition: topoface.h:195
Indices m_edges
edges on this face
Definition: topoface.h:192
void pushSplitsToEdges(Topology &topo) const
propagate constraint splitting to topological edges
Definition: topoface.cpp:342
MeshGeneratorPtr m_mg
dispatches to DC or JRS mesh generation
Definition: topoface.h:201
Real sqMergeTolerance() const
access point merge tolerance
Definition: topoface.cpp:389
uint generateMesh(const Topology &topo)
create mesh on face, accounting for discretized edges
Definition: topoface.cpp:61
void importMesh(const PointList< 2 > &uvp, const Indices &tri, bool keepExplicit=true)
alternatively, import a mesh generated explicitly (call replaceEdgeNodes!)
Definition: topoface.cpp:173
static int s_backend
mesh generator backend to use
Definition: topoface.h:210
void uvDump(const Topology &topo, const std::string &fname) const
debugging : write mesh and boundaries in (u,v) space
Definition: topoface.cpp:422
uint appendEdge(uint e, bool isHole=false)
connect to edge e
Definition: topoface.h:92
uint findEdge(uint e) const
find local index of edge e
Definition: topoface.h:117
void print(uint k, std::ostream &os) const
plain-text debugging output
Definition: topoface.cpp:495
Generated on Mon Jan 24 2022 03:03:16 for libsurf by   doxygen 1.8.5