]> SALOME platform Git repositories - modules/smesh.git/blob - src/SMDS/SMDS_Mesh.hxx
Salome HOME
Bug IPAL19467 - QT4 porting: geometrical group is not selected for mesh group
[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 "SMESH_SMDS.hxx"
31
32 #include "SMDS_MeshNode.hxx"
33 #include "SMDS_MeshEdge.hxx"
34 #include "SMDS_MeshFace.hxx"
35 #include "SMDS_MeshVolume.hxx"
36 #include "SMDS_MeshElementIDFactory.hxx"
37 #include "SMDS_MeshInfo.hxx"
38 #include "SMDS_ElemIterator.hxx"
39 #include <NCollection_Map.hxx>
40
41 #include <boost/shared_ptr.hpp>
42 #include <set>
43 #include <list>
44
45 class SMDS_EXPORT SMDS_Mesh:public SMDS_MeshObject{
46 public:
47   
48   SMDS_Mesh();
49   
50   SMDS_NodeIteratorPtr nodesIterator() const;
51   SMDS_EdgeIteratorPtr edgesIterator() const;
52   SMDS_FaceIteratorPtr facesIterator() const;
53   SMDS_VolumeIteratorPtr volumesIterator() const;
54   SMDS_ElemIteratorPtr elementsIterator() const;  
55   
56   SMDSAbs_ElementType GetElementType( const int id, const bool iselem ) const;
57
58   SMDS_Mesh *AddSubMesh();
59   
60   virtual SMDS_MeshNode* AddNodeWithID(double x, double y, double z, int ID);
61   virtual SMDS_MeshNode* AddNode(double x, double y, double z);
62   
63   virtual SMDS_MeshEdge* AddEdgeWithID(int n1, int n2, int ID);
64   virtual SMDS_MeshEdge* AddEdgeWithID(const SMDS_MeshNode * n1,
65                                        const SMDS_MeshNode * n2, 
66                                        int ID);
67   virtual SMDS_MeshEdge* AddEdge(const SMDS_MeshNode * n1,
68                                  const SMDS_MeshNode * n2);
69   
70   // 2d order edge with 3 nodes: n12 - node between n1 and n2
71   virtual SMDS_MeshEdge* AddEdgeWithID(int n1, int n2, int n12, int ID);
72   virtual SMDS_MeshEdge* AddEdgeWithID(const SMDS_MeshNode * n1,
73                                        const SMDS_MeshNode * n2, 
74                                        const SMDS_MeshNode * n12, 
75                                        int ID);
76   virtual SMDS_MeshEdge* AddEdge(const SMDS_MeshNode * n1,
77                                  const SMDS_MeshNode * n2,
78                                  const SMDS_MeshNode * n12);
79
80   virtual SMDS_MeshFace* AddFaceWithID(int n1, int n2, int n3, int ID);
81   virtual SMDS_MeshFace* AddFaceWithID(const SMDS_MeshNode * n1,
82                                        const SMDS_MeshNode * n2,
83                                        const SMDS_MeshNode * n3, 
84                                        int ID);
85   virtual SMDS_MeshFace* AddFace(const SMDS_MeshNode * n1,
86                                  const SMDS_MeshNode * n2,
87                                  const SMDS_MeshNode * n3);
88   
89   virtual SMDS_MeshFace* AddFaceWithID(int n1, int n2, int n3, int n4, int ID);
90   virtual SMDS_MeshFace* AddFaceWithID(const SMDS_MeshNode * n1,
91                                        const SMDS_MeshNode * n2,
92                                        const SMDS_MeshNode * n3,
93                                        const SMDS_MeshNode * n4, 
94                                        int ID);
95   virtual SMDS_MeshFace* AddFace(const SMDS_MeshNode * n1,
96                                  const SMDS_MeshNode * n2,
97                                  const SMDS_MeshNode * n3,
98                                  const SMDS_MeshNode * n4);
99   
100   virtual SMDS_MeshFace* AddFaceWithID(const SMDS_MeshEdge * e1,
101                                        const SMDS_MeshEdge * e2,
102                                        const SMDS_MeshEdge * e3, int ID);
103   virtual SMDS_MeshFace* AddFace(const SMDS_MeshEdge * e1,
104                                  const SMDS_MeshEdge * e2,
105                                  const SMDS_MeshEdge * e3);
106
107   virtual SMDS_MeshFace* AddFaceWithID(const SMDS_MeshEdge * e1,
108                                        const SMDS_MeshEdge * e2,
109                                        const SMDS_MeshEdge * e3,
110                                        const SMDS_MeshEdge * e4, int ID);
111   virtual SMDS_MeshFace* AddFace(const SMDS_MeshEdge * e1,
112                                  const SMDS_MeshEdge * e2,
113                                  const SMDS_MeshEdge * e3,
114                                  const SMDS_MeshEdge * e4);
115
116   // 2d order triangle of 6 nodes
117   virtual SMDS_MeshFace* AddFaceWithID(int n1, int n2, int n3,
118                                        int n12,int n23,int n31, int ID);
119   virtual SMDS_MeshFace* AddFaceWithID(const SMDS_MeshNode * n1,
120                                        const SMDS_MeshNode * n2,
121                                        const SMDS_MeshNode * n3, 
122                                        const SMDS_MeshNode * n12,
123                                        const SMDS_MeshNode * n23,
124                                        const SMDS_MeshNode * n31, 
125                                        int ID);
126   virtual SMDS_MeshFace* AddFace(const SMDS_MeshNode * n1,
127                                  const SMDS_MeshNode * n2,
128                                  const SMDS_MeshNode * n3,
129                                  const SMDS_MeshNode * n12,
130                                  const SMDS_MeshNode * n23,
131                                  const SMDS_MeshNode * n31);
132
133   // 2d order quadrangle
134   virtual SMDS_MeshFace* AddFaceWithID(int n1, int n2, int n3, int n4,
135                                        int n12,int n23,int n34,int n41, int ID);
136   virtual SMDS_MeshFace* AddFaceWithID(const SMDS_MeshNode * n1,
137                                        const SMDS_MeshNode * n2,
138                                        const SMDS_MeshNode * n3,
139                                        const SMDS_MeshNode * n4, 
140                                        const SMDS_MeshNode * n12,
141                                        const SMDS_MeshNode * n23,
142                                        const SMDS_MeshNode * n34,
143                                        const SMDS_MeshNode * n41, 
144                                        int ID);
145   virtual SMDS_MeshFace* AddFace(const SMDS_MeshNode * n1,
146                                  const SMDS_MeshNode * n2,
147                                  const SMDS_MeshNode * n3,
148                                  const SMDS_MeshNode * n4,
149                                  const SMDS_MeshNode * n12,
150                                  const SMDS_MeshNode * n23,
151                                  const SMDS_MeshNode * n34,
152                                  const SMDS_MeshNode * n41);
153
154   virtual SMDS_MeshVolume* AddVolumeWithID(int n1, int n2, int n3, int n4, int ID);
155   virtual SMDS_MeshVolume* AddVolumeWithID(const SMDS_MeshNode * n1,
156                                            const SMDS_MeshNode * n2,
157                                            const SMDS_MeshNode * n3,
158                                            const SMDS_MeshNode * n4, 
159                                            int ID);
160   virtual SMDS_MeshVolume* AddVolume(const SMDS_MeshNode * n1,
161                                      const SMDS_MeshNode * n2,
162                                      const SMDS_MeshNode * n3,
163                                      const SMDS_MeshNode * n4);
164   
165   virtual SMDS_MeshVolume* AddVolumeWithID(int n1, int n2, int n3, int n4,
166                                            int n5, int ID);
167   virtual SMDS_MeshVolume* AddVolumeWithID(const SMDS_MeshNode * n1,
168                                            const SMDS_MeshNode * n2,
169                                            const SMDS_MeshNode * n3,
170                                            const SMDS_MeshNode * n4,
171                                            const SMDS_MeshNode * n5, 
172                                            int ID);
173   virtual SMDS_MeshVolume* AddVolume(const SMDS_MeshNode * n1,
174                                      const SMDS_MeshNode * n2,
175                                      const SMDS_MeshNode * n3,
176                                      const SMDS_MeshNode * n4,
177                                      const SMDS_MeshNode * n5);
178   
179   virtual SMDS_MeshVolume* AddVolumeWithID(int n1, int n2, int n3, int n4,
180                                            int n5, int n6, int ID);
181   virtual SMDS_MeshVolume* AddVolumeWithID(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                                            const SMDS_MeshNode * n6, 
187                                            int ID);
188   virtual SMDS_MeshVolume* AddVolume(const SMDS_MeshNode * n1,
189                                      const SMDS_MeshNode * n2,
190                                      const SMDS_MeshNode * n3,
191                                      const SMDS_MeshNode * n4,
192                                      const SMDS_MeshNode * n5,
193                                      const SMDS_MeshNode * n6);
194   
195   virtual SMDS_MeshVolume* AddVolumeWithID(int n1, int n2, int n3, int n4,
196                                            int n5, int n6, int n7, int n8, int ID);
197   virtual SMDS_MeshVolume* AddVolumeWithID(const SMDS_MeshNode * n1,
198                                            const SMDS_MeshNode * n2,
199                                            const SMDS_MeshNode * n3,
200                                            const SMDS_MeshNode * n4,
201                                            const SMDS_MeshNode * n5,
202                                            const SMDS_MeshNode * n6,
203                                            const SMDS_MeshNode * n7,
204                                            const SMDS_MeshNode * n8, 
205                                            int ID);
206   virtual SMDS_MeshVolume* AddVolume(const SMDS_MeshNode * n1,
207                                      const SMDS_MeshNode * n2,
208                                      const SMDS_MeshNode * n3,
209                                      const SMDS_MeshNode * n4,
210                                      const SMDS_MeshNode * n5,
211                                      const SMDS_MeshNode * n6,
212                                      const SMDS_MeshNode * n7,
213                                      const SMDS_MeshNode * n8);
214
215   virtual SMDS_MeshVolume* AddVolumeWithID(const SMDS_MeshFace * f1,
216                                            const SMDS_MeshFace * f2,
217                                            const SMDS_MeshFace * f3,
218                                            const SMDS_MeshFace * f4, int ID);
219   virtual SMDS_MeshVolume* AddVolume(const SMDS_MeshFace * f1,
220                                      const SMDS_MeshFace * f2,
221                                      const SMDS_MeshFace * f3,
222                                      const SMDS_MeshFace * f4);
223
224   virtual SMDS_MeshVolume* AddVolumeWithID(const SMDS_MeshFace * f1,
225                                            const SMDS_MeshFace * f2,
226                                            const SMDS_MeshFace * f3,
227                                            const SMDS_MeshFace * f4,
228                                            const SMDS_MeshFace * f5, int ID);
229   virtual SMDS_MeshVolume* AddVolume(const SMDS_MeshFace * f1,
230                                      const SMDS_MeshFace * f2,
231                                      const SMDS_MeshFace * f3,
232                                      const SMDS_MeshFace * f4,
233                                      const SMDS_MeshFace * f5);
234
235   virtual SMDS_MeshVolume* AddVolumeWithID(const SMDS_MeshFace * f1,
236                                            const SMDS_MeshFace * f2,
237                                            const SMDS_MeshFace * f3,
238                                            const SMDS_MeshFace * f4,
239                                            const SMDS_MeshFace * f5,
240                                            const SMDS_MeshFace * f6, int ID);
241   virtual SMDS_MeshVolume* AddVolume(const SMDS_MeshFace * f1,
242                                      const SMDS_MeshFace * f2,
243                                      const SMDS_MeshFace * f3,
244                                      const SMDS_MeshFace * f4,
245                                      const SMDS_MeshFace * f5,
246                                      const SMDS_MeshFace * f6);
247
248   // 2d order tetrahedron of 10 nodes
249   virtual SMDS_MeshVolume* AddVolumeWithID(int n1, int n2, int n3, int n4,
250                                            int n12,int n23,int n31,
251                                            int n14,int n24,int n34, int ID);
252   virtual SMDS_MeshVolume* AddVolumeWithID(const SMDS_MeshNode * n1,
253                                            const SMDS_MeshNode * n2,
254                                            const SMDS_MeshNode * n3,
255                                            const SMDS_MeshNode * n4, 
256                                            const SMDS_MeshNode * n12,
257                                            const SMDS_MeshNode * n23,
258                                            const SMDS_MeshNode * n31,
259                                            const SMDS_MeshNode * n14, 
260                                            const SMDS_MeshNode * n24,
261                                            const SMDS_MeshNode * n34, 
262                                            int ID);
263   virtual SMDS_MeshVolume* AddVolume(const SMDS_MeshNode * n1,
264                                      const SMDS_MeshNode * n2,
265                                      const SMDS_MeshNode * n3,
266                                      const SMDS_MeshNode * n4,
267                                      const SMDS_MeshNode * n12,
268                                      const SMDS_MeshNode * n23,
269                                      const SMDS_MeshNode * n31,
270                                      const SMDS_MeshNode * n14, 
271                                      const SMDS_MeshNode * n24,
272                                      const SMDS_MeshNode * n34);
273
274   // 2d order pyramid of 13 nodes
275   virtual SMDS_MeshVolume* AddVolumeWithID(int n1, int n2, int n3, int n4, int n5,
276                                            int n12,int n23,int n34,int n41,
277                                            int n15,int n25,int n35,int n45,
278                                            int ID);
279   virtual SMDS_MeshVolume* AddVolumeWithID(const SMDS_MeshNode * n1,
280                                            const SMDS_MeshNode * n2,
281                                            const SMDS_MeshNode * n3,
282                                            const SMDS_MeshNode * n4,
283                                            const SMDS_MeshNode * n5, 
284                                            const SMDS_MeshNode * n12,
285                                            const SMDS_MeshNode * n23,
286                                            const SMDS_MeshNode * n34,
287                                            const SMDS_MeshNode * n41, 
288                                            const SMDS_MeshNode * n15,
289                                            const SMDS_MeshNode * n25,
290                                            const SMDS_MeshNode * n35,
291                                            const SMDS_MeshNode * n45, 
292                                            int ID);
293   virtual SMDS_MeshVolume* AddVolume(const SMDS_MeshNode * n1,
294                                      const SMDS_MeshNode * n2,
295                                      const SMDS_MeshNode * n3,
296                                      const SMDS_MeshNode * n4,
297                                      const SMDS_MeshNode * n5,
298                                      const SMDS_MeshNode * n12,
299                                      const SMDS_MeshNode * n23,
300                                      const SMDS_MeshNode * n34,
301                                      const SMDS_MeshNode * n41, 
302                                      const SMDS_MeshNode * n15,
303                                      const SMDS_MeshNode * n25,
304                                      const SMDS_MeshNode * n35,
305                                      const SMDS_MeshNode * n45);
306
307   // 2d order Pentahedron with 15 nodes
308   virtual SMDS_MeshVolume* AddVolumeWithID(int n1, int n2, int n3,
309                                            int n4, int n5, int n6,
310                                            int n12,int n23,int n31,
311                                            int n45,int n56,int n64,
312                                            int n14,int n25,int n36,
313                                            int ID);
314   virtual SMDS_MeshVolume* AddVolumeWithID(const SMDS_MeshNode * n1,
315                                            const SMDS_MeshNode * n2,
316                                            const SMDS_MeshNode * n3,
317                                            const SMDS_MeshNode * n4,
318                                            const SMDS_MeshNode * n5,
319                                            const SMDS_MeshNode * n6, 
320                                            const SMDS_MeshNode * n12,
321                                            const SMDS_MeshNode * n23,
322                                            const SMDS_MeshNode * n31, 
323                                            const SMDS_MeshNode * n45,
324                                            const SMDS_MeshNode * n56,
325                                            const SMDS_MeshNode * n64, 
326                                            const SMDS_MeshNode * n14,
327                                            const SMDS_MeshNode * n25,
328                                            const SMDS_MeshNode * n36, 
329                                            int ID);
330   virtual SMDS_MeshVolume* AddVolume(const SMDS_MeshNode * n1,
331                                      const SMDS_MeshNode * n2,
332                                      const SMDS_MeshNode * n3,
333                                      const SMDS_MeshNode * n4,
334                                      const SMDS_MeshNode * n5,
335                                      const SMDS_MeshNode * n6, 
336                                      const SMDS_MeshNode * n12,
337                                      const SMDS_MeshNode * n23,
338                                      const SMDS_MeshNode * n31, 
339                                      const SMDS_MeshNode * n45,
340                                      const SMDS_MeshNode * n56,
341                                      const SMDS_MeshNode * n64, 
342                                      const SMDS_MeshNode * n14,
343                                      const SMDS_MeshNode * n25,
344                                      const SMDS_MeshNode * n36);
345
346   // 2d oreder Hexahedrons with 20 nodes
347   virtual SMDS_MeshVolume* AddVolumeWithID(int n1, int n2, int n3, int n4,
348                                            int n5, int n6, int n7, int n8,
349                                            int n12,int n23,int n34,int n41,
350                                            int n56,int n67,int n78,int n85,
351                                            int n15,int n26,int n37,int n48,
352                                            int ID);
353   virtual SMDS_MeshVolume* AddVolumeWithID(const SMDS_MeshNode * n1,
354                                            const SMDS_MeshNode * n2,
355                                            const SMDS_MeshNode * n3,
356                                            const SMDS_MeshNode * n4,
357                                            const SMDS_MeshNode * n5,
358                                            const SMDS_MeshNode * n6,
359                                            const SMDS_MeshNode * n7,
360                                            const SMDS_MeshNode * n8, 
361                                            const SMDS_MeshNode * n12,
362                                            const SMDS_MeshNode * n23,
363                                            const SMDS_MeshNode * n34,
364                                            const SMDS_MeshNode * n41, 
365                                            const SMDS_MeshNode * n56,
366                                            const SMDS_MeshNode * n67,
367                                            const SMDS_MeshNode * n78,
368                                            const SMDS_MeshNode * n85, 
369                                            const SMDS_MeshNode * n15,
370                                            const SMDS_MeshNode * n26,
371                                            const SMDS_MeshNode * n37,
372                                            const SMDS_MeshNode * n48, 
373                                            int ID);
374   virtual SMDS_MeshVolume* AddVolume(const SMDS_MeshNode * n1,
375                                      const SMDS_MeshNode * n2,
376                                      const SMDS_MeshNode * n3,
377                                      const SMDS_MeshNode * n4,
378                                      const SMDS_MeshNode * n5,
379                                      const SMDS_MeshNode * n6,
380                                      const SMDS_MeshNode * n7,
381                                      const SMDS_MeshNode * n8, 
382                                      const SMDS_MeshNode * n12,
383                                      const SMDS_MeshNode * n23,
384                                      const SMDS_MeshNode * n34,
385                                      const SMDS_MeshNode * n41, 
386                                      const SMDS_MeshNode * n56,
387                                      const SMDS_MeshNode * n67,
388                                      const SMDS_MeshNode * n78,
389                                      const SMDS_MeshNode * n85, 
390                                      const SMDS_MeshNode * n15,
391                                      const SMDS_MeshNode * n26,
392                                      const SMDS_MeshNode * n37,
393                                      const SMDS_MeshNode * n48);
394
395   virtual SMDS_MeshFace* AddPolygonalFaceWithID (std::vector<int> nodes_ids,
396                                                  const int        ID);
397
398   virtual SMDS_MeshFace* AddPolygonalFaceWithID (std::vector<const SMDS_MeshNode*> nodes,
399                                                  const int                         ID);
400
401   virtual SMDS_MeshFace* AddPolygonalFace (std::vector<const SMDS_MeshNode*> nodes);
402
403   virtual SMDS_MeshVolume* AddPolyhedralVolumeWithID
404                            (std::vector<int> nodes_ids,
405                             std::vector<int> quantities,
406                             const int        ID);
407
408   virtual SMDS_MeshVolume* AddPolyhedralVolumeWithID
409                            (std::vector<const SMDS_MeshNode*> nodes,
410                             std::vector<int>                  quantities,
411                             const int                         ID);
412
413   virtual SMDS_MeshVolume* AddPolyhedralVolume
414                            (std::vector<const SMDS_MeshNode*> nodes,
415                             std::vector<int>                  quantities);
416
417   virtual void RemoveElement(const SMDS_MeshElement *        elem,
418                              std::list<const SMDS_MeshElement *>& removedElems,
419                              std::list<const SMDS_MeshElement *>& removedNodes,
420                              const bool                      removenodes = false);
421   virtual void RemoveElement(const SMDS_MeshElement * elem, bool removenodes = false);
422   virtual void RemoveNode(const SMDS_MeshNode * node);
423   virtual void RemoveEdge(const SMDS_MeshEdge * edge);
424   virtual void RemoveFace(const SMDS_MeshFace * face);
425   virtual void RemoveVolume(const SMDS_MeshVolume * volume);
426
427   /*! Remove only the given element and only if it is free.
428    *  Method does not work for meshes with descendants.
429    *  Implemented for fast cleaning of meshes.
430    */
431   virtual void RemoveFreeElement(const SMDS_MeshElement * elem);
432   
433   virtual bool RemoveFromParent();
434   virtual bool RemoveSubMesh(const SMDS_Mesh * aMesh);
435
436   bool ChangeElementNodes(const SMDS_MeshElement * elem,
437                           const SMDS_MeshNode    * nodes[],
438                           const int                nbnodes);
439   bool ChangePolyhedronNodes(const SMDS_MeshElement *                 elem,
440                              const std::vector<const SMDS_MeshNode*>& nodes,
441                              const std::vector<int> &                 quantities);
442
443   virtual void Renumber (const bool isNodes, const int startID = 1, const int deltaID = 1);
444   // Renumber all nodes or elements.
445
446   const SMDS_MeshNode *FindNode(int idnode) const;
447   const SMDS_MeshEdge *FindEdge(int idnode1, int idnode2) const;
448   const SMDS_MeshEdge *FindEdge(int idnode1, int idnode2, int idnode3) const;
449   const SMDS_MeshFace *FindFace(int idnode1, int idnode2, int idnode3) const;
450   const SMDS_MeshFace *FindFace(int idnode1, int idnode2, int idnode3, int idnode4) const;
451   const SMDS_MeshFace *FindFace(int idnode1, int idnode2, int idnode3,
452                                 int idnode4, int idnode5, int idnode6) const;
453   const SMDS_MeshFace *FindFace(int idnode1, int idnode2, int idnode3, int idnode4,
454                                 int idnode5, int idnode6, int idnode7, int idnode8) const;
455   const SMDS_MeshElement *FindElement(int IDelem) const;
456   static const SMDS_MeshEdge* FindEdge(const SMDS_MeshNode * n1,
457                                        const SMDS_MeshNode * n2);
458   static const SMDS_MeshEdge* FindEdge(const SMDS_MeshNode * n1,
459                                        const SMDS_MeshNode * n2,
460                                        const SMDS_MeshNode * n3);
461   static const SMDS_MeshFace* FindFace(const SMDS_MeshNode *n1,
462                                        const SMDS_MeshNode *n2,
463                                        const SMDS_MeshNode *n3);
464   static const SMDS_MeshFace* FindFace(const SMDS_MeshNode *n1,
465                                        const SMDS_MeshNode *n2,
466                                        const SMDS_MeshNode *n3,
467                                        const SMDS_MeshNode *n4);
468   static const SMDS_MeshFace* FindFace(const SMDS_MeshNode *n1,
469                                        const SMDS_MeshNode *n2,
470                                        const SMDS_MeshNode *n3,
471                                        const SMDS_MeshNode *n4,
472                                        const SMDS_MeshNode *n5,
473                                        const SMDS_MeshNode *n6);
474   static const SMDS_MeshFace* FindFace(const SMDS_MeshNode *n1,
475                                        const SMDS_MeshNode *n2,
476                                        const SMDS_MeshNode *n3,
477                                        const SMDS_MeshNode *n4,
478                                        const SMDS_MeshNode *n5,
479                                        const SMDS_MeshNode *n6,
480                                        const SMDS_MeshNode *n7,
481                                        const SMDS_MeshNode *n8);
482
483   const SMDS_MeshFace *FindFace(std::vector<int> nodes_ids) const;
484   static const SMDS_MeshFace* FindFace(std::vector<const SMDS_MeshNode *> nodes);
485
486   /*!
487    * \brief Raise an exception if free memory (ram+swap) too low
488     * \param doNotRaise - if true, suppres exception, just return free memory size
489     * \retval int - amount of available memory in MB or negative number in failure case
490    */
491   static int CheckMemory(const bool doNotRaise=false) throw (std::bad_alloc);
492
493   int MaxNodeID() const;
494   int MinNodeID() const;
495   int MaxElementID() const;
496   int MinElementID() const;
497
498   const SMDS_MeshInfo& GetMeshInfo() const { return myInfo; }
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   SMDS_MeshInfo          myInfo;
570
571   bool myHasConstructionEdges;
572   bool myHasConstructionFaces;
573   bool myHasInverseElements;
574 };
575
576
577 #endif