1 // Copyright (C) 2007-2010 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.
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
29 #include "SMESHDS_Mesh.hxx"
31 #include "SMESHDS_Group.hxx"
32 #include "SMDS_VertexPosition.hxx"
33 #include "SMDS_EdgePosition.hxx"
34 #include "SMDS_FacePosition.hxx"
35 #include "SMDS_SpacePosition.hxx"
36 #include "SMESHDS_GroupOnGeom.hxx"
38 #include <Standard_ErrorHandler.hxx>
39 #include <Standard_OutOfRange.hxx>
41 #include <TopExp_Explorer.hxx>
42 #include <TopoDS_Iterator.hxx>
44 #include "utilities.h"
48 /*Standard_Boolean IsEqual( const TopoDS_Shape& S1, const TopoDS_Shape& S2 )
50 return S1.IsSame( S2 );
53 //=======================================================================
56 //=======================================================================
57 SMESHDS_Mesh::SMESHDS_Mesh(int theMeshID, bool theIsEmbeddedMode):
59 myIsEmbeddedMode(theIsEmbeddedMode),
62 myScript = new SMESHDS_Script(theIsEmbeddedMode);
64 SetPersistentId(theMeshID);
67 //=======================================================================
68 bool SMESHDS_Mesh::IsEmbeddedMode()
70 return myIsEmbeddedMode;
73 //================================================================================
75 * \brief Store ID persistent during lifecycle
77 //================================================================================
79 void SMESHDS_Mesh::SetPersistentId(int id)
84 //================================================================================
86 * \brief Return ID persistent during lifecycle
88 //================================================================================
90 int SMESHDS_Mesh::GetPersistentId() const
92 return myPersistentID;
95 //=======================================================================
96 //function : ShapeToMesh
98 //=======================================================================
99 void SMESHDS_Mesh::ShapeToMesh(const TopoDS_Shape & S)
101 if ( !myShape.IsNull() && S.IsNull() )
103 // removal of a shape to mesh, delete ...
105 myShapeToHypothesis.Clear();
106 // - shape indices in SMDS_Position of nodes
107 map<int,SMESHDS_SubMesh*>::iterator i_sub = myShapeIndexToSubMesh.begin();
108 for ( ; i_sub != myShapeIndexToSubMesh.end(); i_sub++ ) {
109 if ( !i_sub->second->IsComplexSubmesh() ) {
110 SMDS_NodeIteratorPtr nIt = i_sub->second->GetNodes();
111 while ( nIt->more() )
112 nIt->next()->GetPosition()->SetShapeId( 0 );
116 TShapeIndexToSubMesh::iterator i_sm = myShapeIndexToSubMesh.begin();
117 for ( ; i_sm != myShapeIndexToSubMesh.end(); ++i_sm )
119 myShapeIndexToSubMesh.clear();
120 myIndexToShape.Clear();
121 // - groups on geometry
122 set<SMESHDS_GroupBase*>::iterator gr = myGroups.begin();
123 while ( gr != myGroups.end() ) {
124 if ( dynamic_cast<SMESHDS_GroupOnGeom*>( *gr ))
125 myGroups.erase( gr++ );
133 TopExp::MapShapes(myShape, myIndexToShape);
137 //=======================================================================
138 //function : AddHypothesis
140 //=======================================================================
142 bool SMESHDS_Mesh::AddHypothesis(const TopoDS_Shape & SS,
143 const SMESHDS_Hypothesis * H)
145 if (!myShapeToHypothesis.IsBound(SS.Oriented(TopAbs_FORWARD))) {
146 list<const SMESHDS_Hypothesis *> aList;
147 myShapeToHypothesis.Bind(SS.Oriented(TopAbs_FORWARD), aList);
149 list<const SMESHDS_Hypothesis *>& alist =
150 myShapeToHypothesis(SS.Oriented(TopAbs_FORWARD)); // ignore orientation of SS
152 //Check if the Hypothesis is still present
153 list<const SMESHDS_Hypothesis*>::iterator ith = find(alist.begin(),alist.end(), H );
155 if (alist.end() != ith) return false;
161 //=======================================================================
162 //function : RemoveHypothesis
164 //=======================================================================
166 bool SMESHDS_Mesh::RemoveHypothesis(const TopoDS_Shape & S,
167 const SMESHDS_Hypothesis * H)
169 if( myShapeToHypothesis.IsBound( S.Oriented(TopAbs_FORWARD) ) )
171 list<const SMESHDS_Hypothesis *>& alist=myShapeToHypothesis.ChangeFind( S.Oriented(TopAbs_FORWARD) );
172 list<const SMESHDS_Hypothesis*>::iterator ith=find(alist.begin(),alist.end(), H );
173 if (ith != alist.end())
182 //=======================================================================
185 //=======================================================================
186 SMDS_MeshNode* SMESHDS_Mesh::AddNode(double x, double y, double z){
187 SMDS_MeshNode* node = SMDS_Mesh::AddNode(x, y, z);
188 if(node!=NULL) myScript->AddNode(node->GetID(), x, y, z);
192 SMDS_MeshNode* SMESHDS_Mesh::AddNodeWithID(double x, double y, double z, int ID){
193 SMDS_MeshNode* node = SMDS_Mesh::AddNodeWithID(x,y,z,ID);
194 if(node!=NULL) myScript->AddNode(node->GetID(), x, y, z);
198 //=======================================================================
199 //function : MoveNode
201 //=======================================================================
202 void SMESHDS_Mesh::MoveNode(const SMDS_MeshNode *n, double x, double y, double z)
204 SMDS_MeshNode * node=const_cast<SMDS_MeshNode*>(n);
206 myScript->MoveNode(n->GetID(), x, y, z);
209 //=======================================================================
210 //function : ChangeElementNodes
212 //=======================================================================
214 bool SMESHDS_Mesh::ChangeElementNodes(const SMDS_MeshElement * elem,
215 const SMDS_MeshNode * nodes[],
218 if ( ! SMDS_Mesh::ChangeElementNodes( elem, nodes, nbnodes ))
221 vector<int> IDs( nbnodes );
222 for ( int i = 0; i < nbnodes; i++ )
223 IDs [ i ] = nodes[ i ]->GetID();
224 myScript->ChangeElementNodes( elem->GetID(), &IDs[0], nbnodes);
229 //=======================================================================
230 //function : ChangePolygonNodes
232 //=======================================================================
233 bool SMESHDS_Mesh::ChangePolygonNodes
234 (const SMDS_MeshElement * elem,
235 vector<const SMDS_MeshNode*> nodes)
237 ASSERT(nodes.size() > 3);
239 return ChangeElementNodes(elem, &nodes[0], nodes.size());
242 //=======================================================================
243 //function : ChangePolyhedronNodes
245 //=======================================================================
246 bool SMESHDS_Mesh::ChangePolyhedronNodes
247 (const SMDS_MeshElement * elem,
248 std::vector<const SMDS_MeshNode*> nodes,
249 std::vector<int> quantities)
251 ASSERT(nodes.size() > 3);
253 if (!SMDS_Mesh::ChangePolyhedronNodes(elem, nodes, quantities))
256 int i, len = nodes.size();
257 std::vector<int> nodes_ids (len);
258 for (i = 0; i < len; i++) {
259 nodes_ids[i] = nodes[i]->GetID();
261 myScript->ChangePolyhedronNodes(elem->GetID(), nodes_ids, quantities);
266 //=======================================================================
267 //function : Renumber
269 //=======================================================================
271 void SMESHDS_Mesh::Renumber (const bool isNodes, const int startID, const int deltaID)
273 SMDS_Mesh::Renumber( isNodes, startID, deltaID );
274 myScript->Renumber( isNodes, startID, deltaID );
277 //=======================================================================
278 //function : Add0DElement
280 //=======================================================================
281 SMDS_Mesh0DElement* SMESHDS_Mesh::Add0DElementWithID(int nodeID, int ID)
283 SMDS_Mesh0DElement* anElem = SMDS_Mesh::Add0DElementWithID(nodeID, ID);
284 if (anElem) myScript->Add0DElement(ID, nodeID);
288 SMDS_Mesh0DElement* SMESHDS_Mesh::Add0DElementWithID
289 (const SMDS_MeshNode * node, int ID)
291 return Add0DElementWithID(node->GetID(), ID);
294 SMDS_Mesh0DElement* SMESHDS_Mesh::Add0DElement(const SMDS_MeshNode * node)
296 SMDS_Mesh0DElement* anElem = SMDS_Mesh::Add0DElement(node);
297 if (anElem) myScript->Add0DElement(anElem->GetID(), node->GetID());
301 //=======================================================================
302 //function :AddEdgeWithID
304 //=======================================================================
305 SMDS_MeshEdge* SMESHDS_Mesh::AddEdgeWithID(int n1, int n2, int ID)
307 SMDS_MeshEdge* anElem = SMDS_Mesh::AddEdgeWithID(n1,n2,ID);
308 if(anElem) myScript->AddEdge(ID,n1,n2);
312 SMDS_MeshEdge* SMESHDS_Mesh::AddEdgeWithID(const SMDS_MeshNode * n1,
313 const SMDS_MeshNode * n2,
316 return AddEdgeWithID(n1->GetID(),
321 SMDS_MeshEdge* SMESHDS_Mesh::AddEdge(const SMDS_MeshNode * n1,
322 const SMDS_MeshNode * n2)
324 SMDS_MeshEdge* anElem = SMDS_Mesh::AddEdge(n1,n2);
325 if(anElem) myScript->AddEdge(anElem->GetID(),
331 //=======================================================================
334 //=======================================================================
335 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(int n1, int n2, int n3, int ID)
337 SMDS_MeshFace *anElem = SMDS_Mesh::AddFaceWithID(n1, n2, n3, ID);
338 if(anElem) myScript->AddFace(ID,n1,n2,n3);
342 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(const SMDS_MeshNode * n1,
343 const SMDS_MeshNode * n2,
344 const SMDS_MeshNode * n3,
347 return AddFaceWithID(n1->GetID(),
353 SMDS_MeshFace* SMESHDS_Mesh::AddFace( const SMDS_MeshNode * n1,
354 const SMDS_MeshNode * n2,
355 const SMDS_MeshNode * n3)
357 SMDS_MeshFace *anElem = SMDS_Mesh::AddFace(n1, n2, n3);
358 if(anElem) myScript->AddFace(anElem->GetID(),
365 //=======================================================================
368 //=======================================================================
369 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(int n1, int n2, int n3, int n4, int ID)
371 SMDS_MeshFace *anElem = SMDS_Mesh::AddFaceWithID(n1, n2, n3, n4, ID);
372 if(anElem) myScript->AddFace(ID, n1, n2, n3, n4);
376 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(const SMDS_MeshNode * n1,
377 const SMDS_MeshNode * n2,
378 const SMDS_MeshNode * n3,
379 const SMDS_MeshNode * n4,
382 return AddFaceWithID(n1->GetID(),
389 SMDS_MeshFace* SMESHDS_Mesh::AddFace(const SMDS_MeshNode * n1,
390 const SMDS_MeshNode * n2,
391 const SMDS_MeshNode * n3,
392 const SMDS_MeshNode * n4)
394 SMDS_MeshFace *anElem = SMDS_Mesh::AddFace(n1, n2, n3, n4);
395 if(anElem) myScript->AddFace(anElem->GetID(),
403 //=======================================================================
404 //function :AddVolume
406 //=======================================================================
407 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3, int n4, int ID)
409 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolumeWithID(n1, n2, n3, n4, ID);
410 if(anElem) myScript->AddVolume(ID, n1, n2, n3, n4);
414 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
415 const SMDS_MeshNode * n2,
416 const SMDS_MeshNode * n3,
417 const SMDS_MeshNode * n4,
420 return AddVolumeWithID(n1->GetID(),
427 SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
428 const SMDS_MeshNode * n2,
429 const SMDS_MeshNode * n3,
430 const SMDS_MeshNode * n4)
432 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1, n2, n3, n4);
433 if(anElem) myScript->AddVolume(anElem->GetID(),
441 //=======================================================================
442 //function :AddVolume
444 //=======================================================================
445 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3, int n4, int n5, int ID)
447 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolumeWithID(n1, n2, n3, n4, n5, ID);
448 if(anElem) myScript->AddVolume(ID, n1, n2, n3, n4, n5);
452 SMDS_MeshVolume* SMESHDS_Mesh::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,
459 return AddVolumeWithID(n1->GetID(),
467 SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
468 const SMDS_MeshNode * n2,
469 const SMDS_MeshNode * n3,
470 const SMDS_MeshNode * n4,
471 const SMDS_MeshNode * n5)
473 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1, n2, n3, n4, n5);
474 if(anElem) myScript->AddVolume(anElem->GetID(),
483 //=======================================================================
484 //function :AddVolume
486 //=======================================================================
487 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3, int n4, int n5, int n6, int ID)
489 SMDS_MeshVolume *anElem= SMDS_Mesh::AddVolumeWithID(n1, n2, n3, n4, n5, n6, ID);
490 if(anElem) myScript->AddVolume(ID, n1, n2, n3, n4, n5, n6);
494 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
495 const SMDS_MeshNode * n2,
496 const SMDS_MeshNode * n3,
497 const SMDS_MeshNode * n4,
498 const SMDS_MeshNode * n5,
499 const SMDS_MeshNode * n6,
502 return AddVolumeWithID(n1->GetID(),
511 SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
512 const SMDS_MeshNode * n2,
513 const SMDS_MeshNode * n3,
514 const SMDS_MeshNode * n4,
515 const SMDS_MeshNode * n5,
516 const SMDS_MeshNode * n6)
518 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1, n2, n3, n4, n5, n6);
519 if(anElem) myScript->AddVolume(anElem->GetID(),
529 //=======================================================================
530 //function :AddVolume
532 //=======================================================================
533 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3, int n4, int n5, int n6, int n7, int n8, int ID)
535 SMDS_MeshVolume *anElem= SMDS_Mesh::AddVolumeWithID(n1, n2, n3, n4, n5, n6, n7, n8, ID);
536 if(anElem) myScript->AddVolume(ID, n1, n2, n3, n4, n5, n6, n7, n8);
540 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
541 const SMDS_MeshNode * n2,
542 const SMDS_MeshNode * n3,
543 const SMDS_MeshNode * n4,
544 const SMDS_MeshNode * n5,
545 const SMDS_MeshNode * n6,
546 const SMDS_MeshNode * n7,
547 const SMDS_MeshNode * n8,
550 return AddVolumeWithID(n1->GetID(),
561 SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
562 const SMDS_MeshNode * n2,
563 const SMDS_MeshNode * n3,
564 const SMDS_MeshNode * n4,
565 const SMDS_MeshNode * n5,
566 const SMDS_MeshNode * n6,
567 const SMDS_MeshNode * n7,
568 const SMDS_MeshNode * n8)
570 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1, n2, n3, n4, n5, n6, n7, n8);
571 if(anElem) myScript->AddVolume(anElem->GetID(),
583 //=======================================================================
584 //function : AddPolygonalFace
586 //=======================================================================
587 SMDS_MeshFace* SMESHDS_Mesh::AddPolygonalFaceWithID (const std::vector<int>& nodes_ids,
590 SMDS_MeshFace *anElem = SMDS_Mesh::AddPolygonalFaceWithID(nodes_ids, ID);
592 myScript->AddPolygonalFace(ID, nodes_ids);
597 SMDS_MeshFace* SMESHDS_Mesh::AddPolygonalFaceWithID
598 (const std::vector<const SMDS_MeshNode*>& nodes,
601 SMDS_MeshFace *anElem = SMDS_Mesh::AddPolygonalFaceWithID(nodes, ID);
603 int i, len = nodes.size();
604 std::vector<int> nodes_ids (len);
605 for (i = 0; i < len; i++) {
606 nodes_ids[i] = nodes[i]->GetID();
608 myScript->AddPolygonalFace(ID, nodes_ids);
613 SMDS_MeshFace* SMESHDS_Mesh::AddPolygonalFace
614 (const std::vector<const SMDS_MeshNode*>& nodes)
616 SMDS_MeshFace *anElem = SMDS_Mesh::AddPolygonalFace(nodes);
618 int i, len = nodes.size();
619 std::vector<int> nodes_ids (len);
620 for (i = 0; i < len; i++) {
621 nodes_ids[i] = nodes[i]->GetID();
623 myScript->AddPolygonalFace(anElem->GetID(), nodes_ids);
628 //=======================================================================
629 //function : AddPolyhedralVolume
631 //=======================================================================
632 SMDS_MeshVolume* SMESHDS_Mesh::AddPolyhedralVolumeWithID (const std::vector<int>& nodes_ids,
633 const std::vector<int>& quantities,
636 SMDS_MeshVolume *anElem = SMDS_Mesh::AddPolyhedralVolumeWithID(nodes_ids, quantities, ID);
638 myScript->AddPolyhedralVolume(ID, nodes_ids, quantities);
643 SMDS_MeshVolume* SMESHDS_Mesh::AddPolyhedralVolumeWithID
644 (const std::vector<const SMDS_MeshNode*>& nodes,
645 const std::vector<int>& quantities,
648 SMDS_MeshVolume *anElem = SMDS_Mesh::AddPolyhedralVolumeWithID(nodes, quantities, ID);
650 int i, len = nodes.size();
651 std::vector<int> nodes_ids (len);
652 for (i = 0; i < len; i++) {
653 nodes_ids[i] = nodes[i]->GetID();
655 myScript->AddPolyhedralVolume(ID, nodes_ids, quantities);
660 SMDS_MeshVolume* SMESHDS_Mesh::AddPolyhedralVolume
661 (const std::vector<const SMDS_MeshNode*>& nodes,
662 const std::vector<int>& quantities)
664 SMDS_MeshVolume *anElem = SMDS_Mesh::AddPolyhedralVolume(nodes, quantities);
666 int i, len = nodes.size();
667 std::vector<int> nodes_ids (len);
668 for (i = 0; i < len; i++) {
669 nodes_ids[i] = nodes[i]->GetID();
671 myScript->AddPolyhedralVolume(anElem->GetID(), nodes_ids, quantities);
676 //=======================================================================
677 //function : removeFromContainers
679 //=======================================================================
681 static void removeFromContainers (map<int,SMESHDS_SubMesh*>& theSubMeshes,
682 set<SMESHDS_GroupBase*>& theGroups,
683 list<const SMDS_MeshElement*>& theElems,
686 if ( theElems.empty() )
690 // Element can belong to several groups
691 if ( !theGroups.empty() )
693 set<SMESHDS_GroupBase*>::iterator GrIt = theGroups.begin();
694 for ( ; GrIt != theGroups.end(); GrIt++ )
696 SMESHDS_Group* group = dynamic_cast<SMESHDS_Group*>( *GrIt );
697 if ( !group || group->IsEmpty() ) continue;
699 list<const SMDS_MeshElement *>::iterator elIt = theElems.begin();
700 for ( ; elIt != theElems.end(); elIt++ )
702 group->SMDSGroup().Remove( *elIt );
703 if ( group->IsEmpty() ) break;
708 const bool deleted=true;
710 // Rm from sub-meshes
711 // Element should belong to only one sub-mesh
712 map<int,SMESHDS_SubMesh*>::iterator SubIt = theSubMeshes.begin();
713 for ( ; SubIt != theSubMeshes.end(); SubIt++ )
715 int size = isNode ? (*SubIt).second->NbNodes() : (*SubIt).second->NbElements();
716 if ( size == 0 ) continue;
718 list<const SMDS_MeshElement *>::iterator elIt = theElems.begin();
719 while ( elIt != theElems.end() )
721 bool removed = false;
723 removed = (*SubIt).second->RemoveNode( static_cast<const SMDS_MeshNode*> (*elIt), deleted );
725 removed = (*SubIt).second->RemoveElement( *elIt, deleted );
729 elIt = theElems.erase( elIt );
730 if ( theElems.empty() )
731 return; // all elements are found and removed
741 //=======================================================================
742 //function : RemoveNode
744 //=======================================================================
745 void SMESHDS_Mesh::RemoveNode(const SMDS_MeshNode * n)
747 if ( n->NbInverseElements() == 0 && !(hasConstructionEdges() || hasConstructionFaces()))
749 SMESHDS_SubMesh* subMesh=0;
750 map<int,SMESHDS_SubMesh*>::iterator SubIt =
751 myShapeIndexToSubMesh.find( n->GetPosition()->GetShapeId() );
752 if ( SubIt != myShapeIndexToSubMesh.end() )
753 subMesh = SubIt->second;
755 SubIt = myShapeIndexToSubMesh.begin();
756 for ( ; !subMesh && SubIt != myShapeIndexToSubMesh.end(); SubIt++ )
757 if (!SubIt->second->IsComplexSubmesh() && SubIt->second->Contains( n ))
758 subMesh = SubIt->second;
760 RemoveFreeNode( n, subMesh, true);
764 myScript->RemoveNode(n->GetID());
766 list<const SMDS_MeshElement *> removedElems;
767 list<const SMDS_MeshElement *> removedNodes;
769 SMDS_Mesh::RemoveElement( n, removedElems, removedNodes, true );
771 removeFromContainers( myShapeIndexToSubMesh, myGroups, removedElems, false );
772 removeFromContainers( myShapeIndexToSubMesh, myGroups, removedNodes, true );
775 //=======================================================================
776 //function : RemoveFreeNode
778 //=======================================================================
779 void SMESHDS_Mesh::RemoveFreeNode(const SMDS_MeshNode * n,
780 SMESHDS_SubMesh * subMesh,
783 myScript->RemoveNode(n->GetID());
786 // Node can belong to several groups
787 if (fromGroups && !myGroups.empty()) {
788 set<SMESHDS_GroupBase*>::iterator GrIt = myGroups.begin();
789 for (; GrIt != myGroups.end(); GrIt++) {
790 SMESHDS_Group* group = dynamic_cast<SMESHDS_Group*>(*GrIt);
791 if (!group || group->IsEmpty()) continue;
792 group->SMDSGroup().Remove(n);
797 // Node should belong to only one sub-mesh
799 subMesh->RemoveNode(n,/*deleted=*/false);
801 SMDS_Mesh::RemoveFreeElement(n);
804 //=======================================================================
805 //function : RemoveElement
807 //========================================================================
808 void SMESHDS_Mesh::RemoveElement(const SMDS_MeshElement * elt)
810 if (elt->GetType() == SMDSAbs_Node)
812 RemoveNode( static_cast<const SMDS_MeshNode*>( elt ));
815 if (!hasConstructionEdges() && !hasConstructionFaces())
817 SMESHDS_SubMesh* subMesh=0;
818 map<int,SMESHDS_SubMesh*>::iterator SubIt = myShapeIndexToSubMesh.begin();
819 for ( ; !subMesh && SubIt != myShapeIndexToSubMesh.end(); SubIt++ )
820 if (!SubIt->second->IsComplexSubmesh() && SubIt->second->Contains( elt ))
821 subMesh = SubIt->second;
823 RemoveFreeElement( elt, subMesh, true);
827 myScript->RemoveElement(elt->GetID());
829 list<const SMDS_MeshElement *> removedElems;
830 list<const SMDS_MeshElement *> removedNodes;
832 SMDS_Mesh::RemoveElement(elt, removedElems, removedNodes, false);
834 removeFromContainers( myShapeIndexToSubMesh, myGroups, removedElems, false );
837 //=======================================================================
838 //function : RemoveFreeElement
840 //========================================================================
841 void SMESHDS_Mesh::RemoveFreeElement(const SMDS_MeshElement * elt,
842 SMESHDS_SubMesh * subMesh,
845 if (elt->GetType() == SMDSAbs_Node) {
846 RemoveFreeNode( static_cast<const SMDS_MeshNode*>(elt), subMesh);
850 if (hasConstructionEdges() || hasConstructionFaces())
851 // this methods is only for meshes without descendants
854 myScript->RemoveElement(elt->GetID());
857 // Node can belong to several groups
858 if ( fromGroups && !myGroups.empty() ) {
859 set<SMESHDS_GroupBase*>::iterator GrIt = myGroups.begin();
860 for (; GrIt != myGroups.end(); GrIt++) {
861 SMESHDS_Group* group = dynamic_cast<SMESHDS_Group*>(*GrIt);
862 if (group && !group->IsEmpty())
863 group->SMDSGroup().Remove(elt);
868 // Element should belong to only one sub-mesh
870 subMesh->RemoveElement(elt, /*deleted=*/false);
872 SMDS_Mesh::RemoveFreeElement(elt);
875 //================================================================================
877 * \brief Remove all data from the mesh
879 //================================================================================
881 void SMESHDS_Mesh::ClearMesh()
883 myScript->ClearMesh();
887 map<int,SMESHDS_SubMesh*>::iterator sub, subEnd = myShapeIndexToSubMesh.end();
888 for ( sub = myShapeIndexToSubMesh.begin(); sub != subEnd; ++sub )
889 sub->second->Clear();
892 TGroups::iterator group, groupEnd = myGroups.end();
893 for ( group = myGroups.begin(); group != groupEnd; ++group ) {
894 if ( SMESHDS_Group* g = dynamic_cast<SMESHDS_Group*>(*group)) {
895 SMDSAbs_ElementType groupType = g->GetType();
897 g->SetType( groupType );
902 //================================================================================
904 * \brief return submesh by shape
905 * \param shape - the subshape
906 * \retval SMESHDS_SubMesh* - the found submesh
908 * search of submeshes is optimized
910 //================================================================================
912 SMESHDS_SubMesh* SMESHDS_Mesh::getSubmesh( const TopoDS_Shape & shape )
914 if ( shape.IsNull() )
917 if ( !myCurSubShape.IsNull() && shape.IsSame( myCurSubShape ))
920 getSubmesh( ShapeToIndex( shape ));
921 myCurSubShape = shape;
925 //================================================================================
927 * \brief return submesh by subshape index
928 * \param Index - the subshape index
929 * \retval SMESHDS_SubMesh* - the found submesh
930 * search of submeshes is optimized
932 //================================================================================
934 SMESHDS_SubMesh* SMESHDS_Mesh::getSubmesh( const int Index )
936 //Update or build submesh
937 if ( Index != myCurSubID ) {
938 map<int,SMESHDS_SubMesh*>::iterator it = myShapeIndexToSubMesh.find( Index );
939 if ( it == myShapeIndexToSubMesh.end() )
940 it = myShapeIndexToSubMesh.insert( make_pair(Index, new SMESHDS_SubMesh() )).first;
941 myCurSubMesh = it->second;
943 myCurSubShape.Nullify(); // myCurSubShape no more corresponds to submesh
948 //================================================================================
950 * \brief Add element or node to submesh
951 * \param elem - element to add
952 * \param subMesh - submesh to be filled in
954 //================================================================================
956 bool SMESHDS_Mesh::add(const SMDS_MeshElement* elem, SMESHDS_SubMesh* subMesh )
958 if ( elem && subMesh ) {
959 if ( elem->GetType() == SMDSAbs_Node )
960 subMesh->AddNode( static_cast<const SMDS_MeshNode* >( elem ));
962 subMesh->AddElement( elem );
970 //================================================================================
972 * \brief Creates a node position in volume
974 //================================================================================
976 inline SMDS_PositionPtr volumePosition(int volId)
978 SMDS_SpacePosition* pos = new SMDS_SpacePosition();
979 pos->SetShapeId( volId );
980 return SMDS_PositionPtr(pos);
984 //=======================================================================
985 //function : SetNodeOnVolume
987 //=======================================================================
988 void SMESHDS_Mesh::SetNodeInVolume(SMDS_MeshNode * aNode,
989 const TopoDS_Shell & S)
991 if ( add( aNode, getSubmesh(S) ))
992 aNode->SetPosition ( volumePosition( myCurSubID ));
994 //=======================================================================
995 //function : SetNodeOnVolume
997 //=======================================================================
998 void SMESHDS_Mesh::SetNodeInVolume(SMDS_MeshNode * aNode,
999 const TopoDS_Solid & S)
1001 if ( add( aNode, getSubmesh(S) ))
1002 aNode->SetPosition ( volumePosition( myCurSubID ));
1005 //=======================================================================
1006 //function : SetNodeOnFace
1008 //=======================================================================
1009 void SMESHDS_Mesh::SetNodeOnFace(SMDS_MeshNode * aNode,
1010 const TopoDS_Face & S,
1014 if ( add( aNode, getSubmesh(S) ))
1015 aNode->SetPosition(SMDS_PositionPtr(new SMDS_FacePosition(myCurSubID, u, v)));
1018 //=======================================================================
1019 //function : SetNodeOnEdge
1021 //=======================================================================
1022 void SMESHDS_Mesh::SetNodeOnEdge(SMDS_MeshNode * aNode,
1023 const TopoDS_Edge & S,
1026 if ( add( aNode, getSubmesh(S) ))
1027 aNode->SetPosition(SMDS_PositionPtr(new SMDS_EdgePosition(myCurSubID, u)));
1030 //=======================================================================
1031 //function : SetNodeOnVertex
1033 //=======================================================================
1034 void SMESHDS_Mesh::SetNodeOnVertex(SMDS_MeshNode * aNode,
1035 const TopoDS_Vertex & S)
1037 if ( add( aNode, getSubmesh(S) ))
1038 aNode->SetPosition(SMDS_PositionPtr(new SMDS_VertexPosition(myCurSubID)));
1041 //=======================================================================
1042 //function : UnSetNodeOnShape
1044 //=======================================================================
1045 void SMESHDS_Mesh::UnSetNodeOnShape(const SMDS_MeshNode* aNode)
1047 if ( aNode && aNode->GetPosition() ) {
1048 map<int,SMESHDS_SubMesh*>::iterator it =
1049 myShapeIndexToSubMesh.find( aNode->GetPosition()->GetShapeId() );
1050 if ( it != myShapeIndexToSubMesh.end() )
1051 it->second->RemoveNode( aNode, /*deleted=*/false );
1055 //=======================================================================
1056 //function : SetMeshElementOnShape
1058 //=======================================================================
1059 void SMESHDS_Mesh::SetMeshElementOnShape(const SMDS_MeshElement * anElement,
1060 const TopoDS_Shape & S)
1062 add( anElement, getSubmesh(S) );
1065 //=======================================================================
1066 //function : UnSetMeshElementOnShape
1068 //=======================================================================
1069 void SMESHDS_Mesh::UnSetMeshElementOnShape(const SMDS_MeshElement * elem,
1070 const TopoDS_Shape & S)
1072 int Index = myIndexToShape.FindIndex(S);
1074 map<int,SMESHDS_SubMesh*>::iterator it = myShapeIndexToSubMesh.find( Index );
1075 if ( it != myShapeIndexToSubMesh.end() )
1076 if ( elem->GetType() == SMDSAbs_Node )
1077 it->second->RemoveNode( static_cast<const SMDS_MeshNode* >( elem ), /*deleted=*/false );
1079 it->second->RemoveElement( elem, /*deleted=*/false );
1082 //=======================================================================
1083 //function : ShapeToMesh
1085 //=======================================================================
1086 TopoDS_Shape SMESHDS_Mesh::ShapeToMesh() const
1091 //=======================================================================
1092 //function : IsGroupOfSubShapes
1093 //purpose : return true if at least one subshape of theShape is a subshape
1094 // of myShape or theShape == myShape
1095 //=======================================================================
1097 bool SMESHDS_Mesh::IsGroupOfSubShapes (const TopoDS_Shape& theShape) const
1099 if ( myIndexToShape.Contains(theShape) )
1102 for ( TopoDS_Iterator it( theShape ); it.More(); it.Next() )
1103 if (IsGroupOfSubShapes( it.Value() ))
1109 ///////////////////////////////////////////////////////////////////////////////
1110 /// Return the sub mesh linked to the a given TopoDS_Shape or NULL if the given
1111 /// TopoDS_Shape is unknown
1112 ///////////////////////////////////////////////////////////////////////////////
1113 SMESHDS_SubMesh * SMESHDS_Mesh::MeshElements(const TopoDS_Shape & S) const
1115 int Index = ShapeToIndex(S);
1116 TShapeIndexToSubMesh::const_iterator anIter = myShapeIndexToSubMesh.find(Index);
1117 if (anIter != myShapeIndexToSubMesh.end())
1118 return anIter->second;
1123 ///////////////////////////////////////////////////////////////////////////////
1124 /// Return the sub mesh by Id of shape it is linked to
1125 ///////////////////////////////////////////////////////////////////////////////
1126 SMESHDS_SubMesh * SMESHDS_Mesh::MeshElements(const int Index)
1128 TShapeIndexToSubMesh::const_iterator anIter = myShapeIndexToSubMesh.find(Index);
1129 if (anIter != myShapeIndexToSubMesh.end())
1130 return anIter->second;
1135 //=======================================================================
1136 //function : SubMeshIndices
1138 //=======================================================================
1139 list<int> SMESHDS_Mesh::SubMeshIndices()
1141 list<int> anIndices;
1142 std::map<int,SMESHDS_SubMesh*>::iterator anIter = myShapeIndexToSubMesh.begin();
1143 for (; anIter != myShapeIndexToSubMesh.end(); anIter++) {
1144 anIndices.push_back((*anIter).first);
1149 //=======================================================================
1150 //function : GetHypothesis
1152 //=======================================================================
1154 const list<const SMESHDS_Hypothesis*>&
1155 SMESHDS_Mesh::GetHypothesis(const TopoDS_Shape & S) const
1157 if ( myShapeToHypothesis.IsBound( S.Oriented(TopAbs_FORWARD) ) ) // ignore orientation of S
1158 return myShapeToHypothesis.Find( S.Oriented(TopAbs_FORWARD) );
1160 static list<const SMESHDS_Hypothesis*> empty;
1164 //=======================================================================
1165 //function : GetScript
1167 //=======================================================================
1168 SMESHDS_Script* SMESHDS_Mesh::GetScript()
1173 //=======================================================================
1174 //function : ClearScript
1176 //=======================================================================
1177 void SMESHDS_Mesh::ClearScript()
1182 //=======================================================================
1183 //function : HasMeshElements
1185 //=======================================================================
1186 bool SMESHDS_Mesh::HasMeshElements(const TopoDS_Shape & S)
1188 if (myShape.IsNull()) MESSAGE("myShape is NULL");
1189 int Index = myIndexToShape.FindIndex(S);
1190 return myShapeIndexToSubMesh.find(Index)!=myShapeIndexToSubMesh.end();
1193 //=======================================================================
1194 //function : HasHypothesis
1196 //=======================================================================
1197 bool SMESHDS_Mesh::HasHypothesis(const TopoDS_Shape & S)
1199 return myShapeToHypothesis.IsBound(S.Oriented(TopAbs_FORWARD));
1202 //=======================================================================
1203 //function : NewSubMesh
1205 //=======================================================================
1206 SMESHDS_SubMesh * SMESHDS_Mesh::NewSubMesh(int Index)
1208 SMESHDS_SubMesh* SM = 0;
1209 TShapeIndexToSubMesh::iterator anIter = myShapeIndexToSubMesh.find(Index);
1210 if (anIter == myShapeIndexToSubMesh.end())
1212 SM = new SMESHDS_SubMesh();
1213 myShapeIndexToSubMesh[Index]=SM;
1216 SM = anIter->second;
1220 //=======================================================================
1221 //function : AddCompoundSubmesh
1223 //=======================================================================
1225 int SMESHDS_Mesh::AddCompoundSubmesh(const TopoDS_Shape& S,
1226 TopAbs_ShapeEnum type)
1229 if ( IsGroupOfSubShapes( S ))
1231 aMainIndex = myIndexToShape.Add( S );
1232 bool all = ( type == TopAbs_SHAPE );
1233 if ( all ) // corresponding simple submesh may exist
1234 aMainIndex = -aMainIndex;
1235 //MESSAGE("AddCompoundSubmesh index = " << aMainIndex );
1236 SMESHDS_SubMesh * aNewSub = NewSubMesh( aMainIndex );
1237 if ( !aNewSub->IsComplexSubmesh() ) // is empty
1239 int shapeType = Max( TopAbs_SOLID, all ? myShape.ShapeType() : type );
1240 int typeLimit = all ? TopAbs_VERTEX : type;
1241 for ( ; shapeType <= typeLimit; shapeType++ )
1243 TopExp_Explorer exp( S, TopAbs_ShapeEnum( shapeType ));
1244 for ( ; exp.More(); exp.Next() )
1246 int index = myIndexToShape.FindIndex( exp.Current() );
1248 aNewSub->AddSubMesh( NewSubMesh( index ));
1256 //=======================================================================
1257 //function : IndexToShape
1259 //=======================================================================
1260 const TopoDS_Shape& SMESHDS_Mesh::IndexToShape(int ShapeIndex) const
1264 return myIndexToShape.FindKey(ShapeIndex);
1266 catch ( Standard_OutOfRange )
1269 static TopoDS_Shape nullShape;
1273 //================================================================================
1275 * \brief Return max index of sub-mesh
1277 //================================================================================
1279 int SMESHDS_Mesh::MaxSubMeshIndex() const
1281 return myShapeIndexToSubMesh.empty() ? 0 : myShapeIndexToSubMesh.rbegin()->first;
1284 //=======================================================================
1285 //function : ShapeToIndex
1287 //=======================================================================
1288 int SMESHDS_Mesh::ShapeToIndex(const TopoDS_Shape & S) const
1290 if (myShape.IsNull())
1291 MESSAGE("myShape is NULL");
1293 int index = myIndexToShape.FindIndex(S);
1298 //=======================================================================
1299 //function : SetNodeOnVolume
1301 //=======================================================================
1302 void SMESHDS_Mesh::SetNodeInVolume(const SMDS_MeshNode* aNode, int Index)
1304 if ( add( aNode, getSubmesh( Index )))
1305 ((SMDS_MeshNode*) aNode)->SetPosition( volumePosition( Index ));
1308 //=======================================================================
1309 //function : SetNodeOnFace
1311 //=======================================================================
1312 void SMESHDS_Mesh::SetNodeOnFace(SMDS_MeshNode* aNode, int Index, double u, double v)
1314 //Set Position on Node
1315 if ( add( aNode, getSubmesh( Index )))
1316 aNode->SetPosition(SMDS_PositionPtr(new SMDS_FacePosition(Index, u, v)));
1319 //=======================================================================
1320 //function : SetNodeOnEdge
1322 //=======================================================================
1323 void SMESHDS_Mesh::SetNodeOnEdge(SMDS_MeshNode* aNode,
1327 //Set Position on Node
1328 if ( add( aNode, getSubmesh( Index )))
1329 aNode->SetPosition(SMDS_PositionPtr(new SMDS_EdgePosition(Index, u)));
1332 //=======================================================================
1333 //function : SetNodeOnVertex
1335 //=======================================================================
1336 void SMESHDS_Mesh::SetNodeOnVertex(SMDS_MeshNode* aNode, int Index)
1338 //Set Position on Node
1339 if ( add( aNode, getSubmesh( Index )))
1340 aNode->SetPosition(SMDS_PositionPtr(new SMDS_VertexPosition(Index)));
1343 //=======================================================================
1344 //function : SetMeshElementOnShape
1346 //=======================================================================
1347 void SMESHDS_Mesh::SetMeshElementOnShape(const SMDS_MeshElement* anElement,
1350 add( anElement, getSubmesh( Index ));
1353 //=======================================================================
1354 //function : ~SMESHDS_Mesh
1356 //=======================================================================
1357 SMESHDS_Mesh::~SMESHDS_Mesh()
1362 TShapeIndexToSubMesh::iterator i_sm = myShapeIndexToSubMesh.begin();
1363 for ( ; i_sm != myShapeIndexToSubMesh.end(); ++i_sm )
1364 delete i_sm->second;
1368 //********************************************************************
1369 //********************************************************************
1370 //******** *********
1371 //***** Methods for addition of quadratic elements ******
1372 //******** *********
1373 //********************************************************************
1374 //********************************************************************
1376 //=======================================================================
1377 //function : AddEdgeWithID
1379 //=======================================================================
1380 SMDS_MeshEdge* SMESHDS_Mesh::AddEdgeWithID(int n1, int n2, int n12, int ID)
1382 SMDS_MeshEdge* anElem = SMDS_Mesh::AddEdgeWithID(n1,n2,n12,ID);
1383 if(anElem) myScript->AddEdge(ID,n1,n2,n12);
1387 //=======================================================================
1388 //function : AddEdge
1390 //=======================================================================
1391 SMDS_MeshEdge* SMESHDS_Mesh::AddEdge(const SMDS_MeshNode* n1,
1392 const SMDS_MeshNode* n2,
1393 const SMDS_MeshNode* n12)
1395 SMDS_MeshEdge* anElem = SMDS_Mesh::AddEdge(n1,n2,n12);
1396 if(anElem) myScript->AddEdge(anElem->GetID(),
1403 //=======================================================================
1404 //function : AddEdgeWithID
1406 //=======================================================================
1407 SMDS_MeshEdge* SMESHDS_Mesh::AddEdgeWithID(const SMDS_MeshNode * n1,
1408 const SMDS_MeshNode * n2,
1409 const SMDS_MeshNode * n12,
1412 return AddEdgeWithID(n1->GetID(),
1419 //=======================================================================
1420 //function : AddFace
1422 //=======================================================================
1423 SMDS_MeshFace* SMESHDS_Mesh::AddFace(const SMDS_MeshNode * n1,
1424 const SMDS_MeshNode * n2,
1425 const SMDS_MeshNode * n3,
1426 const SMDS_MeshNode * n12,
1427 const SMDS_MeshNode * n23,
1428 const SMDS_MeshNode * n31)
1430 SMDS_MeshFace *anElem = SMDS_Mesh::AddFace(n1,n2,n3,n12,n23,n31);
1431 if(anElem) myScript->AddFace(anElem->GetID(),
1432 n1->GetID(), n2->GetID(), n3->GetID(),
1433 n12->GetID(), n23->GetID(), n31->GetID());
1437 //=======================================================================
1438 //function : AddFaceWithID
1440 //=======================================================================
1441 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(int n1, int n2, int n3,
1442 int n12,int n23,int n31, int ID)
1444 SMDS_MeshFace *anElem = SMDS_Mesh::AddFaceWithID(n1,n2,n3,n12,n23,n31,ID);
1445 if(anElem) myScript->AddFace(ID,n1,n2,n3,n12,n23,n31);
1449 //=======================================================================
1450 //function : AddFaceWithID
1452 //=======================================================================
1453 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(const SMDS_MeshNode * n1,
1454 const SMDS_MeshNode * n2,
1455 const SMDS_MeshNode * n3,
1456 const SMDS_MeshNode * n12,
1457 const SMDS_MeshNode * n23,
1458 const SMDS_MeshNode * n31,
1461 return AddFaceWithID(n1->GetID(), n2->GetID(), n3->GetID(),
1462 n12->GetID(), n23->GetID(), n31->GetID(),
1467 //=======================================================================
1468 //function : AddFace
1470 //=======================================================================
1471 SMDS_MeshFace* SMESHDS_Mesh::AddFace(const SMDS_MeshNode * n1,
1472 const SMDS_MeshNode * n2,
1473 const SMDS_MeshNode * n3,
1474 const SMDS_MeshNode * n4,
1475 const SMDS_MeshNode * n12,
1476 const SMDS_MeshNode * n23,
1477 const SMDS_MeshNode * n34,
1478 const SMDS_MeshNode * n41)
1480 SMDS_MeshFace *anElem = SMDS_Mesh::AddFace(n1,n2,n3,n4,n12,n23,n34,n41);
1481 if(anElem) myScript->AddFace(anElem->GetID(),
1482 n1->GetID(), n2->GetID(), n3->GetID(), n4->GetID(),
1483 n12->GetID(), n23->GetID(), n34->GetID(), n41->GetID());
1487 //=======================================================================
1488 //function : AddFaceWithID
1490 //=======================================================================
1491 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(int n1, int n2, int n3, int n4,
1492 int n12,int n23,int n34,int n41, int ID)
1494 SMDS_MeshFace *anElem = SMDS_Mesh::AddFaceWithID(n1,n2,n3,n4,n12,n23,n34,n41,ID);
1495 if(anElem) myScript->AddFace(ID,n1,n2,n3,n4,n12,n23,n34,n41);
1499 //=======================================================================
1500 //function : AddFaceWithID
1502 //=======================================================================
1503 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(const SMDS_MeshNode * n1,
1504 const SMDS_MeshNode * n2,
1505 const SMDS_MeshNode * n3,
1506 const SMDS_MeshNode * n4,
1507 const SMDS_MeshNode * n12,
1508 const SMDS_MeshNode * n23,
1509 const SMDS_MeshNode * n34,
1510 const SMDS_MeshNode * n41,
1513 return AddFaceWithID(n1->GetID(), n2->GetID(), n3->GetID(), n4->GetID(),
1514 n12->GetID(), n23->GetID(), n34->GetID(), n41->GetID(),
1519 //=======================================================================
1520 //function : AddVolume
1522 //=======================================================================
1523 SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
1524 const SMDS_MeshNode * n2,
1525 const SMDS_MeshNode * n3,
1526 const SMDS_MeshNode * n4,
1527 const SMDS_MeshNode * n12,
1528 const SMDS_MeshNode * n23,
1529 const SMDS_MeshNode * n31,
1530 const SMDS_MeshNode * n14,
1531 const SMDS_MeshNode * n24,
1532 const SMDS_MeshNode * n34)
1534 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1,n2,n3,n4,n12,n23,n31,n14,n24,n34);
1535 if(anElem) myScript->AddVolume(anElem->GetID(),
1536 n1->GetID(), n2->GetID(), n3->GetID(), n4->GetID(),
1537 n12->GetID(), n23->GetID(), n31->GetID(),
1538 n14->GetID(), n24->GetID(), n34->GetID());
1542 //=======================================================================
1543 //function : AddVolumeWithID
1545 //=======================================================================
1546 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3, int n4,
1547 int n12,int n23,int n31,
1548 int n14,int n24,int n34, int ID)
1550 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolumeWithID(n1,n2,n3,n4,n12,n23,
1551 n31,n14,n24,n34,ID);
1552 if(anElem) myScript->AddVolume(ID,n1,n2,n3,n4,n12,n23,n31,n14,n24,n34);
1556 //=======================================================================
1557 //function : AddVolumeWithID
1558 //purpose : 2d order tetrahedron of 10 nodes
1559 //=======================================================================
1560 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
1561 const SMDS_MeshNode * n2,
1562 const SMDS_MeshNode * n3,
1563 const SMDS_MeshNode * n4,
1564 const SMDS_MeshNode * n12,
1565 const SMDS_MeshNode * n23,
1566 const SMDS_MeshNode * n31,
1567 const SMDS_MeshNode * n14,
1568 const SMDS_MeshNode * n24,
1569 const SMDS_MeshNode * n34,
1572 return AddVolumeWithID(n1->GetID(), n2->GetID(), n3->GetID(), n4->GetID(),
1573 n12->GetID(), n23->GetID(), n31->GetID(),
1574 n14->GetID(), n24->GetID(), n34->GetID(), ID);
1578 //=======================================================================
1579 //function : AddVolume
1581 //=======================================================================
1582 SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
1583 const SMDS_MeshNode * n2,
1584 const SMDS_MeshNode * n3,
1585 const SMDS_MeshNode * n4,
1586 const SMDS_MeshNode * n5,
1587 const SMDS_MeshNode * n12,
1588 const SMDS_MeshNode * n23,
1589 const SMDS_MeshNode * n34,
1590 const SMDS_MeshNode * n41,
1591 const SMDS_MeshNode * n15,
1592 const SMDS_MeshNode * n25,
1593 const SMDS_MeshNode * n35,
1594 const SMDS_MeshNode * n45)
1596 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1,n2,n3,n4,n5,n12,n23,n34,n41,
1599 myScript->AddVolume(anElem->GetID(), n1->GetID(), n2->GetID(),
1600 n3->GetID(), n4->GetID(), n5->GetID(),
1601 n12->GetID(), n23->GetID(), n34->GetID(), n41->GetID(),
1602 n15->GetID(), n25->GetID(), n35->GetID(), n45->GetID());
1606 //=======================================================================
1607 //function : AddVolumeWithID
1609 //=======================================================================
1610 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3, int n4, int n5,
1611 int n12,int n23,int n34,int n41,
1612 int n15,int n25,int n35,int n45, int ID)
1614 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolumeWithID(n1,n2,n3,n4,n5,
1616 n15,n25,n35,n45,ID);
1617 if(anElem) myScript->AddVolume(ID,n1,n2,n3,n4,n5,n12,n23,n34,n41,
1622 //=======================================================================
1623 //function : AddVolumeWithID
1624 //purpose : 2d order pyramid of 13 nodes
1625 //=======================================================================
1626 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
1627 const SMDS_MeshNode * n2,
1628 const SMDS_MeshNode * n3,
1629 const SMDS_MeshNode * n4,
1630 const SMDS_MeshNode * n5,
1631 const SMDS_MeshNode * n12,
1632 const SMDS_MeshNode * n23,
1633 const SMDS_MeshNode * n34,
1634 const SMDS_MeshNode * n41,
1635 const SMDS_MeshNode * n15,
1636 const SMDS_MeshNode * n25,
1637 const SMDS_MeshNode * n35,
1638 const SMDS_MeshNode * n45,
1641 return AddVolumeWithID(n1->GetID(), n2->GetID(), n3->GetID(),
1642 n4->GetID(), n5->GetID(),
1643 n12->GetID(), n23->GetID(), n34->GetID(), n41->GetID(),
1644 n15->GetID(), n25->GetID(), n35->GetID(), n45->GetID(),
1649 //=======================================================================
1650 //function : AddVolume
1652 //=======================================================================
1653 SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
1654 const SMDS_MeshNode * n2,
1655 const SMDS_MeshNode * n3,
1656 const SMDS_MeshNode * n4,
1657 const SMDS_MeshNode * n5,
1658 const SMDS_MeshNode * n6,
1659 const SMDS_MeshNode * n12,
1660 const SMDS_MeshNode * n23,
1661 const SMDS_MeshNode * n31,
1662 const SMDS_MeshNode * n45,
1663 const SMDS_MeshNode * n56,
1664 const SMDS_MeshNode * n64,
1665 const SMDS_MeshNode * n14,
1666 const SMDS_MeshNode * n25,
1667 const SMDS_MeshNode * n36)
1669 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1,n2,n3,n4,n5,n6,n12,n23,n31,
1670 n45,n56,n64,n14,n25,n36);
1672 myScript->AddVolume(anElem->GetID(), n1->GetID(), n2->GetID(),
1673 n3->GetID(), n4->GetID(), n5->GetID(), n6->GetID(),
1674 n12->GetID(), n23->GetID(), n31->GetID(),
1675 n45->GetID(), n56->GetID(), n64->GetID(),
1676 n14->GetID(), n25->GetID(), n36->GetID());
1680 //=======================================================================
1681 //function : AddVolumeWithID
1683 //=======================================================================
1684 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3,
1685 int n4, int n5, int n6,
1686 int n12,int n23,int n31,
1687 int n45,int n56,int n64,
1688 int n14,int n25,int n36, int ID)
1690 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolumeWithID(n1,n2,n3,n4,n5,n6,
1694 if(anElem) myScript->AddVolume(ID,n1,n2,n3,n4,n5,n6,n12,n23,n31,
1695 n45,n56,n64,n14,n25,n36);
1699 //=======================================================================
1700 //function : AddVolumeWithID
1701 //purpose : 2d order Pentahedron with 15 nodes
1702 //=======================================================================
1703 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
1704 const SMDS_MeshNode * n2,
1705 const SMDS_MeshNode * n3,
1706 const SMDS_MeshNode * n4,
1707 const SMDS_MeshNode * n5,
1708 const SMDS_MeshNode * n6,
1709 const SMDS_MeshNode * n12,
1710 const SMDS_MeshNode * n23,
1711 const SMDS_MeshNode * n31,
1712 const SMDS_MeshNode * n45,
1713 const SMDS_MeshNode * n56,
1714 const SMDS_MeshNode * n64,
1715 const SMDS_MeshNode * n14,
1716 const SMDS_MeshNode * n25,
1717 const SMDS_MeshNode * n36,
1720 return AddVolumeWithID(n1->GetID(), n2->GetID(), n3->GetID(),
1721 n4->GetID(), n5->GetID(), n6->GetID(),
1722 n12->GetID(), n23->GetID(), n31->GetID(),
1723 n45->GetID(), n56->GetID(), n64->GetID(),
1724 n14->GetID(), n25->GetID(), n36->GetID(),
1729 //=======================================================================
1730 //function : AddVolume
1732 //=======================================================================
1733 SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
1734 const SMDS_MeshNode * n2,
1735 const SMDS_MeshNode * n3,
1736 const SMDS_MeshNode * n4,
1737 const SMDS_MeshNode * n5,
1738 const SMDS_MeshNode * n6,
1739 const SMDS_MeshNode * n7,
1740 const SMDS_MeshNode * n8,
1741 const SMDS_MeshNode * n12,
1742 const SMDS_MeshNode * n23,
1743 const SMDS_MeshNode * n34,
1744 const SMDS_MeshNode * n41,
1745 const SMDS_MeshNode * n56,
1746 const SMDS_MeshNode * n67,
1747 const SMDS_MeshNode * n78,
1748 const SMDS_MeshNode * n85,
1749 const SMDS_MeshNode * n15,
1750 const SMDS_MeshNode * n26,
1751 const SMDS_MeshNode * n37,
1752 const SMDS_MeshNode * n48)
1754 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1,n2,n3,n4,n5,n6,n7,n8,
1759 myScript->AddVolume(anElem->GetID(), n1->GetID(), n2->GetID(),
1760 n3->GetID(), n4->GetID(), n5->GetID(),
1761 n6->GetID(), n7->GetID(), n8->GetID(),
1762 n12->GetID(), n23->GetID(), n34->GetID(), n41->GetID(),
1763 n56->GetID(), n67->GetID(), n78->GetID(), n85->GetID(),
1764 n15->GetID(), n26->GetID(), n37->GetID(), n48->GetID());
1768 //=======================================================================
1769 //function : AddVolumeWithID
1771 //=======================================================================
1772 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3, int n4,
1773 int n5, int n6, int n7, int n8,
1774 int n12,int n23,int n34,int n41,
1775 int n56,int n67,int n78,int n85,
1776 int n15,int n26,int n37,int n48, int ID)
1778 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolumeWithID(n1,n2,n3,n4,n5,n6,n7,n8,
1781 n15,n26,n37,n48,ID);
1782 if(anElem) myScript->AddVolume(ID,n1,n2,n3,n4,n5,n6,n7,n8,n12,n23,n34,n41,
1783 n56,n67,n78,n85,n15,n26,n37,n48);
1787 //=======================================================================
1788 //function : AddVolumeWithID
1789 //purpose : 2d order Hexahedrons with 20 nodes
1790 //=======================================================================
1791 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
1792 const SMDS_MeshNode * n2,
1793 const SMDS_MeshNode * n3,
1794 const SMDS_MeshNode * n4,
1795 const SMDS_MeshNode * n5,
1796 const SMDS_MeshNode * n6,
1797 const SMDS_MeshNode * n7,
1798 const SMDS_MeshNode * n8,
1799 const SMDS_MeshNode * n12,
1800 const SMDS_MeshNode * n23,
1801 const SMDS_MeshNode * n34,
1802 const SMDS_MeshNode * n41,
1803 const SMDS_MeshNode * n56,
1804 const SMDS_MeshNode * n67,
1805 const SMDS_MeshNode * n78,
1806 const SMDS_MeshNode * n85,
1807 const SMDS_MeshNode * n15,
1808 const SMDS_MeshNode * n26,
1809 const SMDS_MeshNode * n37,
1810 const SMDS_MeshNode * n48,
1813 return AddVolumeWithID(n1->GetID(), n2->GetID(), n3->GetID(), n4->GetID(),
1814 n5->GetID(), n6->GetID(), n7->GetID(), n8->GetID(),
1815 n12->GetID(), n23->GetID(), n34->GetID(), n41->GetID(),
1816 n56->GetID(), n67->GetID(), n78->GetID(), n85->GetID(),
1817 n15->GetID(), n26->GetID(), n37->GetID(), n48->GetID(),