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