1 |
francois |
1158 |
//####//------------------------------------------------------------ |
2 |
|
|
//####//------------------------------------------------------------ |
3 |
|
|
//####// MAGiC |
4 |
|
|
//####// Jean Christophe Cuilliere et Vincent FRANCOIS |
5 |
|
|
//####// Departement de Genie Mecanique - UQTR |
6 |
|
|
//####//------------------------------------------------------------ |
7 |
|
|
//####// MAGIC est un projet de recherche de l equipe ERICCA |
8 |
|
|
//####// du departement de genie mecanique de l Universite du Quebec a Trois Rivieres |
9 |
|
|
//####// http://www.uqtr.ca/ericca |
10 |
|
|
//####// http://www.uqtr.ca/ |
11 |
|
|
//####//------------------------------------------------------------ |
12 |
|
|
//####//------------------------------------------------------------ |
13 |
|
|
//####// |
14 |
|
|
//####// CAD4FE_MCAA.h |
15 |
|
|
//####// |
16 |
|
|
//####//------------------------------------------------------------ |
17 |
|
|
//####//------------------------------------------------------------ |
18 |
|
|
//####// COPYRIGHT 2000-2024 |
19 |
|
|
//####// jeu 13 jun 2024 11:58:56 EDT |
20 |
|
|
//####//------------------------------------------------------------ |
21 |
|
|
//####//------------------------------------------------------------ |
22 |
foucault |
27 |
|
23 |
|
|
#ifndef CAD4FE_MCAAH
|
24 |
|
|
#define CAD4FE_MCAAH
|
25 |
|
|
|
26 |
|
|
#include <map>
|
27 |
|
|
#include <set>
|
28 |
|
|
#include <string>
|
29 |
|
|
#include <vector>
|
30 |
|
|
|
31 |
|
|
class MG_VOLUME;
|
32 |
|
|
class MG_FACE;
|
33 |
|
|
class MG_SOMMET;
|
34 |
|
|
class MG_NOEUD;
|
35 |
|
|
class MG_MAILLAGE;
|
36 |
|
|
class MG_GESTIONNAIRE;
|
37 |
|
|
class MG_GEOMETRIE;
|
38 |
|
|
class MG_ELEMENT_TOPOLOGIQUE;
|
39 |
|
|
class MG_ELEMENT_MAILLAGE;
|
40 |
|
|
class MG_IDENTIFICATEUR;
|
41 |
|
|
class FCT_TAILLE;
|
42 |
|
|
class MG_SEGMENT;
|
43 |
|
|
class MG_COSOMMET;
|
44 |
|
|
|
45 |
|
|
#include <tpl_map_entite.h>
|
46 |
|
|
#include <tpl_set.h>
|
47 |
|
|
#include <tpl_grille.h>
|
48 |
|
|
#include <ot_mathematique.h>
|
49 |
|
|
|
50 |
foucault |
569 |
#include "CAD4FE_MCT_Platform.h"
|
51 |
foucault |
27 |
#include "ot_mathematique.h"
|
52 |
|
|
|
53 |
foucault |
176 |
#include "CAD4FE_Graph.h"
|
54 |
foucault |
27 |
|
55 |
|
|
namespace CAD4FE {
|
56 |
|
|
|
57 |
|
|
class Intersection_Plane_MG_MAILLAGE;
|
58 |
|
|
class MCBody;
|
59 |
|
|
class MCEdge;
|
60 |
|
|
class MCVertex;
|
61 |
|
|
class MCFace;
|
62 |
|
|
|
63 |
|
|
class CovertexCriteria;
|
64 |
|
|
class GlobalEdgeCriteria;
|
65 |
|
|
class LocalEdgeCriteria;
|
66 |
|
|
class VertexCriteria;
|
67 |
|
|
|
68 |
|
|
struct MCTChanges;
|
69 |
|
|
typedef struct MCTChanges MCTChanges;
|
70 |
|
|
struct RTChanges;
|
71 |
|
|
typedef struct RTChanges RTChanges;
|
72 |
|
|
|
73 |
francois |
1158 |
class MCAA {
|
74 |
foucault |
27 |
public:
|
75 |
|
|
typedef std::map<MCVertex*, VertexCriteria* > VCMap;
|
76 |
|
|
typedef std::map<MCVertex*, VertexCriteria* >::iterator VCMapIterator;
|
77 |
|
|
typedef std::map<MCVertex*, VertexCriteria* >::const_iterator VCMapCIterator;
|
78 |
|
|
|
79 |
|
|
typedef std::map<MCEdge *, GlobalEdgeCriteria *> ECMap;
|
80 |
|
|
typedef std::pair<MCEdge *, GlobalEdgeCriteria *> ECPair;
|
81 |
|
|
typedef std::map<MCEdge *, GlobalEdgeCriteria *>::iterator ECMapIterator;
|
82 |
|
|
typedef std::map<MCEdge *, GlobalEdgeCriteria *>::const_iterator ECMapCIterator;
|
83 |
|
|
|
84 |
|
|
MCAA( MG_VOLUME * __refBody, MG_MAILLAGE * __tessellation, MG_GESTIONNAIRE * __refGest, MG_GEOMETRIE * __geom);
|
85 |
|
|
|
86 |
|
|
virtual ~MCAA();
|
87 |
|
|
|
88 |
|
|
MG_VOLUME * GetRefBody () const;
|
89 |
|
|
MCBody * GetMCBody () const;
|
90 |
|
|
MG_MAILLAGE * GetRefTess () const;
|
91 |
|
|
MG_MAILLAGE * GetMCTess () const;
|
92 |
|
|
MG_GEOMETRIE * GetGeometrie () const;
|
93 |
|
|
MG_GESTIONNAIRE * GetGest () const;
|
94 |
|
|
void GetBoundingBox(double __bbox[6]) const;
|
95 |
|
|
|
96 |
|
|
// FE Mesh methods
|
97 |
|
|
MG_MAILLAGE * GetFEMesh () const;
|
98 |
|
|
void InitializeFEMesh ();
|
99 |
|
|
void InitializeFEMesh(MCEdge * __mcEdge);
|
100 |
|
|
void InitializeFEMesh(MCVertex * __mcVertex, MG_NOEUD ** __n = NULL);
|
101 |
|
|
void DeleteFEMesh(MCEdge * __mcEdge);
|
102 |
|
|
void DeleteMesh(MCEdge * __mcEdge);
|
103 |
|
|
void DeleteFEMesh(MCVertex * __mcVertex);
|
104 |
|
|
int GetFEMeshSegmentCount(MCEdge * __mcEdge);
|
105 |
|
|
|
106 |
|
|
// Edge local properties
|
107 |
|
|
void EC_Init(MCEdge *);
|
108 |
|
|
void EC_Delete(MCEdge *);
|
109 |
|
|
void EC_Update(MCEdge *);
|
110 |
|
|
void EC_Init();
|
111 |
|
|
void EC_ChangeTopo(MCEdge * __old, MCEdge * __new);
|
112 |
|
|
std::vector <LocalEdgeCriteria *> EC_Get(MCEdge * __mcEdge);
|
113 |
|
|
GlobalEdgeCriteria * GetHighestEdgeDeletionScore();
|
114 |
|
|
GlobalEdgeCriteria * GetGlobalEdgeCriteria(MCEdge * __mcEdge);
|
115 |
|
|
|
116 |
|
|
// Vertex properties
|
117 |
|
|
void VC_Init();
|
118 |
|
|
void VC_Delete(MCVertex * __mcVertex);
|
119 |
|
|
void VC_Init(MCVertex * __mcVertex);
|
120 |
|
|
VertexCriteria * VC_Get(MCVertex * __mcVertex);
|
121 |
|
|
VertexCriteria * GetHighestVCScore();
|
122 |
|
|
|
123 |
|
|
// Input Meshing criteria
|
124 |
|
|
void SetRelativeSag(double);
|
125 |
|
|
double GetRelativeSag();
|
126 |
|
|
|
127 |
|
|
double GetLimitAngle();
|
128 |
|
|
void SetLimitAngle(double __limitAngle);
|
129 |
|
|
|
130 |
|
|
void SetMaxOverdensity(double);
|
131 |
|
|
double GetMaxOverdensity();
|
132 |
|
|
|
133 |
|
|
void SetConstantMeshSize(double __meshSize);
|
134 |
|
|
double CalculateDefaultMeshSize();
|
135 |
|
|
void UseDefaultMeshSize();
|
136 |
|
|
void ReadSizeMapRefinementFile(const char * );
|
137 |
|
|
void ReadSizeMapFile(const char * );
|
138 |
|
|
void SetSizeMap(FCT_TAILLE * __sizeMap);
|
139 |
|
|
|
140 |
|
|
double GetSize(double xyz[3]);
|
141 |
|
|
double GetMinSize(double __xyz[3]);
|
142 |
|
|
|
143 |
|
|
// Simplification routines
|
144 |
foucault |
176 |
// template <class C> std::map<C,double>::iterator GetHighestScore(std::map< C,double>&);
|
145 |
foucault |
27 |
//void Simplify(MCTChanges * __mctChanges);
|
146 |
|
|
//bool TestEdgeSupprBoundary(MCVertex * __mcVertex);
|
147 |
|
|
//bool Next(MCTChanges * __mctChanges);
|
148 |
|
|
//bool SuppressNextEdge(MCTChanges * __mctChanges);
|
149 |
|
|
|
150 |
|
|
// Split Edge
|
151 |
|
|
void SplitEdge(MCEdge * __mcEdge, double xyz[3], MCTChanges * __mctChanges, RTChanges * __rtChanges, bool __splitTessellation=true);
|
152 |
|
|
void SplitEdgeInMesh(MG_MAILLAGE * __mesh, MCEdge * __origEdge, MCVertex * __splitVertex, MCEdge * __splitEdges[2]);
|
153 |
|
|
bool SplitEdgesAtIncompatibleLocalCriteria(MCTChanges * __mctChanges);
|
154 |
|
|
|
155 |
|
|
/// suppress a edge of the mc body and
|
156 |
|
|
/// * update its tessellation
|
157 |
|
|
/// * update the criteria
|
158 |
|
|
void SuppressMCEdge(MCEdge * __mcEdge, MCTChanges * __mctChanges);
|
159 |
|
|
/// vertex simplification methods
|
160 |
|
|
void SuppressMCVertex (MCVertex *, MCTChanges * __mctChanges);
|
161 |
|
|
double UpdateSuppressionScore(MCVertex * __mcVertex);
|
162 |
|
|
void MergeVertices(MCVertex * __deleteVertex, MCVertex * __targetVertex);
|
163 |
|
|
bool CollapseMCEdgeToMCVertex(MCEdge * collapseEdge, MCVertex * __mcVertex);
|
164 |
|
|
|
165 |
|
|
void Update();
|
166 |
|
|
|
167 |
|
|
bool CheckIfTopoExists(MG_ELEMENT_TOPOLOGIQUE * topo);
|
168 |
|
|
void CheckMCMesh(MG_MAILLAGE*, std::set<MG_SEGMENT*> & __setSegmentBadTopology, std::set<MG_NOEUD*> & __setNodeBadTopology);
|
169 |
|
|
bool CheckIfMeshIsReferencedInTopo(MG_ELEMENT_MAILLAGE * __elem);
|
170 |
|
|
bool CheckIfMeshIsReferencedInTopo(MG_SEGMENT * __seg, MG_FACE * __face);
|
171 |
|
|
|
172 |
|
|
///
|
173 |
|
|
class ConstrictedSection {
|
174 |
|
|
public:
|
175 |
|
|
ConstrictedSection(){}
|
176 |
|
|
ConstrictedSection(const ConstrictedSection &cs):F(cs.F),Seg1(cs.Seg1),Seg2(cs.Seg2),Node(cs.Node),Seg1P(cs.Seg1P),Seg2P(cs.Seg2P){}
|
177 |
|
|
MCFace * F;
|
178 |
|
|
MG_SEGMENT * Seg1;
|
179 |
|
|
MG_NOEUD * Node;
|
180 |
|
|
MG_SEGMENT * Seg2;
|
181 |
|
|
OT_VECTEUR_3D Seg1P;
|
182 |
|
|
OT_VECTEUR_3D Seg2P;
|
183 |
|
|
} ;
|
184 |
|
|
|
185 |
|
|
bool NodeConstrictedSection(MCFace * __mcFace, MG_NOEUD * __n, ConstrictedSection &, Graph::Graph *);
|
186 |
|
|
bool ProcessNextConstrictedSectionInFace(MCFace * __mcFace);
|
187 |
|
|
bool Node_Segment_Same_Face(MG_NOEUD * __n, MG_SEGMENT * __seg, std::set <MCFace *> & __commonFaces);
|
188 |
|
|
double ShortestPath(MG_MAILLAGE * __mesh, MG_SEGMENT * sa, MG_SEGMENT * sb);
|
189 |
foucault |
176 |
static double GraphDistanceBetweenSegs(Graph::Node * __a, Graph::Node * __b, Graph::Arc * __arc );
|
190 |
foucault |
27 |
Graph::Graph * FaceBoundaryMesh(MG_MAILLAGE * __mesh, MCFace * __face, std::set <MG_NOEUD * > & nodes, std::set <MG_SEGMENT *> & segs);
|
191 |
|
|
|
192 |
|
|
// new edge deletion operator
|
193 |
foucault |
176 |
void Simplify();
|
194 |
francois |
1158 |
bool Next2( MCTChanges * __mctChanges );
|
195 |
foucault |
27 |
bool SuppressNextVertex(MCTChanges * __mctChanges);
|
196 |
|
|
bool SuppressNextEdge2(MCTChanges * __mctChanges);
|
197 |
|
|
void Simplify2(MCTChanges * __mctChanges);
|
198 |
|
|
int SimplifyConstrictedSections();
|
199 |
|
|
int SimplifyEdgeCollapse();
|
200 |
|
|
int SimplifyFaceLoop();
|
201 |
|
|
int NextSimplifyFaceLoop();
|
202 |
francois |
1158 |
void DeleteEdge2(MCEdge * __mcEdge, MCTChanges * __mctChanges, RTChanges * __rtChanges);
|
203 |
foucault |
27 |
|
204 |
|
|
/**
|
205 |
|
|
* time : represent how many simplification steps have been done
|
206 |
|
|
* since the beginning of the process
|
207 |
|
|
*/
|
208 |
|
|
int time;
|
209 |
|
|
|
210 |
|
|
/// Access to the MC Tessellation Segments Grid
|
211 |
|
|
TPL_GRILLE <MG_SEGMENT *> * GetMCTessSegGrid();
|
212 |
francois |
1158 |
|
213 |
foucault |
27 |
/// Given a plane (N,P),
|
214 |
|
|
/// find the closest segment from P which is intersected the plane
|
215 |
|
|
MG_SEGMENT * FindClosestSeg(MCEdge * __mcEdge, double __P[3], double __N[3]);
|
216 |
|
|
|
217 |
|
|
|
218 |
|
|
int GetEdgeDeletionCount(){return _nbA;}
|
219 |
francois |
1158 |
int GetVertexDeletionCount(){return _nbB;}
|
220 |
|
|
int GetEdgeCollapseCount(){return _nbC;}
|
221 |
|
|
int GetConstrictedSectionCollapseCount(){return _nbD=0;}
|
222 |
foucault |
27 |
int GetLoopDeletionCount(){return _nbE;}
|
223 |
foucault |
64 |
int GetMinMCEdgeCount();
|
224 |
|
|
void SetMinMCEdgeCount(int __minMCEdgeCount);
|
225 |
|
|
int GetMinMCVertexCount();
|
226 |
|
|
void SetMinMCVertexCount(int __minMCVertexCount);
|
227 |
foucault |
27 |
|
228 |
|
|
protected:
|
229 |
|
|
/// Copy the tessellation of the initial reference body MG_VOLUME (__tessellation)
|
230 |
|
|
/// and link tessellation entities to MC entities
|
231 |
|
|
void _InitializeMCBodyTessellation();
|
232 |
|
|
|
233 |
|
|
/// debug routines
|
234 |
|
|
void _DebugmcEntsByMeshing();
|
235 |
|
|
void _DebugSurfacesByMeshingAlongIsoParametric();
|
236 |
|
|
|
237 |
|
|
/// find the closest segment from P which is intersected by plane (N,P)
|
238 |
|
|
MG_SEGMENT * _FindClosestSeg(TPL_MAP_ENTITE<MG_SEGMENT *> & __lstSegs, MCEdge * __mcEdge, double __P[3], double __N[3]);
|
239 |
|
|
|
240 |
|
|
/// Initialize the MC Tessellation Segments Grid
|
241 |
|
|
void _InitializeMCTessSegGrid();
|
242 |
|
|
void _UpdateMCTessSegGrid(MCEdge * __mcEdge, MG_SEGMENT * __originalSegment, MG_SEGMENT * __splitSegments[2]);
|
243 |
|
|
|
244 |
|
|
void _DebugTraditionnalMesh();
|
245 |
|
|
|
246 |
|
|
private:
|
247 |
|
|
VCMap _vcMap;
|
248 |
|
|
ECMap _ecMap;
|
249 |
|
|
|
250 |
|
|
/// Input Meshing criteria and
|
251 |
|
|
/// Simplification properties
|
252 |
|
|
double _limitAngle;
|
253 |
|
|
double _relativeSag;
|
254 |
|
|
double _maxOverdensity;
|
255 |
|
|
|
256 |
|
|
/// reference body
|
257 |
|
|
MG_VOLUME * _refBody;
|
258 |
|
|
/// tessellation mesh
|
259 |
|
|
MG_MAILLAGE * _refTess;
|
260 |
|
|
/// MC Body which will be simplified
|
261 |
|
|
MCBody * _mcBody;
|
262 |
|
|
/// tessellation of the simplified body
|
263 |
|
|
MG_MAILLAGE * _mcTess;
|
264 |
|
|
|
265 |
|
|
/// topology and geometry and mesh manager
|
266 |
|
|
/// of the reference entities
|
267 |
|
|
MG_GESTIONNAIRE * _refGest;
|
268 |
|
|
|
269 |
|
|
/// Criteria for adaptation
|
270 |
|
|
/// std::map < int, LocalEdgeCrit * >
|
271 |
|
|
|
272 |
|
|
MG_GEOMETRIE * _geom;
|
273 |
|
|
|
274 |
|
|
/// Finite Element Analysis mesh of the
|
275 |
|
|
/// MC Body
|
276 |
|
|
MG_MAILLAGE * _feMesh;
|
277 |
|
|
|
278 |
|
|
/// Size map
|
279 |
|
|
FCT_TAILLE * _sizeMap;
|
280 |
|
|
|
281 |
|
|
/// Bounding box of the part
|
282 |
|
|
double _bbox[6];
|
283 |
|
|
|
284 |
|
|
/// Grid containing the segments of the MC Tessellation
|
285 |
|
|
TPL_GRILLE <MG_SEGMENT *> * _mcTessSegGrid;
|
286 |
|
|
|
287 |
|
|
/// Record of the last inserted vertex
|
288 |
|
|
std::map <MG_SOMMET*, int> _mapSuppressRefVertexCount;
|
289 |
|
|
|
290 |
|
|
int _nbA; /// edge deletion
|
291 |
francois |
1158 |
int _nbB; /// vertex deletion
|
292 |
|
|
int _nbC; /// edge collapse
|
293 |
|
|
int _nbD; /// constricted section
|
294 |
|
|
int _nbE; /// loops
|
295 |
foucault |
27 |
|
296 |
francois |
1158 |
|
297 |
|
|
int _minMCEdgeCount;
|
298 |
|
|
|
299 |
|
|
int _minMCVertexCount;
|
300 |
|
|
|
301 |
foucault |
27 |
};
|
302 |
|
|
|
303 |
|
|
}
|
304 |
|
|
|
305 |
|
|
#endif
|