Version: 8.3.0
SMDS_Mesh.hxx
Go to the documentation of this file.
1 // Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007 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, or (at your option) any later version.
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 // SMESH SMDS : implementaion of Salome mesh data structure
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_MeshCell.hxx"
34 #include "SMDS_Mesh0DElement.hxx"
35 #include "SMDS_MeshEdge.hxx"
36 #include "SMDS_MeshFace.hxx"
37 #include "SMDS_MeshVolume.hxx"
40 #include "SMDS_MeshInfo.hxx"
41 #include "SMDS_ElemIterator.hxx"
42 #include "SMDS_VolumeOfNodes.hxx"
43 #include "SMDS_VtkEdge.hxx"
44 #include "SMDS_VtkFace.hxx"
45 #include "SMDS_VtkVolume.hxx"
46 #include "ObjectPool.hxx"
48 #include "SMDS_BallElement.hxx"
49 
50 #include <boost/shared_ptr.hpp>
51 #include <set>
52 #include <list>
53 #include <vector>
54 #include <vtkSystemIncludes.h>
55 #include <cassert>
56 
57 #include "Utils_SALOME_Exception.hxx"
58 
59 #define MYASSERT(val) if (!(val)) throw SALOME_Exception(LOCALIZED("assertion not verified"));
60 
62 {
63 public:
64  friend class SMDS_MeshIDFactory;
65  friend class SMDS_MeshNodeIDFactory;
67  friend class SMDS_MeshVolumeVtkNodes;
68  friend class SMDS_MeshNode;
69 
70  SMDS_Mesh();
71 
73  static std::vector<SMDS_Mesh*> _meshList;
74 
76  inline SMDS_UnstructuredGrid* getGrid() { return myGrid; }
77  inline int getMeshId() { return myMeshId; }
78 
79  virtual SMDS_NodeIteratorPtr nodesIterator (bool idInceasingOrder=false) const;
80  virtual SMDS_EdgeIteratorPtr edgesIterator (bool idInceasingOrder=false) const;
81  virtual SMDS_FaceIteratorPtr facesIterator (bool idInceasingOrder=false) const;
82  virtual SMDS_VolumeIteratorPtr volumesIterator (bool idInceasingOrder=false) const;
83 
85  virtual SMDS_ElemIteratorPtr elementGeomIterator(SMDSAbs_GeometryType type) const;
86  virtual SMDS_ElemIteratorPtr elementEntityIterator(SMDSAbs_EntityType type) const;
87 
88  SMDSAbs_ElementType GetElementType( const int id, const bool iselem ) const;
89 
90  SMDS_Mesh *AddSubMesh();
91 
92  virtual SMDS_MeshNode* AddNodeWithID(double x, double y, double z, int ID);
93  virtual SMDS_MeshNode* AddNode (double x, double y, double z);
94 
95  virtual SMDS_Mesh0DElement* Add0DElementWithID(int n, int ID);
96  virtual SMDS_Mesh0DElement* Add0DElementWithID(const SMDS_MeshNode * n, int ID);
97  virtual SMDS_Mesh0DElement* Add0DElement (const SMDS_MeshNode * n);
98 
99  virtual SMDS_BallElement* AddBallWithID(int n, double diameter, int ID);
100  virtual SMDS_BallElement* AddBallWithID(const SMDS_MeshNode * n, double diameter, int ID);
101  virtual SMDS_BallElement* AddBall (const SMDS_MeshNode * n, double diameter);
102 
103  virtual SMDS_MeshEdge* AddEdgeWithID(int n1, int n2, int ID);
104  virtual SMDS_MeshEdge* AddEdgeWithID(const SMDS_MeshNode * n1,
105  const SMDS_MeshNode * n2,
106  int ID);
107  virtual SMDS_MeshEdge* AddEdge(const SMDS_MeshNode * n1,
108  const SMDS_MeshNode * n2);
109 
110  // 2d order edge with 3 nodes: n12 - node between n1 and n2
111  virtual SMDS_MeshEdge* AddEdgeWithID(int n1, int n2, int n12, int ID);
112  virtual SMDS_MeshEdge* AddEdgeWithID(const SMDS_MeshNode * n1,
113  const SMDS_MeshNode * n2,
114  const SMDS_MeshNode * n12,
115  int ID);
116  virtual SMDS_MeshEdge* AddEdge(const SMDS_MeshNode * n1,
117  const SMDS_MeshNode * n2,
118  const SMDS_MeshNode * n12);
119 
120  virtual SMDS_MeshFace* AddFaceWithID(int n1, int n2, int n3, int ID);
121  virtual SMDS_MeshFace* AddFaceWithID(const SMDS_MeshNode * n1,
122  const SMDS_MeshNode * n2,
123  const SMDS_MeshNode * n3,
124  int ID);
125  virtual SMDS_MeshFace* AddFace(const SMDS_MeshNode * n1,
126  const SMDS_MeshNode * n2,
127  const SMDS_MeshNode * n3);
128 
129  virtual SMDS_MeshFace* AddFaceWithID(int n1, int n2, int n3, int n4, int ID);
130  virtual SMDS_MeshFace* AddFaceWithID(const SMDS_MeshNode * n1,
131  const SMDS_MeshNode * n2,
132  const SMDS_MeshNode * n3,
133  const SMDS_MeshNode * n4,
134  int ID);
135  virtual SMDS_MeshFace* AddFace(const SMDS_MeshNode * n1,
136  const SMDS_MeshNode * n2,
137  const SMDS_MeshNode * n3,
138  const SMDS_MeshNode * n4);
139 
140  virtual SMDS_MeshFace* AddFaceWithID(const SMDS_MeshEdge * e1,
141  const SMDS_MeshEdge * e2,
142  const SMDS_MeshEdge * e3, int ID);
143  virtual SMDS_MeshFace* AddFace(const SMDS_MeshEdge * e1,
144  const SMDS_MeshEdge * e2,
145  const SMDS_MeshEdge * e3);
146 
147  virtual SMDS_MeshFace* AddFaceWithID(const SMDS_MeshEdge * e1,
148  const SMDS_MeshEdge * e2,
149  const SMDS_MeshEdge * e3,
150  const SMDS_MeshEdge * e4, int ID);
151  virtual SMDS_MeshFace* AddFace(const SMDS_MeshEdge * e1,
152  const SMDS_MeshEdge * e2,
153  const SMDS_MeshEdge * e3,
154  const SMDS_MeshEdge * e4);
155 
156  // 2d order triangle of 6 nodes
157  virtual SMDS_MeshFace* AddFaceWithID(int n1, int n2, int n3,
158  int n12,int n23,int n31, int ID);
159  virtual SMDS_MeshFace* AddFaceWithID(const SMDS_MeshNode * n1,
160  const SMDS_MeshNode * n2,
161  const SMDS_MeshNode * n3,
162  const SMDS_MeshNode * n12,
163  const SMDS_MeshNode * n23,
164  const SMDS_MeshNode * n31,
165  int ID);
166  virtual SMDS_MeshFace* AddFace(const SMDS_MeshNode * n1,
167  const SMDS_MeshNode * n2,
168  const SMDS_MeshNode * n3,
169  const SMDS_MeshNode * n12,
170  const SMDS_MeshNode * n23,
171  const SMDS_MeshNode * n31);
172 
173  // 2d order triangle of 7 nodes
174  virtual SMDS_MeshFace* AddFaceWithID(int n1, int n2, int n3,
175  int n12,int n23,int n31, int nCenter, int ID);
176  virtual SMDS_MeshFace* AddFaceWithID(const SMDS_MeshNode * n1,
177  const SMDS_MeshNode * n2,
178  const SMDS_MeshNode * n3,
179  const SMDS_MeshNode * n12,
180  const SMDS_MeshNode * n23,
181  const SMDS_MeshNode * n31,
182  const SMDS_MeshNode * nCenter,
183  int ID);
184  virtual SMDS_MeshFace* AddFace(const SMDS_MeshNode * n1,
185  const SMDS_MeshNode * n2,
186  const SMDS_MeshNode * n3,
187  const SMDS_MeshNode * n12,
188  const SMDS_MeshNode * n23,
189  const SMDS_MeshNode * n31,
190  const SMDS_MeshNode * nCenter);
191 
192  // 2d order quadrangle
193  virtual SMDS_MeshFace* AddFaceWithID(int n1, int n2, int n3, int n4,
194  int n12,int n23,int n34,int n41, int ID);
195  virtual SMDS_MeshFace* AddFaceWithID(const SMDS_MeshNode * n1,
196  const SMDS_MeshNode * n2,
197  const SMDS_MeshNode * n3,
198  const SMDS_MeshNode * n4,
199  const SMDS_MeshNode * n12,
200  const SMDS_MeshNode * n23,
201  const SMDS_MeshNode * n34,
202  const SMDS_MeshNode * n41,
203  int ID);
204  virtual SMDS_MeshFace* AddFace(const SMDS_MeshNode * n1,
205  const SMDS_MeshNode * n2,
206  const SMDS_MeshNode * n3,
207  const SMDS_MeshNode * n4,
208  const SMDS_MeshNode * n12,
209  const SMDS_MeshNode * n23,
210  const SMDS_MeshNode * n34,
211  const SMDS_MeshNode * n41);
212 
213  virtual SMDS_MeshFace* AddFaceWithID(int n1, int n2, int n3, int n4,
214  int n12,int n23,int n34,int n41, int nCenter, int ID);
215  virtual SMDS_MeshFace* AddFaceWithID(const SMDS_MeshNode * n1,
216  const SMDS_MeshNode * n2,
217  const SMDS_MeshNode * n3,
218  const SMDS_MeshNode * n4,
219  const SMDS_MeshNode * n12,
220  const SMDS_MeshNode * n23,
221  const SMDS_MeshNode * n34,
222  const SMDS_MeshNode * n41,
223  const SMDS_MeshNode * nCenter,
224  int ID);
225  virtual SMDS_MeshFace* AddFace(const SMDS_MeshNode * n1,
226  const SMDS_MeshNode * n2,
227  const SMDS_MeshNode * n3,
228  const SMDS_MeshNode * n4,
229  const SMDS_MeshNode * n12,
230  const SMDS_MeshNode * n23,
231  const SMDS_MeshNode * n34,
232  const SMDS_MeshNode * n41,
233  const SMDS_MeshNode * nCenter);
234 
235  virtual SMDS_MeshVolume* AddVolumeWithID(int n1, int n2, int n3, int n4, int ID);
236  virtual SMDS_MeshVolume* AddVolumeWithID(const SMDS_MeshNode * n1,
237  const SMDS_MeshNode * n2,
238  const SMDS_MeshNode * n3,
239  const SMDS_MeshNode * n4,
240  int ID);
241  virtual SMDS_MeshVolume* AddVolume(const SMDS_MeshNode * n1,
242  const SMDS_MeshNode * n2,
243  const SMDS_MeshNode * n3,
244  const SMDS_MeshNode * n4);
245 
246  virtual SMDS_MeshVolume* AddVolumeWithID(int n1, int n2, int n3, int n4,
247  int n5, int ID);
248  virtual SMDS_MeshVolume* AddVolumeWithID(const SMDS_MeshNode * n1,
249  const SMDS_MeshNode * n2,
250  const SMDS_MeshNode * n3,
251  const SMDS_MeshNode * n4,
252  const SMDS_MeshNode * n5,
253  int ID);
254  virtual SMDS_MeshVolume* AddVolume(const SMDS_MeshNode * n1,
255  const SMDS_MeshNode * n2,
256  const SMDS_MeshNode * n3,
257  const SMDS_MeshNode * n4,
258  const SMDS_MeshNode * n5);
259 
260  virtual SMDS_MeshVolume* AddVolumeWithID(int n1, int n2, int n3, int n4,
261  int n5, int n6, int ID);
262  virtual SMDS_MeshVolume* AddVolumeWithID(const SMDS_MeshNode * n1,
263  const SMDS_MeshNode * n2,
264  const SMDS_MeshNode * n3,
265  const SMDS_MeshNode * n4,
266  const SMDS_MeshNode * n5,
267  const SMDS_MeshNode * n6,
268  int ID);
269  virtual SMDS_MeshVolume* AddVolume(const SMDS_MeshNode * n1,
270  const SMDS_MeshNode * n2,
271  const SMDS_MeshNode * n3,
272  const SMDS_MeshNode * n4,
273  const SMDS_MeshNode * n5,
274  const SMDS_MeshNode * n6);
275 
276  virtual SMDS_MeshVolume* AddVolumeWithID(int n1, int n2, int n3, int n4,
277  int n5, int n6, int n7, int n8, int ID);
278  virtual SMDS_MeshVolume* AddVolumeWithID(const SMDS_MeshNode * n1,
279  const SMDS_MeshNode * n2,
280  const SMDS_MeshNode * n3,
281  const SMDS_MeshNode * n4,
282  const SMDS_MeshNode * n5,
283  const SMDS_MeshNode * n6,
284  const SMDS_MeshNode * n7,
285  const SMDS_MeshNode * n8,
286  int ID);
287  virtual SMDS_MeshVolume* AddVolume(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 * n6,
293  const SMDS_MeshNode * n7,
294  const SMDS_MeshNode * n8);
295 
296  virtual SMDS_MeshVolume* AddVolumeWithID(const SMDS_MeshFace * f1,
297  const SMDS_MeshFace * f2,
298  const SMDS_MeshFace * f3,
299  const SMDS_MeshFace * f4, int ID);
300  virtual SMDS_MeshVolume* AddVolume(const SMDS_MeshFace * f1,
301  const SMDS_MeshFace * f2,
302  const SMDS_MeshFace * f3,
303  const SMDS_MeshFace * f4);
304 
305  virtual SMDS_MeshVolume* AddVolumeWithID(const SMDS_MeshFace * f1,
306  const SMDS_MeshFace * f2,
307  const SMDS_MeshFace * f3,
308  const SMDS_MeshFace * f4,
309  const SMDS_MeshFace * f5, int ID);
310  virtual SMDS_MeshVolume* AddVolume(const SMDS_MeshFace * f1,
311  const SMDS_MeshFace * f2,
312  const SMDS_MeshFace * f3,
313  const SMDS_MeshFace * f4,
314  const SMDS_MeshFace * f5);
315 
316  virtual SMDS_MeshVolume* AddVolumeWithID(const SMDS_MeshFace * f1,
317  const SMDS_MeshFace * f2,
318  const SMDS_MeshFace * f3,
319  const SMDS_MeshFace * f4,
320  const SMDS_MeshFace * f5,
321  const SMDS_MeshFace * f6, int ID);
322  virtual SMDS_MeshVolume* AddVolume(const SMDS_MeshFace * f1,
323  const SMDS_MeshFace * f2,
324  const SMDS_MeshFace * f3,
325  const SMDS_MeshFace * f4,
326  const SMDS_MeshFace * f5,
327  const SMDS_MeshFace * f6);
328 
329  // hexagonal prism
330  virtual SMDS_MeshVolume* AddVolumeWithID(int n1, int n2, int n3, int n4, int n5, int n6,
331  int n7, int n8, int n9, int n10, int n11, int n12,
332  int ID);
333  virtual SMDS_MeshVolume* AddVolumeWithID(const SMDS_MeshNode * n1,
334  const SMDS_MeshNode * n2,
335  const SMDS_MeshNode * n3,
336  const SMDS_MeshNode * n4,
337  const SMDS_MeshNode * n5,
338  const SMDS_MeshNode * n6,
339  const SMDS_MeshNode * n7,
340  const SMDS_MeshNode * n8,
341  const SMDS_MeshNode * n9,
342  const SMDS_MeshNode * n10,
343  const SMDS_MeshNode * n11,
344  const SMDS_MeshNode * n12,
345  int ID);
346  virtual SMDS_MeshVolume* AddVolume(const SMDS_MeshNode * n1,
347  const SMDS_MeshNode * n2,
348  const SMDS_MeshNode * n3,
349  const SMDS_MeshNode * n4,
350  const SMDS_MeshNode * n5,
351  const SMDS_MeshNode * n6,
352  const SMDS_MeshNode * n7,
353  const SMDS_MeshNode * n8,
354  const SMDS_MeshNode * n9,
355  const SMDS_MeshNode * n10,
356  const SMDS_MeshNode * n11,
357  const SMDS_MeshNode * n12);
358 
359  // 2d order tetrahedron of 10 nodes
360  virtual SMDS_MeshVolume* AddVolumeWithID(int n1, int n2, int n3, int n4,
361  int n12,int n23,int n31,
362  int n14,int n24,int n34, int ID);
363  virtual SMDS_MeshVolume* AddVolumeWithID(const SMDS_MeshNode * n1,
364  const SMDS_MeshNode * n2,
365  const SMDS_MeshNode * n3,
366  const SMDS_MeshNode * n4,
367  const SMDS_MeshNode * n12,
368  const SMDS_MeshNode * n23,
369  const SMDS_MeshNode * n31,
370  const SMDS_MeshNode * n14,
371  const SMDS_MeshNode * n24,
372  const SMDS_MeshNode * n34,
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 * n12,
379  const SMDS_MeshNode * n23,
380  const SMDS_MeshNode * n31,
381  const SMDS_MeshNode * n14,
382  const SMDS_MeshNode * n24,
383  const SMDS_MeshNode * n34);
384 
385  // 2d order pyramid of 13 nodes
386  virtual SMDS_MeshVolume* AddVolumeWithID(int n1, int n2, int n3, int n4, int n5,
387  int n12,int n23,int n34,int n41,
388  int n15,int n25,int n35,int n45,
389  int ID);
390  virtual SMDS_MeshVolume* AddVolumeWithID(const SMDS_MeshNode * n1,
391  const SMDS_MeshNode * n2,
392  const SMDS_MeshNode * n3,
393  const SMDS_MeshNode * n4,
394  const SMDS_MeshNode * n5,
395  const SMDS_MeshNode * n12,
396  const SMDS_MeshNode * n23,
397  const SMDS_MeshNode * n34,
398  const SMDS_MeshNode * n41,
399  const SMDS_MeshNode * n15,
400  const SMDS_MeshNode * n25,
401  const SMDS_MeshNode * n35,
402  const SMDS_MeshNode * n45,
403  int ID);
404  virtual SMDS_MeshVolume* AddVolume(const SMDS_MeshNode * n1,
405  const SMDS_MeshNode * n2,
406  const SMDS_MeshNode * n3,
407  const SMDS_MeshNode * n4,
408  const SMDS_MeshNode * n5,
409  const SMDS_MeshNode * n12,
410  const SMDS_MeshNode * n23,
411  const SMDS_MeshNode * n34,
412  const SMDS_MeshNode * n41,
413  const SMDS_MeshNode * n15,
414  const SMDS_MeshNode * n25,
415  const SMDS_MeshNode * n35,
416  const SMDS_MeshNode * n45);
417 
418  // 2d order Pentahedron with 15 nodes
419  virtual SMDS_MeshVolume* AddVolumeWithID(int n1, int n2, int n3,
420  int n4, int n5, int n6,
421  int n12,int n23,int n31,
422  int n45,int n56,int n64,
423  int n14,int n25,int n36,
424  int ID);
425  virtual SMDS_MeshVolume* AddVolumeWithID(const SMDS_MeshNode * n1,
426  const SMDS_MeshNode * n2,
427  const SMDS_MeshNode * n3,
428  const SMDS_MeshNode * n4,
429  const SMDS_MeshNode * n5,
430  const SMDS_MeshNode * n6,
431  const SMDS_MeshNode * n12,
432  const SMDS_MeshNode * n23,
433  const SMDS_MeshNode * n31,
434  const SMDS_MeshNode * n45,
435  const SMDS_MeshNode * n56,
436  const SMDS_MeshNode * n64,
437  const SMDS_MeshNode * n14,
438  const SMDS_MeshNode * n25,
439  const SMDS_MeshNode * n36,
440  int ID);
441  virtual SMDS_MeshVolume* AddVolume(const SMDS_MeshNode * n1,
442  const SMDS_MeshNode * n2,
443  const SMDS_MeshNode * n3,
444  const SMDS_MeshNode * n4,
445  const SMDS_MeshNode * n5,
446  const SMDS_MeshNode * n6,
447  const SMDS_MeshNode * n12,
448  const SMDS_MeshNode * n23,
449  const SMDS_MeshNode * n31,
450  const SMDS_MeshNode * n45,
451  const SMDS_MeshNode * n56,
452  const SMDS_MeshNode * n64,
453  const SMDS_MeshNode * n14,
454  const SMDS_MeshNode * n25,
455  const SMDS_MeshNode * n36);
456 
457  // 2d oreder Hexahedrons with 20 nodes
458  virtual SMDS_MeshVolume* AddVolumeWithID(int n1, int n2, int n3, int n4,
459  int n5, int n6, int n7, int n8,
460  int n12,int n23,int n34,int n41,
461  int n56,int n67,int n78,int n85,
462  int n15,int n26,int n37,int n48,
463  int ID);
464  virtual SMDS_MeshVolume* AddVolumeWithID(const SMDS_MeshNode * n1,
465  const SMDS_MeshNode * n2,
466  const SMDS_MeshNode * n3,
467  const SMDS_MeshNode * n4,
468  const SMDS_MeshNode * n5,
469  const SMDS_MeshNode * n6,
470  const SMDS_MeshNode * n7,
471  const SMDS_MeshNode * n8,
472  const SMDS_MeshNode * n12,
473  const SMDS_MeshNode * n23,
474  const SMDS_MeshNode * n34,
475  const SMDS_MeshNode * n41,
476  const SMDS_MeshNode * n56,
477  const SMDS_MeshNode * n67,
478  const SMDS_MeshNode * n78,
479  const SMDS_MeshNode * n85,
480  const SMDS_MeshNode * n15,
481  const SMDS_MeshNode * n26,
482  const SMDS_MeshNode * n37,
483  const SMDS_MeshNode * n48,
484  int ID);
485  virtual SMDS_MeshVolume* AddVolume(const SMDS_MeshNode * n1,
486  const SMDS_MeshNode * n2,
487  const SMDS_MeshNode * n3,
488  const SMDS_MeshNode * n4,
489  const SMDS_MeshNode * n5,
490  const SMDS_MeshNode * n6,
491  const SMDS_MeshNode * n7,
492  const SMDS_MeshNode * n8,
493  const SMDS_MeshNode * n12,
494  const SMDS_MeshNode * n23,
495  const SMDS_MeshNode * n34,
496  const SMDS_MeshNode * n41,
497  const SMDS_MeshNode * n56,
498  const SMDS_MeshNode * n67,
499  const SMDS_MeshNode * n78,
500  const SMDS_MeshNode * n85,
501  const SMDS_MeshNode * n15,
502  const SMDS_MeshNode * n26,
503  const SMDS_MeshNode * n37,
504  const SMDS_MeshNode * n48);
505 
506  // 2d oreder Hexahedrons with 27 nodes
507  virtual SMDS_MeshVolume* AddVolumeWithID(int n1, int n2, int n3, int n4,
508  int n5, int n6, int n7, int n8,
509  int n12,int n23,int n34,int n41,
510  int n56,int n67,int n78,int n85,
511  int n15,int n26,int n37,int n48,
512  int n1234,int n1256,int n2367,int n3478,
513  int n1458,int n5678,int nCenter,
514  int ID);
515  virtual SMDS_MeshVolume* AddVolumeWithID(const SMDS_MeshNode * n1,
516  const SMDS_MeshNode * n2,
517  const SMDS_MeshNode * n3,
518  const SMDS_MeshNode * n4,
519  const SMDS_MeshNode * n5,
520  const SMDS_MeshNode * n6,
521  const SMDS_MeshNode * n7,
522  const SMDS_MeshNode * n8,
523  const SMDS_MeshNode * n12,
524  const SMDS_MeshNode * n23,
525  const SMDS_MeshNode * n34,
526  const SMDS_MeshNode * n41,
527  const SMDS_MeshNode * n56,
528  const SMDS_MeshNode * n67,
529  const SMDS_MeshNode * n78,
530  const SMDS_MeshNode * n85,
531  const SMDS_MeshNode * n15,
532  const SMDS_MeshNode * n26,
533  const SMDS_MeshNode * n37,
534  const SMDS_MeshNode * n48,
535  const SMDS_MeshNode * n1234,
536  const SMDS_MeshNode * n1256,
537  const SMDS_MeshNode * n2367,
538  const SMDS_MeshNode * n3478,
539  const SMDS_MeshNode * n1458,
540  const SMDS_MeshNode * n5678,
541  const SMDS_MeshNode * nCenter,
542  int ID);
543  virtual SMDS_MeshVolume* AddVolume(const SMDS_MeshNode * n1,
544  const SMDS_MeshNode * n2,
545  const SMDS_MeshNode * n3,
546  const SMDS_MeshNode * n4,
547  const SMDS_MeshNode * n5,
548  const SMDS_MeshNode * n6,
549  const SMDS_MeshNode * n7,
550  const SMDS_MeshNode * n8,
551  const SMDS_MeshNode * n12,
552  const SMDS_MeshNode * n23,
553  const SMDS_MeshNode * n34,
554  const SMDS_MeshNode * n41,
555  const SMDS_MeshNode * n56,
556  const SMDS_MeshNode * n67,
557  const SMDS_MeshNode * n78,
558  const SMDS_MeshNode * n85,
559  const SMDS_MeshNode * n15,
560  const SMDS_MeshNode * n26,
561  const SMDS_MeshNode * n37,
562  const SMDS_MeshNode * n48,
563  const SMDS_MeshNode * n1234,
564  const SMDS_MeshNode * n1256,
565  const SMDS_MeshNode * n2367,
566  const SMDS_MeshNode * n3478,
567  const SMDS_MeshNode * n1458,
568  const SMDS_MeshNode * n5678,
569  const SMDS_MeshNode * nCenter);
570 
571  virtual SMDS_MeshFace* AddPolygonalFaceWithID (const std::vector<int> & nodes_ids,
572  const int ID);
573 
574  virtual SMDS_MeshFace* AddPolygonalFaceWithID (const std::vector<const SMDS_MeshNode*> & nodes,
575  const int ID);
576 
577  virtual SMDS_MeshFace* AddPolygonalFace (const std::vector<const SMDS_MeshNode*> & nodes);
578 
579  virtual SMDS_MeshFace* AddQuadPolygonalFaceWithID(const std::vector<int> & nodes_ids,
580  const int ID);
581 
582  virtual SMDS_MeshFace* AddQuadPolygonalFaceWithID(const std::vector<const SMDS_MeshNode*> & nodes,
583  const int ID);
584 
585  virtual SMDS_MeshFace* AddQuadPolygonalFace(const std::vector<const SMDS_MeshNode*> & nodes);
586 
587  virtual SMDS_MeshVolume* AddPolyhedralVolumeWithID
588  (const std::vector<int> & nodes_ids,
589  const std::vector<int> & quantities,
590  const int ID);
591 
592  virtual SMDS_MeshVolume* AddPolyhedralVolumeWithID
593  (const std::vector<const SMDS_MeshNode*> & nodes,
594  const std::vector<int> & quantities,
595  const int ID);
596 
597  virtual SMDS_MeshVolume* AddPolyhedralVolume
598  (const std::vector<const SMDS_MeshNode*> & nodes,
599  const std::vector<int> & quantities);
600 
601  virtual SMDS_MeshVolume* AddVolumeFromVtkIds(const std::vector<vtkIdType>& vtkNodeIds);
602 
603  virtual SMDS_MeshVolume* AddVolumeFromVtkIdsWithID(const std::vector<vtkIdType>& vtkNodeIds,
604  const int ID);
605 
606  virtual SMDS_MeshFace* AddFaceFromVtkIds(const std::vector<vtkIdType>& vtkNodeIds);
607 
608  virtual SMDS_MeshFace* AddFaceFromVtkIdsWithID(const std::vector<vtkIdType>& vtkNodeIds,
609  const int ID);
610  virtual void MoveNode(const SMDS_MeshNode *n, double x, double y, double z);
611 
612  virtual void RemoveElement(const SMDS_MeshElement * elem,
613  std::list<const SMDS_MeshElement *>& removedElems,
614  std::list<const SMDS_MeshElement *>& removedNodes,
615  const bool removenodes = false);
616  virtual void RemoveElement(const SMDS_MeshElement * elem, bool removenodes = false);
617  virtual void RemoveNode(const SMDS_MeshNode * node);
618  virtual void Remove0DElement(const SMDS_Mesh0DElement * elem0d);
619  virtual void RemoveEdge(const SMDS_MeshEdge * edge);
620  virtual void RemoveFace(const SMDS_MeshFace * face);
621  virtual void RemoveVolume(const SMDS_MeshVolume * volume);
622 
627  virtual void RemoveFreeElement(const SMDS_MeshElement * elem);
628 
629  virtual void Clear();
630 
631  virtual bool RemoveFromParent();
632  virtual bool RemoveSubMesh(const SMDS_Mesh * aMesh);
633 
634  bool ChangeElementNodes(const SMDS_MeshElement * elem,
635  const SMDS_MeshNode * nodes[],
636  const int nbnodes);
637  bool ChangePolyhedronNodes(const SMDS_MeshElement * elem,
638  const std::vector<const SMDS_MeshNode*>& nodes,
639  const std::vector<int> & quantities);
640 
641  virtual void Renumber (const bool isNodes, const int startID = 1, const int deltaID = 1);
642  // Renumber all nodes or elements.
643  virtual void compactMesh();
644 
645  const SMDS_MeshNode *FindNode(int idnode) const;
646  const SMDS_MeshNode *FindNodeVtk(int idnode) const;
647  const SMDS_Mesh0DElement* Find0DElement(int idnode) const;
648  const SMDS_BallElement* FindBall(int idnode) const;
649  const SMDS_MeshEdge *FindEdge(int idnode1, int idnode2) const;
650  const SMDS_MeshEdge *FindEdge(int idnode1, int idnode2, int idnode3) const;
651  const SMDS_MeshFace *FindFace(int idnode1, int idnode2, int idnode3) const;
652  const SMDS_MeshFace *FindFace(int idnode1, int idnode2, int idnode3, int idnode4) const;
653  const SMDS_MeshFace *FindFace(int idnode1, int idnode2, int idnode3,
654  int idnode4, int idnode5, int idnode6) const;
655  const SMDS_MeshFace *FindFace(int idnode1, int idnode2, int idnode3, int idnode4,
656  int idnode5, int idnode6, int idnode7, int idnode8) const;
657  const SMDS_MeshElement *FindElement(int IDelem) const;
658  static const SMDS_Mesh0DElement* Find0DElement(const SMDS_MeshNode * n);
659  static const SMDS_BallElement* FindBall(const SMDS_MeshNode * n);
660  static const SMDS_MeshEdge* FindEdge(const SMDS_MeshNode * n1,
661  const SMDS_MeshNode * n2);
662  static const SMDS_MeshEdge* FindEdge(const SMDS_MeshNode * n1,
663  const SMDS_MeshNode * n2,
664  const SMDS_MeshNode * n3);
665  static const SMDS_MeshFace* FindFace(const SMDS_MeshNode *n1,
666  const SMDS_MeshNode *n2,
667  const SMDS_MeshNode *n3);
668  static const SMDS_MeshFace* FindFace(const SMDS_MeshNode *n1,
669  const SMDS_MeshNode *n2,
670  const SMDS_MeshNode *n3,
671  const SMDS_MeshNode *n4);
672  static const SMDS_MeshFace* FindFace(const SMDS_MeshNode *n1,
673  const SMDS_MeshNode *n2,
674  const SMDS_MeshNode *n3,
675  const SMDS_MeshNode *n4,
676  const SMDS_MeshNode *n5,
677  const SMDS_MeshNode *n6);
678  static const SMDS_MeshFace* FindFace(const SMDS_MeshNode *n1,
679  const SMDS_MeshNode *n2,
680  const SMDS_MeshNode *n3,
681  const SMDS_MeshNode *n4,
682  const SMDS_MeshNode *n5,
683  const SMDS_MeshNode *n6,
684  const SMDS_MeshNode *n7,
685  const SMDS_MeshNode *n8);
686 
687  const SMDS_MeshFace *FindFace(const std::vector<int>& nodes_ids) const;
688  static const SMDS_MeshFace* FindFace(const std::vector<const SMDS_MeshNode *>& nodes);
689  static const SMDS_MeshElement* FindElement(const std::vector<const SMDS_MeshNode *>& nodes,
690  const SMDSAbs_ElementType type=SMDSAbs_All,
691  const bool noMedium=true);
692 
698  static int CheckMemory(const bool doNotRaise=false) throw (std::bad_alloc);
699 
700  int MaxNodeID() const;
701  int MinNodeID() const;
702  int MaxElementID() const;
703  int MinElementID() const;
704 
705  const SMDS_MeshInfo& GetMeshInfo() const { return myInfo; }
706 
707  virtual int NbNodes() const;
708  virtual int NbElements() const;
709  virtual int Nb0DElements() const;
710  virtual int NbBalls() const;
711  virtual int NbEdges() const;
712  virtual int NbFaces() const;
713  virtual int NbVolumes() const;
714  virtual int NbSubMesh() const;
715 
716  void DumpNodes() const;
717  void Dump0DElements() const;
718  void DumpEdges() const;
719  void DumpFaces() const;
720  void DumpVolumes() const;
721  void DebugStats() const;
722 
723  virtual ~SMDS_Mesh();
724 
725  bool hasConstructionEdges();
726  bool hasConstructionFaces();
727  bool hasInverseElements();
728  void setConstructionEdges(bool);
729  void setConstructionFaces(bool);
730  void setInverseElements(bool);
731 
738  bool Contains (const SMDS_MeshElement* elem) const;
739 
740  typedef std::vector<SMDS_MeshNode *> SetOfNodes;
741  typedef std::vector<SMDS_MeshCell *> SetOfCells;
742 
743  //void updateBoundingBox();
744  double getMaxDim();
745  int fromVtkToSmds(int vtkid);
746 
747  void dumpGrid(std::string ficdump="dumpGrid");
748  static int chunkSize;
749 
751  inline void setMyModified() { this->myModified = true; }
752 
753  void Modified();
754  vtkMTimeType GetMTime() const;
755  bool isCompacted();
756 
757 protected:
758  SMDS_Mesh(SMDS_Mesh * parent);
759 
760  SMDS_MeshFace * createTriangle(const SMDS_MeshNode * node1,
761  const SMDS_MeshNode * node2,
762  const SMDS_MeshNode * node3,
763  int ID);
764  SMDS_MeshFace * createQuadrangle(const SMDS_MeshNode * node1,
765  const SMDS_MeshNode * node2,
766  const SMDS_MeshNode * node3,
767  const SMDS_MeshNode * node4,
768  int ID);
769  SMDS_MeshEdge* FindEdgeOrCreate(const SMDS_MeshNode * n1,
770  const SMDS_MeshNode * n2);
771  SMDS_MeshFace* FindFaceOrCreate(const SMDS_MeshNode *n1,
772  const SMDS_MeshNode *n2,
773  const SMDS_MeshNode *n3);
774  SMDS_MeshFace* FindFaceOrCreate(const SMDS_MeshNode *n1,
775  const SMDS_MeshNode *n2,
776  const SMDS_MeshNode *n3,
777  const SMDS_MeshNode *n4);
778 
779  bool registerElement(int ID, SMDS_MeshElement * element);
780 
781  void addChildrenWithNodes(std::set<const SMDS_MeshElement*>& setOfChildren,
782  const SMDS_MeshElement * element,
783  std::set<const SMDS_MeshElement*>& nodes);
784 
785  inline void adjustmyCellsCapacity(int ID)
786  {
787  assert(ID >= 0);
788  myElementIDFactory->adjustMaxId(ID);
789  if (ID >= (int)myCells.size())
790  myCells.resize(ID+SMDS_Mesh::chunkSize,0);
791  }
792 
793  inline void adjustBoundingBox(double x, double y, double z)
794  {
795  if (x > xmax) xmax = x;
796  else if (x < xmin) xmin = x;
797  if (y > ymax) ymax = y;
798  else if (y < ymin) ymin = y;
799  if (z > zmax) zmax = z;
800  else if (z < zmin) zmin = z;
801  }
802 
803  // Fields PRIVATE
804 
806  int myMeshId;
807 
810 
813 
819 
823 
825  std::vector<vtkIdType> myNodeIds;
826 
828  std::vector<int> myCellIdVtkToSmds;
829 
831  std::list<SMDS_Mesh *> myChildren;
835 
839  unsigned long myModifTime, myCompactTime;
840 
844 
845  double xmin;
846  double xmax;
847  double ymin;
848  double ymax;
849  double zmin;
850  double zmax;
851 };
852 
853 
854 #endif