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):
49 myIsEmbeddedMode(theIsEmbeddedMode),
52 myScript = new SMESHDS_Script(theIsEmbeddedMode);
55 //=======================================================================
56 bool SMESHDS_Mesh::IsEmbeddedMode()
58 return myIsEmbeddedMode;
61 //=======================================================================
62 //function : ShapeToMesh
64 //=======================================================================
65 void SMESHDS_Mesh::ShapeToMesh(const TopoDS_Shape & S)
67 if ( !myShape.IsNull() && S.IsNull() )
69 // removal of a shape to mesh, delete ...
71 myShapeToHypothesis.clear();
72 // - shape indices in SMDS_Position of nodes
73 map<int,SMESHDS_SubMesh*>::iterator i_sub = myShapeIndexToSubMesh.begin();
74 for ( ; i_sub != myShapeIndexToSubMesh.end(); i_sub++ ) {
75 if ( !i_sub->second->IsComplexSubmesh() ) {
76 SMDS_NodeIteratorPtr nIt = i_sub->second->GetNodes();
78 nIt->next()->GetPosition()->SetShapeId( 0 );
82 myIndexToShape.Clear();
83 myShapeIndexToSubMesh.clear();
84 // - groups on geometry
85 set<SMESHDS_GroupBase*>::iterator gr = myGroups.begin();
86 while ( gr != myGroups.end() ) {
87 if ( dynamic_cast<SMESHDS_GroupOnGeom*>( *gr ))
88 myGroups.erase( gr++ );
96 TopExp::MapShapes(myShape, myIndexToShape);
100 //=======================================================================
101 //function : AddHypothesis
103 //=======================================================================
105 bool SMESHDS_Mesh::AddHypothesis(const TopoDS_Shape & SS,
106 const SMESHDS_Hypothesis * H)
108 list<const SMESHDS_Hypothesis *>& alist=myShapeToHypothesis[SS];
110 //Check if the Hypothesis is still present
111 list<const SMESHDS_Hypothesis*>::iterator ith=alist.begin();
113 for (; ith!=alist.end(); ith++)
114 if (H == *ith) return false;
120 //=======================================================================
121 //function : RemoveHypothesis
123 //=======================================================================
125 bool SMESHDS_Mesh::RemoveHypothesis(const TopoDS_Shape & S,
126 const SMESHDS_Hypothesis * H)
128 ShapeToHypothesis::iterator its=myShapeToHypothesis.find(S);
129 if(its!=myShapeToHypothesis.end())
131 list<const SMESHDS_Hypothesis*>::iterator ith=(*its).second.begin();
133 for (; ith!=(*its).second.end(); ith++)
136 (*its).second.erase(ith);
143 //=======================================================================
146 //=======================================================================
147 SMDS_MeshNode* SMESHDS_Mesh::AddNode(double x, double y, double z){
148 SMDS_MeshNode* node = SMDS_Mesh::AddNode(x, y, z);
149 if(node!=NULL) myScript->AddNode(node->GetID(), x, y, z);
153 SMDS_MeshNode* SMESHDS_Mesh::AddNodeWithID(double x, double y, double z, int ID){
154 SMDS_MeshNode* node = SMDS_Mesh::AddNodeWithID(x,y,z,ID);
155 if(node!=NULL) myScript->AddNode(node->GetID(), x, y, z);
159 //=======================================================================
160 //function : MoveNode
162 //=======================================================================
163 void SMESHDS_Mesh::MoveNode(const SMDS_MeshNode *n, double x, double y, double z)
165 SMDS_MeshNode * node=const_cast<SMDS_MeshNode*>(n);
167 myScript->MoveNode(n->GetID(), x, y, z);
170 //=======================================================================
171 //function : ChangeElementNodes
173 //=======================================================================
175 bool SMESHDS_Mesh::ChangeElementNodes(const SMDS_MeshElement * elem,
176 const SMDS_MeshNode * nodes[],
179 if ( ! SMDS_Mesh::ChangeElementNodes( elem, nodes, nbnodes ))
182 vector<int> IDs( nbnodes );
183 for ( int i = 0; i < nbnodes; i++ )
184 IDs [ i ] = nodes[ i ]->GetID();
185 myScript->ChangeElementNodes( elem->GetID(), &IDs[0], nbnodes);
190 //=======================================================================
191 //function : ChangePolygonNodes
193 //=======================================================================
194 bool SMESHDS_Mesh::ChangePolygonNodes
195 (const SMDS_MeshElement * elem,
196 vector<const SMDS_MeshNode*> nodes)
198 ASSERT(nodes.size() > 3);
200 return ChangeElementNodes(elem, &nodes[0], nodes.size());
203 //=======================================================================
204 //function : ChangePolyhedronNodes
206 //=======================================================================
207 bool SMESHDS_Mesh::ChangePolyhedronNodes
208 (const SMDS_MeshElement * elem,
209 std::vector<const SMDS_MeshNode*> nodes,
210 std::vector<int> quantities)
212 ASSERT(nodes.size() > 3);
214 if (!SMDS_Mesh::ChangePolyhedronNodes(elem, nodes, quantities))
217 int i, len = nodes.size();
218 std::vector<int> nodes_ids (len);
219 for (i = 0; i < len; i++) {
220 nodes_ids[i] = nodes[i]->GetID();
222 myScript->ChangePolyhedronNodes(elem->GetID(), nodes_ids, quantities);
227 //=======================================================================
228 //function : Renumber
230 //=======================================================================
232 void SMESHDS_Mesh::Renumber (const bool isNodes, const int startID, const int deltaID)
234 SMDS_Mesh::Renumber( isNodes, startID, deltaID );
235 myScript->Renumber( isNodes, startID, deltaID );
238 //=======================================================================
239 //function :AddEdgeWithID
241 //=======================================================================
242 SMDS_MeshEdge* SMESHDS_Mesh::AddEdgeWithID(int n1, int n2, int ID)
244 SMDS_MeshEdge* anElem = SMDS_Mesh::AddEdgeWithID(n1,n2,ID);
245 if(anElem) myScript->AddEdge(ID,n1,n2);
249 SMDS_MeshEdge* SMESHDS_Mesh::AddEdgeWithID(const SMDS_MeshNode * n1,
250 const SMDS_MeshNode * n2,
253 return AddEdgeWithID(n1->GetID(),
258 SMDS_MeshEdge* SMESHDS_Mesh::AddEdge(const SMDS_MeshNode * n1,
259 const SMDS_MeshNode * n2)
261 SMDS_MeshEdge* anElem = SMDS_Mesh::AddEdge(n1,n2);
262 if(anElem) myScript->AddEdge(anElem->GetID(),
268 //=======================================================================
271 //=======================================================================
272 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(int n1, int n2, int n3, int ID)
274 SMDS_MeshFace *anElem = SMDS_Mesh::AddFaceWithID(n1, n2, n3, ID);
275 if(anElem) myScript->AddFace(ID,n1,n2,n3);
279 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(const SMDS_MeshNode * n1,
280 const SMDS_MeshNode * n2,
281 const SMDS_MeshNode * n3,
284 return AddFaceWithID(n1->GetID(),
290 SMDS_MeshFace* SMESHDS_Mesh::AddFace( const SMDS_MeshNode * n1,
291 const SMDS_MeshNode * n2,
292 const SMDS_MeshNode * n3)
294 SMDS_MeshFace *anElem = SMDS_Mesh::AddFace(n1, n2, n3);
295 if(anElem) myScript->AddFace(anElem->GetID(),
302 //=======================================================================
305 //=======================================================================
306 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(int n1, int n2, int n3, int n4, int ID)
308 SMDS_MeshFace *anElem = SMDS_Mesh::AddFaceWithID(n1, n2, n3, n4, ID);
309 if(anElem) myScript->AddFace(ID, n1, n2, n3, n4);
313 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(const SMDS_MeshNode * n1,
314 const SMDS_MeshNode * n2,
315 const SMDS_MeshNode * n3,
316 const SMDS_MeshNode * n4,
319 return AddFaceWithID(n1->GetID(),
326 SMDS_MeshFace* SMESHDS_Mesh::AddFace(const SMDS_MeshNode * n1,
327 const SMDS_MeshNode * n2,
328 const SMDS_MeshNode * n3,
329 const SMDS_MeshNode * n4)
331 SMDS_MeshFace *anElem = SMDS_Mesh::AddFace(n1, n2, n3, n4);
332 if(anElem) myScript->AddFace(anElem->GetID(),
340 //=======================================================================
341 //function :AddVolume
343 //=======================================================================
344 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3, int n4, int ID)
346 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolumeWithID(n1, n2, n3, n4, ID);
347 if(anElem) myScript->AddVolume(ID, n1, n2, n3, n4);
351 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
352 const SMDS_MeshNode * n2,
353 const SMDS_MeshNode * n3,
354 const SMDS_MeshNode * n4,
357 return AddVolumeWithID(n1->GetID(),
364 SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
365 const SMDS_MeshNode * n2,
366 const SMDS_MeshNode * n3,
367 const SMDS_MeshNode * n4)
369 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1, n2, n3, n4);
370 if(anElem) myScript->AddVolume(anElem->GetID(),
378 //=======================================================================
379 //function :AddVolume
381 //=======================================================================
382 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3, int n4, int n5, int ID)
384 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolumeWithID(n1, n2, n3, n4, n5, ID);
385 if(anElem) myScript->AddVolume(ID, n1, n2, n3, n4, n5);
389 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
390 const SMDS_MeshNode * n2,
391 const SMDS_MeshNode * n3,
392 const SMDS_MeshNode * n4,
393 const SMDS_MeshNode * n5,
396 return AddVolumeWithID(n1->GetID(),
404 SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
405 const SMDS_MeshNode * n2,
406 const SMDS_MeshNode * n3,
407 const SMDS_MeshNode * n4,
408 const SMDS_MeshNode * n5)
410 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1, n2, n3, n4, n5);
411 if(anElem) myScript->AddVolume(anElem->GetID(),
420 //=======================================================================
421 //function :AddVolume
423 //=======================================================================
424 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3, int n4, int n5, int n6, int ID)
426 SMDS_MeshVolume *anElem= SMDS_Mesh::AddVolumeWithID(n1, n2, n3, n4, n5, n6, ID);
427 if(anElem) myScript->AddVolume(ID, n1, n2, n3, n4, n5, n6);
431 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
432 const SMDS_MeshNode * n2,
433 const SMDS_MeshNode * n3,
434 const SMDS_MeshNode * n4,
435 const SMDS_MeshNode * n5,
436 const SMDS_MeshNode * n6,
439 return AddVolumeWithID(n1->GetID(),
448 SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
449 const SMDS_MeshNode * n2,
450 const SMDS_MeshNode * n3,
451 const SMDS_MeshNode * n4,
452 const SMDS_MeshNode * n5,
453 const SMDS_MeshNode * n6)
455 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1, n2, n3, n4, n5, n6);
456 if(anElem) myScript->AddVolume(anElem->GetID(),
466 //=======================================================================
467 //function :AddVolume
469 //=======================================================================
470 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3, int n4, int n5, int n6, int n7, int n8, int ID)
472 SMDS_MeshVolume *anElem= SMDS_Mesh::AddVolumeWithID(n1, n2, n3, n4, n5, n6, n7, n8, ID);
473 if(anElem) myScript->AddVolume(ID, n1, n2, n3, n4, n5, n6, n7, n8);
477 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
478 const SMDS_MeshNode * n2,
479 const SMDS_MeshNode * n3,
480 const SMDS_MeshNode * n4,
481 const SMDS_MeshNode * n5,
482 const SMDS_MeshNode * n6,
483 const SMDS_MeshNode * n7,
484 const SMDS_MeshNode * n8,
487 return AddVolumeWithID(n1->GetID(),
498 SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
499 const SMDS_MeshNode * n2,
500 const SMDS_MeshNode * n3,
501 const SMDS_MeshNode * n4,
502 const SMDS_MeshNode * n5,
503 const SMDS_MeshNode * n6,
504 const SMDS_MeshNode * n7,
505 const SMDS_MeshNode * n8)
507 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1, n2, n3, n4, n5, n6, n7, n8);
508 if(anElem) myScript->AddVolume(anElem->GetID(),
520 //=======================================================================
521 //function : AddPolygonalFace
523 //=======================================================================
524 SMDS_MeshFace* SMESHDS_Mesh::AddPolygonalFaceWithID (std::vector<int> nodes_ids,
527 SMDS_MeshFace *anElem = SMDS_Mesh::AddPolygonalFaceWithID(nodes_ids, ID);
529 myScript->AddPolygonalFace(ID, nodes_ids);
534 SMDS_MeshFace* SMESHDS_Mesh::AddPolygonalFaceWithID
535 (std::vector<const SMDS_MeshNode*> nodes,
538 SMDS_MeshFace *anElem = SMDS_Mesh::AddPolygonalFaceWithID(nodes, ID);
540 int i, len = nodes.size();
541 std::vector<int> nodes_ids (len);
542 for (i = 0; i < len; i++) {
543 nodes_ids[i] = nodes[i]->GetID();
545 myScript->AddPolygonalFace(ID, nodes_ids);
550 SMDS_MeshFace* SMESHDS_Mesh::AddPolygonalFace
551 (std::vector<const SMDS_MeshNode*> nodes)
553 SMDS_MeshFace *anElem = SMDS_Mesh::AddPolygonalFace(nodes);
555 int i, len = nodes.size();
556 std::vector<int> nodes_ids (len);
557 for (i = 0; i < len; i++) {
558 nodes_ids[i] = nodes[i]->GetID();
560 myScript->AddPolygonalFace(anElem->GetID(), nodes_ids);
565 //=======================================================================
566 //function : AddPolyhedralVolume
568 //=======================================================================
569 SMDS_MeshVolume* SMESHDS_Mesh::AddPolyhedralVolumeWithID (std::vector<int> nodes_ids,
570 std::vector<int> quantities,
573 SMDS_MeshVolume *anElem = SMDS_Mesh::AddPolyhedralVolumeWithID(nodes_ids, quantities, ID);
575 myScript->AddPolyhedralVolume(ID, nodes_ids, quantities);
580 SMDS_MeshVolume* SMESHDS_Mesh::AddPolyhedralVolumeWithID
581 (std::vector<const SMDS_MeshNode*> nodes,
582 std::vector<int> quantities,
585 SMDS_MeshVolume *anElem = SMDS_Mesh::AddPolyhedralVolumeWithID(nodes, quantities, ID);
587 int i, len = nodes.size();
588 std::vector<int> nodes_ids (len);
589 for (i = 0; i < len; i++) {
590 nodes_ids[i] = nodes[i]->GetID();
592 myScript->AddPolyhedralVolume(ID, nodes_ids, quantities);
597 SMDS_MeshVolume* SMESHDS_Mesh::AddPolyhedralVolume
598 (std::vector<const SMDS_MeshNode*> nodes,
599 std::vector<int> quantities)
601 SMDS_MeshVolume *anElem = SMDS_Mesh::AddPolyhedralVolume(nodes, quantities);
603 int i, len = nodes.size();
604 std::vector<int> nodes_ids (len);
605 for (i = 0; i < len; i++) {
606 nodes_ids[i] = nodes[i]->GetID();
608 myScript->AddPolyhedralVolume(anElem->GetID(), nodes_ids, quantities);
613 //=======================================================================
614 //function : removeFromContainers
616 //=======================================================================
618 static void removeFromContainers (map<int,SMESHDS_SubMesh*>& theSubMeshes,
619 set<SMESHDS_GroupBase*>& theGroups,
620 list<const SMDS_MeshElement*>& theElems,
623 if ( theElems.empty() )
627 // Element can belong to several groups
628 if ( !theGroups.empty() )
630 set<SMESHDS_GroupBase*>::iterator GrIt = theGroups.begin();
631 for ( ; GrIt != theGroups.end(); GrIt++ )
633 SMESHDS_Group* group = dynamic_cast<SMESHDS_Group*>( *GrIt );
634 if ( !group || group->IsEmpty() ) continue;
636 list<const SMDS_MeshElement *>::iterator elIt = theElems.begin();
637 for ( ; elIt != theElems.end(); elIt++ )
639 group->SMDSGroup().Remove( *elIt );
640 if ( group->IsEmpty() ) break;
645 // Rm from sub-meshes
646 // Element should belong to only one sub-mesh
647 map<int,SMESHDS_SubMesh*>::iterator SubIt = theSubMeshes.begin();
648 for ( ; SubIt != theSubMeshes.end(); SubIt++ )
650 int size = isNode ? (*SubIt).second->NbNodes() : (*SubIt).second->NbElements();
651 if ( size == 0 ) continue;
653 list<const SMDS_MeshElement *>::iterator elIt = theElems.begin();
654 while ( elIt != theElems.end() )
656 bool removed = false;
658 removed = (*SubIt).second->RemoveNode( static_cast<const SMDS_MeshNode*> (*elIt) );
660 removed = (*SubIt).second->RemoveElement( *elIt );
664 elIt = theElems.erase( elIt );
665 if ( theElems.empty() )
666 return; // all elements are found and removed
676 //=======================================================================
677 //function : RemoveNode
679 //=======================================================================
680 void SMESHDS_Mesh::RemoveNode(const SMDS_MeshNode * n)
682 myScript->RemoveNode(n->GetID());
684 list<const SMDS_MeshElement *> removedElems;
685 list<const SMDS_MeshElement *> removedNodes;
687 SMDS_Mesh::RemoveElement( n, removedElems, removedNodes, true );
689 removeFromContainers( myShapeIndexToSubMesh, myGroups, removedElems, false );
690 removeFromContainers( myShapeIndexToSubMesh, myGroups, removedNodes, true );
693 //=======================================================================
694 //function : RemoveFreeNode
696 //=======================================================================
697 void SMESHDS_Mesh::RemoveFreeNode(const SMDS_MeshNode * n, SMESHDS_SubMesh * subMesh)
699 myScript->RemoveNode(n->GetID());
702 // Node can belong to several groups
703 if (!myGroups.empty()) {
704 set<SMESHDS_GroupBase*>::iterator GrIt = myGroups.begin();
705 for (; GrIt != myGroups.end(); GrIt++) {
706 SMESHDS_Group* group = dynamic_cast<SMESHDS_Group*>(*GrIt);
707 if (!group || group->IsEmpty()) continue;
708 group->SMDSGroup().Remove(n);
713 // Node should belong to only one sub-mesh
714 subMesh->RemoveNode(n);
716 SMDS_Mesh::RemoveFreeElement(n);
719 //=======================================================================
720 //function : RemoveElement
722 //========================================================================
723 void SMESHDS_Mesh::RemoveElement(const SMDS_MeshElement * elt)
725 if (elt->GetType() == SMDSAbs_Node)
727 RemoveNode( static_cast<const SMDS_MeshNode*>( elt ));
731 myScript->RemoveElement(elt->GetID());
733 list<const SMDS_MeshElement *> removedElems;
734 list<const SMDS_MeshElement *> removedNodes;
736 SMDS_Mesh::RemoveElement(elt, removedElems, removedNodes, false);
738 removeFromContainers( myShapeIndexToSubMesh, myGroups, removedElems, false );
741 //=======================================================================
742 //function : RemoveFreeElement
744 //========================================================================
745 void SMESHDS_Mesh::RemoveFreeElement(const SMDS_MeshElement * elt, SMESHDS_SubMesh * subMesh)
747 if (elt->GetType() == SMDSAbs_Node) {
748 RemoveFreeNode( static_cast<const SMDS_MeshNode*>(elt), subMesh);
752 if (hasConstructionEdges() || hasConstructionFaces())
753 // this methods is only for meshes without descendants
756 myScript->RemoveElement(elt->GetID());
759 // Node can belong to several groups
760 if (!myGroups.empty()) {
761 set<SMESHDS_GroupBase*>::iterator GrIt = myGroups.begin();
762 for (; GrIt != myGroups.end(); GrIt++) {
763 SMESHDS_Group* group = dynamic_cast<SMESHDS_Group*>(*GrIt);
764 if (!group || group->IsEmpty()) continue;
765 group->SMDSGroup().Remove(elt);
770 // Element should belong to only one sub-mesh
771 subMesh->RemoveElement(elt);
773 SMDS_Mesh::RemoveFreeElement(elt);
776 //================================================================================
778 * \brief return submesh by shape
779 * \param shape - the subshape
780 * \retval SMESHDS_SubMesh* - the found submesh
782 * search of submeshes is optimized
784 //================================================================================
786 SMESHDS_SubMesh* SMESHDS_Mesh::getSubmesh( const TopoDS_Shape & shape )
788 if ( shape.IsNull() )
791 if ( !myCurSubShape.IsNull() && shape.IsSame( myCurSubShape ))
794 getSubmesh( ShapeToIndex( shape ));
795 myCurSubShape = shape;
799 //================================================================================
801 * \brief return submesh by subshape index
802 * \param Index - the subshape index
803 * \retval SMESHDS_SubMesh* - the found submesh
804 * search of submeshes is optimized
806 //================================================================================
808 SMESHDS_SubMesh* SMESHDS_Mesh::getSubmesh( const int Index )
810 //Update or build submesh
811 if ( Index != myCurSubID ) {
812 map<int,SMESHDS_SubMesh*>::iterator it = myShapeIndexToSubMesh.find( Index );
813 if ( it == myShapeIndexToSubMesh.end() )
814 it = myShapeIndexToSubMesh.insert( make_pair(Index, new SMESHDS_SubMesh() )).first;
815 myCurSubMesh = it->second;
817 myCurSubShape.Nullify(); // myCurSubShape no more corresponds to submesh
822 //================================================================================
824 * \brief Add element or node to submesh
825 * \param elem - element to add
826 * \param subMesh - submesh to be filled in
828 //================================================================================
830 bool SMESHDS_Mesh::add(const SMDS_MeshElement* elem, SMESHDS_SubMesh* subMesh )
832 if ( elem && subMesh ) {
833 if ( elem->GetType() == SMDSAbs_Node )
834 subMesh->AddNode( static_cast<const SMDS_MeshNode* >( elem ));
836 subMesh->AddElement( elem );
842 //=======================================================================
843 //function : SetNodeOnVolume
845 //=======================================================================
846 void SMESHDS_Mesh::SetNodeInVolume(SMDS_MeshNode * aNode,
847 const TopoDS_Shell & S)
849 add( aNode, getSubmesh(S) );
851 //=======================================================================
852 //function : SetNodeOnVolume
854 //=======================================================================
855 void SMESHDS_Mesh::SetNodeInVolume(SMDS_MeshNode * aNode,
856 const TopoDS_Solid & S)
858 add( aNode, getSubmesh(S) );
861 //=======================================================================
862 //function : SetNodeOnFace
864 //=======================================================================
865 void SMESHDS_Mesh::SetNodeOnFace(SMDS_MeshNode * aNode,
866 const TopoDS_Face & S,
870 if ( add( aNode, getSubmesh(S) ))
871 aNode->SetPosition(SMDS_PositionPtr(new SMDS_FacePosition(myCurSubID, u, v)));
874 //=======================================================================
875 //function : SetNodeOnEdge
877 //=======================================================================
878 void SMESHDS_Mesh::SetNodeOnEdge(SMDS_MeshNode * aNode,
879 const TopoDS_Edge & S,
882 if ( add( aNode, getSubmesh(S) ))
883 aNode->SetPosition(SMDS_PositionPtr(new SMDS_EdgePosition(myCurSubID, u)));
886 //=======================================================================
887 //function : SetNodeOnVertex
889 //=======================================================================
890 void SMESHDS_Mesh::SetNodeOnVertex(SMDS_MeshNode * aNode,
891 const TopoDS_Vertex & S)
893 if ( add( aNode, getSubmesh(S) ))
894 aNode->SetPosition(SMDS_PositionPtr(new SMDS_VertexPosition(myCurSubID)));
897 //=======================================================================
898 //function : UnSetNodeOnShape
900 //=======================================================================
901 void SMESHDS_Mesh::UnSetNodeOnShape(const SMDS_MeshNode* aNode)
903 if ( aNode && aNode->GetPosition() ) {
904 map<int,SMESHDS_SubMesh*>::iterator it =
905 myShapeIndexToSubMesh.find( aNode->GetPosition()->GetShapeId() );
906 if ( it != myShapeIndexToSubMesh.end() )
907 it->second->RemoveNode( aNode );
911 //=======================================================================
912 //function : SetMeshElementOnShape
914 //=======================================================================
915 void SMESHDS_Mesh::SetMeshElementOnShape(const SMDS_MeshElement * anElement,
916 const TopoDS_Shape & S)
918 add( anElement, getSubmesh(S) );
921 //=======================================================================
922 //function : UnSetMeshElementOnShape
924 //=======================================================================
925 void SMESHDS_Mesh::UnSetMeshElementOnShape(const SMDS_MeshElement * elem,
926 const TopoDS_Shape & S)
928 int Index = myIndexToShape.FindIndex(S);
930 map<int,SMESHDS_SubMesh*>::iterator it = myShapeIndexToSubMesh.find( Index );
931 if ( it != myShapeIndexToSubMesh.end() )
932 if ( elem->GetType() == SMDSAbs_Node )
933 it->second->RemoveNode( static_cast<const SMDS_MeshNode* >( elem ));
935 it->second->RemoveElement( elem );
938 //=======================================================================
939 //function : ShapeToMesh
941 //=======================================================================
942 TopoDS_Shape SMESHDS_Mesh::ShapeToMesh() const
947 //=======================================================================
948 //function : IsGroupOfSubShapes
949 //purpose : return true if at least one subshape of theShape is a subshape
950 // of myShape or theShape == myShape
951 //=======================================================================
953 bool SMESHDS_Mesh::IsGroupOfSubShapes (const TopoDS_Shape& theShape) const
955 if ( myShape.IsSame( theShape ))
958 for ( TopoDS_Iterator it( theShape ); it.More(); it.Next() ) {
959 if (myIndexToShape.Contains( it.Value() ) ||
960 IsGroupOfSubShapes( it.Value() ))
967 ///////////////////////////////////////////////////////////////////////////////
968 /// Return the sub mesh linked to the a given TopoDS_Shape or NULL if the given
969 /// TopoDS_Shape is unknown
970 ///////////////////////////////////////////////////////////////////////////////
971 SMESHDS_SubMesh * SMESHDS_Mesh::MeshElements(const TopoDS_Shape & S) const
973 int Index = ShapeToIndex(S);
974 TShapeIndexToSubMesh::const_iterator anIter = myShapeIndexToSubMesh.find(Index);
975 if (anIter != myShapeIndexToSubMesh.end())
976 return anIter->second;
981 ///////////////////////////////////////////////////////////////////////////////
982 /// Return the sub mesh by Id of shape it is linked to
983 ///////////////////////////////////////////////////////////////////////////////
984 SMESHDS_SubMesh * SMESHDS_Mesh::MeshElements(const int Index)
986 TShapeIndexToSubMesh::const_iterator anIter = myShapeIndexToSubMesh.find(Index);
987 if (anIter != myShapeIndexToSubMesh.end())
988 return anIter->second;
993 //=======================================================================
994 //function : SubMeshIndices
996 //=======================================================================
997 list<int> SMESHDS_Mesh::SubMeshIndices()
1000 std::map<int,SMESHDS_SubMesh*>::iterator anIter = myShapeIndexToSubMesh.begin();
1001 for (; anIter != myShapeIndexToSubMesh.end(); anIter++) {
1002 anIndices.push_back((*anIter).first);
1007 //=======================================================================
1008 //function : GetHypothesis
1010 //=======================================================================
1012 const list<const SMESHDS_Hypothesis*>& SMESHDS_Mesh::GetHypothesis(
1013 const TopoDS_Shape & S) const
1015 if (myShapeToHypothesis.find(S)!=myShapeToHypothesis.end())
1016 return myShapeToHypothesis.find(S)->second;
1018 static list<const SMESHDS_Hypothesis*> empty;
1022 //=======================================================================
1023 //function : GetScript
1025 //=======================================================================
1026 SMESHDS_Script* SMESHDS_Mesh::GetScript()
1031 //=======================================================================
1032 //function : ClearScript
1034 //=======================================================================
1035 void SMESHDS_Mesh::ClearScript()
1040 //=======================================================================
1041 //function : HasMeshElements
1043 //=======================================================================
1044 bool SMESHDS_Mesh::HasMeshElements(const TopoDS_Shape & S)
1046 if (myShape.IsNull()) MESSAGE("myShape is NULL");
1047 int Index = myIndexToShape.FindIndex(S);
1048 return myShapeIndexToSubMesh.find(Index)!=myShapeIndexToSubMesh.end();
1051 //=======================================================================
1052 //function : HasHypothesis
1054 //=======================================================================
1055 bool SMESHDS_Mesh::HasHypothesis(const TopoDS_Shape & S)
1057 return myShapeToHypothesis.find(S)!=myShapeToHypothesis.end();
1060 //=======================================================================
1061 //function : NewSubMesh
1063 //=======================================================================
1064 SMESHDS_SubMesh * SMESHDS_Mesh::NewSubMesh(int Index)
1066 SMESHDS_SubMesh* SM = 0;
1067 TShapeIndexToSubMesh::iterator anIter = myShapeIndexToSubMesh.find(Index);
1068 if (anIter == myShapeIndexToSubMesh.end())
1070 SM = new SMESHDS_SubMesh();
1071 myShapeIndexToSubMesh[Index]=SM;
1074 SM = anIter->second;
1078 //=======================================================================
1079 //function : AddCompoundSubmesh
1081 //=======================================================================
1083 int SMESHDS_Mesh::AddCompoundSubmesh(const TopoDS_Shape& S,
1084 TopAbs_ShapeEnum type)
1087 if ( IsGroupOfSubShapes( S ) || (S.ShapeType() == TopAbs_VERTEX && myIndexToShape.Contains(S)) )
1089 aMainIndex = myIndexToShape.Add( S );
1090 bool all = ( type == TopAbs_SHAPE );
1091 if ( all ) // corresponding simple submesh may exist
1092 aMainIndex = -aMainIndex;
1093 //MESSAGE("AddCompoundSubmesh index = " << aMainIndex );
1094 SMESHDS_SubMesh * aNewSub = NewSubMesh( aMainIndex );
1095 if ( !aNewSub->IsComplexSubmesh() ) // is empty
1097 int shapeType = all ? myShape.ShapeType() : type;
1098 int typeLimit = all ? TopAbs_VERTEX : type;
1099 for ( ; shapeType <= typeLimit; shapeType++ )
1101 TopExp_Explorer exp( S, TopAbs_ShapeEnum( shapeType ));
1102 for ( ; exp.More(); exp.Next() )
1104 int index = myIndexToShape.FindIndex( exp.Current() );
1106 aNewSub->AddSubMesh( NewSubMesh( index ));
1114 //=======================================================================
1115 //function : IndexToShape
1117 //=======================================================================
1118 const TopoDS_Shape& SMESHDS_Mesh::IndexToShape(int ShapeIndex) const
1120 return myIndexToShape.FindKey(ShapeIndex);
1123 //=======================================================================
1124 //function : ShapeToIndex
1126 //=======================================================================
1127 int SMESHDS_Mesh::ShapeToIndex(const TopoDS_Shape & S) const
1129 if (myShape.IsNull())
1130 MESSAGE("myShape is NULL");
1132 int index = myIndexToShape.FindIndex(S);
1137 //=======================================================================
1138 //function : SetNodeOnVolume
1140 //=======================================================================
1141 void SMESHDS_Mesh::SetNodeInVolume(const SMDS_MeshNode* aNode, int Index)
1143 add( aNode, getSubmesh( Index ));
1146 //=======================================================================
1147 //function : SetNodeOnFace
1149 //=======================================================================
1150 void SMESHDS_Mesh::SetNodeOnFace(SMDS_MeshNode* aNode, int Index, double u, double v)
1152 //Set Position on Node
1153 if ( add( aNode, getSubmesh( Index )))
1154 aNode->SetPosition(SMDS_PositionPtr(new SMDS_FacePosition(Index, u, v)));
1157 //=======================================================================
1158 //function : SetNodeOnEdge
1160 //=======================================================================
1161 void SMESHDS_Mesh::SetNodeOnEdge(SMDS_MeshNode* aNode,
1165 //Set Position on Node
1166 if ( add( aNode, getSubmesh( Index )))
1167 aNode->SetPosition(SMDS_PositionPtr(new SMDS_EdgePosition(Index, u)));
1170 //=======================================================================
1171 //function : SetNodeOnVertex
1173 //=======================================================================
1174 void SMESHDS_Mesh::SetNodeOnVertex(SMDS_MeshNode* aNode, int Index)
1176 //Set Position on Node
1177 if ( add( aNode, getSubmesh( Index )))
1178 aNode->SetPosition(SMDS_PositionPtr(new SMDS_VertexPosition(Index)));
1181 //=======================================================================
1182 //function : SetMeshElementOnShape
1184 //=======================================================================
1185 void SMESHDS_Mesh::SetMeshElementOnShape(const SMDS_MeshElement* anElement,
1188 add( anElement, getSubmesh( Index ));
1191 SMESHDS_Mesh::~SMESHDS_Mesh()
1198 //********************************************************************
1199 //********************************************************************
1200 //******** *********
1201 //***** Methods for addition of quadratic elements ******
1202 //******** *********
1203 //********************************************************************
1204 //********************************************************************
1206 //=======================================================================
1207 //function : AddEdgeWithID
1209 //=======================================================================
1210 SMDS_MeshEdge* SMESHDS_Mesh::AddEdgeWithID(int n1, int n2, int n12, int ID)
1212 SMDS_MeshEdge* anElem = SMDS_Mesh::AddEdgeWithID(n1,n2,n12,ID);
1213 if(anElem) myScript->AddEdge(ID,n1,n2,n12);
1217 //=======================================================================
1218 //function : AddEdge
1220 //=======================================================================
1221 SMDS_MeshEdge* SMESHDS_Mesh::AddEdge(const SMDS_MeshNode* n1,
1222 const SMDS_MeshNode* n2,
1223 const SMDS_MeshNode* n12)
1225 SMDS_MeshEdge* anElem = SMDS_Mesh::AddEdge(n1,n2,n12);
1226 if(anElem) myScript->AddEdge(anElem->GetID(),
1233 //=======================================================================
1234 //function : AddEdgeWithID
1236 //=======================================================================
1237 SMDS_MeshEdge* SMESHDS_Mesh::AddEdgeWithID(const SMDS_MeshNode * n1,
1238 const SMDS_MeshNode * n2,
1239 const SMDS_MeshNode * n12,
1242 return AddEdgeWithID(n1->GetID(),
1249 //=======================================================================
1250 //function : AddFace
1252 //=======================================================================
1253 SMDS_MeshFace* SMESHDS_Mesh::AddFace(const SMDS_MeshNode * n1,
1254 const SMDS_MeshNode * n2,
1255 const SMDS_MeshNode * n3,
1256 const SMDS_MeshNode * n12,
1257 const SMDS_MeshNode * n23,
1258 const SMDS_MeshNode * n31)
1260 SMDS_MeshFace *anElem = SMDS_Mesh::AddFace(n1,n2,n3,n12,n23,n31);
1261 if(anElem) myScript->AddFace(anElem->GetID(),
1262 n1->GetID(), n2->GetID(), n3->GetID(),
1263 n12->GetID(), n23->GetID(), n31->GetID());
1267 //=======================================================================
1268 //function : AddFaceWithID
1270 //=======================================================================
1271 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(int n1, int n2, int n3,
1272 int n12,int n23,int n31, int ID)
1274 SMDS_MeshFace *anElem = SMDS_Mesh::AddFaceWithID(n1,n2,n3,n12,n23,n31,ID);
1275 if(anElem) myScript->AddFace(ID,n1,n2,n3,n12,n23,n31);
1279 //=======================================================================
1280 //function : AddFaceWithID
1282 //=======================================================================
1283 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(const SMDS_MeshNode * n1,
1284 const SMDS_MeshNode * n2,
1285 const SMDS_MeshNode * n3,
1286 const SMDS_MeshNode * n12,
1287 const SMDS_MeshNode * n23,
1288 const SMDS_MeshNode * n31,
1291 return AddFaceWithID(n1->GetID(), n2->GetID(), n3->GetID(),
1292 n12->GetID(), n23->GetID(), n31->GetID(),
1297 //=======================================================================
1298 //function : AddFace
1300 //=======================================================================
1301 SMDS_MeshFace* SMESHDS_Mesh::AddFace(const SMDS_MeshNode * n1,
1302 const SMDS_MeshNode * n2,
1303 const SMDS_MeshNode * n3,
1304 const SMDS_MeshNode * n4,
1305 const SMDS_MeshNode * n12,
1306 const SMDS_MeshNode * n23,
1307 const SMDS_MeshNode * n34,
1308 const SMDS_MeshNode * n41)
1310 SMDS_MeshFace *anElem = SMDS_Mesh::AddFace(n1,n2,n3,n4,n12,n23,n34,n41);
1311 if(anElem) myScript->AddFace(anElem->GetID(),
1312 n1->GetID(), n2->GetID(), n3->GetID(), n4->GetID(),
1313 n12->GetID(), n23->GetID(), n34->GetID(), n41->GetID());
1317 //=======================================================================
1318 //function : AddFaceWithID
1320 //=======================================================================
1321 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(int n1, int n2, int n3, int n4,
1322 int n12,int n23,int n34,int n41, int ID)
1324 SMDS_MeshFace *anElem = SMDS_Mesh::AddFaceWithID(n1,n2,n3,n4,n12,n23,n34,n41,ID);
1325 if(anElem) myScript->AddFace(ID,n1,n2,n3,n4,n12,n23,n34,n41);
1329 //=======================================================================
1330 //function : AddFaceWithID
1332 //=======================================================================
1333 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(const SMDS_MeshNode * n1,
1334 const SMDS_MeshNode * n2,
1335 const SMDS_MeshNode * n3,
1336 const SMDS_MeshNode * n4,
1337 const SMDS_MeshNode * n12,
1338 const SMDS_MeshNode * n23,
1339 const SMDS_MeshNode * n34,
1340 const SMDS_MeshNode * n41,
1343 return AddFaceWithID(n1->GetID(), n2->GetID(), n3->GetID(), n4->GetID(),
1344 n12->GetID(), n23->GetID(), n34->GetID(), n41->GetID(),
1349 //=======================================================================
1350 //function : AddVolume
1352 //=======================================================================
1353 SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
1354 const SMDS_MeshNode * n2,
1355 const SMDS_MeshNode * n3,
1356 const SMDS_MeshNode * n4,
1357 const SMDS_MeshNode * n12,
1358 const SMDS_MeshNode * n23,
1359 const SMDS_MeshNode * n31,
1360 const SMDS_MeshNode * n14,
1361 const SMDS_MeshNode * n24,
1362 const SMDS_MeshNode * n34)
1364 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1,n2,n3,n4,n12,n23,n31,n14,n24,n34);
1365 if(anElem) myScript->AddVolume(anElem->GetID(),
1366 n1->GetID(), n2->GetID(), n3->GetID(), n4->GetID(),
1367 n12->GetID(), n23->GetID(), n31->GetID(),
1368 n14->GetID(), n24->GetID(), n34->GetID());
1372 //=======================================================================
1373 //function : AddVolumeWithID
1375 //=======================================================================
1376 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3, int n4,
1377 int n12,int n23,int n31,
1378 int n14,int n24,int n34, int ID)
1380 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolumeWithID(n1,n2,n3,n4,n12,n23,
1381 n31,n14,n24,n34,ID);
1382 if(anElem) myScript->AddVolume(ID,n1,n2,n3,n4,n12,n23,n31,n14,n24,n34);
1386 //=======================================================================
1387 //function : AddVolumeWithID
1388 //purpose : 2d order tetrahedron of 10 nodes
1389 //=======================================================================
1390 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
1391 const SMDS_MeshNode * n2,
1392 const SMDS_MeshNode * n3,
1393 const SMDS_MeshNode * n4,
1394 const SMDS_MeshNode * n12,
1395 const SMDS_MeshNode * n23,
1396 const SMDS_MeshNode * n31,
1397 const SMDS_MeshNode * n14,
1398 const SMDS_MeshNode * n24,
1399 const SMDS_MeshNode * n34,
1402 return AddVolumeWithID(n1->GetID(), n2->GetID(), n3->GetID(), n4->GetID(),
1403 n12->GetID(), n23->GetID(), n31->GetID(),
1404 n14->GetID(), n24->GetID(), n34->GetID(), ID);
1408 //=======================================================================
1409 //function : AddVolume
1411 //=======================================================================
1412 SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
1413 const SMDS_MeshNode * n2,
1414 const SMDS_MeshNode * n3,
1415 const SMDS_MeshNode * n4,
1416 const SMDS_MeshNode * n5,
1417 const SMDS_MeshNode * n12,
1418 const SMDS_MeshNode * n23,
1419 const SMDS_MeshNode * n34,
1420 const SMDS_MeshNode * n41,
1421 const SMDS_MeshNode * n15,
1422 const SMDS_MeshNode * n25,
1423 const SMDS_MeshNode * n35,
1424 const SMDS_MeshNode * n45)
1426 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1,n2,n3,n4,n5,n12,n23,n34,n41,
1429 myScript->AddVolume(anElem->GetID(), n1->GetID(), n2->GetID(),
1430 n3->GetID(), n4->GetID(), n5->GetID(),
1431 n12->GetID(), n23->GetID(), n34->GetID(), n41->GetID(),
1432 n15->GetID(), n25->GetID(), n35->GetID(), n45->GetID());
1436 //=======================================================================
1437 //function : AddVolumeWithID
1439 //=======================================================================
1440 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3, int n4, int n5,
1441 int n12,int n23,int n34,int n41,
1442 int n15,int n25,int n35,int n45, int ID)
1444 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolumeWithID(n1,n2,n3,n4,n5,
1446 n15,n25,n35,n45,ID);
1447 if(anElem) myScript->AddVolume(ID,n1,n2,n3,n4,n5,n12,n23,n34,n41,
1452 //=======================================================================
1453 //function : AddVolumeWithID
1454 //purpose : 2d order pyramid of 13 nodes
1455 //=======================================================================
1456 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
1457 const SMDS_MeshNode * n2,
1458 const SMDS_MeshNode * n3,
1459 const SMDS_MeshNode * n4,
1460 const SMDS_MeshNode * n5,
1461 const SMDS_MeshNode * n12,
1462 const SMDS_MeshNode * n23,
1463 const SMDS_MeshNode * n34,
1464 const SMDS_MeshNode * n41,
1465 const SMDS_MeshNode * n15,
1466 const SMDS_MeshNode * n25,
1467 const SMDS_MeshNode * n35,
1468 const SMDS_MeshNode * n45,
1471 return AddVolumeWithID(n1->GetID(), n2->GetID(), n3->GetID(),
1472 n4->GetID(), n5->GetID(),
1473 n12->GetID(), n23->GetID(), n34->GetID(), n41->GetID(),
1474 n15->GetID(), n25->GetID(), n35->GetID(), n45->GetID(),
1479 //=======================================================================
1480 //function : AddVolume
1482 //=======================================================================
1483 SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
1484 const SMDS_MeshNode * n2,
1485 const SMDS_MeshNode * n3,
1486 const SMDS_MeshNode * n4,
1487 const SMDS_MeshNode * n5,
1488 const SMDS_MeshNode * n6,
1489 const SMDS_MeshNode * n12,
1490 const SMDS_MeshNode * n23,
1491 const SMDS_MeshNode * n31,
1492 const SMDS_MeshNode * n45,
1493 const SMDS_MeshNode * n56,
1494 const SMDS_MeshNode * n64,
1495 const SMDS_MeshNode * n14,
1496 const SMDS_MeshNode * n25,
1497 const SMDS_MeshNode * n36)
1499 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1,n2,n3,n4,n5,n6,n12,n23,n31,
1500 n45,n56,n64,n14,n25,n36);
1502 myScript->AddVolume(anElem->GetID(), n1->GetID(), n2->GetID(),
1503 n3->GetID(), n4->GetID(), n5->GetID(), n6->GetID(),
1504 n12->GetID(), n23->GetID(), n31->GetID(),
1505 n45->GetID(), n56->GetID(), n64->GetID(),
1506 n14->GetID(), n25->GetID(), n36->GetID());
1510 //=======================================================================
1511 //function : AddVolumeWithID
1513 //=======================================================================
1514 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3,
1515 int n4, int n5, int n6,
1516 int n12,int n23,int n31,
1517 int n45,int n56,int n64,
1518 int n14,int n25,int n36, int ID)
1520 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolumeWithID(n1,n2,n3,n4,n5,n6,
1524 if(anElem) myScript->AddVolume(ID,n1,n2,n3,n4,n5,n6,n12,n23,n31,
1525 n45,n56,n64,n14,n25,n36);
1529 //=======================================================================
1530 //function : AddVolumeWithID
1531 //purpose : 2d order Pentahedron with 15 nodes
1532 //=======================================================================
1533 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
1534 const SMDS_MeshNode * n2,
1535 const SMDS_MeshNode * n3,
1536 const SMDS_MeshNode * n4,
1537 const SMDS_MeshNode * n5,
1538 const SMDS_MeshNode * n6,
1539 const SMDS_MeshNode * n12,
1540 const SMDS_MeshNode * n23,
1541 const SMDS_MeshNode * n31,
1542 const SMDS_MeshNode * n45,
1543 const SMDS_MeshNode * n56,
1544 const SMDS_MeshNode * n64,
1545 const SMDS_MeshNode * n14,
1546 const SMDS_MeshNode * n25,
1547 const SMDS_MeshNode * n36,
1550 return AddVolumeWithID(n1->GetID(), n2->GetID(), n3->GetID(),
1551 n4->GetID(), n5->GetID(), n6->GetID(),
1552 n12->GetID(), n23->GetID(), n31->GetID(),
1553 n45->GetID(), n56->GetID(), n64->GetID(),
1554 n14->GetID(), n25->GetID(), n36->GetID(),
1559 //=======================================================================
1560 //function : AddVolume
1562 //=======================================================================
1563 SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
1564 const SMDS_MeshNode * n2,
1565 const SMDS_MeshNode * n3,
1566 const SMDS_MeshNode * n4,
1567 const SMDS_MeshNode * n5,
1568 const SMDS_MeshNode * n6,
1569 const SMDS_MeshNode * n7,
1570 const SMDS_MeshNode * n8,
1571 const SMDS_MeshNode * n12,
1572 const SMDS_MeshNode * n23,
1573 const SMDS_MeshNode * n34,
1574 const SMDS_MeshNode * n41,
1575 const SMDS_MeshNode * n56,
1576 const SMDS_MeshNode * n67,
1577 const SMDS_MeshNode * n78,
1578 const SMDS_MeshNode * n85,
1579 const SMDS_MeshNode * n15,
1580 const SMDS_MeshNode * n26,
1581 const SMDS_MeshNode * n37,
1582 const SMDS_MeshNode * n48)
1584 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1,n2,n3,n4,n5,n6,n7,n8,
1589 myScript->AddVolume(anElem->GetID(), n1->GetID(), n2->GetID(),
1590 n3->GetID(), n4->GetID(), n5->GetID(),
1591 n6->GetID(), n7->GetID(), n8->GetID(),
1592 n12->GetID(), n23->GetID(), n34->GetID(), n41->GetID(),
1593 n56->GetID(), n67->GetID(), n78->GetID(), n85->GetID(),
1594 n15->GetID(), n26->GetID(), n37->GetID(), n48->GetID());
1598 //=======================================================================
1599 //function : AddVolumeWithID
1601 //=======================================================================
1602 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3, int n4,
1603 int n5, int n6, int n7, int n8,
1604 int n12,int n23,int n34,int n41,
1605 int n56,int n67,int n78,int n85,
1606 int n15,int n26,int n37,int n48, int ID)
1608 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolumeWithID(n1,n2,n3,n4,n5,n6,n7,n8,
1611 n15,n26,n37,n48,ID);
1612 if(anElem) myScript->AddVolume(ID,n1,n2,n3,n4,n5,n6,n7,n8,n12,n23,n34,n41,
1613 n56,n67,n78,n85,n15,n26,n37,n48);
1617 //=======================================================================
1618 //function : AddVolumeWithID
1619 //purpose : 2d order Hexahedrons with 20 nodes
1620 //=======================================================================
1621 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
1622 const SMDS_MeshNode * n2,
1623 const SMDS_MeshNode * n3,
1624 const SMDS_MeshNode * n4,
1625 const SMDS_MeshNode * n5,
1626 const SMDS_MeshNode * n6,
1627 const SMDS_MeshNode * n7,
1628 const SMDS_MeshNode * n8,
1629 const SMDS_MeshNode * n12,
1630 const SMDS_MeshNode * n23,
1631 const SMDS_MeshNode * n34,
1632 const SMDS_MeshNode * n41,
1633 const SMDS_MeshNode * n56,
1634 const SMDS_MeshNode * n67,
1635 const SMDS_MeshNode * n78,
1636 const SMDS_MeshNode * n85,
1637 const SMDS_MeshNode * n15,
1638 const SMDS_MeshNode * n26,
1639 const SMDS_MeshNode * n37,
1640 const SMDS_MeshNode * n48,
1643 return AddVolumeWithID(n1->GetID(), n2->GetID(), n3->GetID(), n4->GetID(),
1644 n5->GetID(), n6->GetID(), n7->GetID(), n8->GetID(),
1645 n12->GetID(), n23->GetID(), n34->GetID(), n41->GetID(),
1646 n56->GetID(), n67->GetID(), n78->GetID(), n85->GetID(),
1647 n15->GetID(), n26->GetID(), n37->GetID(), n48->GetID(),