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 TShapeIndexToSubMesh::iterator i_sm = myShapeIndexToSubMesh.begin();
91 for ( ; i_sm != myShapeIndexToSubMesh.end(); ++i_sm )
93 myShapeIndexToSubMesh.clear();
94 myIndexToShape.Clear();
95 // - groups on geometry
96 set<SMESHDS_GroupBase*>::iterator gr = myGroups.begin();
97 while ( gr != myGroups.end() ) {
98 if ( dynamic_cast<SMESHDS_GroupOnGeom*>( *gr ))
99 myGroups.erase( gr++ );
107 TopExp::MapShapes(myShape, myIndexToShape);
111 //=======================================================================
112 //function : AddHypothesis
114 //=======================================================================
116 bool SMESHDS_Mesh::AddHypothesis(const TopoDS_Shape & SS,
117 const SMESHDS_Hypothesis * H)
119 if (!myShapeToHypothesis.IsBound(SS.Oriented(TopAbs_FORWARD))) {
120 list<const SMESHDS_Hypothesis *> aList;
121 myShapeToHypothesis.Bind(SS.Oriented(TopAbs_FORWARD), aList);
123 list<const SMESHDS_Hypothesis *>& alist =
124 myShapeToHypothesis(SS.Oriented(TopAbs_FORWARD)); // ignore orientation of SS
126 //Check if the Hypothesis is still present
127 list<const SMESHDS_Hypothesis*>::iterator ith = find(alist.begin(),alist.end(), H );
129 if (alist.end() != ith) return false;
135 //=======================================================================
136 //function : RemoveHypothesis
138 //=======================================================================
140 bool SMESHDS_Mesh::RemoveHypothesis(const TopoDS_Shape & S,
141 const SMESHDS_Hypothesis * H)
143 if( myShapeToHypothesis.IsBound( S.Oriented(TopAbs_FORWARD) ) )
145 list<const SMESHDS_Hypothesis *>& alist=myShapeToHypothesis.ChangeFind( S.Oriented(TopAbs_FORWARD) );
146 list<const SMESHDS_Hypothesis*>::iterator ith=find(alist.begin(),alist.end(), H );
147 if (ith != alist.end())
156 //=======================================================================
159 //=======================================================================
160 SMDS_MeshNode* SMESHDS_Mesh::AddNode(double x, double y, double z){
161 SMDS_MeshNode* node = SMDS_Mesh::AddNode(x, y, z);
162 if(node!=NULL) myScript->AddNode(node->GetID(), x, y, z);
166 SMDS_MeshNode* SMESHDS_Mesh::AddNodeWithID(double x, double y, double z, int ID){
167 SMDS_MeshNode* node = SMDS_Mesh::AddNodeWithID(x,y,z,ID);
168 if(node!=NULL) myScript->AddNode(node->GetID(), x, y, z);
172 //=======================================================================
173 //function : MoveNode
175 //=======================================================================
176 void SMESHDS_Mesh::MoveNode(const SMDS_MeshNode *n, double x, double y, double z)
178 SMDS_MeshNode * node=const_cast<SMDS_MeshNode*>(n);
180 myScript->MoveNode(n->GetID(), x, y, z);
183 //=======================================================================
184 //function : ChangeElementNodes
186 //=======================================================================
188 bool SMESHDS_Mesh::ChangeElementNodes(const SMDS_MeshElement * elem,
189 const SMDS_MeshNode * nodes[],
192 if ( ! SMDS_Mesh::ChangeElementNodes( elem, nodes, nbnodes ))
195 vector<int> IDs( nbnodes );
196 for ( int i = 0; i < nbnodes; i++ )
197 IDs [ i ] = nodes[ i ]->GetID();
198 myScript->ChangeElementNodes( elem->GetID(), &IDs[0], nbnodes);
203 //=======================================================================
204 //function : ChangePolygonNodes
206 //=======================================================================
207 bool SMESHDS_Mesh::ChangePolygonNodes
208 (const SMDS_MeshElement * elem,
209 vector<const SMDS_MeshNode*> nodes)
211 ASSERT(nodes.size() > 3);
213 return ChangeElementNodes(elem, &nodes[0], nodes.size());
216 //=======================================================================
217 //function : ChangePolyhedronNodes
219 //=======================================================================
220 bool SMESHDS_Mesh::ChangePolyhedronNodes
221 (const SMDS_MeshElement * elem,
222 std::vector<const SMDS_MeshNode*> nodes,
223 std::vector<int> quantities)
225 ASSERT(nodes.size() > 3);
227 if (!SMDS_Mesh::ChangePolyhedronNodes(elem, nodes, quantities))
230 int i, len = nodes.size();
231 std::vector<int> nodes_ids (len);
232 for (i = 0; i < len; i++) {
233 nodes_ids[i] = nodes[i]->GetID();
235 myScript->ChangePolyhedronNodes(elem->GetID(), nodes_ids, quantities);
240 //=======================================================================
241 //function : Renumber
243 //=======================================================================
245 void SMESHDS_Mesh::Renumber (const bool isNodes, const int startID, const int deltaID)
247 SMDS_Mesh::Renumber( isNodes, startID, deltaID );
248 myScript->Renumber( isNodes, startID, deltaID );
251 //=======================================================================
252 //function :AddEdgeWithID
254 //=======================================================================
255 SMDS_MeshEdge* SMESHDS_Mesh::AddEdgeWithID(int n1, int n2, int ID)
257 SMDS_MeshEdge* anElem = SMDS_Mesh::AddEdgeWithID(n1,n2,ID);
258 if(anElem) myScript->AddEdge(ID,n1,n2);
262 SMDS_MeshEdge* SMESHDS_Mesh::AddEdgeWithID(const SMDS_MeshNode * n1,
263 const SMDS_MeshNode * n2,
266 return AddEdgeWithID(n1->GetID(),
271 SMDS_MeshEdge* SMESHDS_Mesh::AddEdge(const SMDS_MeshNode * n1,
272 const SMDS_MeshNode * n2)
274 SMDS_MeshEdge* anElem = SMDS_Mesh::AddEdge(n1,n2);
275 if(anElem) myScript->AddEdge(anElem->GetID(),
281 //=======================================================================
284 //=======================================================================
285 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(int n1, int n2, int n3, int ID)
287 SMDS_MeshFace *anElem = SMDS_Mesh::AddFaceWithID(n1, n2, n3, ID);
288 if(anElem) myScript->AddFace(ID,n1,n2,n3);
292 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(const SMDS_MeshNode * n1,
293 const SMDS_MeshNode * n2,
294 const SMDS_MeshNode * n3,
297 return AddFaceWithID(n1->GetID(),
303 SMDS_MeshFace* SMESHDS_Mesh::AddFace( const SMDS_MeshNode * n1,
304 const SMDS_MeshNode * n2,
305 const SMDS_MeshNode * n3)
307 SMDS_MeshFace *anElem = SMDS_Mesh::AddFace(n1, n2, n3);
308 if(anElem) myScript->AddFace(anElem->GetID(),
315 //=======================================================================
318 //=======================================================================
319 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(int n1, int n2, int n3, int n4, int ID)
321 SMDS_MeshFace *anElem = SMDS_Mesh::AddFaceWithID(n1, n2, n3, n4, ID);
322 if(anElem) myScript->AddFace(ID, n1, n2, n3, n4);
326 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(const SMDS_MeshNode * n1,
327 const SMDS_MeshNode * n2,
328 const SMDS_MeshNode * n3,
329 const SMDS_MeshNode * n4,
332 return AddFaceWithID(n1->GetID(),
339 SMDS_MeshFace* SMESHDS_Mesh::AddFace(const SMDS_MeshNode * n1,
340 const SMDS_MeshNode * n2,
341 const SMDS_MeshNode * n3,
342 const SMDS_MeshNode * n4)
344 SMDS_MeshFace *anElem = SMDS_Mesh::AddFace(n1, n2, n3, n4);
345 if(anElem) myScript->AddFace(anElem->GetID(),
353 //=======================================================================
354 //function :AddVolume
356 //=======================================================================
357 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3, int n4, int ID)
359 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolumeWithID(n1, n2, n3, n4, ID);
360 if(anElem) myScript->AddVolume(ID, n1, n2, n3, n4);
364 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
365 const SMDS_MeshNode * n2,
366 const SMDS_MeshNode * n3,
367 const SMDS_MeshNode * n4,
370 return AddVolumeWithID(n1->GetID(),
377 SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
378 const SMDS_MeshNode * n2,
379 const SMDS_MeshNode * n3,
380 const SMDS_MeshNode * n4)
382 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1, n2, n3, n4);
383 if(anElem) myScript->AddVolume(anElem->GetID(),
391 //=======================================================================
392 //function :AddVolume
394 //=======================================================================
395 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3, int n4, int n5, int ID)
397 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolumeWithID(n1, n2, n3, n4, n5, ID);
398 if(anElem) myScript->AddVolume(ID, n1, n2, n3, n4, n5);
402 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
403 const SMDS_MeshNode * n2,
404 const SMDS_MeshNode * n3,
405 const SMDS_MeshNode * n4,
406 const SMDS_MeshNode * n5,
409 return AddVolumeWithID(n1->GetID(),
417 SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
418 const SMDS_MeshNode * n2,
419 const SMDS_MeshNode * n3,
420 const SMDS_MeshNode * n4,
421 const SMDS_MeshNode * n5)
423 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1, n2, n3, n4, n5);
424 if(anElem) myScript->AddVolume(anElem->GetID(),
433 //=======================================================================
434 //function :AddVolume
436 //=======================================================================
437 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3, int n4, int n5, int n6, int ID)
439 SMDS_MeshVolume *anElem= SMDS_Mesh::AddVolumeWithID(n1, n2, n3, n4, n5, n6, ID);
440 if(anElem) myScript->AddVolume(ID, n1, n2, n3, n4, n5, n6);
444 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
445 const SMDS_MeshNode * n2,
446 const SMDS_MeshNode * n3,
447 const SMDS_MeshNode * n4,
448 const SMDS_MeshNode * n5,
449 const SMDS_MeshNode * n6,
452 return AddVolumeWithID(n1->GetID(),
461 SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
462 const SMDS_MeshNode * n2,
463 const SMDS_MeshNode * n3,
464 const SMDS_MeshNode * n4,
465 const SMDS_MeshNode * n5,
466 const SMDS_MeshNode * n6)
468 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1, n2, n3, n4, n5, n6);
469 if(anElem) myScript->AddVolume(anElem->GetID(),
479 //=======================================================================
480 //function :AddVolume
482 //=======================================================================
483 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3, int n4, int n5, int n6, int n7, int n8, int ID)
485 SMDS_MeshVolume *anElem= SMDS_Mesh::AddVolumeWithID(n1, n2, n3, n4, n5, n6, n7, n8, ID);
486 if(anElem) myScript->AddVolume(ID, n1, n2, n3, n4, n5, n6, n7, n8);
490 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
491 const SMDS_MeshNode * n2,
492 const SMDS_MeshNode * n3,
493 const SMDS_MeshNode * n4,
494 const SMDS_MeshNode * n5,
495 const SMDS_MeshNode * n6,
496 const SMDS_MeshNode * n7,
497 const SMDS_MeshNode * n8,
500 return AddVolumeWithID(n1->GetID(),
511 SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
512 const SMDS_MeshNode * n2,
513 const SMDS_MeshNode * n3,
514 const SMDS_MeshNode * n4,
515 const SMDS_MeshNode * n5,
516 const SMDS_MeshNode * n6,
517 const SMDS_MeshNode * n7,
518 const SMDS_MeshNode * n8)
520 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1, n2, n3, n4, n5, n6, n7, n8);
521 if(anElem) myScript->AddVolume(anElem->GetID(),
533 //=======================================================================
534 //function : AddPolygonalFace
536 //=======================================================================
537 SMDS_MeshFace* SMESHDS_Mesh::AddPolygonalFaceWithID (std::vector<int> nodes_ids,
540 SMDS_MeshFace *anElem = SMDS_Mesh::AddPolygonalFaceWithID(nodes_ids, ID);
542 myScript->AddPolygonalFace(ID, nodes_ids);
547 SMDS_MeshFace* SMESHDS_Mesh::AddPolygonalFaceWithID
548 (std::vector<const SMDS_MeshNode*> nodes,
551 SMDS_MeshFace *anElem = SMDS_Mesh::AddPolygonalFaceWithID(nodes, ID);
553 int i, len = nodes.size();
554 std::vector<int> nodes_ids (len);
555 for (i = 0; i < len; i++) {
556 nodes_ids[i] = nodes[i]->GetID();
558 myScript->AddPolygonalFace(ID, nodes_ids);
563 SMDS_MeshFace* SMESHDS_Mesh::AddPolygonalFace
564 (std::vector<const SMDS_MeshNode*> nodes)
566 SMDS_MeshFace *anElem = SMDS_Mesh::AddPolygonalFace(nodes);
568 int i, len = nodes.size();
569 std::vector<int> nodes_ids (len);
570 for (i = 0; i < len; i++) {
571 nodes_ids[i] = nodes[i]->GetID();
573 myScript->AddPolygonalFace(anElem->GetID(), nodes_ids);
578 //=======================================================================
579 //function : AddPolyhedralVolume
581 //=======================================================================
582 SMDS_MeshVolume* SMESHDS_Mesh::AddPolyhedralVolumeWithID (std::vector<int> nodes_ids,
583 std::vector<int> quantities,
586 SMDS_MeshVolume *anElem = SMDS_Mesh::AddPolyhedralVolumeWithID(nodes_ids, quantities, ID);
588 myScript->AddPolyhedralVolume(ID, nodes_ids, quantities);
593 SMDS_MeshVolume* SMESHDS_Mesh::AddPolyhedralVolumeWithID
594 (std::vector<const SMDS_MeshNode*> nodes,
595 std::vector<int> quantities,
598 SMDS_MeshVolume *anElem = SMDS_Mesh::AddPolyhedralVolumeWithID(nodes, quantities, ID);
600 int i, len = nodes.size();
601 std::vector<int> nodes_ids (len);
602 for (i = 0; i < len; i++) {
603 nodes_ids[i] = nodes[i]->GetID();
605 myScript->AddPolyhedralVolume(ID, nodes_ids, quantities);
610 SMDS_MeshVolume* SMESHDS_Mesh::AddPolyhedralVolume
611 (std::vector<const SMDS_MeshNode*> nodes,
612 std::vector<int> quantities)
614 SMDS_MeshVolume *anElem = SMDS_Mesh::AddPolyhedralVolume(nodes, quantities);
616 int i, len = nodes.size();
617 std::vector<int> nodes_ids (len);
618 for (i = 0; i < len; i++) {
619 nodes_ids[i] = nodes[i]->GetID();
621 myScript->AddPolyhedralVolume(anElem->GetID(), nodes_ids, quantities);
626 //=======================================================================
627 //function : removeFromContainers
629 //=======================================================================
631 static void removeFromContainers (map<int,SMESHDS_SubMesh*>& theSubMeshes,
632 set<SMESHDS_GroupBase*>& theGroups,
633 list<const SMDS_MeshElement*>& theElems,
636 if ( theElems.empty() )
640 // Element can belong to several groups
641 if ( !theGroups.empty() )
643 set<SMESHDS_GroupBase*>::iterator GrIt = theGroups.begin();
644 for ( ; GrIt != theGroups.end(); GrIt++ )
646 SMESHDS_Group* group = dynamic_cast<SMESHDS_Group*>( *GrIt );
647 if ( !group || group->IsEmpty() ) continue;
649 list<const SMDS_MeshElement *>::iterator elIt = theElems.begin();
650 for ( ; elIt != theElems.end(); elIt++ )
652 group->SMDSGroup().Remove( *elIt );
653 if ( group->IsEmpty() ) break;
658 const bool deleted=true;
660 // Rm from sub-meshes
661 // Element should belong to only one sub-mesh
662 map<int,SMESHDS_SubMesh*>::iterator SubIt = theSubMeshes.begin();
663 for ( ; SubIt != theSubMeshes.end(); SubIt++ )
665 int size = isNode ? (*SubIt).second->NbNodes() : (*SubIt).second->NbElements();
666 if ( size == 0 ) continue;
668 list<const SMDS_MeshElement *>::iterator elIt = theElems.begin();
669 while ( elIt != theElems.end() )
671 bool removed = false;
673 removed = (*SubIt).second->RemoveNode( static_cast<const SMDS_MeshNode*> (*elIt), deleted );
675 removed = (*SubIt).second->RemoveElement( *elIt, deleted );
679 elIt = theElems.erase( elIt );
680 if ( theElems.empty() )
681 return; // all elements are found and removed
691 //=======================================================================
692 //function : RemoveNode
694 //=======================================================================
695 void SMESHDS_Mesh::RemoveNode(const SMDS_MeshNode * n)
697 if ( n->NbInverseElements() == 0 && !(hasConstructionEdges() || hasConstructionFaces()))
699 SMESHDS_SubMesh* subMesh=0;
700 map<int,SMESHDS_SubMesh*>::iterator SubIt =
701 myShapeIndexToSubMesh.find( n->GetPosition()->GetShapeId() );
702 if ( SubIt != myShapeIndexToSubMesh.end() )
703 subMesh = SubIt->second;
705 SubIt = myShapeIndexToSubMesh.begin();
706 for ( ; !subMesh && SubIt != myShapeIndexToSubMesh.end(); SubIt++ )
707 if (!SubIt->second->IsComplexSubmesh() && SubIt->second->Contains( n ))
708 subMesh = SubIt->second;
710 RemoveFreeNode( n, subMesh, true);
714 myScript->RemoveNode(n->GetID());
716 list<const SMDS_MeshElement *> removedElems;
717 list<const SMDS_MeshElement *> removedNodes;
719 SMDS_Mesh::RemoveElement( n, removedElems, removedNodes, true );
721 removeFromContainers( myShapeIndexToSubMesh, myGroups, removedElems, false );
722 removeFromContainers( myShapeIndexToSubMesh, myGroups, removedNodes, true );
725 //=======================================================================
726 //function : RemoveFreeNode
728 //=======================================================================
729 void SMESHDS_Mesh::RemoveFreeNode(const SMDS_MeshNode * n,
730 SMESHDS_SubMesh * subMesh,
733 myScript->RemoveNode(n->GetID());
736 // Node can belong to several groups
737 if (fromGroups && !myGroups.empty()) {
738 set<SMESHDS_GroupBase*>::iterator GrIt = myGroups.begin();
739 for (; GrIt != myGroups.end(); GrIt++) {
740 SMESHDS_Group* group = dynamic_cast<SMESHDS_Group*>(*GrIt);
741 if (!group || group->IsEmpty()) continue;
742 group->SMDSGroup().Remove(n);
747 // Node should belong to only one sub-mesh
749 subMesh->RemoveNode(n,/*deleted=*/false);
751 SMDS_Mesh::RemoveFreeElement(n);
754 //=======================================================================
755 //function : RemoveElement
757 //========================================================================
758 void SMESHDS_Mesh::RemoveElement(const SMDS_MeshElement * elt)
760 if (elt->GetType() == SMDSAbs_Node)
762 RemoveNode( static_cast<const SMDS_MeshNode*>( elt ));
765 if (!hasConstructionEdges() && !hasConstructionFaces())
767 SMESHDS_SubMesh* subMesh=0;
768 map<int,SMESHDS_SubMesh*>::iterator SubIt = myShapeIndexToSubMesh.begin();
769 for ( ; !subMesh && SubIt != myShapeIndexToSubMesh.end(); SubIt++ )
770 if (!SubIt->second->IsComplexSubmesh() && SubIt->second->Contains( elt ))
771 subMesh = SubIt->second;
773 RemoveFreeElement( elt, subMesh, true);
777 myScript->RemoveElement(elt->GetID());
779 list<const SMDS_MeshElement *> removedElems;
780 list<const SMDS_MeshElement *> removedNodes;
782 SMDS_Mesh::RemoveElement(elt, removedElems, removedNodes, false);
784 removeFromContainers( myShapeIndexToSubMesh, myGroups, removedElems, false );
787 //=======================================================================
788 //function : RemoveFreeElement
790 //========================================================================
791 void SMESHDS_Mesh::RemoveFreeElement(const SMDS_MeshElement * elt,
792 SMESHDS_SubMesh * subMesh,
795 if (elt->GetType() == SMDSAbs_Node) {
796 RemoveFreeNode( static_cast<const SMDS_MeshNode*>(elt), subMesh);
800 if (hasConstructionEdges() || hasConstructionFaces())
801 // this methods is only for meshes without descendants
804 myScript->RemoveElement(elt->GetID());
807 // Node can belong to several groups
808 if ( fromGroups && !myGroups.empty() ) {
809 set<SMESHDS_GroupBase*>::iterator GrIt = myGroups.begin();
810 for (; GrIt != myGroups.end(); GrIt++) {
811 SMESHDS_Group* group = dynamic_cast<SMESHDS_Group*>(*GrIt);
812 if (group && !group->IsEmpty())
813 group->SMDSGroup().Remove(elt);
818 // Element should belong to only one sub-mesh
820 subMesh->RemoveElement(elt, /*deleted=*/false);
822 SMDS_Mesh::RemoveFreeElement(elt);
825 //================================================================================
827 * \brief Remove all data from the mesh
829 //================================================================================
831 void SMESHDS_Mesh::ClearMesh()
833 myScript->ClearMesh();
837 map<int,SMESHDS_SubMesh*>::iterator sub, subEnd = myShapeIndexToSubMesh.end();
838 for ( sub = myShapeIndexToSubMesh.begin(); sub != subEnd; ++sub )
839 sub->second->Clear();
842 TGroups::iterator group, groupEnd = myGroups.end();
843 for ( group = myGroups.begin(); group != groupEnd; ++group ) {
844 if ( SMESHDS_Group* g = dynamic_cast<SMESHDS_Group*>(*group)) {
845 SMDSAbs_ElementType groupType = g->GetType();
847 g->SetType( groupType );
852 //================================================================================
854 * \brief return submesh by shape
855 * \param shape - the subshape
856 * \retval SMESHDS_SubMesh* - the found submesh
858 * search of submeshes is optimized
860 //================================================================================
862 SMESHDS_SubMesh* SMESHDS_Mesh::getSubmesh( const TopoDS_Shape & shape )
864 if ( shape.IsNull() )
867 if ( !myCurSubShape.IsNull() && shape.IsSame( myCurSubShape ))
870 getSubmesh( ShapeToIndex( shape ));
871 myCurSubShape = shape;
875 //================================================================================
877 * \brief return submesh by subshape index
878 * \param Index - the subshape index
879 * \retval SMESHDS_SubMesh* - the found submesh
880 * search of submeshes is optimized
882 //================================================================================
884 SMESHDS_SubMesh* SMESHDS_Mesh::getSubmesh( const int Index )
886 //Update or build submesh
887 if ( Index != myCurSubID ) {
888 map<int,SMESHDS_SubMesh*>::iterator it = myShapeIndexToSubMesh.find( Index );
889 if ( it == myShapeIndexToSubMesh.end() )
890 it = myShapeIndexToSubMesh.insert( make_pair(Index, new SMESHDS_SubMesh() )).first;
891 myCurSubMesh = it->second;
893 myCurSubShape.Nullify(); // myCurSubShape no more corresponds to submesh
898 //================================================================================
900 * \brief Add element or node to submesh
901 * \param elem - element to add
902 * \param subMesh - submesh to be filled in
904 //================================================================================
906 bool SMESHDS_Mesh::add(const SMDS_MeshElement* elem, SMESHDS_SubMesh* subMesh )
908 if ( elem && subMesh ) {
909 if ( elem->GetType() == SMDSAbs_Node )
910 subMesh->AddNode( static_cast<const SMDS_MeshNode* >( elem ));
912 subMesh->AddElement( elem );
920 //================================================================================
922 * \brief Creates a node position in volume
924 //================================================================================
926 inline SMDS_PositionPtr volumePosition(int volId)
928 SMDS_SpacePosition* pos = new SMDS_SpacePosition();
929 pos->SetShapeId( volId );
930 return SMDS_PositionPtr(pos);
934 //=======================================================================
935 //function : SetNodeOnVolume
937 //=======================================================================
938 void SMESHDS_Mesh::SetNodeInVolume(SMDS_MeshNode * aNode,
939 const TopoDS_Shell & S)
941 if ( add( aNode, getSubmesh(S) ))
942 aNode->SetPosition ( volumePosition( myCurSubID ));
944 //=======================================================================
945 //function : SetNodeOnVolume
947 //=======================================================================
948 void SMESHDS_Mesh::SetNodeInVolume(SMDS_MeshNode * aNode,
949 const TopoDS_Solid & S)
951 if ( add( aNode, getSubmesh(S) ))
952 aNode->SetPosition ( volumePosition( myCurSubID ));
955 //=======================================================================
956 //function : SetNodeOnFace
958 //=======================================================================
959 void SMESHDS_Mesh::SetNodeOnFace(SMDS_MeshNode * aNode,
960 const TopoDS_Face & S,
964 if ( add( aNode, getSubmesh(S) ))
965 aNode->SetPosition(SMDS_PositionPtr(new SMDS_FacePosition(myCurSubID, u, v)));
968 //=======================================================================
969 //function : SetNodeOnEdge
971 //=======================================================================
972 void SMESHDS_Mesh::SetNodeOnEdge(SMDS_MeshNode * aNode,
973 const TopoDS_Edge & S,
976 if ( add( aNode, getSubmesh(S) ))
977 aNode->SetPosition(SMDS_PositionPtr(new SMDS_EdgePosition(myCurSubID, u)));
980 //=======================================================================
981 //function : SetNodeOnVertex
983 //=======================================================================
984 void SMESHDS_Mesh::SetNodeOnVertex(SMDS_MeshNode * aNode,
985 const TopoDS_Vertex & S)
987 if ( add( aNode, getSubmesh(S) ))
988 aNode->SetPosition(SMDS_PositionPtr(new SMDS_VertexPosition(myCurSubID)));
991 //=======================================================================
992 //function : UnSetNodeOnShape
994 //=======================================================================
995 void SMESHDS_Mesh::UnSetNodeOnShape(const SMDS_MeshNode* aNode)
997 if ( aNode && aNode->GetPosition() ) {
998 map<int,SMESHDS_SubMesh*>::iterator it =
999 myShapeIndexToSubMesh.find( aNode->GetPosition()->GetShapeId() );
1000 if ( it != myShapeIndexToSubMesh.end() )
1001 it->second->RemoveNode( aNode, /*deleted=*/false );
1005 //=======================================================================
1006 //function : SetMeshElementOnShape
1008 //=======================================================================
1009 void SMESHDS_Mesh::SetMeshElementOnShape(const SMDS_MeshElement * anElement,
1010 const TopoDS_Shape & S)
1012 add( anElement, getSubmesh(S) );
1015 //=======================================================================
1016 //function : UnSetMeshElementOnShape
1018 //=======================================================================
1019 void SMESHDS_Mesh::UnSetMeshElementOnShape(const SMDS_MeshElement * elem,
1020 const TopoDS_Shape & S)
1022 int Index = myIndexToShape.FindIndex(S);
1024 map<int,SMESHDS_SubMesh*>::iterator it = myShapeIndexToSubMesh.find( Index );
1025 if ( it != myShapeIndexToSubMesh.end() )
1026 if ( elem->GetType() == SMDSAbs_Node )
1027 it->second->RemoveNode( static_cast<const SMDS_MeshNode* >( elem ), /*deleted=*/false );
1029 it->second->RemoveElement( elem, /*deleted=*/false );
1032 //=======================================================================
1033 //function : ShapeToMesh
1035 //=======================================================================
1036 TopoDS_Shape SMESHDS_Mesh::ShapeToMesh() const
1041 //=======================================================================
1042 //function : IsGroupOfSubShapes
1043 //purpose : return true if at least one subshape of theShape is a subshape
1044 // of myShape or theShape == myShape
1045 //=======================================================================
1047 bool SMESHDS_Mesh::IsGroupOfSubShapes (const TopoDS_Shape& theShape) const
1049 if ( myShape.IsSame( theShape ))
1052 for ( TopoDS_Iterator it( theShape ); it.More(); it.Next() ) {
1053 if (myIndexToShape.Contains( it.Value() ) ||
1054 IsGroupOfSubShapes( it.Value() ))
1061 ///////////////////////////////////////////////////////////////////////////////
1062 /// Return the sub mesh linked to the a given TopoDS_Shape or NULL if the given
1063 /// TopoDS_Shape is unknown
1064 ///////////////////////////////////////////////////////////////////////////////
1065 SMESHDS_SubMesh * SMESHDS_Mesh::MeshElements(const TopoDS_Shape & S) const
1067 int Index = ShapeToIndex(S);
1068 TShapeIndexToSubMesh::const_iterator anIter = myShapeIndexToSubMesh.find(Index);
1069 if (anIter != myShapeIndexToSubMesh.end())
1070 return anIter->second;
1075 ///////////////////////////////////////////////////////////////////////////////
1076 /// Return the sub mesh by Id of shape it is linked to
1077 ///////////////////////////////////////////////////////////////////////////////
1078 SMESHDS_SubMesh * SMESHDS_Mesh::MeshElements(const int Index)
1080 TShapeIndexToSubMesh::const_iterator anIter = myShapeIndexToSubMesh.find(Index);
1081 if (anIter != myShapeIndexToSubMesh.end())
1082 return anIter->second;
1087 //=======================================================================
1088 //function : SubMeshIndices
1090 //=======================================================================
1091 list<int> SMESHDS_Mesh::SubMeshIndices()
1093 list<int> anIndices;
1094 std::map<int,SMESHDS_SubMesh*>::iterator anIter = myShapeIndexToSubMesh.begin();
1095 for (; anIter != myShapeIndexToSubMesh.end(); anIter++) {
1096 anIndices.push_back((*anIter).first);
1101 //=======================================================================
1102 //function : GetHypothesis
1104 //=======================================================================
1106 const list<const SMESHDS_Hypothesis*>&
1107 SMESHDS_Mesh::GetHypothesis(const TopoDS_Shape & S) const
1109 if ( myShapeToHypothesis.IsBound( S.Oriented(TopAbs_FORWARD) ) ) // ignore orientation of S
1110 return myShapeToHypothesis.Find( S.Oriented(TopAbs_FORWARD) );
1112 static list<const SMESHDS_Hypothesis*> empty;
1116 //=======================================================================
1117 //function : GetScript
1119 //=======================================================================
1120 SMESHDS_Script* SMESHDS_Mesh::GetScript()
1125 //=======================================================================
1126 //function : ClearScript
1128 //=======================================================================
1129 void SMESHDS_Mesh::ClearScript()
1134 //=======================================================================
1135 //function : HasMeshElements
1137 //=======================================================================
1138 bool SMESHDS_Mesh::HasMeshElements(const TopoDS_Shape & S)
1140 if (myShape.IsNull()) MESSAGE("myShape is NULL");
1141 int Index = myIndexToShape.FindIndex(S);
1142 return myShapeIndexToSubMesh.find(Index)!=myShapeIndexToSubMesh.end();
1145 //=======================================================================
1146 //function : HasHypothesis
1148 //=======================================================================
1149 bool SMESHDS_Mesh::HasHypothesis(const TopoDS_Shape & S)
1151 return myShapeToHypothesis.IsBound(S.Oriented(TopAbs_FORWARD));
1154 //=======================================================================
1155 //function : NewSubMesh
1157 //=======================================================================
1158 SMESHDS_SubMesh * SMESHDS_Mesh::NewSubMesh(int Index)
1160 SMESHDS_SubMesh* SM = 0;
1161 TShapeIndexToSubMesh::iterator anIter = myShapeIndexToSubMesh.find(Index);
1162 if (anIter == myShapeIndexToSubMesh.end())
1164 SM = new SMESHDS_SubMesh();
1165 myShapeIndexToSubMesh[Index]=SM;
1168 SM = anIter->second;
1172 //=======================================================================
1173 //function : AddCompoundSubmesh
1175 //=======================================================================
1177 int SMESHDS_Mesh::AddCompoundSubmesh(const TopoDS_Shape& S,
1178 TopAbs_ShapeEnum type)
1181 if ( IsGroupOfSubShapes( S ) || (S.ShapeType() == TopAbs_VERTEX && myIndexToShape.Contains(S)) )
1183 aMainIndex = myIndexToShape.Add( S );
1184 bool all = ( type == TopAbs_SHAPE );
1185 if ( all ) // corresponding simple submesh may exist
1186 aMainIndex = -aMainIndex;
1187 //MESSAGE("AddCompoundSubmesh index = " << aMainIndex );
1188 SMESHDS_SubMesh * aNewSub = NewSubMesh( aMainIndex );
1189 if ( !aNewSub->IsComplexSubmesh() ) // is empty
1191 int shapeType = Max( TopAbs_SOLID, all ? myShape.ShapeType() : type );
1192 int typeLimit = all ? TopAbs_VERTEX : type;
1193 for ( ; shapeType <= typeLimit; shapeType++ )
1195 TopExp_Explorer exp( S, TopAbs_ShapeEnum( shapeType ));
1196 for ( ; exp.More(); exp.Next() )
1198 int index = myIndexToShape.FindIndex( exp.Current() );
1200 aNewSub->AddSubMesh( NewSubMesh( index ));
1208 //=======================================================================
1209 //function : IndexToShape
1211 //=======================================================================
1212 const TopoDS_Shape& SMESHDS_Mesh::IndexToShape(int ShapeIndex) const
1214 return myIndexToShape.FindKey(ShapeIndex);
1217 //=======================================================================
1218 //function : ShapeToIndex
1220 //=======================================================================
1221 int SMESHDS_Mesh::ShapeToIndex(const TopoDS_Shape & S) const
1223 if (myShape.IsNull())
1224 MESSAGE("myShape is NULL");
1226 int index = myIndexToShape.FindIndex(S);
1231 //=======================================================================
1232 //function : SetNodeOnVolume
1234 //=======================================================================
1235 void SMESHDS_Mesh::SetNodeInVolume(const SMDS_MeshNode* aNode, int Index)
1237 if ( add( aNode, getSubmesh( Index )))
1238 ((SMDS_MeshNode*) aNode)->SetPosition( volumePosition( Index ));
1241 //=======================================================================
1242 //function : SetNodeOnFace
1244 //=======================================================================
1245 void SMESHDS_Mesh::SetNodeOnFace(SMDS_MeshNode* aNode, int Index, double u, double v)
1247 //Set Position on Node
1248 if ( add( aNode, getSubmesh( Index )))
1249 aNode->SetPosition(SMDS_PositionPtr(new SMDS_FacePosition(Index, u, v)));
1252 //=======================================================================
1253 //function : SetNodeOnEdge
1255 //=======================================================================
1256 void SMESHDS_Mesh::SetNodeOnEdge(SMDS_MeshNode* aNode,
1260 //Set Position on Node
1261 if ( add( aNode, getSubmesh( Index )))
1262 aNode->SetPosition(SMDS_PositionPtr(new SMDS_EdgePosition(Index, u)));
1265 //=======================================================================
1266 //function : SetNodeOnVertex
1268 //=======================================================================
1269 void SMESHDS_Mesh::SetNodeOnVertex(SMDS_MeshNode* aNode, int Index)
1271 //Set Position on Node
1272 if ( add( aNode, getSubmesh( Index )))
1273 aNode->SetPosition(SMDS_PositionPtr(new SMDS_VertexPosition(Index)));
1276 //=======================================================================
1277 //function : SetMeshElementOnShape
1279 //=======================================================================
1280 void SMESHDS_Mesh::SetMeshElementOnShape(const SMDS_MeshElement* anElement,
1283 add( anElement, getSubmesh( Index ));
1286 //=======================================================================
1287 //function : ~SMESHDS_Mesh
1289 //=======================================================================
1290 SMESHDS_Mesh::~SMESHDS_Mesh()
1295 TShapeIndexToSubMesh::iterator i_sm = myShapeIndexToSubMesh.begin();
1296 for ( ; i_sm != myShapeIndexToSubMesh.end(); ++i_sm )
1297 delete i_sm->second;
1301 //********************************************************************
1302 //********************************************************************
1303 //******** *********
1304 //***** Methods for addition of quadratic elements ******
1305 //******** *********
1306 //********************************************************************
1307 //********************************************************************
1309 //=======================================================================
1310 //function : AddEdgeWithID
1312 //=======================================================================
1313 SMDS_MeshEdge* SMESHDS_Mesh::AddEdgeWithID(int n1, int n2, int n12, int ID)
1315 SMDS_MeshEdge* anElem = SMDS_Mesh::AddEdgeWithID(n1,n2,n12,ID);
1316 if(anElem) myScript->AddEdge(ID,n1,n2,n12);
1320 //=======================================================================
1321 //function : AddEdge
1323 //=======================================================================
1324 SMDS_MeshEdge* SMESHDS_Mesh::AddEdge(const SMDS_MeshNode* n1,
1325 const SMDS_MeshNode* n2,
1326 const SMDS_MeshNode* n12)
1328 SMDS_MeshEdge* anElem = SMDS_Mesh::AddEdge(n1,n2,n12);
1329 if(anElem) myScript->AddEdge(anElem->GetID(),
1336 //=======================================================================
1337 //function : AddEdgeWithID
1339 //=======================================================================
1340 SMDS_MeshEdge* SMESHDS_Mesh::AddEdgeWithID(const SMDS_MeshNode * n1,
1341 const SMDS_MeshNode * n2,
1342 const SMDS_MeshNode * n12,
1345 return AddEdgeWithID(n1->GetID(),
1352 //=======================================================================
1353 //function : AddFace
1355 //=======================================================================
1356 SMDS_MeshFace* SMESHDS_Mesh::AddFace(const SMDS_MeshNode * n1,
1357 const SMDS_MeshNode * n2,
1358 const SMDS_MeshNode * n3,
1359 const SMDS_MeshNode * n12,
1360 const SMDS_MeshNode * n23,
1361 const SMDS_MeshNode * n31)
1363 SMDS_MeshFace *anElem = SMDS_Mesh::AddFace(n1,n2,n3,n12,n23,n31);
1364 if(anElem) myScript->AddFace(anElem->GetID(),
1365 n1->GetID(), n2->GetID(), n3->GetID(),
1366 n12->GetID(), n23->GetID(), n31->GetID());
1370 //=======================================================================
1371 //function : AddFaceWithID
1373 //=======================================================================
1374 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(int n1, int n2, int n3,
1375 int n12,int n23,int n31, int ID)
1377 SMDS_MeshFace *anElem = SMDS_Mesh::AddFaceWithID(n1,n2,n3,n12,n23,n31,ID);
1378 if(anElem) myScript->AddFace(ID,n1,n2,n3,n12,n23,n31);
1382 //=======================================================================
1383 //function : AddFaceWithID
1385 //=======================================================================
1386 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(const SMDS_MeshNode * n1,
1387 const SMDS_MeshNode * n2,
1388 const SMDS_MeshNode * n3,
1389 const SMDS_MeshNode * n12,
1390 const SMDS_MeshNode * n23,
1391 const SMDS_MeshNode * n31,
1394 return AddFaceWithID(n1->GetID(), n2->GetID(), n3->GetID(),
1395 n12->GetID(), n23->GetID(), n31->GetID(),
1400 //=======================================================================
1401 //function : AddFace
1403 //=======================================================================
1404 SMDS_MeshFace* SMESHDS_Mesh::AddFace(const SMDS_MeshNode * n1,
1405 const SMDS_MeshNode * n2,
1406 const SMDS_MeshNode * n3,
1407 const SMDS_MeshNode * n4,
1408 const SMDS_MeshNode * n12,
1409 const SMDS_MeshNode * n23,
1410 const SMDS_MeshNode * n34,
1411 const SMDS_MeshNode * n41)
1413 SMDS_MeshFace *anElem = SMDS_Mesh::AddFace(n1,n2,n3,n4,n12,n23,n34,n41);
1414 if(anElem) myScript->AddFace(anElem->GetID(),
1415 n1->GetID(), n2->GetID(), n3->GetID(), n4->GetID(),
1416 n12->GetID(), n23->GetID(), n34->GetID(), n41->GetID());
1420 //=======================================================================
1421 //function : AddFaceWithID
1423 //=======================================================================
1424 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(int n1, int n2, int n3, int n4,
1425 int n12,int n23,int n34,int n41, int ID)
1427 SMDS_MeshFace *anElem = SMDS_Mesh::AddFaceWithID(n1,n2,n3,n4,n12,n23,n34,n41,ID);
1428 if(anElem) myScript->AddFace(ID,n1,n2,n3,n4,n12,n23,n34,n41);
1432 //=======================================================================
1433 //function : AddFaceWithID
1435 //=======================================================================
1436 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(const SMDS_MeshNode * n1,
1437 const SMDS_MeshNode * n2,
1438 const SMDS_MeshNode * n3,
1439 const SMDS_MeshNode * n4,
1440 const SMDS_MeshNode * n12,
1441 const SMDS_MeshNode * n23,
1442 const SMDS_MeshNode * n34,
1443 const SMDS_MeshNode * n41,
1446 return AddFaceWithID(n1->GetID(), n2->GetID(), n3->GetID(), n4->GetID(),
1447 n12->GetID(), n23->GetID(), n34->GetID(), n41->GetID(),
1452 //=======================================================================
1453 //function : AddVolume
1455 //=======================================================================
1456 SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
1457 const SMDS_MeshNode * n2,
1458 const SMDS_MeshNode * n3,
1459 const SMDS_MeshNode * n4,
1460 const SMDS_MeshNode * n12,
1461 const SMDS_MeshNode * n23,
1462 const SMDS_MeshNode * n31,
1463 const SMDS_MeshNode * n14,
1464 const SMDS_MeshNode * n24,
1465 const SMDS_MeshNode * n34)
1467 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1,n2,n3,n4,n12,n23,n31,n14,n24,n34);
1468 if(anElem) myScript->AddVolume(anElem->GetID(),
1469 n1->GetID(), n2->GetID(), n3->GetID(), n4->GetID(),
1470 n12->GetID(), n23->GetID(), n31->GetID(),
1471 n14->GetID(), n24->GetID(), n34->GetID());
1475 //=======================================================================
1476 //function : AddVolumeWithID
1478 //=======================================================================
1479 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3, int n4,
1480 int n12,int n23,int n31,
1481 int n14,int n24,int n34, int ID)
1483 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolumeWithID(n1,n2,n3,n4,n12,n23,
1484 n31,n14,n24,n34,ID);
1485 if(anElem) myScript->AddVolume(ID,n1,n2,n3,n4,n12,n23,n31,n14,n24,n34);
1489 //=======================================================================
1490 //function : AddVolumeWithID
1491 //purpose : 2d order tetrahedron of 10 nodes
1492 //=======================================================================
1493 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
1494 const SMDS_MeshNode * n2,
1495 const SMDS_MeshNode * n3,
1496 const SMDS_MeshNode * n4,
1497 const SMDS_MeshNode * n12,
1498 const SMDS_MeshNode * n23,
1499 const SMDS_MeshNode * n31,
1500 const SMDS_MeshNode * n14,
1501 const SMDS_MeshNode * n24,
1502 const SMDS_MeshNode * n34,
1505 return AddVolumeWithID(n1->GetID(), n2->GetID(), n3->GetID(), n4->GetID(),
1506 n12->GetID(), n23->GetID(), n31->GetID(),
1507 n14->GetID(), n24->GetID(), n34->GetID(), ID);
1511 //=======================================================================
1512 //function : AddVolume
1514 //=======================================================================
1515 SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
1516 const SMDS_MeshNode * n2,
1517 const SMDS_MeshNode * n3,
1518 const SMDS_MeshNode * n4,
1519 const SMDS_MeshNode * n5,
1520 const SMDS_MeshNode * n12,
1521 const SMDS_MeshNode * n23,
1522 const SMDS_MeshNode * n34,
1523 const SMDS_MeshNode * n41,
1524 const SMDS_MeshNode * n15,
1525 const SMDS_MeshNode * n25,
1526 const SMDS_MeshNode * n35,
1527 const SMDS_MeshNode * n45)
1529 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1,n2,n3,n4,n5,n12,n23,n34,n41,
1532 myScript->AddVolume(anElem->GetID(), n1->GetID(), n2->GetID(),
1533 n3->GetID(), n4->GetID(), n5->GetID(),
1534 n12->GetID(), n23->GetID(), n34->GetID(), n41->GetID(),
1535 n15->GetID(), n25->GetID(), n35->GetID(), n45->GetID());
1539 //=======================================================================
1540 //function : AddVolumeWithID
1542 //=======================================================================
1543 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3, int n4, int n5,
1544 int n12,int n23,int n34,int n41,
1545 int n15,int n25,int n35,int n45, int ID)
1547 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolumeWithID(n1,n2,n3,n4,n5,
1549 n15,n25,n35,n45,ID);
1550 if(anElem) myScript->AddVolume(ID,n1,n2,n3,n4,n5,n12,n23,n34,n41,
1555 //=======================================================================
1556 //function : AddVolumeWithID
1557 //purpose : 2d order pyramid of 13 nodes
1558 //=======================================================================
1559 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
1560 const SMDS_MeshNode * n2,
1561 const SMDS_MeshNode * n3,
1562 const SMDS_MeshNode * n4,
1563 const SMDS_MeshNode * n5,
1564 const SMDS_MeshNode * n12,
1565 const SMDS_MeshNode * n23,
1566 const SMDS_MeshNode * n34,
1567 const SMDS_MeshNode * n41,
1568 const SMDS_MeshNode * n15,
1569 const SMDS_MeshNode * n25,
1570 const SMDS_MeshNode * n35,
1571 const SMDS_MeshNode * n45,
1574 return AddVolumeWithID(n1->GetID(), n2->GetID(), n3->GetID(),
1575 n4->GetID(), n5->GetID(),
1576 n12->GetID(), n23->GetID(), n34->GetID(), n41->GetID(),
1577 n15->GetID(), n25->GetID(), n35->GetID(), n45->GetID(),
1582 //=======================================================================
1583 //function : AddVolume
1585 //=======================================================================
1586 SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
1587 const SMDS_MeshNode * n2,
1588 const SMDS_MeshNode * n3,
1589 const SMDS_MeshNode * n4,
1590 const SMDS_MeshNode * n5,
1591 const SMDS_MeshNode * n6,
1592 const SMDS_MeshNode * n12,
1593 const SMDS_MeshNode * n23,
1594 const SMDS_MeshNode * n31,
1595 const SMDS_MeshNode * n45,
1596 const SMDS_MeshNode * n56,
1597 const SMDS_MeshNode * n64,
1598 const SMDS_MeshNode * n14,
1599 const SMDS_MeshNode * n25,
1600 const SMDS_MeshNode * n36)
1602 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1,n2,n3,n4,n5,n6,n12,n23,n31,
1603 n45,n56,n64,n14,n25,n36);
1605 myScript->AddVolume(anElem->GetID(), n1->GetID(), n2->GetID(),
1606 n3->GetID(), n4->GetID(), n5->GetID(), n6->GetID(),
1607 n12->GetID(), n23->GetID(), n31->GetID(),
1608 n45->GetID(), n56->GetID(), n64->GetID(),
1609 n14->GetID(), n25->GetID(), n36->GetID());
1613 //=======================================================================
1614 //function : AddVolumeWithID
1616 //=======================================================================
1617 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3,
1618 int n4, int n5, int n6,
1619 int n12,int n23,int n31,
1620 int n45,int n56,int n64,
1621 int n14,int n25,int n36, int ID)
1623 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolumeWithID(n1,n2,n3,n4,n5,n6,
1627 if(anElem) myScript->AddVolume(ID,n1,n2,n3,n4,n5,n6,n12,n23,n31,
1628 n45,n56,n64,n14,n25,n36);
1632 //=======================================================================
1633 //function : AddVolumeWithID
1634 //purpose : 2d order Pentahedron with 15 nodes
1635 //=======================================================================
1636 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
1637 const SMDS_MeshNode * n2,
1638 const SMDS_MeshNode * n3,
1639 const SMDS_MeshNode * n4,
1640 const SMDS_MeshNode * n5,
1641 const SMDS_MeshNode * n6,
1642 const SMDS_MeshNode * n12,
1643 const SMDS_MeshNode * n23,
1644 const SMDS_MeshNode * n31,
1645 const SMDS_MeshNode * n45,
1646 const SMDS_MeshNode * n56,
1647 const SMDS_MeshNode * n64,
1648 const SMDS_MeshNode * n14,
1649 const SMDS_MeshNode * n25,
1650 const SMDS_MeshNode * n36,
1653 return AddVolumeWithID(n1->GetID(), n2->GetID(), n3->GetID(),
1654 n4->GetID(), n5->GetID(), n6->GetID(),
1655 n12->GetID(), n23->GetID(), n31->GetID(),
1656 n45->GetID(), n56->GetID(), n64->GetID(),
1657 n14->GetID(), n25->GetID(), n36->GetID(),
1662 //=======================================================================
1663 //function : AddVolume
1665 //=======================================================================
1666 SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
1667 const SMDS_MeshNode * n2,
1668 const SMDS_MeshNode * n3,
1669 const SMDS_MeshNode * n4,
1670 const SMDS_MeshNode * n5,
1671 const SMDS_MeshNode * n6,
1672 const SMDS_MeshNode * n7,
1673 const SMDS_MeshNode * n8,
1674 const SMDS_MeshNode * n12,
1675 const SMDS_MeshNode * n23,
1676 const SMDS_MeshNode * n34,
1677 const SMDS_MeshNode * n41,
1678 const SMDS_MeshNode * n56,
1679 const SMDS_MeshNode * n67,
1680 const SMDS_MeshNode * n78,
1681 const SMDS_MeshNode * n85,
1682 const SMDS_MeshNode * n15,
1683 const SMDS_MeshNode * n26,
1684 const SMDS_MeshNode * n37,
1685 const SMDS_MeshNode * n48)
1687 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1,n2,n3,n4,n5,n6,n7,n8,
1692 myScript->AddVolume(anElem->GetID(), n1->GetID(), n2->GetID(),
1693 n3->GetID(), n4->GetID(), n5->GetID(),
1694 n6->GetID(), n7->GetID(), n8->GetID(),
1695 n12->GetID(), n23->GetID(), n34->GetID(), n41->GetID(),
1696 n56->GetID(), n67->GetID(), n78->GetID(), n85->GetID(),
1697 n15->GetID(), n26->GetID(), n37->GetID(), n48->GetID());
1701 //=======================================================================
1702 //function : AddVolumeWithID
1704 //=======================================================================
1705 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3, int n4,
1706 int n5, int n6, int n7, int n8,
1707 int n12,int n23,int n34,int n41,
1708 int n56,int n67,int n78,int n85,
1709 int n15,int n26,int n37,int n48, int ID)
1711 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolumeWithID(n1,n2,n3,n4,n5,n6,n7,n8,
1714 n15,n26,n37,n48,ID);
1715 if(anElem) myScript->AddVolume(ID,n1,n2,n3,n4,n5,n6,n7,n8,n12,n23,n34,n41,
1716 n56,n67,n78,n85,n15,n26,n37,n48);
1720 //=======================================================================
1721 //function : AddVolumeWithID
1722 //purpose : 2d order Hexahedrons with 20 nodes
1723 //=======================================================================
1724 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
1725 const SMDS_MeshNode * n2,
1726 const SMDS_MeshNode * n3,
1727 const SMDS_MeshNode * n4,
1728 const SMDS_MeshNode * n5,
1729 const SMDS_MeshNode * n6,
1730 const SMDS_MeshNode * n7,
1731 const SMDS_MeshNode * n8,
1732 const SMDS_MeshNode * n12,
1733 const SMDS_MeshNode * n23,
1734 const SMDS_MeshNode * n34,
1735 const SMDS_MeshNode * n41,
1736 const SMDS_MeshNode * n56,
1737 const SMDS_MeshNode * n67,
1738 const SMDS_MeshNode * n78,
1739 const SMDS_MeshNode * n85,
1740 const SMDS_MeshNode * n15,
1741 const SMDS_MeshNode * n26,
1742 const SMDS_MeshNode * n37,
1743 const SMDS_MeshNode * n48,
1746 return AddVolumeWithID(n1->GetID(), n2->GetID(), n3->GetID(), n4->GetID(),
1747 n5->GetID(), n6->GetID(), n7->GetID(), n8->GetID(),
1748 n12->GetID(), n23->GetID(), n34->GetID(), n41->GetID(),
1749 n56->GetID(), n67->GetID(), n78->GetID(), n85->GetID(),
1750 n15->GetID(), n26->GetID(), n37->GetID(), n48->GetID(),