1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 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
22 // SMESH SMESHDS : management of mesh data and SMESH document
23 // File : SMESH_Mesh.cxx
24 // Author : Yves FRICAUD, OCC
28 #include "SMESHDS_Mesh.hxx"
30 #include "SMESHDS_Group.hxx"
31 #include "SMDS_VertexPosition.hxx"
32 #include "SMDS_EdgePosition.hxx"
33 #include "SMDS_FacePosition.hxx"
34 #include "SMDS_SpacePosition.hxx"
35 #include "SMESHDS_GroupOnGeom.hxx"
37 #include <TopExp_Explorer.hxx>
39 #include <TopoDS_Iterator.hxx>
41 #include "utilities.h"
45 /*Standard_Boolean IsEqual( const TopoDS_Shape& S1, const TopoDS_Shape& S2 )
47 return S1.IsSame( S2 );
50 //=======================================================================
53 //=======================================================================
54 SMESHDS_Mesh::SMESHDS_Mesh(int theMeshID, bool theIsEmbeddedMode):
56 myIsEmbeddedMode(theIsEmbeddedMode),
59 myScript = new SMESHDS_Script(theIsEmbeddedMode);
63 //=======================================================================
64 bool SMESHDS_Mesh::IsEmbeddedMode()
66 return myIsEmbeddedMode;
69 //=======================================================================
70 //function : ShapeToMesh
72 //=======================================================================
73 void SMESHDS_Mesh::ShapeToMesh(const TopoDS_Shape & S)
75 if ( !myShape.IsNull() && S.IsNull() )
77 // removal of a shape to mesh, delete ...
79 myShapeToHypothesis.Clear();
80 // - shape indices in SMDS_Position of nodes
81 map<int,SMESHDS_SubMesh*>::iterator i_sub = myShapeIndexToSubMesh.begin();
82 for ( ; i_sub != myShapeIndexToSubMesh.end(); i_sub++ ) {
83 if ( !i_sub->second->IsComplexSubmesh() ) {
84 SMDS_NodeIteratorPtr nIt = i_sub->second->GetNodes();
86 nIt->next()->GetPosition()->SetShapeId( 0 );
90 myIndexToShape.Clear();
91 myShapeIndexToSubMesh.clear();
92 // - groups on geometry
93 set<SMESHDS_GroupBase*>::iterator gr = myGroups.begin();
94 while ( gr != myGroups.end() ) {
95 if ( dynamic_cast<SMESHDS_GroupOnGeom*>( *gr ))
96 myGroups.erase( gr++ );
104 TopExp::MapShapes(myShape, myIndexToShape);
108 //=======================================================================
109 //function : AddHypothesis
111 //=======================================================================
113 bool SMESHDS_Mesh::AddHypothesis(const TopoDS_Shape & SS,
114 const SMESHDS_Hypothesis * H)
116 if (!myShapeToHypothesis.IsBound(SS.Oriented(TopAbs_FORWARD))) {
117 list<const SMESHDS_Hypothesis *> aList;
118 myShapeToHypothesis.Bind(SS.Oriented(TopAbs_FORWARD), aList);
120 list<const SMESHDS_Hypothesis *>& alist =
121 myShapeToHypothesis(SS.Oriented(TopAbs_FORWARD)); // ignore orientation of SS
123 //Check if the Hypothesis is still present
124 list<const SMESHDS_Hypothesis*>::iterator ith = find(alist.begin(),alist.end(), H );
126 if (alist.end() != ith) return false;
132 //=======================================================================
133 //function : RemoveHypothesis
135 //=======================================================================
137 bool SMESHDS_Mesh::RemoveHypothesis(const TopoDS_Shape & S,
138 const SMESHDS_Hypothesis * H)
140 if( myShapeToHypothesis.IsBound( S.Oriented(TopAbs_FORWARD) ) )
142 list<const SMESHDS_Hypothesis *>& alist=myShapeToHypothesis.ChangeFind( S.Oriented(TopAbs_FORWARD) );
143 list<const SMESHDS_Hypothesis*>::iterator ith=find(alist.begin(),alist.end(), H );
144 if (ith != alist.end())
153 //=======================================================================
156 //=======================================================================
157 SMDS_MeshNode* SMESHDS_Mesh::AddNode(double x, double y, double z){
158 SMDS_MeshNode* node = SMDS_Mesh::AddNode(x, y, z);
159 if(node!=NULL) myScript->AddNode(node->GetID(), x, y, z);
163 SMDS_MeshNode* SMESHDS_Mesh::AddNodeWithID(double x, double y, double z, int ID){
164 SMDS_MeshNode* node = SMDS_Mesh::AddNodeWithID(x,y,z,ID);
165 if(node!=NULL) myScript->AddNode(node->GetID(), x, y, z);
169 //=======================================================================
170 //function : MoveNode
172 //=======================================================================
173 void SMESHDS_Mesh::MoveNode(const SMDS_MeshNode *n, double x, double y, double z)
175 SMDS_MeshNode * node=const_cast<SMDS_MeshNode*>(n);
177 myScript->MoveNode(n->GetID(), x, y, z);
180 //=======================================================================
181 //function : ChangeElementNodes
183 //=======================================================================
185 bool SMESHDS_Mesh::ChangeElementNodes(const SMDS_MeshElement * elem,
186 const SMDS_MeshNode * nodes[],
189 if ( ! SMDS_Mesh::ChangeElementNodes( elem, nodes, nbnodes ))
192 vector<int> IDs( nbnodes );
193 for ( int i = 0; i < nbnodes; i++ )
194 IDs [ i ] = nodes[ i ]->GetID();
195 myScript->ChangeElementNodes( elem->GetID(), &IDs[0], nbnodes);
200 //=======================================================================
201 //function : ChangePolygonNodes
203 //=======================================================================
204 bool SMESHDS_Mesh::ChangePolygonNodes
205 (const SMDS_MeshElement * elem,
206 vector<const SMDS_MeshNode*> nodes)
208 ASSERT(nodes.size() > 3);
210 return ChangeElementNodes(elem, &nodes[0], nodes.size());
213 //=======================================================================
214 //function : ChangePolyhedronNodes
216 //=======================================================================
217 bool SMESHDS_Mesh::ChangePolyhedronNodes
218 (const SMDS_MeshElement * elem,
219 std::vector<const SMDS_MeshNode*> nodes,
220 std::vector<int> quantities)
222 ASSERT(nodes.size() > 3);
224 if (!SMDS_Mesh::ChangePolyhedronNodes(elem, nodes, quantities))
227 int i, len = nodes.size();
228 std::vector<int> nodes_ids (len);
229 for (i = 0; i < len; i++) {
230 nodes_ids[i] = nodes[i]->GetID();
232 myScript->ChangePolyhedronNodes(elem->GetID(), nodes_ids, quantities);
237 //=======================================================================
238 //function : Renumber
240 //=======================================================================
242 void SMESHDS_Mesh::Renumber (const bool isNodes, const int startID, const int deltaID)
244 SMDS_Mesh::Renumber( isNodes, startID, deltaID );
245 myScript->Renumber( isNodes, startID, deltaID );
248 //=======================================================================
249 //function :AddEdgeWithID
251 //=======================================================================
252 SMDS_MeshEdge* SMESHDS_Mesh::AddEdgeWithID(int n1, int n2, int ID)
254 SMDS_MeshEdge* anElem = SMDS_Mesh::AddEdgeWithID(n1,n2,ID);
255 if(anElem) myScript->AddEdge(ID,n1,n2);
259 SMDS_MeshEdge* SMESHDS_Mesh::AddEdgeWithID(const SMDS_MeshNode * n1,
260 const SMDS_MeshNode * n2,
263 return AddEdgeWithID(n1->GetID(),
268 SMDS_MeshEdge* SMESHDS_Mesh::AddEdge(const SMDS_MeshNode * n1,
269 const SMDS_MeshNode * n2)
271 SMDS_MeshEdge* anElem = SMDS_Mesh::AddEdge(n1,n2);
272 if(anElem) myScript->AddEdge(anElem->GetID(),
278 //=======================================================================
281 //=======================================================================
282 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(int n1, int n2, int n3, int ID)
284 SMDS_MeshFace *anElem = SMDS_Mesh::AddFaceWithID(n1, n2, n3, ID);
285 if(anElem) myScript->AddFace(ID,n1,n2,n3);
289 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(const SMDS_MeshNode * n1,
290 const SMDS_MeshNode * n2,
291 const SMDS_MeshNode * n3,
294 return AddFaceWithID(n1->GetID(),
300 SMDS_MeshFace* SMESHDS_Mesh::AddFace( const SMDS_MeshNode * n1,
301 const SMDS_MeshNode * n2,
302 const SMDS_MeshNode * n3)
304 SMDS_MeshFace *anElem = SMDS_Mesh::AddFace(n1, n2, n3);
305 if(anElem) myScript->AddFace(anElem->GetID(),
312 //=======================================================================
315 //=======================================================================
316 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(int n1, int n2, int n3, int n4, int ID)
318 SMDS_MeshFace *anElem = SMDS_Mesh::AddFaceWithID(n1, n2, n3, n4, ID);
319 if(anElem) myScript->AddFace(ID, n1, n2, n3, n4);
323 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(const SMDS_MeshNode * n1,
324 const SMDS_MeshNode * n2,
325 const SMDS_MeshNode * n3,
326 const SMDS_MeshNode * n4,
329 return AddFaceWithID(n1->GetID(),
336 SMDS_MeshFace* SMESHDS_Mesh::AddFace(const SMDS_MeshNode * n1,
337 const SMDS_MeshNode * n2,
338 const SMDS_MeshNode * n3,
339 const SMDS_MeshNode * n4)
341 SMDS_MeshFace *anElem = SMDS_Mesh::AddFace(n1, n2, n3, n4);
342 if(anElem) myScript->AddFace(anElem->GetID(),
350 //=======================================================================
351 //function :AddVolume
353 //=======================================================================
354 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3, int n4, int ID)
356 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolumeWithID(n1, n2, n3, n4, ID);
357 if(anElem) myScript->AddVolume(ID, n1, n2, n3, n4);
361 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
362 const SMDS_MeshNode * n2,
363 const SMDS_MeshNode * n3,
364 const SMDS_MeshNode * n4,
367 return AddVolumeWithID(n1->GetID(),
374 SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
375 const SMDS_MeshNode * n2,
376 const SMDS_MeshNode * n3,
377 const SMDS_MeshNode * n4)
379 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1, n2, n3, n4);
380 if(anElem) myScript->AddVolume(anElem->GetID(),
388 //=======================================================================
389 //function :AddVolume
391 //=======================================================================
392 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3, int n4, int n5, int ID)
394 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolumeWithID(n1, n2, n3, n4, n5, ID);
395 if(anElem) myScript->AddVolume(ID, n1, n2, n3, n4, n5);
399 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
400 const SMDS_MeshNode * n2,
401 const SMDS_MeshNode * n3,
402 const SMDS_MeshNode * n4,
403 const SMDS_MeshNode * n5,
406 return AddVolumeWithID(n1->GetID(),
414 SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
415 const SMDS_MeshNode * n2,
416 const SMDS_MeshNode * n3,
417 const SMDS_MeshNode * n4,
418 const SMDS_MeshNode * n5)
420 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1, n2, n3, n4, n5);
421 if(anElem) myScript->AddVolume(anElem->GetID(),
430 //=======================================================================
431 //function :AddVolume
433 //=======================================================================
434 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3, int n4, int n5, int n6, int ID)
436 SMDS_MeshVolume *anElem= SMDS_Mesh::AddVolumeWithID(n1, n2, n3, n4, n5, n6, ID);
437 if(anElem) myScript->AddVolume(ID, n1, n2, n3, n4, n5, n6);
441 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
442 const SMDS_MeshNode * n2,
443 const SMDS_MeshNode * n3,
444 const SMDS_MeshNode * n4,
445 const SMDS_MeshNode * n5,
446 const SMDS_MeshNode * n6,
449 return AddVolumeWithID(n1->GetID(),
458 SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
459 const SMDS_MeshNode * n2,
460 const SMDS_MeshNode * n3,
461 const SMDS_MeshNode * n4,
462 const SMDS_MeshNode * n5,
463 const SMDS_MeshNode * n6)
465 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1, n2, n3, n4, n5, n6);
466 if(anElem) myScript->AddVolume(anElem->GetID(),
476 //=======================================================================
477 //function :AddVolume
479 //=======================================================================
480 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3, int n4, int n5, int n6, int n7, int n8, int ID)
482 SMDS_MeshVolume *anElem= SMDS_Mesh::AddVolumeWithID(n1, n2, n3, n4, n5, n6, n7, n8, ID);
483 if(anElem) myScript->AddVolume(ID, n1, n2, n3, n4, n5, n6, n7, n8);
487 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
488 const SMDS_MeshNode * n2,
489 const SMDS_MeshNode * n3,
490 const SMDS_MeshNode * n4,
491 const SMDS_MeshNode * n5,
492 const SMDS_MeshNode * n6,
493 const SMDS_MeshNode * n7,
494 const SMDS_MeshNode * n8,
497 return AddVolumeWithID(n1->GetID(),
508 SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
509 const SMDS_MeshNode * n2,
510 const SMDS_MeshNode * n3,
511 const SMDS_MeshNode * n4,
512 const SMDS_MeshNode * n5,
513 const SMDS_MeshNode * n6,
514 const SMDS_MeshNode * n7,
515 const SMDS_MeshNode * n8)
517 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1, n2, n3, n4, n5, n6, n7, n8);
518 if(anElem) myScript->AddVolume(anElem->GetID(),
530 //=======================================================================
531 //function : AddPolygonalFace
533 //=======================================================================
534 SMDS_MeshFace* SMESHDS_Mesh::AddPolygonalFaceWithID (std::vector<int> nodes_ids,
537 SMDS_MeshFace *anElem = SMDS_Mesh::AddPolygonalFaceWithID(nodes_ids, ID);
539 myScript->AddPolygonalFace(ID, nodes_ids);
544 SMDS_MeshFace* SMESHDS_Mesh::AddPolygonalFaceWithID
545 (std::vector<const SMDS_MeshNode*> nodes,
548 SMDS_MeshFace *anElem = SMDS_Mesh::AddPolygonalFaceWithID(nodes, ID);
550 int i, len = nodes.size();
551 std::vector<int> nodes_ids (len);
552 for (i = 0; i < len; i++) {
553 nodes_ids[i] = nodes[i]->GetID();
555 myScript->AddPolygonalFace(ID, nodes_ids);
560 SMDS_MeshFace* SMESHDS_Mesh::AddPolygonalFace
561 (std::vector<const SMDS_MeshNode*> nodes)
563 SMDS_MeshFace *anElem = SMDS_Mesh::AddPolygonalFace(nodes);
565 int i, len = nodes.size();
566 std::vector<int> nodes_ids (len);
567 for (i = 0; i < len; i++) {
568 nodes_ids[i] = nodes[i]->GetID();
570 myScript->AddPolygonalFace(anElem->GetID(), nodes_ids);
575 //=======================================================================
576 //function : AddPolyhedralVolume
578 //=======================================================================
579 SMDS_MeshVolume* SMESHDS_Mesh::AddPolyhedralVolumeWithID (std::vector<int> nodes_ids,
580 std::vector<int> quantities,
583 SMDS_MeshVolume *anElem = SMDS_Mesh::AddPolyhedralVolumeWithID(nodes_ids, quantities, ID);
585 myScript->AddPolyhedralVolume(ID, nodes_ids, quantities);
590 SMDS_MeshVolume* SMESHDS_Mesh::AddPolyhedralVolumeWithID
591 (std::vector<const SMDS_MeshNode*> nodes,
592 std::vector<int> quantities,
595 SMDS_MeshVolume *anElem = SMDS_Mesh::AddPolyhedralVolumeWithID(nodes, quantities, ID);
597 int i, len = nodes.size();
598 std::vector<int> nodes_ids (len);
599 for (i = 0; i < len; i++) {
600 nodes_ids[i] = nodes[i]->GetID();
602 myScript->AddPolyhedralVolume(ID, nodes_ids, quantities);
607 SMDS_MeshVolume* SMESHDS_Mesh::AddPolyhedralVolume
608 (std::vector<const SMDS_MeshNode*> nodes,
609 std::vector<int> quantities)
611 SMDS_MeshVolume *anElem = SMDS_Mesh::AddPolyhedralVolume(nodes, quantities);
613 int i, len = nodes.size();
614 std::vector<int> nodes_ids (len);
615 for (i = 0; i < len; i++) {
616 nodes_ids[i] = nodes[i]->GetID();
618 myScript->AddPolyhedralVolume(anElem->GetID(), nodes_ids, quantities);
623 //=======================================================================
624 //function : removeFromContainers
626 //=======================================================================
628 static void removeFromContainers (map<int,SMESHDS_SubMesh*>& theSubMeshes,
629 set<SMESHDS_GroupBase*>& theGroups,
630 list<const SMDS_MeshElement*>& theElems,
633 if ( theElems.empty() )
637 // Element can belong to several groups
638 if ( !theGroups.empty() )
640 set<SMESHDS_GroupBase*>::iterator GrIt = theGroups.begin();
641 for ( ; GrIt != theGroups.end(); GrIt++ )
643 SMESHDS_Group* group = dynamic_cast<SMESHDS_Group*>( *GrIt );
644 if ( !group || group->IsEmpty() ) continue;
646 list<const SMDS_MeshElement *>::iterator elIt = theElems.begin();
647 for ( ; elIt != theElems.end(); elIt++ )
649 group->SMDSGroup().Remove( *elIt );
650 if ( group->IsEmpty() ) break;
655 const bool deleted=true;
657 // Rm from sub-meshes
658 // Element should belong to only one sub-mesh
659 map<int,SMESHDS_SubMesh*>::iterator SubIt = theSubMeshes.begin();
660 for ( ; SubIt != theSubMeshes.end(); SubIt++ )
662 int size = isNode ? (*SubIt).second->NbNodes() : (*SubIt).second->NbElements();
663 if ( size == 0 ) continue;
665 list<const SMDS_MeshElement *>::iterator elIt = theElems.begin();
666 while ( elIt != theElems.end() )
668 bool removed = false;
670 removed = (*SubIt).second->RemoveNode( static_cast<const SMDS_MeshNode*> (*elIt), deleted );
672 removed = (*SubIt).second->RemoveElement( *elIt, deleted );
676 elIt = theElems.erase( elIt );
677 if ( theElems.empty() )
678 return; // all elements are found and removed
688 //=======================================================================
689 //function : RemoveNode
691 //=======================================================================
692 void SMESHDS_Mesh::RemoveNode(const SMDS_MeshNode * n)
694 if ( n->NbInverseElements() == 0 && !(hasConstructionEdges() || hasConstructionFaces()))
696 SMESHDS_SubMesh* subMesh=0;
697 map<int,SMESHDS_SubMesh*>::iterator SubIt =
698 myShapeIndexToSubMesh.find( n->GetPosition()->GetShapeId() );
699 if ( SubIt != myShapeIndexToSubMesh.end() )
700 subMesh = SubIt->second;
702 SubIt = myShapeIndexToSubMesh.begin();
703 for ( ; !subMesh && SubIt != myShapeIndexToSubMesh.end(); SubIt++ )
704 if ( SubIt->second->Contains( n ))
705 subMesh = SubIt->second;
707 RemoveFreeNode( n, subMesh, true);
711 myScript->RemoveNode(n->GetID());
713 list<const SMDS_MeshElement *> removedElems;
714 list<const SMDS_MeshElement *> removedNodes;
716 SMDS_Mesh::RemoveElement( n, removedElems, removedNodes, true );
718 removeFromContainers( myShapeIndexToSubMesh, myGroups, removedElems, false );
719 removeFromContainers( myShapeIndexToSubMesh, myGroups, removedNodes, true );
722 //=======================================================================
723 //function : RemoveFreeNode
725 //=======================================================================
726 void SMESHDS_Mesh::RemoveFreeNode(const SMDS_MeshNode * n,
727 SMESHDS_SubMesh * subMesh,
730 myScript->RemoveNode(n->GetID());
733 // Node can belong to several groups
734 if (fromGroups && !myGroups.empty()) {
735 set<SMESHDS_GroupBase*>::iterator GrIt = myGroups.begin();
736 for (; GrIt != myGroups.end(); GrIt++) {
737 SMESHDS_Group* group = dynamic_cast<SMESHDS_Group*>(*GrIt);
738 if (!group || group->IsEmpty()) continue;
739 group->SMDSGroup().Remove(n);
744 // Node should belong to only one sub-mesh
746 subMesh->RemoveNode(n,/*deleted=*/false);
748 SMDS_Mesh::RemoveFreeElement(n);
751 //=======================================================================
752 //function : RemoveElement
754 //========================================================================
755 void SMESHDS_Mesh::RemoveElement(const SMDS_MeshElement * elt)
757 if (elt->GetType() == SMDSAbs_Node)
759 RemoveNode( static_cast<const SMDS_MeshNode*>( elt ));
762 if (!hasConstructionEdges() && !hasConstructionFaces())
764 SMESHDS_SubMesh* subMesh=0;
765 map<int,SMESHDS_SubMesh*>::iterator SubIt = myShapeIndexToSubMesh.begin();
766 for ( ; !subMesh && SubIt != myShapeIndexToSubMesh.end(); SubIt++ )
767 if ( SubIt->second->Contains( elt ))
768 subMesh = SubIt->second;
770 RemoveFreeElement( elt, subMesh, true);
774 myScript->RemoveElement(elt->GetID());
776 list<const SMDS_MeshElement *> removedElems;
777 list<const SMDS_MeshElement *> removedNodes;
779 SMDS_Mesh::RemoveElement(elt, removedElems, removedNodes, false);
781 removeFromContainers( myShapeIndexToSubMesh, myGroups, removedElems, false );
784 //=======================================================================
785 //function : RemoveFreeElement
787 //========================================================================
788 void SMESHDS_Mesh::RemoveFreeElement(const SMDS_MeshElement * elt,
789 SMESHDS_SubMesh * subMesh,
792 if (elt->GetType() == SMDSAbs_Node) {
793 RemoveFreeNode( static_cast<const SMDS_MeshNode*>(elt), subMesh);
797 if (hasConstructionEdges() || hasConstructionFaces())
798 // this methods is only for meshes without descendants
801 myScript->RemoveElement(elt->GetID());
804 // Node can belong to several groups
805 if ( fromGroups && !myGroups.empty() ) {
806 set<SMESHDS_GroupBase*>::iterator GrIt = myGroups.begin();
807 for (; GrIt != myGroups.end(); GrIt++) {
808 SMESHDS_Group* group = dynamic_cast<SMESHDS_Group*>(*GrIt);
809 if (group && !group->IsEmpty())
810 group->SMDSGroup().Remove(elt);
815 // Element should belong to only one sub-mesh
817 subMesh->RemoveElement(elt, /*deleted=*/false);
819 SMDS_Mesh::RemoveFreeElement(elt);
822 //================================================================================
824 * \brief Remove all data from the mesh
826 //================================================================================
828 void SMESHDS_Mesh::ClearMesh()
830 myScript->ClearMesh();
834 map<int,SMESHDS_SubMesh*>::iterator sub, subEnd = myShapeIndexToSubMesh.end();
835 for ( sub = myShapeIndexToSubMesh.begin(); sub != subEnd; ++sub )
836 sub->second->Clear();
839 TGroups::iterator group, groupEnd = myGroups.end();
840 for ( group = myGroups.begin(); group != groupEnd; ++group ) {
841 if ( SMESHDS_Group* g = dynamic_cast<SMESHDS_Group*>(*group)) {
842 SMDSAbs_ElementType groupType = g->GetType();
844 g->SetType( groupType );
849 //================================================================================
851 * \brief return submesh by shape
852 * \param shape - the subshape
853 * \retval SMESHDS_SubMesh* - the found submesh
855 * search of submeshes is optimized
857 //================================================================================
859 SMESHDS_SubMesh* SMESHDS_Mesh::getSubmesh( const TopoDS_Shape & shape )
861 if ( shape.IsNull() )
864 if ( !myCurSubShape.IsNull() && shape.IsSame( myCurSubShape ))
867 getSubmesh( ShapeToIndex( shape ));
868 myCurSubShape = shape;
872 //================================================================================
874 * \brief return submesh by subshape index
875 * \param Index - the subshape index
876 * \retval SMESHDS_SubMesh* - the found submesh
877 * search of submeshes is optimized
879 //================================================================================
881 SMESHDS_SubMesh* SMESHDS_Mesh::getSubmesh( const int Index )
883 //Update or build submesh
884 if ( Index != myCurSubID ) {
885 map<int,SMESHDS_SubMesh*>::iterator it = myShapeIndexToSubMesh.find( Index );
886 if ( it == myShapeIndexToSubMesh.end() )
887 it = myShapeIndexToSubMesh.insert( make_pair(Index, new SMESHDS_SubMesh() )).first;
888 myCurSubMesh = it->second;
890 myCurSubShape.Nullify(); // myCurSubShape no more corresponds to submesh
895 //================================================================================
897 * \brief Add element or node to submesh
898 * \param elem - element to add
899 * \param subMesh - submesh to be filled in
901 //================================================================================
903 bool SMESHDS_Mesh::add(const SMDS_MeshElement* elem, SMESHDS_SubMesh* subMesh )
905 if ( elem && subMesh ) {
906 if ( elem->GetType() == SMDSAbs_Node )
907 subMesh->AddNode( static_cast<const SMDS_MeshNode* >( elem ));
909 subMesh->AddElement( elem );
917 //================================================================================
919 * \brief Creates a node position in volume
921 //================================================================================
923 inline SMDS_PositionPtr volumePosition(int volId)
925 SMDS_SpacePosition* pos = new SMDS_SpacePosition();
926 pos->SetShapeId( volId );
927 return SMDS_PositionPtr(pos);
931 //=======================================================================
932 //function : SetNodeOnVolume
934 //=======================================================================
935 void SMESHDS_Mesh::SetNodeInVolume(SMDS_MeshNode * aNode,
936 const TopoDS_Shell & S)
938 if ( add( aNode, getSubmesh(S) ))
939 aNode->SetPosition ( volumePosition( myCurSubID ));
941 //=======================================================================
942 //function : SetNodeOnVolume
944 //=======================================================================
945 void SMESHDS_Mesh::SetNodeInVolume(SMDS_MeshNode * aNode,
946 const TopoDS_Solid & S)
948 if ( add( aNode, getSubmesh(S) ))
949 aNode->SetPosition ( volumePosition( myCurSubID ));
952 //=======================================================================
953 //function : SetNodeOnFace
955 //=======================================================================
956 void SMESHDS_Mesh::SetNodeOnFace(SMDS_MeshNode * aNode,
957 const TopoDS_Face & S,
961 if ( add( aNode, getSubmesh(S) ))
962 aNode->SetPosition(SMDS_PositionPtr(new SMDS_FacePosition(myCurSubID, u, v)));
965 //=======================================================================
966 //function : SetNodeOnEdge
968 //=======================================================================
969 void SMESHDS_Mesh::SetNodeOnEdge(SMDS_MeshNode * aNode,
970 const TopoDS_Edge & S,
973 if ( add( aNode, getSubmesh(S) ))
974 aNode->SetPosition(SMDS_PositionPtr(new SMDS_EdgePosition(myCurSubID, u)));
977 //=======================================================================
978 //function : SetNodeOnVertex
980 //=======================================================================
981 void SMESHDS_Mesh::SetNodeOnVertex(SMDS_MeshNode * aNode,
982 const TopoDS_Vertex & S)
984 if ( add( aNode, getSubmesh(S) ))
985 aNode->SetPosition(SMDS_PositionPtr(new SMDS_VertexPosition(myCurSubID)));
988 //=======================================================================
989 //function : UnSetNodeOnShape
991 //=======================================================================
992 void SMESHDS_Mesh::UnSetNodeOnShape(const SMDS_MeshNode* aNode)
994 if ( aNode && aNode->GetPosition() ) {
995 map<int,SMESHDS_SubMesh*>::iterator it =
996 myShapeIndexToSubMesh.find( aNode->GetPosition()->GetShapeId() );
997 if ( it != myShapeIndexToSubMesh.end() )
998 it->second->RemoveNode( aNode, /*deleted=*/false );
1002 //=======================================================================
1003 //function : SetMeshElementOnShape
1005 //=======================================================================
1006 void SMESHDS_Mesh::SetMeshElementOnShape(const SMDS_MeshElement * anElement,
1007 const TopoDS_Shape & S)
1009 add( anElement, getSubmesh(S) );
1012 //=======================================================================
1013 //function : UnSetMeshElementOnShape
1015 //=======================================================================
1016 void SMESHDS_Mesh::UnSetMeshElementOnShape(const SMDS_MeshElement * elem,
1017 const TopoDS_Shape & S)
1019 int Index = myIndexToShape.FindIndex(S);
1021 map<int,SMESHDS_SubMesh*>::iterator it = myShapeIndexToSubMesh.find( Index );
1022 if ( it != myShapeIndexToSubMesh.end() )
1023 if ( elem->GetType() == SMDSAbs_Node )
1024 it->second->RemoveNode( static_cast<const SMDS_MeshNode* >( elem ), /*deleted=*/false );
1026 it->second->RemoveElement( elem, /*deleted=*/false );
1029 //=======================================================================
1030 //function : ShapeToMesh
1032 //=======================================================================
1033 TopoDS_Shape SMESHDS_Mesh::ShapeToMesh() const
1038 //=======================================================================
1039 //function : IsGroupOfSubShapes
1040 //purpose : return true if at least one subshape of theShape is a subshape
1041 // of myShape or theShape == myShape
1042 //=======================================================================
1044 bool SMESHDS_Mesh::IsGroupOfSubShapes (const TopoDS_Shape& theShape) const
1046 if ( myShape.IsSame( theShape ))
1049 for ( TopoDS_Iterator it( theShape ); it.More(); it.Next() ) {
1050 if (myIndexToShape.Contains( it.Value() ) ||
1051 IsGroupOfSubShapes( it.Value() ))
1058 ///////////////////////////////////////////////////////////////////////////////
1059 /// Return the sub mesh linked to the a given TopoDS_Shape or NULL if the given
1060 /// TopoDS_Shape is unknown
1061 ///////////////////////////////////////////////////////////////////////////////
1062 SMESHDS_SubMesh * SMESHDS_Mesh::MeshElements(const TopoDS_Shape & S) const
1064 int Index = ShapeToIndex(S);
1065 TShapeIndexToSubMesh::const_iterator anIter = myShapeIndexToSubMesh.find(Index);
1066 if (anIter != myShapeIndexToSubMesh.end())
1067 return anIter->second;
1072 ///////////////////////////////////////////////////////////////////////////////
1073 /// Return the sub mesh by Id of shape it is linked to
1074 ///////////////////////////////////////////////////////////////////////////////
1075 SMESHDS_SubMesh * SMESHDS_Mesh::MeshElements(const int Index)
1077 TShapeIndexToSubMesh::const_iterator anIter = myShapeIndexToSubMesh.find(Index);
1078 if (anIter != myShapeIndexToSubMesh.end())
1079 return anIter->second;
1084 //=======================================================================
1085 //function : SubMeshIndices
1087 //=======================================================================
1088 list<int> SMESHDS_Mesh::SubMeshIndices()
1090 list<int> anIndices;
1091 std::map<int,SMESHDS_SubMesh*>::iterator anIter = myShapeIndexToSubMesh.begin();
1092 for (; anIter != myShapeIndexToSubMesh.end(); anIter++) {
1093 anIndices.push_back((*anIter).first);
1098 //=======================================================================
1099 //function : GetHypothesis
1101 //=======================================================================
1103 const list<const SMESHDS_Hypothesis*>&
1104 SMESHDS_Mesh::GetHypothesis(const TopoDS_Shape & S) const
1106 if ( myShapeToHypothesis.IsBound( S.Oriented(TopAbs_FORWARD) ) ) // ignore orientation of S
1107 return myShapeToHypothesis.Find( S.Oriented(TopAbs_FORWARD) );
1109 static list<const SMESHDS_Hypothesis*> empty;
1113 //=======================================================================
1114 //function : GetScript
1116 //=======================================================================
1117 SMESHDS_Script* SMESHDS_Mesh::GetScript()
1122 //=======================================================================
1123 //function : ClearScript
1125 //=======================================================================
1126 void SMESHDS_Mesh::ClearScript()
1131 //=======================================================================
1132 //function : HasMeshElements
1134 //=======================================================================
1135 bool SMESHDS_Mesh::HasMeshElements(const TopoDS_Shape & S)
1137 if (myShape.IsNull()) MESSAGE("myShape is NULL");
1138 int Index = myIndexToShape.FindIndex(S);
1139 return myShapeIndexToSubMesh.find(Index)!=myShapeIndexToSubMesh.end();
1142 //=======================================================================
1143 //function : HasHypothesis
1145 //=======================================================================
1146 bool SMESHDS_Mesh::HasHypothesis(const TopoDS_Shape & S)
1148 return myShapeToHypothesis.IsBound(S.Oriented(TopAbs_FORWARD));
1151 //=======================================================================
1152 //function : NewSubMesh
1154 //=======================================================================
1155 SMESHDS_SubMesh * SMESHDS_Mesh::NewSubMesh(int Index)
1157 SMESHDS_SubMesh* SM = 0;
1158 TShapeIndexToSubMesh::iterator anIter = myShapeIndexToSubMesh.find(Index);
1159 if (anIter == myShapeIndexToSubMesh.end())
1161 SM = new SMESHDS_SubMesh();
1162 myShapeIndexToSubMesh[Index]=SM;
1165 SM = anIter->second;
1169 //=======================================================================
1170 //function : AddCompoundSubmesh
1172 //=======================================================================
1174 int SMESHDS_Mesh::AddCompoundSubmesh(const TopoDS_Shape& S,
1175 TopAbs_ShapeEnum type)
1178 if ( IsGroupOfSubShapes( S ) || (S.ShapeType() == TopAbs_VERTEX && myIndexToShape.Contains(S)) )
1180 aMainIndex = myIndexToShape.Add( S );
1181 bool all = ( type == TopAbs_SHAPE );
1182 if ( all ) // corresponding simple submesh may exist
1183 aMainIndex = -aMainIndex;
1184 //MESSAGE("AddCompoundSubmesh index = " << aMainIndex );
1185 SMESHDS_SubMesh * aNewSub = NewSubMesh( aMainIndex );
1186 if ( !aNewSub->IsComplexSubmesh() ) // is empty
1188 int shapeType = Max( TopAbs_SOLID, all ? myShape.ShapeType() : type );
1189 int typeLimit = all ? TopAbs_VERTEX : type;
1190 for ( ; shapeType <= typeLimit; shapeType++ )
1192 TopExp_Explorer exp( S, TopAbs_ShapeEnum( shapeType ));
1193 for ( ; exp.More(); exp.Next() )
1195 int index = myIndexToShape.FindIndex( exp.Current() );
1197 aNewSub->AddSubMesh( NewSubMesh( index ));
1205 //=======================================================================
1206 //function : IndexToShape
1208 //=======================================================================
1209 const TopoDS_Shape& SMESHDS_Mesh::IndexToShape(int ShapeIndex) const
1211 return myIndexToShape.FindKey(ShapeIndex);
1214 //=======================================================================
1215 //function : ShapeToIndex
1217 //=======================================================================
1218 int SMESHDS_Mesh::ShapeToIndex(const TopoDS_Shape & S) const
1220 if (myShape.IsNull())
1221 MESSAGE("myShape is NULL");
1223 int index = myIndexToShape.FindIndex(S);
1228 //=======================================================================
1229 //function : SetNodeOnVolume
1231 //=======================================================================
1232 void SMESHDS_Mesh::SetNodeInVolume(const SMDS_MeshNode* aNode, int Index)
1234 if ( add( aNode, getSubmesh( Index )))
1235 ((SMDS_MeshNode*) aNode)->SetPosition( volumePosition( Index ));
1238 //=======================================================================
1239 //function : SetNodeOnFace
1241 //=======================================================================
1242 void SMESHDS_Mesh::SetNodeOnFace(SMDS_MeshNode* aNode, int Index, double u, double v)
1244 //Set Position on Node
1245 if ( add( aNode, getSubmesh( Index )))
1246 aNode->SetPosition(SMDS_PositionPtr(new SMDS_FacePosition(Index, u, v)));
1249 //=======================================================================
1250 //function : SetNodeOnEdge
1252 //=======================================================================
1253 void SMESHDS_Mesh::SetNodeOnEdge(SMDS_MeshNode* aNode,
1257 //Set Position on Node
1258 if ( add( aNode, getSubmesh( Index )))
1259 aNode->SetPosition(SMDS_PositionPtr(new SMDS_EdgePosition(Index, u)));
1262 //=======================================================================
1263 //function : SetNodeOnVertex
1265 //=======================================================================
1266 void SMESHDS_Mesh::SetNodeOnVertex(SMDS_MeshNode* aNode, int Index)
1268 //Set Position on Node
1269 if ( add( aNode, getSubmesh( Index )))
1270 aNode->SetPosition(SMDS_PositionPtr(new SMDS_VertexPosition(Index)));
1273 //=======================================================================
1274 //function : SetMeshElementOnShape
1276 //=======================================================================
1277 void SMESHDS_Mesh::SetMeshElementOnShape(const SMDS_MeshElement* anElement,
1280 add( anElement, getSubmesh( Index ));
1283 //=======================================================================
1284 //function : ~SMESHDS_Mesh
1286 //=======================================================================
1287 SMESHDS_Mesh::~SMESHDS_Mesh()
1292 TShapeIndexToSubMesh::iterator i_sm = myShapeIndexToSubMesh.begin();
1293 for ( ; i_sm != myShapeIndexToSubMesh.end(); ++i_sm )
1294 delete i_sm->second;
1298 //********************************************************************
1299 //********************************************************************
1300 //******** *********
1301 //***** Methods for addition of quadratic elements ******
1302 //******** *********
1303 //********************************************************************
1304 //********************************************************************
1306 //=======================================================================
1307 //function : AddEdgeWithID
1309 //=======================================================================
1310 SMDS_MeshEdge* SMESHDS_Mesh::AddEdgeWithID(int n1, int n2, int n12, int ID)
1312 SMDS_MeshEdge* anElem = SMDS_Mesh::AddEdgeWithID(n1,n2,n12,ID);
1313 if(anElem) myScript->AddEdge(ID,n1,n2,n12);
1317 //=======================================================================
1318 //function : AddEdge
1320 //=======================================================================
1321 SMDS_MeshEdge* SMESHDS_Mesh::AddEdge(const SMDS_MeshNode* n1,
1322 const SMDS_MeshNode* n2,
1323 const SMDS_MeshNode* n12)
1325 SMDS_MeshEdge* anElem = SMDS_Mesh::AddEdge(n1,n2,n12);
1326 if(anElem) myScript->AddEdge(anElem->GetID(),
1333 //=======================================================================
1334 //function : AddEdgeWithID
1336 //=======================================================================
1337 SMDS_MeshEdge* SMESHDS_Mesh::AddEdgeWithID(const SMDS_MeshNode * n1,
1338 const SMDS_MeshNode * n2,
1339 const SMDS_MeshNode * n12,
1342 return AddEdgeWithID(n1->GetID(),
1349 //=======================================================================
1350 //function : AddFace
1352 //=======================================================================
1353 SMDS_MeshFace* SMESHDS_Mesh::AddFace(const SMDS_MeshNode * n1,
1354 const SMDS_MeshNode * n2,
1355 const SMDS_MeshNode * n3,
1356 const SMDS_MeshNode * n12,
1357 const SMDS_MeshNode * n23,
1358 const SMDS_MeshNode * n31)
1360 SMDS_MeshFace *anElem = SMDS_Mesh::AddFace(n1,n2,n3,n12,n23,n31);
1361 if(anElem) myScript->AddFace(anElem->GetID(),
1362 n1->GetID(), n2->GetID(), n3->GetID(),
1363 n12->GetID(), n23->GetID(), n31->GetID());
1367 //=======================================================================
1368 //function : AddFaceWithID
1370 //=======================================================================
1371 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(int n1, int n2, int n3,
1372 int n12,int n23,int n31, int ID)
1374 SMDS_MeshFace *anElem = SMDS_Mesh::AddFaceWithID(n1,n2,n3,n12,n23,n31,ID);
1375 if(anElem) myScript->AddFace(ID,n1,n2,n3,n12,n23,n31);
1379 //=======================================================================
1380 //function : AddFaceWithID
1382 //=======================================================================
1383 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(const SMDS_MeshNode * n1,
1384 const SMDS_MeshNode * n2,
1385 const SMDS_MeshNode * n3,
1386 const SMDS_MeshNode * n12,
1387 const SMDS_MeshNode * n23,
1388 const SMDS_MeshNode * n31,
1391 return AddFaceWithID(n1->GetID(), n2->GetID(), n3->GetID(),
1392 n12->GetID(), n23->GetID(), n31->GetID(),
1397 //=======================================================================
1398 //function : AddFace
1400 //=======================================================================
1401 SMDS_MeshFace* SMESHDS_Mesh::AddFace(const SMDS_MeshNode * n1,
1402 const SMDS_MeshNode * n2,
1403 const SMDS_MeshNode * n3,
1404 const SMDS_MeshNode * n4,
1405 const SMDS_MeshNode * n12,
1406 const SMDS_MeshNode * n23,
1407 const SMDS_MeshNode * n34,
1408 const SMDS_MeshNode * n41)
1410 SMDS_MeshFace *anElem = SMDS_Mesh::AddFace(n1,n2,n3,n4,n12,n23,n34,n41);
1411 if(anElem) myScript->AddFace(anElem->GetID(),
1412 n1->GetID(), n2->GetID(), n3->GetID(), n4->GetID(),
1413 n12->GetID(), n23->GetID(), n34->GetID(), n41->GetID());
1417 //=======================================================================
1418 //function : AddFaceWithID
1420 //=======================================================================
1421 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(int n1, int n2, int n3, int n4,
1422 int n12,int n23,int n34,int n41, int ID)
1424 SMDS_MeshFace *anElem = SMDS_Mesh::AddFaceWithID(n1,n2,n3,n4,n12,n23,n34,n41,ID);
1425 if(anElem) myScript->AddFace(ID,n1,n2,n3,n4,n12,n23,n34,n41);
1429 //=======================================================================
1430 //function : AddFaceWithID
1432 //=======================================================================
1433 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(const SMDS_MeshNode * n1,
1434 const SMDS_MeshNode * n2,
1435 const SMDS_MeshNode * n3,
1436 const SMDS_MeshNode * n4,
1437 const SMDS_MeshNode * n12,
1438 const SMDS_MeshNode * n23,
1439 const SMDS_MeshNode * n34,
1440 const SMDS_MeshNode * n41,
1443 return AddFaceWithID(n1->GetID(), n2->GetID(), n3->GetID(), n4->GetID(),
1444 n12->GetID(), n23->GetID(), n34->GetID(), n41->GetID(),
1449 //=======================================================================
1450 //function : AddVolume
1452 //=======================================================================
1453 SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
1454 const SMDS_MeshNode * n2,
1455 const SMDS_MeshNode * n3,
1456 const SMDS_MeshNode * n4,
1457 const SMDS_MeshNode * n12,
1458 const SMDS_MeshNode * n23,
1459 const SMDS_MeshNode * n31,
1460 const SMDS_MeshNode * n14,
1461 const SMDS_MeshNode * n24,
1462 const SMDS_MeshNode * n34)
1464 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1,n2,n3,n4,n12,n23,n31,n14,n24,n34);
1465 if(anElem) myScript->AddVolume(anElem->GetID(),
1466 n1->GetID(), n2->GetID(), n3->GetID(), n4->GetID(),
1467 n12->GetID(), n23->GetID(), n31->GetID(),
1468 n14->GetID(), n24->GetID(), n34->GetID());
1472 //=======================================================================
1473 //function : AddVolumeWithID
1475 //=======================================================================
1476 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3, int n4,
1477 int n12,int n23,int n31,
1478 int n14,int n24,int n34, int ID)
1480 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolumeWithID(n1,n2,n3,n4,n12,n23,
1481 n31,n14,n24,n34,ID);
1482 if(anElem) myScript->AddVolume(ID,n1,n2,n3,n4,n12,n23,n31,n14,n24,n34);
1486 //=======================================================================
1487 //function : AddVolumeWithID
1488 //purpose : 2d order tetrahedron of 10 nodes
1489 //=======================================================================
1490 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
1491 const SMDS_MeshNode * n2,
1492 const SMDS_MeshNode * n3,
1493 const SMDS_MeshNode * n4,
1494 const SMDS_MeshNode * n12,
1495 const SMDS_MeshNode * n23,
1496 const SMDS_MeshNode * n31,
1497 const SMDS_MeshNode * n14,
1498 const SMDS_MeshNode * n24,
1499 const SMDS_MeshNode * n34,
1502 return AddVolumeWithID(n1->GetID(), n2->GetID(), n3->GetID(), n4->GetID(),
1503 n12->GetID(), n23->GetID(), n31->GetID(),
1504 n14->GetID(), n24->GetID(), n34->GetID(), ID);
1508 //=======================================================================
1509 //function : AddVolume
1511 //=======================================================================
1512 SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
1513 const SMDS_MeshNode * n2,
1514 const SMDS_MeshNode * n3,
1515 const SMDS_MeshNode * n4,
1516 const SMDS_MeshNode * n5,
1517 const SMDS_MeshNode * n12,
1518 const SMDS_MeshNode * n23,
1519 const SMDS_MeshNode * n34,
1520 const SMDS_MeshNode * n41,
1521 const SMDS_MeshNode * n15,
1522 const SMDS_MeshNode * n25,
1523 const SMDS_MeshNode * n35,
1524 const SMDS_MeshNode * n45)
1526 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1,n2,n3,n4,n5,n12,n23,n34,n41,
1529 myScript->AddVolume(anElem->GetID(), n1->GetID(), n2->GetID(),
1530 n3->GetID(), n4->GetID(), n5->GetID(),
1531 n12->GetID(), n23->GetID(), n34->GetID(), n41->GetID(),
1532 n15->GetID(), n25->GetID(), n35->GetID(), n45->GetID());
1536 //=======================================================================
1537 //function : AddVolumeWithID
1539 //=======================================================================
1540 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3, int n4, int n5,
1541 int n12,int n23,int n34,int n41,
1542 int n15,int n25,int n35,int n45, int ID)
1544 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolumeWithID(n1,n2,n3,n4,n5,
1546 n15,n25,n35,n45,ID);
1547 if(anElem) myScript->AddVolume(ID,n1,n2,n3,n4,n5,n12,n23,n34,n41,
1552 //=======================================================================
1553 //function : AddVolumeWithID
1554 //purpose : 2d order pyramid of 13 nodes
1555 //=======================================================================
1556 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
1557 const SMDS_MeshNode * n2,
1558 const SMDS_MeshNode * n3,
1559 const SMDS_MeshNode * n4,
1560 const SMDS_MeshNode * n5,
1561 const SMDS_MeshNode * n12,
1562 const SMDS_MeshNode * n23,
1563 const SMDS_MeshNode * n34,
1564 const SMDS_MeshNode * n41,
1565 const SMDS_MeshNode * n15,
1566 const SMDS_MeshNode * n25,
1567 const SMDS_MeshNode * n35,
1568 const SMDS_MeshNode * n45,
1571 return AddVolumeWithID(n1->GetID(), n2->GetID(), n3->GetID(),
1572 n4->GetID(), n5->GetID(),
1573 n12->GetID(), n23->GetID(), n34->GetID(), n41->GetID(),
1574 n15->GetID(), n25->GetID(), n35->GetID(), n45->GetID(),
1579 //=======================================================================
1580 //function : AddVolume
1582 //=======================================================================
1583 SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
1584 const SMDS_MeshNode * n2,
1585 const SMDS_MeshNode * n3,
1586 const SMDS_MeshNode * n4,
1587 const SMDS_MeshNode * n5,
1588 const SMDS_MeshNode * n6,
1589 const SMDS_MeshNode * n12,
1590 const SMDS_MeshNode * n23,
1591 const SMDS_MeshNode * n31,
1592 const SMDS_MeshNode * n45,
1593 const SMDS_MeshNode * n56,
1594 const SMDS_MeshNode * n64,
1595 const SMDS_MeshNode * n14,
1596 const SMDS_MeshNode * n25,
1597 const SMDS_MeshNode * n36)
1599 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1,n2,n3,n4,n5,n6,n12,n23,n31,
1600 n45,n56,n64,n14,n25,n36);
1602 myScript->AddVolume(anElem->GetID(), n1->GetID(), n2->GetID(),
1603 n3->GetID(), n4->GetID(), n5->GetID(), n6->GetID(),
1604 n12->GetID(), n23->GetID(), n31->GetID(),
1605 n45->GetID(), n56->GetID(), n64->GetID(),
1606 n14->GetID(), n25->GetID(), n36->GetID());
1610 //=======================================================================
1611 //function : AddVolumeWithID
1613 //=======================================================================
1614 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3,
1615 int n4, int n5, int n6,
1616 int n12,int n23,int n31,
1617 int n45,int n56,int n64,
1618 int n14,int n25,int n36, int ID)
1620 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolumeWithID(n1,n2,n3,n4,n5,n6,
1624 if(anElem) myScript->AddVolume(ID,n1,n2,n3,n4,n5,n6,n12,n23,n31,
1625 n45,n56,n64,n14,n25,n36);
1629 //=======================================================================
1630 //function : AddVolumeWithID
1631 //purpose : 2d order Pentahedron with 15 nodes
1632 //=======================================================================
1633 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
1634 const SMDS_MeshNode * n2,
1635 const SMDS_MeshNode * n3,
1636 const SMDS_MeshNode * n4,
1637 const SMDS_MeshNode * n5,
1638 const SMDS_MeshNode * n6,
1639 const SMDS_MeshNode * n12,
1640 const SMDS_MeshNode * n23,
1641 const SMDS_MeshNode * n31,
1642 const SMDS_MeshNode * n45,
1643 const SMDS_MeshNode * n56,
1644 const SMDS_MeshNode * n64,
1645 const SMDS_MeshNode * n14,
1646 const SMDS_MeshNode * n25,
1647 const SMDS_MeshNode * n36,
1650 return AddVolumeWithID(n1->GetID(), n2->GetID(), n3->GetID(),
1651 n4->GetID(), n5->GetID(), n6->GetID(),
1652 n12->GetID(), n23->GetID(), n31->GetID(),
1653 n45->GetID(), n56->GetID(), n64->GetID(),
1654 n14->GetID(), n25->GetID(), n36->GetID(),
1659 //=======================================================================
1660 //function : AddVolume
1662 //=======================================================================
1663 SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
1664 const SMDS_MeshNode * n2,
1665 const SMDS_MeshNode * n3,
1666 const SMDS_MeshNode * n4,
1667 const SMDS_MeshNode * n5,
1668 const SMDS_MeshNode * n6,
1669 const SMDS_MeshNode * n7,
1670 const SMDS_MeshNode * n8,
1671 const SMDS_MeshNode * n12,
1672 const SMDS_MeshNode * n23,
1673 const SMDS_MeshNode * n34,
1674 const SMDS_MeshNode * n41,
1675 const SMDS_MeshNode * n56,
1676 const SMDS_MeshNode * n67,
1677 const SMDS_MeshNode * n78,
1678 const SMDS_MeshNode * n85,
1679 const SMDS_MeshNode * n15,
1680 const SMDS_MeshNode * n26,
1681 const SMDS_MeshNode * n37,
1682 const SMDS_MeshNode * n48)
1684 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1,n2,n3,n4,n5,n6,n7,n8,
1689 myScript->AddVolume(anElem->GetID(), n1->GetID(), n2->GetID(),
1690 n3->GetID(), n4->GetID(), n5->GetID(),
1691 n6->GetID(), n7->GetID(), n8->GetID(),
1692 n12->GetID(), n23->GetID(), n34->GetID(), n41->GetID(),
1693 n56->GetID(), n67->GetID(), n78->GetID(), n85->GetID(),
1694 n15->GetID(), n26->GetID(), n37->GetID(), n48->GetID());
1698 //=======================================================================
1699 //function : AddVolumeWithID
1701 //=======================================================================
1702 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3, int n4,
1703 int n5, int n6, int n7, int n8,
1704 int n12,int n23,int n34,int n41,
1705 int n56,int n67,int n78,int n85,
1706 int n15,int n26,int n37,int n48, int ID)
1708 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolumeWithID(n1,n2,n3,n4,n5,n6,n7,n8,
1711 n15,n26,n37,n48,ID);
1712 if(anElem) myScript->AddVolume(ID,n1,n2,n3,n4,n5,n6,n7,n8,n12,n23,n34,n41,
1713 n56,n67,n78,n85,n15,n26,n37,n48);
1717 //=======================================================================
1718 //function : AddVolumeWithID
1719 //purpose : 2d order Hexahedrons with 20 nodes
1720 //=======================================================================
1721 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
1722 const SMDS_MeshNode * n2,
1723 const SMDS_MeshNode * n3,
1724 const SMDS_MeshNode * n4,
1725 const SMDS_MeshNode * n5,
1726 const SMDS_MeshNode * n6,
1727 const SMDS_MeshNode * n7,
1728 const SMDS_MeshNode * n8,
1729 const SMDS_MeshNode * n12,
1730 const SMDS_MeshNode * n23,
1731 const SMDS_MeshNode * n34,
1732 const SMDS_MeshNode * n41,
1733 const SMDS_MeshNode * n56,
1734 const SMDS_MeshNode * n67,
1735 const SMDS_MeshNode * n78,
1736 const SMDS_MeshNode * n85,
1737 const SMDS_MeshNode * n15,
1738 const SMDS_MeshNode * n26,
1739 const SMDS_MeshNode * n37,
1740 const SMDS_MeshNode * n48,
1743 return AddVolumeWithID(n1->GetID(), n2->GetID(), n3->GetID(), n4->GetID(),
1744 n5->GetID(), n6->GetID(), n7->GetID(), n8->GetID(),
1745 n12->GetID(), n23->GetID(), n34->GetID(), n41->GetID(),
1746 n56->GetID(), n67->GetID(), n78->GetID(), n85->GetID(),
1747 n15->GetID(), n26->GetID(), n37->GetID(), n48->GetID(),