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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
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=myShapeToHypothesis[SS];
112 //Check if the Hypothesis is still present
113 list<const SMESHDS_Hypothesis*>::iterator ith=alist.begin();
115 for (; ith!=alist.end(); ith++)
116 if (H == *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=myShapeToHypothesis.find(S);
131 if(its!=myShapeToHypothesis.end())
133 list<const SMESHDS_Hypothesis*>::iterator ith=(*its).second.begin();
135 for (; ith!=(*its).second.end(); ith++)
138 (*its).second.erase(ith);
145 //=======================================================================
148 //=======================================================================
149 SMDS_MeshNode* SMESHDS_Mesh::AddNode(double x, double y, double z){
150 SMDS_MeshNode* node = SMDS_Mesh::AddNode(x, y, z);
151 if(node!=NULL) myScript->AddNode(node->GetID(), x, y, z);
155 SMDS_MeshNode* SMESHDS_Mesh::AddNodeWithID(double x, double y, double z, int ID){
156 SMDS_MeshNode* node = SMDS_Mesh::AddNodeWithID(x,y,z,ID);
157 if(node!=NULL) myScript->AddNode(node->GetID(), x, y, z);
161 //=======================================================================
162 //function : MoveNode
164 //=======================================================================
165 void SMESHDS_Mesh::MoveNode(const SMDS_MeshNode *n, double x, double y, double z)
167 SMDS_MeshNode * node=const_cast<SMDS_MeshNode*>(n);
169 myScript->MoveNode(n->GetID(), x, y, z);
172 //=======================================================================
173 //function : ChangeElementNodes
175 //=======================================================================
177 bool SMESHDS_Mesh::ChangeElementNodes(const SMDS_MeshElement * elem,
178 const SMDS_MeshNode * nodes[],
181 if ( ! SMDS_Mesh::ChangeElementNodes( elem, nodes, nbnodes ))
184 vector<int> IDs( nbnodes );
185 for ( int i = 0; i < nbnodes; i++ )
186 IDs [ i ] = nodes[ i ]->GetID();
187 myScript->ChangeElementNodes( elem->GetID(), &IDs[0], nbnodes);
192 //=======================================================================
193 //function : ChangePolygonNodes
195 //=======================================================================
196 bool SMESHDS_Mesh::ChangePolygonNodes
197 (const SMDS_MeshElement * elem,
198 vector<const SMDS_MeshNode*> nodes)
200 ASSERT(nodes.size() > 3);
202 return ChangeElementNodes(elem, &nodes[0], nodes.size());
205 //=======================================================================
206 //function : ChangePolyhedronNodes
208 //=======================================================================
209 bool SMESHDS_Mesh::ChangePolyhedronNodes
210 (const SMDS_MeshElement * elem,
211 std::vector<const SMDS_MeshNode*> nodes,
212 std::vector<int> quantities)
214 ASSERT(nodes.size() > 3);
216 if (!SMDS_Mesh::ChangePolyhedronNodes(elem, nodes, quantities))
219 int i, len = nodes.size();
220 std::vector<int> nodes_ids (len);
221 for (i = 0; i < len; i++) {
222 nodes_ids[i] = nodes[i]->GetID();
224 myScript->ChangePolyhedronNodes(elem->GetID(), nodes_ids, quantities);
229 //=======================================================================
230 //function : Renumber
232 //=======================================================================
234 void SMESHDS_Mesh::Renumber (const bool isNodes, const int startID, const int deltaID)
236 SMDS_Mesh::Renumber( isNodes, startID, deltaID );
237 myScript->Renumber( isNodes, startID, deltaID );
240 //=======================================================================
241 //function :AddEdgeWithID
243 //=======================================================================
244 SMDS_MeshEdge* SMESHDS_Mesh::AddEdgeWithID(int n1, int n2, int ID)
246 SMDS_MeshEdge* anElem = SMDS_Mesh::AddEdgeWithID(n1,n2,ID);
247 if(anElem) myScript->AddEdge(ID,n1,n2);
251 SMDS_MeshEdge* SMESHDS_Mesh::AddEdgeWithID(const SMDS_MeshNode * n1,
252 const SMDS_MeshNode * n2,
255 return AddEdgeWithID(n1->GetID(),
260 SMDS_MeshEdge* SMESHDS_Mesh::AddEdge(const SMDS_MeshNode * n1,
261 const SMDS_MeshNode * n2)
263 SMDS_MeshEdge* anElem = SMDS_Mesh::AddEdge(n1,n2);
264 if(anElem) myScript->AddEdge(anElem->GetID(),
270 //=======================================================================
273 //=======================================================================
274 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(int n1, int n2, int n3, int ID)
276 SMDS_MeshFace *anElem = SMDS_Mesh::AddFaceWithID(n1, n2, n3, ID);
277 if(anElem) myScript->AddFace(ID,n1,n2,n3);
281 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(const SMDS_MeshNode * n1,
282 const SMDS_MeshNode * n2,
283 const SMDS_MeshNode * n3,
286 return AddFaceWithID(n1->GetID(),
292 SMDS_MeshFace* SMESHDS_Mesh::AddFace( const SMDS_MeshNode * n1,
293 const SMDS_MeshNode * n2,
294 const SMDS_MeshNode * n3)
296 SMDS_MeshFace *anElem = SMDS_Mesh::AddFace(n1, n2, n3);
297 if(anElem) myScript->AddFace(anElem->GetID(),
304 //=======================================================================
307 //=======================================================================
308 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(int n1, int n2, int n3, int n4, int ID)
310 SMDS_MeshFace *anElem = SMDS_Mesh::AddFaceWithID(n1, n2, n3, n4, ID);
311 if(anElem) myScript->AddFace(ID, n1, n2, n3, n4);
315 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(const SMDS_MeshNode * n1,
316 const SMDS_MeshNode * n2,
317 const SMDS_MeshNode * n3,
318 const SMDS_MeshNode * n4,
321 return AddFaceWithID(n1->GetID(),
328 SMDS_MeshFace* SMESHDS_Mesh::AddFace(const SMDS_MeshNode * n1,
329 const SMDS_MeshNode * n2,
330 const SMDS_MeshNode * n3,
331 const SMDS_MeshNode * n4)
333 SMDS_MeshFace *anElem = SMDS_Mesh::AddFace(n1, n2, n3, n4);
334 if(anElem) myScript->AddFace(anElem->GetID(),
342 //=======================================================================
343 //function :AddVolume
345 //=======================================================================
346 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3, int n4, int ID)
348 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolumeWithID(n1, n2, n3, n4, ID);
349 if(anElem) myScript->AddVolume(ID, n1, n2, n3, n4);
353 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
354 const SMDS_MeshNode * n2,
355 const SMDS_MeshNode * n3,
356 const SMDS_MeshNode * n4,
359 return AddVolumeWithID(n1->GetID(),
366 SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
367 const SMDS_MeshNode * n2,
368 const SMDS_MeshNode * n3,
369 const SMDS_MeshNode * n4)
371 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1, n2, n3, n4);
372 if(anElem) myScript->AddVolume(anElem->GetID(),
380 //=======================================================================
381 //function :AddVolume
383 //=======================================================================
384 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3, int n4, int n5, int ID)
386 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolumeWithID(n1, n2, n3, n4, n5, ID);
387 if(anElem) myScript->AddVolume(ID, n1, n2, n3, n4, n5);
391 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
392 const SMDS_MeshNode * n2,
393 const SMDS_MeshNode * n3,
394 const SMDS_MeshNode * n4,
395 const SMDS_MeshNode * n5,
398 return AddVolumeWithID(n1->GetID(),
406 SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
407 const SMDS_MeshNode * n2,
408 const SMDS_MeshNode * n3,
409 const SMDS_MeshNode * n4,
410 const SMDS_MeshNode * n5)
412 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1, n2, n3, n4, n5);
413 if(anElem) myScript->AddVolume(anElem->GetID(),
422 //=======================================================================
423 //function :AddVolume
425 //=======================================================================
426 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3, int n4, int n5, int n6, int ID)
428 SMDS_MeshVolume *anElem= SMDS_Mesh::AddVolumeWithID(n1, n2, n3, n4, n5, n6, ID);
429 if(anElem) myScript->AddVolume(ID, n1, n2, n3, n4, n5, n6);
433 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
434 const SMDS_MeshNode * n2,
435 const SMDS_MeshNode * n3,
436 const SMDS_MeshNode * n4,
437 const SMDS_MeshNode * n5,
438 const SMDS_MeshNode * n6,
441 return AddVolumeWithID(n1->GetID(),
450 SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
451 const SMDS_MeshNode * n2,
452 const SMDS_MeshNode * n3,
453 const SMDS_MeshNode * n4,
454 const SMDS_MeshNode * n5,
455 const SMDS_MeshNode * n6)
457 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1, n2, n3, n4, n5, n6);
458 if(anElem) myScript->AddVolume(anElem->GetID(),
468 //=======================================================================
469 //function :AddVolume
471 //=======================================================================
472 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3, int n4, int n5, int n6, int n7, int n8, int ID)
474 SMDS_MeshVolume *anElem= SMDS_Mesh::AddVolumeWithID(n1, n2, n3, n4, n5, n6, n7, n8, ID);
475 if(anElem) myScript->AddVolume(ID, n1, n2, n3, n4, n5, n6, n7, n8);
479 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
480 const SMDS_MeshNode * n2,
481 const SMDS_MeshNode * n3,
482 const SMDS_MeshNode * n4,
483 const SMDS_MeshNode * n5,
484 const SMDS_MeshNode * n6,
485 const SMDS_MeshNode * n7,
486 const SMDS_MeshNode * n8,
489 return AddVolumeWithID(n1->GetID(),
500 SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
501 const SMDS_MeshNode * n2,
502 const SMDS_MeshNode * n3,
503 const SMDS_MeshNode * n4,
504 const SMDS_MeshNode * n5,
505 const SMDS_MeshNode * n6,
506 const SMDS_MeshNode * n7,
507 const SMDS_MeshNode * n8)
509 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1, n2, n3, n4, n5, n6, n7, n8);
510 if(anElem) myScript->AddVolume(anElem->GetID(),
522 //=======================================================================
523 //function : AddPolygonalFace
525 //=======================================================================
526 SMDS_MeshFace* SMESHDS_Mesh::AddPolygonalFaceWithID (std::vector<int> nodes_ids,
529 SMDS_MeshFace *anElem = SMDS_Mesh::AddPolygonalFaceWithID(nodes_ids, ID);
531 myScript->AddPolygonalFace(ID, nodes_ids);
536 SMDS_MeshFace* SMESHDS_Mesh::AddPolygonalFaceWithID
537 (std::vector<const SMDS_MeshNode*> nodes,
540 SMDS_MeshFace *anElem = SMDS_Mesh::AddPolygonalFaceWithID(nodes, ID);
542 int i, len = nodes.size();
543 std::vector<int> nodes_ids (len);
544 for (i = 0; i < len; i++) {
545 nodes_ids[i] = nodes[i]->GetID();
547 myScript->AddPolygonalFace(ID, nodes_ids);
552 SMDS_MeshFace* SMESHDS_Mesh::AddPolygonalFace
553 (std::vector<const SMDS_MeshNode*> nodes)
555 SMDS_MeshFace *anElem = SMDS_Mesh::AddPolygonalFace(nodes);
557 int i, len = nodes.size();
558 std::vector<int> nodes_ids (len);
559 for (i = 0; i < len; i++) {
560 nodes_ids[i] = nodes[i]->GetID();
562 myScript->AddPolygonalFace(anElem->GetID(), nodes_ids);
567 //=======================================================================
568 //function : AddPolyhedralVolume
570 //=======================================================================
571 SMDS_MeshVolume* SMESHDS_Mesh::AddPolyhedralVolumeWithID (std::vector<int> nodes_ids,
572 std::vector<int> quantities,
575 SMDS_MeshVolume *anElem = SMDS_Mesh::AddPolyhedralVolumeWithID(nodes_ids, quantities, ID);
577 myScript->AddPolyhedralVolume(ID, nodes_ids, quantities);
582 SMDS_MeshVolume* SMESHDS_Mesh::AddPolyhedralVolumeWithID
583 (std::vector<const SMDS_MeshNode*> nodes,
584 std::vector<int> quantities,
587 SMDS_MeshVolume *anElem = SMDS_Mesh::AddPolyhedralVolumeWithID(nodes, quantities, ID);
589 int i, len = nodes.size();
590 std::vector<int> nodes_ids (len);
591 for (i = 0; i < len; i++) {
592 nodes_ids[i] = nodes[i]->GetID();
594 myScript->AddPolyhedralVolume(ID, nodes_ids, quantities);
599 SMDS_MeshVolume* SMESHDS_Mesh::AddPolyhedralVolume
600 (std::vector<const SMDS_MeshNode*> nodes,
601 std::vector<int> quantities)
603 SMDS_MeshVolume *anElem = SMDS_Mesh::AddPolyhedralVolume(nodes, quantities);
605 int i, len = nodes.size();
606 std::vector<int> nodes_ids (len);
607 for (i = 0; i < len; i++) {
608 nodes_ids[i] = nodes[i]->GetID();
610 myScript->AddPolyhedralVolume(anElem->GetID(), nodes_ids, quantities);
615 //=======================================================================
616 //function : removeFromContainers
618 //=======================================================================
620 static void removeFromContainers (map<int,SMESHDS_SubMesh*>& theSubMeshes,
621 set<SMESHDS_GroupBase*>& theGroups,
622 list<const SMDS_MeshElement*>& theElems,
625 if ( theElems.empty() )
629 // Element can belong to several groups
630 if ( !theGroups.empty() )
632 set<SMESHDS_GroupBase*>::iterator GrIt = theGroups.begin();
633 for ( ; GrIt != theGroups.end(); GrIt++ )
635 SMESHDS_Group* group = dynamic_cast<SMESHDS_Group*>( *GrIt );
636 if ( !group || group->IsEmpty() ) continue;
638 list<const SMDS_MeshElement *>::iterator elIt = theElems.begin();
639 for ( ; elIt != theElems.end(); elIt++ )
641 group->SMDSGroup().Remove( *elIt );
642 if ( group->IsEmpty() ) break;
647 // Rm from sub-meshes
648 // Element should belong to only one sub-mesh
649 map<int,SMESHDS_SubMesh*>::iterator SubIt = theSubMeshes.begin();
650 for ( ; SubIt != theSubMeshes.end(); SubIt++ )
652 int size = isNode ? (*SubIt).second->NbNodes() : (*SubIt).second->NbElements();
653 if ( size == 0 ) continue;
655 list<const SMDS_MeshElement *>::iterator elIt = theElems.begin();
656 while ( elIt != theElems.end() )
658 bool removed = false;
660 removed = (*SubIt).second->RemoveNode( static_cast<const SMDS_MeshNode*> (*elIt) );
662 removed = (*SubIt).second->RemoveElement( *elIt );
666 elIt = theElems.erase( elIt );
667 if ( theElems.empty() )
668 return; // all elements are found and removed
678 //=======================================================================
679 //function : RemoveNode
681 //=======================================================================
682 void SMESHDS_Mesh::RemoveNode(const SMDS_MeshNode * n)
684 myScript->RemoveNode(n->GetID());
686 list<const SMDS_MeshElement *> removedElems;
687 list<const SMDS_MeshElement *> removedNodes;
689 SMDS_Mesh::RemoveElement( n, removedElems, removedNodes, true );
691 removeFromContainers( myShapeIndexToSubMesh, myGroups, removedElems, false );
692 removeFromContainers( myShapeIndexToSubMesh, myGroups, removedNodes, true );
695 //=======================================================================
696 //function : RemoveFreeNode
698 //=======================================================================
699 void SMESHDS_Mesh::RemoveFreeNode(const SMDS_MeshNode * n, SMESHDS_SubMesh * subMesh)
701 myScript->RemoveNode(n->GetID());
704 // Node can belong to several groups
705 if (!myGroups.empty()) {
706 set<SMESHDS_GroupBase*>::iterator GrIt = myGroups.begin();
707 for (; GrIt != myGroups.end(); GrIt++) {
708 SMESHDS_Group* group = dynamic_cast<SMESHDS_Group*>(*GrIt);
709 if (!group || group->IsEmpty()) continue;
710 group->SMDSGroup().Remove(n);
715 // Node should belong to only one sub-mesh
717 subMesh->RemoveNode(n);
719 SMDS_Mesh::RemoveFreeElement(n);
722 //=======================================================================
723 //function : RemoveElement
725 //========================================================================
726 void SMESHDS_Mesh::RemoveElement(const SMDS_MeshElement * elt)
728 if (elt->GetType() == SMDSAbs_Node)
730 RemoveNode( static_cast<const SMDS_MeshNode*>( elt ));
734 myScript->RemoveElement(elt->GetID());
736 list<const SMDS_MeshElement *> removedElems;
737 list<const SMDS_MeshElement *> removedNodes;
739 SMDS_Mesh::RemoveElement(elt, removedElems, removedNodes, false);
741 removeFromContainers( myShapeIndexToSubMesh, myGroups, removedElems, false );
744 //=======================================================================
745 //function : RemoveFreeElement
747 //========================================================================
748 void SMESHDS_Mesh::RemoveFreeElement(const SMDS_MeshElement * elt, SMESHDS_SubMesh * subMesh)
750 if (elt->GetType() == SMDSAbs_Node) {
751 RemoveFreeNode( static_cast<const SMDS_MeshNode*>(elt), subMesh);
755 if (hasConstructionEdges() || hasConstructionFaces())
756 // this methods is only for meshes without descendants
759 myScript->RemoveElement(elt->GetID());
762 // Node can belong to several groups
763 if (!myGroups.empty()) {
764 set<SMESHDS_GroupBase*>::iterator GrIt = myGroups.begin();
765 for (; GrIt != myGroups.end(); GrIt++) {
766 SMESHDS_Group* group = dynamic_cast<SMESHDS_Group*>(*GrIt);
767 if (!group || group->IsEmpty()) continue;
768 group->SMDSGroup().Remove(elt);
773 // Element should belong to only one sub-mesh
775 subMesh->RemoveElement(elt);
777 SMDS_Mesh::RemoveFreeElement(elt);
780 //================================================================================
782 * \brief return submesh by shape
783 * \param shape - the subshape
784 * \retval SMESHDS_SubMesh* - the found submesh
786 * search of submeshes is optimized
788 //================================================================================
790 SMESHDS_SubMesh* SMESHDS_Mesh::getSubmesh( const TopoDS_Shape & shape )
792 if ( shape.IsNull() )
795 if ( !myCurSubShape.IsNull() && shape.IsSame( myCurSubShape ))
798 getSubmesh( ShapeToIndex( shape ));
799 myCurSubShape = shape;
803 //================================================================================
805 * \brief return submesh by subshape index
806 * \param Index - the subshape index
807 * \retval SMESHDS_SubMesh* - the found submesh
808 * search of submeshes is optimized
810 //================================================================================
812 SMESHDS_SubMesh* SMESHDS_Mesh::getSubmesh( const int Index )
814 //Update or build submesh
815 if ( Index != myCurSubID ) {
816 map<int,SMESHDS_SubMesh*>::iterator it = myShapeIndexToSubMesh.find( Index );
817 if ( it == myShapeIndexToSubMesh.end() )
818 it = myShapeIndexToSubMesh.insert( make_pair(Index, new SMESHDS_SubMesh() )).first;
819 myCurSubMesh = it->second;
821 myCurSubShape.Nullify(); // myCurSubShape no more corresponds to submesh
826 //================================================================================
828 * \brief Add element or node to submesh
829 * \param elem - element to add
830 * \param subMesh - submesh to be filled in
832 //================================================================================
834 bool SMESHDS_Mesh::add(const SMDS_MeshElement* elem, SMESHDS_SubMesh* subMesh )
836 if ( elem && subMesh ) {
837 if ( elem->GetType() == SMDSAbs_Node )
838 subMesh->AddNode( static_cast<const SMDS_MeshNode* >( elem ));
840 subMesh->AddElement( elem );
846 //=======================================================================
847 //function : SetNodeOnVolume
849 //=======================================================================
850 void SMESHDS_Mesh::SetNodeInVolume(SMDS_MeshNode * aNode,
851 const TopoDS_Shell & S)
853 if ( add( aNode, getSubmesh(S) ))
854 const_cast<SMDS_Position*>( aNode->GetPosition().get() )->SetShapeId( myCurSubID );
856 //=======================================================================
857 //function : SetNodeOnVolume
859 //=======================================================================
860 void SMESHDS_Mesh::SetNodeInVolume(SMDS_MeshNode * aNode,
861 const TopoDS_Solid & S)
863 if ( add( aNode, getSubmesh(S) ))
864 const_cast<SMDS_Position*>( aNode->GetPosition().get() )->SetShapeId( myCurSubID );
867 //=======================================================================
868 //function : SetNodeOnFace
870 //=======================================================================
871 void SMESHDS_Mesh::SetNodeOnFace(SMDS_MeshNode * aNode,
872 const TopoDS_Face & S,
876 if ( add( aNode, getSubmesh(S) ))
877 aNode->SetPosition(SMDS_PositionPtr(new SMDS_FacePosition(myCurSubID, u, v)));
880 //=======================================================================
881 //function : SetNodeOnEdge
883 //=======================================================================
884 void SMESHDS_Mesh::SetNodeOnEdge(SMDS_MeshNode * aNode,
885 const TopoDS_Edge & S,
888 if ( add( aNode, getSubmesh(S) ))
889 aNode->SetPosition(SMDS_PositionPtr(new SMDS_EdgePosition(myCurSubID, u)));
892 //=======================================================================
893 //function : SetNodeOnVertex
895 //=======================================================================
896 void SMESHDS_Mesh::SetNodeOnVertex(SMDS_MeshNode * aNode,
897 const TopoDS_Vertex & S)
899 if ( add( aNode, getSubmesh(S) ))
900 aNode->SetPosition(SMDS_PositionPtr(new SMDS_VertexPosition(myCurSubID)));
903 //=======================================================================
904 //function : UnSetNodeOnShape
906 //=======================================================================
907 void SMESHDS_Mesh::UnSetNodeOnShape(const SMDS_MeshNode* aNode)
909 if ( aNode && aNode->GetPosition() ) {
910 map<int,SMESHDS_SubMesh*>::iterator it =
911 myShapeIndexToSubMesh.find( aNode->GetPosition()->GetShapeId() );
912 if ( it != myShapeIndexToSubMesh.end() )
913 it->second->RemoveNode( aNode );
917 //=======================================================================
918 //function : SetMeshElementOnShape
920 //=======================================================================
921 void SMESHDS_Mesh::SetMeshElementOnShape(const SMDS_MeshElement * anElement,
922 const TopoDS_Shape & S)
924 add( anElement, getSubmesh(S) );
927 //=======================================================================
928 //function : UnSetMeshElementOnShape
930 //=======================================================================
931 void SMESHDS_Mesh::UnSetMeshElementOnShape(const SMDS_MeshElement * elem,
932 const TopoDS_Shape & S)
934 int Index = myIndexToShape.FindIndex(S);
936 map<int,SMESHDS_SubMesh*>::iterator it = myShapeIndexToSubMesh.find( Index );
937 if ( it != myShapeIndexToSubMesh.end() )
938 if ( elem->GetType() == SMDSAbs_Node )
939 it->second->RemoveNode( static_cast<const SMDS_MeshNode* >( elem ));
941 it->second->RemoveElement( elem );
944 //=======================================================================
945 //function : ShapeToMesh
947 //=======================================================================
948 TopoDS_Shape SMESHDS_Mesh::ShapeToMesh() const
953 //=======================================================================
954 //function : IsGroupOfSubShapes
955 //purpose : return true if at least one subshape of theShape is a subshape
956 // of myShape or theShape == myShape
957 //=======================================================================
959 bool SMESHDS_Mesh::IsGroupOfSubShapes (const TopoDS_Shape& theShape) const
961 if ( myShape.IsSame( theShape ))
964 for ( TopoDS_Iterator it( theShape ); it.More(); it.Next() ) {
965 if (myIndexToShape.Contains( it.Value() ) ||
966 IsGroupOfSubShapes( it.Value() ))
973 ///////////////////////////////////////////////////////////////////////////////
974 /// Return the sub mesh linked to the a given TopoDS_Shape or NULL if the given
975 /// TopoDS_Shape is unknown
976 ///////////////////////////////////////////////////////////////////////////////
977 SMESHDS_SubMesh * SMESHDS_Mesh::MeshElements(const TopoDS_Shape & S) const
979 int Index = ShapeToIndex(S);
980 TShapeIndexToSubMesh::const_iterator anIter = myShapeIndexToSubMesh.find(Index);
981 if (anIter != myShapeIndexToSubMesh.end())
982 return anIter->second;
987 ///////////////////////////////////////////////////////////////////////////////
988 /// Return the sub mesh by Id of shape it is linked to
989 ///////////////////////////////////////////////////////////////////////////////
990 SMESHDS_SubMesh * SMESHDS_Mesh::MeshElements(const int Index)
992 TShapeIndexToSubMesh::const_iterator anIter = myShapeIndexToSubMesh.find(Index);
993 if (anIter != myShapeIndexToSubMesh.end())
994 return anIter->second;
999 //=======================================================================
1000 //function : SubMeshIndices
1002 //=======================================================================
1003 list<int> SMESHDS_Mesh::SubMeshIndices()
1005 list<int> anIndices;
1006 std::map<int,SMESHDS_SubMesh*>::iterator anIter = myShapeIndexToSubMesh.begin();
1007 for (; anIter != myShapeIndexToSubMesh.end(); anIter++) {
1008 anIndices.push_back((*anIter).first);
1013 //=======================================================================
1014 //function : GetHypothesis
1016 //=======================================================================
1018 const list<const SMESHDS_Hypothesis*>& SMESHDS_Mesh::GetHypothesis(
1019 const TopoDS_Shape & S) const
1021 if (myShapeToHypothesis.find(S)!=myShapeToHypothesis.end())
1022 return myShapeToHypothesis.find(S)->second;
1024 static list<const SMESHDS_Hypothesis*> empty;
1028 //=======================================================================
1029 //function : GetScript
1031 //=======================================================================
1032 SMESHDS_Script* SMESHDS_Mesh::GetScript()
1037 //=======================================================================
1038 //function : ClearScript
1040 //=======================================================================
1041 void SMESHDS_Mesh::ClearScript()
1046 //=======================================================================
1047 //function : HasMeshElements
1049 //=======================================================================
1050 bool SMESHDS_Mesh::HasMeshElements(const TopoDS_Shape & S)
1052 if (myShape.IsNull()) MESSAGE("myShape is NULL");
1053 int Index = myIndexToShape.FindIndex(S);
1054 return myShapeIndexToSubMesh.find(Index)!=myShapeIndexToSubMesh.end();
1057 //=======================================================================
1058 //function : HasHypothesis
1060 //=======================================================================
1061 bool SMESHDS_Mesh::HasHypothesis(const TopoDS_Shape & S)
1063 return myShapeToHypothesis.find(S)!=myShapeToHypothesis.end();
1066 //=======================================================================
1067 //function : NewSubMesh
1069 //=======================================================================
1070 SMESHDS_SubMesh * SMESHDS_Mesh::NewSubMesh(int Index)
1072 SMESHDS_SubMesh* SM = 0;
1073 TShapeIndexToSubMesh::iterator anIter = myShapeIndexToSubMesh.find(Index);
1074 if (anIter == myShapeIndexToSubMesh.end())
1076 SM = new SMESHDS_SubMesh();
1077 myShapeIndexToSubMesh[Index]=SM;
1080 SM = anIter->second;
1084 //=======================================================================
1085 //function : AddCompoundSubmesh
1087 //=======================================================================
1089 int SMESHDS_Mesh::AddCompoundSubmesh(const TopoDS_Shape& S,
1090 TopAbs_ShapeEnum type)
1093 if ( IsGroupOfSubShapes( S ) || (S.ShapeType() == TopAbs_VERTEX && myIndexToShape.Contains(S)) )
1095 aMainIndex = myIndexToShape.Add( S );
1096 bool all = ( type == TopAbs_SHAPE );
1097 if ( all ) // corresponding simple submesh may exist
1098 aMainIndex = -aMainIndex;
1099 //MESSAGE("AddCompoundSubmesh index = " << aMainIndex );
1100 SMESHDS_SubMesh * aNewSub = NewSubMesh( aMainIndex );
1101 if ( !aNewSub->IsComplexSubmesh() ) // is empty
1103 int shapeType = all ? myShape.ShapeType() : type;
1104 int typeLimit = all ? TopAbs_VERTEX : type;
1105 for ( ; shapeType <= typeLimit; shapeType++ )
1107 TopExp_Explorer exp( S, TopAbs_ShapeEnum( shapeType ));
1108 for ( ; exp.More(); exp.Next() )
1110 int index = myIndexToShape.FindIndex( exp.Current() );
1112 aNewSub->AddSubMesh( NewSubMesh( index ));
1120 //=======================================================================
1121 //function : IndexToShape
1123 //=======================================================================
1124 const TopoDS_Shape& SMESHDS_Mesh::IndexToShape(int ShapeIndex) const
1126 return myIndexToShape.FindKey(ShapeIndex);
1129 //=======================================================================
1130 //function : ShapeToIndex
1132 //=======================================================================
1133 int SMESHDS_Mesh::ShapeToIndex(const TopoDS_Shape & S) const
1135 if (myShape.IsNull())
1136 MESSAGE("myShape is NULL");
1138 int index = myIndexToShape.FindIndex(S);
1143 //=======================================================================
1144 //function : SetNodeOnVolume
1146 //=======================================================================
1147 void SMESHDS_Mesh::SetNodeInVolume(const SMDS_MeshNode* aNode, int Index)
1149 if ( add( aNode, getSubmesh( Index )))
1150 const_cast<SMDS_Position*>( aNode->GetPosition().get() )->SetShapeId( Index );
1153 //=======================================================================
1154 //function : SetNodeOnFace
1156 //=======================================================================
1157 void SMESHDS_Mesh::SetNodeOnFace(SMDS_MeshNode* aNode, int Index, double u, double v)
1159 //Set Position on Node
1160 if ( add( aNode, getSubmesh( Index )))
1161 aNode->SetPosition(SMDS_PositionPtr(new SMDS_FacePosition(Index, u, v)));
1164 //=======================================================================
1165 //function : SetNodeOnEdge
1167 //=======================================================================
1168 void SMESHDS_Mesh::SetNodeOnEdge(SMDS_MeshNode* aNode,
1172 //Set Position on Node
1173 if ( add( aNode, getSubmesh( Index )))
1174 aNode->SetPosition(SMDS_PositionPtr(new SMDS_EdgePosition(Index, u)));
1177 //=======================================================================
1178 //function : SetNodeOnVertex
1180 //=======================================================================
1181 void SMESHDS_Mesh::SetNodeOnVertex(SMDS_MeshNode* aNode, int Index)
1183 //Set Position on Node
1184 if ( add( aNode, getSubmesh( Index )))
1185 aNode->SetPosition(SMDS_PositionPtr(new SMDS_VertexPosition(Index)));
1188 //=======================================================================
1189 //function : SetMeshElementOnShape
1191 //=======================================================================
1192 void SMESHDS_Mesh::SetMeshElementOnShape(const SMDS_MeshElement* anElement,
1195 add( anElement, getSubmesh( Index ));
1198 SMESHDS_Mesh::~SMESHDS_Mesh()
1205 //********************************************************************
1206 //********************************************************************
1207 //******** *********
1208 //***** Methods for addition of quadratic elements ******
1209 //******** *********
1210 //********************************************************************
1211 //********************************************************************
1213 //=======================================================================
1214 //function : AddEdgeWithID
1216 //=======================================================================
1217 SMDS_MeshEdge* SMESHDS_Mesh::AddEdgeWithID(int n1, int n2, int n12, int ID)
1219 SMDS_MeshEdge* anElem = SMDS_Mesh::AddEdgeWithID(n1,n2,n12,ID);
1220 if(anElem) myScript->AddEdge(ID,n1,n2,n12);
1224 //=======================================================================
1225 //function : AddEdge
1227 //=======================================================================
1228 SMDS_MeshEdge* SMESHDS_Mesh::AddEdge(const SMDS_MeshNode* n1,
1229 const SMDS_MeshNode* n2,
1230 const SMDS_MeshNode* n12)
1232 SMDS_MeshEdge* anElem = SMDS_Mesh::AddEdge(n1,n2,n12);
1233 if(anElem) myScript->AddEdge(anElem->GetID(),
1240 //=======================================================================
1241 //function : AddEdgeWithID
1243 //=======================================================================
1244 SMDS_MeshEdge* SMESHDS_Mesh::AddEdgeWithID(const SMDS_MeshNode * n1,
1245 const SMDS_MeshNode * n2,
1246 const SMDS_MeshNode * n12,
1249 return AddEdgeWithID(n1->GetID(),
1256 //=======================================================================
1257 //function : AddFace
1259 //=======================================================================
1260 SMDS_MeshFace* SMESHDS_Mesh::AddFace(const SMDS_MeshNode * n1,
1261 const SMDS_MeshNode * n2,
1262 const SMDS_MeshNode * n3,
1263 const SMDS_MeshNode * n12,
1264 const SMDS_MeshNode * n23,
1265 const SMDS_MeshNode * n31)
1267 SMDS_MeshFace *anElem = SMDS_Mesh::AddFace(n1,n2,n3,n12,n23,n31);
1268 if(anElem) myScript->AddFace(anElem->GetID(),
1269 n1->GetID(), n2->GetID(), n3->GetID(),
1270 n12->GetID(), n23->GetID(), n31->GetID());
1274 //=======================================================================
1275 //function : AddFaceWithID
1277 //=======================================================================
1278 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(int n1, int n2, int n3,
1279 int n12,int n23,int n31, int ID)
1281 SMDS_MeshFace *anElem = SMDS_Mesh::AddFaceWithID(n1,n2,n3,n12,n23,n31,ID);
1282 if(anElem) myScript->AddFace(ID,n1,n2,n3,n12,n23,n31);
1286 //=======================================================================
1287 //function : AddFaceWithID
1289 //=======================================================================
1290 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(const SMDS_MeshNode * n1,
1291 const SMDS_MeshNode * n2,
1292 const SMDS_MeshNode * n3,
1293 const SMDS_MeshNode * n12,
1294 const SMDS_MeshNode * n23,
1295 const SMDS_MeshNode * n31,
1298 return AddFaceWithID(n1->GetID(), n2->GetID(), n3->GetID(),
1299 n12->GetID(), n23->GetID(), n31->GetID(),
1304 //=======================================================================
1305 //function : AddFace
1307 //=======================================================================
1308 SMDS_MeshFace* SMESHDS_Mesh::AddFace(const SMDS_MeshNode * n1,
1309 const SMDS_MeshNode * n2,
1310 const SMDS_MeshNode * n3,
1311 const SMDS_MeshNode * n4,
1312 const SMDS_MeshNode * n12,
1313 const SMDS_MeshNode * n23,
1314 const SMDS_MeshNode * n34,
1315 const SMDS_MeshNode * n41)
1317 SMDS_MeshFace *anElem = SMDS_Mesh::AddFace(n1,n2,n3,n4,n12,n23,n34,n41);
1318 if(anElem) myScript->AddFace(anElem->GetID(),
1319 n1->GetID(), n2->GetID(), n3->GetID(), n4->GetID(),
1320 n12->GetID(), n23->GetID(), n34->GetID(), n41->GetID());
1324 //=======================================================================
1325 //function : AddFaceWithID
1327 //=======================================================================
1328 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(int n1, int n2, int n3, int n4,
1329 int n12,int n23,int n34,int n41, int ID)
1331 SMDS_MeshFace *anElem = SMDS_Mesh::AddFaceWithID(n1,n2,n3,n4,n12,n23,n34,n41,ID);
1332 if(anElem) myScript->AddFace(ID,n1,n2,n3,n4,n12,n23,n34,n41);
1336 //=======================================================================
1337 //function : AddFaceWithID
1339 //=======================================================================
1340 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(const SMDS_MeshNode * n1,
1341 const SMDS_MeshNode * n2,
1342 const SMDS_MeshNode * n3,
1343 const SMDS_MeshNode * n4,
1344 const SMDS_MeshNode * n12,
1345 const SMDS_MeshNode * n23,
1346 const SMDS_MeshNode * n34,
1347 const SMDS_MeshNode * n41,
1350 return AddFaceWithID(n1->GetID(), n2->GetID(), n3->GetID(), n4->GetID(),
1351 n12->GetID(), n23->GetID(), n34->GetID(), n41->GetID(),
1356 //=======================================================================
1357 //function : AddVolume
1359 //=======================================================================
1360 SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
1361 const SMDS_MeshNode * n2,
1362 const SMDS_MeshNode * n3,
1363 const SMDS_MeshNode * n4,
1364 const SMDS_MeshNode * n12,
1365 const SMDS_MeshNode * n23,
1366 const SMDS_MeshNode * n31,
1367 const SMDS_MeshNode * n14,
1368 const SMDS_MeshNode * n24,
1369 const SMDS_MeshNode * n34)
1371 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1,n2,n3,n4,n12,n23,n31,n14,n24,n34);
1372 if(anElem) myScript->AddVolume(anElem->GetID(),
1373 n1->GetID(), n2->GetID(), n3->GetID(), n4->GetID(),
1374 n12->GetID(), n23->GetID(), n31->GetID(),
1375 n14->GetID(), n24->GetID(), n34->GetID());
1379 //=======================================================================
1380 //function : AddVolumeWithID
1382 //=======================================================================
1383 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3, int n4,
1384 int n12,int n23,int n31,
1385 int n14,int n24,int n34, int ID)
1387 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolumeWithID(n1,n2,n3,n4,n12,n23,
1388 n31,n14,n24,n34,ID);
1389 if(anElem) myScript->AddVolume(ID,n1,n2,n3,n4,n12,n23,n31,n14,n24,n34);
1393 //=======================================================================
1394 //function : AddVolumeWithID
1395 //purpose : 2d order tetrahedron of 10 nodes
1396 //=======================================================================
1397 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
1398 const SMDS_MeshNode * n2,
1399 const SMDS_MeshNode * n3,
1400 const SMDS_MeshNode * n4,
1401 const SMDS_MeshNode * n12,
1402 const SMDS_MeshNode * n23,
1403 const SMDS_MeshNode * n31,
1404 const SMDS_MeshNode * n14,
1405 const SMDS_MeshNode * n24,
1406 const SMDS_MeshNode * n34,
1409 return AddVolumeWithID(n1->GetID(), n2->GetID(), n3->GetID(), n4->GetID(),
1410 n12->GetID(), n23->GetID(), n31->GetID(),
1411 n14->GetID(), n24->GetID(), n34->GetID(), ID);
1415 //=======================================================================
1416 //function : AddVolume
1418 //=======================================================================
1419 SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
1420 const SMDS_MeshNode * n2,
1421 const SMDS_MeshNode * n3,
1422 const SMDS_MeshNode * n4,
1423 const SMDS_MeshNode * n5,
1424 const SMDS_MeshNode * n12,
1425 const SMDS_MeshNode * n23,
1426 const SMDS_MeshNode * n34,
1427 const SMDS_MeshNode * n41,
1428 const SMDS_MeshNode * n15,
1429 const SMDS_MeshNode * n25,
1430 const SMDS_MeshNode * n35,
1431 const SMDS_MeshNode * n45)
1433 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1,n2,n3,n4,n5,n12,n23,n34,n41,
1436 myScript->AddVolume(anElem->GetID(), n1->GetID(), n2->GetID(),
1437 n3->GetID(), n4->GetID(), n5->GetID(),
1438 n12->GetID(), n23->GetID(), n34->GetID(), n41->GetID(),
1439 n15->GetID(), n25->GetID(), n35->GetID(), n45->GetID());
1443 //=======================================================================
1444 //function : AddVolumeWithID
1446 //=======================================================================
1447 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3, int n4, int n5,
1448 int n12,int n23,int n34,int n41,
1449 int n15,int n25,int n35,int n45, int ID)
1451 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolumeWithID(n1,n2,n3,n4,n5,
1453 n15,n25,n35,n45,ID);
1454 if(anElem) myScript->AddVolume(ID,n1,n2,n3,n4,n5,n12,n23,n34,n41,
1459 //=======================================================================
1460 //function : AddVolumeWithID
1461 //purpose : 2d order pyramid of 13 nodes
1462 //=======================================================================
1463 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
1464 const SMDS_MeshNode * n2,
1465 const SMDS_MeshNode * n3,
1466 const SMDS_MeshNode * n4,
1467 const SMDS_MeshNode * n5,
1468 const SMDS_MeshNode * n12,
1469 const SMDS_MeshNode * n23,
1470 const SMDS_MeshNode * n34,
1471 const SMDS_MeshNode * n41,
1472 const SMDS_MeshNode * n15,
1473 const SMDS_MeshNode * n25,
1474 const SMDS_MeshNode * n35,
1475 const SMDS_MeshNode * n45,
1478 return AddVolumeWithID(n1->GetID(), n2->GetID(), n3->GetID(),
1479 n4->GetID(), n5->GetID(),
1480 n12->GetID(), n23->GetID(), n34->GetID(), n41->GetID(),
1481 n15->GetID(), n25->GetID(), n35->GetID(), n45->GetID(),
1486 //=======================================================================
1487 //function : AddVolume
1489 //=======================================================================
1490 SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
1491 const SMDS_MeshNode * n2,
1492 const SMDS_MeshNode * n3,
1493 const SMDS_MeshNode * n4,
1494 const SMDS_MeshNode * n5,
1495 const SMDS_MeshNode * n6,
1496 const SMDS_MeshNode * n12,
1497 const SMDS_MeshNode * n23,
1498 const SMDS_MeshNode * n31,
1499 const SMDS_MeshNode * n45,
1500 const SMDS_MeshNode * n56,
1501 const SMDS_MeshNode * n64,
1502 const SMDS_MeshNode * n14,
1503 const SMDS_MeshNode * n25,
1504 const SMDS_MeshNode * n36)
1506 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1,n2,n3,n4,n5,n6,n12,n23,n31,
1507 n45,n56,n64,n14,n25,n36);
1509 myScript->AddVolume(anElem->GetID(), n1->GetID(), n2->GetID(),
1510 n3->GetID(), n4->GetID(), n5->GetID(), n6->GetID(),
1511 n12->GetID(), n23->GetID(), n31->GetID(),
1512 n45->GetID(), n56->GetID(), n64->GetID(),
1513 n14->GetID(), n25->GetID(), n36->GetID());
1517 //=======================================================================
1518 //function : AddVolumeWithID
1520 //=======================================================================
1521 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3,
1522 int n4, int n5, int n6,
1523 int n12,int n23,int n31,
1524 int n45,int n56,int n64,
1525 int n14,int n25,int n36, int ID)
1527 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolumeWithID(n1,n2,n3,n4,n5,n6,
1531 if(anElem) myScript->AddVolume(ID,n1,n2,n3,n4,n5,n6,n12,n23,n31,
1532 n45,n56,n64,n14,n25,n36);
1536 //=======================================================================
1537 //function : AddVolumeWithID
1538 //purpose : 2d order Pentahedron with 15 nodes
1539 //=======================================================================
1540 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
1541 const SMDS_MeshNode * n2,
1542 const SMDS_MeshNode * n3,
1543 const SMDS_MeshNode * n4,
1544 const SMDS_MeshNode * n5,
1545 const SMDS_MeshNode * n6,
1546 const SMDS_MeshNode * n12,
1547 const SMDS_MeshNode * n23,
1548 const SMDS_MeshNode * n31,
1549 const SMDS_MeshNode * n45,
1550 const SMDS_MeshNode * n56,
1551 const SMDS_MeshNode * n64,
1552 const SMDS_MeshNode * n14,
1553 const SMDS_MeshNode * n25,
1554 const SMDS_MeshNode * n36,
1557 return AddVolumeWithID(n1->GetID(), n2->GetID(), n3->GetID(),
1558 n4->GetID(), n5->GetID(), n6->GetID(),
1559 n12->GetID(), n23->GetID(), n31->GetID(),
1560 n45->GetID(), n56->GetID(), n64->GetID(),
1561 n14->GetID(), n25->GetID(), n36->GetID(),
1566 //=======================================================================
1567 //function : AddVolume
1569 //=======================================================================
1570 SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
1571 const SMDS_MeshNode * n2,
1572 const SMDS_MeshNode * n3,
1573 const SMDS_MeshNode * n4,
1574 const SMDS_MeshNode * n5,
1575 const SMDS_MeshNode * n6,
1576 const SMDS_MeshNode * n7,
1577 const SMDS_MeshNode * n8,
1578 const SMDS_MeshNode * n12,
1579 const SMDS_MeshNode * n23,
1580 const SMDS_MeshNode * n34,
1581 const SMDS_MeshNode * n41,
1582 const SMDS_MeshNode * n56,
1583 const SMDS_MeshNode * n67,
1584 const SMDS_MeshNode * n78,
1585 const SMDS_MeshNode * n85,
1586 const SMDS_MeshNode * n15,
1587 const SMDS_MeshNode * n26,
1588 const SMDS_MeshNode * n37,
1589 const SMDS_MeshNode * n48)
1591 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1,n2,n3,n4,n5,n6,n7,n8,
1596 myScript->AddVolume(anElem->GetID(), n1->GetID(), n2->GetID(),
1597 n3->GetID(), n4->GetID(), n5->GetID(),
1598 n6->GetID(), n7->GetID(), n8->GetID(),
1599 n12->GetID(), n23->GetID(), n34->GetID(), n41->GetID(),
1600 n56->GetID(), n67->GetID(), n78->GetID(), n85->GetID(),
1601 n15->GetID(), n26->GetID(), n37->GetID(), n48->GetID());
1605 //=======================================================================
1606 //function : AddVolumeWithID
1608 //=======================================================================
1609 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3, int n4,
1610 int n5, int n6, int n7, int n8,
1611 int n12,int n23,int n34,int n41,
1612 int n56,int n67,int n78,int n85,
1613 int n15,int n26,int n37,int n48, int ID)
1615 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolumeWithID(n1,n2,n3,n4,n5,n6,n7,n8,
1618 n15,n26,n37,n48,ID);
1619 if(anElem) myScript->AddVolume(ID,n1,n2,n3,n4,n5,n6,n7,n8,n12,n23,n34,n41,
1620 n56,n67,n78,n85,n15,n26,n37,n48);
1624 //=======================================================================
1625 //function : AddVolumeWithID
1626 //purpose : 2d order Hexahedrons with 20 nodes
1627 //=======================================================================
1628 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
1629 const SMDS_MeshNode * n2,
1630 const SMDS_MeshNode * n3,
1631 const SMDS_MeshNode * n4,
1632 const SMDS_MeshNode * n5,
1633 const SMDS_MeshNode * n6,
1634 const SMDS_MeshNode * n7,
1635 const SMDS_MeshNode * n8,
1636 const SMDS_MeshNode * n12,
1637 const SMDS_MeshNode * n23,
1638 const SMDS_MeshNode * n34,
1639 const SMDS_MeshNode * n41,
1640 const SMDS_MeshNode * n56,
1641 const SMDS_MeshNode * n67,
1642 const SMDS_MeshNode * n78,
1643 const SMDS_MeshNode * n85,
1644 const SMDS_MeshNode * n15,
1645 const SMDS_MeshNode * n26,
1646 const SMDS_MeshNode * n37,
1647 const SMDS_MeshNode * n48,
1650 return AddVolumeWithID(n1->GetID(), n2->GetID(), n3->GetID(), n4->GetID(),
1651 n5->GetID(), n6->GetID(), n7->GetID(), n8->GetID(),
1652 n12->GetID(), n23->GetID(), n34->GetID(), n41->GetID(),
1653 n56->GetID(), n67->GetID(), n78->GetID(), n85->GetID(),
1654 n15->GetID(), n26->GetID(), n37->GetID(), n48->GetID(),