libsurf
Programmer's Documentation

meshcomponent.h (r6227/r5385)
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_MESHCOMPONENT_H
16 #define SURF_MESHCOMPONENT_H
17 
18 #include "forward.h"
19 #include "dnmesh.h"
20 #include "sides.h"
21 #include <genua/trimesh.h>
22 
36 class MeshComponent : public TriMesh
37 {
38  public:
39 
41  MeshComponent(const SurfacePtr & s);
42 
44  MeshComponent(const SurfacePtr & s, const DnRefineCriterionPtr & pc);
45 
47  virtual ~MeshComponent() {}
48 
50  const SurfacePtr & surface() const {return psf;}
51 
53  void surface(const SurfacePtr & srf) {psf = srf; bFreshMesh=false;}
54 
56  void criterion(const DnRefineCriterionPtr & pc) {pcrit = pc;}
57 
59  const DnRefineCriterionPtr & criterion() const {return pcrit;}
60 
62  void tag(uint t) {iTag = t;}
63 
65  uint tag() const {return iTag;}
66 
68  void allowRefinement(bool flag) {bRefine = flag;}
69 
71  void surfaceChanged(bool flag=true) {bFreshMesh=!flag;}
72 
74  bool freshMesh() const {return bFreshMesh;}
75 
77  void stretchedMesh(bool flag) {bStretchedMesh = flag;}
78 
80  bool stretchedMesh() const {return bStretchedMesh;}
81 
83  void smoothingIterations(uint n) {nSmooth = n;}
84 
86  uint smoothingIterations() {return nSmooth;}
87 
89  void smoothingFactor(Real w) {wSmooth = w;}
90 
92  Real smoothingFactor() {return wSmooth;}
93 
95  void kinkLimit(Real k) {rKinkLimit = k;}
96 
98  Real kinkLimit() const {return rKinkLimit;}
99 
101  uint nNeighbors() const {return tnb.size();}
102 
104  void registerNeighbor(const MeshComponent *nb);
105 
107  bool isNeighbor(const MeshComponent *a) const;
108 
110  void clearNeighbors() {tnb.clear();}
111 
113  uint nParents() const {return parents.size();}
114 
116  void registerParent(const MeshComponent *nb);
117 
119  bool isParent(const MeshComponent *a) const;
120 
122  bool isChild(const MeshComponent *a) const {
123  assert(a != 0);
124  return a->isParent(this);
125  }
126 
128  void clearParents() {parents.clear();}
129 
131  const Vct2 & parameter(uint k) const {return ppt[k];}
132 
134  virtual void premesh(const PointGrid<2> & pgi = PointGrid<2>());
135 
137  virtual void premesh(const PointList<2> & pp, const Indices & tri);
138 
140  void boundary(side_t s, Indices & si) const;
141 
143  bool constrain(const PointList<2> & uvc, const PointList<3> & rep);
144 
146  bool reconstrain();
147 
149  uint nConstraint() const {return icon.size();}
150 
152  bool insertBoundaryPoints(const PointList<2> & uvc, const PointList<3> & rep);
153 
155  virtual void refine();
156 
158  virtual void refineAround(const Indices & vlist);
159 
161  virtual void adapt();
162 
164  virtual void clear();
165 
168  pcon.clear(); rcon.clear(); icon.clear();
169  }
170 
172  const std::string & lastError() const {return mg.lastError();}
173 
175  void dbStoreMesh(const std::string & fname) const;
176 
177  protected:
178 
180  void genStretched();
181 
183  uint fixNormals();
184 
186  virtual void transfer();
187 
188  protected:
189 
191  SurfacePtr psf;
192 
195 
198 
200  DnRefineCriterionPtr pcrit;
201 
203  std::vector<PointList<2> > pcon;
204 
206  std::vector<PointList<3> > rcon;
207 
209  std::vector<Indices> icon;
210 
212  std::vector<const MeshComponent*> tnb;
213 
215  std::vector<const MeshComponent*> parents;
216 
218  Real wSmooth, rKinkLimit;
219 
221  uint nSmooth;
222 
224  uint iTag;
225 
227  bool bFreshMesh, bRefine, bStretchedMesh;
228 };
229 
230 #endif
uint iTag
tag to identify mesh sections
Definition: meshcomponent.h:224
const std::string & lastError() const
access error message from DnMesh
Definition: meshcomponent.h:172
void tag(uint t)
set section tag
Definition: meshcomponent.h:62
void kinkLimit(Real k)
access kink limiter
Definition: meshcomponent.h:95
void registerNeighbor(const MeshComponent *nb)
register another surface as touching neighbor
Definition: meshcomponent.cpp:417
uint smoothingIterations()
access smoothing parameters
Definition: meshcomponent.h:86
void smoothingFactor(Real w)
access smoothing parameters
Definition: meshcomponent.h:89
Mesh generation engine.
Definition: dnmesh.h:47
uint nSmooth
smoothing iterations
Definition: meshcomponent.h:221
PointList< 2 > ppt
vertices in parameter space
Definition: meshcomponent.h:194
DnMesh mg
mesh generator for this patch
Definition: meshcomponent.h:197
void stretchedMesh(bool flag)
use algorithm to generate streched mesh
Definition: meshcomponent.h:77
Real smoothingFactor()
access smoothing parameters
Definition: meshcomponent.h:92
virtual void transfer()
transfer mesh from mesh generator
Definition: meshcomponent.cpp:297
virtual ~MeshComponent()
destruction
Definition: meshcomponent.h:47
uint nNeighbors() const
return number of neighbors registered
Definition: meshcomponent.h:101
bool reconstrain()
apply the same set of constraints again
Definition: meshcomponent.cpp:109
void criterion(const DnRefineCriterionPtr &pc)
change mesh generation criterion
Definition: meshcomponent.h:56
std::vector< PointList< 2 > > pcon
mesh constraints in parameter space
Definition: meshcomponent.h:203
bool constrain(const PointList< 2 > &uvc, const PointList< 3 > &rep)
add constraint in uv-space, return false if that failed
Definition: meshcomponent.cpp:86
void boundary(side_t s, Indices &si) const
extract the mesh vertices which are on a boundary
Definition: meshcomponent.cpp:351
void surfaceChanged(bool flag=true)
set dirty flag whenever surface changed
Definition: meshcomponent.h:71
Mesh component.
Definition: meshcomponent.h:36
std::vector< PointList< 3 > > rcon
replacement points for constrained vertices
Definition: meshcomponent.h:206
void clearConstraints()
clear constraints only
Definition: meshcomponent.h:167
void clearParents()
clear dependency information
Definition: meshcomponent.h:128
bool insertBoundaryPoints(const PointList< 2 > &uvc, const PointList< 3 > &rep)
insert boundary point into mesh
Definition: meshcomponent.cpp:163
std::vector< const MeshComponent * > tnb
components marked as non-intersecting neighbors
Definition: meshcomponent.h:212
bool stretchedMesh() const
access anisotropic mesh setting
Definition: meshcomponent.h:80
virtual void premesh(const PointGrid< 2 > &pgi=PointGrid< 2 >())
generate mesh without constraints
Definition: meshcomponent.cpp:34
void surface(const SurfacePtr &srf)
access bound surface
Definition: meshcomponent.h:53
const SurfacePtr & surface() const
access bound surface
Definition: meshcomponent.h:50
SurfacePtr psf
surface to which mesh is pinned
Definition: meshcomponent.h:191
bool isChild(const MeshComponent *a) const
test if component a is a child of this one
Definition: meshcomponent.h:122
MeshComponent(const SurfacePtr &s)
every component is attached to a surface object
Definition: meshcomponent.cpp:23
uint nConstraint() const
number of constraints defined
Definition: meshcomponent.h:149
void allowRefinement(bool flag)
set iterative refinement flag
Definition: meshcomponent.h:68
virtual void adapt()
mesh adaptation call (base class implementation empty)
Definition: meshcomponent.cpp:224
std::vector< const MeshComponent * > parents
components which must be meshed first (dependencies)
Definition: meshcomponent.h:215
void genStretched()
generate stretched mesh
Definition: meshcomponent.cpp:230
bool freshMesh() const
access flag indicating if mesh is up-to-date
Definition: meshcomponent.h:74
virtual void refineAround(const Indices &vlist)
perform a refinement step around vertices vlist
Definition: meshcomponent.cpp:209
void clearNeighbors()
erase neighborhood information
Definition: meshcomponent.h:110
std::vector< Indices > icon
indices of constrained mesh vertices
Definition: meshcomponent.h:209
void dbStoreMesh(const std::string &fname) const
debugging: write current mesh to file
Definition: meshcomponent.cpp:448
bool isParent(const MeshComponent *a) const
test if surface a is a non-intersecting neighbor
Definition: meshcomponent.cpp:442
DnRefineCriterionPtr pcrit
criterion for mesh generation
Definition: meshcomponent.h:200
bool isNeighbor(const MeshComponent *a) const
test if surface a is a non-intersecting neighbor
Definition: meshcomponent.cpp:427
virtual void clear()
clear all data, but keep constraints
Definition: meshcomponent.cpp:407
Real wSmooth
smoothing parameter, kink limit
Definition: meshcomponent.h:218
void registerParent(const MeshComponent *nb)
register another component as parent of this one
Definition: meshcomponent.cpp:432
const DnRefineCriterionPtr & criterion() const
access criterion
Definition: meshcomponent.h:59
uint nParents() const
number of components which need to be meshed first
Definition: meshcomponent.h:113
const std::string & lastError() const
access error message
Definition: dnmesh.h:191
uint fixNormals()
check and ensure that the triangle normal matches surface normal
Definition: meshcomponent.cpp:327
void smoothingIterations(uint n)
access smoothing parameters
Definition: meshcomponent.h:83
bool bFreshMesh
flag to control mesh generation
Definition: meshcomponent.h:227
virtual void refine()
perform a refinement step on the constrained mesh
Definition: meshcomponent.cpp:192
Real kinkLimit() const
access kink limiter
Definition: meshcomponent.h:98
const Vct2 & parameter(uint k) const
access parameter coordinates
Definition: meshcomponent.h:131
uint tag() const
access section tag
Definition: meshcomponent.h:65
Generated on Mon Jan 24 2022 03:03:16 for libsurf by   doxygen 1.8.5