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 /*Standard_Boolean IsEqual( const TopoDS_Shape& S1, const TopoDS_Shape& S2 )
46 return S1.IsSame( S2 );
49 //=======================================================================
52 //=======================================================================
53 SMESHDS_Mesh::SMESHDS_Mesh(int theMeshID, bool theIsEmbeddedMode):
55 myIsEmbeddedMode(theIsEmbeddedMode),
58 myScript = new SMESHDS_Script(theIsEmbeddedMode);
62 //=======================================================================
63 bool SMESHDS_Mesh::IsEmbeddedMode()
65 return myIsEmbeddedMode;
68 //=======================================================================
69 //function : ShapeToMesh
71 //=======================================================================
72 void SMESHDS_Mesh::ShapeToMesh(const TopoDS_Shape & S)
74 if ( !myShape.IsNull() && S.IsNull() )
76 // removal of a shape to mesh, delete ...
78 myShapeToHypothesis.Clear();
79 // - shape indices in SMDS_Position of nodes
80 map<int,SMESHDS_SubMesh*>::iterator i_sub = myShapeIndexToSubMesh.begin();
81 for ( ; i_sub != myShapeIndexToSubMesh.end(); i_sub++ ) {
82 if ( !i_sub->second->IsComplexSubmesh() ) {
83 SMDS_NodeIteratorPtr nIt = i_sub->second->GetNodes();
85 nIt->next()->GetPosition()->SetShapeId( 0 );
89 myIndexToShape.Clear();
90 myShapeIndexToSubMesh.clear();
91 // - groups on geometry
92 set<SMESHDS_GroupBase*>::iterator gr = myGroups.begin();
93 while ( gr != myGroups.end() ) {
94 if ( dynamic_cast<SMESHDS_GroupOnGeom*>( *gr ))
95 myGroups.erase( gr++ );
103 TopExp::MapShapes(myShape, myIndexToShape);
107 //=======================================================================
108 //function : AddHypothesis
110 //=======================================================================
112 bool SMESHDS_Mesh::AddHypothesis(const TopoDS_Shape & SS,
113 const SMESHDS_Hypothesis * H)
115 if (!myShapeToHypothesis.IsBound(SS.Oriented(TopAbs_FORWARD))) {
116 list<const SMESHDS_Hypothesis *> aList;
117 myShapeToHypothesis.Bind(SS.Oriented(TopAbs_FORWARD), aList);
119 list<const SMESHDS_Hypothesis *>& alist =
120 myShapeToHypothesis(SS.Oriented(TopAbs_FORWARD)); // ignore orientation of SS
122 //Check if the Hypothesis is still present
123 list<const SMESHDS_Hypothesis*>::iterator ith = find(alist.begin(),alist.end(), H );
125 if (alist.end() != ith) return false;
131 //=======================================================================
132 //function : RemoveHypothesis
134 //=======================================================================
136 bool SMESHDS_Mesh::RemoveHypothesis(const TopoDS_Shape & S,
137 const SMESHDS_Hypothesis * H)
139 if( myShapeToHypothesis.IsBound( S.Oriented(TopAbs_FORWARD) ) )
141 list<const SMESHDS_Hypothesis *>& alist=myShapeToHypothesis.ChangeFind( S.Oriented(TopAbs_FORWARD) );
142 list<const SMESHDS_Hypothesis*>::iterator ith=find(alist.begin(),alist.end(), H );
143 if (ith != alist.end())
152 //=======================================================================
155 //=======================================================================
156 SMDS_MeshNode* SMESHDS_Mesh::AddNode(double x, double y, double z){
157 SMDS_MeshNode* node = SMDS_Mesh::AddNode(x, y, z);
158 if(node!=NULL) myScript->AddNode(node->GetID(), x, y, z);
162 SMDS_MeshNode* SMESHDS_Mesh::AddNodeWithID(double x, double y, double z, int ID){
163 SMDS_MeshNode* node = SMDS_Mesh::AddNodeWithID(x,y,z,ID);
164 if(node!=NULL) myScript->AddNode(node->GetID(), x, y, z);
168 //=======================================================================
169 //function : MoveNode
171 //=======================================================================
172 void SMESHDS_Mesh::MoveNode(const SMDS_MeshNode *n, double x, double y, double z)
174 SMDS_MeshNode * node=const_cast<SMDS_MeshNode*>(n);
176 myScript->MoveNode(n->GetID(), x, y, z);
179 //=======================================================================
180 //function : ChangeElementNodes
182 //=======================================================================
184 bool SMESHDS_Mesh::ChangeElementNodes(const SMDS_MeshElement * elem,
185 const SMDS_MeshNode * nodes[],
188 if ( ! SMDS_Mesh::ChangeElementNodes( elem, nodes, nbnodes ))
191 vector<int> IDs( nbnodes );
192 for ( int i = 0; i < nbnodes; i++ )
193 IDs [ i ] = nodes[ i ]->GetID();
194 myScript->ChangeElementNodes( elem->GetID(), &IDs[0], nbnodes);
199 //=======================================================================
200 //function : ChangePolygonNodes
202 //=======================================================================
203 bool SMESHDS_Mesh::ChangePolygonNodes
204 (const SMDS_MeshElement * elem,
205 vector<const SMDS_MeshNode*> nodes)
207 ASSERT(nodes.size() > 3);
209 return ChangeElementNodes(elem, &nodes[0], nodes.size());
212 //=======================================================================
213 //function : ChangePolyhedronNodes
215 //=======================================================================
216 bool SMESHDS_Mesh::ChangePolyhedronNodes
217 (const SMDS_MeshElement * elem,
218 std::vector<const SMDS_MeshNode*> nodes,
219 std::vector<int> quantities)
221 ASSERT(nodes.size() > 3);
223 if (!SMDS_Mesh::ChangePolyhedronNodes(elem, nodes, quantities))
226 int i, len = nodes.size();
227 std::vector<int> nodes_ids (len);
228 for (i = 0; i < len; i++) {
229 nodes_ids[i] = nodes[i]->GetID();
231 myScript->ChangePolyhedronNodes(elem->GetID(), nodes_ids, quantities);
236 //=======================================================================
237 //function : Renumber
239 //=======================================================================
241 void SMESHDS_Mesh::Renumber (const bool isNodes, const int startID, const int deltaID)
243 SMDS_Mesh::Renumber( isNodes, startID, deltaID );
244 myScript->Renumber( isNodes, startID, deltaID );
247 //=======================================================================
248 //function :AddEdgeWithID
250 //=======================================================================
251 SMDS_MeshEdge* SMESHDS_Mesh::AddEdgeWithID(int n1, int n2, int ID)
253 SMDS_MeshEdge* anElem = SMDS_Mesh::AddEdgeWithID(n1,n2,ID);
254 if(anElem) myScript->AddEdge(ID,n1,n2);
258 SMDS_MeshEdge* SMESHDS_Mesh::AddEdgeWithID(const SMDS_MeshNode * n1,
259 const SMDS_MeshNode * n2,
262 return AddEdgeWithID(n1->GetID(),
267 SMDS_MeshEdge* SMESHDS_Mesh::AddEdge(const SMDS_MeshNode * n1,
268 const SMDS_MeshNode * n2)
270 SMDS_MeshEdge* anElem = SMDS_Mesh::AddEdge(n1,n2);
271 if(anElem) myScript->AddEdge(anElem->GetID(),
277 //=======================================================================
280 //=======================================================================
281 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(int n1, int n2, int n3, int ID)
283 SMDS_MeshFace *anElem = SMDS_Mesh::AddFaceWithID(n1, n2, n3, ID);
284 if(anElem) myScript->AddFace(ID,n1,n2,n3);
288 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(const SMDS_MeshNode * n1,
289 const SMDS_MeshNode * n2,
290 const SMDS_MeshNode * n3,
293 return AddFaceWithID(n1->GetID(),
299 SMDS_MeshFace* SMESHDS_Mesh::AddFace( const SMDS_MeshNode * n1,
300 const SMDS_MeshNode * n2,
301 const SMDS_MeshNode * n3)
303 SMDS_MeshFace *anElem = SMDS_Mesh::AddFace(n1, n2, n3);
304 if(anElem) myScript->AddFace(anElem->GetID(),
311 //=======================================================================
314 //=======================================================================
315 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(int n1, int n2, int n3, int n4, int ID)
317 SMDS_MeshFace *anElem = SMDS_Mesh::AddFaceWithID(n1, n2, n3, n4, ID);
318 if(anElem) myScript->AddFace(ID, n1, n2, n3, n4);
322 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(const SMDS_MeshNode * n1,
323 const SMDS_MeshNode * n2,
324 const SMDS_MeshNode * n3,
325 const SMDS_MeshNode * n4,
328 return AddFaceWithID(n1->GetID(),
335 SMDS_MeshFace* SMESHDS_Mesh::AddFace(const SMDS_MeshNode * n1,
336 const SMDS_MeshNode * n2,
337 const SMDS_MeshNode * n3,
338 const SMDS_MeshNode * n4)
340 SMDS_MeshFace *anElem = SMDS_Mesh::AddFace(n1, n2, n3, n4);
341 if(anElem) myScript->AddFace(anElem->GetID(),
349 //=======================================================================
350 //function :AddVolume
352 //=======================================================================
353 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3, int n4, int ID)
355 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolumeWithID(n1, n2, n3, n4, ID);
356 if(anElem) myScript->AddVolume(ID, n1, n2, n3, n4);
360 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
361 const SMDS_MeshNode * n2,
362 const SMDS_MeshNode * n3,
363 const SMDS_MeshNode * n4,
366 return AddVolumeWithID(n1->GetID(),
373 SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
374 const SMDS_MeshNode * n2,
375 const SMDS_MeshNode * n3,
376 const SMDS_MeshNode * n4)
378 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1, n2, n3, n4);
379 if(anElem) myScript->AddVolume(anElem->GetID(),
387 //=======================================================================
388 //function :AddVolume
390 //=======================================================================
391 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3, int n4, int n5, int ID)
393 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolumeWithID(n1, n2, n3, n4, n5, ID);
394 if(anElem) myScript->AddVolume(ID, n1, n2, n3, n4, n5);
398 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
399 const SMDS_MeshNode * n2,
400 const SMDS_MeshNode * n3,
401 const SMDS_MeshNode * n4,
402 const SMDS_MeshNode * n5,
405 return AddVolumeWithID(n1->GetID(),
413 SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
414 const SMDS_MeshNode * n2,
415 const SMDS_MeshNode * n3,
416 const SMDS_MeshNode * n4,
417 const SMDS_MeshNode * n5)
419 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1, n2, n3, n4, n5);
420 if(anElem) myScript->AddVolume(anElem->GetID(),
429 //=======================================================================
430 //function :AddVolume
432 //=======================================================================
433 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3, int n4, int n5, int n6, int ID)
435 SMDS_MeshVolume *anElem= SMDS_Mesh::AddVolumeWithID(n1, n2, n3, n4, n5, n6, ID);
436 if(anElem) myScript->AddVolume(ID, n1, n2, n3, n4, n5, n6);
440 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
441 const SMDS_MeshNode * n2,
442 const SMDS_MeshNode * n3,
443 const SMDS_MeshNode * n4,
444 const SMDS_MeshNode * n5,
445 const SMDS_MeshNode * n6,
448 return AddVolumeWithID(n1->GetID(),
457 SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
458 const SMDS_MeshNode * n2,
459 const SMDS_MeshNode * n3,
460 const SMDS_MeshNode * n4,
461 const SMDS_MeshNode * n5,
462 const SMDS_MeshNode * n6)
464 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1, n2, n3, n4, n5, n6);
465 if(anElem) myScript->AddVolume(anElem->GetID(),
475 //=======================================================================
476 //function :AddVolume
478 //=======================================================================
479 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3, int n4, int n5, int n6, int n7, int n8, int ID)
481 SMDS_MeshVolume *anElem= SMDS_Mesh::AddVolumeWithID(n1, n2, n3, n4, n5, n6, n7, n8, ID);
482 if(anElem) myScript->AddVolume(ID, n1, n2, n3, n4, n5, n6, n7, n8);
486 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
487 const SMDS_MeshNode * n2,
488 const SMDS_MeshNode * n3,
489 const SMDS_MeshNode * n4,
490 const SMDS_MeshNode * n5,
491 const SMDS_MeshNode * n6,
492 const SMDS_MeshNode * n7,
493 const SMDS_MeshNode * n8,
496 return AddVolumeWithID(n1->GetID(),
507 SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
508 const SMDS_MeshNode * n2,
509 const SMDS_MeshNode * n3,
510 const SMDS_MeshNode * n4,
511 const SMDS_MeshNode * n5,
512 const SMDS_MeshNode * n6,
513 const SMDS_MeshNode * n7,
514 const SMDS_MeshNode * n8)
516 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1, n2, n3, n4, n5, n6, n7, n8);
517 if(anElem) myScript->AddVolume(anElem->GetID(),
529 //=======================================================================
530 //function : AddPolygonalFace
532 //=======================================================================
533 SMDS_MeshFace* SMESHDS_Mesh::AddPolygonalFaceWithID (std::vector<int> nodes_ids,
536 SMDS_MeshFace *anElem = SMDS_Mesh::AddPolygonalFaceWithID(nodes_ids, ID);
538 myScript->AddPolygonalFace(ID, nodes_ids);
543 SMDS_MeshFace* SMESHDS_Mesh::AddPolygonalFaceWithID
544 (std::vector<const SMDS_MeshNode*> nodes,
547 SMDS_MeshFace *anElem = SMDS_Mesh::AddPolygonalFaceWithID(nodes, ID);
549 int i, len = nodes.size();
550 std::vector<int> nodes_ids (len);
551 for (i = 0; i < len; i++) {
552 nodes_ids[i] = nodes[i]->GetID();
554 myScript->AddPolygonalFace(ID, nodes_ids);
559 SMDS_MeshFace* SMESHDS_Mesh::AddPolygonalFace
560 (std::vector<const SMDS_MeshNode*> nodes)
562 SMDS_MeshFace *anElem = SMDS_Mesh::AddPolygonalFace(nodes);
564 int i, len = nodes.size();
565 std::vector<int> nodes_ids (len);
566 for (i = 0; i < len; i++) {
567 nodes_ids[i] = nodes[i]->GetID();
569 myScript->AddPolygonalFace(anElem->GetID(), nodes_ids);
574 //=======================================================================
575 //function : AddPolyhedralVolume
577 //=======================================================================
578 SMDS_MeshVolume* SMESHDS_Mesh::AddPolyhedralVolumeWithID (std::vector<int> nodes_ids,
579 std::vector<int> quantities,
582 SMDS_MeshVolume *anElem = SMDS_Mesh::AddPolyhedralVolumeWithID(nodes_ids, quantities, ID);
584 myScript->AddPolyhedralVolume(ID, nodes_ids, quantities);
589 SMDS_MeshVolume* SMESHDS_Mesh::AddPolyhedralVolumeWithID
590 (std::vector<const SMDS_MeshNode*> nodes,
591 std::vector<int> quantities,
594 SMDS_MeshVolume *anElem = SMDS_Mesh::AddPolyhedralVolumeWithID(nodes, quantities, ID);
596 int i, len = nodes.size();
597 std::vector<int> nodes_ids (len);
598 for (i = 0; i < len; i++) {
599 nodes_ids[i] = nodes[i]->GetID();
601 myScript->AddPolyhedralVolume(ID, nodes_ids, quantities);
606 SMDS_MeshVolume* SMESHDS_Mesh::AddPolyhedralVolume
607 (std::vector<const SMDS_MeshNode*> nodes,
608 std::vector<int> quantities)
610 SMDS_MeshVolume *anElem = SMDS_Mesh::AddPolyhedralVolume(nodes, quantities);
612 int i, len = nodes.size();
613 std::vector<int> nodes_ids (len);
614 for (i = 0; i < len; i++) {
615 nodes_ids[i] = nodes[i]->GetID();
617 myScript->AddPolyhedralVolume(anElem->GetID(), nodes_ids, quantities);
622 //=======================================================================
623 //function : removeFromContainers
625 //=======================================================================
627 static void removeFromContainers (map<int,SMESHDS_SubMesh*>& theSubMeshes,
628 set<SMESHDS_GroupBase*>& theGroups,
629 list<const SMDS_MeshElement*>& theElems,
632 if ( theElems.empty() )
636 // Element can belong to several groups
637 if ( !theGroups.empty() )
639 set<SMESHDS_GroupBase*>::iterator GrIt = theGroups.begin();
640 for ( ; GrIt != theGroups.end(); GrIt++ )
642 SMESHDS_Group* group = dynamic_cast<SMESHDS_Group*>( *GrIt );
643 if ( !group || group->IsEmpty() ) continue;
645 list<const SMDS_MeshElement *>::iterator elIt = theElems.begin();
646 for ( ; elIt != theElems.end(); elIt++ )
648 group->SMDSGroup().Remove( *elIt );
649 if ( group->IsEmpty() ) break;
654 // Rm from sub-meshes
655 // Element should belong to only one sub-mesh
656 map<int,SMESHDS_SubMesh*>::iterator SubIt = theSubMeshes.begin();
657 for ( ; SubIt != theSubMeshes.end(); SubIt++ )
659 int size = isNode ? (*SubIt).second->NbNodes() : (*SubIt).second->NbElements();
660 if ( size == 0 ) continue;
662 list<const SMDS_MeshElement *>::iterator elIt = theElems.begin();
663 while ( elIt != theElems.end() )
665 bool removed = false;
667 removed = (*SubIt).second->RemoveNode( static_cast<const SMDS_MeshNode*> (*elIt) );
669 removed = (*SubIt).second->RemoveElement( *elIt );
673 elIt = theElems.erase( elIt );
674 if ( theElems.empty() )
675 return; // all elements are found and removed
685 //=======================================================================
686 //function : RemoveNode
688 //=======================================================================
689 void SMESHDS_Mesh::RemoveNode(const SMDS_MeshNode * n)
691 myScript->RemoveNode(n->GetID());
693 list<const SMDS_MeshElement *> removedElems;
694 list<const SMDS_MeshElement *> removedNodes;
696 SMDS_Mesh::RemoveElement( n, removedElems, removedNodes, true );
698 removeFromContainers( myShapeIndexToSubMesh, myGroups, removedElems, false );
699 removeFromContainers( myShapeIndexToSubMesh, myGroups, removedNodes, true );
702 //=======================================================================
703 //function : RemoveFreeNode
705 //=======================================================================
706 void SMESHDS_Mesh::RemoveFreeNode(const SMDS_MeshNode * n, SMESHDS_SubMesh * subMesh)
708 myScript->RemoveNode(n->GetID());
711 // Node can belong to several groups
712 if (!myGroups.empty()) {
713 set<SMESHDS_GroupBase*>::iterator GrIt = myGroups.begin();
714 for (; GrIt != myGroups.end(); GrIt++) {
715 SMESHDS_Group* group = dynamic_cast<SMESHDS_Group*>(*GrIt);
716 if (!group || group->IsEmpty()) continue;
717 group->SMDSGroup().Remove(n);
722 // Node should belong to only one sub-mesh
724 subMesh->RemoveNode(n);
726 SMDS_Mesh::RemoveFreeElement(n);
729 //=======================================================================
730 //function : RemoveElement
732 //========================================================================
733 void SMESHDS_Mesh::RemoveElement(const SMDS_MeshElement * elt)
735 if (elt->GetType() == SMDSAbs_Node)
737 RemoveNode( static_cast<const SMDS_MeshNode*>( elt ));
741 myScript->RemoveElement(elt->GetID());
743 list<const SMDS_MeshElement *> removedElems;
744 list<const SMDS_MeshElement *> removedNodes;
746 SMDS_Mesh::RemoveElement(elt, removedElems, removedNodes, false);
748 removeFromContainers( myShapeIndexToSubMesh, myGroups, removedElems, false );
751 //=======================================================================
752 //function : RemoveFreeElement
754 //========================================================================
755 void SMESHDS_Mesh::RemoveFreeElement(const SMDS_MeshElement * elt, SMESHDS_SubMesh * subMesh)
757 if (elt->GetType() == SMDSAbs_Node) {
758 RemoveFreeNode( static_cast<const SMDS_MeshNode*>(elt), subMesh);
762 if (hasConstructionEdges() || hasConstructionFaces())
763 // this methods is only for meshes without descendants
766 myScript->RemoveElement(elt->GetID());
769 // Node can belong to several groups
770 if (!myGroups.empty()) {
771 set<SMESHDS_GroupBase*>::iterator GrIt = myGroups.begin();
772 for (; GrIt != myGroups.end(); GrIt++) {
773 SMESHDS_Group* group = dynamic_cast<SMESHDS_Group*>(*GrIt);
774 if (!group || group->IsEmpty()) continue;
775 group->SMDSGroup().Remove(elt);
780 // Element should belong to only one sub-mesh
782 subMesh->RemoveElement(elt);
784 SMDS_Mesh::RemoveFreeElement(elt);
787 //================================================================================
789 * \brief return submesh by shape
790 * \param shape - the subshape
791 * \retval SMESHDS_SubMesh* - the found submesh
793 * search of submeshes is optimized
795 //================================================================================
797 SMESHDS_SubMesh* SMESHDS_Mesh::getSubmesh( const TopoDS_Shape & shape )
799 if ( shape.IsNull() )
802 if ( !myCurSubShape.IsNull() && shape.IsSame( myCurSubShape ))
805 getSubmesh( ShapeToIndex( shape ));
806 myCurSubShape = shape;
810 //================================================================================
812 * \brief return submesh by subshape index
813 * \param Index - the subshape index
814 * \retval SMESHDS_SubMesh* - the found submesh
815 * search of submeshes is optimized
817 //================================================================================
819 SMESHDS_SubMesh* SMESHDS_Mesh::getSubmesh( const int Index )
821 //Update or build submesh
822 if ( Index != myCurSubID ) {
823 map<int,SMESHDS_SubMesh*>::iterator it = myShapeIndexToSubMesh.find( Index );
824 if ( it == myShapeIndexToSubMesh.end() )
825 it = myShapeIndexToSubMesh.insert( make_pair(Index, new SMESHDS_SubMesh() )).first;
826 myCurSubMesh = it->second;
828 myCurSubShape.Nullify(); // myCurSubShape no more corresponds to submesh
833 //================================================================================
835 * \brief Add element or node to submesh
836 * \param elem - element to add
837 * \param subMesh - submesh to be filled in
839 //================================================================================
841 bool SMESHDS_Mesh::add(const SMDS_MeshElement* elem, SMESHDS_SubMesh* subMesh )
843 if ( elem && subMesh ) {
844 if ( elem->GetType() == SMDSAbs_Node )
845 subMesh->AddNode( static_cast<const SMDS_MeshNode* >( elem ));
847 subMesh->AddElement( elem );
853 //=======================================================================
854 //function : SetNodeOnVolume
856 //=======================================================================
857 void SMESHDS_Mesh::SetNodeInVolume(SMDS_MeshNode * aNode,
858 const TopoDS_Shell & S)
860 if ( add( aNode, getSubmesh(S) ))
861 const_cast<SMDS_Position*>( aNode->GetPosition().get() )->SetShapeId( myCurSubID );
863 //=======================================================================
864 //function : SetNodeOnVolume
866 //=======================================================================
867 void SMESHDS_Mesh::SetNodeInVolume(SMDS_MeshNode * aNode,
868 const TopoDS_Solid & S)
870 if ( add( aNode, getSubmesh(S) ))
871 const_cast<SMDS_Position*>( aNode->GetPosition().get() )->SetShapeId( myCurSubID );
874 //=======================================================================
875 //function : SetNodeOnFace
877 //=======================================================================
878 void SMESHDS_Mesh::SetNodeOnFace(SMDS_MeshNode * aNode,
879 const TopoDS_Face & S,
883 if ( add( aNode, getSubmesh(S) ))
884 aNode->SetPosition(SMDS_PositionPtr(new SMDS_FacePosition(myCurSubID, u, v)));
887 //=======================================================================
888 //function : SetNodeOnEdge
890 //=======================================================================
891 void SMESHDS_Mesh::SetNodeOnEdge(SMDS_MeshNode * aNode,
892 const TopoDS_Edge & S,
895 if ( add( aNode, getSubmesh(S) ))
896 aNode->SetPosition(SMDS_PositionPtr(new SMDS_EdgePosition(myCurSubID, u)));
899 //=======================================================================
900 //function : SetNodeOnVertex
902 //=======================================================================
903 void SMESHDS_Mesh::SetNodeOnVertex(SMDS_MeshNode * aNode,
904 const TopoDS_Vertex & S)
906 if ( add( aNode, getSubmesh(S) ))
907 aNode->SetPosition(SMDS_PositionPtr(new SMDS_VertexPosition(myCurSubID)));
910 //=======================================================================
911 //function : UnSetNodeOnShape
913 //=======================================================================
914 void SMESHDS_Mesh::UnSetNodeOnShape(const SMDS_MeshNode* aNode)
916 if ( aNode && aNode->GetPosition() ) {
917 map<int,SMESHDS_SubMesh*>::iterator it =
918 myShapeIndexToSubMesh.find( aNode->GetPosition()->GetShapeId() );
919 if ( it != myShapeIndexToSubMesh.end() )
920 it->second->RemoveNode( aNode );
924 //=======================================================================
925 //function : SetMeshElementOnShape
927 //=======================================================================
928 void SMESHDS_Mesh::SetMeshElementOnShape(const SMDS_MeshElement * anElement,
929 const TopoDS_Shape & S)
931 add( anElement, getSubmesh(S) );
934 //=======================================================================
935 //function : UnSetMeshElementOnShape
937 //=======================================================================
938 void SMESHDS_Mesh::UnSetMeshElementOnShape(const SMDS_MeshElement * elem,
939 const TopoDS_Shape & S)
941 int Index = myIndexToShape.FindIndex(S);
943 map<int,SMESHDS_SubMesh*>::iterator it = myShapeIndexToSubMesh.find( Index );
944 if ( it != myShapeIndexToSubMesh.end() )
945 if ( elem->GetType() == SMDSAbs_Node )
946 it->second->RemoveNode( static_cast<const SMDS_MeshNode* >( elem ));
948 it->second->RemoveElement( elem );
951 //=======================================================================
952 //function : ShapeToMesh
954 //=======================================================================
955 TopoDS_Shape SMESHDS_Mesh::ShapeToMesh() const
960 //=======================================================================
961 //function : IsGroupOfSubShapes
962 //purpose : return true if at least one subshape of theShape is a subshape
963 // of myShape or theShape == myShape
964 //=======================================================================
966 bool SMESHDS_Mesh::IsGroupOfSubShapes (const TopoDS_Shape& theShape) const
968 if ( myShape.IsSame( theShape ))
971 for ( TopoDS_Iterator it( theShape ); it.More(); it.Next() ) {
972 if (myIndexToShape.Contains( it.Value() ) ||
973 IsGroupOfSubShapes( it.Value() ))
980 ///////////////////////////////////////////////////////////////////////////////
981 /// Return the sub mesh linked to the a given TopoDS_Shape or NULL if the given
982 /// TopoDS_Shape is unknown
983 ///////////////////////////////////////////////////////////////////////////////
984 SMESHDS_SubMesh * SMESHDS_Mesh::MeshElements(const TopoDS_Shape & S) const
986 int Index = ShapeToIndex(S);
987 TShapeIndexToSubMesh::const_iterator anIter = myShapeIndexToSubMesh.find(Index);
988 if (anIter != myShapeIndexToSubMesh.end())
989 return anIter->second;
994 ///////////////////////////////////////////////////////////////////////////////
995 /// Return the sub mesh by Id of shape it is linked to
996 ///////////////////////////////////////////////////////////////////////////////
997 SMESHDS_SubMesh * SMESHDS_Mesh::MeshElements(const int Index)
999 TShapeIndexToSubMesh::const_iterator anIter = myShapeIndexToSubMesh.find(Index);
1000 if (anIter != myShapeIndexToSubMesh.end())
1001 return anIter->second;
1006 //=======================================================================
1007 //function : SubMeshIndices
1009 //=======================================================================
1010 list<int> SMESHDS_Mesh::SubMeshIndices()
1012 list<int> anIndices;
1013 std::map<int,SMESHDS_SubMesh*>::iterator anIter = myShapeIndexToSubMesh.begin();
1014 for (; anIter != myShapeIndexToSubMesh.end(); anIter++) {
1015 anIndices.push_back((*anIter).first);
1020 //=======================================================================
1021 //function : GetHypothesis
1023 //=======================================================================
1025 const list<const SMESHDS_Hypothesis*>&
1026 SMESHDS_Mesh::GetHypothesis(const TopoDS_Shape & S) const
1028 if ( myShapeToHypothesis.IsBound( S.Oriented(TopAbs_FORWARD) ) ) // ignore orientation of S
1029 return myShapeToHypothesis.Find( S.Oriented(TopAbs_FORWARD) );
1031 static list<const SMESHDS_Hypothesis*> empty;
1035 //=======================================================================
1036 //function : GetScript
1038 //=======================================================================
1039 SMESHDS_Script* SMESHDS_Mesh::GetScript()
1044 //=======================================================================
1045 //function : ClearScript
1047 //=======================================================================
1048 void SMESHDS_Mesh::ClearScript()
1053 //=======================================================================
1054 //function : HasMeshElements
1056 //=======================================================================
1057 bool SMESHDS_Mesh::HasMeshElements(const TopoDS_Shape & S)
1059 if (myShape.IsNull()) MESSAGE("myShape is NULL");
1060 int Index = myIndexToShape.FindIndex(S);
1061 return myShapeIndexToSubMesh.find(Index)!=myShapeIndexToSubMesh.end();
1064 //=======================================================================
1065 //function : HasHypothesis
1067 //=======================================================================
1068 bool SMESHDS_Mesh::HasHypothesis(const TopoDS_Shape & S)
1070 return myShapeToHypothesis.IsBound(S.Oriented(TopAbs_FORWARD));
1073 //=======================================================================
1074 //function : NewSubMesh
1076 //=======================================================================
1077 SMESHDS_SubMesh * SMESHDS_Mesh::NewSubMesh(int Index)
1079 SMESHDS_SubMesh* SM = 0;
1080 TShapeIndexToSubMesh::iterator anIter = myShapeIndexToSubMesh.find(Index);
1081 if (anIter == myShapeIndexToSubMesh.end())
1083 SM = new SMESHDS_SubMesh();
1084 myShapeIndexToSubMesh[Index]=SM;
1087 SM = anIter->second;
1091 //=======================================================================
1092 //function : AddCompoundSubmesh
1094 //=======================================================================
1096 int SMESHDS_Mesh::AddCompoundSubmesh(const TopoDS_Shape& S,
1097 TopAbs_ShapeEnum type)
1100 if ( IsGroupOfSubShapes( S ) || (S.ShapeType() == TopAbs_VERTEX && myIndexToShape.Contains(S)) )
1102 aMainIndex = myIndexToShape.Add( S );
1103 bool all = ( type == TopAbs_SHAPE );
1104 if ( all ) // corresponding simple submesh may exist
1105 aMainIndex = -aMainIndex;
1106 //MESSAGE("AddCompoundSubmesh index = " << aMainIndex );
1107 SMESHDS_SubMesh * aNewSub = NewSubMesh( aMainIndex );
1108 if ( !aNewSub->IsComplexSubmesh() ) // is empty
1110 int shapeType = all ? myShape.ShapeType() : type;
1111 int typeLimit = all ? TopAbs_VERTEX : type;
1112 for ( ; shapeType <= typeLimit; shapeType++ )
1114 TopExp_Explorer exp( S, TopAbs_ShapeEnum( shapeType ));
1115 for ( ; exp.More(); exp.Next() )
1117 int index = myIndexToShape.FindIndex( exp.Current() );
1119 aNewSub->AddSubMesh( NewSubMesh( index ));
1127 //=======================================================================
1128 //function : IndexToShape
1130 //=======================================================================
1131 const TopoDS_Shape& SMESHDS_Mesh::IndexToShape(int ShapeIndex) const
1133 return myIndexToShape.FindKey(ShapeIndex);
1136 //=======================================================================
1137 //function : ShapeToIndex
1139 //=======================================================================
1140 int SMESHDS_Mesh::ShapeToIndex(const TopoDS_Shape & S) const
1142 if (myShape.IsNull())
1143 MESSAGE("myShape is NULL");
1145 int index = myIndexToShape.FindIndex(S);
1150 //=======================================================================
1151 //function : SetNodeOnVolume
1153 //=======================================================================
1154 void SMESHDS_Mesh::SetNodeInVolume(const SMDS_MeshNode* aNode, int Index)
1156 if ( add( aNode, getSubmesh( Index )))
1157 const_cast<SMDS_Position*>( aNode->GetPosition().get() )->SetShapeId( Index );
1160 //=======================================================================
1161 //function : SetNodeOnFace
1163 //=======================================================================
1164 void SMESHDS_Mesh::SetNodeOnFace(SMDS_MeshNode* aNode, int Index, double u, double v)
1166 //Set Position on Node
1167 if ( add( aNode, getSubmesh( Index )))
1168 aNode->SetPosition(SMDS_PositionPtr(new SMDS_FacePosition(Index, u, v)));
1171 //=======================================================================
1172 //function : SetNodeOnEdge
1174 //=======================================================================
1175 void SMESHDS_Mesh::SetNodeOnEdge(SMDS_MeshNode* aNode,
1179 //Set Position on Node
1180 if ( add( aNode, getSubmesh( Index )))
1181 aNode->SetPosition(SMDS_PositionPtr(new SMDS_EdgePosition(Index, u)));
1184 //=======================================================================
1185 //function : SetNodeOnVertex
1187 //=======================================================================
1188 void SMESHDS_Mesh::SetNodeOnVertex(SMDS_MeshNode* aNode, int Index)
1190 //Set Position on Node
1191 if ( add( aNode, getSubmesh( Index )))
1192 aNode->SetPosition(SMDS_PositionPtr(new SMDS_VertexPosition(Index)));
1195 //=======================================================================
1196 //function : SetMeshElementOnShape
1198 //=======================================================================
1199 void SMESHDS_Mesh::SetMeshElementOnShape(const SMDS_MeshElement* anElement,
1202 add( anElement, getSubmesh( Index ));
1205 SMESHDS_Mesh::~SMESHDS_Mesh()
1212 //********************************************************************
1213 //********************************************************************
1214 //******** *********
1215 //***** Methods for addition of quadratic elements ******
1216 //******** *********
1217 //********************************************************************
1218 //********************************************************************
1220 //=======================================================================
1221 //function : AddEdgeWithID
1223 //=======================================================================
1224 SMDS_MeshEdge* SMESHDS_Mesh::AddEdgeWithID(int n1, int n2, int n12, int ID)
1226 SMDS_MeshEdge* anElem = SMDS_Mesh::AddEdgeWithID(n1,n2,n12,ID);
1227 if(anElem) myScript->AddEdge(ID,n1,n2,n12);
1231 //=======================================================================
1232 //function : AddEdge
1234 //=======================================================================
1235 SMDS_MeshEdge* SMESHDS_Mesh::AddEdge(const SMDS_MeshNode* n1,
1236 const SMDS_MeshNode* n2,
1237 const SMDS_MeshNode* n12)
1239 SMDS_MeshEdge* anElem = SMDS_Mesh::AddEdge(n1,n2,n12);
1240 if(anElem) myScript->AddEdge(anElem->GetID(),
1247 //=======================================================================
1248 //function : AddEdgeWithID
1250 //=======================================================================
1251 SMDS_MeshEdge* SMESHDS_Mesh::AddEdgeWithID(const SMDS_MeshNode * n1,
1252 const SMDS_MeshNode * n2,
1253 const SMDS_MeshNode * n12,
1256 return AddEdgeWithID(n1->GetID(),
1263 //=======================================================================
1264 //function : AddFace
1266 //=======================================================================
1267 SMDS_MeshFace* SMESHDS_Mesh::AddFace(const SMDS_MeshNode * n1,
1268 const SMDS_MeshNode * n2,
1269 const SMDS_MeshNode * n3,
1270 const SMDS_MeshNode * n12,
1271 const SMDS_MeshNode * n23,
1272 const SMDS_MeshNode * n31)
1274 SMDS_MeshFace *anElem = SMDS_Mesh::AddFace(n1,n2,n3,n12,n23,n31);
1275 if(anElem) myScript->AddFace(anElem->GetID(),
1276 n1->GetID(), n2->GetID(), n3->GetID(),
1277 n12->GetID(), n23->GetID(), n31->GetID());
1281 //=======================================================================
1282 //function : AddFaceWithID
1284 //=======================================================================
1285 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(int n1, int n2, int n3,
1286 int n12,int n23,int n31, int ID)
1288 SMDS_MeshFace *anElem = SMDS_Mesh::AddFaceWithID(n1,n2,n3,n12,n23,n31,ID);
1289 if(anElem) myScript->AddFace(ID,n1,n2,n3,n12,n23,n31);
1293 //=======================================================================
1294 //function : AddFaceWithID
1296 //=======================================================================
1297 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(const SMDS_MeshNode * n1,
1298 const SMDS_MeshNode * n2,
1299 const SMDS_MeshNode * n3,
1300 const SMDS_MeshNode * n12,
1301 const SMDS_MeshNode * n23,
1302 const SMDS_MeshNode * n31,
1305 return AddFaceWithID(n1->GetID(), n2->GetID(), n3->GetID(),
1306 n12->GetID(), n23->GetID(), n31->GetID(),
1311 //=======================================================================
1312 //function : AddFace
1314 //=======================================================================
1315 SMDS_MeshFace* SMESHDS_Mesh::AddFace(const SMDS_MeshNode * n1,
1316 const SMDS_MeshNode * n2,
1317 const SMDS_MeshNode * n3,
1318 const SMDS_MeshNode * n4,
1319 const SMDS_MeshNode * n12,
1320 const SMDS_MeshNode * n23,
1321 const SMDS_MeshNode * n34,
1322 const SMDS_MeshNode * n41)
1324 SMDS_MeshFace *anElem = SMDS_Mesh::AddFace(n1,n2,n3,n4,n12,n23,n34,n41);
1325 if(anElem) myScript->AddFace(anElem->GetID(),
1326 n1->GetID(), n2->GetID(), n3->GetID(), n4->GetID(),
1327 n12->GetID(), n23->GetID(), n34->GetID(), n41->GetID());
1331 //=======================================================================
1332 //function : AddFaceWithID
1334 //=======================================================================
1335 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(int n1, int n2, int n3, int n4,
1336 int n12,int n23,int n34,int n41, int ID)
1338 SMDS_MeshFace *anElem = SMDS_Mesh::AddFaceWithID(n1,n2,n3,n4,n12,n23,n34,n41,ID);
1339 if(anElem) myScript->AddFace(ID,n1,n2,n3,n4,n12,n23,n34,n41);
1343 //=======================================================================
1344 //function : AddFaceWithID
1346 //=======================================================================
1347 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(const SMDS_MeshNode * n1,
1348 const SMDS_MeshNode * n2,
1349 const SMDS_MeshNode * n3,
1350 const SMDS_MeshNode * n4,
1351 const SMDS_MeshNode * n12,
1352 const SMDS_MeshNode * n23,
1353 const SMDS_MeshNode * n34,
1354 const SMDS_MeshNode * n41,
1357 return AddFaceWithID(n1->GetID(), n2->GetID(), n3->GetID(), n4->GetID(),
1358 n12->GetID(), n23->GetID(), n34->GetID(), n41->GetID(),
1363 //=======================================================================
1364 //function : AddVolume
1366 //=======================================================================
1367 SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
1368 const SMDS_MeshNode * n2,
1369 const SMDS_MeshNode * n3,
1370 const SMDS_MeshNode * n4,
1371 const SMDS_MeshNode * n12,
1372 const SMDS_MeshNode * n23,
1373 const SMDS_MeshNode * n31,
1374 const SMDS_MeshNode * n14,
1375 const SMDS_MeshNode * n24,
1376 const SMDS_MeshNode * n34)
1378 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1,n2,n3,n4,n12,n23,n31,n14,n24,n34);
1379 if(anElem) myScript->AddVolume(anElem->GetID(),
1380 n1->GetID(), n2->GetID(), n3->GetID(), n4->GetID(),
1381 n12->GetID(), n23->GetID(), n31->GetID(),
1382 n14->GetID(), n24->GetID(), n34->GetID());
1386 //=======================================================================
1387 //function : AddVolumeWithID
1389 //=======================================================================
1390 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3, int n4,
1391 int n12,int n23,int n31,
1392 int n14,int n24,int n34, int ID)
1394 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolumeWithID(n1,n2,n3,n4,n12,n23,
1395 n31,n14,n24,n34,ID);
1396 if(anElem) myScript->AddVolume(ID,n1,n2,n3,n4,n12,n23,n31,n14,n24,n34);
1400 //=======================================================================
1401 //function : AddVolumeWithID
1402 //purpose : 2d order tetrahedron of 10 nodes
1403 //=======================================================================
1404 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
1405 const SMDS_MeshNode * n2,
1406 const SMDS_MeshNode * n3,
1407 const SMDS_MeshNode * n4,
1408 const SMDS_MeshNode * n12,
1409 const SMDS_MeshNode * n23,
1410 const SMDS_MeshNode * n31,
1411 const SMDS_MeshNode * n14,
1412 const SMDS_MeshNode * n24,
1413 const SMDS_MeshNode * n34,
1416 return AddVolumeWithID(n1->GetID(), n2->GetID(), n3->GetID(), n4->GetID(),
1417 n12->GetID(), n23->GetID(), n31->GetID(),
1418 n14->GetID(), n24->GetID(), n34->GetID(), ID);
1422 //=======================================================================
1423 //function : AddVolume
1425 //=======================================================================
1426 SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
1427 const SMDS_MeshNode * n2,
1428 const SMDS_MeshNode * n3,
1429 const SMDS_MeshNode * n4,
1430 const SMDS_MeshNode * n5,
1431 const SMDS_MeshNode * n12,
1432 const SMDS_MeshNode * n23,
1433 const SMDS_MeshNode * n34,
1434 const SMDS_MeshNode * n41,
1435 const SMDS_MeshNode * n15,
1436 const SMDS_MeshNode * n25,
1437 const SMDS_MeshNode * n35,
1438 const SMDS_MeshNode * n45)
1440 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1,n2,n3,n4,n5,n12,n23,n34,n41,
1443 myScript->AddVolume(anElem->GetID(), n1->GetID(), n2->GetID(),
1444 n3->GetID(), n4->GetID(), n5->GetID(),
1445 n12->GetID(), n23->GetID(), n34->GetID(), n41->GetID(),
1446 n15->GetID(), n25->GetID(), n35->GetID(), n45->GetID());
1450 //=======================================================================
1451 //function : AddVolumeWithID
1453 //=======================================================================
1454 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3, int n4, int n5,
1455 int n12,int n23,int n34,int n41,
1456 int n15,int n25,int n35,int n45, int ID)
1458 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolumeWithID(n1,n2,n3,n4,n5,
1460 n15,n25,n35,n45,ID);
1461 if(anElem) myScript->AddVolume(ID,n1,n2,n3,n4,n5,n12,n23,n34,n41,
1466 //=======================================================================
1467 //function : AddVolumeWithID
1468 //purpose : 2d order pyramid of 13 nodes
1469 //=======================================================================
1470 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
1471 const SMDS_MeshNode * n2,
1472 const SMDS_MeshNode * n3,
1473 const SMDS_MeshNode * n4,
1474 const SMDS_MeshNode * n5,
1475 const SMDS_MeshNode * n12,
1476 const SMDS_MeshNode * n23,
1477 const SMDS_MeshNode * n34,
1478 const SMDS_MeshNode * n41,
1479 const SMDS_MeshNode * n15,
1480 const SMDS_MeshNode * n25,
1481 const SMDS_MeshNode * n35,
1482 const SMDS_MeshNode * n45,
1485 return AddVolumeWithID(n1->GetID(), n2->GetID(), n3->GetID(),
1486 n4->GetID(), n5->GetID(),
1487 n12->GetID(), n23->GetID(), n34->GetID(), n41->GetID(),
1488 n15->GetID(), n25->GetID(), n35->GetID(), n45->GetID(),
1493 //=======================================================================
1494 //function : AddVolume
1496 //=======================================================================
1497 SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
1498 const SMDS_MeshNode * n2,
1499 const SMDS_MeshNode * n3,
1500 const SMDS_MeshNode * n4,
1501 const SMDS_MeshNode * n5,
1502 const SMDS_MeshNode * n6,
1503 const SMDS_MeshNode * n12,
1504 const SMDS_MeshNode * n23,
1505 const SMDS_MeshNode * n31,
1506 const SMDS_MeshNode * n45,
1507 const SMDS_MeshNode * n56,
1508 const SMDS_MeshNode * n64,
1509 const SMDS_MeshNode * n14,
1510 const SMDS_MeshNode * n25,
1511 const SMDS_MeshNode * n36)
1513 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1,n2,n3,n4,n5,n6,n12,n23,n31,
1514 n45,n56,n64,n14,n25,n36);
1516 myScript->AddVolume(anElem->GetID(), n1->GetID(), n2->GetID(),
1517 n3->GetID(), n4->GetID(), n5->GetID(), n6->GetID(),
1518 n12->GetID(), n23->GetID(), n31->GetID(),
1519 n45->GetID(), n56->GetID(), n64->GetID(),
1520 n14->GetID(), n25->GetID(), n36->GetID());
1524 //=======================================================================
1525 //function : AddVolumeWithID
1527 //=======================================================================
1528 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3,
1529 int n4, int n5, int n6,
1530 int n12,int n23,int n31,
1531 int n45,int n56,int n64,
1532 int n14,int n25,int n36, int ID)
1534 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolumeWithID(n1,n2,n3,n4,n5,n6,
1538 if(anElem) myScript->AddVolume(ID,n1,n2,n3,n4,n5,n6,n12,n23,n31,
1539 n45,n56,n64,n14,n25,n36);
1543 //=======================================================================
1544 //function : AddVolumeWithID
1545 //purpose : 2d order Pentahedron with 15 nodes
1546 //=======================================================================
1547 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
1548 const SMDS_MeshNode * n2,
1549 const SMDS_MeshNode * n3,
1550 const SMDS_MeshNode * n4,
1551 const SMDS_MeshNode * n5,
1552 const SMDS_MeshNode * n6,
1553 const SMDS_MeshNode * n12,
1554 const SMDS_MeshNode * n23,
1555 const SMDS_MeshNode * n31,
1556 const SMDS_MeshNode * n45,
1557 const SMDS_MeshNode * n56,
1558 const SMDS_MeshNode * n64,
1559 const SMDS_MeshNode * n14,
1560 const SMDS_MeshNode * n25,
1561 const SMDS_MeshNode * n36,
1564 return AddVolumeWithID(n1->GetID(), n2->GetID(), n3->GetID(),
1565 n4->GetID(), n5->GetID(), n6->GetID(),
1566 n12->GetID(), n23->GetID(), n31->GetID(),
1567 n45->GetID(), n56->GetID(), n64->GetID(),
1568 n14->GetID(), n25->GetID(), n36->GetID(),
1573 //=======================================================================
1574 //function : AddVolume
1576 //=======================================================================
1577 SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
1578 const SMDS_MeshNode * n2,
1579 const SMDS_MeshNode * n3,
1580 const SMDS_MeshNode * n4,
1581 const SMDS_MeshNode * n5,
1582 const SMDS_MeshNode * n6,
1583 const SMDS_MeshNode * n7,
1584 const SMDS_MeshNode * n8,
1585 const SMDS_MeshNode * n12,
1586 const SMDS_MeshNode * n23,
1587 const SMDS_MeshNode * n34,
1588 const SMDS_MeshNode * n41,
1589 const SMDS_MeshNode * n56,
1590 const SMDS_MeshNode * n67,
1591 const SMDS_MeshNode * n78,
1592 const SMDS_MeshNode * n85,
1593 const SMDS_MeshNode * n15,
1594 const SMDS_MeshNode * n26,
1595 const SMDS_MeshNode * n37,
1596 const SMDS_MeshNode * n48)
1598 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1,n2,n3,n4,n5,n6,n7,n8,
1603 myScript->AddVolume(anElem->GetID(), n1->GetID(), n2->GetID(),
1604 n3->GetID(), n4->GetID(), n5->GetID(),
1605 n6->GetID(), n7->GetID(), n8->GetID(),
1606 n12->GetID(), n23->GetID(), n34->GetID(), n41->GetID(),
1607 n56->GetID(), n67->GetID(), n78->GetID(), n85->GetID(),
1608 n15->GetID(), n26->GetID(), n37->GetID(), n48->GetID());
1612 //=======================================================================
1613 //function : AddVolumeWithID
1615 //=======================================================================
1616 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3, int n4,
1617 int n5, int n6, int n7, int n8,
1618 int n12,int n23,int n34,int n41,
1619 int n56,int n67,int n78,int n85,
1620 int n15,int n26,int n37,int n48, int ID)
1622 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolumeWithID(n1,n2,n3,n4,n5,n6,n7,n8,
1625 n15,n26,n37,n48,ID);
1626 if(anElem) myScript->AddVolume(ID,n1,n2,n3,n4,n5,n6,n7,n8,n12,n23,n34,n41,
1627 n56,n67,n78,n85,n15,n26,n37,n48);
1631 //=======================================================================
1632 //function : AddVolumeWithID
1633 //purpose : 2d order Hexahedrons with 20 nodes
1634 //=======================================================================
1635 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
1636 const SMDS_MeshNode * n2,
1637 const SMDS_MeshNode * n3,
1638 const SMDS_MeshNode * n4,
1639 const SMDS_MeshNode * n5,
1640 const SMDS_MeshNode * n6,
1641 const SMDS_MeshNode * n7,
1642 const SMDS_MeshNode * n8,
1643 const SMDS_MeshNode * n12,
1644 const SMDS_MeshNode * n23,
1645 const SMDS_MeshNode * n34,
1646 const SMDS_MeshNode * n41,
1647 const SMDS_MeshNode * n56,
1648 const SMDS_MeshNode * n67,
1649 const SMDS_MeshNode * n78,
1650 const SMDS_MeshNode * n85,
1651 const SMDS_MeshNode * n15,
1652 const SMDS_MeshNode * n26,
1653 const SMDS_MeshNode * n37,
1654 const SMDS_MeshNode * n48,
1657 return AddVolumeWithID(n1->GetID(), n2->GetID(), n3->GetID(), n4->GetID(),
1658 n5->GetID(), n6->GetID(), n7->GetID(), n8->GetID(),
1659 n12->GetID(), n23->GetID(), n34->GetID(), n41->GetID(),
1660 n56->GetID(), n67->GetID(), n78->GetID(), n85->GetID(),
1661 n15->GetID(), n26->GetID(), n37->GetID(), n48->GetID(),