ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/REPOS_ERICCA/magic/lib/CAD4FE/src/CAD4FE_MCAA.h
Revision: 569
Committed: Thu Oct 16 14:36:31 2014 UTC (10 years, 6 months ago) by foucault
Content type: text/plain
File size: 10898 byte(s)
Error occurred while calculating annotation data.
Log Message:
Mise à jour pour CAD4FE (Gilles) : operation 1 (tentative)

File Contents

# Content
1 //---------------------------------------------------------------------------
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 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 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 int GetMinMCEdgeCount();
209 void SetMinMCEdgeCount(int __minMCEdgeCount);
210 int GetMinMCVertexCount();
211 void SetMinMCVertexCount(int __minMCVertexCount);
212
213 protected:
214 /// Copy the tessellation of the initial reference body MG_VOLUME (__tessellation)
215 /// and link tessellation entities to MC entities
216 void _InitializeMCBodyTessellation();
217
218 /// debug routines
219 void _DebugmcEntsByMeshing();
220 void _DebugSurfacesByMeshingAlongIsoParametric();
221
222 /// find the closest segment from P which is intersected by plane (N,P)
223 MG_SEGMENT * _FindClosestSeg(TPL_MAP_ENTITE<MG_SEGMENT *> & __lstSegs, MCEdge * __mcEdge, double __P[3], double __N[3]);
224
225 /// Initialize the MC Tessellation Segments Grid
226 void _InitializeMCTessSegGrid();
227 void _UpdateMCTessSegGrid(MCEdge * __mcEdge, MG_SEGMENT * __originalSegment, MG_SEGMENT * __splitSegments[2]);
228
229 void _DebugTraditionnalMesh();
230
231 private:
232 VCMap _vcMap;
233 ECMap _ecMap;
234
235 /// Input Meshing criteria and
236 /// Simplification properties
237 double _limitAngle;
238 double _relativeSag;
239 double _maxOverdensity;
240
241 /// reference body
242 MG_VOLUME * _refBody;
243 /// tessellation mesh
244 MG_MAILLAGE * _refTess;
245 /// MC Body which will be simplified
246 MCBody * _mcBody;
247 /// tessellation of the simplified body
248 MG_MAILLAGE * _mcTess;
249
250 /// topology and geometry and mesh manager
251 /// of the reference entities
252 MG_GESTIONNAIRE * _refGest;
253
254 /// Criteria for adaptation
255 /// std::map < int, LocalEdgeCrit * >
256
257 MG_GEOMETRIE * _geom;
258
259 /// Finite Element Analysis mesh of the
260 /// MC Body
261 MG_MAILLAGE * _feMesh;
262
263 /// Size map
264 FCT_TAILLE * _sizeMap;
265
266 /// Bounding box of the part
267 double _bbox[6];
268
269 /// Grid containing the segments of the MC Tessellation
270 TPL_GRILLE <MG_SEGMENT *> * _mcTessSegGrid;
271
272 /// Record of the last inserted vertex
273 std::map <MG_SOMMET*, int> _mapSuppressRefVertexCount;
274
275 int _nbA; /// edge deletion
276 int _nbB; /// vertex deletion
277 int _nbC; /// edge collapse
278 int _nbD; /// constricted section
279 int _nbE; /// loops
280
281 int _minMCEdgeCount;
282 int _minMCVertexCount;
283 };
284
285 }
286
287 #endif