]> SALOME platform Git repositories - modules/smesh.git/blob - src/SMDS/SMDS_Mesh.hxx
Salome HOME
PAL13330( When mesh generation does not success, trace where )
[modules/smesh.git] / src / SMDS / SMDS_Mesh.hxx
1 //  SMESH SMDS : implementaion of Salome mesh data structure
2 //
3 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
5 // 
6 //  This library is free software; you can redistribute it and/or 
7 //  modify it under the terms of the GNU Lesser General Public 
8 //  License as published by the Free Software Foundation; either 
9 //  version 2.1 of the License. 
10 // 
11 //  This library is distributed in the hope that it will be useful, 
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of 
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
14 //  Lesser General Public License for more details. 
15 // 
16 //  You should have received a copy of the GNU Lesser General Public 
17 //  License along with this library; if not, write to the Free Software 
18 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
19 // 
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 //
23 //
24 //  File   : SMDS_Mesh.hxx
25 //  Module : SMESH
26
27 #ifndef _SMDS_Mesh_HeaderFile
28 #define _SMDS_Mesh_HeaderFile
29
30 #include "SMDS_MeshNode.hxx"
31 #include "SMDS_MeshEdge.hxx"
32 #include "SMDS_MeshFace.hxx"
33 #include "SMDS_MeshVolume.hxx"
34 #include "SMDS_MeshElementIDFactory.hxx"
35 #include "SMDS_ElemIterator.hxx"
36 #include <NCollection_Map.hxx>
37
38 //#ifdef WNT
39 //#include <SALOME_WNT.hxx>
40 //#else
41 //#define SALOME_WNT_EXPORT
42 //#endif
43 #if defined WNT && defined WIN32 && defined SMDS_EXPORTS
44 #define SMDS_WNT_EXPORT __declspec( dllexport )
45 #else
46 #define SMDS_WNT_EXPORT
47 #endif
48
49 #include <boost/shared_ptr.hpp>
50 #include <set>
51 #include <list>
52
53 class SMDS_WNT_EXPORT SMDS_Mesh:public SMDS_MeshObject{
54 public:
55   
56   SMDS_Mesh();
57   
58   SMDS_NodeIteratorPtr nodesIterator() const;
59   SMDS_EdgeIteratorPtr edgesIterator() const;
60   SMDS_FaceIteratorPtr facesIterator() const;
61   SMDS_VolumeIteratorPtr volumesIterator() const;
62   SMDS_ElemIteratorPtr elementsIterator() const;  
63   
64   SMDSAbs_ElementType GetElementType( const int id, const bool iselem ) const;
65
66   SMDS_Mesh *AddSubMesh();
67   
68   virtual SMDS_MeshNode* AddNodeWithID(double x, double y, double z, int ID);
69   virtual SMDS_MeshNode* AddNode(double x, double y, double z);
70   
71   virtual SMDS_MeshEdge* AddEdgeWithID(int n1, int n2, int ID);
72   virtual SMDS_MeshEdge* AddEdgeWithID(const SMDS_MeshNode * n1,
73                                        const SMDS_MeshNode * n2, 
74                                        int ID);
75   virtual SMDS_MeshEdge* AddEdge(const SMDS_MeshNode * n1,
76                                  const SMDS_MeshNode * n2);
77   
78   // 2d order edge with 3 nodes: n12 - node between n1 and n2
79   virtual SMDS_MeshEdge* AddEdgeWithID(int n1, int n2, int n12, int ID);
80   virtual SMDS_MeshEdge* AddEdgeWithID(const SMDS_MeshNode * n1,
81                                        const SMDS_MeshNode * n2, 
82                                        const SMDS_MeshNode * n12, 
83                                        int ID);
84   virtual SMDS_MeshEdge* AddEdge(const SMDS_MeshNode * n1,
85                                  const SMDS_MeshNode * n2,
86                                  const SMDS_MeshNode * n12);
87
88   virtual SMDS_MeshFace* AddFaceWithID(int n1, int n2, int n3, int ID);
89   virtual SMDS_MeshFace* AddFaceWithID(const SMDS_MeshNode * n1,
90                                        const SMDS_MeshNode * n2,
91                                        const SMDS_MeshNode * n3, 
92                                        int ID);
93   virtual SMDS_MeshFace* AddFace(const SMDS_MeshNode * n1,
94                                  const SMDS_MeshNode * n2,
95                                  const SMDS_MeshNode * n3);
96   
97   virtual SMDS_MeshFace* AddFaceWithID(int n1, int n2, int n3, int n4, int ID);
98   virtual SMDS_MeshFace* AddFaceWithID(const SMDS_MeshNode * n1,
99                                        const SMDS_MeshNode * n2,
100                                        const SMDS_MeshNode * n3,
101                                        const SMDS_MeshNode * n4, 
102                                        int ID);
103   virtual SMDS_MeshFace* AddFace(const SMDS_MeshNode * n1,
104                                  const SMDS_MeshNode * n2,
105                                  const SMDS_MeshNode * n3,
106                                  const SMDS_MeshNode * n4);
107   
108   virtual SMDS_MeshFace* AddFaceWithID(const SMDS_MeshEdge * e1,
109                                        const SMDS_MeshEdge * e2,
110                                        const SMDS_MeshEdge * e3, int ID);
111   virtual SMDS_MeshFace* AddFace(const SMDS_MeshEdge * e1,
112                                  const SMDS_MeshEdge * e2,
113                                  const SMDS_MeshEdge * e3);
114
115   virtual SMDS_MeshFace* AddFaceWithID(const SMDS_MeshEdge * e1,
116                                        const SMDS_MeshEdge * e2,
117                                        const SMDS_MeshEdge * e3,
118                                        const SMDS_MeshEdge * e4, int ID);
119   virtual SMDS_MeshFace* AddFace(const SMDS_MeshEdge * e1,
120                                  const SMDS_MeshEdge * e2,
121                                  const SMDS_MeshEdge * e3,
122                                  const SMDS_MeshEdge * e4);
123
124   // 2d order triangle of 6 nodes
125   virtual SMDS_MeshFace* AddFaceWithID(int n1, int n2, int n3,
126                                        int n12,int n23,int n31, int ID);
127   virtual SMDS_MeshFace* AddFaceWithID(const SMDS_MeshNode * n1,
128                                        const SMDS_MeshNode * n2,
129                                        const SMDS_MeshNode * n3, 
130                                        const SMDS_MeshNode * n12,
131                                        const SMDS_MeshNode * n23,
132                                        const SMDS_MeshNode * n31, 
133                                        int ID);
134   virtual SMDS_MeshFace* AddFace(const SMDS_MeshNode * n1,
135                                  const SMDS_MeshNode * n2,
136                                  const SMDS_MeshNode * n3,
137                                  const SMDS_MeshNode * n12,
138                                  const SMDS_MeshNode * n23,
139                                  const SMDS_MeshNode * n31);
140
141   // 2d order quadrangle
142   virtual SMDS_MeshFace* AddFaceWithID(int n1, int n2, int n3, int n4,
143                                        int n12,int n23,int n34,int n41, int ID);
144   virtual SMDS_MeshFace* AddFaceWithID(const SMDS_MeshNode * n1,
145                                        const SMDS_MeshNode * n2,
146                                        const SMDS_MeshNode * n3,
147                                        const SMDS_MeshNode * n4, 
148                                        const SMDS_MeshNode * n12,
149                                        const SMDS_MeshNode * n23,
150                                        const SMDS_MeshNode * n34,
151                                        const SMDS_MeshNode * n41, 
152                                        int ID);
153   virtual SMDS_MeshFace* AddFace(const SMDS_MeshNode * n1,
154                                  const SMDS_MeshNode * n2,
155                                  const SMDS_MeshNode * n3,
156                                  const SMDS_MeshNode * n4,
157                                  const SMDS_MeshNode * n12,
158                                  const SMDS_MeshNode * n23,
159                                  const SMDS_MeshNode * n34,
160                                  const SMDS_MeshNode * n41);
161
162   virtual SMDS_MeshVolume* AddVolumeWithID(int n1, int n2, int n3, int n4, int ID);
163   virtual SMDS_MeshVolume* AddVolumeWithID(const SMDS_MeshNode * n1,
164                                            const SMDS_MeshNode * n2,
165                                            const SMDS_MeshNode * n3,
166                                            const SMDS_MeshNode * n4, 
167                                            int ID);
168   virtual SMDS_MeshVolume* AddVolume(const SMDS_MeshNode * n1,
169                                      const SMDS_MeshNode * n2,
170                                      const SMDS_MeshNode * n3,
171                                      const SMDS_MeshNode * n4);
172   
173   virtual SMDS_MeshVolume* AddVolumeWithID(int n1, int n2, int n3, int n4,
174                                            int n5, int ID);
175   virtual SMDS_MeshVolume* AddVolumeWithID(const SMDS_MeshNode * n1,
176                                            const SMDS_MeshNode * n2,
177                                            const SMDS_MeshNode * n3,
178                                            const SMDS_MeshNode * n4,
179                                            const SMDS_MeshNode * n5, 
180                                            int ID);
181   virtual SMDS_MeshVolume* AddVolume(const SMDS_MeshNode * n1,
182                                      const SMDS_MeshNode * n2,
183                                      const SMDS_MeshNode * n3,
184                                      const SMDS_MeshNode * n4,
185                                      const SMDS_MeshNode * n5);
186   
187   virtual SMDS_MeshVolume* AddVolumeWithID(int n1, int n2, int n3, int n4,
188                                            int n5, int n6, int ID);
189   virtual SMDS_MeshVolume* AddVolumeWithID(const SMDS_MeshNode * n1,
190                                            const SMDS_MeshNode * n2,
191                                            const SMDS_MeshNode * n3,
192                                            const SMDS_MeshNode * n4,
193                                            const SMDS_MeshNode * n5,
194                                            const SMDS_MeshNode * n6, 
195                                            int ID);
196   virtual SMDS_MeshVolume* AddVolume(const SMDS_MeshNode * n1,
197                                      const SMDS_MeshNode * n2,
198                                      const SMDS_MeshNode * n3,
199                                      const SMDS_MeshNode * n4,
200                                      const SMDS_MeshNode * n5,
201                                      const SMDS_MeshNode * n6);
202   
203   virtual SMDS_MeshVolume* AddVolumeWithID(int n1, int n2, int n3, int n4,
204                                            int n5, int n6, int n7, int n8, int ID);
205   virtual SMDS_MeshVolume* AddVolumeWithID(const SMDS_MeshNode * n1,
206                                            const SMDS_MeshNode * n2,
207                                            const SMDS_MeshNode * n3,
208                                            const SMDS_MeshNode * n4,
209                                            const SMDS_MeshNode * n5,
210                                            const SMDS_MeshNode * n6,
211                                            const SMDS_MeshNode * n7,
212                                            const SMDS_MeshNode * n8, 
213                                            int ID);
214   virtual SMDS_MeshVolume* AddVolume(const SMDS_MeshNode * n1,
215                                      const SMDS_MeshNode * n2,
216                                      const SMDS_MeshNode * n3,
217                                      const SMDS_MeshNode * n4,
218                                      const SMDS_MeshNode * n5,
219                                      const SMDS_MeshNode * n6,
220                                      const SMDS_MeshNode * n7,
221                                      const SMDS_MeshNode * n8);
222
223   virtual SMDS_MeshVolume* AddVolumeWithID(const SMDS_MeshFace * f1,
224                                            const SMDS_MeshFace * f2,
225                                            const SMDS_MeshFace * f3,
226                                            const SMDS_MeshFace * f4, int ID);
227   virtual SMDS_MeshVolume* AddVolume(const SMDS_MeshFace * f1,
228                                      const SMDS_MeshFace * f2,
229                                      const SMDS_MeshFace * f3,
230                                      const SMDS_MeshFace * f4);
231
232   virtual SMDS_MeshVolume* AddVolumeWithID(const SMDS_MeshFace * f1,
233                                            const SMDS_MeshFace * f2,
234                                            const SMDS_MeshFace * f3,
235                                            const SMDS_MeshFace * f4,
236                                            const SMDS_MeshFace * f5, int ID);
237   virtual SMDS_MeshVolume* AddVolume(const SMDS_MeshFace * f1,
238                                      const SMDS_MeshFace * f2,
239                                      const SMDS_MeshFace * f3,
240                                      const SMDS_MeshFace * f4,
241                                      const SMDS_MeshFace * f5);
242
243   virtual SMDS_MeshVolume* AddVolumeWithID(const SMDS_MeshFace * f1,
244                                            const SMDS_MeshFace * f2,
245                                            const SMDS_MeshFace * f3,
246                                            const SMDS_MeshFace * f4,
247                                            const SMDS_MeshFace * f5,
248                                            const SMDS_MeshFace * f6, int ID);
249   virtual SMDS_MeshVolume* AddVolume(const SMDS_MeshFace * f1,
250                                      const SMDS_MeshFace * f2,
251                                      const SMDS_MeshFace * f3,
252                                      const SMDS_MeshFace * f4,
253                                      const SMDS_MeshFace * f5,
254                                      const SMDS_MeshFace * f6);
255
256   // 2d order tetrahedron of 10 nodes
257   virtual SMDS_MeshVolume* AddVolumeWithID(int n1, int n2, int n3, int n4,
258                                            int n12,int n23,int n31,
259                                            int n14,int n24,int n34, int ID);
260   virtual SMDS_MeshVolume* AddVolumeWithID(const SMDS_MeshNode * n1,
261                                            const SMDS_MeshNode * n2,
262                                            const SMDS_MeshNode * n3,
263                                            const SMDS_MeshNode * n4, 
264                                            const SMDS_MeshNode * n12,
265                                            const SMDS_MeshNode * n23,
266                                            const SMDS_MeshNode * n31,
267                                            const SMDS_MeshNode * n14, 
268                                            const SMDS_MeshNode * n24,
269                                            const SMDS_MeshNode * n34, 
270                                            int ID);
271   virtual SMDS_MeshVolume* AddVolume(const SMDS_MeshNode * n1,
272                                      const SMDS_MeshNode * n2,
273                                      const SMDS_MeshNode * n3,
274                                      const SMDS_MeshNode * n4,
275                                      const SMDS_MeshNode * n12,
276                                      const SMDS_MeshNode * n23,
277                                      const SMDS_MeshNode * n31,
278                                      const SMDS_MeshNode * n14, 
279                                      const SMDS_MeshNode * n24,
280                                      const SMDS_MeshNode * n34);
281
282   // 2d order pyramid of 13 nodes
283   virtual SMDS_MeshVolume* AddVolumeWithID(int n1, int n2, int n3, int n4, int n5,
284                                            int n12,int n23,int n34,int n41,
285                                            int n15,int n25,int n35,int n45,
286                                            int ID);
287   virtual SMDS_MeshVolume* AddVolumeWithID(const SMDS_MeshNode * n1,
288                                            const SMDS_MeshNode * n2,
289                                            const SMDS_MeshNode * n3,
290                                            const SMDS_MeshNode * n4,
291                                            const SMDS_MeshNode * n5, 
292                                            const SMDS_MeshNode * n12,
293                                            const SMDS_MeshNode * n23,
294                                            const SMDS_MeshNode * n34,
295                                            const SMDS_MeshNode * n41, 
296                                            const SMDS_MeshNode * n15,
297                                            const SMDS_MeshNode * n25,
298                                            const SMDS_MeshNode * n35,
299                                            const SMDS_MeshNode * n45, 
300                                            int ID);
301   virtual SMDS_MeshVolume* AddVolume(const SMDS_MeshNode * n1,
302                                      const SMDS_MeshNode * n2,
303                                      const SMDS_MeshNode * n3,
304                                      const SMDS_MeshNode * n4,
305                                      const SMDS_MeshNode * n5,
306                                      const SMDS_MeshNode * n12,
307                                      const SMDS_MeshNode * n23,
308                                      const SMDS_MeshNode * n34,
309                                      const SMDS_MeshNode * n41, 
310                                      const SMDS_MeshNode * n15,
311                                      const SMDS_MeshNode * n25,
312                                      const SMDS_MeshNode * n35,
313                                      const SMDS_MeshNode * n45);
314
315   // 2d order Pentahedron with 15 nodes
316   virtual SMDS_MeshVolume* AddVolumeWithID(int n1, int n2, int n3,
317                                            int n4, int n5, int n6,
318                                            int n12,int n23,int n31,
319                                            int n45,int n56,int n64,
320                                            int n14,int n25,int n36,
321                                            int ID);
322   virtual SMDS_MeshVolume* AddVolumeWithID(const SMDS_MeshNode * n1,
323                                            const SMDS_MeshNode * n2,
324                                            const SMDS_MeshNode * n3,
325                                            const SMDS_MeshNode * n4,
326                                            const SMDS_MeshNode * n5,
327                                            const SMDS_MeshNode * n6, 
328                                            const SMDS_MeshNode * n12,
329                                            const SMDS_MeshNode * n23,
330                                            const SMDS_MeshNode * n31, 
331                                            const SMDS_MeshNode * n45,
332                                            const SMDS_MeshNode * n56,
333                                            const SMDS_MeshNode * n64, 
334                                            const SMDS_MeshNode * n14,
335                                            const SMDS_MeshNode * n25,
336                                            const SMDS_MeshNode * n36, 
337                                            int ID);
338   virtual SMDS_MeshVolume* AddVolume(const SMDS_MeshNode * n1,
339                                      const SMDS_MeshNode * n2,
340                                      const SMDS_MeshNode * n3,
341                                      const SMDS_MeshNode * n4,
342                                      const SMDS_MeshNode * n5,
343                                      const SMDS_MeshNode * n6, 
344                                      const SMDS_MeshNode * n12,
345                                      const SMDS_MeshNode * n23,
346                                      const SMDS_MeshNode * n31, 
347                                      const SMDS_MeshNode * n45,
348                                      const SMDS_MeshNode * n56,
349                                      const SMDS_MeshNode * n64, 
350                                      const SMDS_MeshNode * n14,
351                                      const SMDS_MeshNode * n25,
352                                      const SMDS_MeshNode * n36);
353
354   // 2d oreder Hexahedrons with 20 nodes
355   virtual SMDS_MeshVolume* AddVolumeWithID(int n1, int n2, int n3, int n4,
356                                            int n5, int n6, int n7, int n8,
357                                            int n12,int n23,int n34,int n41,
358                                            int n56,int n67,int n78,int n85,
359                                            int n15,int n26,int n37,int n48,
360                                            int ID);
361   virtual SMDS_MeshVolume* AddVolumeWithID(const SMDS_MeshNode * n1,
362                                            const SMDS_MeshNode * n2,
363                                            const SMDS_MeshNode * n3,
364                                            const SMDS_MeshNode * n4,
365                                            const SMDS_MeshNode * n5,
366                                            const SMDS_MeshNode * n6,
367                                            const SMDS_MeshNode * n7,
368                                            const SMDS_MeshNode * n8, 
369                                            const SMDS_MeshNode * n12,
370                                            const SMDS_MeshNode * n23,
371                                            const SMDS_MeshNode * n34,
372                                            const SMDS_MeshNode * n41, 
373                                            const SMDS_MeshNode * n56,
374                                            const SMDS_MeshNode * n67,
375                                            const SMDS_MeshNode * n78,
376                                            const SMDS_MeshNode * n85, 
377                                            const SMDS_MeshNode * n15,
378                                            const SMDS_MeshNode * n26,
379                                            const SMDS_MeshNode * n37,
380                                            const SMDS_MeshNode * n48, 
381                                            int ID);
382   virtual SMDS_MeshVolume* AddVolume(const SMDS_MeshNode * n1,
383                                      const SMDS_MeshNode * n2,
384                                      const SMDS_MeshNode * n3,
385                                      const SMDS_MeshNode * n4,
386                                      const SMDS_MeshNode * n5,
387                                      const SMDS_MeshNode * n6,
388                                      const SMDS_MeshNode * n7,
389                                      const SMDS_MeshNode * n8, 
390                                      const SMDS_MeshNode * n12,
391                                      const SMDS_MeshNode * n23,
392                                      const SMDS_MeshNode * n34,
393                                      const SMDS_MeshNode * n41, 
394                                      const SMDS_MeshNode * n56,
395                                      const SMDS_MeshNode * n67,
396                                      const SMDS_MeshNode * n78,
397                                      const SMDS_MeshNode * n85, 
398                                      const SMDS_MeshNode * n15,
399                                      const SMDS_MeshNode * n26,
400                                      const SMDS_MeshNode * n37,
401                                      const SMDS_MeshNode * n48);
402
403   virtual SMDS_MeshFace* AddPolygonalFaceWithID (std::vector<int> nodes_ids,
404                                                  const int        ID);
405
406   virtual SMDS_MeshFace* AddPolygonalFaceWithID (std::vector<const SMDS_MeshNode*> nodes,
407                                                  const int                         ID);
408
409   virtual SMDS_MeshFace* AddPolygonalFace (std::vector<const SMDS_MeshNode*> nodes);
410
411   virtual SMDS_MeshVolume* AddPolyhedralVolumeWithID
412                            (std::vector<int> nodes_ids,
413                             std::vector<int> quantities,
414                             const int        ID);
415
416   virtual SMDS_MeshVolume* AddPolyhedralVolumeWithID
417                            (std::vector<const SMDS_MeshNode*> nodes,
418                             std::vector<int>                  quantities,
419                             const int                         ID);
420
421   virtual SMDS_MeshVolume* AddPolyhedralVolume
422                            (std::vector<const SMDS_MeshNode*> nodes,
423                             std::vector<int>                  quantities);
424
425   virtual void RemoveElement(const SMDS_MeshElement *        elem,
426                              std::list<const SMDS_MeshElement *>& removedElems,
427                              std::list<const SMDS_MeshElement *>& removedNodes,
428                              const bool                      removenodes = false);
429   virtual void RemoveElement(const SMDS_MeshElement * elem, bool removenodes = false);
430   virtual void RemoveNode(const SMDS_MeshNode * node);
431   virtual void RemoveEdge(const SMDS_MeshEdge * edge);
432   virtual void RemoveFace(const SMDS_MeshFace * face);
433   virtual void RemoveVolume(const SMDS_MeshVolume * volume);
434
435   /*! Remove only the given element and only if it is free.
436    *  Method does not work for meshes with descendants.
437    *  Implemented for fast cleaning of meshes.
438    */
439   virtual void RemoveFreeElement(const SMDS_MeshElement * elem);
440   
441   virtual bool RemoveFromParent();
442   virtual bool RemoveSubMesh(const SMDS_Mesh * aMesh);
443
444   static bool ChangeElementNodes(const SMDS_MeshElement * elem,
445                                  const SMDS_MeshNode    * nodes[],
446                                  const int                nbnodes);
447   static bool ChangePolyhedronNodes(const SMDS_MeshElement * elem,
448                                     std::vector<const SMDS_MeshNode*> nodes,
449                                     std::vector<int>                  quantities);
450
451   virtual void Renumber (const bool isNodes, const int startID = 1, const int deltaID = 1);
452   // Renumber all nodes or elements.
453
454   const SMDS_MeshNode *FindNode(int idnode) const;
455   const SMDS_MeshEdge *FindEdge(int idnode1, int idnode2) const;
456   const SMDS_MeshEdge *FindEdge(int idnode1, int idnode2, int idnode3) const;
457   const SMDS_MeshFace *FindFace(int idnode1, int idnode2, int idnode3) const;
458   const SMDS_MeshFace *FindFace(int idnode1, int idnode2, int idnode3, int idnode4) const;
459   const SMDS_MeshFace *FindFace(int idnode1, int idnode2, int idnode3,
460                                 int idnode4, int idnode5, int idnode6) const;
461   const SMDS_MeshFace *FindFace(int idnode1, int idnode2, int idnode3, int idnode4,
462                                 int idnode5, int idnode6, int idnode7, int idnode8) const;
463   const SMDS_MeshElement *FindElement(int IDelem) const;
464   static const SMDS_MeshEdge* FindEdge(const SMDS_MeshNode * n1,
465                                        const SMDS_MeshNode * n2);
466   static const SMDS_MeshEdge* FindEdge(const SMDS_MeshNode * n1,
467                                        const SMDS_MeshNode * n2,
468                                        const SMDS_MeshNode * n3);
469   static const SMDS_MeshFace* FindFace(const SMDS_MeshNode *n1,
470                                        const SMDS_MeshNode *n2,
471                                        const SMDS_MeshNode *n3);
472   static const SMDS_MeshFace* FindFace(const SMDS_MeshNode *n1,
473                                        const SMDS_MeshNode *n2,
474                                        const SMDS_MeshNode *n3,
475                                        const SMDS_MeshNode *n4);
476   static const SMDS_MeshFace* FindFace(const SMDS_MeshNode *n1,
477                                        const SMDS_MeshNode *n2,
478                                        const SMDS_MeshNode *n3,
479                                        const SMDS_MeshNode *n4,
480                                        const SMDS_MeshNode *n5,
481                                        const SMDS_MeshNode *n6);
482   static const SMDS_MeshFace* FindFace(const SMDS_MeshNode *n1,
483                                        const SMDS_MeshNode *n2,
484                                        const SMDS_MeshNode *n3,
485                                        const SMDS_MeshNode *n4,
486                                        const SMDS_MeshNode *n5,
487                                        const SMDS_MeshNode *n6,
488                                        const SMDS_MeshNode *n7,
489                                        const SMDS_MeshNode *n8);
490
491   const SMDS_MeshFace *FindFace(std::vector<int> nodes_ids) const;
492   static const SMDS_MeshFace* FindFace(std::vector<const SMDS_MeshNode *> nodes);
493
494   int MaxNodeID() const;
495   int MinNodeID() const;
496   int MaxElementID() const;
497   int MinElementID() const;
498
499
500   int NbNodes() const;
501   int NbEdges() const;
502   int NbFaces() const;
503   int NbVolumes() const;
504   int NbSubMesh() const;
505   void DumpNodes() const;
506   void DumpEdges() const;
507   void DumpFaces() const;
508   void DumpVolumes() const;
509   void DebugStats() const;
510   SMDS_Mesh *boundaryFaces();
511   SMDS_Mesh *boundaryEdges();
512   virtual ~SMDS_Mesh();
513   bool hasConstructionEdges();
514   bool hasConstructionFaces();
515   bool hasInverseElements();
516   void setConstructionEdges(bool);
517   void setConstructionFaces(bool);
518   void setInverseElements(bool);
519
520   /*!
521    * Checks if the element is present in mesh.
522    * Useful to determine dead pointers.
523    * Use this function for debug purpose only! Do not check in the code
524    * using it even in _DEBUG_ mode
525    */
526   bool Contains (const SMDS_MeshElement* elem) const;
527
528   typedef NCollection_Map<SMDS_MeshNode *> SetOfNodes;
529   typedef NCollection_Map<SMDS_MeshEdge *> SetOfEdges;
530   typedef NCollection_Map<SMDS_MeshFace *> SetOfFaces;
531   typedef NCollection_Map<SMDS_MeshVolume *> SetOfVolumes;
532
533 private:
534   SMDS_Mesh(SMDS_Mesh * parent);
535
536   SMDS_MeshFace * createTriangle(const SMDS_MeshNode * node1, 
537                                  const SMDS_MeshNode * node2, 
538                                  const SMDS_MeshNode * node3);
539   SMDS_MeshFace * createQuadrangle(const SMDS_MeshNode * node1,
540                                    const SMDS_MeshNode * node2, 
541                                    const SMDS_MeshNode * node3, 
542                                    const SMDS_MeshNode * node4);
543   SMDS_MeshEdge* FindEdgeOrCreate(const SMDS_MeshNode * n1,
544                                   const SMDS_MeshNode * n2);
545   SMDS_MeshFace* FindFaceOrCreate(const SMDS_MeshNode *n1,
546                                   const SMDS_MeshNode *n2,
547                                   const SMDS_MeshNode *n3);
548   SMDS_MeshFace* FindFaceOrCreate(const SMDS_MeshNode *n1,
549                                   const SMDS_MeshNode *n2,
550                                   const SMDS_MeshNode *n3,
551                                   const SMDS_MeshNode *n4);
552
553   bool registerElement(int ID, SMDS_MeshElement * element);
554
555   void addChildrenWithNodes(std::set<const SMDS_MeshElement*>& setOfChildren, 
556                             const SMDS_MeshElement * element, 
557                             std::set<const SMDS_MeshElement*>& nodes);
558
559   // Fields PRIVATE
560   
561   SetOfNodes myNodes;
562   SetOfEdges myEdges;
563   SetOfFaces myFaces;
564   SetOfVolumes myVolumes;
565   SMDS_Mesh *myParent;
566   std::list<SMDS_Mesh *> myChildren;
567   SMDS_MeshElementIDFactory *myNodeIDFactory;
568   SMDS_MeshElementIDFactory *myElementIDFactory;
569   
570   bool myHasConstructionEdges;
571   bool myHasConstructionFaces;
572   bool myHasInverseElements;
573 };
574
575
576 #endif