1 // Copyright (C) 2007-2008 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
22 // SMESH SMESHDS : management of mesh data and SMESH document
23 // File : SMESH_Mesh.cxx
24 // Author : Yves FRICAUD, OCC
28 #include "SMESHDS_Mesh.hxx"
30 #include "SMESHDS_Group.hxx"
31 #include "SMDS_VertexPosition.hxx"
32 #include "SMDS_EdgePosition.hxx"
33 #include "SMDS_FacePosition.hxx"
34 #include "SMDS_SpacePosition.hxx"
35 #include "SMESHDS_GroupOnGeom.hxx"
37 #include <Standard_ErrorHandler.hxx>
38 #include <Standard_OutOfRange.hxx>
40 #include <TopExp_Explorer.hxx>
41 #include <TopoDS_Iterator.hxx>
43 #include "utilities.h"
47 /*Standard_Boolean IsEqual( const TopoDS_Shape& S1, const TopoDS_Shape& S2 )
49 return S1.IsSame( S2 );
52 //=======================================================================
55 //=======================================================================
56 SMESHDS_Mesh::SMESHDS_Mesh(int theMeshID, bool theIsEmbeddedMode):
58 myIsEmbeddedMode(theIsEmbeddedMode),
61 myScript = new SMESHDS_Script(theIsEmbeddedMode);
65 //=======================================================================
66 bool SMESHDS_Mesh::IsEmbeddedMode()
68 return myIsEmbeddedMode;
71 //=======================================================================
72 //function : ShapeToMesh
74 //=======================================================================
75 void SMESHDS_Mesh::ShapeToMesh(const TopoDS_Shape & S)
77 if ( !myShape.IsNull() && S.IsNull() )
79 // removal of a shape to mesh, delete ...
81 myShapeToHypothesis.Clear();
82 // - shape indices in SMDS_Position of nodes
83 map<int,SMESHDS_SubMesh*>::iterator i_sub = myShapeIndexToSubMesh.begin();
84 for ( ; i_sub != myShapeIndexToSubMesh.end(); i_sub++ ) {
85 if ( !i_sub->second->IsComplexSubmesh() ) {
86 SMDS_NodeIteratorPtr nIt = i_sub->second->GetNodes();
88 nIt->next()->GetPosition()->SetShapeId( 0 );
92 TShapeIndexToSubMesh::iterator i_sm = myShapeIndexToSubMesh.begin();
93 for ( ; i_sm != myShapeIndexToSubMesh.end(); ++i_sm )
95 myShapeIndexToSubMesh.clear();
96 myIndexToShape.Clear();
97 // - groups on geometry
98 set<SMESHDS_GroupBase*>::iterator gr = myGroups.begin();
99 while ( gr != myGroups.end() ) {
100 if ( dynamic_cast<SMESHDS_GroupOnGeom*>( *gr ))
101 myGroups.erase( gr++ );
109 TopExp::MapShapes(myShape, myIndexToShape);
113 //=======================================================================
114 //function : AddHypothesis
116 //=======================================================================
118 bool SMESHDS_Mesh::AddHypothesis(const TopoDS_Shape & SS,
119 const SMESHDS_Hypothesis * H)
121 if (!myShapeToHypothesis.IsBound(SS.Oriented(TopAbs_FORWARD))) {
122 list<const SMESHDS_Hypothesis *> aList;
123 myShapeToHypothesis.Bind(SS.Oriented(TopAbs_FORWARD), aList);
125 list<const SMESHDS_Hypothesis *>& alist =
126 myShapeToHypothesis(SS.Oriented(TopAbs_FORWARD)); // ignore orientation of SS
128 //Check if the Hypothesis is still present
129 list<const SMESHDS_Hypothesis*>::iterator ith = find(alist.begin(),alist.end(), H );
131 if (alist.end() != ith) return false;
137 //=======================================================================
138 //function : RemoveHypothesis
140 //=======================================================================
142 bool SMESHDS_Mesh::RemoveHypothesis(const TopoDS_Shape & S,
143 const SMESHDS_Hypothesis * H)
145 if( myShapeToHypothesis.IsBound( S.Oriented(TopAbs_FORWARD) ) )
147 list<const SMESHDS_Hypothesis *>& alist=myShapeToHypothesis.ChangeFind( S.Oriented(TopAbs_FORWARD) );
148 list<const SMESHDS_Hypothesis*>::iterator ith=find(alist.begin(),alist.end(), H );
149 if (ith != alist.end())
158 //=======================================================================
161 //=======================================================================
162 SMDS_MeshNode* SMESHDS_Mesh::AddNode(double x, double y, double z){
163 SMDS_MeshNode* node = SMDS_Mesh::AddNode(x, y, z);
164 if(node!=NULL) myScript->AddNode(node->GetID(), x, y, z);
168 SMDS_MeshNode* SMESHDS_Mesh::AddNodeWithID(double x, double y, double z, int ID){
169 SMDS_MeshNode* node = SMDS_Mesh::AddNodeWithID(x,y,z,ID);
170 if(node!=NULL) myScript->AddNode(node->GetID(), x, y, z);
174 //=======================================================================
175 //function : MoveNode
177 //=======================================================================
178 void SMESHDS_Mesh::MoveNode(const SMDS_MeshNode *n, double x, double y, double z)
180 SMDS_MeshNode * node=const_cast<SMDS_MeshNode*>(n);
182 myScript->MoveNode(n->GetID(), x, y, z);
185 //=======================================================================
186 //function : ChangeElementNodes
188 //=======================================================================
190 bool SMESHDS_Mesh::ChangeElementNodes(const SMDS_MeshElement * elem,
191 const SMDS_MeshNode * nodes[],
194 if ( ! SMDS_Mesh::ChangeElementNodes( elem, nodes, nbnodes ))
197 vector<int> IDs( nbnodes );
198 for ( int i = 0; i < nbnodes; i++ )
199 IDs [ i ] = nodes[ i ]->GetID();
200 myScript->ChangeElementNodes( elem->GetID(), &IDs[0], nbnodes);
205 //=======================================================================
206 //function : ChangePolygonNodes
208 //=======================================================================
209 bool SMESHDS_Mesh::ChangePolygonNodes
210 (const SMDS_MeshElement * elem,
211 vector<const SMDS_MeshNode*> nodes)
213 ASSERT(nodes.size() > 3);
215 return ChangeElementNodes(elem, &nodes[0], nodes.size());
218 //=======================================================================
219 //function : ChangePolyhedronNodes
221 //=======================================================================
222 bool SMESHDS_Mesh::ChangePolyhedronNodes
223 (const SMDS_MeshElement * elem,
224 std::vector<const SMDS_MeshNode*> nodes,
225 std::vector<int> quantities)
227 ASSERT(nodes.size() > 3);
229 if (!SMDS_Mesh::ChangePolyhedronNodes(elem, nodes, quantities))
232 int i, len = nodes.size();
233 std::vector<int> nodes_ids (len);
234 for (i = 0; i < len; i++) {
235 nodes_ids[i] = nodes[i]->GetID();
237 myScript->ChangePolyhedronNodes(elem->GetID(), nodes_ids, quantities);
242 //=======================================================================
243 //function : Renumber
245 //=======================================================================
247 void SMESHDS_Mesh::Renumber (const bool isNodes, const int startID, const int deltaID)
249 SMDS_Mesh::Renumber( isNodes, startID, deltaID );
250 myScript->Renumber( isNodes, startID, deltaID );
253 //=======================================================================
254 //function : Add0DElement
256 //=======================================================================
257 SMDS_Mesh0DElement* SMESHDS_Mesh::Add0DElementWithID(int nodeID, int ID)
259 SMDS_Mesh0DElement* anElem = SMDS_Mesh::Add0DElementWithID(nodeID, ID);
260 if (anElem) myScript->Add0DElement(ID, nodeID);
264 SMDS_Mesh0DElement* SMESHDS_Mesh::Add0DElementWithID
265 (const SMDS_MeshNode * node, int ID)
267 return Add0DElementWithID(node->GetID(), ID);
270 SMDS_Mesh0DElement* SMESHDS_Mesh::Add0DElement(const SMDS_MeshNode * node)
272 SMDS_Mesh0DElement* anElem = SMDS_Mesh::Add0DElement(node);
273 if (anElem) myScript->Add0DElement(anElem->GetID(), node->GetID());
277 //=======================================================================
278 //function :AddEdgeWithID
280 //=======================================================================
281 SMDS_MeshEdge* SMESHDS_Mesh::AddEdgeWithID(int n1, int n2, int ID)
283 SMDS_MeshEdge* anElem = SMDS_Mesh::AddEdgeWithID(n1,n2,ID);
284 if(anElem) myScript->AddEdge(ID,n1,n2);
288 SMDS_MeshEdge* SMESHDS_Mesh::AddEdgeWithID(const SMDS_MeshNode * n1,
289 const SMDS_MeshNode * n2,
292 return AddEdgeWithID(n1->GetID(),
297 SMDS_MeshEdge* SMESHDS_Mesh::AddEdge(const SMDS_MeshNode * n1,
298 const SMDS_MeshNode * n2)
300 SMDS_MeshEdge* anElem = SMDS_Mesh::AddEdge(n1,n2);
301 if(anElem) myScript->AddEdge(anElem->GetID(),
307 //=======================================================================
310 //=======================================================================
311 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(int n1, int n2, int n3, int ID)
313 SMDS_MeshFace *anElem = SMDS_Mesh::AddFaceWithID(n1, n2, n3, ID);
314 if(anElem) myScript->AddFace(ID,n1,n2,n3);
318 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(const SMDS_MeshNode * n1,
319 const SMDS_MeshNode * n2,
320 const SMDS_MeshNode * n3,
323 return AddFaceWithID(n1->GetID(),
329 SMDS_MeshFace* SMESHDS_Mesh::AddFace( const SMDS_MeshNode * n1,
330 const SMDS_MeshNode * n2,
331 const SMDS_MeshNode * n3)
333 SMDS_MeshFace *anElem = SMDS_Mesh::AddFace(n1, n2, n3);
334 if(anElem) myScript->AddFace(anElem->GetID(),
341 //=======================================================================
344 //=======================================================================
345 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(int n1, int n2, int n3, int n4, int ID)
347 SMDS_MeshFace *anElem = SMDS_Mesh::AddFaceWithID(n1, n2, n3, n4, ID);
348 if(anElem) myScript->AddFace(ID, n1, n2, n3, n4);
352 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(const SMDS_MeshNode * n1,
353 const SMDS_MeshNode * n2,
354 const SMDS_MeshNode * n3,
355 const SMDS_MeshNode * n4,
358 return AddFaceWithID(n1->GetID(),
365 SMDS_MeshFace* SMESHDS_Mesh::AddFace(const SMDS_MeshNode * n1,
366 const SMDS_MeshNode * n2,
367 const SMDS_MeshNode * n3,
368 const SMDS_MeshNode * n4)
370 SMDS_MeshFace *anElem = SMDS_Mesh::AddFace(n1, n2, n3, n4);
371 if(anElem) myScript->AddFace(anElem->GetID(),
379 //=======================================================================
380 //function :AddVolume
382 //=======================================================================
383 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3, int n4, int ID)
385 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolumeWithID(n1, n2, n3, n4, ID);
386 if(anElem) myScript->AddVolume(ID, n1, n2, n3, n4);
390 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
391 const SMDS_MeshNode * n2,
392 const SMDS_MeshNode * n3,
393 const SMDS_MeshNode * n4,
396 return AddVolumeWithID(n1->GetID(),
403 SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
404 const SMDS_MeshNode * n2,
405 const SMDS_MeshNode * n3,
406 const SMDS_MeshNode * n4)
408 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1, n2, n3, n4);
409 if(anElem) myScript->AddVolume(anElem->GetID(),
417 //=======================================================================
418 //function :AddVolume
420 //=======================================================================
421 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3, int n4, int n5, int ID)
423 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolumeWithID(n1, n2, n3, n4, n5, ID);
424 if(anElem) myScript->AddVolume(ID, n1, n2, n3, n4, n5);
428 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
429 const SMDS_MeshNode * n2,
430 const SMDS_MeshNode * n3,
431 const SMDS_MeshNode * n4,
432 const SMDS_MeshNode * n5,
435 return AddVolumeWithID(n1->GetID(),
443 SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
444 const SMDS_MeshNode * n2,
445 const SMDS_MeshNode * n3,
446 const SMDS_MeshNode * n4,
447 const SMDS_MeshNode * n5)
449 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1, n2, n3, n4, n5);
450 if(anElem) myScript->AddVolume(anElem->GetID(),
459 //=======================================================================
460 //function :AddVolume
462 //=======================================================================
463 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3, int n4, int n5, int n6, int ID)
465 SMDS_MeshVolume *anElem= SMDS_Mesh::AddVolumeWithID(n1, n2, n3, n4, n5, n6, ID);
466 if(anElem) myScript->AddVolume(ID, n1, n2, n3, n4, n5, n6);
470 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
471 const SMDS_MeshNode * n2,
472 const SMDS_MeshNode * n3,
473 const SMDS_MeshNode * n4,
474 const SMDS_MeshNode * n5,
475 const SMDS_MeshNode * n6,
478 return AddVolumeWithID(n1->GetID(),
487 SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
488 const SMDS_MeshNode * n2,
489 const SMDS_MeshNode * n3,
490 const SMDS_MeshNode * n4,
491 const SMDS_MeshNode * n5,
492 const SMDS_MeshNode * n6)
494 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1, n2, n3, n4, n5, n6);
495 if(anElem) myScript->AddVolume(anElem->GetID(),
505 //=======================================================================
506 //function :AddVolume
508 //=======================================================================
509 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3, int n4, int n5, int n6, int n7, int n8, int ID)
511 SMDS_MeshVolume *anElem= SMDS_Mesh::AddVolumeWithID(n1, n2, n3, n4, n5, n6, n7, n8, ID);
512 if(anElem) myScript->AddVolume(ID, n1, n2, n3, n4, n5, n6, n7, n8);
516 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
517 const SMDS_MeshNode * n2,
518 const SMDS_MeshNode * n3,
519 const SMDS_MeshNode * n4,
520 const SMDS_MeshNode * n5,
521 const SMDS_MeshNode * n6,
522 const SMDS_MeshNode * n7,
523 const SMDS_MeshNode * n8,
526 return AddVolumeWithID(n1->GetID(),
537 SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
538 const SMDS_MeshNode * n2,
539 const SMDS_MeshNode * n3,
540 const SMDS_MeshNode * n4,
541 const SMDS_MeshNode * n5,
542 const SMDS_MeshNode * n6,
543 const SMDS_MeshNode * n7,
544 const SMDS_MeshNode * n8)
546 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1, n2, n3, n4, n5, n6, n7, n8);
547 if(anElem) myScript->AddVolume(anElem->GetID(),
559 //=======================================================================
560 //function : AddPolygonalFace
562 //=======================================================================
563 SMDS_MeshFace* SMESHDS_Mesh::AddPolygonalFaceWithID (std::vector<int> nodes_ids,
566 SMDS_MeshFace *anElem = SMDS_Mesh::AddPolygonalFaceWithID(nodes_ids, ID);
568 myScript->AddPolygonalFace(ID, nodes_ids);
573 SMDS_MeshFace* SMESHDS_Mesh::AddPolygonalFaceWithID
574 (std::vector<const SMDS_MeshNode*> nodes,
577 SMDS_MeshFace *anElem = SMDS_Mesh::AddPolygonalFaceWithID(nodes, ID);
579 int i, len = nodes.size();
580 std::vector<int> nodes_ids (len);
581 for (i = 0; i < len; i++) {
582 nodes_ids[i] = nodes[i]->GetID();
584 myScript->AddPolygonalFace(ID, nodes_ids);
589 SMDS_MeshFace* SMESHDS_Mesh::AddPolygonalFace
590 (std::vector<const SMDS_MeshNode*> nodes)
592 SMDS_MeshFace *anElem = SMDS_Mesh::AddPolygonalFace(nodes);
594 int i, len = nodes.size();
595 std::vector<int> nodes_ids (len);
596 for (i = 0; i < len; i++) {
597 nodes_ids[i] = nodes[i]->GetID();
599 myScript->AddPolygonalFace(anElem->GetID(), nodes_ids);
604 //=======================================================================
605 //function : AddPolyhedralVolume
607 //=======================================================================
608 SMDS_MeshVolume* SMESHDS_Mesh::AddPolyhedralVolumeWithID (std::vector<int> nodes_ids,
609 std::vector<int> quantities,
612 SMDS_MeshVolume *anElem = SMDS_Mesh::AddPolyhedralVolumeWithID(nodes_ids, quantities, ID);
614 myScript->AddPolyhedralVolume(ID, nodes_ids, quantities);
619 SMDS_MeshVolume* SMESHDS_Mesh::AddPolyhedralVolumeWithID
620 (std::vector<const SMDS_MeshNode*> nodes,
621 std::vector<int> quantities,
624 SMDS_MeshVolume *anElem = SMDS_Mesh::AddPolyhedralVolumeWithID(nodes, quantities, ID);
626 int i, len = nodes.size();
627 std::vector<int> nodes_ids (len);
628 for (i = 0; i < len; i++) {
629 nodes_ids[i] = nodes[i]->GetID();
631 myScript->AddPolyhedralVolume(ID, nodes_ids, quantities);
636 SMDS_MeshVolume* SMESHDS_Mesh::AddPolyhedralVolume
637 (std::vector<const SMDS_MeshNode*> nodes,
638 std::vector<int> quantities)
640 SMDS_MeshVolume *anElem = SMDS_Mesh::AddPolyhedralVolume(nodes, quantities);
642 int i, len = nodes.size();
643 std::vector<int> nodes_ids (len);
644 for (i = 0; i < len; i++) {
645 nodes_ids[i] = nodes[i]->GetID();
647 myScript->AddPolyhedralVolume(anElem->GetID(), nodes_ids, quantities);
652 //=======================================================================
653 //function : removeFromContainers
655 //=======================================================================
657 static void removeFromContainers (map<int,SMESHDS_SubMesh*>& theSubMeshes,
658 set<SMESHDS_GroupBase*>& theGroups,
659 list<const SMDS_MeshElement*>& theElems,
662 if ( theElems.empty() )
666 // Element can belong to several groups
667 if ( !theGroups.empty() )
669 set<SMESHDS_GroupBase*>::iterator GrIt = theGroups.begin();
670 for ( ; GrIt != theGroups.end(); GrIt++ )
672 SMESHDS_Group* group = dynamic_cast<SMESHDS_Group*>( *GrIt );
673 if ( !group || group->IsEmpty() ) continue;
675 list<const SMDS_MeshElement *>::iterator elIt = theElems.begin();
676 for ( ; elIt != theElems.end(); elIt++ )
678 group->SMDSGroup().Remove( *elIt );
679 if ( group->IsEmpty() ) break;
684 const bool deleted=true;
686 // Rm from sub-meshes
687 // Element should belong to only one sub-mesh
688 map<int,SMESHDS_SubMesh*>::iterator SubIt = theSubMeshes.begin();
689 for ( ; SubIt != theSubMeshes.end(); SubIt++ )
691 int size = isNode ? (*SubIt).second->NbNodes() : (*SubIt).second->NbElements();
692 if ( size == 0 ) continue;
694 list<const SMDS_MeshElement *>::iterator elIt = theElems.begin();
695 while ( elIt != theElems.end() )
697 bool removed = false;
699 removed = (*SubIt).second->RemoveNode( static_cast<const SMDS_MeshNode*> (*elIt), deleted );
701 removed = (*SubIt).second->RemoveElement( *elIt, deleted );
705 elIt = theElems.erase( elIt );
706 if ( theElems.empty() )
707 return; // all elements are found and removed
717 //=======================================================================
718 //function : RemoveNode
720 //=======================================================================
721 void SMESHDS_Mesh::RemoveNode(const SMDS_MeshNode * n)
723 if ( n->NbInverseElements() == 0 && !(hasConstructionEdges() || hasConstructionFaces()))
725 SMESHDS_SubMesh* subMesh=0;
726 map<int,SMESHDS_SubMesh*>::iterator SubIt =
727 myShapeIndexToSubMesh.find( n->GetPosition()->GetShapeId() );
728 if ( SubIt != myShapeIndexToSubMesh.end() )
729 subMesh = SubIt->second;
731 SubIt = myShapeIndexToSubMesh.begin();
732 for ( ; !subMesh && SubIt != myShapeIndexToSubMesh.end(); SubIt++ )
733 if (!SubIt->second->IsComplexSubmesh() && SubIt->second->Contains( n ))
734 subMesh = SubIt->second;
736 RemoveFreeNode( n, subMesh, true);
740 myScript->RemoveNode(n->GetID());
742 list<const SMDS_MeshElement *> removedElems;
743 list<const SMDS_MeshElement *> removedNodes;
745 SMDS_Mesh::RemoveElement( n, removedElems, removedNodes, true );
747 removeFromContainers( myShapeIndexToSubMesh, myGroups, removedElems, false );
748 removeFromContainers( myShapeIndexToSubMesh, myGroups, removedNodes, true );
751 //=======================================================================
752 //function : RemoveFreeNode
754 //=======================================================================
755 void SMESHDS_Mesh::RemoveFreeNode(const SMDS_MeshNode * n,
756 SMESHDS_SubMesh * subMesh,
759 myScript->RemoveNode(n->GetID());
762 // Node can belong to several groups
763 if (fromGroups && !myGroups.empty()) {
764 set<SMESHDS_GroupBase*>::iterator GrIt = myGroups.begin();
765 for (; GrIt != myGroups.end(); GrIt++) {
766 SMESHDS_Group* group = dynamic_cast<SMESHDS_Group*>(*GrIt);
767 if (!group || group->IsEmpty()) continue;
768 group->SMDSGroup().Remove(n);
773 // Node should belong to only one sub-mesh
775 subMesh->RemoveNode(n,/*deleted=*/false);
777 SMDS_Mesh::RemoveFreeElement(n);
780 //=======================================================================
781 //function : RemoveElement
783 //========================================================================
784 void SMESHDS_Mesh::RemoveElement(const SMDS_MeshElement * elt)
786 if (elt->GetType() == SMDSAbs_Node)
788 RemoveNode( static_cast<const SMDS_MeshNode*>( elt ));
791 if (!hasConstructionEdges() && !hasConstructionFaces())
793 SMESHDS_SubMesh* subMesh=0;
794 map<int,SMESHDS_SubMesh*>::iterator SubIt = myShapeIndexToSubMesh.begin();
795 for ( ; !subMesh && SubIt != myShapeIndexToSubMesh.end(); SubIt++ )
796 if (!SubIt->second->IsComplexSubmesh() && SubIt->second->Contains( elt ))
797 subMesh = SubIt->second;
799 RemoveFreeElement( elt, subMesh, true);
803 myScript->RemoveElement(elt->GetID());
805 list<const SMDS_MeshElement *> removedElems;
806 list<const SMDS_MeshElement *> removedNodes;
808 SMDS_Mesh::RemoveElement(elt, removedElems, removedNodes, false);
810 removeFromContainers( myShapeIndexToSubMesh, myGroups, removedElems, false );
813 //=======================================================================
814 //function : RemoveFreeElement
816 //========================================================================
817 void SMESHDS_Mesh::RemoveFreeElement(const SMDS_MeshElement * elt,
818 SMESHDS_SubMesh * subMesh,
821 if (elt->GetType() == SMDSAbs_Node) {
822 RemoveFreeNode( static_cast<const SMDS_MeshNode*>(elt), subMesh);
826 if (hasConstructionEdges() || hasConstructionFaces())
827 // this methods is only for meshes without descendants
830 myScript->RemoveElement(elt->GetID());
833 // Node can belong to several groups
834 if ( fromGroups && !myGroups.empty() ) {
835 set<SMESHDS_GroupBase*>::iterator GrIt = myGroups.begin();
836 for (; GrIt != myGroups.end(); GrIt++) {
837 SMESHDS_Group* group = dynamic_cast<SMESHDS_Group*>(*GrIt);
838 if (group && !group->IsEmpty())
839 group->SMDSGroup().Remove(elt);
844 // Element should belong to only one sub-mesh
846 subMesh->RemoveElement(elt, /*deleted=*/false);
848 SMDS_Mesh::RemoveFreeElement(elt);
851 //================================================================================
853 * \brief Remove all data from the mesh
855 //================================================================================
857 void SMESHDS_Mesh::ClearMesh()
859 myScript->ClearMesh();
863 map<int,SMESHDS_SubMesh*>::iterator sub, subEnd = myShapeIndexToSubMesh.end();
864 for ( sub = myShapeIndexToSubMesh.begin(); sub != subEnd; ++sub )
865 sub->second->Clear();
868 TGroups::iterator group, groupEnd = myGroups.end();
869 for ( group = myGroups.begin(); group != groupEnd; ++group ) {
870 if ( SMESHDS_Group* g = dynamic_cast<SMESHDS_Group*>(*group)) {
871 SMDSAbs_ElementType groupType = g->GetType();
873 g->SetType( groupType );
878 //================================================================================
880 * \brief return submesh by shape
881 * \param shape - the subshape
882 * \retval SMESHDS_SubMesh* - the found submesh
884 * search of submeshes is optimized
886 //================================================================================
888 SMESHDS_SubMesh* SMESHDS_Mesh::getSubmesh( const TopoDS_Shape & shape )
890 if ( shape.IsNull() )
893 if ( !myCurSubShape.IsNull() && shape.IsSame( myCurSubShape ))
896 getSubmesh( ShapeToIndex( shape ));
897 myCurSubShape = shape;
901 //================================================================================
903 * \brief return submesh by subshape index
904 * \param Index - the subshape index
905 * \retval SMESHDS_SubMesh* - the found submesh
906 * search of submeshes is optimized
908 //================================================================================
910 SMESHDS_SubMesh* SMESHDS_Mesh::getSubmesh( const int Index )
912 //Update or build submesh
913 if ( Index != myCurSubID ) {
914 map<int,SMESHDS_SubMesh*>::iterator it = myShapeIndexToSubMesh.find( Index );
915 if ( it == myShapeIndexToSubMesh.end() )
916 it = myShapeIndexToSubMesh.insert( make_pair(Index, new SMESHDS_SubMesh() )).first;
917 myCurSubMesh = it->second;
919 myCurSubShape.Nullify(); // myCurSubShape no more corresponds to submesh
924 //================================================================================
926 * \brief Add element or node to submesh
927 * \param elem - element to add
928 * \param subMesh - submesh to be filled in
930 //================================================================================
932 bool SMESHDS_Mesh::add(const SMDS_MeshElement* elem, SMESHDS_SubMesh* subMesh )
934 if ( elem && subMesh ) {
935 if ( elem->GetType() == SMDSAbs_Node )
936 subMesh->AddNode( static_cast<const SMDS_MeshNode* >( elem ));
938 subMesh->AddElement( elem );
946 //================================================================================
948 * \brief Creates a node position in volume
950 //================================================================================
952 inline SMDS_PositionPtr volumePosition(int volId)
954 SMDS_SpacePosition* pos = new SMDS_SpacePosition();
955 pos->SetShapeId( volId );
956 return SMDS_PositionPtr(pos);
960 //=======================================================================
961 //function : SetNodeOnVolume
963 //=======================================================================
964 void SMESHDS_Mesh::SetNodeInVolume(SMDS_MeshNode * aNode,
965 const TopoDS_Shell & S)
967 if ( add( aNode, getSubmesh(S) ))
968 aNode->SetPosition ( volumePosition( myCurSubID ));
970 //=======================================================================
971 //function : SetNodeOnVolume
973 //=======================================================================
974 void SMESHDS_Mesh::SetNodeInVolume(SMDS_MeshNode * aNode,
975 const TopoDS_Solid & S)
977 if ( add( aNode, getSubmesh(S) ))
978 aNode->SetPosition ( volumePosition( myCurSubID ));
981 //=======================================================================
982 //function : SetNodeOnFace
984 //=======================================================================
985 void SMESHDS_Mesh::SetNodeOnFace(SMDS_MeshNode * aNode,
986 const TopoDS_Face & S,
990 if ( add( aNode, getSubmesh(S) ))
991 aNode->SetPosition(SMDS_PositionPtr(new SMDS_FacePosition(myCurSubID, u, v)));
994 //=======================================================================
995 //function : SetNodeOnEdge
997 //=======================================================================
998 void SMESHDS_Mesh::SetNodeOnEdge(SMDS_MeshNode * aNode,
999 const TopoDS_Edge & S,
1002 if ( add( aNode, getSubmesh(S) ))
1003 aNode->SetPosition(SMDS_PositionPtr(new SMDS_EdgePosition(myCurSubID, u)));
1006 //=======================================================================
1007 //function : SetNodeOnVertex
1009 //=======================================================================
1010 void SMESHDS_Mesh::SetNodeOnVertex(SMDS_MeshNode * aNode,
1011 const TopoDS_Vertex & S)
1013 if ( add( aNode, getSubmesh(S) ))
1014 aNode->SetPosition(SMDS_PositionPtr(new SMDS_VertexPosition(myCurSubID)));
1017 //=======================================================================
1018 //function : UnSetNodeOnShape
1020 //=======================================================================
1021 void SMESHDS_Mesh::UnSetNodeOnShape(const SMDS_MeshNode* aNode)
1023 if ( aNode && aNode->GetPosition() ) {
1024 map<int,SMESHDS_SubMesh*>::iterator it =
1025 myShapeIndexToSubMesh.find( aNode->GetPosition()->GetShapeId() );
1026 if ( it != myShapeIndexToSubMesh.end() )
1027 it->second->RemoveNode( aNode, /*deleted=*/false );
1031 //=======================================================================
1032 //function : SetMeshElementOnShape
1034 //=======================================================================
1035 void SMESHDS_Mesh::SetMeshElementOnShape(const SMDS_MeshElement * anElement,
1036 const TopoDS_Shape & S)
1038 add( anElement, getSubmesh(S) );
1041 //=======================================================================
1042 //function : UnSetMeshElementOnShape
1044 //=======================================================================
1045 void SMESHDS_Mesh::UnSetMeshElementOnShape(const SMDS_MeshElement * elem,
1046 const TopoDS_Shape & S)
1048 int Index = myIndexToShape.FindIndex(S);
1050 map<int,SMESHDS_SubMesh*>::iterator it = myShapeIndexToSubMesh.find( Index );
1051 if ( it != myShapeIndexToSubMesh.end() )
1052 if ( elem->GetType() == SMDSAbs_Node )
1053 it->second->RemoveNode( static_cast<const SMDS_MeshNode* >( elem ), /*deleted=*/false );
1055 it->second->RemoveElement( elem, /*deleted=*/false );
1058 //=======================================================================
1059 //function : ShapeToMesh
1061 //=======================================================================
1062 TopoDS_Shape SMESHDS_Mesh::ShapeToMesh() const
1067 //=======================================================================
1068 //function : IsGroupOfSubShapes
1069 //purpose : return true if at least one subshape of theShape is a subshape
1070 // of myShape or theShape == myShape
1071 //=======================================================================
1073 bool SMESHDS_Mesh::IsGroupOfSubShapes (const TopoDS_Shape& theShape) const
1075 if ( myShape.IsSame( theShape ))
1078 for ( TopoDS_Iterator it( theShape ); it.More(); it.Next() ) {
1079 if (myIndexToShape.Contains( it.Value() ) ||
1080 IsGroupOfSubShapes( it.Value() ))
1087 ///////////////////////////////////////////////////////////////////////////////
1088 /// Return the sub mesh linked to the a given TopoDS_Shape or NULL if the given
1089 /// TopoDS_Shape is unknown
1090 ///////////////////////////////////////////////////////////////////////////////
1091 SMESHDS_SubMesh * SMESHDS_Mesh::MeshElements(const TopoDS_Shape & S) const
1093 int Index = ShapeToIndex(S);
1094 TShapeIndexToSubMesh::const_iterator anIter = myShapeIndexToSubMesh.find(Index);
1095 if (anIter != myShapeIndexToSubMesh.end())
1096 return anIter->second;
1101 ///////////////////////////////////////////////////////////////////////////////
1102 /// Return the sub mesh by Id of shape it is linked to
1103 ///////////////////////////////////////////////////////////////////////////////
1104 SMESHDS_SubMesh * SMESHDS_Mesh::MeshElements(const int Index)
1106 TShapeIndexToSubMesh::const_iterator anIter = myShapeIndexToSubMesh.find(Index);
1107 if (anIter != myShapeIndexToSubMesh.end())
1108 return anIter->second;
1113 //=======================================================================
1114 //function : SubMeshIndices
1116 //=======================================================================
1117 list<int> SMESHDS_Mesh::SubMeshIndices()
1119 list<int> anIndices;
1120 std::map<int,SMESHDS_SubMesh*>::iterator anIter = myShapeIndexToSubMesh.begin();
1121 for (; anIter != myShapeIndexToSubMesh.end(); anIter++) {
1122 anIndices.push_back((*anIter).first);
1127 //=======================================================================
1128 //function : GetHypothesis
1130 //=======================================================================
1132 const list<const SMESHDS_Hypothesis*>&
1133 SMESHDS_Mesh::GetHypothesis(const TopoDS_Shape & S) const
1135 if ( myShapeToHypothesis.IsBound( S.Oriented(TopAbs_FORWARD) ) ) // ignore orientation of S
1136 return myShapeToHypothesis.Find( S.Oriented(TopAbs_FORWARD) );
1138 static list<const SMESHDS_Hypothesis*> empty;
1142 //=======================================================================
1143 //function : GetScript
1145 //=======================================================================
1146 SMESHDS_Script* SMESHDS_Mesh::GetScript()
1151 //=======================================================================
1152 //function : ClearScript
1154 //=======================================================================
1155 void SMESHDS_Mesh::ClearScript()
1160 //=======================================================================
1161 //function : HasMeshElements
1163 //=======================================================================
1164 bool SMESHDS_Mesh::HasMeshElements(const TopoDS_Shape & S)
1166 if (myShape.IsNull()) MESSAGE("myShape is NULL");
1167 int Index = myIndexToShape.FindIndex(S);
1168 return myShapeIndexToSubMesh.find(Index)!=myShapeIndexToSubMesh.end();
1171 //=======================================================================
1172 //function : HasHypothesis
1174 //=======================================================================
1175 bool SMESHDS_Mesh::HasHypothesis(const TopoDS_Shape & S)
1177 return myShapeToHypothesis.IsBound(S.Oriented(TopAbs_FORWARD));
1180 //=======================================================================
1181 //function : NewSubMesh
1183 //=======================================================================
1184 SMESHDS_SubMesh * SMESHDS_Mesh::NewSubMesh(int Index)
1186 SMESHDS_SubMesh* SM = 0;
1187 TShapeIndexToSubMesh::iterator anIter = myShapeIndexToSubMesh.find(Index);
1188 if (anIter == myShapeIndexToSubMesh.end())
1190 SM = new SMESHDS_SubMesh();
1191 myShapeIndexToSubMesh[Index]=SM;
1194 SM = anIter->second;
1198 //=======================================================================
1199 //function : AddCompoundSubmesh
1201 //=======================================================================
1203 int SMESHDS_Mesh::AddCompoundSubmesh(const TopoDS_Shape& S,
1204 TopAbs_ShapeEnum type)
1207 if ( IsGroupOfSubShapes( S ) || (S.ShapeType() == TopAbs_VERTEX && myIndexToShape.Contains(S)) )
1209 aMainIndex = myIndexToShape.Add( S );
1210 bool all = ( type == TopAbs_SHAPE );
1211 if ( all ) // corresponding simple submesh may exist
1212 aMainIndex = -aMainIndex;
1213 //MESSAGE("AddCompoundSubmesh index = " << aMainIndex );
1214 SMESHDS_SubMesh * aNewSub = NewSubMesh( aMainIndex );
1215 if ( !aNewSub->IsComplexSubmesh() ) // is empty
1217 int shapeType = Max( TopAbs_SOLID, all ? myShape.ShapeType() : type );
1218 int typeLimit = all ? TopAbs_VERTEX : type;
1219 for ( ; shapeType <= typeLimit; shapeType++ )
1221 TopExp_Explorer exp( S, TopAbs_ShapeEnum( shapeType ));
1222 for ( ; exp.More(); exp.Next() )
1224 int index = myIndexToShape.FindIndex( exp.Current() );
1226 aNewSub->AddSubMesh( NewSubMesh( index ));
1234 //=======================================================================
1235 //function : IndexToShape
1237 //=======================================================================
1238 const TopoDS_Shape& SMESHDS_Mesh::IndexToShape(int ShapeIndex) const
1242 return myIndexToShape.FindKey(ShapeIndex);
1244 catch ( Standard_OutOfRange )
1247 static TopoDS_Shape nullShape;
1251 //=======================================================================
1252 //function : ShapeToIndex
1254 //=======================================================================
1255 int SMESHDS_Mesh::ShapeToIndex(const TopoDS_Shape & S) const
1257 if (myShape.IsNull())
1258 MESSAGE("myShape is NULL");
1260 int index = myIndexToShape.FindIndex(S);
1265 //=======================================================================
1266 //function : SetNodeOnVolume
1268 //=======================================================================
1269 void SMESHDS_Mesh::SetNodeInVolume(const SMDS_MeshNode* aNode, int Index)
1271 if ( add( aNode, getSubmesh( Index )))
1272 ((SMDS_MeshNode*) aNode)->SetPosition( volumePosition( Index ));
1275 //=======================================================================
1276 //function : SetNodeOnFace
1278 //=======================================================================
1279 void SMESHDS_Mesh::SetNodeOnFace(SMDS_MeshNode* aNode, int Index, double u, double v)
1281 //Set Position on Node
1282 if ( add( aNode, getSubmesh( Index )))
1283 aNode->SetPosition(SMDS_PositionPtr(new SMDS_FacePosition(Index, u, v)));
1286 //=======================================================================
1287 //function : SetNodeOnEdge
1289 //=======================================================================
1290 void SMESHDS_Mesh::SetNodeOnEdge(SMDS_MeshNode* aNode,
1294 //Set Position on Node
1295 if ( add( aNode, getSubmesh( Index )))
1296 aNode->SetPosition(SMDS_PositionPtr(new SMDS_EdgePosition(Index, u)));
1299 //=======================================================================
1300 //function : SetNodeOnVertex
1302 //=======================================================================
1303 void SMESHDS_Mesh::SetNodeOnVertex(SMDS_MeshNode* aNode, int Index)
1305 //Set Position on Node
1306 if ( add( aNode, getSubmesh( Index )))
1307 aNode->SetPosition(SMDS_PositionPtr(new SMDS_VertexPosition(Index)));
1310 //=======================================================================
1311 //function : SetMeshElementOnShape
1313 //=======================================================================
1314 void SMESHDS_Mesh::SetMeshElementOnShape(const SMDS_MeshElement* anElement,
1317 add( anElement, getSubmesh( Index ));
1320 //=======================================================================
1321 //function : ~SMESHDS_Mesh
1323 //=======================================================================
1324 SMESHDS_Mesh::~SMESHDS_Mesh()
1329 TShapeIndexToSubMesh::iterator i_sm = myShapeIndexToSubMesh.begin();
1330 for ( ; i_sm != myShapeIndexToSubMesh.end(); ++i_sm )
1331 delete i_sm->second;
1335 //********************************************************************
1336 //********************************************************************
1337 //******** *********
1338 //***** Methods for addition of quadratic elements ******
1339 //******** *********
1340 //********************************************************************
1341 //********************************************************************
1343 //=======================================================================
1344 //function : AddEdgeWithID
1346 //=======================================================================
1347 SMDS_MeshEdge* SMESHDS_Mesh::AddEdgeWithID(int n1, int n2, int n12, int ID)
1349 SMDS_MeshEdge* anElem = SMDS_Mesh::AddEdgeWithID(n1,n2,n12,ID);
1350 if(anElem) myScript->AddEdge(ID,n1,n2,n12);
1354 //=======================================================================
1355 //function : AddEdge
1357 //=======================================================================
1358 SMDS_MeshEdge* SMESHDS_Mesh::AddEdge(const SMDS_MeshNode* n1,
1359 const SMDS_MeshNode* n2,
1360 const SMDS_MeshNode* n12)
1362 SMDS_MeshEdge* anElem = SMDS_Mesh::AddEdge(n1,n2,n12);
1363 if(anElem) myScript->AddEdge(anElem->GetID(),
1370 //=======================================================================
1371 //function : AddEdgeWithID
1373 //=======================================================================
1374 SMDS_MeshEdge* SMESHDS_Mesh::AddEdgeWithID(const SMDS_MeshNode * n1,
1375 const SMDS_MeshNode * n2,
1376 const SMDS_MeshNode * n12,
1379 return AddEdgeWithID(n1->GetID(),
1386 //=======================================================================
1387 //function : AddFace
1389 //=======================================================================
1390 SMDS_MeshFace* SMESHDS_Mesh::AddFace(const SMDS_MeshNode * n1,
1391 const SMDS_MeshNode * n2,
1392 const SMDS_MeshNode * n3,
1393 const SMDS_MeshNode * n12,
1394 const SMDS_MeshNode * n23,
1395 const SMDS_MeshNode * n31)
1397 SMDS_MeshFace *anElem = SMDS_Mesh::AddFace(n1,n2,n3,n12,n23,n31);
1398 if(anElem) myScript->AddFace(anElem->GetID(),
1399 n1->GetID(), n2->GetID(), n3->GetID(),
1400 n12->GetID(), n23->GetID(), n31->GetID());
1404 //=======================================================================
1405 //function : AddFaceWithID
1407 //=======================================================================
1408 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(int n1, int n2, int n3,
1409 int n12,int n23,int n31, int ID)
1411 SMDS_MeshFace *anElem = SMDS_Mesh::AddFaceWithID(n1,n2,n3,n12,n23,n31,ID);
1412 if(anElem) myScript->AddFace(ID,n1,n2,n3,n12,n23,n31);
1416 //=======================================================================
1417 //function : AddFaceWithID
1419 //=======================================================================
1420 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(const SMDS_MeshNode * n1,
1421 const SMDS_MeshNode * n2,
1422 const SMDS_MeshNode * n3,
1423 const SMDS_MeshNode * n12,
1424 const SMDS_MeshNode * n23,
1425 const SMDS_MeshNode * n31,
1428 return AddFaceWithID(n1->GetID(), n2->GetID(), n3->GetID(),
1429 n12->GetID(), n23->GetID(), n31->GetID(),
1434 //=======================================================================
1435 //function : AddFace
1437 //=======================================================================
1438 SMDS_MeshFace* SMESHDS_Mesh::AddFace(const SMDS_MeshNode * n1,
1439 const SMDS_MeshNode * n2,
1440 const SMDS_MeshNode * n3,
1441 const SMDS_MeshNode * n4,
1442 const SMDS_MeshNode * n12,
1443 const SMDS_MeshNode * n23,
1444 const SMDS_MeshNode * n34,
1445 const SMDS_MeshNode * n41)
1447 SMDS_MeshFace *anElem = SMDS_Mesh::AddFace(n1,n2,n3,n4,n12,n23,n34,n41);
1448 if(anElem) myScript->AddFace(anElem->GetID(),
1449 n1->GetID(), n2->GetID(), n3->GetID(), n4->GetID(),
1450 n12->GetID(), n23->GetID(), n34->GetID(), n41->GetID());
1454 //=======================================================================
1455 //function : AddFaceWithID
1457 //=======================================================================
1458 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(int n1, int n2, int n3, int n4,
1459 int n12,int n23,int n34,int n41, int ID)
1461 SMDS_MeshFace *anElem = SMDS_Mesh::AddFaceWithID(n1,n2,n3,n4,n12,n23,n34,n41,ID);
1462 if(anElem) myScript->AddFace(ID,n1,n2,n3,n4,n12,n23,n34,n41);
1466 //=======================================================================
1467 //function : AddFaceWithID
1469 //=======================================================================
1470 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(const SMDS_MeshNode * n1,
1471 const SMDS_MeshNode * n2,
1472 const SMDS_MeshNode * n3,
1473 const SMDS_MeshNode * n4,
1474 const SMDS_MeshNode * n12,
1475 const SMDS_MeshNode * n23,
1476 const SMDS_MeshNode * n34,
1477 const SMDS_MeshNode * n41,
1480 return AddFaceWithID(n1->GetID(), n2->GetID(), n3->GetID(), n4->GetID(),
1481 n12->GetID(), n23->GetID(), n34->GetID(), n41->GetID(),
1486 //=======================================================================
1487 //function : AddVolume
1489 //=======================================================================
1490 SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
1491 const SMDS_MeshNode * n2,
1492 const SMDS_MeshNode * n3,
1493 const SMDS_MeshNode * n4,
1494 const SMDS_MeshNode * n12,
1495 const SMDS_MeshNode * n23,
1496 const SMDS_MeshNode * n31,
1497 const SMDS_MeshNode * n14,
1498 const SMDS_MeshNode * n24,
1499 const SMDS_MeshNode * n34)
1501 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1,n2,n3,n4,n12,n23,n31,n14,n24,n34);
1502 if(anElem) myScript->AddVolume(anElem->GetID(),
1503 n1->GetID(), n2->GetID(), n3->GetID(), n4->GetID(),
1504 n12->GetID(), n23->GetID(), n31->GetID(),
1505 n14->GetID(), n24->GetID(), n34->GetID());
1509 //=======================================================================
1510 //function : AddVolumeWithID
1512 //=======================================================================
1513 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3, int n4,
1514 int n12,int n23,int n31,
1515 int n14,int n24,int n34, int ID)
1517 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolumeWithID(n1,n2,n3,n4,n12,n23,
1518 n31,n14,n24,n34,ID);
1519 if(anElem) myScript->AddVolume(ID,n1,n2,n3,n4,n12,n23,n31,n14,n24,n34);
1523 //=======================================================================
1524 //function : AddVolumeWithID
1525 //purpose : 2d order tetrahedron of 10 nodes
1526 //=======================================================================
1527 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
1528 const SMDS_MeshNode * n2,
1529 const SMDS_MeshNode * n3,
1530 const SMDS_MeshNode * n4,
1531 const SMDS_MeshNode * n12,
1532 const SMDS_MeshNode * n23,
1533 const SMDS_MeshNode * n31,
1534 const SMDS_MeshNode * n14,
1535 const SMDS_MeshNode * n24,
1536 const SMDS_MeshNode * n34,
1539 return AddVolumeWithID(n1->GetID(), n2->GetID(), n3->GetID(), n4->GetID(),
1540 n12->GetID(), n23->GetID(), n31->GetID(),
1541 n14->GetID(), n24->GetID(), n34->GetID(), ID);
1545 //=======================================================================
1546 //function : AddVolume
1548 //=======================================================================
1549 SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
1550 const SMDS_MeshNode * n2,
1551 const SMDS_MeshNode * n3,
1552 const SMDS_MeshNode * n4,
1553 const SMDS_MeshNode * n5,
1554 const SMDS_MeshNode * n12,
1555 const SMDS_MeshNode * n23,
1556 const SMDS_MeshNode * n34,
1557 const SMDS_MeshNode * n41,
1558 const SMDS_MeshNode * n15,
1559 const SMDS_MeshNode * n25,
1560 const SMDS_MeshNode * n35,
1561 const SMDS_MeshNode * n45)
1563 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1,n2,n3,n4,n5,n12,n23,n34,n41,
1566 myScript->AddVolume(anElem->GetID(), n1->GetID(), n2->GetID(),
1567 n3->GetID(), n4->GetID(), n5->GetID(),
1568 n12->GetID(), n23->GetID(), n34->GetID(), n41->GetID(),
1569 n15->GetID(), n25->GetID(), n35->GetID(), n45->GetID());
1573 //=======================================================================
1574 //function : AddVolumeWithID
1576 //=======================================================================
1577 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3, int n4, int n5,
1578 int n12,int n23,int n34,int n41,
1579 int n15,int n25,int n35,int n45, int ID)
1581 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolumeWithID(n1,n2,n3,n4,n5,
1583 n15,n25,n35,n45,ID);
1584 if(anElem) myScript->AddVolume(ID,n1,n2,n3,n4,n5,n12,n23,n34,n41,
1589 //=======================================================================
1590 //function : AddVolumeWithID
1591 //purpose : 2d order pyramid of 13 nodes
1592 //=======================================================================
1593 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
1594 const SMDS_MeshNode * n2,
1595 const SMDS_MeshNode * n3,
1596 const SMDS_MeshNode * n4,
1597 const SMDS_MeshNode * n5,
1598 const SMDS_MeshNode * n12,
1599 const SMDS_MeshNode * n23,
1600 const SMDS_MeshNode * n34,
1601 const SMDS_MeshNode * n41,
1602 const SMDS_MeshNode * n15,
1603 const SMDS_MeshNode * n25,
1604 const SMDS_MeshNode * n35,
1605 const SMDS_MeshNode * n45,
1608 return AddVolumeWithID(n1->GetID(), n2->GetID(), n3->GetID(),
1609 n4->GetID(), n5->GetID(),
1610 n12->GetID(), n23->GetID(), n34->GetID(), n41->GetID(),
1611 n15->GetID(), n25->GetID(), n35->GetID(), n45->GetID(),
1616 //=======================================================================
1617 //function : AddVolume
1619 //=======================================================================
1620 SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
1621 const SMDS_MeshNode * n2,
1622 const SMDS_MeshNode * n3,
1623 const SMDS_MeshNode * n4,
1624 const SMDS_MeshNode * n5,
1625 const SMDS_MeshNode * n6,
1626 const SMDS_MeshNode * n12,
1627 const SMDS_MeshNode * n23,
1628 const SMDS_MeshNode * n31,
1629 const SMDS_MeshNode * n45,
1630 const SMDS_MeshNode * n56,
1631 const SMDS_MeshNode * n64,
1632 const SMDS_MeshNode * n14,
1633 const SMDS_MeshNode * n25,
1634 const SMDS_MeshNode * n36)
1636 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1,n2,n3,n4,n5,n6,n12,n23,n31,
1637 n45,n56,n64,n14,n25,n36);
1639 myScript->AddVolume(anElem->GetID(), n1->GetID(), n2->GetID(),
1640 n3->GetID(), n4->GetID(), n5->GetID(), n6->GetID(),
1641 n12->GetID(), n23->GetID(), n31->GetID(),
1642 n45->GetID(), n56->GetID(), n64->GetID(),
1643 n14->GetID(), n25->GetID(), n36->GetID());
1647 //=======================================================================
1648 //function : AddVolumeWithID
1650 //=======================================================================
1651 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3,
1652 int n4, int n5, int n6,
1653 int n12,int n23,int n31,
1654 int n45,int n56,int n64,
1655 int n14,int n25,int n36, int ID)
1657 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolumeWithID(n1,n2,n3,n4,n5,n6,
1661 if(anElem) myScript->AddVolume(ID,n1,n2,n3,n4,n5,n6,n12,n23,n31,
1662 n45,n56,n64,n14,n25,n36);
1666 //=======================================================================
1667 //function : AddVolumeWithID
1668 //purpose : 2d order Pentahedron with 15 nodes
1669 //=======================================================================
1670 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
1671 const SMDS_MeshNode * n2,
1672 const SMDS_MeshNode * n3,
1673 const SMDS_MeshNode * n4,
1674 const SMDS_MeshNode * n5,
1675 const SMDS_MeshNode * n6,
1676 const SMDS_MeshNode * n12,
1677 const SMDS_MeshNode * n23,
1678 const SMDS_MeshNode * n31,
1679 const SMDS_MeshNode * n45,
1680 const SMDS_MeshNode * n56,
1681 const SMDS_MeshNode * n64,
1682 const SMDS_MeshNode * n14,
1683 const SMDS_MeshNode * n25,
1684 const SMDS_MeshNode * n36,
1687 return AddVolumeWithID(n1->GetID(), n2->GetID(), n3->GetID(),
1688 n4->GetID(), n5->GetID(), n6->GetID(),
1689 n12->GetID(), n23->GetID(), n31->GetID(),
1690 n45->GetID(), n56->GetID(), n64->GetID(),
1691 n14->GetID(), n25->GetID(), n36->GetID(),
1696 //=======================================================================
1697 //function : AddVolume
1699 //=======================================================================
1700 SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
1701 const SMDS_MeshNode * n2,
1702 const SMDS_MeshNode * n3,
1703 const SMDS_MeshNode * n4,
1704 const SMDS_MeshNode * n5,
1705 const SMDS_MeshNode * n6,
1706 const SMDS_MeshNode * n7,
1707 const SMDS_MeshNode * n8,
1708 const SMDS_MeshNode * n12,
1709 const SMDS_MeshNode * n23,
1710 const SMDS_MeshNode * n34,
1711 const SMDS_MeshNode * n41,
1712 const SMDS_MeshNode * n56,
1713 const SMDS_MeshNode * n67,
1714 const SMDS_MeshNode * n78,
1715 const SMDS_MeshNode * n85,
1716 const SMDS_MeshNode * n15,
1717 const SMDS_MeshNode * n26,
1718 const SMDS_MeshNode * n37,
1719 const SMDS_MeshNode * n48)
1721 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1,n2,n3,n4,n5,n6,n7,n8,
1726 myScript->AddVolume(anElem->GetID(), n1->GetID(), n2->GetID(),
1727 n3->GetID(), n4->GetID(), n5->GetID(),
1728 n6->GetID(), n7->GetID(), n8->GetID(),
1729 n12->GetID(), n23->GetID(), n34->GetID(), n41->GetID(),
1730 n56->GetID(), n67->GetID(), n78->GetID(), n85->GetID(),
1731 n15->GetID(), n26->GetID(), n37->GetID(), n48->GetID());
1735 //=======================================================================
1736 //function : AddVolumeWithID
1738 //=======================================================================
1739 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3, int n4,
1740 int n5, int n6, int n7, int n8,
1741 int n12,int n23,int n34,int n41,
1742 int n56,int n67,int n78,int n85,
1743 int n15,int n26,int n37,int n48, int ID)
1745 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolumeWithID(n1,n2,n3,n4,n5,n6,n7,n8,
1748 n15,n26,n37,n48,ID);
1749 if(anElem) myScript->AddVolume(ID,n1,n2,n3,n4,n5,n6,n7,n8,n12,n23,n34,n41,
1750 n56,n67,n78,n85,n15,n26,n37,n48);
1754 //=======================================================================
1755 //function : AddVolumeWithID
1756 //purpose : 2d order Hexahedrons with 20 nodes
1757 //=======================================================================
1758 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
1759 const SMDS_MeshNode * n2,
1760 const SMDS_MeshNode * n3,
1761 const SMDS_MeshNode * n4,
1762 const SMDS_MeshNode * n5,
1763 const SMDS_MeshNode * n6,
1764 const SMDS_MeshNode * n7,
1765 const SMDS_MeshNode * n8,
1766 const SMDS_MeshNode * n12,
1767 const SMDS_MeshNode * n23,
1768 const SMDS_MeshNode * n34,
1769 const SMDS_MeshNode * n41,
1770 const SMDS_MeshNode * n56,
1771 const SMDS_MeshNode * n67,
1772 const SMDS_MeshNode * n78,
1773 const SMDS_MeshNode * n85,
1774 const SMDS_MeshNode * n15,
1775 const SMDS_MeshNode * n26,
1776 const SMDS_MeshNode * n37,
1777 const SMDS_MeshNode * n48,
1780 return AddVolumeWithID(n1->GetID(), n2->GetID(), n3->GetID(), n4->GetID(),
1781 n5->GetID(), n6->GetID(), n7->GetID(), n8->GetID(),
1782 n12->GetID(), n23->GetID(), n34->GetID(), n41->GetID(),
1783 n56->GetID(), n67->GetID(), n78->GetID(), n85->GetID(),
1784 n15->GetID(), n26->GetID(), n37->GetID(), n48->GetID(),