1 // Copyright (C) 2007-2020 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // SMESH SMDS : implementation of Salome mesh data structure
24 // File : SMDS_Mesh.hxx
27 #ifndef _SMDS_Mesh_HeaderFile
28 #define _SMDS_Mesh_HeaderFile
30 #include "SMESH_SMDS.hxx"
32 #include "SMDS_BallElement.hxx"
33 #include "SMDS_ElemIterator.hxx"
34 #include "SMDS_Mesh0DElement.hxx"
35 #include "SMDS_MeshCell.hxx"
36 #include "SMDS_MeshEdge.hxx"
37 #include "SMDS_MeshFace.hxx"
38 #include "SMDS_MeshInfo.hxx"
39 #include "SMDS_MeshNode.hxx"
40 #include "SMDS_MeshVolume.hxx"
41 #include "SMDS_UnstructuredGrid.hxx"
47 class SMDS_ElementHolder;
48 class SMDS_ElementFactory;
49 class SMDS_NodeFactory;
51 class SMDS_EXPORT SMDS_Mesh : public SMDS_MeshObject
57 //! actual nodes coordinates, cells definition and reverse connectivity are stored in a vtkUnstructuredGrid
58 inline SMDS_UnstructuredGrid* GetGrid() { return myGrid; }
60 virtual SMDS_NodeIteratorPtr nodesIterator () const;
61 virtual SMDS_EdgeIteratorPtr edgesIterator () const;
62 virtual SMDS_FaceIteratorPtr facesIterator () const;
63 virtual SMDS_VolumeIteratorPtr volumesIterator() const;
65 virtual SMDS_ElemIteratorPtr elementsIterator(SMDSAbs_ElementType type=SMDSAbs_All) const;
66 virtual SMDS_ElemIteratorPtr elementGeomIterator(SMDSAbs_GeometryType type) const;
67 virtual SMDS_ElemIteratorPtr elementEntityIterator(SMDSAbs_EntityType type) const;
69 virtual SMDS_NodeIteratorPtr shapeNodesIterator (int shapeID,
70 size_t nbElemsToReturn=-1,
71 const SMDS_MeshNode* sm1stNode=0) const;
72 virtual SMDS_ElemIteratorPtr shapeElementsIterator(int shapeID,
73 size_t nbElemsToReturn=-1,
74 const SMDS_MeshElement* sm1stElem=0) const;
76 SMDSAbs_ElementType GetElementType( const int id, const bool iselem ) const;
78 SMDS_Mesh *AddSubMesh();
80 virtual SMDS_MeshNode* AddNodeWithID(double x, double y, double z, int ID);
81 virtual SMDS_MeshNode* AddNode (double x, double y, double z);
83 virtual SMDS_Mesh0DElement* Add0DElementWithID(int n, int ID);
84 virtual SMDS_Mesh0DElement* Add0DElementWithID(const SMDS_MeshNode * n, int ID);
85 virtual SMDS_Mesh0DElement* Add0DElement (const SMDS_MeshNode * n);
87 virtual SMDS_BallElement* AddBallWithID(int n, double diameter, int ID);
88 virtual SMDS_BallElement* AddBallWithID(const SMDS_MeshNode * n, double diameter, int ID);
89 virtual SMDS_BallElement* AddBall (const SMDS_MeshNode * n, double diameter);
91 virtual SMDS_MeshEdge* AddEdgeWithID(int n1, int n2, int ID);
92 virtual SMDS_MeshEdge* AddEdgeWithID(const SMDS_MeshNode * n1,
93 const SMDS_MeshNode * n2,
95 virtual SMDS_MeshEdge* AddEdge(const SMDS_MeshNode * n1,
96 const SMDS_MeshNode * n2);
98 // 2d order edge with 3 nodes: n12 - node between n1 and n2
99 virtual SMDS_MeshEdge* AddEdgeWithID(int n1, int n2, int n12, int ID);
100 virtual SMDS_MeshEdge* AddEdgeWithID(const SMDS_MeshNode * n1,
101 const SMDS_MeshNode * n2,
102 const SMDS_MeshNode * n12,
104 virtual SMDS_MeshEdge* AddEdge(const SMDS_MeshNode * n1,
105 const SMDS_MeshNode * n2,
106 const SMDS_MeshNode * n12);
108 virtual SMDS_MeshFace* AddFaceWithID(int n1, int n2, int n3, int ID);
109 virtual SMDS_MeshFace* AddFaceWithID(const SMDS_MeshNode * n1,
110 const SMDS_MeshNode * n2,
111 const SMDS_MeshNode * n3,
113 virtual SMDS_MeshFace* AddFace(const SMDS_MeshNode * n1,
114 const SMDS_MeshNode * n2,
115 const SMDS_MeshNode * n3);
117 virtual SMDS_MeshFace* AddFaceWithID(int n1, int n2, int n3, int n4, int ID);
118 virtual SMDS_MeshFace* AddFaceWithID(const SMDS_MeshNode * n1,
119 const SMDS_MeshNode * n2,
120 const SMDS_MeshNode * n3,
121 const SMDS_MeshNode * n4,
123 virtual SMDS_MeshFace* AddFace(const SMDS_MeshNode * n1,
124 const SMDS_MeshNode * n2,
125 const SMDS_MeshNode * n3,
126 const SMDS_MeshNode * n4);
129 // 2d order triangle of 6 nodes
130 virtual SMDS_MeshFace* AddFaceWithID(int n1, int n2, int n3,
131 int n12,int n23,int n31, int ID);
132 virtual SMDS_MeshFace* AddFaceWithID(const SMDS_MeshNode * n1,
133 const SMDS_MeshNode * n2,
134 const SMDS_MeshNode * n3,
135 const SMDS_MeshNode * n12,
136 const SMDS_MeshNode * n23,
137 const SMDS_MeshNode * n31,
139 virtual SMDS_MeshFace* AddFace(const SMDS_MeshNode * n1,
140 const SMDS_MeshNode * n2,
141 const SMDS_MeshNode * n3,
142 const SMDS_MeshNode * n12,
143 const SMDS_MeshNode * n23,
144 const SMDS_MeshNode * n31);
146 // 2d order triangle of 7 nodes
147 virtual SMDS_MeshFace* AddFaceWithID(int n1, int n2, int n3,
148 int n12,int n23,int n31, int nCenter, int ID);
149 virtual SMDS_MeshFace* AddFaceWithID(const SMDS_MeshNode * n1,
150 const SMDS_MeshNode * n2,
151 const SMDS_MeshNode * n3,
152 const SMDS_MeshNode * n12,
153 const SMDS_MeshNode * n23,
154 const SMDS_MeshNode * n31,
155 const SMDS_MeshNode * nCenter,
157 virtual SMDS_MeshFace* AddFace(const SMDS_MeshNode * n1,
158 const SMDS_MeshNode * n2,
159 const SMDS_MeshNode * n3,
160 const SMDS_MeshNode * n12,
161 const SMDS_MeshNode * n23,
162 const SMDS_MeshNode * n31,
163 const SMDS_MeshNode * nCenter);
165 // 2d order quadrangle
166 virtual SMDS_MeshFace* AddFaceWithID(int n1, int n2, int n3, int n4,
167 int n12,int n23,int n34,int n41, int ID);
168 virtual SMDS_MeshFace* AddFaceWithID(const SMDS_MeshNode * n1,
169 const SMDS_MeshNode * n2,
170 const SMDS_MeshNode * n3,
171 const SMDS_MeshNode * n4,
172 const SMDS_MeshNode * n12,
173 const SMDS_MeshNode * n23,
174 const SMDS_MeshNode * n34,
175 const SMDS_MeshNode * n41,
177 virtual SMDS_MeshFace* AddFace(const SMDS_MeshNode * n1,
178 const SMDS_MeshNode * n2,
179 const SMDS_MeshNode * n3,
180 const SMDS_MeshNode * n4,
181 const SMDS_MeshNode * n12,
182 const SMDS_MeshNode * n23,
183 const SMDS_MeshNode * n34,
184 const SMDS_MeshNode * n41);
186 virtual SMDS_MeshFace* AddFaceWithID(int n1, int n2, int n3, int n4,
187 int n12,int n23,int n34,int n41, int nCenter, int ID);
188 virtual SMDS_MeshFace* AddFaceWithID(const SMDS_MeshNode * n1,
189 const SMDS_MeshNode * n2,
190 const SMDS_MeshNode * n3,
191 const SMDS_MeshNode * n4,
192 const SMDS_MeshNode * n12,
193 const SMDS_MeshNode * n23,
194 const SMDS_MeshNode * n34,
195 const SMDS_MeshNode * n41,
196 const SMDS_MeshNode * nCenter,
198 virtual SMDS_MeshFace* AddFace(const SMDS_MeshNode * n1,
199 const SMDS_MeshNode * n2,
200 const SMDS_MeshNode * n3,
201 const SMDS_MeshNode * n4,
202 const SMDS_MeshNode * n12,
203 const SMDS_MeshNode * n23,
204 const SMDS_MeshNode * n34,
205 const SMDS_MeshNode * n41,
206 const SMDS_MeshNode * nCenter);
208 virtual SMDS_MeshVolume* AddVolumeWithID(int n1, int n2, int n3, int n4, int ID);
209 virtual SMDS_MeshVolume* AddVolumeWithID(const SMDS_MeshNode * n1,
210 const SMDS_MeshNode * n2,
211 const SMDS_MeshNode * n3,
212 const SMDS_MeshNode * n4,
214 virtual SMDS_MeshVolume* AddVolume(const SMDS_MeshNode * n1,
215 const SMDS_MeshNode * n2,
216 const SMDS_MeshNode * n3,
217 const SMDS_MeshNode * n4);
219 virtual SMDS_MeshVolume* AddVolumeWithID(int n1, int n2, int n3, int n4,
221 virtual SMDS_MeshVolume* AddVolumeWithID(const SMDS_MeshNode * n1,
222 const SMDS_MeshNode * n2,
223 const SMDS_MeshNode * n3,
224 const SMDS_MeshNode * n4,
225 const SMDS_MeshNode * n5,
227 virtual SMDS_MeshVolume* AddVolume(const SMDS_MeshNode * n1,
228 const SMDS_MeshNode * n2,
229 const SMDS_MeshNode * n3,
230 const SMDS_MeshNode * n4,
231 const SMDS_MeshNode * n5);
233 virtual SMDS_MeshVolume* AddVolumeWithID(int n1, int n2, int n3, int n4,
234 int n5, int n6, int ID);
235 virtual SMDS_MeshVolume* AddVolumeWithID(const SMDS_MeshNode * n1,
236 const SMDS_MeshNode * n2,
237 const SMDS_MeshNode * n3,
238 const SMDS_MeshNode * n4,
239 const SMDS_MeshNode * n5,
240 const SMDS_MeshNode * n6,
242 virtual SMDS_MeshVolume* AddVolume(const SMDS_MeshNode * n1,
243 const SMDS_MeshNode * n2,
244 const SMDS_MeshNode * n3,
245 const SMDS_MeshNode * n4,
246 const SMDS_MeshNode * n5,
247 const SMDS_MeshNode * n6);
249 virtual SMDS_MeshVolume* AddVolumeWithID(int n1, int n2, int n3, int n4,
250 int n5, int n6, int n7, int n8, int ID);
251 virtual SMDS_MeshVolume* AddVolumeWithID(const SMDS_MeshNode * n1,
252 const SMDS_MeshNode * n2,
253 const SMDS_MeshNode * n3,
254 const SMDS_MeshNode * n4,
255 const SMDS_MeshNode * n5,
256 const SMDS_MeshNode * n6,
257 const SMDS_MeshNode * n7,
258 const SMDS_MeshNode * n8,
260 virtual SMDS_MeshVolume* AddVolume(const SMDS_MeshNode * n1,
261 const SMDS_MeshNode * n2,
262 const SMDS_MeshNode * n3,
263 const SMDS_MeshNode * n4,
264 const SMDS_MeshNode * n5,
265 const SMDS_MeshNode * n6,
266 const SMDS_MeshNode * n7,
267 const SMDS_MeshNode * n8);
271 virtual SMDS_MeshVolume* AddVolumeWithID(int n1, int n2, int n3, int n4, int n5, int n6,
272 int n7, int n8, int n9, int n10, int n11, int n12,
274 virtual SMDS_MeshVolume* AddVolumeWithID(const SMDS_MeshNode * n1,
275 const SMDS_MeshNode * n2,
276 const SMDS_MeshNode * n3,
277 const SMDS_MeshNode * n4,
278 const SMDS_MeshNode * n5,
279 const SMDS_MeshNode * n6,
280 const SMDS_MeshNode * n7,
281 const SMDS_MeshNode * n8,
282 const SMDS_MeshNode * n9,
283 const SMDS_MeshNode * n10,
284 const SMDS_MeshNode * n11,
285 const SMDS_MeshNode * n12,
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 const SMDS_MeshNode * n9,
296 const SMDS_MeshNode * n10,
297 const SMDS_MeshNode * n11,
298 const SMDS_MeshNode * n12);
300 // 2d order tetrahedron of 10 nodes
301 virtual SMDS_MeshVolume* AddVolumeWithID(int n1, int n2, int n3, int n4,
302 int n12,int n23,int n31,
303 int n14,int n24,int n34, int ID);
304 virtual SMDS_MeshVolume* AddVolumeWithID(const SMDS_MeshNode * n1,
305 const SMDS_MeshNode * n2,
306 const SMDS_MeshNode * n3,
307 const SMDS_MeshNode * n4,
308 const SMDS_MeshNode * n12,
309 const SMDS_MeshNode * n23,
310 const SMDS_MeshNode * n31,
311 const SMDS_MeshNode * n14,
312 const SMDS_MeshNode * n24,
313 const SMDS_MeshNode * n34,
315 virtual SMDS_MeshVolume* AddVolume(const SMDS_MeshNode * n1,
316 const SMDS_MeshNode * n2,
317 const SMDS_MeshNode * n3,
318 const SMDS_MeshNode * n4,
319 const SMDS_MeshNode * n12,
320 const SMDS_MeshNode * n23,
321 const SMDS_MeshNode * n31,
322 const SMDS_MeshNode * n14,
323 const SMDS_MeshNode * n24,
324 const SMDS_MeshNode * n34);
326 // 2d order pyramid of 13 nodes
327 virtual SMDS_MeshVolume* AddVolumeWithID(int n1, int n2, int n3, int n4, int n5,
328 int n12,int n23,int n34,int n41,
329 int n15,int n25,int n35,int n45,
331 virtual SMDS_MeshVolume* AddVolumeWithID(const SMDS_MeshNode * n1,
332 const SMDS_MeshNode * n2,
333 const SMDS_MeshNode * n3,
334 const SMDS_MeshNode * n4,
335 const SMDS_MeshNode * n5,
336 const SMDS_MeshNode * n12,
337 const SMDS_MeshNode * n23,
338 const SMDS_MeshNode * n34,
339 const SMDS_MeshNode * n41,
340 const SMDS_MeshNode * n15,
341 const SMDS_MeshNode * n25,
342 const SMDS_MeshNode * n35,
343 const SMDS_MeshNode * n45,
345 virtual SMDS_MeshVolume* AddVolume(const SMDS_MeshNode * n1,
346 const SMDS_MeshNode * n2,
347 const SMDS_MeshNode * n3,
348 const SMDS_MeshNode * n4,
349 const SMDS_MeshNode * n5,
350 const SMDS_MeshNode * n12,
351 const SMDS_MeshNode * n23,
352 const SMDS_MeshNode * n34,
353 const SMDS_MeshNode * n41,
354 const SMDS_MeshNode * n15,
355 const SMDS_MeshNode * n25,
356 const SMDS_MeshNode * n35,
357 const SMDS_MeshNode * n45);
359 // 2d order Pentahedron with 15 nodes
360 virtual SMDS_MeshVolume* AddVolumeWithID(int n1, int n2, int n3,
361 int n4, int n5, int n6,
362 int n12,int n23,int n31,
363 int n45,int n56,int n64,
364 int n14,int n25,int n36,
366 virtual SMDS_MeshVolume* AddVolumeWithID(const SMDS_MeshNode * n1,
367 const SMDS_MeshNode * n2,
368 const SMDS_MeshNode * n3,
369 const SMDS_MeshNode * n4,
370 const SMDS_MeshNode * n5,
371 const SMDS_MeshNode * n6,
372 const SMDS_MeshNode * n12,
373 const SMDS_MeshNode * n23,
374 const SMDS_MeshNode * n31,
375 const SMDS_MeshNode * n45,
376 const SMDS_MeshNode * n56,
377 const SMDS_MeshNode * n64,
378 const SMDS_MeshNode * n14,
379 const SMDS_MeshNode * n25,
380 const SMDS_MeshNode * n36,
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 * n12,
389 const SMDS_MeshNode * n23,
390 const SMDS_MeshNode * n31,
391 const SMDS_MeshNode * n45,
392 const SMDS_MeshNode * n56,
393 const SMDS_MeshNode * n64,
394 const SMDS_MeshNode * n14,
395 const SMDS_MeshNode * n25,
396 const SMDS_MeshNode * n36);
398 // 2d order Pentahedron with 18 nodes
399 virtual SMDS_MeshVolume* AddVolumeWithID(int n1, int n2, int n3,
400 int n4, int n5, int n6,
401 int n12,int n23,int n31,
402 int n45,int n56,int n64,
403 int n14,int n25,int n36,
404 int n1245, int n2356, int n1346,
406 virtual SMDS_MeshVolume* AddVolumeWithID(const SMDS_MeshNode * n1,
407 const SMDS_MeshNode * n2,
408 const SMDS_MeshNode * n3,
409 const SMDS_MeshNode * n4,
410 const SMDS_MeshNode * n5,
411 const SMDS_MeshNode * n6,
412 const SMDS_MeshNode * n12,
413 const SMDS_MeshNode * n23,
414 const SMDS_MeshNode * n31,
415 const SMDS_MeshNode * n45,
416 const SMDS_MeshNode * n56,
417 const SMDS_MeshNode * n64,
418 const SMDS_MeshNode * n14,
419 const SMDS_MeshNode * n25,
420 const SMDS_MeshNode * n36,
421 const SMDS_MeshNode * n1245,
422 const SMDS_MeshNode * n2356,
423 const SMDS_MeshNode * n1346,
425 virtual SMDS_MeshVolume* AddVolume(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 const SMDS_MeshNode * n1245,
441 const SMDS_MeshNode * n2356,
442 const SMDS_MeshNode * n1346);
445 // 2d oreder Hexahedrons with 20 nodes
446 virtual SMDS_MeshVolume* AddVolumeWithID(int n1, int n2, int n3, int n4,
447 int n5, int n6, int n7, int n8,
448 int n12,int n23,int n34,int n41,
449 int n56,int n67,int n78,int n85,
450 int n15,int n26,int n37,int n48,
452 virtual SMDS_MeshVolume* AddVolumeWithID(const SMDS_MeshNode * n1,
453 const SMDS_MeshNode * n2,
454 const SMDS_MeshNode * n3,
455 const SMDS_MeshNode * n4,
456 const SMDS_MeshNode * n5,
457 const SMDS_MeshNode * n6,
458 const SMDS_MeshNode * n7,
459 const SMDS_MeshNode * n8,
460 const SMDS_MeshNode * n12,
461 const SMDS_MeshNode * n23,
462 const SMDS_MeshNode * n34,
463 const SMDS_MeshNode * n41,
464 const SMDS_MeshNode * n56,
465 const SMDS_MeshNode * n67,
466 const SMDS_MeshNode * n78,
467 const SMDS_MeshNode * n85,
468 const SMDS_MeshNode * n15,
469 const SMDS_MeshNode * n26,
470 const SMDS_MeshNode * n37,
471 const SMDS_MeshNode * n48,
473 virtual SMDS_MeshVolume* AddVolume(const SMDS_MeshNode * n1,
474 const SMDS_MeshNode * n2,
475 const SMDS_MeshNode * n3,
476 const SMDS_MeshNode * n4,
477 const SMDS_MeshNode * n5,
478 const SMDS_MeshNode * n6,
479 const SMDS_MeshNode * n7,
480 const SMDS_MeshNode * n8,
481 const SMDS_MeshNode * n12,
482 const SMDS_MeshNode * n23,
483 const SMDS_MeshNode * n34,
484 const SMDS_MeshNode * n41,
485 const SMDS_MeshNode * n56,
486 const SMDS_MeshNode * n67,
487 const SMDS_MeshNode * n78,
488 const SMDS_MeshNode * n85,
489 const SMDS_MeshNode * n15,
490 const SMDS_MeshNode * n26,
491 const SMDS_MeshNode * n37,
492 const SMDS_MeshNode * n48);
494 // 2d oreder Hexahedrons with 27 nodes
495 virtual SMDS_MeshVolume* AddVolumeWithID(int n1, int n2, int n3, int n4,
496 int n5, int n6, int n7, int n8,
497 int n12,int n23,int n34,int n41,
498 int n56,int n67,int n78,int n85,
499 int n15,int n26,int n37,int n48,
500 int n1234,int n1256,int n2367,int n3478,
501 int n1458,int n5678,int nCenter,
503 virtual SMDS_MeshVolume* AddVolumeWithID(const SMDS_MeshNode * n1,
504 const SMDS_MeshNode * n2,
505 const SMDS_MeshNode * n3,
506 const SMDS_MeshNode * n4,
507 const SMDS_MeshNode * n5,
508 const SMDS_MeshNode * n6,
509 const SMDS_MeshNode * n7,
510 const SMDS_MeshNode * n8,
511 const SMDS_MeshNode * n12,
512 const SMDS_MeshNode * n23,
513 const SMDS_MeshNode * n34,
514 const SMDS_MeshNode * n41,
515 const SMDS_MeshNode * n56,
516 const SMDS_MeshNode * n67,
517 const SMDS_MeshNode * n78,
518 const SMDS_MeshNode * n85,
519 const SMDS_MeshNode * n15,
520 const SMDS_MeshNode * n26,
521 const SMDS_MeshNode * n37,
522 const SMDS_MeshNode * n48,
523 const SMDS_MeshNode * n1234,
524 const SMDS_MeshNode * n1256,
525 const SMDS_MeshNode * n2367,
526 const SMDS_MeshNode * n3478,
527 const SMDS_MeshNode * n1458,
528 const SMDS_MeshNode * n5678,
529 const SMDS_MeshNode * nCenter,
531 virtual SMDS_MeshVolume* AddVolume(const SMDS_MeshNode * n1,
532 const SMDS_MeshNode * n2,
533 const SMDS_MeshNode * n3,
534 const SMDS_MeshNode * n4,
535 const SMDS_MeshNode * n5,
536 const SMDS_MeshNode * n6,
537 const SMDS_MeshNode * n7,
538 const SMDS_MeshNode * n8,
539 const SMDS_MeshNode * n12,
540 const SMDS_MeshNode * n23,
541 const SMDS_MeshNode * n34,
542 const SMDS_MeshNode * n41,
543 const SMDS_MeshNode * n56,
544 const SMDS_MeshNode * n67,
545 const SMDS_MeshNode * n78,
546 const SMDS_MeshNode * n85,
547 const SMDS_MeshNode * n15,
548 const SMDS_MeshNode * n26,
549 const SMDS_MeshNode * n37,
550 const SMDS_MeshNode * n48,
551 const SMDS_MeshNode * n1234,
552 const SMDS_MeshNode * n1256,
553 const SMDS_MeshNode * n2367,
554 const SMDS_MeshNode * n3478,
555 const SMDS_MeshNode * n1458,
556 const SMDS_MeshNode * n5678,
557 const SMDS_MeshNode * nCenter);
559 virtual SMDS_MeshFace* AddPolygonalFaceWithID (const std::vector<int> & nodes_ids,
562 virtual SMDS_MeshFace* AddPolygonalFaceWithID (const std::vector<const SMDS_MeshNode*> & nodes,
565 virtual SMDS_MeshFace* AddPolygonalFace (const std::vector<const SMDS_MeshNode*> & nodes);
567 virtual SMDS_MeshFace* AddQuadPolygonalFaceWithID(const std::vector<int> & nodes_ids,
570 virtual SMDS_MeshFace* AddQuadPolygonalFaceWithID(const std::vector<const SMDS_MeshNode*> & nodes,
573 virtual SMDS_MeshFace* AddQuadPolygonalFace(const std::vector<const SMDS_MeshNode*> & nodes);
575 virtual SMDS_MeshVolume* AddPolyhedralVolumeWithID
576 (const std::vector<int> & nodes_ids,
577 const std::vector<int> & quantities,
580 virtual SMDS_MeshVolume* AddPolyhedralVolumeWithID
581 (const std::vector<const SMDS_MeshNode*> & nodes,
582 const std::vector<int> & quantities,
585 virtual SMDS_MeshVolume* AddPolyhedralVolume
586 (const std::vector<const SMDS_MeshNode*> & nodes,
587 const std::vector<int> & quantities);
589 virtual SMDS_MeshVolume* AddVolumeFromVtkIds(const std::vector<vtkIdType>& vtkNodeIds);
591 virtual SMDS_MeshFace* AddFaceFromVtkIds(const std::vector<vtkIdType>& vtkNodeIds);
593 virtual void MoveNode(const SMDS_MeshNode *n, double x, double y, double z);
595 virtual void RemoveElement(const SMDS_MeshElement * elem,
596 std::vector<const SMDS_MeshElement *>& removedElems,
597 std::vector<const SMDS_MeshElement *>& removedNodes,
598 const bool removenodes = false);
599 virtual void RemoveElement(const SMDS_MeshElement * elem, bool removenodes = false);
600 virtual void RemoveNode(const SMDS_MeshNode * node);
602 /*! Remove only the given element and only if it is free.
603 * Method does not work for meshes with descendants.
604 * Implemented for fast cleaning of meshes.
606 virtual void RemoveFreeElement(const SMDS_MeshElement * elem);
608 virtual void Clear();
610 virtual bool RemoveFromParent();
611 virtual bool RemoveSubMesh(const SMDS_Mesh * aMesh);
613 bool ChangeElementNodes(const SMDS_MeshElement * elem,
614 const SMDS_MeshNode * nodes[],
616 bool ChangePolyhedronNodes(const SMDS_MeshElement * elem,
617 const std::vector<const SMDS_MeshNode*>& nodes,
618 const std::vector<int>& quantities);
620 //virtual void Renumber (const bool isNodes, const int startID = 1, const int deltaID = 1);
621 // Renumber all nodes or elements.
623 virtual void CompactMesh();
624 virtual bool IsCompacted();
625 virtual bool HasNumerationHoles();
627 template<class ELEMTYPE>
628 static const ELEMTYPE* DownCast( const SMDS_MeshElement* e )
630 return (( e && !e->IsNull() && ELEMTYPE::Type() == e->GetType() ) ?
631 static_cast<const ELEMTYPE*>(e) : 0 );
634 const SMDS_MeshNode *FindNode(int idnode) const;
635 const SMDS_MeshNode *FindNodeVtk(int idnode) const;
636 const SMDS_MeshElement *FindElementVtk(int IDelem) const;
637 virtual const SMDS_MeshElement * FindElement(int IDelem) const;
638 static const SMDS_Mesh0DElement* Find0DElement(const SMDS_MeshNode * n);
639 static const SMDS_BallElement* FindBall(const SMDS_MeshNode * n);
640 static const SMDS_MeshEdge* FindEdge(const SMDS_MeshNode * n1,
641 const SMDS_MeshNode * n2);
642 static const SMDS_MeshEdge* FindEdge(const SMDS_MeshNode * n1,
643 const SMDS_MeshNode * n2,
644 const SMDS_MeshNode * n3);
645 static const SMDS_MeshFace* FindFace(const SMDS_MeshNode *n1,
646 const SMDS_MeshNode *n2,
647 const SMDS_MeshNode *n3);
648 static const SMDS_MeshFace* FindFace(const SMDS_MeshNode *n1,
649 const SMDS_MeshNode *n2,
650 const SMDS_MeshNode *n3,
651 const SMDS_MeshNode *n4);
652 static const SMDS_MeshFace* FindFace(const SMDS_MeshNode *n1,
653 const SMDS_MeshNode *n2,
654 const SMDS_MeshNode *n3,
655 const SMDS_MeshNode *n4,
656 const SMDS_MeshNode *n5,
657 const SMDS_MeshNode *n6);
658 static const SMDS_MeshFace* FindFace(const SMDS_MeshNode *n1,
659 const SMDS_MeshNode *n2,
660 const SMDS_MeshNode *n3,
661 const SMDS_MeshNode *n4,
662 const SMDS_MeshNode *n5,
663 const SMDS_MeshNode *n6,
664 const SMDS_MeshNode *n7,
665 const SMDS_MeshNode *n8);
667 static const SMDS_MeshFace* FindFace (const std::vector<const SMDS_MeshNode *>& nodes);
668 static const SMDS_MeshElement* FindElement(const std::vector<const SMDS_MeshNode *>& nodes,
669 const SMDSAbs_ElementType type=SMDSAbs_All,
670 const bool noMedium=true);
671 static int GetElementsByNodes(const std::vector<const SMDS_MeshNode *>& nodes,
672 std::vector<const SMDS_MeshElement *>& foundElems,
673 const SMDSAbs_ElementType type=SMDSAbs_All);
675 virtual bool Contains( const SMDS_MeshElement* elem ) const;
678 * \brief Raise an exception if free memory (ram+swap) too low
679 * \param doNotRaise - if true, suppress exception, just return free memory size
680 * \retval int - amount of available memory in MB or negative number in failure case
682 static int CheckMemory(const bool doNotRaise=false) throw (std::bad_alloc);
684 virtual int MaxNodeID() const;
685 virtual int MinNodeID() const;
686 virtual int MaxElementID() const;
687 virtual int MinElementID() const;
689 const SMDS_MeshInfo& GetMeshInfo() const { return myInfo; }
691 virtual int NbNodes() const;
692 virtual int NbElements() const;
693 virtual int Nb0DElements() const;
694 virtual int NbBalls() const;
695 virtual int NbEdges() const;
696 virtual int NbFaces() const;
697 virtual int NbVolumes() const;
698 virtual int NbSubMesh() const;
700 virtual ~SMDS_Mesh();
703 int FromVtkToSmds(int vtkid) const;
705 void dumpGrid(std::string ficdump="dumpGrid");
706 static int chunkSize;
708 //! low level modification: add, change or remove node or element
709 inline void setMyModified() { this->myModified = true; }
712 vtkMTimeType GetMTime() const;
715 SMDS_Mesh(SMDS_Mesh * parent);
717 void addChildrenWithNodes(std::set<const SMDS_MeshElement*>& setOfChildren,
718 const SMDS_MeshElement * element,
719 std::set<const SMDS_MeshElement*>& nodes);
721 inline void adjustBoundingBox(double x, double y, double z)
723 if (x > xmax) xmax = x;
724 else if (x < xmin) xmin = x;
725 if (y > ymax) ymax = y;
726 else if (y < ymin) ymin = y;
727 if (z > zmax) zmax = z;
728 else if (z < zmin) zmin = z;
731 void updateInverseElements( const SMDS_MeshElement * element,
732 const SMDS_MeshNode* const* nodes,
734 std::set<const SMDS_MeshNode*>& oldNodes );
736 void setNbShapes( size_t nbShapes );
741 //! actual nodes coordinates, cells definition and reverse connectivity are stored in a vtkUnstructuredGrid
742 SMDS_UnstructuredGrid* myGrid;
744 //! Small objects like SMDS_MeshNode are allocated by chunks to limit memory costs of new
745 SMDS_NodeFactory* myNodeFactory;
746 SMDS_ElementFactory* myCellFactory;
748 SMDS_Mesh * myParent;
749 std::list<SMDS_Mesh *> myChildren;
750 SMDS_MeshInfo myInfo;
752 //! any add, remove or change of node or cell
754 //! use a counter to keep track of modifications
755 unsigned long myModifTime, myCompactTime;
757 friend class SMDS_ElementHolder;
758 std::set< SMDS_ElementHolder* > myElemHolders;