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 list<const SMESHDS_Hypothesis *>& alist=
116 myShapeToHypothesis[SS.Oriented(TopAbs_FORWARD)]; // ignore orientation of SS
118 //Check if the Hypothesis is still present
119 list<const SMESHDS_Hypothesis*>::iterator ith=find(alist.begin(),alist.end(), H );
121 if (alist.end() != ith) return false;
127 //=======================================================================
128 //function : RemoveHypothesis
130 //=======================================================================
132 bool SMESHDS_Mesh::RemoveHypothesis(const TopoDS_Shape & S,
133 const SMESHDS_Hypothesis * H)
135 ShapeToHypothesis::iterator its=
136 myShapeToHypothesis.find(S.Oriented(TopAbs_FORWARD)); // ignore orientation of S
138 if(its!=myShapeToHypothesis.end())
140 list<const SMESHDS_Hypothesis *>& alist=(*its).second;
141 list<const SMESHDS_Hypothesis*>::iterator ith=find(alist.begin(),alist.end(), H );
142 if (ith != alist.end())
151 //=======================================================================
154 //=======================================================================
155 SMDS_MeshNode* SMESHDS_Mesh::AddNode(double x, double y, double z){
156 SMDS_MeshNode* node = SMDS_Mesh::AddNode(x, y, z);
157 if(node!=NULL) myScript->AddNode(node->GetID(), x, y, z);
161 SMDS_MeshNode* SMESHDS_Mesh::AddNodeWithID(double x, double y, double z, int ID){
162 SMDS_MeshNode* node = SMDS_Mesh::AddNodeWithID(x,y,z,ID);
163 if(node!=NULL) myScript->AddNode(node->GetID(), x, y, z);
167 //=======================================================================
168 //function : MoveNode
170 //=======================================================================
171 void SMESHDS_Mesh::MoveNode(const SMDS_MeshNode *n, double x, double y, double z)
173 SMDS_MeshNode * node=const_cast<SMDS_MeshNode*>(n);
175 myScript->MoveNode(n->GetID(), x, y, z);
178 //=======================================================================
179 //function : ChangeElementNodes
181 //=======================================================================
183 bool SMESHDS_Mesh::ChangeElementNodes(const SMDS_MeshElement * elem,
184 const SMDS_MeshNode * nodes[],
187 if ( ! SMDS_Mesh::ChangeElementNodes( elem, nodes, nbnodes ))
190 vector<int> IDs( nbnodes );
191 for ( int i = 0; i < nbnodes; i++ )
192 IDs [ i ] = nodes[ i ]->GetID();
193 myScript->ChangeElementNodes( elem->GetID(), &IDs[0], nbnodes);
198 //=======================================================================
199 //function : ChangePolygonNodes
201 //=======================================================================
202 bool SMESHDS_Mesh::ChangePolygonNodes
203 (const SMDS_MeshElement * elem,
204 vector<const SMDS_MeshNode*> nodes)
206 ASSERT(nodes.size() > 3);
208 return ChangeElementNodes(elem, &nodes[0], nodes.size());
211 //=======================================================================
212 //function : ChangePolyhedronNodes
214 //=======================================================================
215 bool SMESHDS_Mesh::ChangePolyhedronNodes
216 (const SMDS_MeshElement * elem,
217 std::vector<const SMDS_MeshNode*> nodes,
218 std::vector<int> quantities)
220 ASSERT(nodes.size() > 3);
222 if (!SMDS_Mesh::ChangePolyhedronNodes(elem, nodes, quantities))
225 int i, len = nodes.size();
226 std::vector<int> nodes_ids (len);
227 for (i = 0; i < len; i++) {
228 nodes_ids[i] = nodes[i]->GetID();
230 myScript->ChangePolyhedronNodes(elem->GetID(), nodes_ids, quantities);
235 //=======================================================================
236 //function : Renumber
238 //=======================================================================
240 void SMESHDS_Mesh::Renumber (const bool isNodes, const int startID, const int deltaID)
242 SMDS_Mesh::Renumber( isNodes, startID, deltaID );
243 myScript->Renumber( isNodes, startID, deltaID );
246 //=======================================================================
247 //function :AddEdgeWithID
249 //=======================================================================
250 SMDS_MeshEdge* SMESHDS_Mesh::AddEdgeWithID(int n1, int n2, int ID)
252 SMDS_MeshEdge* anElem = SMDS_Mesh::AddEdgeWithID(n1,n2,ID);
253 if(anElem) myScript->AddEdge(ID,n1,n2);
257 SMDS_MeshEdge* SMESHDS_Mesh::AddEdgeWithID(const SMDS_MeshNode * n1,
258 const SMDS_MeshNode * n2,
261 return AddEdgeWithID(n1->GetID(),
266 SMDS_MeshEdge* SMESHDS_Mesh::AddEdge(const SMDS_MeshNode * n1,
267 const SMDS_MeshNode * n2)
269 SMDS_MeshEdge* anElem = SMDS_Mesh::AddEdge(n1,n2);
270 if(anElem) myScript->AddEdge(anElem->GetID(),
276 //=======================================================================
279 //=======================================================================
280 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(int n1, int n2, int n3, int ID)
282 SMDS_MeshFace *anElem = SMDS_Mesh::AddFaceWithID(n1, n2, n3, ID);
283 if(anElem) myScript->AddFace(ID,n1,n2,n3);
287 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(const SMDS_MeshNode * n1,
288 const SMDS_MeshNode * n2,
289 const SMDS_MeshNode * n3,
292 return AddFaceWithID(n1->GetID(),
298 SMDS_MeshFace* SMESHDS_Mesh::AddFace( const SMDS_MeshNode * n1,
299 const SMDS_MeshNode * n2,
300 const SMDS_MeshNode * n3)
302 SMDS_MeshFace *anElem = SMDS_Mesh::AddFace(n1, n2, n3);
303 if(anElem) myScript->AddFace(anElem->GetID(),
310 //=======================================================================
313 //=======================================================================
314 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(int n1, int n2, int n3, int n4, int ID)
316 SMDS_MeshFace *anElem = SMDS_Mesh::AddFaceWithID(n1, n2, n3, n4, ID);
317 if(anElem) myScript->AddFace(ID, n1, n2, n3, n4);
321 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(const SMDS_MeshNode * n1,
322 const SMDS_MeshNode * n2,
323 const SMDS_MeshNode * n3,
324 const SMDS_MeshNode * n4,
327 return AddFaceWithID(n1->GetID(),
334 SMDS_MeshFace* SMESHDS_Mesh::AddFace(const SMDS_MeshNode * n1,
335 const SMDS_MeshNode * n2,
336 const SMDS_MeshNode * n3,
337 const SMDS_MeshNode * n4)
339 SMDS_MeshFace *anElem = SMDS_Mesh::AddFace(n1, n2, n3, n4);
340 if(anElem) myScript->AddFace(anElem->GetID(),
348 //=======================================================================
349 //function :AddVolume
351 //=======================================================================
352 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3, int n4, int ID)
354 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolumeWithID(n1, n2, n3, n4, ID);
355 if(anElem) myScript->AddVolume(ID, n1, n2, n3, n4);
359 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
360 const SMDS_MeshNode * n2,
361 const SMDS_MeshNode * n3,
362 const SMDS_MeshNode * n4,
365 return AddVolumeWithID(n1->GetID(),
372 SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
373 const SMDS_MeshNode * n2,
374 const SMDS_MeshNode * n3,
375 const SMDS_MeshNode * n4)
377 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1, n2, n3, n4);
378 if(anElem) myScript->AddVolume(anElem->GetID(),
386 //=======================================================================
387 //function :AddVolume
389 //=======================================================================
390 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3, int n4, int n5, int ID)
392 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolumeWithID(n1, n2, n3, n4, n5, ID);
393 if(anElem) myScript->AddVolume(ID, n1, n2, n3, n4, n5);
397 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
398 const SMDS_MeshNode * n2,
399 const SMDS_MeshNode * n3,
400 const SMDS_MeshNode * n4,
401 const SMDS_MeshNode * n5,
404 return AddVolumeWithID(n1->GetID(),
412 SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
413 const SMDS_MeshNode * n2,
414 const SMDS_MeshNode * n3,
415 const SMDS_MeshNode * n4,
416 const SMDS_MeshNode * n5)
418 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1, n2, n3, n4, n5);
419 if(anElem) myScript->AddVolume(anElem->GetID(),
428 //=======================================================================
429 //function :AddVolume
431 //=======================================================================
432 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3, int n4, int n5, int n6, int ID)
434 SMDS_MeshVolume *anElem= SMDS_Mesh::AddVolumeWithID(n1, n2, n3, n4, n5, n6, ID);
435 if(anElem) myScript->AddVolume(ID, n1, n2, n3, n4, n5, n6);
439 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
440 const SMDS_MeshNode * n2,
441 const SMDS_MeshNode * n3,
442 const SMDS_MeshNode * n4,
443 const SMDS_MeshNode * n5,
444 const SMDS_MeshNode * n6,
447 return AddVolumeWithID(n1->GetID(),
456 SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
457 const SMDS_MeshNode * n2,
458 const SMDS_MeshNode * n3,
459 const SMDS_MeshNode * n4,
460 const SMDS_MeshNode * n5,
461 const SMDS_MeshNode * n6)
463 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1, n2, n3, n4, n5, n6);
464 if(anElem) myScript->AddVolume(anElem->GetID(),
474 //=======================================================================
475 //function :AddVolume
477 //=======================================================================
478 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3, int n4, int n5, int n6, int n7, int n8, int ID)
480 SMDS_MeshVolume *anElem= SMDS_Mesh::AddVolumeWithID(n1, n2, n3, n4, n5, n6, n7, n8, ID);
481 if(anElem) myScript->AddVolume(ID, n1, n2, n3, n4, n5, n6, n7, n8);
485 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
486 const SMDS_MeshNode * n2,
487 const SMDS_MeshNode * n3,
488 const SMDS_MeshNode * n4,
489 const SMDS_MeshNode * n5,
490 const SMDS_MeshNode * n6,
491 const SMDS_MeshNode * n7,
492 const SMDS_MeshNode * n8,
495 return AddVolumeWithID(n1->GetID(),
506 SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
507 const SMDS_MeshNode * n2,
508 const SMDS_MeshNode * n3,
509 const SMDS_MeshNode * n4,
510 const SMDS_MeshNode * n5,
511 const SMDS_MeshNode * n6,
512 const SMDS_MeshNode * n7,
513 const SMDS_MeshNode * n8)
515 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1, n2, n3, n4, n5, n6, n7, n8);
516 if(anElem) myScript->AddVolume(anElem->GetID(),
528 //=======================================================================
529 //function : AddPolygonalFace
531 //=======================================================================
532 SMDS_MeshFace* SMESHDS_Mesh::AddPolygonalFaceWithID (std::vector<int> nodes_ids,
535 SMDS_MeshFace *anElem = SMDS_Mesh::AddPolygonalFaceWithID(nodes_ids, ID);
537 myScript->AddPolygonalFace(ID, nodes_ids);
542 SMDS_MeshFace* SMESHDS_Mesh::AddPolygonalFaceWithID
543 (std::vector<const SMDS_MeshNode*> nodes,
546 SMDS_MeshFace *anElem = SMDS_Mesh::AddPolygonalFaceWithID(nodes, ID);
548 int i, len = nodes.size();
549 std::vector<int> nodes_ids (len);
550 for (i = 0; i < len; i++) {
551 nodes_ids[i] = nodes[i]->GetID();
553 myScript->AddPolygonalFace(ID, nodes_ids);
558 SMDS_MeshFace* SMESHDS_Mesh::AddPolygonalFace
559 (std::vector<const SMDS_MeshNode*> nodes)
561 SMDS_MeshFace *anElem = SMDS_Mesh::AddPolygonalFace(nodes);
563 int i, len = nodes.size();
564 std::vector<int> nodes_ids (len);
565 for (i = 0; i < len; i++) {
566 nodes_ids[i] = nodes[i]->GetID();
568 myScript->AddPolygonalFace(anElem->GetID(), nodes_ids);
573 //=======================================================================
574 //function : AddPolyhedralVolume
576 //=======================================================================
577 SMDS_MeshVolume* SMESHDS_Mesh::AddPolyhedralVolumeWithID (std::vector<int> nodes_ids,
578 std::vector<int> quantities,
581 SMDS_MeshVolume *anElem = SMDS_Mesh::AddPolyhedralVolumeWithID(nodes_ids, quantities, ID);
583 myScript->AddPolyhedralVolume(ID, nodes_ids, quantities);
588 SMDS_MeshVolume* SMESHDS_Mesh::AddPolyhedralVolumeWithID
589 (std::vector<const SMDS_MeshNode*> nodes,
590 std::vector<int> quantities,
593 SMDS_MeshVolume *anElem = SMDS_Mesh::AddPolyhedralVolumeWithID(nodes, quantities, ID);
595 int i, len = nodes.size();
596 std::vector<int> nodes_ids (len);
597 for (i = 0; i < len; i++) {
598 nodes_ids[i] = nodes[i]->GetID();
600 myScript->AddPolyhedralVolume(ID, nodes_ids, quantities);
605 SMDS_MeshVolume* SMESHDS_Mesh::AddPolyhedralVolume
606 (std::vector<const SMDS_MeshNode*> nodes,
607 std::vector<int> quantities)
609 SMDS_MeshVolume *anElem = SMDS_Mesh::AddPolyhedralVolume(nodes, quantities);
611 int i, len = nodes.size();
612 std::vector<int> nodes_ids (len);
613 for (i = 0; i < len; i++) {
614 nodes_ids[i] = nodes[i]->GetID();
616 myScript->AddPolyhedralVolume(anElem->GetID(), nodes_ids, quantities);
621 //=======================================================================
622 //function : removeFromContainers
624 //=======================================================================
626 static void removeFromContainers (map<int,SMESHDS_SubMesh*>& theSubMeshes,
627 set<SMESHDS_GroupBase*>& theGroups,
628 list<const SMDS_MeshElement*>& theElems,
631 if ( theElems.empty() )
635 // Element can belong to several groups
636 if ( !theGroups.empty() )
638 set<SMESHDS_GroupBase*>::iterator GrIt = theGroups.begin();
639 for ( ; GrIt != theGroups.end(); GrIt++ )
641 SMESHDS_Group* group = dynamic_cast<SMESHDS_Group*>( *GrIt );
642 if ( !group || group->IsEmpty() ) continue;
644 list<const SMDS_MeshElement *>::iterator elIt = theElems.begin();
645 for ( ; elIt != theElems.end(); elIt++ )
647 group->SMDSGroup().Remove( *elIt );
648 if ( group->IsEmpty() ) break;
653 // Rm from sub-meshes
654 // Element should belong to only one sub-mesh
655 map<int,SMESHDS_SubMesh*>::iterator SubIt = theSubMeshes.begin();
656 for ( ; SubIt != theSubMeshes.end(); SubIt++ )
658 int size = isNode ? (*SubIt).second->NbNodes() : (*SubIt).second->NbElements();
659 if ( size == 0 ) continue;
661 list<const SMDS_MeshElement *>::iterator elIt = theElems.begin();
662 while ( elIt != theElems.end() )
664 bool removed = false;
666 removed = (*SubIt).second->RemoveNode( static_cast<const SMDS_MeshNode*> (*elIt) );
668 removed = (*SubIt).second->RemoveElement( *elIt );
672 elIt = theElems.erase( elIt );
673 if ( theElems.empty() )
674 return; // all elements are found and removed
684 //=======================================================================
685 //function : RemoveNode
687 //=======================================================================
688 void SMESHDS_Mesh::RemoveNode(const SMDS_MeshNode * n)
690 myScript->RemoveNode(n->GetID());
692 list<const SMDS_MeshElement *> removedElems;
693 list<const SMDS_MeshElement *> removedNodes;
695 SMDS_Mesh::RemoveElement( n, removedElems, removedNodes, true );
697 removeFromContainers( myShapeIndexToSubMesh, myGroups, removedElems, false );
698 removeFromContainers( myShapeIndexToSubMesh, myGroups, removedNodes, true );
701 //=======================================================================
702 //function : RemoveFreeNode
704 //=======================================================================
705 void SMESHDS_Mesh::RemoveFreeNode(const SMDS_MeshNode * n, SMESHDS_SubMesh * subMesh)
707 myScript->RemoveNode(n->GetID());
710 // Node can belong to several groups
711 if (!myGroups.empty()) {
712 set<SMESHDS_GroupBase*>::iterator GrIt = myGroups.begin();
713 for (; GrIt != myGroups.end(); GrIt++) {
714 SMESHDS_Group* group = dynamic_cast<SMESHDS_Group*>(*GrIt);
715 if (!group || group->IsEmpty()) continue;
716 group->SMDSGroup().Remove(n);
721 // Node should belong to only one sub-mesh
723 subMesh->RemoveNode(n);
725 SMDS_Mesh::RemoveFreeElement(n);
728 //=======================================================================
729 //function : RemoveElement
731 //========================================================================
732 void SMESHDS_Mesh::RemoveElement(const SMDS_MeshElement * elt)
734 if (elt->GetType() == SMDSAbs_Node)
736 RemoveNode( static_cast<const SMDS_MeshNode*>( elt ));
740 myScript->RemoveElement(elt->GetID());
742 list<const SMDS_MeshElement *> removedElems;
743 list<const SMDS_MeshElement *> removedNodes;
745 SMDS_Mesh::RemoveElement(elt, removedElems, removedNodes, false);
747 removeFromContainers( myShapeIndexToSubMesh, myGroups, removedElems, false );
750 //=======================================================================
751 //function : RemoveFreeElement
753 //========================================================================
754 void SMESHDS_Mesh::RemoveFreeElement(const SMDS_MeshElement * elt, SMESHDS_SubMesh * subMesh)
756 if (elt->GetType() == SMDSAbs_Node) {
757 RemoveFreeNode( static_cast<const SMDS_MeshNode*>(elt), subMesh);
761 if (hasConstructionEdges() || hasConstructionFaces())
762 // this methods is only for meshes without descendants
765 myScript->RemoveElement(elt->GetID());
768 // Node can belong to several groups
769 if (!myGroups.empty()) {
770 set<SMESHDS_GroupBase*>::iterator GrIt = myGroups.begin();
771 for (; GrIt != myGroups.end(); GrIt++) {
772 SMESHDS_Group* group = dynamic_cast<SMESHDS_Group*>(*GrIt);
773 if (!group || group->IsEmpty()) continue;
774 group->SMDSGroup().Remove(elt);
779 // Element should belong to only one sub-mesh
781 subMesh->RemoveElement(elt);
783 SMDS_Mesh::RemoveFreeElement(elt);
786 //================================================================================
788 * \brief return submesh by shape
789 * \param shape - the subshape
790 * \retval SMESHDS_SubMesh* - the found submesh
792 * search of submeshes is optimized
794 //================================================================================
796 SMESHDS_SubMesh* SMESHDS_Mesh::getSubmesh( const TopoDS_Shape & shape )
798 if ( shape.IsNull() )
801 if ( !myCurSubShape.IsNull() && shape.IsSame( myCurSubShape ))
804 getSubmesh( ShapeToIndex( shape ));
805 myCurSubShape = shape;
809 //================================================================================
811 * \brief return submesh by subshape index
812 * \param Index - the subshape index
813 * \retval SMESHDS_SubMesh* - the found submesh
814 * search of submeshes is optimized
816 //================================================================================
818 SMESHDS_SubMesh* SMESHDS_Mesh::getSubmesh( const int Index )
820 //Update or build submesh
821 if ( Index != myCurSubID ) {
822 map<int,SMESHDS_SubMesh*>::iterator it = myShapeIndexToSubMesh.find( Index );
823 if ( it == myShapeIndexToSubMesh.end() )
824 it = myShapeIndexToSubMesh.insert( make_pair(Index, new SMESHDS_SubMesh() )).first;
825 myCurSubMesh = it->second;
827 myCurSubShape.Nullify(); // myCurSubShape no more corresponds to submesh
832 //================================================================================
834 * \brief Add element or node to submesh
835 * \param elem - element to add
836 * \param subMesh - submesh to be filled in
838 //================================================================================
840 bool SMESHDS_Mesh::add(const SMDS_MeshElement* elem, SMESHDS_SubMesh* subMesh )
842 if ( elem && subMesh ) {
843 if ( elem->GetType() == SMDSAbs_Node )
844 subMesh->AddNode( static_cast<const SMDS_MeshNode* >( elem ));
846 subMesh->AddElement( elem );
852 //=======================================================================
853 //function : SetNodeOnVolume
855 //=======================================================================
856 void SMESHDS_Mesh::SetNodeInVolume(SMDS_MeshNode * aNode,
857 const TopoDS_Shell & S)
859 if ( add( aNode, getSubmesh(S) ))
860 const_cast<SMDS_Position*>( aNode->GetPosition().get() )->SetShapeId( myCurSubID );
862 //=======================================================================
863 //function : SetNodeOnVolume
865 //=======================================================================
866 void SMESHDS_Mesh::SetNodeInVolume(SMDS_MeshNode * aNode,
867 const TopoDS_Solid & S)
869 if ( add( aNode, getSubmesh(S) ))
870 const_cast<SMDS_Position*>( aNode->GetPosition().get() )->SetShapeId( myCurSubID );
873 //=======================================================================
874 //function : SetNodeOnFace
876 //=======================================================================
877 void SMESHDS_Mesh::SetNodeOnFace(SMDS_MeshNode * aNode,
878 const TopoDS_Face & S,
882 if ( add( aNode, getSubmesh(S) ))
883 aNode->SetPosition(SMDS_PositionPtr(new SMDS_FacePosition(myCurSubID, u, v)));
886 //=======================================================================
887 //function : SetNodeOnEdge
889 //=======================================================================
890 void SMESHDS_Mesh::SetNodeOnEdge(SMDS_MeshNode * aNode,
891 const TopoDS_Edge & S,
894 if ( add( aNode, getSubmesh(S) ))
895 aNode->SetPosition(SMDS_PositionPtr(new SMDS_EdgePosition(myCurSubID, u)));
898 //=======================================================================
899 //function : SetNodeOnVertex
901 //=======================================================================
902 void SMESHDS_Mesh::SetNodeOnVertex(SMDS_MeshNode * aNode,
903 const TopoDS_Vertex & S)
905 if ( add( aNode, getSubmesh(S) ))
906 aNode->SetPosition(SMDS_PositionPtr(new SMDS_VertexPosition(myCurSubID)));
909 //=======================================================================
910 //function : UnSetNodeOnShape
912 //=======================================================================
913 void SMESHDS_Mesh::UnSetNodeOnShape(const SMDS_MeshNode* aNode)
915 if ( aNode && aNode->GetPosition() ) {
916 map<int,SMESHDS_SubMesh*>::iterator it =
917 myShapeIndexToSubMesh.find( aNode->GetPosition()->GetShapeId() );
918 if ( it != myShapeIndexToSubMesh.end() )
919 it->second->RemoveNode( aNode );
923 //=======================================================================
924 //function : SetMeshElementOnShape
926 //=======================================================================
927 void SMESHDS_Mesh::SetMeshElementOnShape(const SMDS_MeshElement * anElement,
928 const TopoDS_Shape & S)
930 add( anElement, getSubmesh(S) );
933 //=======================================================================
934 //function : UnSetMeshElementOnShape
936 //=======================================================================
937 void SMESHDS_Mesh::UnSetMeshElementOnShape(const SMDS_MeshElement * elem,
938 const TopoDS_Shape & S)
940 int Index = myIndexToShape.FindIndex(S);
942 map<int,SMESHDS_SubMesh*>::iterator it = myShapeIndexToSubMesh.find( Index );
943 if ( it != myShapeIndexToSubMesh.end() )
944 if ( elem->GetType() == SMDSAbs_Node )
945 it->second->RemoveNode( static_cast<const SMDS_MeshNode* >( elem ));
947 it->second->RemoveElement( elem );
950 //=======================================================================
951 //function : ShapeToMesh
953 //=======================================================================
954 TopoDS_Shape SMESHDS_Mesh::ShapeToMesh() const
959 //=======================================================================
960 //function : IsGroupOfSubShapes
961 //purpose : return true if at least one subshape of theShape is a subshape
962 // of myShape or theShape == myShape
963 //=======================================================================
965 bool SMESHDS_Mesh::IsGroupOfSubShapes (const TopoDS_Shape& theShape) const
967 if ( myShape.IsSame( theShape ))
970 for ( TopoDS_Iterator it( theShape ); it.More(); it.Next() ) {
971 if (myIndexToShape.Contains( it.Value() ) ||
972 IsGroupOfSubShapes( it.Value() ))
979 ///////////////////////////////////////////////////////////////////////////////
980 /// Return the sub mesh linked to the a given TopoDS_Shape or NULL if the given
981 /// TopoDS_Shape is unknown
982 ///////////////////////////////////////////////////////////////////////////////
983 SMESHDS_SubMesh * SMESHDS_Mesh::MeshElements(const TopoDS_Shape & S) const
985 int Index = ShapeToIndex(S);
986 TShapeIndexToSubMesh::const_iterator anIter = myShapeIndexToSubMesh.find(Index);
987 if (anIter != myShapeIndexToSubMesh.end())
988 return anIter->second;
993 ///////////////////////////////////////////////////////////////////////////////
994 /// Return the sub mesh by Id of shape it is linked to
995 ///////////////////////////////////////////////////////////////////////////////
996 SMESHDS_SubMesh * SMESHDS_Mesh::MeshElements(const int Index)
998 TShapeIndexToSubMesh::const_iterator anIter = myShapeIndexToSubMesh.find(Index);
999 if (anIter != myShapeIndexToSubMesh.end())
1000 return anIter->second;
1005 //=======================================================================
1006 //function : SubMeshIndices
1008 //=======================================================================
1009 list<int> SMESHDS_Mesh::SubMeshIndices()
1011 list<int> anIndices;
1012 std::map<int,SMESHDS_SubMesh*>::iterator anIter = myShapeIndexToSubMesh.begin();
1013 for (; anIter != myShapeIndexToSubMesh.end(); anIter++) {
1014 anIndices.push_back((*anIter).first);
1019 //=======================================================================
1020 //function : GetHypothesis
1022 //=======================================================================
1024 const list<const SMESHDS_Hypothesis*>&
1025 SMESHDS_Mesh::GetHypothesis(const TopoDS_Shape & S) const
1027 ShapeToHypothesis::const_iterator its=
1028 myShapeToHypothesis.find(S.Oriented(TopAbs_FORWARD)); // ignore orientation of S
1029 if (its!=myShapeToHypothesis.end())
1032 static list<const SMESHDS_Hypothesis*> empty;
1036 //=======================================================================
1037 //function : GetScript
1039 //=======================================================================
1040 SMESHDS_Script* SMESHDS_Mesh::GetScript()
1045 //=======================================================================
1046 //function : ClearScript
1048 //=======================================================================
1049 void SMESHDS_Mesh::ClearScript()
1054 //=======================================================================
1055 //function : HasMeshElements
1057 //=======================================================================
1058 bool SMESHDS_Mesh::HasMeshElements(const TopoDS_Shape & S)
1060 if (myShape.IsNull()) MESSAGE("myShape is NULL");
1061 int Index = myIndexToShape.FindIndex(S);
1062 return myShapeIndexToSubMesh.find(Index)!=myShapeIndexToSubMesh.end();
1065 //=======================================================================
1066 //function : HasHypothesis
1068 //=======================================================================
1069 bool SMESHDS_Mesh::HasHypothesis(const TopoDS_Shape & S)
1071 return myShapeToHypothesis.find(S.Oriented(TopAbs_FORWARD))!=myShapeToHypothesis.end();
1074 //=======================================================================
1075 //function : NewSubMesh
1077 //=======================================================================
1078 SMESHDS_SubMesh * SMESHDS_Mesh::NewSubMesh(int Index)
1080 SMESHDS_SubMesh* SM = 0;
1081 TShapeIndexToSubMesh::iterator anIter = myShapeIndexToSubMesh.find(Index);
1082 if (anIter == myShapeIndexToSubMesh.end())
1084 SM = new SMESHDS_SubMesh();
1085 myShapeIndexToSubMesh[Index]=SM;
1088 SM = anIter->second;
1092 //=======================================================================
1093 //function : AddCompoundSubmesh
1095 //=======================================================================
1097 int SMESHDS_Mesh::AddCompoundSubmesh(const TopoDS_Shape& S,
1098 TopAbs_ShapeEnum type)
1101 if ( IsGroupOfSubShapes( S ) || (S.ShapeType() == TopAbs_VERTEX && myIndexToShape.Contains(S)) )
1103 aMainIndex = myIndexToShape.Add( S );
1104 bool all = ( type == TopAbs_SHAPE );
1105 if ( all ) // corresponding simple submesh may exist
1106 aMainIndex = -aMainIndex;
1107 //MESSAGE("AddCompoundSubmesh index = " << aMainIndex );
1108 SMESHDS_SubMesh * aNewSub = NewSubMesh( aMainIndex );
1109 if ( !aNewSub->IsComplexSubmesh() ) // is empty
1111 int shapeType = all ? myShape.ShapeType() : type;
1112 int typeLimit = all ? TopAbs_VERTEX : type;
1113 for ( ; shapeType <= typeLimit; shapeType++ )
1115 TopExp_Explorer exp( S, TopAbs_ShapeEnum( shapeType ));
1116 for ( ; exp.More(); exp.Next() )
1118 int index = myIndexToShape.FindIndex( exp.Current() );
1120 aNewSub->AddSubMesh( NewSubMesh( index ));
1128 //=======================================================================
1129 //function : IndexToShape
1131 //=======================================================================
1132 const TopoDS_Shape& SMESHDS_Mesh::IndexToShape(int ShapeIndex) const
1134 return myIndexToShape.FindKey(ShapeIndex);
1137 //=======================================================================
1138 //function : ShapeToIndex
1140 //=======================================================================
1141 int SMESHDS_Mesh::ShapeToIndex(const TopoDS_Shape & S) const
1143 if (myShape.IsNull())
1144 MESSAGE("myShape is NULL");
1146 int index = myIndexToShape.FindIndex(S);
1151 //=======================================================================
1152 //function : SetNodeOnVolume
1154 //=======================================================================
1155 void SMESHDS_Mesh::SetNodeInVolume(const SMDS_MeshNode* aNode, int Index)
1157 if ( add( aNode, getSubmesh( Index )))
1158 const_cast<SMDS_Position*>( aNode->GetPosition().get() )->SetShapeId( Index );
1161 //=======================================================================
1162 //function : SetNodeOnFace
1164 //=======================================================================
1165 void SMESHDS_Mesh::SetNodeOnFace(SMDS_MeshNode* aNode, int Index, double u, double v)
1167 //Set Position on Node
1168 if ( add( aNode, getSubmesh( Index )))
1169 aNode->SetPosition(SMDS_PositionPtr(new SMDS_FacePosition(Index, u, v)));
1172 //=======================================================================
1173 //function : SetNodeOnEdge
1175 //=======================================================================
1176 void SMESHDS_Mesh::SetNodeOnEdge(SMDS_MeshNode* aNode,
1180 //Set Position on Node
1181 if ( add( aNode, getSubmesh( Index )))
1182 aNode->SetPosition(SMDS_PositionPtr(new SMDS_EdgePosition(Index, u)));
1185 //=======================================================================
1186 //function : SetNodeOnVertex
1188 //=======================================================================
1189 void SMESHDS_Mesh::SetNodeOnVertex(SMDS_MeshNode* aNode, int Index)
1191 //Set Position on Node
1192 if ( add( aNode, getSubmesh( Index )))
1193 aNode->SetPosition(SMDS_PositionPtr(new SMDS_VertexPosition(Index)));
1196 //=======================================================================
1197 //function : SetMeshElementOnShape
1199 //=======================================================================
1200 void SMESHDS_Mesh::SetMeshElementOnShape(const SMDS_MeshElement* anElement,
1203 add( anElement, getSubmesh( Index ));
1206 SMESHDS_Mesh::~SMESHDS_Mesh()
1213 //********************************************************************
1214 //********************************************************************
1215 //******** *********
1216 //***** Methods for addition of quadratic elements ******
1217 //******** *********
1218 //********************************************************************
1219 //********************************************************************
1221 //=======================================================================
1222 //function : AddEdgeWithID
1224 //=======================================================================
1225 SMDS_MeshEdge* SMESHDS_Mesh::AddEdgeWithID(int n1, int n2, int n12, int ID)
1227 SMDS_MeshEdge* anElem = SMDS_Mesh::AddEdgeWithID(n1,n2,n12,ID);
1228 if(anElem) myScript->AddEdge(ID,n1,n2,n12);
1232 //=======================================================================
1233 //function : AddEdge
1235 //=======================================================================
1236 SMDS_MeshEdge* SMESHDS_Mesh::AddEdge(const SMDS_MeshNode* n1,
1237 const SMDS_MeshNode* n2,
1238 const SMDS_MeshNode* n12)
1240 SMDS_MeshEdge* anElem = SMDS_Mesh::AddEdge(n1,n2,n12);
1241 if(anElem) myScript->AddEdge(anElem->GetID(),
1248 //=======================================================================
1249 //function : AddEdgeWithID
1251 //=======================================================================
1252 SMDS_MeshEdge* SMESHDS_Mesh::AddEdgeWithID(const SMDS_MeshNode * n1,
1253 const SMDS_MeshNode * n2,
1254 const SMDS_MeshNode * n12,
1257 return AddEdgeWithID(n1->GetID(),
1264 //=======================================================================
1265 //function : AddFace
1267 //=======================================================================
1268 SMDS_MeshFace* SMESHDS_Mesh::AddFace(const SMDS_MeshNode * n1,
1269 const SMDS_MeshNode * n2,
1270 const SMDS_MeshNode * n3,
1271 const SMDS_MeshNode * n12,
1272 const SMDS_MeshNode * n23,
1273 const SMDS_MeshNode * n31)
1275 SMDS_MeshFace *anElem = SMDS_Mesh::AddFace(n1,n2,n3,n12,n23,n31);
1276 if(anElem) myScript->AddFace(anElem->GetID(),
1277 n1->GetID(), n2->GetID(), n3->GetID(),
1278 n12->GetID(), n23->GetID(), n31->GetID());
1282 //=======================================================================
1283 //function : AddFaceWithID
1285 //=======================================================================
1286 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(int n1, int n2, int n3,
1287 int n12,int n23,int n31, int ID)
1289 SMDS_MeshFace *anElem = SMDS_Mesh::AddFaceWithID(n1,n2,n3,n12,n23,n31,ID);
1290 if(anElem) myScript->AddFace(ID,n1,n2,n3,n12,n23,n31);
1294 //=======================================================================
1295 //function : AddFaceWithID
1297 //=======================================================================
1298 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(const SMDS_MeshNode * n1,
1299 const SMDS_MeshNode * n2,
1300 const SMDS_MeshNode * n3,
1301 const SMDS_MeshNode * n12,
1302 const SMDS_MeshNode * n23,
1303 const SMDS_MeshNode * n31,
1306 return AddFaceWithID(n1->GetID(), n2->GetID(), n3->GetID(),
1307 n12->GetID(), n23->GetID(), n31->GetID(),
1312 //=======================================================================
1313 //function : AddFace
1315 //=======================================================================
1316 SMDS_MeshFace* SMESHDS_Mesh::AddFace(const SMDS_MeshNode * n1,
1317 const SMDS_MeshNode * n2,
1318 const SMDS_MeshNode * n3,
1319 const SMDS_MeshNode * n4,
1320 const SMDS_MeshNode * n12,
1321 const SMDS_MeshNode * n23,
1322 const SMDS_MeshNode * n34,
1323 const SMDS_MeshNode * n41)
1325 SMDS_MeshFace *anElem = SMDS_Mesh::AddFace(n1,n2,n3,n4,n12,n23,n34,n41);
1326 if(anElem) myScript->AddFace(anElem->GetID(),
1327 n1->GetID(), n2->GetID(), n3->GetID(), n4->GetID(),
1328 n12->GetID(), n23->GetID(), n34->GetID(), n41->GetID());
1332 //=======================================================================
1333 //function : AddFaceWithID
1335 //=======================================================================
1336 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(int n1, int n2, int n3, int n4,
1337 int n12,int n23,int n34,int n41, int ID)
1339 SMDS_MeshFace *anElem = SMDS_Mesh::AddFaceWithID(n1,n2,n3,n4,n12,n23,n34,n41,ID);
1340 if(anElem) myScript->AddFace(ID,n1,n2,n3,n4,n12,n23,n34,n41);
1344 //=======================================================================
1345 //function : AddFaceWithID
1347 //=======================================================================
1348 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(const SMDS_MeshNode * n1,
1349 const SMDS_MeshNode * n2,
1350 const SMDS_MeshNode * n3,
1351 const SMDS_MeshNode * n4,
1352 const SMDS_MeshNode * n12,
1353 const SMDS_MeshNode * n23,
1354 const SMDS_MeshNode * n34,
1355 const SMDS_MeshNode * n41,
1358 return AddFaceWithID(n1->GetID(), n2->GetID(), n3->GetID(), n4->GetID(),
1359 n12->GetID(), n23->GetID(), n34->GetID(), n41->GetID(),
1364 //=======================================================================
1365 //function : AddVolume
1367 //=======================================================================
1368 SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
1369 const SMDS_MeshNode * n2,
1370 const SMDS_MeshNode * n3,
1371 const SMDS_MeshNode * n4,
1372 const SMDS_MeshNode * n12,
1373 const SMDS_MeshNode * n23,
1374 const SMDS_MeshNode * n31,
1375 const SMDS_MeshNode * n14,
1376 const SMDS_MeshNode * n24,
1377 const SMDS_MeshNode * n34)
1379 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1,n2,n3,n4,n12,n23,n31,n14,n24,n34);
1380 if(anElem) myScript->AddVolume(anElem->GetID(),
1381 n1->GetID(), n2->GetID(), n3->GetID(), n4->GetID(),
1382 n12->GetID(), n23->GetID(), n31->GetID(),
1383 n14->GetID(), n24->GetID(), n34->GetID());
1387 //=======================================================================
1388 //function : AddVolumeWithID
1390 //=======================================================================
1391 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3, int n4,
1392 int n12,int n23,int n31,
1393 int n14,int n24,int n34, int ID)
1395 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolumeWithID(n1,n2,n3,n4,n12,n23,
1396 n31,n14,n24,n34,ID);
1397 if(anElem) myScript->AddVolume(ID,n1,n2,n3,n4,n12,n23,n31,n14,n24,n34);
1401 //=======================================================================
1402 //function : AddVolumeWithID
1403 //purpose : 2d order tetrahedron of 10 nodes
1404 //=======================================================================
1405 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
1406 const SMDS_MeshNode * n2,
1407 const SMDS_MeshNode * n3,
1408 const SMDS_MeshNode * n4,
1409 const SMDS_MeshNode * n12,
1410 const SMDS_MeshNode * n23,
1411 const SMDS_MeshNode * n31,
1412 const SMDS_MeshNode * n14,
1413 const SMDS_MeshNode * n24,
1414 const SMDS_MeshNode * n34,
1417 return AddVolumeWithID(n1->GetID(), n2->GetID(), n3->GetID(), n4->GetID(),
1418 n12->GetID(), n23->GetID(), n31->GetID(),
1419 n14->GetID(), n24->GetID(), n34->GetID(), ID);
1423 //=======================================================================
1424 //function : AddVolume
1426 //=======================================================================
1427 SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
1428 const SMDS_MeshNode * n2,
1429 const SMDS_MeshNode * n3,
1430 const SMDS_MeshNode * n4,
1431 const SMDS_MeshNode * n5,
1432 const SMDS_MeshNode * n12,
1433 const SMDS_MeshNode * n23,
1434 const SMDS_MeshNode * n34,
1435 const SMDS_MeshNode * n41,
1436 const SMDS_MeshNode * n15,
1437 const SMDS_MeshNode * n25,
1438 const SMDS_MeshNode * n35,
1439 const SMDS_MeshNode * n45)
1441 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1,n2,n3,n4,n5,n12,n23,n34,n41,
1444 myScript->AddVolume(anElem->GetID(), n1->GetID(), n2->GetID(),
1445 n3->GetID(), n4->GetID(), n5->GetID(),
1446 n12->GetID(), n23->GetID(), n34->GetID(), n41->GetID(),
1447 n15->GetID(), n25->GetID(), n35->GetID(), n45->GetID());
1451 //=======================================================================
1452 //function : AddVolumeWithID
1454 //=======================================================================
1455 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3, int n4, int n5,
1456 int n12,int n23,int n34,int n41,
1457 int n15,int n25,int n35,int n45, int ID)
1459 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolumeWithID(n1,n2,n3,n4,n5,
1461 n15,n25,n35,n45,ID);
1462 if(anElem) myScript->AddVolume(ID,n1,n2,n3,n4,n5,n12,n23,n34,n41,
1467 //=======================================================================
1468 //function : AddVolumeWithID
1469 //purpose : 2d order pyramid of 13 nodes
1470 //=======================================================================
1471 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
1472 const SMDS_MeshNode * n2,
1473 const SMDS_MeshNode * n3,
1474 const SMDS_MeshNode * n4,
1475 const SMDS_MeshNode * n5,
1476 const SMDS_MeshNode * n12,
1477 const SMDS_MeshNode * n23,
1478 const SMDS_MeshNode * n34,
1479 const SMDS_MeshNode * n41,
1480 const SMDS_MeshNode * n15,
1481 const SMDS_MeshNode * n25,
1482 const SMDS_MeshNode * n35,
1483 const SMDS_MeshNode * n45,
1486 return AddVolumeWithID(n1->GetID(), n2->GetID(), n3->GetID(),
1487 n4->GetID(), n5->GetID(),
1488 n12->GetID(), n23->GetID(), n34->GetID(), n41->GetID(),
1489 n15->GetID(), n25->GetID(), n35->GetID(), n45->GetID(),
1494 //=======================================================================
1495 //function : AddVolume
1497 //=======================================================================
1498 SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
1499 const SMDS_MeshNode * n2,
1500 const SMDS_MeshNode * n3,
1501 const SMDS_MeshNode * n4,
1502 const SMDS_MeshNode * n5,
1503 const SMDS_MeshNode * n6,
1504 const SMDS_MeshNode * n12,
1505 const SMDS_MeshNode * n23,
1506 const SMDS_MeshNode * n31,
1507 const SMDS_MeshNode * n45,
1508 const SMDS_MeshNode * n56,
1509 const SMDS_MeshNode * n64,
1510 const SMDS_MeshNode * n14,
1511 const SMDS_MeshNode * n25,
1512 const SMDS_MeshNode * n36)
1514 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1,n2,n3,n4,n5,n6,n12,n23,n31,
1515 n45,n56,n64,n14,n25,n36);
1517 myScript->AddVolume(anElem->GetID(), n1->GetID(), n2->GetID(),
1518 n3->GetID(), n4->GetID(), n5->GetID(), n6->GetID(),
1519 n12->GetID(), n23->GetID(), n31->GetID(),
1520 n45->GetID(), n56->GetID(), n64->GetID(),
1521 n14->GetID(), n25->GetID(), n36->GetID());
1525 //=======================================================================
1526 //function : AddVolumeWithID
1528 //=======================================================================
1529 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3,
1530 int n4, int n5, int n6,
1531 int n12,int n23,int n31,
1532 int n45,int n56,int n64,
1533 int n14,int n25,int n36, int ID)
1535 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolumeWithID(n1,n2,n3,n4,n5,n6,
1539 if(anElem) myScript->AddVolume(ID,n1,n2,n3,n4,n5,n6,n12,n23,n31,
1540 n45,n56,n64,n14,n25,n36);
1544 //=======================================================================
1545 //function : AddVolumeWithID
1546 //purpose : 2d order Pentahedron with 15 nodes
1547 //=======================================================================
1548 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
1549 const SMDS_MeshNode * n2,
1550 const SMDS_MeshNode * n3,
1551 const SMDS_MeshNode * n4,
1552 const SMDS_MeshNode * n5,
1553 const SMDS_MeshNode * n6,
1554 const SMDS_MeshNode * n12,
1555 const SMDS_MeshNode * n23,
1556 const SMDS_MeshNode * n31,
1557 const SMDS_MeshNode * n45,
1558 const SMDS_MeshNode * n56,
1559 const SMDS_MeshNode * n64,
1560 const SMDS_MeshNode * n14,
1561 const SMDS_MeshNode * n25,
1562 const SMDS_MeshNode * n36,
1565 return AddVolumeWithID(n1->GetID(), n2->GetID(), n3->GetID(),
1566 n4->GetID(), n5->GetID(), n6->GetID(),
1567 n12->GetID(), n23->GetID(), n31->GetID(),
1568 n45->GetID(), n56->GetID(), n64->GetID(),
1569 n14->GetID(), n25->GetID(), n36->GetID(),
1574 //=======================================================================
1575 //function : AddVolume
1577 //=======================================================================
1578 SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
1579 const SMDS_MeshNode * n2,
1580 const SMDS_MeshNode * n3,
1581 const SMDS_MeshNode * n4,
1582 const SMDS_MeshNode * n5,
1583 const SMDS_MeshNode * n6,
1584 const SMDS_MeshNode * n7,
1585 const SMDS_MeshNode * n8,
1586 const SMDS_MeshNode * n12,
1587 const SMDS_MeshNode * n23,
1588 const SMDS_MeshNode * n34,
1589 const SMDS_MeshNode * n41,
1590 const SMDS_MeshNode * n56,
1591 const SMDS_MeshNode * n67,
1592 const SMDS_MeshNode * n78,
1593 const SMDS_MeshNode * n85,
1594 const SMDS_MeshNode * n15,
1595 const SMDS_MeshNode * n26,
1596 const SMDS_MeshNode * n37,
1597 const SMDS_MeshNode * n48)
1599 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1,n2,n3,n4,n5,n6,n7,n8,
1604 myScript->AddVolume(anElem->GetID(), n1->GetID(), n2->GetID(),
1605 n3->GetID(), n4->GetID(), n5->GetID(),
1606 n6->GetID(), n7->GetID(), n8->GetID(),
1607 n12->GetID(), n23->GetID(), n34->GetID(), n41->GetID(),
1608 n56->GetID(), n67->GetID(), n78->GetID(), n85->GetID(),
1609 n15->GetID(), n26->GetID(), n37->GetID(), n48->GetID());
1613 //=======================================================================
1614 //function : AddVolumeWithID
1616 //=======================================================================
1617 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3, int n4,
1618 int n5, int n6, int n7, int n8,
1619 int n12,int n23,int n34,int n41,
1620 int n56,int n67,int n78,int n85,
1621 int n15,int n26,int n37,int n48, int ID)
1623 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolumeWithID(n1,n2,n3,n4,n5,n6,n7,n8,
1626 n15,n26,n37,n48,ID);
1627 if(anElem) myScript->AddVolume(ID,n1,n2,n3,n4,n5,n6,n7,n8,n12,n23,n34,n41,
1628 n56,n67,n78,n85,n15,n26,n37,n48);
1632 //=======================================================================
1633 //function : AddVolumeWithID
1634 //purpose : 2d order Hexahedrons with 20 nodes
1635 //=======================================================================
1636 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
1637 const SMDS_MeshNode * n2,
1638 const SMDS_MeshNode * n3,
1639 const SMDS_MeshNode * n4,
1640 const SMDS_MeshNode * n5,
1641 const SMDS_MeshNode * n6,
1642 const SMDS_MeshNode * n7,
1643 const SMDS_MeshNode * n8,
1644 const SMDS_MeshNode * n12,
1645 const SMDS_MeshNode * n23,
1646 const SMDS_MeshNode * n34,
1647 const SMDS_MeshNode * n41,
1648 const SMDS_MeshNode * n56,
1649 const SMDS_MeshNode * n67,
1650 const SMDS_MeshNode * n78,
1651 const SMDS_MeshNode * n85,
1652 const SMDS_MeshNode * n15,
1653 const SMDS_MeshNode * n26,
1654 const SMDS_MeshNode * n37,
1655 const SMDS_MeshNode * n48,
1658 return AddVolumeWithID(n1->GetID(), n2->GetID(), n3->GetID(), n4->GetID(),
1659 n5->GetID(), n6->GetID(), n7->GetID(), n8->GetID(),
1660 n12->GetID(), n23->GetID(), n34->GetID(), n41->GetID(),
1661 n56->GetID(), n67->GetID(), n78->GetID(), n85->GetID(),
1662 n15->GetID(), n26->GetID(), n37->GetID(), n48->GetID(),