libsurf
Programmer's Documentation

meshgenerator.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_MESHGENERATOR_H
16 #define SURF_MESHGENERATOR_H
17 
18 #include "forward.h"
19 #include "ttintersector.h"
20 #include "ttitopology.h"
21 #include "tticonnection.h"
22 
29 {
30  public:
31 
33  MgProgressCtrl() : step(0), nstep(0), bStop(false) {}
34 
36  virtual ~MgProgressCtrl() {}
37 
39  virtual void inc(uint k=1) {
40  ScopedLock lock(guard);
41  step += k;
42  }
43 
45  virtual uint progress() const {return step;}
46 
48  virtual void nsteps(uint n) {nstep = n;}
49 
51  virtual uint nsteps() const {return nstep;}
52 
54  virtual bool interrupt() const {return bStop;}
55 
57  virtual void interrupt(bool flag) {
58  ScopedLock lock(guard);
59  bStop = flag;
60  }
61 
62  protected:
63 
66 
68  uint step, nstep;
69 
71  bool bStop;
72 };
73 
79 class MeshGenerator : public TriMesh
80 {
81  public:
82 
84  MeshGenerator() : TriMesh(), ppMergeTol(0.0), ppIter(0),
85  bDropOrphanRidges(true), bDropInternal(true) {}
86 
88  virtual ~MeshGenerator() {}
89 
91  uint ncomponents() const {return components.size();}
92 
94  uint addComponent(const MeshComponentPtr & mcp) {
95  components.push_back(mcp);
96  return components.size() - 1;
97  }
98 
100  uint addComponent(const SurfacePtr & psf,
101  const DnRefineCriterionPtr & rc) {
102  MeshComponentPtr mcp;
103  mcp = MeshComponentPtr(new MeshComponent(psf, rc));
104  return addComponent(mcp);
105  }
106 
108  void eraseComponent(uint k) {
109  assert(k < components.size());
110  components.erase( components.begin()+k );
111  }
112 
114  uint findComponent(const std::string & s) const;
115 
117  MeshComponentPtr component(uint k) const {
118  assert(k < components.size());
119  return components[k];
120  }
121 
123  void addConnection(const TTiConnection & ct) {
124  connections.push_back(ct);
125  }
126 
128  void postprocess(uint iter, Real maxStretch, Real maxPhi, Real mtol=0.0);
129 
131  void toggleDropOrphanRidges(bool flag) {bDropOrphanRidges = flag;}
132 
134  void toggleDropInternal(bool flag) {bDropInternal = flag;}
135 
137  void mergeComponent(const TriMesh & mc);
138 
140  void progressController(const MgProgressPtr & p) {prog = p;}
141 
143  uint findTag(const std::string & s) const;
144 
146  bool incProgress(uint k=1);
147 
149  void interrupt();
150 
151  // high-level interface for CmpAssembly
152 
154  void process(const CmpAssembly & asy, bool rflocal=true, ThreadPool *pool=0);
155 
157  void preprocess(const CmpAssembly & asy, ThreadPool *pool = 0);
158 
160  void intersect(ThreadPool *pool = 0);
161 
163  void refineLocally(ThreadPool *pool = 0);
164 
166  void refineGlobally(ThreadPool *pool = 0);
167 
169  void order();
170 
172  void premesh();
173 
175  void finalize();
176 
178  void loadCollection(const std::string & fname);
179 
180  protected:
181 
183  void destretch();
184 
186  void dbStoreMesh(const std::string & fname) const;
187 
189  void searchExternalInit(Indices & itri) const;
190 
192  void retag();
193 
195  void extractWakes(TriMesh & wkm);
196 
197  private:
198 
200  MeshComponentArray components;
201 
203  TTiConnectionArray connections;
204 
206  TTIntersectorPtr ttip;
207 
210 
213 
215  Real ppMaxPhi, ppMaxStretch, ppMergeTol;
216 
218  uint ppIter;
219 
221  MgProgressPtr prog;
222 
224  StringArray tagmap;
225 
227  Indices mgorder;
228 
230  bool bDropOrphanRidges, bDropInternal;
231 };
232 
233 #endif
MgProgressCtrl()
default controller counts only
Definition: meshgenerator.h:33
void eraseComponent(uint k)
erase component
Definition: meshgenerator.h:108
TTIntersectorPtr ttip
intersector
Definition: meshgenerator.h:206
void destretch()
optional destretching pass
Definition: meshgenerator.cpp:496
Mutex mgguard
guards access to merged mesh
Definition: meshgenerator.h:212
virtual ~MeshGenerator()
virtual destructor
Definition: meshgenerator.h:88
Indices mgorder
mesh processing order (to satisfy dependencies)
Definition: meshgenerator.h:227
uint findComponent(const std::string &s) const
find component by surface name
Definition: meshgenerator.cpp:116
void preprocess(const CmpAssembly &asy, ThreadPool *pool=0)
premesh components from assembly (first mesh generation step)
Definition: meshgenerator.cpp:168
void retag()
re-assign face tags
Definition: meshgenerator.cpp:483
TTiConnectionArray connections
component connections
Definition: meshgenerator.h:203
virtual uint nsteps() const
access number of steps to perform
Definition: meshgenerator.h:51
void refineGlobally(ThreadPool *pool=0)
refine globally after second intersection pass
Definition: meshgenerator.cpp:329
void progressController(const MgProgressPtr &p)
set progress indicator object
Definition: meshgenerator.h:140
Edge-edge connection between surfaces.
Definition: tticonnection.h:33
Intersection topology.
Definition: ttitopology.h:35
void extractWakes(TriMesh &wkm)
extract external part of all wakes and put into wkm
Definition: meshgenerator.cpp:648
void order()
low-level interface : determine component processing order
Definition: meshgenerator.cpp:189
MeshComponentPtr component(uint k) const
access component
Definition: meshgenerator.h:117
uint ncomponents() const
number of components defined
Definition: meshgenerator.h:91
virtual void interrupt(bool flag)
set interrupt flag
Definition: meshgenerator.h:57
TTiTopology topo
intersection topology computer
Definition: meshgenerator.h:209
void toggleDropInternal(bool flag)
toggle removal of internal triangles (development)
Definition: meshgenerator.h:134
Mesh component.
Definition: meshcomponent.h:36
void addConnection(const TTiConnection &ct)
register component connection
Definition: meshgenerator.h:123
StringArray tagmap
store tag-to-surface name data
Definition: meshgenerator.h:224
virtual bool interrupt() const
query interrupt flag
Definition: meshgenerator.h:54
void premesh()
low-level interface : generate initial meshes for all surfaces
Definition: meshgenerator.cpp:234
bool bDropOrphanRidges
options for final mesh processing (development)
Definition: meshgenerator.h:230
void loadCollection(const std::string &fname)
load raw surface collection as saved by sumo
Definition: meshgenerator.cpp:810
Progress indicator and control for MeshGenerator.
Definition: meshgenerator.h:28
MeshGenerator()
empty generator
Definition: meshgenerator.h:84
MgProgressPtr prog
progress indicator
Definition: meshgenerator.h:221
Mutex guard
synchronisation
Definition: meshgenerator.h:65
void refineLocally(ThreadPool *pool=0)
perform local refinement after intersection processing
Definition: meshgenerator.cpp:307
bool bStop
interruption flag
Definition: meshgenerator.h:71
uint step
current step and number of steps
Definition: meshgenerator.h:68
void intersect(ThreadPool *pool=0)
process intersections
Definition: meshgenerator.cpp:252
virtual ~MgProgressCtrl()
virtual destructor
Definition: meshgenerator.h:36
void postprocess(uint iter, Real maxStretch, Real maxPhi, Real mtol=0.0)
set mesh postprocessing options
Definition: meshgenerator.cpp:127
uint ppIter
number of postprocessing iterations
Definition: meshgenerator.h:218
void searchExternalInit(Indices &itri) const
determine list of external triangles to start with
Definition: meshgenerator.cpp:559
MeshComponentArray components
components
Definition: meshgenerator.h:200
virtual void nsteps(uint n)
register number of steps to perform
Definition: meshgenerator.h:48
void finalize()
cleanup and drop internal triangles
Definition: meshgenerator.cpp:401
uint findTag(const std::string &s) const
access tag of surface named s
Definition: meshgenerator.cpp:549
void mergeComponent(const TriMesh &mc)
thread-safe component merge
Definition: meshgenerator.cpp:395
uint addComponent(const MeshComponentPtr &mcp)
add a mesh component
Definition: meshgenerator.h:94
bool incProgress(uint k=1)
log progress and check for interrupt
Definition: meshgenerator.cpp:529
Top-level mesh generator.
Definition: meshgenerator.h:79
void toggleDropOrphanRidges(bool flag)
toggle removal of singly-connected triangles (development)
Definition: meshgenerator.h:131
uint addComponent(const SurfacePtr &psf, const DnRefineCriterionPtr &rc)
add a mesh component
Definition: meshgenerator.h:100
virtual void inc(uint k=1)
log steps as complete
Definition: meshgenerator.h:39
Real ppMaxPhi
global mesh postprocessing options
Definition: meshgenerator.h:215
Container for components.
Definition: assembly.h:31
void process(const CmpAssembly &asy, bool rflocal=true, ThreadPool *pool=0)
process complete assembly
Definition: meshgenerator.cpp:136
virtual uint progress() const
access current state of progress
Definition: meshgenerator.h:45
void interrupt()
interrupt process as soon as possible
Definition: meshgenerator.cpp:542
void dbStoreMesh(const std::string &fname) const
write current global mesh to file in debug mode
Definition: meshgenerator.cpp:801
Generated on Mon Jan 24 2022 03:03:16 for libsurf by   doxygen 1.8.5