1 // Copyright (C) 2007-2015 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 SMESHDS : management of mesh data and SMESH document
24 // File : SMESH_Mesh.cxx
25 // Author : Yves FRICAUD, OCC
28 #include "SMESHDS_Mesh.hxx"
30 #include "SMDS_Downward.hxx"
31 #include "SMDS_EdgePosition.hxx"
32 #include "SMDS_FacePosition.hxx"
33 #include "SMDS_SpacePosition.hxx"
34 #include "SMDS_VertexPosition.hxx"
35 #include "SMESHDS_Group.hxx"
36 #include "SMESHDS_GroupOnGeom.hxx"
37 #include "SMESHDS_Script.hxx"
38 #include "SMESHDS_TSubMeshHolder.hxx"
40 #include <Standard_ErrorHandler.hxx>
41 #include <Standard_OutOfRange.hxx>
43 #include <TopExp_Explorer.hxx>
44 #include <TopoDS_Edge.hxx>
45 #include <TopoDS_Face.hxx>
46 #include <TopoDS_Iterator.hxx>
47 #include <TopoDS_Shell.hxx>
48 #include <TopoDS_Solid.hxx>
49 #include <TopoDS_Vertex.hxx>
51 #include "utilities.h"
55 class SMESHDS_Mesh::SubMeshHolder : public SMESHDS_TSubMeshHolder< const SMESHDS_SubMesh >
59 //=======================================================================
62 //=======================================================================
63 SMESHDS_Mesh::SMESHDS_Mesh(int theMeshID, bool theIsEmbeddedMode):
65 mySubMeshHolder( new SubMeshHolder ),
66 myIsEmbeddedMode(theIsEmbeddedMode)
68 myScript = new SMESHDS_Script(theIsEmbeddedMode);
69 SetPersistentId(theMeshID);
72 //=======================================================================
73 bool SMESHDS_Mesh::IsEmbeddedMode()
75 return myIsEmbeddedMode;
78 //================================================================================
80 * \brief Store ID persistent during lifecycle
82 * Initially it was used to have a persistent reference to the mesh from the hypothesis
84 //================================================================================
86 void SMESHDS_Mesh::SetPersistentId(int id)
91 //================================================================================
93 * \brief Return ID persistent during lifecycle
95 //================================================================================
97 int SMESHDS_Mesh::GetPersistentId() const
99 return myPersistentID;
102 //=======================================================================
103 //function : ShapeToMesh
105 //=======================================================================
106 void SMESHDS_Mesh::ShapeToMesh(const TopoDS_Shape & S)
108 if ( !myShape.IsNull() && S.IsNull() )
110 // removal of a shape to mesh, delete ...
112 myShapeToHypothesis.Clear();
113 // - shape indices in SMDS_Position of nodes
114 SMESHDS_SubMeshIteratorPtr smIt = SubMeshes();
115 while ( SMESHDS_SubMesh* sm = const_cast< SMESHDS_SubMesh* >( smIt->next() )) {
116 if ( !sm->IsComplexSubmesh() ) {
117 SMDS_NodeIteratorPtr nIt = sm->GetNodes();
118 while ( nIt->more() )
119 sm->RemoveNode(nIt->next(), false);
123 mySubMeshHolder->DeleteAll();
125 myIndexToShape.Clear();
126 // - groups on geometry
127 set<SMESHDS_GroupBase*>::iterator gr = myGroups.begin();
128 while ( gr != myGroups.end() ) {
129 if ( dynamic_cast<SMESHDS_GroupOnGeom*>( *gr ))
130 myGroups.erase( gr++ );
138 TopExp::MapShapes(myShape, myIndexToShape);
142 //=======================================================================
143 //function : AddHypothesis
145 //=======================================================================
147 bool SMESHDS_Mesh::AddHypothesis(const TopoDS_Shape & SS,
148 const SMESHDS_Hypothesis * H)
150 if (!myShapeToHypothesis.IsBound(SS/*.Oriented(TopAbs_FORWARD)*/)) {
151 list<const SMESHDS_Hypothesis *> aList;
152 myShapeToHypothesis.Bind(SS/*.Oriented(TopAbs_FORWARD)*/, aList);
154 list<const SMESHDS_Hypothesis *>& alist =
155 myShapeToHypothesis(SS/*.Oriented(TopAbs_FORWARD)*/); // ignore orientation of SS
157 //Check if the Hypothesis is still present
158 list<const SMESHDS_Hypothesis*>::iterator ith = find(alist.begin(),alist.end(), H );
160 if (alist.end() != ith) return false;
166 //=======================================================================
167 //function : RemoveHypothesis
169 //=======================================================================
171 bool SMESHDS_Mesh::RemoveHypothesis(const TopoDS_Shape & S,
172 const SMESHDS_Hypothesis * H)
174 if( myShapeToHypothesis.IsBound( S/*.Oriented(TopAbs_FORWARD)*/ ) )
176 list<const SMESHDS_Hypothesis *>& alist=myShapeToHypothesis.ChangeFind( S/*.Oriented(TopAbs_FORWARD)*/ );
177 list<const SMESHDS_Hypothesis*>::iterator ith=find(alist.begin(),alist.end(), H );
178 if (ith != alist.end())
187 //=======================================================================
190 //=======================================================================
191 SMDS_MeshNode* SMESHDS_Mesh::AddNode(double x, double y, double z){
192 SMDS_MeshNode* node = SMDS_Mesh::AddNode(x, y, z);
193 if(node!=NULL) myScript->AddNode(node->GetID(), x, y, z);
197 SMDS_MeshNode* SMESHDS_Mesh::AddNodeWithID(double x, double y, double z, int ID){
198 SMDS_MeshNode* node = SMDS_Mesh::AddNodeWithID(x,y,z,ID);
199 if(node!=NULL) myScript->AddNode(node->GetID(), x, y, z);
203 //=======================================================================
204 //function : MoveNode
206 //=======================================================================
208 void SMESHDS_Mesh::MoveNode(const SMDS_MeshNode *n, double x, double y, double z)
210 SMDS_Mesh::MoveNode( n, x, y, z );
211 myScript->MoveNode(n->GetID(), x, y, z);
214 //=======================================================================
215 //function : ChangeElementNodes
216 //purpose : Changed nodes of an element provided that nb of nodes does not change
217 //=======================================================================
219 bool SMESHDS_Mesh::ChangeElementNodes(const SMDS_MeshElement * elem,
220 const SMDS_MeshNode * nodes[],
223 //MESSAGE("SMESHDS_Mesh::ChangeElementNodes");
224 if ( ! SMDS_Mesh::ChangeElementNodes( elem, nodes, nbnodes ))
227 vector<int> IDs( nbnodes );
228 for ( int i = 0; i < nbnodes; i++ )
229 IDs [ i ] = nodes[ i ]->GetID();
230 myScript->ChangeElementNodes( elem->GetID(), &IDs[0], nbnodes);
235 //=======================================================================
236 //function : ChangePolygonNodes
238 //=======================================================================
239 bool SMESHDS_Mesh::ChangePolygonNodes
240 (const SMDS_MeshElement * elem,
241 vector<const SMDS_MeshNode*> nodes)
243 ASSERT(nodes.size() > 3);
245 return ChangeElementNodes(elem, &nodes[0], nodes.size());
248 //=======================================================================
249 //function : ChangePolyhedronNodes
251 //=======================================================================
252 bool SMESHDS_Mesh::ChangePolyhedronNodes
253 (const SMDS_MeshElement * elem,
254 std::vector<const SMDS_MeshNode*> nodes,
255 std::vector<int> quantities)
257 ASSERT(nodes.size() > 3);
259 if (!SMDS_Mesh::ChangePolyhedronNodes(elem, nodes, quantities))
262 int i, len = nodes.size();
263 std::vector<int> nodes_ids (len);
264 for (i = 0; i < len; i++) {
265 nodes_ids[i] = nodes[i]->GetID();
267 myScript->ChangePolyhedronNodes(elem->GetID(), nodes_ids, quantities);
272 //=======================================================================
273 //function : Renumber
275 //=======================================================================
277 void SMESHDS_Mesh::Renumber (const bool isNodes, const int startID, const int deltaID)
279 // TODO not possible yet to have node numbers not starting to O and continuous.
280 if (!this->isCompacted())
282 // SMDS_Mesh::Renumber( isNodes, startID, deltaID );
283 // myScript->Renumber( isNodes, startID, deltaID );
286 //=======================================================================
287 //function : Add0DElement
289 //=======================================================================
290 SMDS_Mesh0DElement* SMESHDS_Mesh::Add0DElementWithID(int nodeID, int ID)
292 SMDS_Mesh0DElement* anElem = SMDS_Mesh::Add0DElementWithID(nodeID, ID);
293 if (anElem) myScript->Add0DElement(ID, nodeID);
297 SMDS_Mesh0DElement* SMESHDS_Mesh::Add0DElementWithID
298 (const SMDS_MeshNode * node, int ID)
300 return Add0DElementWithID(node->GetID(), ID);
303 SMDS_Mesh0DElement* SMESHDS_Mesh::Add0DElement(const SMDS_MeshNode * node)
305 SMDS_Mesh0DElement* anElem = SMDS_Mesh::Add0DElement(node);
306 if (anElem) myScript->Add0DElement(anElem->GetID(), node->GetID());
310 //=======================================================================
311 //function :AddBallWithID
313 //=======================================================================
315 SMDS_BallElement* SMESHDS_Mesh::AddBallWithID(int node, double diameter, int ID)
317 SMDS_BallElement* anElem = SMDS_Mesh::AddBallWithID(node,diameter,ID);
318 if (anElem) myScript->AddBall(anElem->GetID(), node, diameter);
322 SMDS_BallElement* SMESHDS_Mesh::AddBallWithID(const SMDS_MeshNode * node,
326 SMDS_BallElement* anElem = SMDS_Mesh::AddBallWithID(node,diameter,ID);
327 if (anElem) myScript->AddBall(anElem->GetID(), node->GetID(), diameter);
331 SMDS_BallElement* SMESHDS_Mesh::AddBall (const SMDS_MeshNode * node,
334 SMDS_BallElement* anElem = SMDS_Mesh::AddBall(node,diameter);
335 if (anElem) myScript->AddBall(anElem->GetID(), node->GetID(), diameter);
339 //=======================================================================
340 //function :AddEdgeWithID
342 //=======================================================================
344 SMDS_MeshEdge* SMESHDS_Mesh::AddEdgeWithID(int n1, int n2, int ID)
346 SMDS_MeshEdge* anElem = SMDS_Mesh::AddEdgeWithID(n1,n2,ID);
347 if(anElem) myScript->AddEdge(ID,n1,n2);
351 SMDS_MeshEdge* SMESHDS_Mesh::AddEdgeWithID(const SMDS_MeshNode * n1,
352 const SMDS_MeshNode * n2,
355 return AddEdgeWithID(n1->GetID(),
360 SMDS_MeshEdge* SMESHDS_Mesh::AddEdge(const SMDS_MeshNode * n1,
361 const SMDS_MeshNode * n2)
363 SMDS_MeshEdge* anElem = SMDS_Mesh::AddEdge(n1,n2);
364 if(anElem) myScript->AddEdge(anElem->GetID(),
370 //=======================================================================
373 //=======================================================================
374 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(int n1, int n2, int n3, int ID)
376 SMDS_MeshFace *anElem = SMDS_Mesh::AddFaceWithID(n1, n2, n3, ID);
377 if(anElem) myScript->AddFace(ID,n1,n2,n3);
381 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(const SMDS_MeshNode * n1,
382 const SMDS_MeshNode * n2,
383 const SMDS_MeshNode * n3,
386 return AddFaceWithID(n1->GetID(),
392 SMDS_MeshFace* SMESHDS_Mesh::AddFace( const SMDS_MeshNode * n1,
393 const SMDS_MeshNode * n2,
394 const SMDS_MeshNode * n3)
396 SMDS_MeshFace *anElem = SMDS_Mesh::AddFace(n1, n2, n3);
397 if(anElem) myScript->AddFace(anElem->GetID(),
404 //=======================================================================
407 //=======================================================================
408 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(int n1, int n2, int n3, int n4, int ID)
410 SMDS_MeshFace *anElem = SMDS_Mesh::AddFaceWithID(n1, n2, n3, n4, ID);
411 if(anElem) myScript->AddFace(ID, n1, n2, n3, n4);
415 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(const SMDS_MeshNode * n1,
416 const SMDS_MeshNode * n2,
417 const SMDS_MeshNode * n3,
418 const SMDS_MeshNode * n4,
421 return AddFaceWithID(n1->GetID(),
428 SMDS_MeshFace* SMESHDS_Mesh::AddFace(const SMDS_MeshNode * n1,
429 const SMDS_MeshNode * n2,
430 const SMDS_MeshNode * n3,
431 const SMDS_MeshNode * n4)
433 SMDS_MeshFace *anElem = SMDS_Mesh::AddFace(n1, n2, n3, n4);
434 if(anElem) myScript->AddFace(anElem->GetID(),
442 //=======================================================================
443 //function :AddVolume
445 //=======================================================================
446 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3, int n4, int ID)
448 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolumeWithID(n1, n2, n3, n4, ID);
449 if(anElem) myScript->AddVolume(ID, n1, n2, n3, n4);
453 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
454 const SMDS_MeshNode * n2,
455 const SMDS_MeshNode * n3,
456 const SMDS_MeshNode * n4,
459 return AddVolumeWithID(n1->GetID(),
466 SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
467 const SMDS_MeshNode * n2,
468 const SMDS_MeshNode * n3,
469 const SMDS_MeshNode * n4)
471 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1, n2, n3, n4);
472 if(anElem) myScript->AddVolume(anElem->GetID(),
480 //=======================================================================
481 //function :AddVolume
483 //=======================================================================
484 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3, int n4, int n5, int ID)
486 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolumeWithID(n1, n2, n3, n4, n5, ID);
487 if(anElem) myScript->AddVolume(ID, n1, n2, n3, n4, n5);
491 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
492 const SMDS_MeshNode * n2,
493 const SMDS_MeshNode * n3,
494 const SMDS_MeshNode * n4,
495 const SMDS_MeshNode * n5,
498 return AddVolumeWithID(n1->GetID(),
506 SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
507 const SMDS_MeshNode * n2,
508 const SMDS_MeshNode * n3,
509 const SMDS_MeshNode * n4,
510 const SMDS_MeshNode * n5)
512 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1, n2, n3, n4, n5);
513 if(anElem) myScript->AddVolume(anElem->GetID(),
522 //=======================================================================
523 //function :AddVolume
525 //=======================================================================
526 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3, int n4, int n5, int n6, int ID)
528 SMDS_MeshVolume *anElem= SMDS_Mesh::AddVolumeWithID(n1, n2, n3, n4, n5, n6, ID);
529 if(anElem) myScript->AddVolume(ID, n1, n2, n3, n4, n5, n6);
533 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
534 const SMDS_MeshNode * n2,
535 const SMDS_MeshNode * n3,
536 const SMDS_MeshNode * n4,
537 const SMDS_MeshNode * n5,
538 const SMDS_MeshNode * n6,
541 return AddVolumeWithID(n1->GetID(),
550 SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
551 const SMDS_MeshNode * n2,
552 const SMDS_MeshNode * n3,
553 const SMDS_MeshNode * n4,
554 const SMDS_MeshNode * n5,
555 const SMDS_MeshNode * n6)
557 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1, n2, n3, n4, n5, n6);
558 if(anElem) myScript->AddVolume(anElem->GetID(),
568 //=======================================================================
569 //function :AddVolume
571 //=======================================================================
572 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3, int n4, int n5, int n6, int n7, int n8, int ID)
574 SMDS_MeshVolume *anElem= SMDS_Mesh::AddVolumeWithID(n1, n2, n3, n4, n5, n6, n7, n8, ID);
575 if(anElem) myScript->AddVolume(ID, n1, n2, n3, n4, n5, n6, n7, n8);
579 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
580 const SMDS_MeshNode * n2,
581 const SMDS_MeshNode * n3,
582 const SMDS_MeshNode * n4,
583 const SMDS_MeshNode * n5,
584 const SMDS_MeshNode * n6,
585 const SMDS_MeshNode * n7,
586 const SMDS_MeshNode * n8,
589 return AddVolumeWithID(n1->GetID(),
600 SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
601 const SMDS_MeshNode * n2,
602 const SMDS_MeshNode * n3,
603 const SMDS_MeshNode * n4,
604 const SMDS_MeshNode * n5,
605 const SMDS_MeshNode * n6,
606 const SMDS_MeshNode * n7,
607 const SMDS_MeshNode * n8)
609 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1, n2, n3, n4, n5, n6, n7, n8);
610 if(anElem) myScript->AddVolume(anElem->GetID(),
623 //=======================================================================
624 //function :AddVolume
625 //purpose : add hexagonal prism
626 //=======================================================================
627 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3, int n4,
628 int n5, int n6, int n7, int n8,
629 int n9, int n10, int n11, int n12,
632 SMDS_MeshVolume *anElem= SMDS_Mesh::AddVolumeWithID(n1, n2, n3, n4, n5, n6, n7, n8, n9, n10, n11, n12, ID);
633 if(anElem) myScript->AddVolume(ID, n1, n2, n3, n4, n5, n6, n7, n8, n9, n10, n11, n12);
637 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
638 const SMDS_MeshNode * n2,
639 const SMDS_MeshNode * n3,
640 const SMDS_MeshNode * n4,
641 const SMDS_MeshNode * n5,
642 const SMDS_MeshNode * n6,
643 const SMDS_MeshNode * n7,
644 const SMDS_MeshNode * n8,
645 const SMDS_MeshNode * n9,
646 const SMDS_MeshNode * n10,
647 const SMDS_MeshNode * n11,
648 const SMDS_MeshNode * n12,
651 return AddVolumeWithID(n1->GetID(),
666 SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
667 const SMDS_MeshNode * n2,
668 const SMDS_MeshNode * n3,
669 const SMDS_MeshNode * n4,
670 const SMDS_MeshNode * n5,
671 const SMDS_MeshNode * n6,
672 const SMDS_MeshNode * n7,
673 const SMDS_MeshNode * n8,
674 const SMDS_MeshNode * n9,
675 const SMDS_MeshNode * n10,
676 const SMDS_MeshNode * n11,
677 const SMDS_MeshNode * n12)
679 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1, n2, n3, n4, n5, n6, n7, n8, n9, n10, n11, n12);
680 if(anElem) myScript->AddVolume(anElem->GetID(),
697 //=======================================================================
698 //function : AddPolygonalFace
700 //=======================================================================
701 SMDS_MeshFace* SMESHDS_Mesh::AddPolygonalFaceWithID (const std::vector<int>& nodes_ids,
704 SMDS_MeshFace *anElem = SMDS_Mesh::AddPolygonalFaceWithID(nodes_ids, ID);
706 myScript->AddPolygonalFace(ID, nodes_ids);
712 SMESHDS_Mesh::AddPolygonalFaceWithID (const std::vector<const SMDS_MeshNode*>& nodes,
715 SMDS_MeshFace *anElem = SMDS_Mesh::AddPolygonalFaceWithID(nodes, ID);
717 int i, len = nodes.size();
718 std::vector<int> nodes_ids (len);
719 for (i = 0; i < len; i++) {
720 nodes_ids[i] = nodes[i]->GetID();
722 myScript->AddPolygonalFace(ID, nodes_ids);
728 SMESHDS_Mesh::AddPolygonalFace (const std::vector<const SMDS_MeshNode*>& nodes)
730 SMDS_MeshFace *anElem = SMDS_Mesh::AddPolygonalFace(nodes);
732 int i, len = nodes.size();
733 std::vector<int> nodes_ids (len);
734 for (i = 0; i < len; i++) {
735 nodes_ids[i] = nodes[i]->GetID();
737 myScript->AddPolygonalFace(anElem->GetID(), nodes_ids);
743 //=======================================================================
744 //function : AddQuadPolygonalFace
746 //=======================================================================
747 SMDS_MeshFace* SMESHDS_Mesh::AddQuadPolygonalFaceWithID (const std::vector<int>& nodes_ids,
750 SMDS_MeshFace *anElem = SMDS_Mesh::AddQuadPolygonalFaceWithID(nodes_ids, ID);
752 myScript->AddQuadPolygonalFace(ID, nodes_ids);
758 SMESHDS_Mesh::AddQuadPolygonalFaceWithID (const std::vector<const SMDS_MeshNode*>& nodes,
761 SMDS_MeshFace *anElem = SMDS_Mesh::AddQuadPolygonalFaceWithID(nodes, ID);
763 int i, len = nodes.size();
764 std::vector<int> nodes_ids (len);
765 for (i = 0; i < len; i++) {
766 nodes_ids[i] = nodes[i]->GetID();
768 myScript->AddQuadPolygonalFace(ID, nodes_ids);
774 SMESHDS_Mesh::AddQuadPolygonalFace (const std::vector<const SMDS_MeshNode*>& nodes)
776 SMDS_MeshFace *anElem = SMDS_Mesh::AddQuadPolygonalFace(nodes);
778 int i, len = nodes.size();
779 std::vector<int> nodes_ids (len);
780 for (i = 0; i < len; i++) {
781 nodes_ids[i] = nodes[i]->GetID();
783 myScript->AddQuadPolygonalFace(anElem->GetID(), nodes_ids);
789 //=======================================================================
790 //function : AddPolyhedralVolume
792 //=======================================================================
793 SMDS_MeshVolume* SMESHDS_Mesh::AddPolyhedralVolumeWithID (const std::vector<int>& nodes_ids,
794 const std::vector<int>& quantities,
797 SMDS_MeshVolume *anElem = SMDS_Mesh::AddPolyhedralVolumeWithID(nodes_ids, quantities, ID);
799 myScript->AddPolyhedralVolume(ID, nodes_ids, quantities);
804 SMDS_MeshVolume* SMESHDS_Mesh::AddPolyhedralVolumeWithID
805 (const std::vector<const SMDS_MeshNode*>& nodes,
806 const std::vector<int>& quantities,
809 SMDS_MeshVolume *anElem = SMDS_Mesh::AddPolyhedralVolumeWithID(nodes, quantities, ID);
811 int i, len = nodes.size();
812 std::vector<int> nodes_ids (len);
813 for (i = 0; i < len; i++) {
814 nodes_ids[i] = nodes[i]->GetID();
816 myScript->AddPolyhedralVolume(ID, nodes_ids, quantities);
821 SMDS_MeshVolume* SMESHDS_Mesh::AddPolyhedralVolume
822 (const std::vector<const SMDS_MeshNode*>& nodes,
823 const std::vector<int>& quantities)
825 SMDS_MeshVolume *anElem = SMDS_Mesh::AddPolyhedralVolume(nodes, quantities);
827 int i, len = nodes.size();
828 std::vector<int> nodes_ids (len);
829 for (i = 0; i < len; i++) {
830 nodes_ids[i] = nodes[i]->GetID();
832 myScript->AddPolyhedralVolume(anElem->GetID(), nodes_ids, quantities);
837 //=======================================================================
838 //function : removeFromContainers
840 //=======================================================================
842 static void removeFromContainers (SMESHDS_Mesh* theMesh,
843 set<SMESHDS_GroupBase*>& theGroups,
844 list<const SMDS_MeshElement*>& theElems,
847 if ( theElems.empty() )
851 // Element can belong to several groups
852 if ( !theGroups.empty() )
854 set<SMESHDS_GroupBase*>::iterator GrIt = theGroups.begin();
855 for ( ; GrIt != theGroups.end(); GrIt++ )
857 SMESHDS_Group* group = dynamic_cast<SMESHDS_Group*>( *GrIt );
858 if ( !group || group->IsEmpty() ) continue;
860 list<const SMDS_MeshElement *>::iterator elIt = theElems.begin();
861 for ( ; elIt != theElems.end(); elIt++ )
863 group->SMDSGroup().Remove( *elIt );
864 if ( group->IsEmpty() ) break;
869 const bool deleted=true;
871 // Rm from sub-meshes
872 // Element should belong to only one sub-mesh
873 if ( theMesh->SubMeshes()->more() )
875 list<const SMDS_MeshElement *>::iterator elIt = theElems.begin();
877 for ( ; elIt != theElems.end(); ++elIt )
878 if ( SMESHDS_SubMesh* sm = theMesh->MeshElements( (*elIt)->getshapeId() ))
879 sm->RemoveNode( static_cast<const SMDS_MeshNode*> (*elIt), deleted );
882 for ( ; elIt != theElems.end(); ++elIt )
883 if ( SMESHDS_SubMesh* sm = theMesh->MeshElements( (*elIt)->getshapeId() ))
884 sm->RemoveElement( *elIt, deleted );
889 //=======================================================================
890 //function : RemoveNode
892 //=======================================================================
893 void SMESHDS_Mesh::RemoveNode(const SMDS_MeshNode * n)
895 if ( n->NbInverseElements() == 0 && !(hasConstructionEdges() || hasConstructionFaces()))
897 SMESHDS_SubMesh* subMesh = MeshElements( n->getshapeId() );
898 SMESHDS_SubMeshIteratorPtr subIt;
901 for ( ; !subMesh && subIt->more(); ) {
902 subMesh = const_cast< SMESHDS_SubMesh* >( subIt->next() );
903 if ( subMesh->IsComplexSubmesh() || !subMesh->Contains( n ))
906 RemoveFreeNode( n, subMesh, true);
910 myScript->RemoveNode(n->GetID());
912 list<const SMDS_MeshElement *> removedElems;
913 list<const SMDS_MeshElement *> removedNodes;
915 SMDS_Mesh::RemoveElement( n, removedElems, removedNodes, true );
917 removeFromContainers( this, myGroups, removedElems, false );
918 removeFromContainers( this, myGroups, removedNodes, true );
921 //=======================================================================
922 //function : RemoveFreeNode
924 //=======================================================================
925 void SMESHDS_Mesh::RemoveFreeNode(const SMDS_MeshNode * n,
926 SMESHDS_SubMesh * subMesh,
929 myScript->RemoveNode(n->GetID());
932 // Node can belong to several groups
933 if (fromGroups && !myGroups.empty()) {
934 set<SMESHDS_GroupBase*>::iterator GrIt = myGroups.begin();
935 for (; GrIt != myGroups.end(); GrIt++) {
936 SMESHDS_Group* group = dynamic_cast<SMESHDS_Group*>(*GrIt);
937 if (group && !group->IsEmpty())
938 group->SMDSGroup().Remove(n);
943 // Node should belong to only one sub-mesh
944 if ( !subMesh || !subMesh->RemoveNode(n,/*deleted=*/false))
945 if (( subMesh = MeshElements( n->getshapeId() )))
946 subMesh->RemoveNode(n,/*deleted=*/false );
948 SMDS_Mesh::RemoveFreeElement(n);
951 //=======================================================================
952 //function : RemoveElement
954 //========================================================================
955 void SMESHDS_Mesh::RemoveElement(const SMDS_MeshElement * elt)
957 if (elt->GetType() == SMDSAbs_Node)
959 RemoveNode( static_cast<const SMDS_MeshNode*>( elt ));
962 if (!hasConstructionEdges() && !hasConstructionFaces())
964 SMESHDS_SubMesh* subMesh=0;
965 if ( elt->getshapeId() > 0 )
966 subMesh = MeshElements( elt->getshapeId() );
968 RemoveFreeElement( elt, subMesh, true);
972 myScript->RemoveElement(elt->GetID());
974 list<const SMDS_MeshElement *> removedElems;
975 list<const SMDS_MeshElement *> removedNodes;
977 SMDS_Mesh::RemoveElement(elt, removedElems, removedNodes, false);
979 removeFromContainers( this, myGroups, removedElems, false );
982 //=======================================================================
983 //function : RemoveFreeElement
985 //========================================================================
986 void SMESHDS_Mesh::RemoveFreeElement(const SMDS_MeshElement * elt,
987 SMESHDS_SubMesh * subMesh,
990 //MESSAGE(" --------------------------------> SMESHDS_Mesh::RemoveFreeElement " << subMesh << " " << fromGroups);
991 if (elt->GetType() == SMDSAbs_Node) {
992 RemoveFreeNode( static_cast<const SMDS_MeshNode*>(elt), subMesh);
996 if (hasConstructionEdges() || hasConstructionFaces())
997 // this methods is only for meshes without descendants
1000 myScript->RemoveElement(elt->GetID());
1003 // Node can belong to several groups
1004 if ( fromGroups && !myGroups.empty() ) {
1005 set<SMESHDS_GroupBase*>::iterator GrIt = myGroups.begin();
1006 for (; GrIt != myGroups.end(); GrIt++) {
1007 SMESHDS_Group* group = dynamic_cast<SMESHDS_Group*>(*GrIt);
1008 if (group && !group->IsEmpty())
1009 group->SMDSGroup().Remove(elt);
1014 // Element should belong to only one sub-mesh
1016 subMesh->RemoveElement(elt, /*deleted=*/false);
1018 SMDS_Mesh::RemoveFreeElement(elt);
1021 //================================================================================
1023 * \brief Remove all data from the mesh
1025 //================================================================================
1027 void SMESHDS_Mesh::ClearMesh()
1029 myScript->ClearMesh();
1033 SMESHDS_SubMeshIteratorPtr smIt = SubMeshes();
1034 while ( SMESHDS_SubMesh* sm = const_cast< SMESHDS_SubMesh* >( smIt->next() ))
1038 TGroups::iterator group, groupEnd = myGroups.end();
1039 for ( group = myGroups.begin(); group != groupEnd; ++group ) {
1040 if ( SMESHDS_Group* g = dynamic_cast<SMESHDS_Group*>(*group)) {
1041 SMDSAbs_ElementType groupType = g->GetType();
1043 g->SetType( groupType );
1047 (*group)->Extent(); // to free cashed elements in GroupOnFilter's
1052 //================================================================================
1054 * \brief return submesh by shape
1055 * \param shape - the sub-shape
1056 * \retval SMESHDS_SubMesh* - the found submesh
1058 //================================================================================
1060 SMESHDS_SubMesh* SMESHDS_Mesh::getSubmesh( const TopoDS_Shape & shape )
1062 if ( shape.IsNull() )
1065 return NewSubMesh( ShapeToIndex( shape ));
1068 //================================================================================
1070 * \brief Add element or node to submesh
1071 * \param elem - element to add
1072 * \param subMesh - submesh to be filled in
1074 //================================================================================
1076 bool SMESHDS_Mesh::add(const SMDS_MeshElement* elem, SMESHDS_SubMesh* subMesh )
1078 if ( elem && subMesh ) {
1079 if ( elem->GetType() == SMDSAbs_Node )
1080 subMesh->AddNode( static_cast<const SMDS_MeshNode* >( elem ));
1082 subMesh->AddElement( elem );
1088 //=======================================================================
1089 //function : SetNodeOnVolume
1091 //=======================================================================
1092 void SMESHDS_Mesh::SetNodeInVolume(const SMDS_MeshNode* aNode,
1093 const TopoDS_Shell & S)
1095 if ( add( aNode, getSubmesh(S) ))
1096 const_cast< SMDS_MeshNode* >
1097 ( aNode )->SetPosition( SMDS_SpacePosition::originSpacePosition() );
1100 //=======================================================================
1101 //function : SetNodeOnVolume
1103 //=======================================================================
1104 void SMESHDS_Mesh::SetNodeInVolume(const SMDS_MeshNode * aNode,
1105 const TopoDS_Solid & S)
1107 if ( add( aNode, getSubmesh(S) ))
1108 const_cast< SMDS_MeshNode* >
1109 ( aNode )->SetPosition( SMDS_SpacePosition::originSpacePosition() );
1112 //=======================================================================
1113 //function : SetNodeOnFace
1115 //=======================================================================
1116 void SMESHDS_Mesh::SetNodeOnFace(const SMDS_MeshNode * aNode,
1117 const TopoDS_Face & S,
1121 if ( add( aNode, getSubmesh(S) ))
1122 const_cast< SMDS_MeshNode* >
1123 ( aNode )->SetPosition(SMDS_PositionPtr(new SMDS_FacePosition( u, v)));
1126 //=======================================================================
1127 //function : SetNodeOnEdge
1129 //=======================================================================
1130 void SMESHDS_Mesh::SetNodeOnEdge(const SMDS_MeshNode * aNode,
1131 const TopoDS_Edge & S,
1134 if ( add( aNode, getSubmesh(S) ))
1135 const_cast< SMDS_MeshNode* >
1136 ( aNode )->SetPosition(SMDS_PositionPtr(new SMDS_EdgePosition(u)));
1139 //=======================================================================
1140 //function : SetNodeOnVertex
1142 //=======================================================================
1143 void SMESHDS_Mesh::SetNodeOnVertex(const SMDS_MeshNode * aNode,
1144 const TopoDS_Vertex & S)
1146 if ( add( aNode, getSubmesh(S) ))
1147 const_cast< SMDS_MeshNode* >
1148 ( aNode )->SetPosition(SMDS_PositionPtr(new SMDS_VertexPosition()));
1151 //=======================================================================
1152 //function : UnSetNodeOnShape
1154 //=======================================================================
1155 void SMESHDS_Mesh::UnSetNodeOnShape(const SMDS_MeshNode* aNode)
1157 int shapeId = aNode->getshapeId();
1159 if ( SMESHDS_SubMesh* sm = MeshElements( shapeId ))
1160 sm->RemoveNode(aNode, /*deleted=*/false);
1163 //=======================================================================
1164 //function : SetMeshElementOnShape
1166 //=======================================================================
1167 void SMESHDS_Mesh::SetMeshElementOnShape(const SMDS_MeshElement * anElement,
1168 const TopoDS_Shape & S)
1170 add( anElement, getSubmesh(S) );
1173 //=======================================================================
1174 //function : UnSetMeshElementOnShape
1176 //=======================================================================
1177 void SMESHDS_Mesh::UnSetMeshElementOnShape(const SMDS_MeshElement * elem,
1178 const TopoDS_Shape & S)
1180 if ( SMESHDS_SubMesh* sm = MeshElements( S ))
1182 if (elem->GetType() == SMDSAbs_Node)
1183 sm->RemoveNode(static_cast<const SMDS_MeshNode*> (elem), /*deleted=*/false);
1185 sm->RemoveElement(elem, /*deleted=*/false);
1189 //=======================================================================
1190 //function : ShapeToMesh
1192 //=======================================================================
1193 TopoDS_Shape SMESHDS_Mesh::ShapeToMesh() const
1198 //=======================================================================
1199 //function : IsGroupOfSubShapes
1200 //purpose : return true if at least one sub-shape of theShape is a sub-shape
1201 // of myShape or theShape == myShape
1202 //=======================================================================
1204 bool SMESHDS_Mesh::IsGroupOfSubShapes (const TopoDS_Shape& theShape) const
1206 if ( myIndexToShape.Contains(theShape) )
1209 for ( TopoDS_Iterator it( theShape ); it.More(); it.Next() )
1210 if (IsGroupOfSubShapes( it.Value() ))
1216 ///////////////////////////////////////////////////////////////////////////////
1217 /// Return the sub mesh linked to the a given TopoDS_Shape or NULL if the given
1218 /// TopoDS_Shape is unknown
1219 ///////////////////////////////////////////////////////////////////////////////
1220 SMESHDS_SubMesh * SMESHDS_Mesh::MeshElements(const TopoDS_Shape & S) const
1222 int Index = ShapeToIndex(S);
1223 return (SMESHDS_SubMesh *) ( Index ? mySubMeshHolder->Get( Index ) : 0 );
1226 ///////////////////////////////////////////////////////////////////////////////
1227 /// Return the sub mesh by Id of shape it is linked to
1228 ///////////////////////////////////////////////////////////////////////////////
1229 SMESHDS_SubMesh * SMESHDS_Mesh::MeshElements(const int Index) const
1231 return const_cast< SMESHDS_SubMesh* >( mySubMeshHolder->Get( Index ));
1234 //=======================================================================
1235 //function : SubMeshIndices
1237 //=======================================================================
1238 list<int> SMESHDS_Mesh::SubMeshIndices() const
1240 list<int> anIndices;
1241 SMESHDS_SubMeshIteratorPtr smIt = SubMeshes();
1242 while ( const SMESHDS_SubMesh* sm = smIt->next() )
1243 anIndices.push_back( sm->GetID() );
1248 //=======================================================================
1249 //function : SubMeshes
1251 //=======================================================================
1253 SMESHDS_SubMeshIteratorPtr SMESHDS_Mesh::SubMeshes() const
1255 return SMESHDS_SubMeshIteratorPtr( mySubMeshHolder->GetIterator() );
1258 //=======================================================================
1259 //function : GetHypothesis
1261 //=======================================================================
1263 const list<const SMESHDS_Hypothesis*>&
1264 SMESHDS_Mesh::GetHypothesis(const TopoDS_Shape & S) const
1266 if ( myShapeToHypothesis.IsBound( S/*.Oriented(TopAbs_FORWARD)*/ ) ) // ignore orientation of S
1267 return myShapeToHypothesis.Find( S/*.Oriented(TopAbs_FORWARD)*/ );
1269 static list<const SMESHDS_Hypothesis*> empty;
1273 //================================================================================
1275 * \brief returns true if the hypothesis is assigned to any sub-shape
1277 //================================================================================
1279 bool SMESHDS_Mesh::IsUsedHypothesis(const SMESHDS_Hypothesis * H) const
1281 ShapeToHypothesis::Iterator s2h( myShapeToHypothesis );
1282 for ( ; s2h.More(); s2h.Next() )
1283 if ( std::find( s2h.Value().begin(), s2h.Value().end(), H ) != s2h.Value().end() )
1288 //=======================================================================
1289 //function : GetScript
1291 //=======================================================================
1292 SMESHDS_Script* SMESHDS_Mesh::GetScript()
1297 //=======================================================================
1298 //function : ClearScript
1300 //=======================================================================
1301 void SMESHDS_Mesh::ClearScript()
1306 //=======================================================================
1307 //function : HasMeshElements
1309 //=======================================================================
1310 bool SMESHDS_Mesh::HasMeshElements(const TopoDS_Shape & S) const
1312 int Index = myIndexToShape.FindIndex(S);
1313 return mySubMeshHolder->Get( Index );
1316 //=======================================================================
1317 //function : HasHypothesis
1319 //=======================================================================
1320 bool SMESHDS_Mesh::HasHypothesis(const TopoDS_Shape & S)
1322 return myShapeToHypothesis.IsBound(S/*.Oriented(TopAbs_FORWARD)*/);
1325 //=======================================================================
1326 //function : NewSubMesh
1328 //=======================================================================
1329 SMESHDS_SubMesh * SMESHDS_Mesh::NewSubMesh(int Index)
1331 SMESHDS_SubMesh* SM = MeshElements( Index );
1334 SM = new SMESHDS_SubMesh(this, Index);
1335 mySubMeshHolder->Add( Index, SM );
1340 //=======================================================================
1341 //function : AddCompoundSubmesh
1343 //=======================================================================
1345 int SMESHDS_Mesh::AddCompoundSubmesh(const TopoDS_Shape& S,
1346 TopAbs_ShapeEnum type)
1349 if ( IsGroupOfSubShapes( S ))
1351 aMainIndex = myIndexToShape.Add( S );
1352 bool all = ( type == TopAbs_SHAPE );
1353 if ( all ) // corresponding simple submesh may exist
1354 aMainIndex = -aMainIndex;
1355 //MESSAGE("AddCompoundSubmesh index = " << aMainIndex );
1356 SMESHDS_SubMesh * aNewSub = NewSubMesh( aMainIndex );
1357 if ( !aNewSub->IsComplexSubmesh() ) // is empty
1359 int shapeType = Max( TopAbs_SOLID, all ? myShape.ShapeType() : type );
1360 int typeLimit = all ? TopAbs_VERTEX : type;
1361 for ( ; shapeType <= typeLimit; shapeType++ )
1363 TopExp_Explorer exp( S, TopAbs_ShapeEnum( shapeType ));
1364 for ( ; exp.More(); exp.Next() )
1366 int index = myIndexToShape.FindIndex( exp.Current() );
1368 aNewSub->AddSubMesh( NewSubMesh( index ));
1376 //=======================================================================
1377 //function : IndexToShape
1379 //=======================================================================
1380 const TopoDS_Shape& SMESHDS_Mesh::IndexToShape(int ShapeIndex) const
1384 if ( ShapeIndex > 0 )
1385 return myIndexToShape.FindKey(ShapeIndex);
1387 catch ( Standard_OutOfRange )
1390 static TopoDS_Shape nullShape;
1394 //================================================================================
1396 * \brief Return max index of sub-mesh
1398 //================================================================================
1400 int SMESHDS_Mesh::MaxSubMeshIndex() const
1402 return mySubMeshHolder->GetMaxID();
1405 //=======================================================================
1406 //function : ShapeToIndex
1408 //=======================================================================
1409 int SMESHDS_Mesh::ShapeToIndex(const TopoDS_Shape & S) const
1411 if (myShape.IsNull())
1412 MESSAGE("myShape is NULL");
1414 int index = myIndexToShape.FindIndex(S);
1419 //=======================================================================
1420 //function : SetNodeOnVolume
1422 //=======================================================================
1423 void SMESHDS_Mesh::SetNodeInVolume(const SMDS_MeshNode* aNode, int Index)
1425 if ( add( aNode, NewSubMesh( Index )))
1426 ((SMDS_MeshNode*) aNode)->SetPosition( SMDS_SpacePosition::originSpacePosition());
1429 //=======================================================================
1430 //function : SetNodeOnFace
1432 //=======================================================================
1433 void SMESHDS_Mesh::SetNodeOnFace(const SMDS_MeshNode* aNode, int Index, double u, double v)
1435 //Set Position on Node
1436 if ( add( aNode, NewSubMesh( Index )))
1437 const_cast< SMDS_MeshNode* >
1438 ( aNode )->SetPosition(SMDS_PositionPtr(new SMDS_FacePosition( u, v)));
1441 //=======================================================================
1442 //function : SetNodeOnEdge
1444 //=======================================================================
1445 void SMESHDS_Mesh::SetNodeOnEdge(const SMDS_MeshNode* aNode,
1449 //Set Position on Node
1450 if ( add( aNode, NewSubMesh( Index )))
1451 const_cast< SMDS_MeshNode* >
1452 ( aNode )->SetPosition(SMDS_PositionPtr(new SMDS_EdgePosition(u)));
1455 //=======================================================================
1456 //function : SetNodeOnVertex
1458 //=======================================================================
1459 void SMESHDS_Mesh::SetNodeOnVertex(const SMDS_MeshNode* aNode, int Index)
1461 //Set Position on Node
1462 if ( add( aNode, NewSubMesh( Index )))
1463 const_cast< SMDS_MeshNode* >
1464 ( aNode )->SetPosition(SMDS_PositionPtr(new SMDS_VertexPosition()));
1467 //=======================================================================
1468 //function : SetMeshElementOnShape
1470 //=======================================================================
1471 void SMESHDS_Mesh::SetMeshElementOnShape(const SMDS_MeshElement* anElement,
1474 add( anElement, NewSubMesh( Index ));
1477 //=======================================================================
1478 //function : ~SMESHDS_Mesh
1480 //=======================================================================
1481 SMESHDS_Mesh::~SMESHDS_Mesh()
1486 delete mySubMeshHolder;
1490 //********************************************************************
1491 //********************************************************************
1492 //******** *********
1493 //***** Methods for addition of quadratic elements ******
1494 //******** *********
1495 //********************************************************************
1496 //********************************************************************
1498 //=======================================================================
1499 //function : AddEdgeWithID
1501 //=======================================================================
1502 SMDS_MeshEdge* SMESHDS_Mesh::AddEdgeWithID(int n1, int n2, int n12, int ID)
1504 SMDS_MeshEdge* anElem = SMDS_Mesh::AddEdgeWithID(n1,n2,n12,ID);
1505 if(anElem) myScript->AddEdge(ID,n1,n2,n12);
1509 //=======================================================================
1510 //function : AddEdge
1512 //=======================================================================
1513 SMDS_MeshEdge* SMESHDS_Mesh::AddEdge(const SMDS_MeshNode* n1,
1514 const SMDS_MeshNode* n2,
1515 const SMDS_MeshNode* n12)
1517 SMDS_MeshEdge* anElem = SMDS_Mesh::AddEdge(n1,n2,n12);
1518 if(anElem) myScript->AddEdge(anElem->GetID(),
1525 //=======================================================================
1526 //function : AddEdgeWithID
1528 //=======================================================================
1529 SMDS_MeshEdge* SMESHDS_Mesh::AddEdgeWithID(const SMDS_MeshNode * n1,
1530 const SMDS_MeshNode * n2,
1531 const SMDS_MeshNode * n12,
1534 return AddEdgeWithID(n1->GetID(),
1541 //=======================================================================
1542 //function : AddFace
1544 //=======================================================================
1545 SMDS_MeshFace* SMESHDS_Mesh::AddFace(const SMDS_MeshNode * n1,
1546 const SMDS_MeshNode * n2,
1547 const SMDS_MeshNode * n3,
1548 const SMDS_MeshNode * n12,
1549 const SMDS_MeshNode * n23,
1550 const SMDS_MeshNode * n31)
1552 SMDS_MeshFace *anElem = SMDS_Mesh::AddFace(n1,n2,n3,n12,n23,n31);
1553 if(anElem) myScript->AddFace(anElem->GetID(),
1554 n1->GetID(), n2->GetID(), n3->GetID(),
1555 n12->GetID(), n23->GetID(), n31->GetID());
1559 //=======================================================================
1560 //function : AddFaceWithID
1562 //=======================================================================
1563 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(int n1, int n2, int n3,
1564 int n12,int n23,int n31, int ID)
1566 SMDS_MeshFace *anElem = SMDS_Mesh::AddFaceWithID(n1,n2,n3,n12,n23,n31,ID);
1567 if(anElem) myScript->AddFace(ID,n1,n2,n3,n12,n23,n31);
1571 //=======================================================================
1572 //function : AddFaceWithID
1574 //=======================================================================
1575 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(const SMDS_MeshNode * n1,
1576 const SMDS_MeshNode * n2,
1577 const SMDS_MeshNode * n3,
1578 const SMDS_MeshNode * n12,
1579 const SMDS_MeshNode * n23,
1580 const SMDS_MeshNode * n31,
1583 return AddFaceWithID(n1->GetID(), n2->GetID(), n3->GetID(),
1584 n12->GetID(), n23->GetID(), n31->GetID(),
1588 //=======================================================================
1589 //function : AddFace
1591 //=======================================================================
1592 SMDS_MeshFace* SMESHDS_Mesh::AddFace(const SMDS_MeshNode * n1,
1593 const SMDS_MeshNode * n2,
1594 const SMDS_MeshNode * n3,
1595 const SMDS_MeshNode * n12,
1596 const SMDS_MeshNode * n23,
1597 const SMDS_MeshNode * n31,
1598 const SMDS_MeshNode * nCenter)
1600 SMDS_MeshFace *anElem = SMDS_Mesh::AddFace(n1,n2,n3,n12,n23,n31,nCenter);
1601 if(anElem) myScript->AddFace(anElem->GetID(),
1602 n1->GetID(), n2->GetID(), n3->GetID(),
1603 n12->GetID(), n23->GetID(), n31->GetID(),
1608 //=======================================================================
1609 //function : AddFaceWithID
1611 //=======================================================================
1612 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(int n1, int n2, int n3,
1613 int n12,int n23,int n31, int nCenter, int ID)
1615 SMDS_MeshFace *anElem = SMDS_Mesh::AddFaceWithID(n1,n2,n3,n12,n23,n31,nCenter,ID);
1616 if(anElem) myScript->AddFace(ID,n1,n2,n3,n12,n23,n31,nCenter);
1620 //=======================================================================
1621 //function : AddFaceWithID
1623 //=======================================================================
1624 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(const SMDS_MeshNode * n1,
1625 const SMDS_MeshNode * n2,
1626 const SMDS_MeshNode * n3,
1627 const SMDS_MeshNode * n12,
1628 const SMDS_MeshNode * n23,
1629 const SMDS_MeshNode * n31,
1630 const SMDS_MeshNode * nCenter,
1633 return AddFaceWithID(n1->GetID(), n2->GetID(), n3->GetID(),
1634 n12->GetID(), n23->GetID(), n31->GetID(),
1635 nCenter->GetID(), ID);
1639 //=======================================================================
1640 //function : AddFace
1642 //=======================================================================
1643 SMDS_MeshFace* SMESHDS_Mesh::AddFace(const SMDS_MeshNode * n1,
1644 const SMDS_MeshNode * n2,
1645 const SMDS_MeshNode * n3,
1646 const SMDS_MeshNode * n4,
1647 const SMDS_MeshNode * n12,
1648 const SMDS_MeshNode * n23,
1649 const SMDS_MeshNode * n34,
1650 const SMDS_MeshNode * n41)
1652 SMDS_MeshFace *anElem = SMDS_Mesh::AddFace(n1,n2,n3,n4,n12,n23,n34,n41);
1653 if(anElem) myScript->AddFace(anElem->GetID(),
1654 n1->GetID(), n2->GetID(), n3->GetID(), n4->GetID(),
1655 n12->GetID(), n23->GetID(), n34->GetID(), n41->GetID());
1659 //=======================================================================
1660 //function : AddFaceWithID
1662 //=======================================================================
1663 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(int n1, int n2, int n3, int n4,
1664 int n12,int n23,int n34,int n41, int ID)
1666 SMDS_MeshFace *anElem = SMDS_Mesh::AddFaceWithID(n1,n2,n3,n4,n12,n23,n34,n41,ID);
1667 if(anElem) myScript->AddFace(ID,n1,n2,n3,n4,n12,n23,n34,n41);
1671 //=======================================================================
1672 //function : AddFaceWithID
1674 //=======================================================================
1675 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(const SMDS_MeshNode * n1,
1676 const SMDS_MeshNode * n2,
1677 const SMDS_MeshNode * n3,
1678 const SMDS_MeshNode * n4,
1679 const SMDS_MeshNode * n12,
1680 const SMDS_MeshNode * n23,
1681 const SMDS_MeshNode * n34,
1682 const SMDS_MeshNode * n41,
1685 return AddFaceWithID(n1->GetID(), n2->GetID(), n3->GetID(), n4->GetID(),
1686 n12->GetID(), n23->GetID(), n34->GetID(), n41->GetID(),
1691 //=======================================================================
1692 //function : AddFace
1694 //=======================================================================
1695 SMDS_MeshFace* SMESHDS_Mesh::AddFace(const SMDS_MeshNode * n1,
1696 const SMDS_MeshNode * n2,
1697 const SMDS_MeshNode * n3,
1698 const SMDS_MeshNode * n4,
1699 const SMDS_MeshNode * n12,
1700 const SMDS_MeshNode * n23,
1701 const SMDS_MeshNode * n34,
1702 const SMDS_MeshNode * n41,
1703 const SMDS_MeshNode * nCenter)
1705 SMDS_MeshFace *anElem = SMDS_Mesh::AddFace(n1,n2,n3,n4,n12,n23,n34,n41,nCenter);
1706 if(anElem) myScript->AddFace(anElem->GetID(),
1707 n1->GetID(), n2->GetID(), n3->GetID(), n4->GetID(),
1708 n12->GetID(), n23->GetID(), n34->GetID(), n41->GetID(),
1713 //=======================================================================
1714 //function : AddFaceWithID
1716 //=======================================================================
1717 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(int n1, int n2, int n3, int n4,
1718 int n12,int n23,int n34,int n41,
1719 int nCenter, int ID)
1721 SMDS_MeshFace *anElem = SMDS_Mesh::AddFaceWithID(n1,n2,n3,n4,n12,n23,n34,n41,nCenter,ID);
1722 if(anElem) myScript->AddFace(ID,n1,n2,n3,n4,n12,n23,n34,n41,nCenter);
1726 //=======================================================================
1727 //function : AddFaceWithID
1729 //=======================================================================
1730 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(const SMDS_MeshNode * n1,
1731 const SMDS_MeshNode * n2,
1732 const SMDS_MeshNode * n3,
1733 const SMDS_MeshNode * n4,
1734 const SMDS_MeshNode * n12,
1735 const SMDS_MeshNode * n23,
1736 const SMDS_MeshNode * n34,
1737 const SMDS_MeshNode * n41,
1738 const SMDS_MeshNode * nCenter,
1741 return AddFaceWithID(n1->GetID(), n2->GetID(), n3->GetID(), n4->GetID(),
1742 n12->GetID(), n23->GetID(), n34->GetID(), n41->GetID(),
1743 nCenter->GetID(), ID);
1747 //=======================================================================
1748 //function : AddVolume
1750 //=======================================================================
1751 SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
1752 const SMDS_MeshNode * n2,
1753 const SMDS_MeshNode * n3,
1754 const SMDS_MeshNode * n4,
1755 const SMDS_MeshNode * n12,
1756 const SMDS_MeshNode * n23,
1757 const SMDS_MeshNode * n31,
1758 const SMDS_MeshNode * n14,
1759 const SMDS_MeshNode * n24,
1760 const SMDS_MeshNode * n34)
1762 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1,n2,n3,n4,n12,n23,n31,n14,n24,n34);
1763 if(anElem) myScript->AddVolume(anElem->GetID(),
1764 n1->GetID(), n2->GetID(), n3->GetID(), n4->GetID(),
1765 n12->GetID(), n23->GetID(), n31->GetID(),
1766 n14->GetID(), n24->GetID(), n34->GetID());
1770 //=======================================================================
1771 //function : AddVolumeWithID
1773 //=======================================================================
1774 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3, int n4,
1775 int n12,int n23,int n31,
1776 int n14,int n24,int n34, int ID)
1778 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolumeWithID(n1,n2,n3,n4,n12,n23,
1779 n31,n14,n24,n34,ID);
1780 if(anElem) myScript->AddVolume(ID,n1,n2,n3,n4,n12,n23,n31,n14,n24,n34);
1784 //=======================================================================
1785 //function : AddVolumeWithID
1786 //purpose : 2d order tetrahedron of 10 nodes
1787 //=======================================================================
1788 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
1789 const SMDS_MeshNode * n2,
1790 const SMDS_MeshNode * n3,
1791 const SMDS_MeshNode * n4,
1792 const SMDS_MeshNode * n12,
1793 const SMDS_MeshNode * n23,
1794 const SMDS_MeshNode * n31,
1795 const SMDS_MeshNode * n14,
1796 const SMDS_MeshNode * n24,
1797 const SMDS_MeshNode * n34,
1800 return AddVolumeWithID(n1->GetID(), n2->GetID(), n3->GetID(), n4->GetID(),
1801 n12->GetID(), n23->GetID(), n31->GetID(),
1802 n14->GetID(), n24->GetID(), n34->GetID(), ID);
1806 //=======================================================================
1807 //function : AddVolume
1809 //=======================================================================
1810 SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
1811 const SMDS_MeshNode * n2,
1812 const SMDS_MeshNode * n3,
1813 const SMDS_MeshNode * n4,
1814 const SMDS_MeshNode * n5,
1815 const SMDS_MeshNode * n12,
1816 const SMDS_MeshNode * n23,
1817 const SMDS_MeshNode * n34,
1818 const SMDS_MeshNode * n41,
1819 const SMDS_MeshNode * n15,
1820 const SMDS_MeshNode * n25,
1821 const SMDS_MeshNode * n35,
1822 const SMDS_MeshNode * n45)
1824 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1,n2,n3,n4,n5,n12,n23,n34,n41,
1827 myScript->AddVolume(anElem->GetID(), n1->GetID(), n2->GetID(),
1828 n3->GetID(), n4->GetID(), n5->GetID(),
1829 n12->GetID(), n23->GetID(), n34->GetID(), n41->GetID(),
1830 n15->GetID(), n25->GetID(), n35->GetID(), n45->GetID());
1834 //=======================================================================
1835 //function : AddVolumeWithID
1837 //=======================================================================
1838 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3, int n4, int n5,
1839 int n12,int n23,int n34,int n41,
1840 int n15,int n25,int n35,int n45, int ID)
1842 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolumeWithID(n1,n2,n3,n4,n5,
1844 n15,n25,n35,n45,ID);
1845 if(anElem) myScript->AddVolume(ID,n1,n2,n3,n4,n5,n12,n23,n34,n41,
1850 //=======================================================================
1851 //function : AddVolumeWithID
1852 //purpose : 2d order pyramid of 13 nodes
1853 //=======================================================================
1854 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
1855 const SMDS_MeshNode * n2,
1856 const SMDS_MeshNode * n3,
1857 const SMDS_MeshNode * n4,
1858 const SMDS_MeshNode * n5,
1859 const SMDS_MeshNode * n12,
1860 const SMDS_MeshNode * n23,
1861 const SMDS_MeshNode * n34,
1862 const SMDS_MeshNode * n41,
1863 const SMDS_MeshNode * n15,
1864 const SMDS_MeshNode * n25,
1865 const SMDS_MeshNode * n35,
1866 const SMDS_MeshNode * n45,
1869 return AddVolumeWithID(n1->GetID(), n2->GetID(), n3->GetID(),
1870 n4->GetID(), n5->GetID(),
1871 n12->GetID(), n23->GetID(), n34->GetID(), n41->GetID(),
1872 n15->GetID(), n25->GetID(), n35->GetID(), n45->GetID(),
1877 //=======================================================================
1878 //function : AddVolume
1880 //=======================================================================
1881 SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
1882 const SMDS_MeshNode * n2,
1883 const SMDS_MeshNode * n3,
1884 const SMDS_MeshNode * n4,
1885 const SMDS_MeshNode * n5,
1886 const SMDS_MeshNode * n6,
1887 const SMDS_MeshNode * n12,
1888 const SMDS_MeshNode * n23,
1889 const SMDS_MeshNode * n31,
1890 const SMDS_MeshNode * n45,
1891 const SMDS_MeshNode * n56,
1892 const SMDS_MeshNode * n64,
1893 const SMDS_MeshNode * n14,
1894 const SMDS_MeshNode * n25,
1895 const SMDS_MeshNode * n36)
1897 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1,n2,n3,n4,n5,n6,n12,n23,n31,
1898 n45,n56,n64,n14,n25,n36);
1900 myScript->AddVolume(anElem->GetID(), n1->GetID(), n2->GetID(),
1901 n3->GetID(), n4->GetID(), n5->GetID(), n6->GetID(),
1902 n12->GetID(), n23->GetID(), n31->GetID(),
1903 n45->GetID(), n56->GetID(), n64->GetID(),
1904 n14->GetID(), n25->GetID(), n36->GetID());
1908 //=======================================================================
1909 //function : AddVolumeWithID
1911 //=======================================================================
1912 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3,
1913 int n4, int n5, int n6,
1914 int n12,int n23,int n31,
1915 int n45,int n56,int n64,
1916 int n14,int n25,int n36, int ID)
1918 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolumeWithID(n1,n2,n3,n4,n5,n6,
1922 if(anElem) myScript->AddVolume(ID,n1,n2,n3,n4,n5,n6,n12,n23,n31,
1923 n45,n56,n64,n14,n25,n36);
1927 //=======================================================================
1928 //function : AddVolumeWithID
1929 //purpose : 2d order Pentahedron with 15 nodes
1930 //=======================================================================
1931 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
1932 const SMDS_MeshNode * n2,
1933 const SMDS_MeshNode * n3,
1934 const SMDS_MeshNode * n4,
1935 const SMDS_MeshNode * n5,
1936 const SMDS_MeshNode * n6,
1937 const SMDS_MeshNode * n12,
1938 const SMDS_MeshNode * n23,
1939 const SMDS_MeshNode * n31,
1940 const SMDS_MeshNode * n45,
1941 const SMDS_MeshNode * n56,
1942 const SMDS_MeshNode * n64,
1943 const SMDS_MeshNode * n14,
1944 const SMDS_MeshNode * n25,
1945 const SMDS_MeshNode * n36,
1948 return AddVolumeWithID(n1->GetID(), n2->GetID(), n3->GetID(),
1949 n4->GetID(), n5->GetID(), n6->GetID(),
1950 n12->GetID(), n23->GetID(), n31->GetID(),
1951 n45->GetID(), n56->GetID(), n64->GetID(),
1952 n14->GetID(), n25->GetID(), n36->GetID(),
1957 //=======================================================================
1958 //function : AddVolume
1959 //purpose : add quadratic hexahedron
1960 //=======================================================================
1961 SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
1962 const SMDS_MeshNode * n2,
1963 const SMDS_MeshNode * n3,
1964 const SMDS_MeshNode * n4,
1965 const SMDS_MeshNode * n5,
1966 const SMDS_MeshNode * n6,
1967 const SMDS_MeshNode * n7,
1968 const SMDS_MeshNode * n8,
1969 const SMDS_MeshNode * n12,
1970 const SMDS_MeshNode * n23,
1971 const SMDS_MeshNode * n34,
1972 const SMDS_MeshNode * n41,
1973 const SMDS_MeshNode * n56,
1974 const SMDS_MeshNode * n67,
1975 const SMDS_MeshNode * n78,
1976 const SMDS_MeshNode * n85,
1977 const SMDS_MeshNode * n15,
1978 const SMDS_MeshNode * n26,
1979 const SMDS_MeshNode * n37,
1980 const SMDS_MeshNode * n48)
1982 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1,n2,n3,n4,n5,n6,n7,n8,
1987 myScript->AddVolume(anElem->GetID(), n1->GetID(), n2->GetID(),
1988 n3->GetID(), n4->GetID(), n5->GetID(),
1989 n6->GetID(), n7->GetID(), n8->GetID(),
1990 n12->GetID(), n23->GetID(), n34->GetID(), n41->GetID(),
1991 n56->GetID(), n67->GetID(), n78->GetID(), n85->GetID(),
1992 n15->GetID(), n26->GetID(), n37->GetID(), n48->GetID());
1996 //=======================================================================
1997 //function : AddVolumeWithID
1999 //=======================================================================
2000 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3, int n4,
2001 int n5, int n6, int n7, int n8,
2002 int n12,int n23,int n34,int n41,
2003 int n56,int n67,int n78,int n85,
2004 int n15,int n26,int n37,int n48, int ID)
2006 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolumeWithID(n1,n2,n3,n4,n5,n6,n7,n8,
2009 n15,n26,n37,n48,ID);
2010 if(anElem) myScript->AddVolume(ID,n1,n2,n3,n4,n5,n6,n7,n8,n12,n23,n34,n41,
2011 n56,n67,n78,n85,n15,n26,n37,n48);
2015 //=======================================================================
2016 //function : AddVolumeWithID
2017 //purpose : 2d order Hexahedrons with 20 nodes
2018 //=======================================================================
2019 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
2020 const SMDS_MeshNode * n2,
2021 const SMDS_MeshNode * n3,
2022 const SMDS_MeshNode * n4,
2023 const SMDS_MeshNode * n5,
2024 const SMDS_MeshNode * n6,
2025 const SMDS_MeshNode * n7,
2026 const SMDS_MeshNode * n8,
2027 const SMDS_MeshNode * n12,
2028 const SMDS_MeshNode * n23,
2029 const SMDS_MeshNode * n34,
2030 const SMDS_MeshNode * n41,
2031 const SMDS_MeshNode * n56,
2032 const SMDS_MeshNode * n67,
2033 const SMDS_MeshNode * n78,
2034 const SMDS_MeshNode * n85,
2035 const SMDS_MeshNode * n15,
2036 const SMDS_MeshNode * n26,
2037 const SMDS_MeshNode * n37,
2038 const SMDS_MeshNode * n48,
2041 return AddVolumeWithID(n1->GetID(), n2->GetID(), n3->GetID(), n4->GetID(),
2042 n5->GetID(), n6->GetID(), n7->GetID(), n8->GetID(),
2043 n12->GetID(), n23->GetID(), n34->GetID(), n41->GetID(),
2044 n56->GetID(), n67->GetID(), n78->GetID(), n85->GetID(),
2045 n15->GetID(), n26->GetID(), n37->GetID(), n48->GetID(),
2049 //=======================================================================
2050 //function : AddVolume
2051 //purpose : add tri-quadratic hexahedron of 27 nodes
2052 //=======================================================================
2054 SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
2055 const SMDS_MeshNode * n2,
2056 const SMDS_MeshNode * n3,
2057 const SMDS_MeshNode * n4,
2058 const SMDS_MeshNode * n5,
2059 const SMDS_MeshNode * n6,
2060 const SMDS_MeshNode * n7,
2061 const SMDS_MeshNode * n8,
2062 const SMDS_MeshNode * n12,
2063 const SMDS_MeshNode * n23,
2064 const SMDS_MeshNode * n34,
2065 const SMDS_MeshNode * n41,
2066 const SMDS_MeshNode * n56,
2067 const SMDS_MeshNode * n67,
2068 const SMDS_MeshNode * n78,
2069 const SMDS_MeshNode * n85,
2070 const SMDS_MeshNode * n15,
2071 const SMDS_MeshNode * n26,
2072 const SMDS_MeshNode * n37,
2073 const SMDS_MeshNode * n48,
2074 const SMDS_MeshNode * n1234,
2075 const SMDS_MeshNode * n1256,
2076 const SMDS_MeshNode * n2367,
2077 const SMDS_MeshNode * n3478,
2078 const SMDS_MeshNode * n1458,
2079 const SMDS_MeshNode * n5678,
2080 const SMDS_MeshNode * nCenter)
2082 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1,n2,n3,n4,n5,n6,n7,n8,
2086 n1234,n1256,n2367,n3478,n1458,n5678,nCenter);
2088 myScript->AddVolume(anElem->GetID(), n1->GetID(), n2->GetID(),
2089 n3->GetID(), n4->GetID(), n5->GetID(),
2090 n6->GetID(), n7->GetID(), n8->GetID(),
2091 n12->GetID(), n23->GetID(), n34->GetID(), n41->GetID(),
2092 n56->GetID(), n67->GetID(), n78->GetID(), n85->GetID(),
2093 n15->GetID(), n26->GetID(), n37->GetID(), n48->GetID(),
2094 n1234->GetID(),n1256->GetID(),n2367->GetID(),n3478->GetID(),
2095 n1458->GetID(),n5678->GetID(),nCenter->GetID());
2099 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3, int n4,
2100 int n5, int n6, int n7, int n8,
2101 int n12,int n23,int n34,int n41,
2102 int n56,int n67,int n78,int n85,
2103 int n15,int n26,int n37,int n48,
2104 int n1234,int n1256,int n2367,int n3478,
2105 int n1458,int n5678,int nCenter,
2108 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolumeWithID(n1,n2,n3,n4,n5,n6,n7,n8,
2112 n1234, n1256, n2367, n3478,
2113 n1458, n5678, nCenter,
2115 if(anElem) myScript->AddVolume(ID,n1,n2,n3,n4,n5,n6,n7,n8,n12,n23,n34,n41,
2116 n56,n67,n78,n85,n15,n26,n37,n48,
2117 n1234, n1256, n2367, n3478,
2118 n1458, n5678, nCenter);
2122 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
2123 const SMDS_MeshNode * n2,
2124 const SMDS_MeshNode * n3,
2125 const SMDS_MeshNode * n4,
2126 const SMDS_MeshNode * n5,
2127 const SMDS_MeshNode * n6,
2128 const SMDS_MeshNode * n7,
2129 const SMDS_MeshNode * n8,
2130 const SMDS_MeshNode * n12,
2131 const SMDS_MeshNode * n23,
2132 const SMDS_MeshNode * n34,
2133 const SMDS_MeshNode * n41,
2134 const SMDS_MeshNode * n56,
2135 const SMDS_MeshNode * n67,
2136 const SMDS_MeshNode * n78,
2137 const SMDS_MeshNode * n85,
2138 const SMDS_MeshNode * n15,
2139 const SMDS_MeshNode * n26,
2140 const SMDS_MeshNode * n37,
2141 const SMDS_MeshNode * n48,
2142 const SMDS_MeshNode * n1234,
2143 const SMDS_MeshNode * n1256,
2144 const SMDS_MeshNode * n2367,
2145 const SMDS_MeshNode * n3478,
2146 const SMDS_MeshNode * n1458,
2147 const SMDS_MeshNode * n5678,
2148 const SMDS_MeshNode * nCenter,
2151 return AddVolumeWithID(n1->GetID(), n2->GetID(), n3->GetID(), n4->GetID(),
2152 n5->GetID(), n6->GetID(), n7->GetID(), n8->GetID(),
2153 n12->GetID(), n23->GetID(), n34->GetID(), n41->GetID(),
2154 n56->GetID(), n67->GetID(), n78->GetID(), n85->GetID(),
2155 n15->GetID(), n26->GetID(), n37->GetID(), n48->GetID(),
2156 n1234->GetID(),n1256->GetID(),n2367->GetID(),n3478->GetID(),
2157 n1458->GetID(),n5678->GetID(),nCenter->GetID(), ID);
2160 void SMESHDS_Mesh::compactMesh()
2162 int newNodeSize = 0;
2163 int nbNodes = myNodes.size();
2164 int nbVtkNodes = myGrid->GetNumberOfPoints();
2165 MESSAGE("nbNodes=" << nbNodes << " nbVtkNodes=" << nbVtkNodes);
2166 int nbNodeTemp = nbVtkNodes;
2167 if (nbNodes > nbVtkNodes)
2168 nbNodeTemp = nbNodes;
2169 vector<int> idNodesOldToNew;
2170 idNodesOldToNew.clear();
2171 idNodesOldToNew.resize(nbNodeTemp, -1); // all unused id will be -1
2173 for (int i = 0; i < nbNodes; i++)
2177 int vtkid = myNodes[i]->getVtkId();
2178 idNodesOldToNew[vtkid] = i; // old vtkId --> old smdsId (valid smdsId are >= 0)
2182 bool areNodesModified = (newNodeSize < nbVtkNodes);
2183 MESSAGE("------------------------- compactMesh Nodes Modified: " << areNodesModified);
2184 areNodesModified = true;
2186 int newCellSize = 0;
2187 int nbCells = myCells.size();
2188 int nbVtkCells = myGrid->GetNumberOfCells();
2189 MESSAGE("nbCells=" << nbCells << " nbVtkCells=" << nbVtkCells);
2190 int nbCellTemp = nbVtkCells;
2191 if (nbCells > nbVtkCells)
2192 nbCellTemp = nbCells;
2193 vector<int> idCellsOldToNew;
2194 idCellsOldToNew.clear();
2195 idCellsOldToNew.resize(nbCellTemp, -1); // all unused id will be -1
2197 for (int i = 0; i < nbCells; i++)
2201 // //idCellsOldToNew[i] = myCellIdVtkToSmds[i]; // valid vtk indexes are > = 0
2202 // int vtkid = myCells[i]->getVtkId();
2203 // idCellsOldToNew[vtkid] = i; // old vtkId --> old smdsId (not used in input)
2207 if (areNodesModified)
2208 myGrid->compactGrid(idNodesOldToNew, newNodeSize, idCellsOldToNew, newCellSize);
2210 myGrid->compactGrid(idNodesOldToNew, 0, idCellsOldToNew, newCellSize);
2212 int nbVtkPts = myGrid->GetNumberOfPoints();
2213 nbVtkCells = myGrid->GetNumberOfCells();
2214 if (nbVtkPts != newNodeSize)
2216 MESSAGE("===> nbVtkPts != newNodeSize " << nbVtkPts << " " << newNodeSize);
2217 if (nbVtkPts > newNodeSize) newNodeSize = nbVtkPts; // several points with same SMDS Id
2219 if (nbVtkCells != newCellSize)
2221 MESSAGE("===> nbVtkCells != newCellSize " << nbVtkCells << " " << newCellSize);
2222 if (nbVtkCells > newCellSize) newCellSize = nbVtkCells; // several cells with same SMDS Id
2225 // --- SMDS_MeshNode and myNodes (id in SMDS and in VTK are the same), myNodeIdFactory
2227 if (areNodesModified)
2229 MESSAGE("-------------- modify myNodes");
2230 SetOfNodes newNodes;
2231 newNodes.resize(newNodeSize+1,0); // 0 not used, SMDS numbers 1..n
2233 for (int i = 0; i < nbNodes; i++)
2237 newSmdsId++; // SMDS id start to 1
2238 int oldVtkId = myNodes[i]->getVtkId();
2239 int newVtkId = idNodesOldToNew[oldVtkId];
2240 //MESSAGE("myNodes["<< i << "] vtkId " << oldVtkId << " --> " << newVtkId);
2241 myNodes[i]->setVtkId(newVtkId);
2242 myNodes[i]->setId(newSmdsId);
2243 newNodes[newSmdsId] = myNodes[i];
2244 //MESSAGE("myNodes["<< i << "] --> newNodes[" << newSmdsId << "]");
2247 myNodes.swap(newNodes);
2248 this->myNodeIDFactory->emptyPool(newSmdsId); // newSmdsId = number of nodes
2249 MESSAGE("myNodes.size " << myNodes.size());
2252 // --- SMDS_MeshCell, myCellIdVtkToSmds, myCellIdSmdsToVtk, myCells
2254 int vtkIndexSize = myCellIdVtkToSmds.size();
2256 for (int oldVtkId = 0; oldVtkId < vtkIndexSize; oldVtkId++)
2258 int oldSmdsId = this->myCellIdVtkToSmds[oldVtkId];
2261 int newVtkId = idCellsOldToNew[oldVtkId];
2262 if (newVtkId > maxVtkId)
2263 maxVtkId = newVtkId;
2264 //MESSAGE("myCells["<< oldSmdsId << "] vtkId " << oldVtkId << " --> " << newVtkId);
2265 myCells[oldSmdsId]->setVtkId(newVtkId);
2268 // MESSAGE("myCells.size()=" << myCells.size()
2269 // << " myCellIdSmdsToVtk.size()=" << myCellIdSmdsToVtk.size()
2270 // << " myCellIdVtkToSmds.size()=" << myCellIdVtkToSmds.size() );
2272 SetOfCells newCells;
2273 //vector<int> newSmdsToVtk;
2274 vector<int> newVtkToSmds;
2276 assert(maxVtkId < newCellSize);
2277 newCells.resize(newCellSize+1, 0); // 0 not used, SMDS numbers 1..n
2278 //newSmdsToVtk.resize(newCellSize+1, -1);
2279 newVtkToSmds.resize(newCellSize+1, -1);
2281 int myCellsSize = myCells.size();
2283 for (int i = 0; i < myCellsSize; i++)
2287 newSmdsId++; // SMDS id start to 1
2288 assert(newSmdsId <= newCellSize);
2289 newCells[newSmdsId] = myCells[i];
2290 newCells[newSmdsId]->setId(newSmdsId);
2291 //MESSAGE("myCells["<< i << "] --> newCells[" << newSmdsId << "]");
2292 int idvtk = myCells[i]->getVtkId();
2293 //newSmdsToVtk[newSmdsId] = idvtk;
2294 assert(idvtk < newCellSize);
2295 newVtkToSmds[idvtk] = newSmdsId;
2299 myCells.swap(newCells);
2300 //myCellIdSmdsToVtk.swap(newSmdsToVtk);
2301 myCellIdVtkToSmds.swap(newVtkToSmds);
2302 MESSAGE("myCells.size()=" << myCells.size()
2303 << " myCellIdVtkToSmds.size()=" << myCellIdVtkToSmds.size() );
2304 this->myElementIDFactory->emptyPool(newSmdsId);
2306 this->myScript->SetModified(true); // notify GUI client for buildPrs when update
2308 // --- compact list myNodes and myElements in submeshes
2310 SMESHDS_SubMeshIteratorPtr smIt = SubMeshes();
2311 while ( SMESHDS_SubMesh* sm = const_cast< SMESHDS_SubMesh* >( smIt->next() ))
2315 void SMESHDS_Mesh::CleanDownWardConnectivity()
2317 myGrid->CleanDownwardConnectivity();
2320 void SMESHDS_Mesh::BuildDownWardConnectivity(bool withEdges)
2322 myGrid->BuildDownwardConnectivity(withEdges);
2325 /*! change some nodes in cell without modifying type or internal connectivity.
2326 * Nodes inverse connectivity is maintained up to date.
2327 * @param vtkVolId vtk id of the cell.
2328 * @param localClonedNodeIds map old node id to new node id.
2329 * @return ok if success.
2331 bool SMESHDS_Mesh::ModifyCellNodes(int vtkVolId, std::map<int,int> localClonedNodeIds)
2333 myGrid->ModifyCellNodes(vtkVolId, localClonedNodeIds);