ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/REPOS_ERICCA/magic/lib/CAD4FE/src/CAD4FE_MCBody.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: 9018 byte(s)
Log Message:
Mise à jour pour CAD4FE (Gilles) : operation 1 (tentative)

File Contents

# User Rev Content
1 foucault 27 #ifndef CAD4FE_MCBodyh
2     #define CAD4FE_MCBodyh
3    
4 foucault 569 #include "CAD4FE_MCT_Platform.h"
5 foucault 27
6     //---------------------------------------------------------------------------
7     // include MAGIC Headers
8     #include "gestionversion.h"
9     #include <mg_geometrie.h>
10     //---------------------------------------------------------------------------
11     // Graph stuff goes here !
12 foucault 176 #include "CAD4FE_Graph.h"
13 foucault 27 //---------------------------------------------------------------------------
14     #include <map>
15     #include <vector>
16    
17     #pragma hdrstop
18    
19     #define MCBODY_FOR_EACH_MCEDGE(M,E)\
20     HypergraphLib::Graph *G21graph_tmp=M->G21(); \
21 foucault 569 HypergraphLib::Graph::MapArcsById::const_iterator iteratorArcs_tmp; \
22     iteratorArcs_tmp = G21graph_tmp->GetArcs().begin(); \
23     CAD4FE::MCEdge * E = (iteratorArcs_tmp->second != NULL) ? M->GetMCEdge(iteratorArcs_tmp->second) : NULL; \
24     for (iteratorArcs_tmp = G21graph_tmp->GetArcs().begin(); \
25     E != NULL; \
26     iteratorArcs_tmp++ , E = (iteratorArcs_tmp != G21graph_tmp->GetArcs().end() && iteratorArcs_tmp->second != NULL) ? M->GetMCEdge(iteratorArcs_tmp->second) : NULL )
27 foucault 27
28    
29     #define MCBODY_FOR_EACH_MCFACE(M,F)\
30     HypergraphLib::Graph *G21graph_tmp=M->G21(); \
31     CAD4FE::MCFace * F=M->GetMCFace(G21graph_tmp->GetNodes().begin()->second); \
32     if (G21graph_tmp->GetNodes().size() != 0)\
33     for (HypergraphLib::Graph::MapNodesById::const_iterator iteratorNodes_tmp = G21graph_tmp->GetNodes().begin() \
34     ; \
35     F != NULL; \
36     iteratorNodes_tmp++ , F = (iteratorNodes_tmp != G21graph_tmp->GetNodes().end()) ? M->GetMCFace(iteratorNodes_tmp->second) : NULL )
37    
38    
39     #define MCBODY_FOR_EACH_MCVERTEX(M,V)\
40     HypergraphLib::Graph *G10graph_tmp=M->G10();\
41     CAD4FE::MCVertex * V=M->GetMCVertex(G10graph_tmp->GetArcs().begin()->second); \
42     if (G10graph_tmp->GetArcs().size() != 0) \
43     for (HypergraphLib::Graph::MapArcsById::const_iterator iteratorArcs_tmp = G10graph_tmp->GetArcs().begin() \
44     ; \
45     V != NULL ; \
46     iteratorArcs_tmp++ , V = (iteratorArcs_tmp != G10graph_tmp->GetArcs().end()) ? M->GetMCVertex(iteratorArcs_tmp->second) : NULL )
47    
48     class MG_ELEMENT_TOPOLOGIQUE;
49     class MG_GEOMETRIE;
50     class MG_COARETE;
51    
52     namespace CAD4FE {
53    
54     class MCEdge;
55     class MCFace;
56     class MCVertex;
57     class Vector3dKey;
58     class PolyCurve;
59    
60     class CAD4FE_MCT_ITEM RTChanges {
61     public:
62     RTChanges(){};
63     /// map of old to new faces
64     std::multimap < MG_FACE *, MG_FACE * > F;
65     /// map of old to new edges
66     std::multimap < MG_ARETE *, MG_ARETE * > E;
67     /// map of old to new vertices
68     std::multimap < MG_SOMMET *, MG_SOMMET * > V;
69     /// Merge changes
70     void Merge(RTChanges&);
71 foucault 569 };
72 foucault 27
73     class CAD4FE_MCT_ITEM MCTChanges {
74     public:
75     MCTChanges(){};
76     /// map of old to new faces
77     std::multimap < MCFace * , MCFace * > F;
78     /// map of old to new edges
79     std::multimap < MCEdge * , MCEdge * > E;
80     /// map of old to new vertices
81 foucault 569 std::multimap < MCVertex * , MCVertex * > V;
82 foucault 27 /// Merge changes
83     void Merge(MCTChanges&);
84     };
85    
86     class CAD4FE_MCT_ITEM MCBody {
87     public:
88     typedef std::map<int, MCFace*> MapMCFaceById;
89     typedef std::map<int, MCEdge*> MapMCEdgeById;
90     typedef std::map<int, MCVertex*> MapMCVertexById;
91    
92     MCBody(MG_GEOMETRIE * __refGeom, MG_VOLUME * __refBody);
93     // Destruction routines
94     ~MCBody();
95    
96     // Construction routines
97     void ReInit();
98     void InitHyperGraphs();
99     double EvaluateBoundaryShape(Graph::Arc *__arcG2V, double __RMin);
100     void InitializeRealGeomData();
101     void InitializeCopyRealToVirtualHyperGraphs();
102     int G2ToNeatoFile (Graph::Graph * __G2, char * __filename, char *__graphname);
103     int G1ToNeatoFile (Graph::Graph * __G1, char * __filename, char *__graphname);
104    
105     Graph::Arc * GetG2ArcFromG1Node(const Graph::Node *) const;
106    
107     Graph::Graph * G10() const;
108     Graph::Graph * G21() const;
109     Graph::Graph * G20() const;
110    
111     MG_GEOMETRIE * GetGeometry(){return _refGeom;};
112    
113     // Link userdata in hypergraphs
114     void Graph_SetUserData(MG_ELEMENT_TOPOLOGIQUE * __topo);
115     void Graph_SetUserData(Graph::Graph * __G, MG_ELEMENT_TOPOLOGIQUE * __topo);
116    
117     // MC Face
118     MCFace * AddMCFace(MG_FACE * __refFace);
119     MCFace * AddMCFace(MCFace *__a, MCFace *__b);
120     MCFace* GetMCFace(const int) const;
121     static MCFace* GetMCFace(Graph::GraphObject * __graphObject);
122     bool Contains(MCFace *) const;
123     void DeleteMCFace(MCFace * __mcFace);
124     // MC Edge
125     MCEdge * AddMCEdge(MG_ARETE * __refEdge);
126     void AddMCEdgeCovertices(MCEdge * __mcEdge, std::vector<MCVertex *> __mcVertex);
127     void DeleteMCEdgeCovertices(MCEdge * __mcEdge);
128     void DeleteMCEdge(MCEdge *__mcEdge);
129     MCEdge * AddMCEdge(MCEdge *__A, MCEdge *__B);
130     MCEdge * AddMCEdge(PolyCurve * );
131     MCEdge* GetMCEdge(const int ) const;
132     static MCEdge* GetMCEdge(Graph::GraphObject * __graphObject);
133     bool Contains(MCEdge *) const;
134     // MC Vertex
135     MCVertex * AddMCVertex(MG_SOMMET * __refVertex);
136     MCVertex * GetMCVertex(const int)const ;
137     void DeleteMCVertex(MCVertex * __mcVertex);
138     static MCVertex * GetMCVertex(Graph::GraphObject * __graphObject);
139     bool Contains(MCVertex *) const;
140    
141     // Create a MCVertex with a defined label
142     MCVertex * CreateMCVertex (MG_SOMMET *);
143     // Split an MC edge at one specified position
144     void SplitEdge(MCEdge * __mcEdge, double __xyz[3], MCTChanges * __mctChanges = 0, RTChanges * __rtChanges = 0);
145     /// Edge suppression algorithm
146     /// Argument #1: MC Edge to delete
147     /// Argument #2: array of MC Face (F1, F2, Fn)
148     /// (F1=2nd face merged (null if no face were merged)
149     /// (F2=2nd face merged (null if no face were merged)
150     /// (Fn=MC Face replacing F1 and F2, or MC Face located on the mc edge)
151     void SuppressMCEdge(MCEdge*, MCFace * __replMCFace[3]);
152     // Vertex suppression algorithm
153     void SuppressMCVertex(MCVertex *, MCTChanges * __mctChanges = 0);
154     // Edge-Vertex Contraction operator
155     void ContractEdgeToVertex(MCEdge * __mcEdge, MCVertex * __targetVertex, std::set <MCEdge*> & , std::set <MCEdge*> &);
156     void MergeVertices(MCVertex * __deleteVertex, MCVertex * __targetVertex, std::set<MCEdge*> & edges);
157    
158     // Topological properties of MCEdges
159     std::set < MCFace * > Edge_GetAdjacentFaces(MCEdge * __mcEdge);
160     void Edge_GetVertices (MCEdge *, std::vector<MCVertex*> & __mcVertices);
161    
162     // Topological properties of MCFaces
163 foucault 176 void Face_GetMCVertices (MCFace * __mcFace, std::vector<MCVertex*> & __mcVertices);
164 foucault 27 std::set < MCEdge * > Face_GetAdjacentEdges(MCFace * __mcFace);
165     Graph::Graph * Face_G10SubGraph(MCFace * __mcFace);
166     std::vector < std::vector < MCEdge * > > Face_GetUnsortedLoops(MCFace * __mcFace);
167     std::vector < std::vector < MCEdge * > > Face_GetCycles(MCFace * __mcFace);
168    
169     // Topological properties of MCVertices
170     void Vertex_GetAdjacentEdges(MCVertex * __mcVertex, std::vector<MCEdge *> & __list);
171     void Vertex_GetAdjacentEdges(MCVertex * __mcVertex, std::set<MCEdge *> & __list);
172     void Vertex_GetAdjacentFaces(MCVertex * __mcVertex, std::set<MCFace *> & __list);
173 foucault 64 int TestInteriorVertexIsolatedInFace(MCVertex * __mcVertex, MCFace ** __mcFace);
174 foucault 27
175 foucault 64 // number of faces, edges, vertices of reference body and mc body
176     void GetFEVCount(int * __faceCount,int * __edgeCount,int * __vertexCount);
177     void GetRefBodyFEVCount(int * __faceCount,int * __edgeCount,int * __vertexCount);
178    
179 foucault 27 // Generate Loops of MC Faces
180     void MCFace_GetLoops(MCFace* __mcFace, const std::set < Graph::Node * > & scc, std::vector < std::vector < std::pair < int, MCEdge * > > > & __loops );
181     MG_COARETE * CreateCoEdge(MCFace * mcFace, MG_BOUCLE * mcLoop, MCEdge * mcEdge);
182     MG_COARETE * CreateCoEdge(MCFace * mcFace, MG_BOUCLE * mcLoop, MCEdge * mcEdge, int sense);
183     int ExportBRep_MCEdgeSense(MCFace * __mcFace, MCEdge * __mcEdge);
184 foucault 64 int ExportBRep_CreateInteriorVertexIsolatedInFace(MCVertex * __mcVertex, MCFace * __mcFace);
185 foucault 27 // Export MC Body hypergraphs to BRep volume
186     MG_VOLUME * ExportBRep();
187     // delete all B-Rep MC entites
188     int DeleteBRep(MG_GESTIONNAIRE * gest, MG_GEOMETRIE * mggeo);
189    
190     /** modification time : represent the last step number
191     * of the MCAA process which created or modified this entity */
192     int time;
193    
194     private:
195     MG_GEOMETRIE * _refGeom;
196     MG_VOLUME * _refBody;
197     MG_VOLUME * _brep;
198     Graph::Graph *_G10;
199     Graph::Graph *_G20;
200     Graph::Graph *_G21;
201     };
202    
203     }
204    
205 foucault 176 #endif // CAD4FE_VIRTUALTOPOLOGYMODEL_H