1 // SMESH SMESHDS : management of mesh data and SMESH document
3 // Copyright (C) 2003 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
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 "SMESHDS_GroupOnGeom.hxx"
36 #include <TopExp_Explorer.hxx>
38 #include <TopoDS_Iterator.hxx>
40 #include "utilities.h"
44 //=======================================================================
47 //=======================================================================
48 SMESHDS_Mesh::SMESHDS_Mesh(int theMeshID, bool theIsEmbeddedMode):
50 myIsEmbeddedMode(theIsEmbeddedMode),
53 myScript = new SMESHDS_Script(theIsEmbeddedMode);
57 //=======================================================================
58 bool SMESHDS_Mesh::IsEmbeddedMode()
60 return myIsEmbeddedMode;
63 //=======================================================================
64 //function : ShapeToMesh
66 //=======================================================================
67 void SMESHDS_Mesh::ShapeToMesh(const TopoDS_Shape & S)
69 if ( !myShape.IsNull() && S.IsNull() )
71 // removal of a shape to mesh, delete ...
73 myShapeToHypothesis.clear();
74 // - shape indices in SMDS_Position of nodes
75 map<int,SMESHDS_SubMesh*>::iterator i_sub = myShapeIndexToSubMesh.begin();
76 for ( ; i_sub != myShapeIndexToSubMesh.end(); i_sub++ ) {
77 if ( !i_sub->second->IsComplexSubmesh() ) {
78 SMDS_NodeIteratorPtr nIt = i_sub->second->GetNodes();
80 nIt->next()->GetPosition()->SetShapeId( 0 );
84 myIndexToShape.Clear();
85 myShapeIndexToSubMesh.clear();
86 // - groups on geometry
87 set<SMESHDS_GroupBase*>::iterator gr = myGroups.begin();
88 while ( gr != myGroups.end() ) {
89 if ( dynamic_cast<SMESHDS_GroupOnGeom*>( *gr ))
90 myGroups.erase( gr++ );
98 TopExp::MapShapes(myShape, myIndexToShape);
102 //=======================================================================
103 //function : AddHypothesis
105 //=======================================================================
107 bool SMESHDS_Mesh::AddHypothesis(const TopoDS_Shape & SS,
108 const SMESHDS_Hypothesis * H)
110 list<const SMESHDS_Hypothesis *>& alist=
111 myShapeToHypothesis[SS.Oriented(TopAbs_FORWARD)]; // ignore orientation of SS
113 //Check if the Hypothesis is still present
114 list<const SMESHDS_Hypothesis*>::iterator ith=find(alist.begin(),alist.end(), H );
116 if (alist.end() != ith) return false;
122 //=======================================================================
123 //function : RemoveHypothesis
125 //=======================================================================
127 bool SMESHDS_Mesh::RemoveHypothesis(const TopoDS_Shape & S,
128 const SMESHDS_Hypothesis * H)
130 ShapeToHypothesis::iterator its=
131 myShapeToHypothesis.find(S.Oriented(TopAbs_FORWARD)); // ignore orientation of S
133 if(its!=myShapeToHypothesis.end())
135 list<const SMESHDS_Hypothesis *>& alist=(*its).second;
136 list<const SMESHDS_Hypothesis*>::iterator ith=find(alist.begin(),alist.end(), H );
137 if (ith != alist.end())
146 //=======================================================================
149 //=======================================================================
150 SMDS_MeshNode* SMESHDS_Mesh::AddNode(double x, double y, double z){
151 SMDS_MeshNode* node = SMDS_Mesh::AddNode(x, y, z);
152 if(node!=NULL) myScript->AddNode(node->GetID(), x, y, z);
156 SMDS_MeshNode* SMESHDS_Mesh::AddNodeWithID(double x, double y, double z, int ID){
157 SMDS_MeshNode* node = SMDS_Mesh::AddNodeWithID(x,y,z,ID);
158 if(node!=NULL) myScript->AddNode(node->GetID(), x, y, z);
162 //=======================================================================
163 //function : MoveNode
165 //=======================================================================
166 void SMESHDS_Mesh::MoveNode(const SMDS_MeshNode *n, double x, double y, double z)
168 SMDS_MeshNode * node=const_cast<SMDS_MeshNode*>(n);
170 myScript->MoveNode(n->GetID(), x, y, z);
173 //=======================================================================
174 //function : ChangeElementNodes
176 //=======================================================================
178 bool SMESHDS_Mesh::ChangeElementNodes(const SMDS_MeshElement * elem,
179 const SMDS_MeshNode * nodes[],
182 if ( ! SMDS_Mesh::ChangeElementNodes( elem, nodes, nbnodes ))
185 vector<int> IDs( nbnodes );
186 for ( int i = 0; i < nbnodes; i++ )
187 IDs [ i ] = nodes[ i ]->GetID();
188 myScript->ChangeElementNodes( elem->GetID(), &IDs[0], nbnodes);
193 //=======================================================================
194 //function : ChangePolygonNodes
196 //=======================================================================
197 bool SMESHDS_Mesh::ChangePolygonNodes
198 (const SMDS_MeshElement * elem,
199 vector<const SMDS_MeshNode*> nodes)
201 ASSERT(nodes.size() > 3);
203 return ChangeElementNodes(elem, &nodes[0], nodes.size());
206 //=======================================================================
207 //function : ChangePolyhedronNodes
209 //=======================================================================
210 bool SMESHDS_Mesh::ChangePolyhedronNodes
211 (const SMDS_MeshElement * elem,
212 std::vector<const SMDS_MeshNode*> nodes,
213 std::vector<int> quantities)
215 ASSERT(nodes.size() > 3);
217 if (!SMDS_Mesh::ChangePolyhedronNodes(elem, nodes, quantities))
220 int i, len = nodes.size();
221 std::vector<int> nodes_ids (len);
222 for (i = 0; i < len; i++) {
223 nodes_ids[i] = nodes[i]->GetID();
225 myScript->ChangePolyhedronNodes(elem->GetID(), nodes_ids, quantities);
230 //=======================================================================
231 //function : Renumber
233 //=======================================================================
235 void SMESHDS_Mesh::Renumber (const bool isNodes, const int startID, const int deltaID)
237 SMDS_Mesh::Renumber( isNodes, startID, deltaID );
238 myScript->Renumber( isNodes, startID, deltaID );
241 //=======================================================================
242 //function :AddEdgeWithID
244 //=======================================================================
245 SMDS_MeshEdge* SMESHDS_Mesh::AddEdgeWithID(int n1, int n2, int ID)
247 SMDS_MeshEdge* anElem = SMDS_Mesh::AddEdgeWithID(n1,n2,ID);
248 if(anElem) myScript->AddEdge(ID,n1,n2);
252 SMDS_MeshEdge* SMESHDS_Mesh::AddEdgeWithID(const SMDS_MeshNode * n1,
253 const SMDS_MeshNode * n2,
256 return AddEdgeWithID(n1->GetID(),
261 SMDS_MeshEdge* SMESHDS_Mesh::AddEdge(const SMDS_MeshNode * n1,
262 const SMDS_MeshNode * n2)
264 SMDS_MeshEdge* anElem = SMDS_Mesh::AddEdge(n1,n2);
265 if(anElem) myScript->AddEdge(anElem->GetID(),
271 //=======================================================================
274 //=======================================================================
275 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(int n1, int n2, int n3, int ID)
277 SMDS_MeshFace *anElem = SMDS_Mesh::AddFaceWithID(n1, n2, n3, ID);
278 if(anElem) myScript->AddFace(ID,n1,n2,n3);
282 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(const SMDS_MeshNode * n1,
283 const SMDS_MeshNode * n2,
284 const SMDS_MeshNode * n3,
287 return AddFaceWithID(n1->GetID(),
293 SMDS_MeshFace* SMESHDS_Mesh::AddFace( const SMDS_MeshNode * n1,
294 const SMDS_MeshNode * n2,
295 const SMDS_MeshNode * n3)
297 SMDS_MeshFace *anElem = SMDS_Mesh::AddFace(n1, n2, n3);
298 if(anElem) myScript->AddFace(anElem->GetID(),
305 //=======================================================================
308 //=======================================================================
309 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(int n1, int n2, int n3, int n4, int ID)
311 SMDS_MeshFace *anElem = SMDS_Mesh::AddFaceWithID(n1, n2, n3, n4, ID);
312 if(anElem) myScript->AddFace(ID, n1, n2, n3, n4);
316 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(const SMDS_MeshNode * n1,
317 const SMDS_MeshNode * n2,
318 const SMDS_MeshNode * n3,
319 const SMDS_MeshNode * n4,
322 return AddFaceWithID(n1->GetID(),
329 SMDS_MeshFace* SMESHDS_Mesh::AddFace(const SMDS_MeshNode * n1,
330 const SMDS_MeshNode * n2,
331 const SMDS_MeshNode * n3,
332 const SMDS_MeshNode * n4)
334 SMDS_MeshFace *anElem = SMDS_Mesh::AddFace(n1, n2, n3, n4);
335 if(anElem) myScript->AddFace(anElem->GetID(),
343 //=======================================================================
344 //function :AddVolume
346 //=======================================================================
347 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3, int n4, int ID)
349 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolumeWithID(n1, n2, n3, n4, ID);
350 if(anElem) myScript->AddVolume(ID, n1, n2, n3, n4);
354 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
355 const SMDS_MeshNode * n2,
356 const SMDS_MeshNode * n3,
357 const SMDS_MeshNode * n4,
360 return AddVolumeWithID(n1->GetID(),
367 SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
368 const SMDS_MeshNode * n2,
369 const SMDS_MeshNode * n3,
370 const SMDS_MeshNode * n4)
372 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1, n2, n3, n4);
373 if(anElem) myScript->AddVolume(anElem->GetID(),
381 //=======================================================================
382 //function :AddVolume
384 //=======================================================================
385 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3, int n4, int n5, int ID)
387 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolumeWithID(n1, n2, n3, n4, n5, ID);
388 if(anElem) myScript->AddVolume(ID, n1, n2, n3, n4, n5);
392 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
393 const SMDS_MeshNode * n2,
394 const SMDS_MeshNode * n3,
395 const SMDS_MeshNode * n4,
396 const SMDS_MeshNode * n5,
399 return AddVolumeWithID(n1->GetID(),
407 SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
408 const SMDS_MeshNode * n2,
409 const SMDS_MeshNode * n3,
410 const SMDS_MeshNode * n4,
411 const SMDS_MeshNode * n5)
413 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1, n2, n3, n4, n5);
414 if(anElem) myScript->AddVolume(anElem->GetID(),
423 //=======================================================================
424 //function :AddVolume
426 //=======================================================================
427 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3, int n4, int n5, int n6, int ID)
429 SMDS_MeshVolume *anElem= SMDS_Mesh::AddVolumeWithID(n1, n2, n3, n4, n5, n6, ID);
430 if(anElem) myScript->AddVolume(ID, n1, n2, n3, n4, n5, n6);
434 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
435 const SMDS_MeshNode * n2,
436 const SMDS_MeshNode * n3,
437 const SMDS_MeshNode * n4,
438 const SMDS_MeshNode * n5,
439 const SMDS_MeshNode * n6,
442 return AddVolumeWithID(n1->GetID(),
451 SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
452 const SMDS_MeshNode * n2,
453 const SMDS_MeshNode * n3,
454 const SMDS_MeshNode * n4,
455 const SMDS_MeshNode * n5,
456 const SMDS_MeshNode * n6)
458 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1, n2, n3, n4, n5, n6);
459 if(anElem) myScript->AddVolume(anElem->GetID(),
469 //=======================================================================
470 //function :AddVolume
472 //=======================================================================
473 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3, int n4, int n5, int n6, int n7, int n8, int ID)
475 SMDS_MeshVolume *anElem= SMDS_Mesh::AddVolumeWithID(n1, n2, n3, n4, n5, n6, n7, n8, ID);
476 if(anElem) myScript->AddVolume(ID, n1, n2, n3, n4, n5, n6, n7, n8);
480 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
481 const SMDS_MeshNode * n2,
482 const SMDS_MeshNode * n3,
483 const SMDS_MeshNode * n4,
484 const SMDS_MeshNode * n5,
485 const SMDS_MeshNode * n6,
486 const SMDS_MeshNode * n7,
487 const SMDS_MeshNode * n8,
490 return AddVolumeWithID(n1->GetID(),
501 SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
502 const SMDS_MeshNode * n2,
503 const SMDS_MeshNode * n3,
504 const SMDS_MeshNode * n4,
505 const SMDS_MeshNode * n5,
506 const SMDS_MeshNode * n6,
507 const SMDS_MeshNode * n7,
508 const SMDS_MeshNode * n8)
510 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1, n2, n3, n4, n5, n6, n7, n8);
511 if(anElem) myScript->AddVolume(anElem->GetID(),
523 //=======================================================================
524 //function : AddPolygonalFace
526 //=======================================================================
527 SMDS_MeshFace* SMESHDS_Mesh::AddPolygonalFaceWithID (std::vector<int> nodes_ids,
530 SMDS_MeshFace *anElem = SMDS_Mesh::AddPolygonalFaceWithID(nodes_ids, ID);
532 myScript->AddPolygonalFace(ID, nodes_ids);
537 SMDS_MeshFace* SMESHDS_Mesh::AddPolygonalFaceWithID
538 (std::vector<const SMDS_MeshNode*> nodes,
541 SMDS_MeshFace *anElem = SMDS_Mesh::AddPolygonalFaceWithID(nodes, ID);
543 int i, len = nodes.size();
544 std::vector<int> nodes_ids (len);
545 for (i = 0; i < len; i++) {
546 nodes_ids[i] = nodes[i]->GetID();
548 myScript->AddPolygonalFace(ID, nodes_ids);
553 SMDS_MeshFace* SMESHDS_Mesh::AddPolygonalFace
554 (std::vector<const SMDS_MeshNode*> nodes)
556 SMDS_MeshFace *anElem = SMDS_Mesh::AddPolygonalFace(nodes);
558 int i, len = nodes.size();
559 std::vector<int> nodes_ids (len);
560 for (i = 0; i < len; i++) {
561 nodes_ids[i] = nodes[i]->GetID();
563 myScript->AddPolygonalFace(anElem->GetID(), nodes_ids);
568 //=======================================================================
569 //function : AddPolyhedralVolume
571 //=======================================================================
572 SMDS_MeshVolume* SMESHDS_Mesh::AddPolyhedralVolumeWithID (std::vector<int> nodes_ids,
573 std::vector<int> quantities,
576 SMDS_MeshVolume *anElem = SMDS_Mesh::AddPolyhedralVolumeWithID(nodes_ids, quantities, ID);
578 myScript->AddPolyhedralVolume(ID, nodes_ids, quantities);
583 SMDS_MeshVolume* SMESHDS_Mesh::AddPolyhedralVolumeWithID
584 (std::vector<const SMDS_MeshNode*> nodes,
585 std::vector<int> quantities,
588 SMDS_MeshVolume *anElem = SMDS_Mesh::AddPolyhedralVolumeWithID(nodes, quantities, ID);
590 int i, len = nodes.size();
591 std::vector<int> nodes_ids (len);
592 for (i = 0; i < len; i++) {
593 nodes_ids[i] = nodes[i]->GetID();
595 myScript->AddPolyhedralVolume(ID, nodes_ids, quantities);
600 SMDS_MeshVolume* SMESHDS_Mesh::AddPolyhedralVolume
601 (std::vector<const SMDS_MeshNode*> nodes,
602 std::vector<int> quantities)
604 SMDS_MeshVolume *anElem = SMDS_Mesh::AddPolyhedralVolume(nodes, quantities);
606 int i, len = nodes.size();
607 std::vector<int> nodes_ids (len);
608 for (i = 0; i < len; i++) {
609 nodes_ids[i] = nodes[i]->GetID();
611 myScript->AddPolyhedralVolume(anElem->GetID(), nodes_ids, quantities);
616 //=======================================================================
617 //function : removeFromContainers
619 //=======================================================================
621 static void removeFromContainers (map<int,SMESHDS_SubMesh*>& theSubMeshes,
622 set<SMESHDS_GroupBase*>& theGroups,
623 list<const SMDS_MeshElement*>& theElems,
626 if ( theElems.empty() )
630 // Element can belong to several groups
631 if ( !theGroups.empty() )
633 set<SMESHDS_GroupBase*>::iterator GrIt = theGroups.begin();
634 for ( ; GrIt != theGroups.end(); GrIt++ )
636 SMESHDS_Group* group = dynamic_cast<SMESHDS_Group*>( *GrIt );
637 if ( !group || group->IsEmpty() ) continue;
639 list<const SMDS_MeshElement *>::iterator elIt = theElems.begin();
640 for ( ; elIt != theElems.end(); elIt++ )
642 group->SMDSGroup().Remove( *elIt );
643 if ( group->IsEmpty() ) break;
648 // Rm from sub-meshes
649 // Element should belong to only one sub-mesh
650 map<int,SMESHDS_SubMesh*>::iterator SubIt = theSubMeshes.begin();
651 for ( ; SubIt != theSubMeshes.end(); SubIt++ )
653 int size = isNode ? (*SubIt).second->NbNodes() : (*SubIt).second->NbElements();
654 if ( size == 0 ) continue;
656 list<const SMDS_MeshElement *>::iterator elIt = theElems.begin();
657 while ( elIt != theElems.end() )
659 bool removed = false;
661 removed = (*SubIt).second->RemoveNode( static_cast<const SMDS_MeshNode*> (*elIt) );
663 removed = (*SubIt).second->RemoveElement( *elIt );
667 elIt = theElems.erase( elIt );
668 if ( theElems.empty() )
669 return; // all elements are found and removed
679 //=======================================================================
680 //function : RemoveNode
682 //=======================================================================
683 void SMESHDS_Mesh::RemoveNode(const SMDS_MeshNode * n)
685 myScript->RemoveNode(n->GetID());
687 list<const SMDS_MeshElement *> removedElems;
688 list<const SMDS_MeshElement *> removedNodes;
690 SMDS_Mesh::RemoveElement( n, removedElems, removedNodes, true );
692 removeFromContainers( myShapeIndexToSubMesh, myGroups, removedElems, false );
693 removeFromContainers( myShapeIndexToSubMesh, myGroups, removedNodes, true );
696 //=======================================================================
697 //function : RemoveFreeNode
699 //=======================================================================
700 void SMESHDS_Mesh::RemoveFreeNode(const SMDS_MeshNode * n, SMESHDS_SubMesh * subMesh)
702 myScript->RemoveNode(n->GetID());
705 // Node can belong to several groups
706 if (!myGroups.empty()) {
707 set<SMESHDS_GroupBase*>::iterator GrIt = myGroups.begin();
708 for (; GrIt != myGroups.end(); GrIt++) {
709 SMESHDS_Group* group = dynamic_cast<SMESHDS_Group*>(*GrIt);
710 if (!group || group->IsEmpty()) continue;
711 group->SMDSGroup().Remove(n);
716 // Node should belong to only one sub-mesh
718 subMesh->RemoveNode(n);
720 SMDS_Mesh::RemoveFreeElement(n);
723 //=======================================================================
724 //function : RemoveElement
726 //========================================================================
727 void SMESHDS_Mesh::RemoveElement(const SMDS_MeshElement * elt)
729 if (elt->GetType() == SMDSAbs_Node)
731 RemoveNode( static_cast<const SMDS_MeshNode*>( elt ));
735 myScript->RemoveElement(elt->GetID());
737 list<const SMDS_MeshElement *> removedElems;
738 list<const SMDS_MeshElement *> removedNodes;
740 SMDS_Mesh::RemoveElement(elt, removedElems, removedNodes, false);
742 removeFromContainers( myShapeIndexToSubMesh, myGroups, removedElems, false );
745 //=======================================================================
746 //function : RemoveFreeElement
748 //========================================================================
749 void SMESHDS_Mesh::RemoveFreeElement(const SMDS_MeshElement * elt, SMESHDS_SubMesh * subMesh)
751 if (elt->GetType() == SMDSAbs_Node) {
752 RemoveFreeNode( static_cast<const SMDS_MeshNode*>(elt), subMesh);
756 if (hasConstructionEdges() || hasConstructionFaces())
757 // this methods is only for meshes without descendants
760 myScript->RemoveElement(elt->GetID());
763 // Node can belong to several groups
764 if (!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(elt);
774 // Element should belong to only one sub-mesh
776 subMesh->RemoveElement(elt);
778 SMDS_Mesh::RemoveFreeElement(elt);
781 //================================================================================
783 * \brief return submesh by shape
784 * \param shape - the subshape
785 * \retval SMESHDS_SubMesh* - the found submesh
787 * search of submeshes is optimized
789 //================================================================================
791 SMESHDS_SubMesh* SMESHDS_Mesh::getSubmesh( const TopoDS_Shape & shape )
793 if ( shape.IsNull() )
796 if ( !myCurSubShape.IsNull() && shape.IsSame( myCurSubShape ))
799 getSubmesh( ShapeToIndex( shape ));
800 myCurSubShape = shape;
804 //================================================================================
806 * \brief return submesh by subshape index
807 * \param Index - the subshape index
808 * \retval SMESHDS_SubMesh* - the found submesh
809 * search of submeshes is optimized
811 //================================================================================
813 SMESHDS_SubMesh* SMESHDS_Mesh::getSubmesh( const int Index )
815 //Update or build submesh
816 if ( Index != myCurSubID ) {
817 map<int,SMESHDS_SubMesh*>::iterator it = myShapeIndexToSubMesh.find( Index );
818 if ( it == myShapeIndexToSubMesh.end() )
819 it = myShapeIndexToSubMesh.insert( make_pair(Index, new SMESHDS_SubMesh() )).first;
820 myCurSubMesh = it->second;
822 myCurSubShape.Nullify(); // myCurSubShape no more corresponds to submesh
827 //================================================================================
829 * \brief Add element or node to submesh
830 * \param elem - element to add
831 * \param subMesh - submesh to be filled in
833 //================================================================================
835 bool SMESHDS_Mesh::add(const SMDS_MeshElement* elem, SMESHDS_SubMesh* subMesh )
837 if ( elem && subMesh ) {
838 if ( elem->GetType() == SMDSAbs_Node )
839 subMesh->AddNode( static_cast<const SMDS_MeshNode* >( elem ));
841 subMesh->AddElement( elem );
847 //=======================================================================
848 //function : SetNodeOnVolume
850 //=======================================================================
851 void SMESHDS_Mesh::SetNodeInVolume(SMDS_MeshNode * aNode,
852 const TopoDS_Shell & S)
854 if ( add( aNode, getSubmesh(S) ))
855 const_cast<SMDS_Position*>( aNode->GetPosition().get() )->SetShapeId( myCurSubID );
857 //=======================================================================
858 //function : SetNodeOnVolume
860 //=======================================================================
861 void SMESHDS_Mesh::SetNodeInVolume(SMDS_MeshNode * aNode,
862 const TopoDS_Solid & S)
864 if ( add( aNode, getSubmesh(S) ))
865 const_cast<SMDS_Position*>( aNode->GetPosition().get() )->SetShapeId( myCurSubID );
868 //=======================================================================
869 //function : SetNodeOnFace
871 //=======================================================================
872 void SMESHDS_Mesh::SetNodeOnFace(SMDS_MeshNode * aNode,
873 const TopoDS_Face & S,
877 if ( add( aNode, getSubmesh(S) ))
878 aNode->SetPosition(SMDS_PositionPtr(new SMDS_FacePosition(myCurSubID, u, v)));
881 //=======================================================================
882 //function : SetNodeOnEdge
884 //=======================================================================
885 void SMESHDS_Mesh::SetNodeOnEdge(SMDS_MeshNode * aNode,
886 const TopoDS_Edge & S,
889 if ( add( aNode, getSubmesh(S) ))
890 aNode->SetPosition(SMDS_PositionPtr(new SMDS_EdgePosition(myCurSubID, u)));
893 //=======================================================================
894 //function : SetNodeOnVertex
896 //=======================================================================
897 void SMESHDS_Mesh::SetNodeOnVertex(SMDS_MeshNode * aNode,
898 const TopoDS_Vertex & S)
900 if ( add( aNode, getSubmesh(S) ))
901 aNode->SetPosition(SMDS_PositionPtr(new SMDS_VertexPosition(myCurSubID)));
904 //=======================================================================
905 //function : UnSetNodeOnShape
907 //=======================================================================
908 void SMESHDS_Mesh::UnSetNodeOnShape(const SMDS_MeshNode* aNode)
910 if ( aNode && aNode->GetPosition() ) {
911 map<int,SMESHDS_SubMesh*>::iterator it =
912 myShapeIndexToSubMesh.find( aNode->GetPosition()->GetShapeId() );
913 if ( it != myShapeIndexToSubMesh.end() )
914 it->second->RemoveNode( aNode );
918 //=======================================================================
919 //function : SetMeshElementOnShape
921 //=======================================================================
922 void SMESHDS_Mesh::SetMeshElementOnShape(const SMDS_MeshElement * anElement,
923 const TopoDS_Shape & S)
925 add( anElement, getSubmesh(S) );
928 //=======================================================================
929 //function : UnSetMeshElementOnShape
931 //=======================================================================
932 void SMESHDS_Mesh::UnSetMeshElementOnShape(const SMDS_MeshElement * elem,
933 const TopoDS_Shape & S)
935 int Index = myIndexToShape.FindIndex(S);
937 map<int,SMESHDS_SubMesh*>::iterator it = myShapeIndexToSubMesh.find( Index );
938 if ( it != myShapeIndexToSubMesh.end() )
939 if ( elem->GetType() == SMDSAbs_Node )
940 it->second->RemoveNode( static_cast<const SMDS_MeshNode* >( elem ));
942 it->second->RemoveElement( elem );
945 //=======================================================================
946 //function : ShapeToMesh
948 //=======================================================================
949 TopoDS_Shape SMESHDS_Mesh::ShapeToMesh() const
954 //=======================================================================
955 //function : IsGroupOfSubShapes
956 //purpose : return true if at least one subshape of theShape is a subshape
957 // of myShape or theShape == myShape
958 //=======================================================================
960 bool SMESHDS_Mesh::IsGroupOfSubShapes (const TopoDS_Shape& theShape) const
962 if ( myShape.IsSame( theShape ))
965 for ( TopoDS_Iterator it( theShape ); it.More(); it.Next() ) {
966 if (myIndexToShape.Contains( it.Value() ) ||
967 IsGroupOfSubShapes( it.Value() ))
974 ///////////////////////////////////////////////////////////////////////////////
975 /// Return the sub mesh linked to the a given TopoDS_Shape or NULL if the given
976 /// TopoDS_Shape is unknown
977 ///////////////////////////////////////////////////////////////////////////////
978 SMESHDS_SubMesh * SMESHDS_Mesh::MeshElements(const TopoDS_Shape & S) const
980 int Index = ShapeToIndex(S);
981 TShapeIndexToSubMesh::const_iterator anIter = myShapeIndexToSubMesh.find(Index);
982 if (anIter != myShapeIndexToSubMesh.end())
983 return anIter->second;
988 ///////////////////////////////////////////////////////////////////////////////
989 /// Return the sub mesh by Id of shape it is linked to
990 ///////////////////////////////////////////////////////////////////////////////
991 SMESHDS_SubMesh * SMESHDS_Mesh::MeshElements(const int Index)
993 TShapeIndexToSubMesh::const_iterator anIter = myShapeIndexToSubMesh.find(Index);
994 if (anIter != myShapeIndexToSubMesh.end())
995 return anIter->second;
1000 //=======================================================================
1001 //function : SubMeshIndices
1003 //=======================================================================
1004 list<int> SMESHDS_Mesh::SubMeshIndices()
1006 list<int> anIndices;
1007 std::map<int,SMESHDS_SubMesh*>::iterator anIter = myShapeIndexToSubMesh.begin();
1008 for (; anIter != myShapeIndexToSubMesh.end(); anIter++) {
1009 anIndices.push_back((*anIter).first);
1014 //=======================================================================
1015 //function : GetHypothesis
1017 //=======================================================================
1019 const list<const SMESHDS_Hypothesis*>&
1020 SMESHDS_Mesh::GetHypothesis(const TopoDS_Shape & S) const
1022 ShapeToHypothesis::const_iterator its=
1023 myShapeToHypothesis.find(S.Oriented(TopAbs_FORWARD)); // ignore orientation of S
1024 if (its!=myShapeToHypothesis.end())
1027 static list<const SMESHDS_Hypothesis*> empty;
1031 //=======================================================================
1032 //function : GetScript
1034 //=======================================================================
1035 SMESHDS_Script* SMESHDS_Mesh::GetScript()
1040 //=======================================================================
1041 //function : ClearScript
1043 //=======================================================================
1044 void SMESHDS_Mesh::ClearScript()
1049 //=======================================================================
1050 //function : HasMeshElements
1052 //=======================================================================
1053 bool SMESHDS_Mesh::HasMeshElements(const TopoDS_Shape & S)
1055 if (myShape.IsNull()) MESSAGE("myShape is NULL");
1056 int Index = myIndexToShape.FindIndex(S);
1057 return myShapeIndexToSubMesh.find(Index)!=myShapeIndexToSubMesh.end();
1060 //=======================================================================
1061 //function : HasHypothesis
1063 //=======================================================================
1064 bool SMESHDS_Mesh::HasHypothesis(const TopoDS_Shape & S)
1066 return myShapeToHypothesis.find(S.Oriented(TopAbs_FORWARD))!=myShapeToHypothesis.end();
1069 //=======================================================================
1070 //function : NewSubMesh
1072 //=======================================================================
1073 SMESHDS_SubMesh * SMESHDS_Mesh::NewSubMesh(int Index)
1075 SMESHDS_SubMesh* SM = 0;
1076 TShapeIndexToSubMesh::iterator anIter = myShapeIndexToSubMesh.find(Index);
1077 if (anIter == myShapeIndexToSubMesh.end())
1079 SM = new SMESHDS_SubMesh();
1080 myShapeIndexToSubMesh[Index]=SM;
1083 SM = anIter->second;
1087 //=======================================================================
1088 //function : AddCompoundSubmesh
1090 //=======================================================================
1092 int SMESHDS_Mesh::AddCompoundSubmesh(const TopoDS_Shape& S,
1093 TopAbs_ShapeEnum type)
1096 if ( IsGroupOfSubShapes( S ) || (S.ShapeType() == TopAbs_VERTEX && myIndexToShape.Contains(S)) )
1098 aMainIndex = myIndexToShape.Add( S );
1099 bool all = ( type == TopAbs_SHAPE );
1100 if ( all ) // corresponding simple submesh may exist
1101 aMainIndex = -aMainIndex;
1102 //MESSAGE("AddCompoundSubmesh index = " << aMainIndex );
1103 SMESHDS_SubMesh * aNewSub = NewSubMesh( aMainIndex );
1104 if ( !aNewSub->IsComplexSubmesh() ) // is empty
1106 int shapeType = all ? myShape.ShapeType() : type;
1107 int typeLimit = all ? TopAbs_VERTEX : type;
1108 for ( ; shapeType <= typeLimit; shapeType++ )
1110 TopExp_Explorer exp( S, TopAbs_ShapeEnum( shapeType ));
1111 for ( ; exp.More(); exp.Next() )
1113 int index = myIndexToShape.FindIndex( exp.Current() );
1115 aNewSub->AddSubMesh( NewSubMesh( index ));
1123 //=======================================================================
1124 //function : IndexToShape
1126 //=======================================================================
1127 const TopoDS_Shape& SMESHDS_Mesh::IndexToShape(int ShapeIndex) const
1129 return myIndexToShape.FindKey(ShapeIndex);
1132 //=======================================================================
1133 //function : ShapeToIndex
1135 //=======================================================================
1136 int SMESHDS_Mesh::ShapeToIndex(const TopoDS_Shape & S) const
1138 if (myShape.IsNull())
1139 MESSAGE("myShape is NULL");
1141 int index = myIndexToShape.FindIndex(S);
1146 //=======================================================================
1147 //function : SetNodeOnVolume
1149 //=======================================================================
1150 void SMESHDS_Mesh::SetNodeInVolume(const SMDS_MeshNode* aNode, int Index)
1152 if ( add( aNode, getSubmesh( Index )))
1153 const_cast<SMDS_Position*>( aNode->GetPosition().get() )->SetShapeId( Index );
1156 //=======================================================================
1157 //function : SetNodeOnFace
1159 //=======================================================================
1160 void SMESHDS_Mesh::SetNodeOnFace(SMDS_MeshNode* aNode, int Index, double u, double v)
1162 //Set Position on Node
1163 if ( add( aNode, getSubmesh( Index )))
1164 aNode->SetPosition(SMDS_PositionPtr(new SMDS_FacePosition(Index, u, v)));
1167 //=======================================================================
1168 //function : SetNodeOnEdge
1170 //=======================================================================
1171 void SMESHDS_Mesh::SetNodeOnEdge(SMDS_MeshNode* aNode,
1175 //Set Position on Node
1176 if ( add( aNode, getSubmesh( Index )))
1177 aNode->SetPosition(SMDS_PositionPtr(new SMDS_EdgePosition(Index, u)));
1180 //=======================================================================
1181 //function : SetNodeOnVertex
1183 //=======================================================================
1184 void SMESHDS_Mesh::SetNodeOnVertex(SMDS_MeshNode* aNode, int Index)
1186 //Set Position on Node
1187 if ( add( aNode, getSubmesh( Index )))
1188 aNode->SetPosition(SMDS_PositionPtr(new SMDS_VertexPosition(Index)));
1191 //=======================================================================
1192 //function : SetMeshElementOnShape
1194 //=======================================================================
1195 void SMESHDS_Mesh::SetMeshElementOnShape(const SMDS_MeshElement* anElement,
1198 add( anElement, getSubmesh( Index ));
1201 SMESHDS_Mesh::~SMESHDS_Mesh()
1208 //********************************************************************
1209 //********************************************************************
1210 //******** *********
1211 //***** Methods for addition of quadratic elements ******
1212 //******** *********
1213 //********************************************************************
1214 //********************************************************************
1216 //=======================================================================
1217 //function : AddEdgeWithID
1219 //=======================================================================
1220 SMDS_MeshEdge* SMESHDS_Mesh::AddEdgeWithID(int n1, int n2, int n12, int ID)
1222 SMDS_MeshEdge* anElem = SMDS_Mesh::AddEdgeWithID(n1,n2,n12,ID);
1223 if(anElem) myScript->AddEdge(ID,n1,n2,n12);
1227 //=======================================================================
1228 //function : AddEdge
1230 //=======================================================================
1231 SMDS_MeshEdge* SMESHDS_Mesh::AddEdge(const SMDS_MeshNode* n1,
1232 const SMDS_MeshNode* n2,
1233 const SMDS_MeshNode* n12)
1235 SMDS_MeshEdge* anElem = SMDS_Mesh::AddEdge(n1,n2,n12);
1236 if(anElem) myScript->AddEdge(anElem->GetID(),
1243 //=======================================================================
1244 //function : AddEdgeWithID
1246 //=======================================================================
1247 SMDS_MeshEdge* SMESHDS_Mesh::AddEdgeWithID(const SMDS_MeshNode * n1,
1248 const SMDS_MeshNode * n2,
1249 const SMDS_MeshNode * n12,
1252 return AddEdgeWithID(n1->GetID(),
1259 //=======================================================================
1260 //function : AddFace
1262 //=======================================================================
1263 SMDS_MeshFace* SMESHDS_Mesh::AddFace(const SMDS_MeshNode * n1,
1264 const SMDS_MeshNode * n2,
1265 const SMDS_MeshNode * n3,
1266 const SMDS_MeshNode * n12,
1267 const SMDS_MeshNode * n23,
1268 const SMDS_MeshNode * n31)
1270 SMDS_MeshFace *anElem = SMDS_Mesh::AddFace(n1,n2,n3,n12,n23,n31);
1271 if(anElem) myScript->AddFace(anElem->GetID(),
1272 n1->GetID(), n2->GetID(), n3->GetID(),
1273 n12->GetID(), n23->GetID(), n31->GetID());
1277 //=======================================================================
1278 //function : AddFaceWithID
1280 //=======================================================================
1281 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(int n1, int n2, int n3,
1282 int n12,int n23,int n31, int ID)
1284 SMDS_MeshFace *anElem = SMDS_Mesh::AddFaceWithID(n1,n2,n3,n12,n23,n31,ID);
1285 if(anElem) myScript->AddFace(ID,n1,n2,n3,n12,n23,n31);
1289 //=======================================================================
1290 //function : AddFaceWithID
1292 //=======================================================================
1293 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(const SMDS_MeshNode * n1,
1294 const SMDS_MeshNode * n2,
1295 const SMDS_MeshNode * n3,
1296 const SMDS_MeshNode * n12,
1297 const SMDS_MeshNode * n23,
1298 const SMDS_MeshNode * n31,
1301 return AddFaceWithID(n1->GetID(), n2->GetID(), n3->GetID(),
1302 n12->GetID(), n23->GetID(), n31->GetID(),
1307 //=======================================================================
1308 //function : AddFace
1310 //=======================================================================
1311 SMDS_MeshFace* SMESHDS_Mesh::AddFace(const SMDS_MeshNode * n1,
1312 const SMDS_MeshNode * n2,
1313 const SMDS_MeshNode * n3,
1314 const SMDS_MeshNode * n4,
1315 const SMDS_MeshNode * n12,
1316 const SMDS_MeshNode * n23,
1317 const SMDS_MeshNode * n34,
1318 const SMDS_MeshNode * n41)
1320 SMDS_MeshFace *anElem = SMDS_Mesh::AddFace(n1,n2,n3,n4,n12,n23,n34,n41);
1321 if(anElem) myScript->AddFace(anElem->GetID(),
1322 n1->GetID(), n2->GetID(), n3->GetID(), n4->GetID(),
1323 n12->GetID(), n23->GetID(), n34->GetID(), n41->GetID());
1327 //=======================================================================
1328 //function : AddFaceWithID
1330 //=======================================================================
1331 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(int n1, int n2, int n3, int n4,
1332 int n12,int n23,int n34,int n41, int ID)
1334 SMDS_MeshFace *anElem = SMDS_Mesh::AddFaceWithID(n1,n2,n3,n4,n12,n23,n34,n41,ID);
1335 if(anElem) myScript->AddFace(ID,n1,n2,n3,n4,n12,n23,n34,n41);
1339 //=======================================================================
1340 //function : AddFaceWithID
1342 //=======================================================================
1343 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(const SMDS_MeshNode * n1,
1344 const SMDS_MeshNode * n2,
1345 const SMDS_MeshNode * n3,
1346 const SMDS_MeshNode * n4,
1347 const SMDS_MeshNode * n12,
1348 const SMDS_MeshNode * n23,
1349 const SMDS_MeshNode * n34,
1350 const SMDS_MeshNode * n41,
1353 return AddFaceWithID(n1->GetID(), n2->GetID(), n3->GetID(), n4->GetID(),
1354 n12->GetID(), n23->GetID(), n34->GetID(), n41->GetID(),
1359 //=======================================================================
1360 //function : AddVolume
1362 //=======================================================================
1363 SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
1364 const SMDS_MeshNode * n2,
1365 const SMDS_MeshNode * n3,
1366 const SMDS_MeshNode * n4,
1367 const SMDS_MeshNode * n12,
1368 const SMDS_MeshNode * n23,
1369 const SMDS_MeshNode * n31,
1370 const SMDS_MeshNode * n14,
1371 const SMDS_MeshNode * n24,
1372 const SMDS_MeshNode * n34)
1374 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1,n2,n3,n4,n12,n23,n31,n14,n24,n34);
1375 if(anElem) myScript->AddVolume(anElem->GetID(),
1376 n1->GetID(), n2->GetID(), n3->GetID(), n4->GetID(),
1377 n12->GetID(), n23->GetID(), n31->GetID(),
1378 n14->GetID(), n24->GetID(), n34->GetID());
1382 //=======================================================================
1383 //function : AddVolumeWithID
1385 //=======================================================================
1386 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3, int n4,
1387 int n12,int n23,int n31,
1388 int n14,int n24,int n34, int ID)
1390 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolumeWithID(n1,n2,n3,n4,n12,n23,
1391 n31,n14,n24,n34,ID);
1392 if(anElem) myScript->AddVolume(ID,n1,n2,n3,n4,n12,n23,n31,n14,n24,n34);
1396 //=======================================================================
1397 //function : AddVolumeWithID
1398 //purpose : 2d order tetrahedron of 10 nodes
1399 //=======================================================================
1400 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
1401 const SMDS_MeshNode * n2,
1402 const SMDS_MeshNode * n3,
1403 const SMDS_MeshNode * n4,
1404 const SMDS_MeshNode * n12,
1405 const SMDS_MeshNode * n23,
1406 const SMDS_MeshNode * n31,
1407 const SMDS_MeshNode * n14,
1408 const SMDS_MeshNode * n24,
1409 const SMDS_MeshNode * n34,
1412 return AddVolumeWithID(n1->GetID(), n2->GetID(), n3->GetID(), n4->GetID(),
1413 n12->GetID(), n23->GetID(), n31->GetID(),
1414 n14->GetID(), n24->GetID(), n34->GetID(), ID);
1418 //=======================================================================
1419 //function : AddVolume
1421 //=======================================================================
1422 SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
1423 const SMDS_MeshNode * n2,
1424 const SMDS_MeshNode * n3,
1425 const SMDS_MeshNode * n4,
1426 const SMDS_MeshNode * n5,
1427 const SMDS_MeshNode * n12,
1428 const SMDS_MeshNode * n23,
1429 const SMDS_MeshNode * n34,
1430 const SMDS_MeshNode * n41,
1431 const SMDS_MeshNode * n15,
1432 const SMDS_MeshNode * n25,
1433 const SMDS_MeshNode * n35,
1434 const SMDS_MeshNode * n45)
1436 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1,n2,n3,n4,n5,n12,n23,n34,n41,
1439 myScript->AddVolume(anElem->GetID(), n1->GetID(), n2->GetID(),
1440 n3->GetID(), n4->GetID(), n5->GetID(),
1441 n12->GetID(), n23->GetID(), n34->GetID(), n41->GetID(),
1442 n15->GetID(), n25->GetID(), n35->GetID(), n45->GetID());
1446 //=======================================================================
1447 //function : AddVolumeWithID
1449 //=======================================================================
1450 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3, int n4, int n5,
1451 int n12,int n23,int n34,int n41,
1452 int n15,int n25,int n35,int n45, int ID)
1454 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolumeWithID(n1,n2,n3,n4,n5,
1456 n15,n25,n35,n45,ID);
1457 if(anElem) myScript->AddVolume(ID,n1,n2,n3,n4,n5,n12,n23,n34,n41,
1462 //=======================================================================
1463 //function : AddVolumeWithID
1464 //purpose : 2d order pyramid of 13 nodes
1465 //=======================================================================
1466 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
1467 const SMDS_MeshNode * n2,
1468 const SMDS_MeshNode * n3,
1469 const SMDS_MeshNode * n4,
1470 const SMDS_MeshNode * n5,
1471 const SMDS_MeshNode * n12,
1472 const SMDS_MeshNode * n23,
1473 const SMDS_MeshNode * n34,
1474 const SMDS_MeshNode * n41,
1475 const SMDS_MeshNode * n15,
1476 const SMDS_MeshNode * n25,
1477 const SMDS_MeshNode * n35,
1478 const SMDS_MeshNode * n45,
1481 return AddVolumeWithID(n1->GetID(), n2->GetID(), n3->GetID(),
1482 n4->GetID(), n5->GetID(),
1483 n12->GetID(), n23->GetID(), n34->GetID(), n41->GetID(),
1484 n15->GetID(), n25->GetID(), n35->GetID(), n45->GetID(),
1489 //=======================================================================
1490 //function : AddVolume
1492 //=======================================================================
1493 SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
1494 const SMDS_MeshNode * n2,
1495 const SMDS_MeshNode * n3,
1496 const SMDS_MeshNode * n4,
1497 const SMDS_MeshNode * n5,
1498 const SMDS_MeshNode * n6,
1499 const SMDS_MeshNode * n12,
1500 const SMDS_MeshNode * n23,
1501 const SMDS_MeshNode * n31,
1502 const SMDS_MeshNode * n45,
1503 const SMDS_MeshNode * n56,
1504 const SMDS_MeshNode * n64,
1505 const SMDS_MeshNode * n14,
1506 const SMDS_MeshNode * n25,
1507 const SMDS_MeshNode * n36)
1509 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1,n2,n3,n4,n5,n6,n12,n23,n31,
1510 n45,n56,n64,n14,n25,n36);
1512 myScript->AddVolume(anElem->GetID(), n1->GetID(), n2->GetID(),
1513 n3->GetID(), n4->GetID(), n5->GetID(), n6->GetID(),
1514 n12->GetID(), n23->GetID(), n31->GetID(),
1515 n45->GetID(), n56->GetID(), n64->GetID(),
1516 n14->GetID(), n25->GetID(), n36->GetID());
1520 //=======================================================================
1521 //function : AddVolumeWithID
1523 //=======================================================================
1524 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3,
1525 int n4, int n5, int n6,
1526 int n12,int n23,int n31,
1527 int n45,int n56,int n64,
1528 int n14,int n25,int n36, int ID)
1530 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolumeWithID(n1,n2,n3,n4,n5,n6,
1534 if(anElem) myScript->AddVolume(ID,n1,n2,n3,n4,n5,n6,n12,n23,n31,
1535 n45,n56,n64,n14,n25,n36);
1539 //=======================================================================
1540 //function : AddVolumeWithID
1541 //purpose : 2d order Pentahedron with 15 nodes
1542 //=======================================================================
1543 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
1544 const SMDS_MeshNode * n2,
1545 const SMDS_MeshNode * n3,
1546 const SMDS_MeshNode * n4,
1547 const SMDS_MeshNode * n5,
1548 const SMDS_MeshNode * n6,
1549 const SMDS_MeshNode * n12,
1550 const SMDS_MeshNode * n23,
1551 const SMDS_MeshNode * n31,
1552 const SMDS_MeshNode * n45,
1553 const SMDS_MeshNode * n56,
1554 const SMDS_MeshNode * n64,
1555 const SMDS_MeshNode * n14,
1556 const SMDS_MeshNode * n25,
1557 const SMDS_MeshNode * n36,
1560 return AddVolumeWithID(n1->GetID(), n2->GetID(), n3->GetID(),
1561 n4->GetID(), n5->GetID(), n6->GetID(),
1562 n12->GetID(), n23->GetID(), n31->GetID(),
1563 n45->GetID(), n56->GetID(), n64->GetID(),
1564 n14->GetID(), n25->GetID(), n36->GetID(),
1569 //=======================================================================
1570 //function : AddVolume
1572 //=======================================================================
1573 SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
1574 const SMDS_MeshNode * n2,
1575 const SMDS_MeshNode * n3,
1576 const SMDS_MeshNode * n4,
1577 const SMDS_MeshNode * n5,
1578 const SMDS_MeshNode * n6,
1579 const SMDS_MeshNode * n7,
1580 const SMDS_MeshNode * n8,
1581 const SMDS_MeshNode * n12,
1582 const SMDS_MeshNode * n23,
1583 const SMDS_MeshNode * n34,
1584 const SMDS_MeshNode * n41,
1585 const SMDS_MeshNode * n56,
1586 const SMDS_MeshNode * n67,
1587 const SMDS_MeshNode * n78,
1588 const SMDS_MeshNode * n85,
1589 const SMDS_MeshNode * n15,
1590 const SMDS_MeshNode * n26,
1591 const SMDS_MeshNode * n37,
1592 const SMDS_MeshNode * n48)
1594 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1,n2,n3,n4,n5,n6,n7,n8,
1599 myScript->AddVolume(anElem->GetID(), n1->GetID(), n2->GetID(),
1600 n3->GetID(), n4->GetID(), n5->GetID(),
1601 n6->GetID(), n7->GetID(), n8->GetID(),
1602 n12->GetID(), n23->GetID(), n34->GetID(), n41->GetID(),
1603 n56->GetID(), n67->GetID(), n78->GetID(), n85->GetID(),
1604 n15->GetID(), n26->GetID(), n37->GetID(), n48->GetID());
1608 //=======================================================================
1609 //function : AddVolumeWithID
1611 //=======================================================================
1612 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3, int n4,
1613 int n5, int n6, int n7, int n8,
1614 int n12,int n23,int n34,int n41,
1615 int n56,int n67,int n78,int n85,
1616 int n15,int n26,int n37,int n48, int ID)
1618 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolumeWithID(n1,n2,n3,n4,n5,n6,n7,n8,
1621 n15,n26,n37,n48,ID);
1622 if(anElem) myScript->AddVolume(ID,n1,n2,n3,n4,n5,n6,n7,n8,n12,n23,n34,n41,
1623 n56,n67,n78,n85,n15,n26,n37,n48);
1627 //=======================================================================
1628 //function : AddVolumeWithID
1629 //purpose : 2d order Hexahedrons with 20 nodes
1630 //=======================================================================
1631 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
1632 const SMDS_MeshNode * n2,
1633 const SMDS_MeshNode * n3,
1634 const SMDS_MeshNode * n4,
1635 const SMDS_MeshNode * n5,
1636 const SMDS_MeshNode * n6,
1637 const SMDS_MeshNode * n7,
1638 const SMDS_MeshNode * n8,
1639 const SMDS_MeshNode * n12,
1640 const SMDS_MeshNode * n23,
1641 const SMDS_MeshNode * n34,
1642 const SMDS_MeshNode * n41,
1643 const SMDS_MeshNode * n56,
1644 const SMDS_MeshNode * n67,
1645 const SMDS_MeshNode * n78,
1646 const SMDS_MeshNode * n85,
1647 const SMDS_MeshNode * n15,
1648 const SMDS_MeshNode * n26,
1649 const SMDS_MeshNode * n37,
1650 const SMDS_MeshNode * n48,
1653 return AddVolumeWithID(n1->GetID(), n2->GetID(), n3->GetID(), n4->GetID(),
1654 n5->GetID(), n6->GetID(), n7->GetID(), n8->GetID(),
1655 n12->GetID(), n23->GetID(), n34->GetID(), n41->GetID(),
1656 n56->GetID(), n67->GetID(), n78->GetID(), n85->GetID(),
1657 n15->GetID(), n26->GetID(), n37->GetID(), n48->GetID(),