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);
66 //=======================================================================
67 bool SMESHDS_Mesh::IsEmbeddedMode()
69 return myIsEmbeddedMode;
72 //=======================================================================
73 //function : ShapeToMesh
75 //=======================================================================
76 void SMESHDS_Mesh::ShapeToMesh(const TopoDS_Shape & S)
78 if ( !myShape.IsNull() && S.IsNull() )
80 // removal of a shape to mesh, delete ...
82 myShapeToHypothesis.Clear();
83 // - shape indices in SMDS_Position of nodes
84 map<int,SMESHDS_SubMesh*>::iterator i_sub = myShapeIndexToSubMesh.begin();
85 for ( ; i_sub != myShapeIndexToSubMesh.end(); i_sub++ ) {
86 if ( !i_sub->second->IsComplexSubmesh() ) {
87 SMDS_NodeIteratorPtr nIt = i_sub->second->GetNodes();
89 nIt->next()->GetPosition()->SetShapeId( 0 );
93 TShapeIndexToSubMesh::iterator i_sm = myShapeIndexToSubMesh.begin();
94 for ( ; i_sm != myShapeIndexToSubMesh.end(); ++i_sm )
96 myShapeIndexToSubMesh.clear();
97 myIndexToShape.Clear();
98 // - groups on geometry
99 set<SMESHDS_GroupBase*>::iterator gr = myGroups.begin();
100 while ( gr != myGroups.end() ) {
101 if ( dynamic_cast<SMESHDS_GroupOnGeom*>( *gr ))
102 myGroups.erase( gr++ );
110 TopExp::MapShapes(myShape, myIndexToShape);
114 //=======================================================================
115 //function : AddHypothesis
117 //=======================================================================
119 bool SMESHDS_Mesh::AddHypothesis(const TopoDS_Shape & SS,
120 const SMESHDS_Hypothesis * H)
122 if (!myShapeToHypothesis.IsBound(SS.Oriented(TopAbs_FORWARD))) {
123 list<const SMESHDS_Hypothesis *> aList;
124 myShapeToHypothesis.Bind(SS.Oriented(TopAbs_FORWARD), aList);
126 list<const SMESHDS_Hypothesis *>& alist =
127 myShapeToHypothesis(SS.Oriented(TopAbs_FORWARD)); // ignore orientation of SS
129 //Check if the Hypothesis is still present
130 list<const SMESHDS_Hypothesis*>::iterator ith = find(alist.begin(),alist.end(), H );
132 if (alist.end() != ith) return false;
138 //=======================================================================
139 //function : RemoveHypothesis
141 //=======================================================================
143 bool SMESHDS_Mesh::RemoveHypothesis(const TopoDS_Shape & S,
144 const SMESHDS_Hypothesis * H)
146 if( myShapeToHypothesis.IsBound( S.Oriented(TopAbs_FORWARD) ) )
148 list<const SMESHDS_Hypothesis *>& alist=myShapeToHypothesis.ChangeFind( S.Oriented(TopAbs_FORWARD) );
149 list<const SMESHDS_Hypothesis*>::iterator ith=find(alist.begin(),alist.end(), H );
150 if (ith != alist.end())
159 //=======================================================================
162 //=======================================================================
163 SMDS_MeshNode* SMESHDS_Mesh::AddNode(double x, double y, double z){
164 SMDS_MeshNode* node = SMDS_Mesh::AddNode(x, y, z);
165 if(node!=NULL) myScript->AddNode(node->GetID(), x, y, z);
169 SMDS_MeshNode* SMESHDS_Mesh::AddNodeWithID(double x, double y, double z, int ID){
170 SMDS_MeshNode* node = SMDS_Mesh::AddNodeWithID(x,y,z,ID);
171 if(node!=NULL) myScript->AddNode(node->GetID(), x, y, z);
175 //=======================================================================
176 //function : MoveNode
178 //=======================================================================
179 void SMESHDS_Mesh::MoveNode(const SMDS_MeshNode *n, double x, double y, double z)
181 SMDS_MeshNode * node=const_cast<SMDS_MeshNode*>(n);
183 myScript->MoveNode(n->GetID(), x, y, z);
186 //=======================================================================
187 //function : ChangeElementNodes
189 //=======================================================================
191 bool SMESHDS_Mesh::ChangeElementNodes(const SMDS_MeshElement * elem,
192 const SMDS_MeshNode * nodes[],
195 if ( ! SMDS_Mesh::ChangeElementNodes( elem, nodes, nbnodes ))
198 vector<int> IDs( nbnodes );
199 for ( int i = 0; i < nbnodes; i++ )
200 IDs [ i ] = nodes[ i ]->GetID();
201 myScript->ChangeElementNodes( elem->GetID(), &IDs[0], nbnodes);
206 //=======================================================================
207 //function : ChangePolygonNodes
209 //=======================================================================
210 bool SMESHDS_Mesh::ChangePolygonNodes
211 (const SMDS_MeshElement * elem,
212 vector<const SMDS_MeshNode*> nodes)
214 ASSERT(nodes.size() > 3);
216 return ChangeElementNodes(elem, &nodes[0], nodes.size());
219 //=======================================================================
220 //function : ChangePolyhedronNodes
222 //=======================================================================
223 bool SMESHDS_Mesh::ChangePolyhedronNodes
224 (const SMDS_MeshElement * elem,
225 std::vector<const SMDS_MeshNode*> nodes,
226 std::vector<int> quantities)
228 ASSERT(nodes.size() > 3);
230 if (!SMDS_Mesh::ChangePolyhedronNodes(elem, nodes, quantities))
233 int i, len = nodes.size();
234 std::vector<int> nodes_ids (len);
235 for (i = 0; i < len; i++) {
236 nodes_ids[i] = nodes[i]->GetID();
238 myScript->ChangePolyhedronNodes(elem->GetID(), nodes_ids, quantities);
243 //=======================================================================
244 //function : Renumber
246 //=======================================================================
248 void SMESHDS_Mesh::Renumber (const bool isNodes, const int startID, const int deltaID)
250 SMDS_Mesh::Renumber( isNodes, startID, deltaID );
251 myScript->Renumber( isNodes, startID, deltaID );
254 //=======================================================================
255 //function : Add0DElement
257 //=======================================================================
258 SMDS_Mesh0DElement* SMESHDS_Mesh::Add0DElementWithID(int nodeID, int ID)
260 SMDS_Mesh0DElement* anElem = SMDS_Mesh::Add0DElementWithID(nodeID, ID);
261 if (anElem) myScript->Add0DElement(ID, nodeID);
265 SMDS_Mesh0DElement* SMESHDS_Mesh::Add0DElementWithID
266 (const SMDS_MeshNode * node, int ID)
268 return Add0DElementWithID(node->GetID(), ID);
271 SMDS_Mesh0DElement* SMESHDS_Mesh::Add0DElement(const SMDS_MeshNode * node)
273 SMDS_Mesh0DElement* anElem = SMDS_Mesh::Add0DElement(node);
274 if (anElem) myScript->Add0DElement(anElem->GetID(), node->GetID());
278 //=======================================================================
279 //function :AddEdgeWithID
281 //=======================================================================
282 SMDS_MeshEdge* SMESHDS_Mesh::AddEdgeWithID(int n1, int n2, int ID)
284 SMDS_MeshEdge* anElem = SMDS_Mesh::AddEdgeWithID(n1,n2,ID);
285 if(anElem) myScript->AddEdge(ID,n1,n2);
289 SMDS_MeshEdge* SMESHDS_Mesh::AddEdgeWithID(const SMDS_MeshNode * n1,
290 const SMDS_MeshNode * n2,
293 return AddEdgeWithID(n1->GetID(),
298 SMDS_MeshEdge* SMESHDS_Mesh::AddEdge(const SMDS_MeshNode * n1,
299 const SMDS_MeshNode * n2)
301 SMDS_MeshEdge* anElem = SMDS_Mesh::AddEdge(n1,n2);
302 if(anElem) myScript->AddEdge(anElem->GetID(),
308 //=======================================================================
311 //=======================================================================
312 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(int n1, int n2, int n3, int ID)
314 SMDS_MeshFace *anElem = SMDS_Mesh::AddFaceWithID(n1, n2, n3, ID);
315 if(anElem) myScript->AddFace(ID,n1,n2,n3);
319 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(const SMDS_MeshNode * n1,
320 const SMDS_MeshNode * n2,
321 const SMDS_MeshNode * n3,
324 return AddFaceWithID(n1->GetID(),
330 SMDS_MeshFace* SMESHDS_Mesh::AddFace( const SMDS_MeshNode * n1,
331 const SMDS_MeshNode * n2,
332 const SMDS_MeshNode * n3)
334 SMDS_MeshFace *anElem = SMDS_Mesh::AddFace(n1, n2, n3);
335 if(anElem) myScript->AddFace(anElem->GetID(),
342 //=======================================================================
345 //=======================================================================
346 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(int n1, int n2, int n3, int n4, int ID)
348 SMDS_MeshFace *anElem = SMDS_Mesh::AddFaceWithID(n1, n2, n3, n4, ID);
349 if(anElem) myScript->AddFace(ID, n1, n2, n3, n4);
353 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(const SMDS_MeshNode * n1,
354 const SMDS_MeshNode * n2,
355 const SMDS_MeshNode * n3,
356 const SMDS_MeshNode * n4,
359 return AddFaceWithID(n1->GetID(),
366 SMDS_MeshFace* SMESHDS_Mesh::AddFace(const SMDS_MeshNode * n1,
367 const SMDS_MeshNode * n2,
368 const SMDS_MeshNode * n3,
369 const SMDS_MeshNode * n4)
371 SMDS_MeshFace *anElem = SMDS_Mesh::AddFace(n1, n2, n3, n4);
372 if(anElem) myScript->AddFace(anElem->GetID(),
380 //=======================================================================
381 //function :AddVolume
383 //=======================================================================
384 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3, int n4, int ID)
386 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolumeWithID(n1, n2, n3, n4, ID);
387 if(anElem) myScript->AddVolume(ID, n1, n2, n3, n4);
391 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
392 const SMDS_MeshNode * n2,
393 const SMDS_MeshNode * n3,
394 const SMDS_MeshNode * n4,
397 return AddVolumeWithID(n1->GetID(),
404 SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
405 const SMDS_MeshNode * n2,
406 const SMDS_MeshNode * n3,
407 const SMDS_MeshNode * n4)
409 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1, n2, n3, n4);
410 if(anElem) myScript->AddVolume(anElem->GetID(),
418 //=======================================================================
419 //function :AddVolume
421 //=======================================================================
422 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3, int n4, int n5, int ID)
424 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolumeWithID(n1, n2, n3, n4, n5, ID);
425 if(anElem) myScript->AddVolume(ID, n1, n2, n3, n4, n5);
429 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
430 const SMDS_MeshNode * n2,
431 const SMDS_MeshNode * n3,
432 const SMDS_MeshNode * n4,
433 const SMDS_MeshNode * n5,
436 return AddVolumeWithID(n1->GetID(),
444 SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
445 const SMDS_MeshNode * n2,
446 const SMDS_MeshNode * n3,
447 const SMDS_MeshNode * n4,
448 const SMDS_MeshNode * n5)
450 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1, n2, n3, n4, n5);
451 if(anElem) myScript->AddVolume(anElem->GetID(),
460 //=======================================================================
461 //function :AddVolume
463 //=======================================================================
464 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3, int n4, int n5, int n6, int ID)
466 SMDS_MeshVolume *anElem= SMDS_Mesh::AddVolumeWithID(n1, n2, n3, n4, n5, n6, ID);
467 if(anElem) myScript->AddVolume(ID, n1, n2, n3, n4, n5, n6);
471 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
472 const SMDS_MeshNode * n2,
473 const SMDS_MeshNode * n3,
474 const SMDS_MeshNode * n4,
475 const SMDS_MeshNode * n5,
476 const SMDS_MeshNode * n6,
479 return AddVolumeWithID(n1->GetID(),
488 SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
489 const SMDS_MeshNode * n2,
490 const SMDS_MeshNode * n3,
491 const SMDS_MeshNode * n4,
492 const SMDS_MeshNode * n5,
493 const SMDS_MeshNode * n6)
495 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1, n2, n3, n4, n5, n6);
496 if(anElem) myScript->AddVolume(anElem->GetID(),
506 //=======================================================================
507 //function :AddVolume
509 //=======================================================================
510 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3, int n4, int n5, int n6, int n7, int n8, int ID)
512 SMDS_MeshVolume *anElem= SMDS_Mesh::AddVolumeWithID(n1, n2, n3, n4, n5, n6, n7, n8, ID);
513 if(anElem) myScript->AddVolume(ID, n1, n2, n3, n4, n5, n6, n7, n8);
517 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
518 const SMDS_MeshNode * n2,
519 const SMDS_MeshNode * n3,
520 const SMDS_MeshNode * n4,
521 const SMDS_MeshNode * n5,
522 const SMDS_MeshNode * n6,
523 const SMDS_MeshNode * n7,
524 const SMDS_MeshNode * n8,
527 return AddVolumeWithID(n1->GetID(),
538 SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
539 const SMDS_MeshNode * n2,
540 const SMDS_MeshNode * n3,
541 const SMDS_MeshNode * n4,
542 const SMDS_MeshNode * n5,
543 const SMDS_MeshNode * n6,
544 const SMDS_MeshNode * n7,
545 const SMDS_MeshNode * n8)
547 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1, n2, n3, n4, n5, n6, n7, n8);
548 if(anElem) myScript->AddVolume(anElem->GetID(),
560 //=======================================================================
561 //function : AddPolygonalFace
563 //=======================================================================
564 SMDS_MeshFace* SMESHDS_Mesh::AddPolygonalFaceWithID (std::vector<int> nodes_ids,
567 SMDS_MeshFace *anElem = SMDS_Mesh::AddPolygonalFaceWithID(nodes_ids, ID);
569 myScript->AddPolygonalFace(ID, nodes_ids);
574 SMDS_MeshFace* SMESHDS_Mesh::AddPolygonalFaceWithID
575 (std::vector<const SMDS_MeshNode*> nodes,
578 SMDS_MeshFace *anElem = SMDS_Mesh::AddPolygonalFaceWithID(nodes, ID);
580 int i, len = nodes.size();
581 std::vector<int> nodes_ids (len);
582 for (i = 0; i < len; i++) {
583 nodes_ids[i] = nodes[i]->GetID();
585 myScript->AddPolygonalFace(ID, nodes_ids);
590 SMDS_MeshFace* SMESHDS_Mesh::AddPolygonalFace
591 (std::vector<const SMDS_MeshNode*> nodes)
593 SMDS_MeshFace *anElem = SMDS_Mesh::AddPolygonalFace(nodes);
595 int i, len = nodes.size();
596 std::vector<int> nodes_ids (len);
597 for (i = 0; i < len; i++) {
598 nodes_ids[i] = nodes[i]->GetID();
600 myScript->AddPolygonalFace(anElem->GetID(), nodes_ids);
605 //=======================================================================
606 //function : AddPolyhedralVolume
608 //=======================================================================
609 SMDS_MeshVolume* SMESHDS_Mesh::AddPolyhedralVolumeWithID (std::vector<int> nodes_ids,
610 std::vector<int> quantities,
613 SMDS_MeshVolume *anElem = SMDS_Mesh::AddPolyhedralVolumeWithID(nodes_ids, quantities, ID);
615 myScript->AddPolyhedralVolume(ID, nodes_ids, quantities);
620 SMDS_MeshVolume* SMESHDS_Mesh::AddPolyhedralVolumeWithID
621 (std::vector<const SMDS_MeshNode*> nodes,
622 std::vector<int> quantities,
625 SMDS_MeshVolume *anElem = SMDS_Mesh::AddPolyhedralVolumeWithID(nodes, quantities, ID);
627 int i, len = nodes.size();
628 std::vector<int> nodes_ids (len);
629 for (i = 0; i < len; i++) {
630 nodes_ids[i] = nodes[i]->GetID();
632 myScript->AddPolyhedralVolume(ID, nodes_ids, quantities);
637 SMDS_MeshVolume* SMESHDS_Mesh::AddPolyhedralVolume
638 (std::vector<const SMDS_MeshNode*> nodes,
639 std::vector<int> quantities)
641 SMDS_MeshVolume *anElem = SMDS_Mesh::AddPolyhedralVolume(nodes, quantities);
643 int i, len = nodes.size();
644 std::vector<int> nodes_ids (len);
645 for (i = 0; i < len; i++) {
646 nodes_ids[i] = nodes[i]->GetID();
648 myScript->AddPolyhedralVolume(anElem->GetID(), nodes_ids, quantities);
653 //=======================================================================
654 //function : removeFromContainers
656 //=======================================================================
658 static void removeFromContainers (map<int,SMESHDS_SubMesh*>& theSubMeshes,
659 set<SMESHDS_GroupBase*>& theGroups,
660 list<const SMDS_MeshElement*>& theElems,
663 if ( theElems.empty() )
667 // Element can belong to several groups
668 if ( !theGroups.empty() )
670 set<SMESHDS_GroupBase*>::iterator GrIt = theGroups.begin();
671 for ( ; GrIt != theGroups.end(); GrIt++ )
673 SMESHDS_Group* group = dynamic_cast<SMESHDS_Group*>( *GrIt );
674 if ( !group || group->IsEmpty() ) continue;
676 list<const SMDS_MeshElement *>::iterator elIt = theElems.begin();
677 for ( ; elIt != theElems.end(); elIt++ )
679 group->SMDSGroup().Remove( *elIt );
680 if ( group->IsEmpty() ) break;
685 const bool deleted=true;
687 // Rm from sub-meshes
688 // Element should belong to only one sub-mesh
689 map<int,SMESHDS_SubMesh*>::iterator SubIt = theSubMeshes.begin();
690 for ( ; SubIt != theSubMeshes.end(); SubIt++ )
692 int size = isNode ? (*SubIt).second->NbNodes() : (*SubIt).second->NbElements();
693 if ( size == 0 ) continue;
695 list<const SMDS_MeshElement *>::iterator elIt = theElems.begin();
696 while ( elIt != theElems.end() )
698 bool removed = false;
700 removed = (*SubIt).second->RemoveNode( static_cast<const SMDS_MeshNode*> (*elIt), deleted );
702 removed = (*SubIt).second->RemoveElement( *elIt, deleted );
706 elIt = theElems.erase( elIt );
707 if ( theElems.empty() )
708 return; // all elements are found and removed
718 //=======================================================================
719 //function : RemoveNode
721 //=======================================================================
722 void SMESHDS_Mesh::RemoveNode(const SMDS_MeshNode * n)
724 if ( n->NbInverseElements() == 0 && !(hasConstructionEdges() || hasConstructionFaces()))
726 SMESHDS_SubMesh* subMesh=0;
727 map<int,SMESHDS_SubMesh*>::iterator SubIt =
728 myShapeIndexToSubMesh.find( n->GetPosition()->GetShapeId() );
729 if ( SubIt != myShapeIndexToSubMesh.end() )
730 subMesh = SubIt->second;
732 SubIt = myShapeIndexToSubMesh.begin();
733 for ( ; !subMesh && SubIt != myShapeIndexToSubMesh.end(); SubIt++ )
734 if (!SubIt->second->IsComplexSubmesh() && SubIt->second->Contains( n ))
735 subMesh = SubIt->second;
737 RemoveFreeNode( n, subMesh, true);
741 myScript->RemoveNode(n->GetID());
743 list<const SMDS_MeshElement *> removedElems;
744 list<const SMDS_MeshElement *> removedNodes;
746 SMDS_Mesh::RemoveElement( n, removedElems, removedNodes, true );
748 removeFromContainers( myShapeIndexToSubMesh, myGroups, removedElems, false );
749 removeFromContainers( myShapeIndexToSubMesh, myGroups, removedNodes, true );
752 //=======================================================================
753 //function : RemoveFreeNode
755 //=======================================================================
756 void SMESHDS_Mesh::RemoveFreeNode(const SMDS_MeshNode * n,
757 SMESHDS_SubMesh * subMesh,
760 myScript->RemoveNode(n->GetID());
763 // Node can belong to several groups
764 if (fromGroups && !myGroups.empty()) {
765 set<SMESHDS_GroupBase*>::iterator GrIt = myGroups.begin();
766 for (; GrIt != myGroups.end(); GrIt++) {
767 SMESHDS_Group* group = dynamic_cast<SMESHDS_Group*>(*GrIt);
768 if (!group || group->IsEmpty()) continue;
769 group->SMDSGroup().Remove(n);
774 // Node should belong to only one sub-mesh
776 subMesh->RemoveNode(n,/*deleted=*/false);
778 SMDS_Mesh::RemoveFreeElement(n);
781 //=======================================================================
782 //function : RemoveElement
784 //========================================================================
785 void SMESHDS_Mesh::RemoveElement(const SMDS_MeshElement * elt)
787 if (elt->GetType() == SMDSAbs_Node)
789 RemoveNode( static_cast<const SMDS_MeshNode*>( elt ));
792 if (!hasConstructionEdges() && !hasConstructionFaces())
794 SMESHDS_SubMesh* subMesh=0;
795 map<int,SMESHDS_SubMesh*>::iterator SubIt = myShapeIndexToSubMesh.begin();
796 for ( ; !subMesh && SubIt != myShapeIndexToSubMesh.end(); SubIt++ )
797 if (!SubIt->second->IsComplexSubmesh() && SubIt->second->Contains( elt ))
798 subMesh = SubIt->second;
800 RemoveFreeElement( elt, subMesh, true);
804 myScript->RemoveElement(elt->GetID());
806 list<const SMDS_MeshElement *> removedElems;
807 list<const SMDS_MeshElement *> removedNodes;
809 SMDS_Mesh::RemoveElement(elt, removedElems, removedNodes, false);
811 removeFromContainers( myShapeIndexToSubMesh, myGroups, removedElems, false );
814 //=======================================================================
815 //function : RemoveFreeElement
817 //========================================================================
818 void SMESHDS_Mesh::RemoveFreeElement(const SMDS_MeshElement * elt,
819 SMESHDS_SubMesh * subMesh,
822 if (elt->GetType() == SMDSAbs_Node) {
823 RemoveFreeNode( static_cast<const SMDS_MeshNode*>(elt), subMesh);
827 if (hasConstructionEdges() || hasConstructionFaces())
828 // this methods is only for meshes without descendants
831 myScript->RemoveElement(elt->GetID());
834 // Node can belong to several groups
835 if ( fromGroups && !myGroups.empty() ) {
836 set<SMESHDS_GroupBase*>::iterator GrIt = myGroups.begin();
837 for (; GrIt != myGroups.end(); GrIt++) {
838 SMESHDS_Group* group = dynamic_cast<SMESHDS_Group*>(*GrIt);
839 if (group && !group->IsEmpty())
840 group->SMDSGroup().Remove(elt);
845 // Element should belong to only one sub-mesh
847 subMesh->RemoveElement(elt, /*deleted=*/false);
849 SMDS_Mesh::RemoveFreeElement(elt);
852 //================================================================================
854 * \brief Remove all data from the mesh
856 //================================================================================
858 void SMESHDS_Mesh::ClearMesh()
860 myScript->ClearMesh();
864 map<int,SMESHDS_SubMesh*>::iterator sub, subEnd = myShapeIndexToSubMesh.end();
865 for ( sub = myShapeIndexToSubMesh.begin(); sub != subEnd; ++sub )
866 sub->second->Clear();
869 TGroups::iterator group, groupEnd = myGroups.end();
870 for ( group = myGroups.begin(); group != groupEnd; ++group ) {
871 if ( SMESHDS_Group* g = dynamic_cast<SMESHDS_Group*>(*group)) {
872 SMDSAbs_ElementType groupType = g->GetType();
874 g->SetType( groupType );
879 //================================================================================
881 * \brief return submesh by shape
882 * \param shape - the subshape
883 * \retval SMESHDS_SubMesh* - the found submesh
885 * search of submeshes is optimized
887 //================================================================================
889 SMESHDS_SubMesh* SMESHDS_Mesh::getSubmesh( const TopoDS_Shape & shape )
891 if ( shape.IsNull() )
894 if ( !myCurSubShape.IsNull() && shape.IsSame( myCurSubShape ))
897 getSubmesh( ShapeToIndex( shape ));
898 myCurSubShape = shape;
902 //================================================================================
904 * \brief return submesh by subshape index
905 * \param Index - the subshape index
906 * \retval SMESHDS_SubMesh* - the found submesh
907 * search of submeshes is optimized
909 //================================================================================
911 SMESHDS_SubMesh* SMESHDS_Mesh::getSubmesh( const int Index )
913 //Update or build submesh
914 if ( Index != myCurSubID ) {
915 map<int,SMESHDS_SubMesh*>::iterator it = myShapeIndexToSubMesh.find( Index );
916 if ( it == myShapeIndexToSubMesh.end() )
917 it = myShapeIndexToSubMesh.insert( make_pair(Index, new SMESHDS_SubMesh() )).first;
918 myCurSubMesh = it->second;
920 myCurSubShape.Nullify(); // myCurSubShape no more corresponds to submesh
925 //================================================================================
927 * \brief Add element or node to submesh
928 * \param elem - element to add
929 * \param subMesh - submesh to be filled in
931 //================================================================================
933 bool SMESHDS_Mesh::add(const SMDS_MeshElement* elem, SMESHDS_SubMesh* subMesh )
935 if ( elem && subMesh ) {
936 if ( elem->GetType() == SMDSAbs_Node )
937 subMesh->AddNode( static_cast<const SMDS_MeshNode* >( elem ));
939 subMesh->AddElement( elem );
947 //================================================================================
949 * \brief Creates a node position in volume
951 //================================================================================
953 inline SMDS_PositionPtr volumePosition(int volId)
955 SMDS_SpacePosition* pos = new SMDS_SpacePosition();
956 pos->SetShapeId( volId );
957 return SMDS_PositionPtr(pos);
961 //=======================================================================
962 //function : SetNodeOnVolume
964 //=======================================================================
965 void SMESHDS_Mesh::SetNodeInVolume(SMDS_MeshNode * aNode,
966 const TopoDS_Shell & S)
968 if ( add( aNode, getSubmesh(S) ))
969 aNode->SetPosition ( volumePosition( myCurSubID ));
971 //=======================================================================
972 //function : SetNodeOnVolume
974 //=======================================================================
975 void SMESHDS_Mesh::SetNodeInVolume(SMDS_MeshNode * aNode,
976 const TopoDS_Solid & S)
978 if ( add( aNode, getSubmesh(S) ))
979 aNode->SetPosition ( volumePosition( myCurSubID ));
982 //=======================================================================
983 //function : SetNodeOnFace
985 //=======================================================================
986 void SMESHDS_Mesh::SetNodeOnFace(SMDS_MeshNode * aNode,
987 const TopoDS_Face & S,
991 if ( add( aNode, getSubmesh(S) ))
992 aNode->SetPosition(SMDS_PositionPtr(new SMDS_FacePosition(myCurSubID, u, v)));
995 //=======================================================================
996 //function : SetNodeOnEdge
998 //=======================================================================
999 void SMESHDS_Mesh::SetNodeOnEdge(SMDS_MeshNode * aNode,
1000 const TopoDS_Edge & S,
1003 if ( add( aNode, getSubmesh(S) ))
1004 aNode->SetPosition(SMDS_PositionPtr(new SMDS_EdgePosition(myCurSubID, u)));
1007 //=======================================================================
1008 //function : SetNodeOnVertex
1010 //=======================================================================
1011 void SMESHDS_Mesh::SetNodeOnVertex(SMDS_MeshNode * aNode,
1012 const TopoDS_Vertex & S)
1014 if ( add( aNode, getSubmesh(S) ))
1015 aNode->SetPosition(SMDS_PositionPtr(new SMDS_VertexPosition(myCurSubID)));
1018 //=======================================================================
1019 //function : UnSetNodeOnShape
1021 //=======================================================================
1022 void SMESHDS_Mesh::UnSetNodeOnShape(const SMDS_MeshNode* aNode)
1024 if ( aNode && aNode->GetPosition() ) {
1025 map<int,SMESHDS_SubMesh*>::iterator it =
1026 myShapeIndexToSubMesh.find( aNode->GetPosition()->GetShapeId() );
1027 if ( it != myShapeIndexToSubMesh.end() )
1028 it->second->RemoveNode( aNode, /*deleted=*/false );
1032 //=======================================================================
1033 //function : SetMeshElementOnShape
1035 //=======================================================================
1036 void SMESHDS_Mesh::SetMeshElementOnShape(const SMDS_MeshElement * anElement,
1037 const TopoDS_Shape & S)
1039 add( anElement, getSubmesh(S) );
1042 //=======================================================================
1043 //function : UnSetMeshElementOnShape
1045 //=======================================================================
1046 void SMESHDS_Mesh::UnSetMeshElementOnShape(const SMDS_MeshElement * elem,
1047 const TopoDS_Shape & S)
1049 int Index = myIndexToShape.FindIndex(S);
1051 map<int,SMESHDS_SubMesh*>::iterator it = myShapeIndexToSubMesh.find( Index );
1052 if ( it != myShapeIndexToSubMesh.end() )
1053 if ( elem->GetType() == SMDSAbs_Node )
1054 it->second->RemoveNode( static_cast<const SMDS_MeshNode* >( elem ), /*deleted=*/false );
1056 it->second->RemoveElement( elem, /*deleted=*/false );
1059 //=======================================================================
1060 //function : ShapeToMesh
1062 //=======================================================================
1063 TopoDS_Shape SMESHDS_Mesh::ShapeToMesh() const
1068 //=======================================================================
1069 //function : IsGroupOfSubShapes
1070 //purpose : return true if at least one subshape of theShape is a subshape
1071 // of myShape or theShape == myShape
1072 //=======================================================================
1074 bool SMESHDS_Mesh::IsGroupOfSubShapes (const TopoDS_Shape& theShape) const
1076 if ( myShape.IsSame( theShape ))
1079 for ( TopoDS_Iterator it( theShape ); it.More(); it.Next() ) {
1080 if (myIndexToShape.Contains( it.Value() ) ||
1081 IsGroupOfSubShapes( it.Value() ))
1088 ///////////////////////////////////////////////////////////////////////////////
1089 /// Return the sub mesh linked to the a given TopoDS_Shape or NULL if the given
1090 /// TopoDS_Shape is unknown
1091 ///////////////////////////////////////////////////////////////////////////////
1092 SMESHDS_SubMesh * SMESHDS_Mesh::MeshElements(const TopoDS_Shape & S) const
1094 int Index = ShapeToIndex(S);
1095 TShapeIndexToSubMesh::const_iterator anIter = myShapeIndexToSubMesh.find(Index);
1096 if (anIter != myShapeIndexToSubMesh.end())
1097 return anIter->second;
1102 ///////////////////////////////////////////////////////////////////////////////
1103 /// Return the sub mesh by Id of shape it is linked to
1104 ///////////////////////////////////////////////////////////////////////////////
1105 SMESHDS_SubMesh * SMESHDS_Mesh::MeshElements(const int Index)
1107 TShapeIndexToSubMesh::const_iterator anIter = myShapeIndexToSubMesh.find(Index);
1108 if (anIter != myShapeIndexToSubMesh.end())
1109 return anIter->second;
1114 //=======================================================================
1115 //function : SubMeshIndices
1117 //=======================================================================
1118 list<int> SMESHDS_Mesh::SubMeshIndices()
1120 list<int> anIndices;
1121 std::map<int,SMESHDS_SubMesh*>::iterator anIter = myShapeIndexToSubMesh.begin();
1122 for (; anIter != myShapeIndexToSubMesh.end(); anIter++) {
1123 anIndices.push_back((*anIter).first);
1128 //=======================================================================
1129 //function : GetHypothesis
1131 //=======================================================================
1133 const list<const SMESHDS_Hypothesis*>&
1134 SMESHDS_Mesh::GetHypothesis(const TopoDS_Shape & S) const
1136 if ( myShapeToHypothesis.IsBound( S.Oriented(TopAbs_FORWARD) ) ) // ignore orientation of S
1137 return myShapeToHypothesis.Find( S.Oriented(TopAbs_FORWARD) );
1139 static list<const SMESHDS_Hypothesis*> empty;
1143 //=======================================================================
1144 //function : GetScript
1146 //=======================================================================
1147 SMESHDS_Script* SMESHDS_Mesh::GetScript()
1152 //=======================================================================
1153 //function : ClearScript
1155 //=======================================================================
1156 void SMESHDS_Mesh::ClearScript()
1161 //=======================================================================
1162 //function : HasMeshElements
1164 //=======================================================================
1165 bool SMESHDS_Mesh::HasMeshElements(const TopoDS_Shape & S)
1167 if (myShape.IsNull()) MESSAGE("myShape is NULL");
1168 int Index = myIndexToShape.FindIndex(S);
1169 return myShapeIndexToSubMesh.find(Index)!=myShapeIndexToSubMesh.end();
1172 //=======================================================================
1173 //function : HasHypothesis
1175 //=======================================================================
1176 bool SMESHDS_Mesh::HasHypothesis(const TopoDS_Shape & S)
1178 return myShapeToHypothesis.IsBound(S.Oriented(TopAbs_FORWARD));
1181 //=======================================================================
1182 //function : NewSubMesh
1184 //=======================================================================
1185 SMESHDS_SubMesh * SMESHDS_Mesh::NewSubMesh(int Index)
1187 SMESHDS_SubMesh* SM = 0;
1188 TShapeIndexToSubMesh::iterator anIter = myShapeIndexToSubMesh.find(Index);
1189 if (anIter == myShapeIndexToSubMesh.end())
1191 SM = new SMESHDS_SubMesh();
1192 myShapeIndexToSubMesh[Index]=SM;
1195 SM = anIter->second;
1199 //=======================================================================
1200 //function : AddCompoundSubmesh
1202 //=======================================================================
1204 int SMESHDS_Mesh::AddCompoundSubmesh(const TopoDS_Shape& S,
1205 TopAbs_ShapeEnum type)
1208 if ( IsGroupOfSubShapes( S ) || (S.ShapeType() == TopAbs_VERTEX && myIndexToShape.Contains(S)) )
1210 aMainIndex = myIndexToShape.Add( S );
1211 bool all = ( type == TopAbs_SHAPE );
1212 if ( all ) // corresponding simple submesh may exist
1213 aMainIndex = -aMainIndex;
1214 //MESSAGE("AddCompoundSubmesh index = " << aMainIndex );
1215 SMESHDS_SubMesh * aNewSub = NewSubMesh( aMainIndex );
1216 if ( !aNewSub->IsComplexSubmesh() ) // is empty
1218 int shapeType = Max( TopAbs_SOLID, all ? myShape.ShapeType() : type );
1219 int typeLimit = all ? TopAbs_VERTEX : type;
1220 for ( ; shapeType <= typeLimit; shapeType++ )
1222 TopExp_Explorer exp( S, TopAbs_ShapeEnum( shapeType ));
1223 for ( ; exp.More(); exp.Next() )
1225 int index = myIndexToShape.FindIndex( exp.Current() );
1227 aNewSub->AddSubMesh( NewSubMesh( index ));
1235 //=======================================================================
1236 //function : IndexToShape
1238 //=======================================================================
1239 const TopoDS_Shape& SMESHDS_Mesh::IndexToShape(int ShapeIndex) const
1243 return myIndexToShape.FindKey(ShapeIndex);
1245 catch ( Standard_OutOfRange )
1248 static TopoDS_Shape nullShape;
1252 //=======================================================================
1253 //function : ShapeToIndex
1255 //=======================================================================
1256 int SMESHDS_Mesh::ShapeToIndex(const TopoDS_Shape & S) const
1258 if (myShape.IsNull())
1259 MESSAGE("myShape is NULL");
1261 int index = myIndexToShape.FindIndex(S);
1266 //=======================================================================
1267 //function : SetNodeOnVolume
1269 //=======================================================================
1270 void SMESHDS_Mesh::SetNodeInVolume(const SMDS_MeshNode* aNode, int Index)
1272 if ( add( aNode, getSubmesh( Index )))
1273 ((SMDS_MeshNode*) aNode)->SetPosition( volumePosition( Index ));
1276 //=======================================================================
1277 //function : SetNodeOnFace
1279 //=======================================================================
1280 void SMESHDS_Mesh::SetNodeOnFace(SMDS_MeshNode* aNode, int Index, double u, double v)
1282 //Set Position on Node
1283 if ( add( aNode, getSubmesh( Index )))
1284 aNode->SetPosition(SMDS_PositionPtr(new SMDS_FacePosition(Index, u, v)));
1287 //=======================================================================
1288 //function : SetNodeOnEdge
1290 //=======================================================================
1291 void SMESHDS_Mesh::SetNodeOnEdge(SMDS_MeshNode* aNode,
1295 //Set Position on Node
1296 if ( add( aNode, getSubmesh( Index )))
1297 aNode->SetPosition(SMDS_PositionPtr(new SMDS_EdgePosition(Index, u)));
1300 //=======================================================================
1301 //function : SetNodeOnVertex
1303 //=======================================================================
1304 void SMESHDS_Mesh::SetNodeOnVertex(SMDS_MeshNode* aNode, int Index)
1306 //Set Position on Node
1307 if ( add( aNode, getSubmesh( Index )))
1308 aNode->SetPosition(SMDS_PositionPtr(new SMDS_VertexPosition(Index)));
1311 //=======================================================================
1312 //function : SetMeshElementOnShape
1314 //=======================================================================
1315 void SMESHDS_Mesh::SetMeshElementOnShape(const SMDS_MeshElement* anElement,
1318 add( anElement, getSubmesh( Index ));
1321 //=======================================================================
1322 //function : ~SMESHDS_Mesh
1324 //=======================================================================
1325 SMESHDS_Mesh::~SMESHDS_Mesh()
1330 TShapeIndexToSubMesh::iterator i_sm = myShapeIndexToSubMesh.begin();
1331 for ( ; i_sm != myShapeIndexToSubMesh.end(); ++i_sm )
1332 delete i_sm->second;
1336 //********************************************************************
1337 //********************************************************************
1338 //******** *********
1339 //***** Methods for addition of quadratic elements ******
1340 //******** *********
1341 //********************************************************************
1342 //********************************************************************
1344 //=======================================================================
1345 //function : AddEdgeWithID
1347 //=======================================================================
1348 SMDS_MeshEdge* SMESHDS_Mesh::AddEdgeWithID(int n1, int n2, int n12, int ID)
1350 SMDS_MeshEdge* anElem = SMDS_Mesh::AddEdgeWithID(n1,n2,n12,ID);
1351 if(anElem) myScript->AddEdge(ID,n1,n2,n12);
1355 //=======================================================================
1356 //function : AddEdge
1358 //=======================================================================
1359 SMDS_MeshEdge* SMESHDS_Mesh::AddEdge(const SMDS_MeshNode* n1,
1360 const SMDS_MeshNode* n2,
1361 const SMDS_MeshNode* n12)
1363 SMDS_MeshEdge* anElem = SMDS_Mesh::AddEdge(n1,n2,n12);
1364 if(anElem) myScript->AddEdge(anElem->GetID(),
1371 //=======================================================================
1372 //function : AddEdgeWithID
1374 //=======================================================================
1375 SMDS_MeshEdge* SMESHDS_Mesh::AddEdgeWithID(const SMDS_MeshNode * n1,
1376 const SMDS_MeshNode * n2,
1377 const SMDS_MeshNode * n12,
1380 return AddEdgeWithID(n1->GetID(),
1387 //=======================================================================
1388 //function : AddFace
1390 //=======================================================================
1391 SMDS_MeshFace* SMESHDS_Mesh::AddFace(const SMDS_MeshNode * n1,
1392 const SMDS_MeshNode * n2,
1393 const SMDS_MeshNode * n3,
1394 const SMDS_MeshNode * n12,
1395 const SMDS_MeshNode * n23,
1396 const SMDS_MeshNode * n31)
1398 SMDS_MeshFace *anElem = SMDS_Mesh::AddFace(n1,n2,n3,n12,n23,n31);
1399 if(anElem) myScript->AddFace(anElem->GetID(),
1400 n1->GetID(), n2->GetID(), n3->GetID(),
1401 n12->GetID(), n23->GetID(), n31->GetID());
1405 //=======================================================================
1406 //function : AddFaceWithID
1408 //=======================================================================
1409 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(int n1, int n2, int n3,
1410 int n12,int n23,int n31, int ID)
1412 SMDS_MeshFace *anElem = SMDS_Mesh::AddFaceWithID(n1,n2,n3,n12,n23,n31,ID);
1413 if(anElem) myScript->AddFace(ID,n1,n2,n3,n12,n23,n31);
1417 //=======================================================================
1418 //function : AddFaceWithID
1420 //=======================================================================
1421 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(const SMDS_MeshNode * n1,
1422 const SMDS_MeshNode * n2,
1423 const SMDS_MeshNode * n3,
1424 const SMDS_MeshNode * n12,
1425 const SMDS_MeshNode * n23,
1426 const SMDS_MeshNode * n31,
1429 return AddFaceWithID(n1->GetID(), n2->GetID(), n3->GetID(),
1430 n12->GetID(), n23->GetID(), n31->GetID(),
1435 //=======================================================================
1436 //function : AddFace
1438 //=======================================================================
1439 SMDS_MeshFace* SMESHDS_Mesh::AddFace(const SMDS_MeshNode * n1,
1440 const SMDS_MeshNode * n2,
1441 const SMDS_MeshNode * n3,
1442 const SMDS_MeshNode * n4,
1443 const SMDS_MeshNode * n12,
1444 const SMDS_MeshNode * n23,
1445 const SMDS_MeshNode * n34,
1446 const SMDS_MeshNode * n41)
1448 SMDS_MeshFace *anElem = SMDS_Mesh::AddFace(n1,n2,n3,n4,n12,n23,n34,n41);
1449 if(anElem) myScript->AddFace(anElem->GetID(),
1450 n1->GetID(), n2->GetID(), n3->GetID(), n4->GetID(),
1451 n12->GetID(), n23->GetID(), n34->GetID(), n41->GetID());
1455 //=======================================================================
1456 //function : AddFaceWithID
1458 //=======================================================================
1459 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(int n1, int n2, int n3, int n4,
1460 int n12,int n23,int n34,int n41, int ID)
1462 SMDS_MeshFace *anElem = SMDS_Mesh::AddFaceWithID(n1,n2,n3,n4,n12,n23,n34,n41,ID);
1463 if(anElem) myScript->AddFace(ID,n1,n2,n3,n4,n12,n23,n34,n41);
1467 //=======================================================================
1468 //function : AddFaceWithID
1470 //=======================================================================
1471 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(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,
1481 return AddFaceWithID(n1->GetID(), n2->GetID(), n3->GetID(), n4->GetID(),
1482 n12->GetID(), n23->GetID(), n34->GetID(), n41->GetID(),
1487 //=======================================================================
1488 //function : AddVolume
1490 //=======================================================================
1491 SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
1492 const SMDS_MeshNode * n2,
1493 const SMDS_MeshNode * n3,
1494 const SMDS_MeshNode * n4,
1495 const SMDS_MeshNode * n12,
1496 const SMDS_MeshNode * n23,
1497 const SMDS_MeshNode * n31,
1498 const SMDS_MeshNode * n14,
1499 const SMDS_MeshNode * n24,
1500 const SMDS_MeshNode * n34)
1502 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1,n2,n3,n4,n12,n23,n31,n14,n24,n34);
1503 if(anElem) myScript->AddVolume(anElem->GetID(),
1504 n1->GetID(), n2->GetID(), n3->GetID(), n4->GetID(),
1505 n12->GetID(), n23->GetID(), n31->GetID(),
1506 n14->GetID(), n24->GetID(), n34->GetID());
1510 //=======================================================================
1511 //function : AddVolumeWithID
1513 //=======================================================================
1514 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3, int n4,
1515 int n12,int n23,int n31,
1516 int n14,int n24,int n34, int ID)
1518 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolumeWithID(n1,n2,n3,n4,n12,n23,
1519 n31,n14,n24,n34,ID);
1520 if(anElem) myScript->AddVolume(ID,n1,n2,n3,n4,n12,n23,n31,n14,n24,n34);
1524 //=======================================================================
1525 //function : AddVolumeWithID
1526 //purpose : 2d order tetrahedron of 10 nodes
1527 //=======================================================================
1528 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
1529 const SMDS_MeshNode * n2,
1530 const SMDS_MeshNode * n3,
1531 const SMDS_MeshNode * n4,
1532 const SMDS_MeshNode * n12,
1533 const SMDS_MeshNode * n23,
1534 const SMDS_MeshNode * n31,
1535 const SMDS_MeshNode * n14,
1536 const SMDS_MeshNode * n24,
1537 const SMDS_MeshNode * n34,
1540 return AddVolumeWithID(n1->GetID(), n2->GetID(), n3->GetID(), n4->GetID(),
1541 n12->GetID(), n23->GetID(), n31->GetID(),
1542 n14->GetID(), n24->GetID(), n34->GetID(), ID);
1546 //=======================================================================
1547 //function : AddVolume
1549 //=======================================================================
1550 SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
1551 const SMDS_MeshNode * n2,
1552 const SMDS_MeshNode * n3,
1553 const SMDS_MeshNode * n4,
1554 const SMDS_MeshNode * n5,
1555 const SMDS_MeshNode * n12,
1556 const SMDS_MeshNode * n23,
1557 const SMDS_MeshNode * n34,
1558 const SMDS_MeshNode * n41,
1559 const SMDS_MeshNode * n15,
1560 const SMDS_MeshNode * n25,
1561 const SMDS_MeshNode * n35,
1562 const SMDS_MeshNode * n45)
1564 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1,n2,n3,n4,n5,n12,n23,n34,n41,
1567 myScript->AddVolume(anElem->GetID(), n1->GetID(), n2->GetID(),
1568 n3->GetID(), n4->GetID(), n5->GetID(),
1569 n12->GetID(), n23->GetID(), n34->GetID(), n41->GetID(),
1570 n15->GetID(), n25->GetID(), n35->GetID(), n45->GetID());
1574 //=======================================================================
1575 //function : AddVolumeWithID
1577 //=======================================================================
1578 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3, int n4, int n5,
1579 int n12,int n23,int n34,int n41,
1580 int n15,int n25,int n35,int n45, int ID)
1582 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolumeWithID(n1,n2,n3,n4,n5,
1584 n15,n25,n35,n45,ID);
1585 if(anElem) myScript->AddVolume(ID,n1,n2,n3,n4,n5,n12,n23,n34,n41,
1590 //=======================================================================
1591 //function : AddVolumeWithID
1592 //purpose : 2d order pyramid of 13 nodes
1593 //=======================================================================
1594 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
1595 const SMDS_MeshNode * n2,
1596 const SMDS_MeshNode * n3,
1597 const SMDS_MeshNode * n4,
1598 const SMDS_MeshNode * n5,
1599 const SMDS_MeshNode * n12,
1600 const SMDS_MeshNode * n23,
1601 const SMDS_MeshNode * n34,
1602 const SMDS_MeshNode * n41,
1603 const SMDS_MeshNode * n15,
1604 const SMDS_MeshNode * n25,
1605 const SMDS_MeshNode * n35,
1606 const SMDS_MeshNode * n45,
1609 return AddVolumeWithID(n1->GetID(), n2->GetID(), n3->GetID(),
1610 n4->GetID(), n5->GetID(),
1611 n12->GetID(), n23->GetID(), n34->GetID(), n41->GetID(),
1612 n15->GetID(), n25->GetID(), n35->GetID(), n45->GetID(),
1617 //=======================================================================
1618 //function : AddVolume
1620 //=======================================================================
1621 SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
1622 const SMDS_MeshNode * n2,
1623 const SMDS_MeshNode * n3,
1624 const SMDS_MeshNode * n4,
1625 const SMDS_MeshNode * n5,
1626 const SMDS_MeshNode * n6,
1627 const SMDS_MeshNode * n12,
1628 const SMDS_MeshNode * n23,
1629 const SMDS_MeshNode * n31,
1630 const SMDS_MeshNode * n45,
1631 const SMDS_MeshNode * n56,
1632 const SMDS_MeshNode * n64,
1633 const SMDS_MeshNode * n14,
1634 const SMDS_MeshNode * n25,
1635 const SMDS_MeshNode * n36)
1637 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1,n2,n3,n4,n5,n6,n12,n23,n31,
1638 n45,n56,n64,n14,n25,n36);
1640 myScript->AddVolume(anElem->GetID(), n1->GetID(), n2->GetID(),
1641 n3->GetID(), n4->GetID(), n5->GetID(), n6->GetID(),
1642 n12->GetID(), n23->GetID(), n31->GetID(),
1643 n45->GetID(), n56->GetID(), n64->GetID(),
1644 n14->GetID(), n25->GetID(), n36->GetID());
1648 //=======================================================================
1649 //function : AddVolumeWithID
1651 //=======================================================================
1652 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3,
1653 int n4, int n5, int n6,
1654 int n12,int n23,int n31,
1655 int n45,int n56,int n64,
1656 int n14,int n25,int n36, int ID)
1658 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolumeWithID(n1,n2,n3,n4,n5,n6,
1662 if(anElem) myScript->AddVolume(ID,n1,n2,n3,n4,n5,n6,n12,n23,n31,
1663 n45,n56,n64,n14,n25,n36);
1667 //=======================================================================
1668 //function : AddVolumeWithID
1669 //purpose : 2d order Pentahedron with 15 nodes
1670 //=======================================================================
1671 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
1672 const SMDS_MeshNode * n2,
1673 const SMDS_MeshNode * n3,
1674 const SMDS_MeshNode * n4,
1675 const SMDS_MeshNode * n5,
1676 const SMDS_MeshNode * n6,
1677 const SMDS_MeshNode * n12,
1678 const SMDS_MeshNode * n23,
1679 const SMDS_MeshNode * n31,
1680 const SMDS_MeshNode * n45,
1681 const SMDS_MeshNode * n56,
1682 const SMDS_MeshNode * n64,
1683 const SMDS_MeshNode * n14,
1684 const SMDS_MeshNode * n25,
1685 const SMDS_MeshNode * n36,
1688 return AddVolumeWithID(n1->GetID(), n2->GetID(), n3->GetID(),
1689 n4->GetID(), n5->GetID(), n6->GetID(),
1690 n12->GetID(), n23->GetID(), n31->GetID(),
1691 n45->GetID(), n56->GetID(), n64->GetID(),
1692 n14->GetID(), n25->GetID(), n36->GetID(),
1697 //=======================================================================
1698 //function : AddVolume
1700 //=======================================================================
1701 SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
1702 const SMDS_MeshNode * n2,
1703 const SMDS_MeshNode * n3,
1704 const SMDS_MeshNode * n4,
1705 const SMDS_MeshNode * n5,
1706 const SMDS_MeshNode * n6,
1707 const SMDS_MeshNode * n7,
1708 const SMDS_MeshNode * n8,
1709 const SMDS_MeshNode * n12,
1710 const SMDS_MeshNode * n23,
1711 const SMDS_MeshNode * n34,
1712 const SMDS_MeshNode * n41,
1713 const SMDS_MeshNode * n56,
1714 const SMDS_MeshNode * n67,
1715 const SMDS_MeshNode * n78,
1716 const SMDS_MeshNode * n85,
1717 const SMDS_MeshNode * n15,
1718 const SMDS_MeshNode * n26,
1719 const SMDS_MeshNode * n37,
1720 const SMDS_MeshNode * n48)
1722 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1,n2,n3,n4,n5,n6,n7,n8,
1727 myScript->AddVolume(anElem->GetID(), n1->GetID(), n2->GetID(),
1728 n3->GetID(), n4->GetID(), n5->GetID(),
1729 n6->GetID(), n7->GetID(), n8->GetID(),
1730 n12->GetID(), n23->GetID(), n34->GetID(), n41->GetID(),
1731 n56->GetID(), n67->GetID(), n78->GetID(), n85->GetID(),
1732 n15->GetID(), n26->GetID(), n37->GetID(), n48->GetID());
1736 //=======================================================================
1737 //function : AddVolumeWithID
1739 //=======================================================================
1740 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3, int n4,
1741 int n5, int n6, int n7, int n8,
1742 int n12,int n23,int n34,int n41,
1743 int n56,int n67,int n78,int n85,
1744 int n15,int n26,int n37,int n48, int ID)
1746 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolumeWithID(n1,n2,n3,n4,n5,n6,n7,n8,
1749 n15,n26,n37,n48,ID);
1750 if(anElem) myScript->AddVolume(ID,n1,n2,n3,n4,n5,n6,n7,n8,n12,n23,n34,n41,
1751 n56,n67,n78,n85,n15,n26,n37,n48);
1755 //=======================================================================
1756 //function : AddVolumeWithID
1757 //purpose : 2d order Hexahedrons with 20 nodes
1758 //=======================================================================
1759 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
1760 const SMDS_MeshNode * n2,
1761 const SMDS_MeshNode * n3,
1762 const SMDS_MeshNode * n4,
1763 const SMDS_MeshNode * n5,
1764 const SMDS_MeshNode * n6,
1765 const SMDS_MeshNode * n7,
1766 const SMDS_MeshNode * n8,
1767 const SMDS_MeshNode * n12,
1768 const SMDS_MeshNode * n23,
1769 const SMDS_MeshNode * n34,
1770 const SMDS_MeshNode * n41,
1771 const SMDS_MeshNode * n56,
1772 const SMDS_MeshNode * n67,
1773 const SMDS_MeshNode * n78,
1774 const SMDS_MeshNode * n85,
1775 const SMDS_MeshNode * n15,
1776 const SMDS_MeshNode * n26,
1777 const SMDS_MeshNode * n37,
1778 const SMDS_MeshNode * n48,
1781 return AddVolumeWithID(n1->GetID(), n2->GetID(), n3->GetID(), n4->GetID(),
1782 n5->GetID(), n6->GetID(), n7->GetID(), n8->GetID(),
1783 n12->GetID(), n23->GetID(), n34->GetID(), n41->GetID(),
1784 n56->GetID(), n67->GetID(), n78->GetID(), n85->GetID(),
1785 n15->GetID(), n26->GetID(), n37->GetID(), n48->GetID(),