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 // Rm from sub-meshes
656 // Element should belong to only one sub-mesh
657 map<int,SMESHDS_SubMesh*>::iterator SubIt = theSubMeshes.begin();
658 for ( ; SubIt != theSubMeshes.end(); SubIt++ )
660 int size = isNode ? (*SubIt).second->NbNodes() : (*SubIt).second->NbElements();
661 if ( size == 0 ) continue;
663 list<const SMDS_MeshElement *>::iterator elIt = theElems.begin();
664 while ( elIt != theElems.end() )
666 bool removed = false;
668 removed = (*SubIt).second->RemoveNode( static_cast<const SMDS_MeshNode*> (*elIt) );
670 removed = (*SubIt).second->RemoveElement( *elIt );
674 elIt = theElems.erase( elIt );
675 if ( theElems.empty() )
676 return; // all elements are found and removed
686 //=======================================================================
687 //function : RemoveNode
689 //=======================================================================
690 void SMESHDS_Mesh::RemoveNode(const SMDS_MeshNode * n)
692 myScript->RemoveNode(n->GetID());
694 list<const SMDS_MeshElement *> removedElems;
695 list<const SMDS_MeshElement *> removedNodes;
697 SMDS_Mesh::RemoveElement( n, removedElems, removedNodes, true );
699 removeFromContainers( myShapeIndexToSubMesh, myGroups, removedElems, false );
700 removeFromContainers( myShapeIndexToSubMesh, myGroups, removedNodes, true );
703 //=======================================================================
704 //function : RemoveFreeNode
706 //=======================================================================
707 void SMESHDS_Mesh::RemoveFreeNode(const SMDS_MeshNode * n,
708 SMESHDS_SubMesh * subMesh,
711 myScript->RemoveNode(n->GetID());
714 // Node can belong to several groups
715 if (fromGroups && !myGroups.empty()) {
716 set<SMESHDS_GroupBase*>::iterator GrIt = myGroups.begin();
717 for (; GrIt != myGroups.end(); GrIt++) {
718 SMESHDS_Group* group = dynamic_cast<SMESHDS_Group*>(*GrIt);
719 if (!group || group->IsEmpty()) continue;
720 group->SMDSGroup().Remove(n);
725 // Node should belong to only one sub-mesh
727 subMesh->RemoveNode(n);
729 SMDS_Mesh::RemoveFreeElement(n);
732 //=======================================================================
733 //function : RemoveElement
735 //========================================================================
736 void SMESHDS_Mesh::RemoveElement(const SMDS_MeshElement * elt)
738 if (elt->GetType() == SMDSAbs_Node)
740 RemoveNode( static_cast<const SMDS_MeshNode*>( elt ));
744 myScript->RemoveElement(elt->GetID());
746 list<const SMDS_MeshElement *> removedElems;
747 list<const SMDS_MeshElement *> removedNodes;
749 SMDS_Mesh::RemoveElement(elt, removedElems, removedNodes, false);
751 removeFromContainers( myShapeIndexToSubMesh, myGroups, removedElems, false );
754 //=======================================================================
755 //function : RemoveFreeElement
757 //========================================================================
758 void SMESHDS_Mesh::RemoveFreeElement(const SMDS_MeshElement * elt,
759 SMESHDS_SubMesh * subMesh,
762 if (elt->GetType() == SMDSAbs_Node) {
763 RemoveFreeNode( static_cast<const SMDS_MeshNode*>(elt), subMesh);
767 if (hasConstructionEdges() || hasConstructionFaces())
768 // this methods is only for meshes without descendants
771 myScript->RemoveElement(elt->GetID());
774 // Node can belong to several groups
775 if ( fromGroups && !myGroups.empty() ) {
776 set<SMESHDS_GroupBase*>::iterator GrIt = myGroups.begin();
777 for (; GrIt != myGroups.end(); GrIt++) {
778 SMESHDS_Group* group = dynamic_cast<SMESHDS_Group*>(*GrIt);
779 if (group && !group->IsEmpty())
780 group->SMDSGroup().Remove(elt);
785 // Element should belong to only one sub-mesh
787 subMesh->RemoveElement(elt);
789 SMDS_Mesh::RemoveFreeElement(elt);
792 //================================================================================
794 * \brief Remove all data from the mesh
796 //================================================================================
798 void SMESHDS_Mesh::ClearMesh()
800 myScript->ClearMesh();
804 map<int,SMESHDS_SubMesh*>::iterator sub, subEnd = myShapeIndexToSubMesh.end();
805 for ( sub = myShapeIndexToSubMesh.begin(); sub != subEnd; ++sub )
806 sub->second->Clear();
809 TGroups::iterator group, groupEnd = myGroups.end();
810 for ( group = myGroups.begin(); group != groupEnd; ++group ) {
811 if ( SMESHDS_Group* g = dynamic_cast<SMESHDS_Group*>(*group)) {
812 SMDSAbs_ElementType groupType = g->GetType();
814 g->SetType( groupType );
819 //================================================================================
821 * \brief return submesh by shape
822 * \param shape - the subshape
823 * \retval SMESHDS_SubMesh* - the found submesh
825 * search of submeshes is optimized
827 //================================================================================
829 SMESHDS_SubMesh* SMESHDS_Mesh::getSubmesh( const TopoDS_Shape & shape )
831 if ( shape.IsNull() )
834 if ( !myCurSubShape.IsNull() && shape.IsSame( myCurSubShape ))
837 getSubmesh( ShapeToIndex( shape ));
838 myCurSubShape = shape;
842 //================================================================================
844 * \brief return submesh by subshape index
845 * \param Index - the subshape index
846 * \retval SMESHDS_SubMesh* - the found submesh
847 * search of submeshes is optimized
849 //================================================================================
851 SMESHDS_SubMesh* SMESHDS_Mesh::getSubmesh( const int Index )
853 //Update or build submesh
854 if ( Index != myCurSubID ) {
855 map<int,SMESHDS_SubMesh*>::iterator it = myShapeIndexToSubMesh.find( Index );
856 if ( it == myShapeIndexToSubMesh.end() )
857 it = myShapeIndexToSubMesh.insert( make_pair(Index, new SMESHDS_SubMesh() )).first;
858 myCurSubMesh = it->second;
860 myCurSubShape.Nullify(); // myCurSubShape no more corresponds to submesh
865 //================================================================================
867 * \brief Add element or node to submesh
868 * \param elem - element to add
869 * \param subMesh - submesh to be filled in
871 //================================================================================
873 bool SMESHDS_Mesh::add(const SMDS_MeshElement* elem, SMESHDS_SubMesh* subMesh )
875 if ( elem && subMesh ) {
876 if ( elem->GetType() == SMDSAbs_Node )
877 subMesh->AddNode( static_cast<const SMDS_MeshNode* >( elem ));
879 subMesh->AddElement( elem );
887 //================================================================================
889 * \brief Creates a node position in volume
891 //================================================================================
893 inline SMDS_PositionPtr volumePosition(int volId)
895 SMDS_SpacePosition* pos = new SMDS_SpacePosition();
896 pos->SetShapeId( volId );
897 return SMDS_PositionPtr(pos);
901 //=======================================================================
902 //function : SetNodeOnVolume
904 //=======================================================================
905 void SMESHDS_Mesh::SetNodeInVolume(SMDS_MeshNode * aNode,
906 const TopoDS_Shell & S)
908 if ( add( aNode, getSubmesh(S) ))
909 aNode->SetPosition ( volumePosition( myCurSubID ));
911 //=======================================================================
912 //function : SetNodeOnVolume
914 //=======================================================================
915 void SMESHDS_Mesh::SetNodeInVolume(SMDS_MeshNode * aNode,
916 const TopoDS_Solid & S)
918 if ( add( aNode, getSubmesh(S) ))
919 aNode->SetPosition ( volumePosition( myCurSubID ));
922 //=======================================================================
923 //function : SetNodeOnFace
925 //=======================================================================
926 void SMESHDS_Mesh::SetNodeOnFace(SMDS_MeshNode * aNode,
927 const TopoDS_Face & S,
931 if ( add( aNode, getSubmesh(S) ))
932 aNode->SetPosition(SMDS_PositionPtr(new SMDS_FacePosition(myCurSubID, u, v)));
935 //=======================================================================
936 //function : SetNodeOnEdge
938 //=======================================================================
939 void SMESHDS_Mesh::SetNodeOnEdge(SMDS_MeshNode * aNode,
940 const TopoDS_Edge & S,
943 if ( add( aNode, getSubmesh(S) ))
944 aNode->SetPosition(SMDS_PositionPtr(new SMDS_EdgePosition(myCurSubID, u)));
947 //=======================================================================
948 //function : SetNodeOnVertex
950 //=======================================================================
951 void SMESHDS_Mesh::SetNodeOnVertex(SMDS_MeshNode * aNode,
952 const TopoDS_Vertex & S)
954 if ( add( aNode, getSubmesh(S) ))
955 aNode->SetPosition(SMDS_PositionPtr(new SMDS_VertexPosition(myCurSubID)));
958 //=======================================================================
959 //function : UnSetNodeOnShape
961 //=======================================================================
962 void SMESHDS_Mesh::UnSetNodeOnShape(const SMDS_MeshNode* aNode)
964 if ( aNode && aNode->GetPosition() ) {
965 map<int,SMESHDS_SubMesh*>::iterator it =
966 myShapeIndexToSubMesh.find( aNode->GetPosition()->GetShapeId() );
967 if ( it != myShapeIndexToSubMesh.end() )
968 it->second->RemoveNode( aNode );
972 //=======================================================================
973 //function : SetMeshElementOnShape
975 //=======================================================================
976 void SMESHDS_Mesh::SetMeshElementOnShape(const SMDS_MeshElement * anElement,
977 const TopoDS_Shape & S)
979 add( anElement, getSubmesh(S) );
982 //=======================================================================
983 //function : UnSetMeshElementOnShape
985 //=======================================================================
986 void SMESHDS_Mesh::UnSetMeshElementOnShape(const SMDS_MeshElement * elem,
987 const TopoDS_Shape & S)
989 int Index = myIndexToShape.FindIndex(S);
991 map<int,SMESHDS_SubMesh*>::iterator it = myShapeIndexToSubMesh.find( Index );
992 if ( it != myShapeIndexToSubMesh.end() )
993 if ( elem->GetType() == SMDSAbs_Node )
994 it->second->RemoveNode( static_cast<const SMDS_MeshNode* >( elem ));
996 it->second->RemoveElement( elem );
999 //=======================================================================
1000 //function : ShapeToMesh
1002 //=======================================================================
1003 TopoDS_Shape SMESHDS_Mesh::ShapeToMesh() const
1008 //=======================================================================
1009 //function : IsGroupOfSubShapes
1010 //purpose : return true if at least one subshape of theShape is a subshape
1011 // of myShape or theShape == myShape
1012 //=======================================================================
1014 bool SMESHDS_Mesh::IsGroupOfSubShapes (const TopoDS_Shape& theShape) const
1016 if ( myShape.IsSame( theShape ))
1019 for ( TopoDS_Iterator it( theShape ); it.More(); it.Next() ) {
1020 if (myIndexToShape.Contains( it.Value() ) ||
1021 IsGroupOfSubShapes( it.Value() ))
1028 ///////////////////////////////////////////////////////////////////////////////
1029 /// Return the sub mesh linked to the a given TopoDS_Shape or NULL if the given
1030 /// TopoDS_Shape is unknown
1031 ///////////////////////////////////////////////////////////////////////////////
1032 SMESHDS_SubMesh * SMESHDS_Mesh::MeshElements(const TopoDS_Shape & S) const
1034 int Index = ShapeToIndex(S);
1035 TShapeIndexToSubMesh::const_iterator anIter = myShapeIndexToSubMesh.find(Index);
1036 if (anIter != myShapeIndexToSubMesh.end())
1037 return anIter->second;
1042 ///////////////////////////////////////////////////////////////////////////////
1043 /// Return the sub mesh by Id of shape it is linked to
1044 ///////////////////////////////////////////////////////////////////////////////
1045 SMESHDS_SubMesh * SMESHDS_Mesh::MeshElements(const int Index)
1047 TShapeIndexToSubMesh::const_iterator anIter = myShapeIndexToSubMesh.find(Index);
1048 if (anIter != myShapeIndexToSubMesh.end())
1049 return anIter->second;
1054 //=======================================================================
1055 //function : SubMeshIndices
1057 //=======================================================================
1058 list<int> SMESHDS_Mesh::SubMeshIndices()
1060 list<int> anIndices;
1061 std::map<int,SMESHDS_SubMesh*>::iterator anIter = myShapeIndexToSubMesh.begin();
1062 for (; anIter != myShapeIndexToSubMesh.end(); anIter++) {
1063 anIndices.push_back((*anIter).first);
1068 //=======================================================================
1069 //function : GetHypothesis
1071 //=======================================================================
1073 const list<const SMESHDS_Hypothesis*>&
1074 SMESHDS_Mesh::GetHypothesis(const TopoDS_Shape & S) const
1076 if ( myShapeToHypothesis.IsBound( S.Oriented(TopAbs_FORWARD) ) ) // ignore orientation of S
1077 return myShapeToHypothesis.Find( S.Oriented(TopAbs_FORWARD) );
1079 static list<const SMESHDS_Hypothesis*> empty;
1083 //=======================================================================
1084 //function : GetScript
1086 //=======================================================================
1087 SMESHDS_Script* SMESHDS_Mesh::GetScript()
1092 //=======================================================================
1093 //function : ClearScript
1095 //=======================================================================
1096 void SMESHDS_Mesh::ClearScript()
1101 //=======================================================================
1102 //function : HasMeshElements
1104 //=======================================================================
1105 bool SMESHDS_Mesh::HasMeshElements(const TopoDS_Shape & S)
1107 if (myShape.IsNull()) MESSAGE("myShape is NULL");
1108 int Index = myIndexToShape.FindIndex(S);
1109 return myShapeIndexToSubMesh.find(Index)!=myShapeIndexToSubMesh.end();
1112 //=======================================================================
1113 //function : HasHypothesis
1115 //=======================================================================
1116 bool SMESHDS_Mesh::HasHypothesis(const TopoDS_Shape & S)
1118 return myShapeToHypothesis.IsBound(S.Oriented(TopAbs_FORWARD));
1121 //=======================================================================
1122 //function : NewSubMesh
1124 //=======================================================================
1125 SMESHDS_SubMesh * SMESHDS_Mesh::NewSubMesh(int Index)
1127 SMESHDS_SubMesh* SM = 0;
1128 TShapeIndexToSubMesh::iterator anIter = myShapeIndexToSubMesh.find(Index);
1129 if (anIter == myShapeIndexToSubMesh.end())
1131 SM = new SMESHDS_SubMesh();
1132 myShapeIndexToSubMesh[Index]=SM;
1135 SM = anIter->second;
1139 //=======================================================================
1140 //function : AddCompoundSubmesh
1142 //=======================================================================
1144 int SMESHDS_Mesh::AddCompoundSubmesh(const TopoDS_Shape& S,
1145 TopAbs_ShapeEnum type)
1148 if ( IsGroupOfSubShapes( S ) || (S.ShapeType() == TopAbs_VERTEX && myIndexToShape.Contains(S)) )
1150 aMainIndex = myIndexToShape.Add( S );
1151 bool all = ( type == TopAbs_SHAPE );
1152 if ( all ) // corresponding simple submesh may exist
1153 aMainIndex = -aMainIndex;
1154 //MESSAGE("AddCompoundSubmesh index = " << aMainIndex );
1155 SMESHDS_SubMesh * aNewSub = NewSubMesh( aMainIndex );
1156 if ( !aNewSub->IsComplexSubmesh() ) // is empty
1158 int shapeType = Max( TopAbs_SOLID, all ? myShape.ShapeType() : type );
1159 int typeLimit = all ? TopAbs_VERTEX : type;
1160 for ( ; shapeType <= typeLimit; shapeType++ )
1162 TopExp_Explorer exp( S, TopAbs_ShapeEnum( shapeType ));
1163 for ( ; exp.More(); exp.Next() )
1165 int index = myIndexToShape.FindIndex( exp.Current() );
1167 aNewSub->AddSubMesh( NewSubMesh( index ));
1175 //=======================================================================
1176 //function : IndexToShape
1178 //=======================================================================
1179 const TopoDS_Shape& SMESHDS_Mesh::IndexToShape(int ShapeIndex) const
1181 return myIndexToShape.FindKey(ShapeIndex);
1184 //=======================================================================
1185 //function : ShapeToIndex
1187 //=======================================================================
1188 int SMESHDS_Mesh::ShapeToIndex(const TopoDS_Shape & S) const
1190 if (myShape.IsNull())
1191 MESSAGE("myShape is NULL");
1193 int index = myIndexToShape.FindIndex(S);
1198 //=======================================================================
1199 //function : SetNodeOnVolume
1201 //=======================================================================
1202 void SMESHDS_Mesh::SetNodeInVolume(const SMDS_MeshNode* aNode, int Index)
1204 if ( add( aNode, getSubmesh( Index )))
1205 ((SMDS_MeshNode*) aNode)->SetPosition( volumePosition( Index ));
1208 //=======================================================================
1209 //function : SetNodeOnFace
1211 //=======================================================================
1212 void SMESHDS_Mesh::SetNodeOnFace(SMDS_MeshNode* aNode, int Index, double u, double v)
1214 //Set Position on Node
1215 if ( add( aNode, getSubmesh( Index )))
1216 aNode->SetPosition(SMDS_PositionPtr(new SMDS_FacePosition(Index, u, v)));
1219 //=======================================================================
1220 //function : SetNodeOnEdge
1222 //=======================================================================
1223 void SMESHDS_Mesh::SetNodeOnEdge(SMDS_MeshNode* aNode,
1227 //Set Position on Node
1228 if ( add( aNode, getSubmesh( Index )))
1229 aNode->SetPosition(SMDS_PositionPtr(new SMDS_EdgePosition(Index, u)));
1232 //=======================================================================
1233 //function : SetNodeOnVertex
1235 //=======================================================================
1236 void SMESHDS_Mesh::SetNodeOnVertex(SMDS_MeshNode* aNode, int Index)
1238 //Set Position on Node
1239 if ( add( aNode, getSubmesh( Index )))
1240 aNode->SetPosition(SMDS_PositionPtr(new SMDS_VertexPosition(Index)));
1243 //=======================================================================
1244 //function : SetMeshElementOnShape
1246 //=======================================================================
1247 void SMESHDS_Mesh::SetMeshElementOnShape(const SMDS_MeshElement* anElement,
1250 add( anElement, getSubmesh( Index ));
1253 //=======================================================================
1254 //function : ~SMESHDS_Mesh
1256 //=======================================================================
1257 SMESHDS_Mesh::~SMESHDS_Mesh()
1262 TShapeIndexToSubMesh::iterator i_sm = myShapeIndexToSubMesh.begin();
1263 for ( ; i_sm != myShapeIndexToSubMesh.end(); ++i_sm )
1264 delete i_sm->second;
1268 //********************************************************************
1269 //********************************************************************
1270 //******** *********
1271 //***** Methods for addition of quadratic elements ******
1272 //******** *********
1273 //********************************************************************
1274 //********************************************************************
1276 //=======================================================================
1277 //function : AddEdgeWithID
1279 //=======================================================================
1280 SMDS_MeshEdge* SMESHDS_Mesh::AddEdgeWithID(int n1, int n2, int n12, int ID)
1282 SMDS_MeshEdge* anElem = SMDS_Mesh::AddEdgeWithID(n1,n2,n12,ID);
1283 if(anElem) myScript->AddEdge(ID,n1,n2,n12);
1287 //=======================================================================
1288 //function : AddEdge
1290 //=======================================================================
1291 SMDS_MeshEdge* SMESHDS_Mesh::AddEdge(const SMDS_MeshNode* n1,
1292 const SMDS_MeshNode* n2,
1293 const SMDS_MeshNode* n12)
1295 SMDS_MeshEdge* anElem = SMDS_Mesh::AddEdge(n1,n2,n12);
1296 if(anElem) myScript->AddEdge(anElem->GetID(),
1303 //=======================================================================
1304 //function : AddEdgeWithID
1306 //=======================================================================
1307 SMDS_MeshEdge* SMESHDS_Mesh::AddEdgeWithID(const SMDS_MeshNode * n1,
1308 const SMDS_MeshNode * n2,
1309 const SMDS_MeshNode * n12,
1312 return AddEdgeWithID(n1->GetID(),
1319 //=======================================================================
1320 //function : AddFace
1322 //=======================================================================
1323 SMDS_MeshFace* SMESHDS_Mesh::AddFace(const SMDS_MeshNode * n1,
1324 const SMDS_MeshNode * n2,
1325 const SMDS_MeshNode * n3,
1326 const SMDS_MeshNode * n12,
1327 const SMDS_MeshNode * n23,
1328 const SMDS_MeshNode * n31)
1330 SMDS_MeshFace *anElem = SMDS_Mesh::AddFace(n1,n2,n3,n12,n23,n31);
1331 if(anElem) myScript->AddFace(anElem->GetID(),
1332 n1->GetID(), n2->GetID(), n3->GetID(),
1333 n12->GetID(), n23->GetID(), n31->GetID());
1337 //=======================================================================
1338 //function : AddFaceWithID
1340 //=======================================================================
1341 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(int n1, int n2, int n3,
1342 int n12,int n23,int n31, int ID)
1344 SMDS_MeshFace *anElem = SMDS_Mesh::AddFaceWithID(n1,n2,n3,n12,n23,n31,ID);
1345 if(anElem) myScript->AddFace(ID,n1,n2,n3,n12,n23,n31);
1349 //=======================================================================
1350 //function : AddFaceWithID
1352 //=======================================================================
1353 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(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,
1361 return AddFaceWithID(n1->GetID(), n2->GetID(), n3->GetID(),
1362 n12->GetID(), n23->GetID(), n31->GetID(),
1367 //=======================================================================
1368 //function : AddFace
1370 //=======================================================================
1371 SMDS_MeshFace* SMESHDS_Mesh::AddFace(const SMDS_MeshNode * n1,
1372 const SMDS_MeshNode * n2,
1373 const SMDS_MeshNode * n3,
1374 const SMDS_MeshNode * n4,
1375 const SMDS_MeshNode * n12,
1376 const SMDS_MeshNode * n23,
1377 const SMDS_MeshNode * n34,
1378 const SMDS_MeshNode * n41)
1380 SMDS_MeshFace *anElem = SMDS_Mesh::AddFace(n1,n2,n3,n4,n12,n23,n34,n41);
1381 if(anElem) myScript->AddFace(anElem->GetID(),
1382 n1->GetID(), n2->GetID(), n3->GetID(), n4->GetID(),
1383 n12->GetID(), n23->GetID(), n34->GetID(), n41->GetID());
1387 //=======================================================================
1388 //function : AddFaceWithID
1390 //=======================================================================
1391 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(int n1, int n2, int n3, int n4,
1392 int n12,int n23,int n34,int n41, int ID)
1394 SMDS_MeshFace *anElem = SMDS_Mesh::AddFaceWithID(n1,n2,n3,n4,n12,n23,n34,n41,ID);
1395 if(anElem) myScript->AddFace(ID,n1,n2,n3,n4,n12,n23,n34,n41);
1399 //=======================================================================
1400 //function : AddFaceWithID
1402 //=======================================================================
1403 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(const SMDS_MeshNode * n1,
1404 const SMDS_MeshNode * n2,
1405 const SMDS_MeshNode * n3,
1406 const SMDS_MeshNode * n4,
1407 const SMDS_MeshNode * n12,
1408 const SMDS_MeshNode * n23,
1409 const SMDS_MeshNode * n34,
1410 const SMDS_MeshNode * n41,
1413 return AddFaceWithID(n1->GetID(), n2->GetID(), n3->GetID(), n4->GetID(),
1414 n12->GetID(), n23->GetID(), n34->GetID(), n41->GetID(),
1419 //=======================================================================
1420 //function : AddVolume
1422 //=======================================================================
1423 SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
1424 const SMDS_MeshNode * n2,
1425 const SMDS_MeshNode * n3,
1426 const SMDS_MeshNode * n4,
1427 const SMDS_MeshNode * n12,
1428 const SMDS_MeshNode * n23,
1429 const SMDS_MeshNode * n31,
1430 const SMDS_MeshNode * n14,
1431 const SMDS_MeshNode * n24,
1432 const SMDS_MeshNode * n34)
1434 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1,n2,n3,n4,n12,n23,n31,n14,n24,n34);
1435 if(anElem) myScript->AddVolume(anElem->GetID(),
1436 n1->GetID(), n2->GetID(), n3->GetID(), n4->GetID(),
1437 n12->GetID(), n23->GetID(), n31->GetID(),
1438 n14->GetID(), n24->GetID(), n34->GetID());
1442 //=======================================================================
1443 //function : AddVolumeWithID
1445 //=======================================================================
1446 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3, int n4,
1447 int n12,int n23,int n31,
1448 int n14,int n24,int n34, int ID)
1450 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolumeWithID(n1,n2,n3,n4,n12,n23,
1451 n31,n14,n24,n34,ID);
1452 if(anElem) myScript->AddVolume(ID,n1,n2,n3,n4,n12,n23,n31,n14,n24,n34);
1456 //=======================================================================
1457 //function : AddVolumeWithID
1458 //purpose : 2d order tetrahedron of 10 nodes
1459 //=======================================================================
1460 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
1461 const SMDS_MeshNode * n2,
1462 const SMDS_MeshNode * n3,
1463 const SMDS_MeshNode * n4,
1464 const SMDS_MeshNode * n12,
1465 const SMDS_MeshNode * n23,
1466 const SMDS_MeshNode * n31,
1467 const SMDS_MeshNode * n14,
1468 const SMDS_MeshNode * n24,
1469 const SMDS_MeshNode * n34,
1472 return AddVolumeWithID(n1->GetID(), n2->GetID(), n3->GetID(), n4->GetID(),
1473 n12->GetID(), n23->GetID(), n31->GetID(),
1474 n14->GetID(), n24->GetID(), n34->GetID(), ID);
1478 //=======================================================================
1479 //function : AddVolume
1481 //=======================================================================
1482 SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
1483 const SMDS_MeshNode * n2,
1484 const SMDS_MeshNode * n3,
1485 const SMDS_MeshNode * n4,
1486 const SMDS_MeshNode * n5,
1487 const SMDS_MeshNode * n12,
1488 const SMDS_MeshNode * n23,
1489 const SMDS_MeshNode * n34,
1490 const SMDS_MeshNode * n41,
1491 const SMDS_MeshNode * n15,
1492 const SMDS_MeshNode * n25,
1493 const SMDS_MeshNode * n35,
1494 const SMDS_MeshNode * n45)
1496 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1,n2,n3,n4,n5,n12,n23,n34,n41,
1499 myScript->AddVolume(anElem->GetID(), n1->GetID(), n2->GetID(),
1500 n3->GetID(), n4->GetID(), n5->GetID(),
1501 n12->GetID(), n23->GetID(), n34->GetID(), n41->GetID(),
1502 n15->GetID(), n25->GetID(), n35->GetID(), n45->GetID());
1506 //=======================================================================
1507 //function : AddVolumeWithID
1509 //=======================================================================
1510 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3, int n4, int n5,
1511 int n12,int n23,int n34,int n41,
1512 int n15,int n25,int n35,int n45, int ID)
1514 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolumeWithID(n1,n2,n3,n4,n5,
1516 n15,n25,n35,n45,ID);
1517 if(anElem) myScript->AddVolume(ID,n1,n2,n3,n4,n5,n12,n23,n34,n41,
1522 //=======================================================================
1523 //function : AddVolumeWithID
1524 //purpose : 2d order pyramid of 13 nodes
1525 //=======================================================================
1526 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
1527 const SMDS_MeshNode * n2,
1528 const SMDS_MeshNode * n3,
1529 const SMDS_MeshNode * n4,
1530 const SMDS_MeshNode * n5,
1531 const SMDS_MeshNode * n12,
1532 const SMDS_MeshNode * n23,
1533 const SMDS_MeshNode * n34,
1534 const SMDS_MeshNode * n41,
1535 const SMDS_MeshNode * n15,
1536 const SMDS_MeshNode * n25,
1537 const SMDS_MeshNode * n35,
1538 const SMDS_MeshNode * n45,
1541 return AddVolumeWithID(n1->GetID(), n2->GetID(), n3->GetID(),
1542 n4->GetID(), n5->GetID(),
1543 n12->GetID(), n23->GetID(), n34->GetID(), n41->GetID(),
1544 n15->GetID(), n25->GetID(), n35->GetID(), n45->GetID(),
1549 //=======================================================================
1550 //function : AddVolume
1552 //=======================================================================
1553 SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
1554 const SMDS_MeshNode * n2,
1555 const SMDS_MeshNode * n3,
1556 const SMDS_MeshNode * n4,
1557 const SMDS_MeshNode * n5,
1558 const SMDS_MeshNode * n6,
1559 const SMDS_MeshNode * n12,
1560 const SMDS_MeshNode * n23,
1561 const SMDS_MeshNode * n31,
1562 const SMDS_MeshNode * n45,
1563 const SMDS_MeshNode * n56,
1564 const SMDS_MeshNode * n64,
1565 const SMDS_MeshNode * n14,
1566 const SMDS_MeshNode * n25,
1567 const SMDS_MeshNode * n36)
1569 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1,n2,n3,n4,n5,n6,n12,n23,n31,
1570 n45,n56,n64,n14,n25,n36);
1572 myScript->AddVolume(anElem->GetID(), n1->GetID(), n2->GetID(),
1573 n3->GetID(), n4->GetID(), n5->GetID(), n6->GetID(),
1574 n12->GetID(), n23->GetID(), n31->GetID(),
1575 n45->GetID(), n56->GetID(), n64->GetID(),
1576 n14->GetID(), n25->GetID(), n36->GetID());
1580 //=======================================================================
1581 //function : AddVolumeWithID
1583 //=======================================================================
1584 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3,
1585 int n4, int n5, int n6,
1586 int n12,int n23,int n31,
1587 int n45,int n56,int n64,
1588 int n14,int n25,int n36, int ID)
1590 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolumeWithID(n1,n2,n3,n4,n5,n6,
1594 if(anElem) myScript->AddVolume(ID,n1,n2,n3,n4,n5,n6,n12,n23,n31,
1595 n45,n56,n64,n14,n25,n36);
1599 //=======================================================================
1600 //function : AddVolumeWithID
1601 //purpose : 2d order Pentahedron with 15 nodes
1602 //=======================================================================
1603 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
1604 const SMDS_MeshNode * n2,
1605 const SMDS_MeshNode * n3,
1606 const SMDS_MeshNode * n4,
1607 const SMDS_MeshNode * n5,
1608 const SMDS_MeshNode * n6,
1609 const SMDS_MeshNode * n12,
1610 const SMDS_MeshNode * n23,
1611 const SMDS_MeshNode * n31,
1612 const SMDS_MeshNode * n45,
1613 const SMDS_MeshNode * n56,
1614 const SMDS_MeshNode * n64,
1615 const SMDS_MeshNode * n14,
1616 const SMDS_MeshNode * n25,
1617 const SMDS_MeshNode * n36,
1620 return AddVolumeWithID(n1->GetID(), n2->GetID(), n3->GetID(),
1621 n4->GetID(), n5->GetID(), n6->GetID(),
1622 n12->GetID(), n23->GetID(), n31->GetID(),
1623 n45->GetID(), n56->GetID(), n64->GetID(),
1624 n14->GetID(), n25->GetID(), n36->GetID(),
1629 //=======================================================================
1630 //function : AddVolume
1632 //=======================================================================
1633 SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(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 * n7,
1640 const SMDS_MeshNode * n8,
1641 const SMDS_MeshNode * n12,
1642 const SMDS_MeshNode * n23,
1643 const SMDS_MeshNode * n34,
1644 const SMDS_MeshNode * n41,
1645 const SMDS_MeshNode * n56,
1646 const SMDS_MeshNode * n67,
1647 const SMDS_MeshNode * n78,
1648 const SMDS_MeshNode * n85,
1649 const SMDS_MeshNode * n15,
1650 const SMDS_MeshNode * n26,
1651 const SMDS_MeshNode * n37,
1652 const SMDS_MeshNode * n48)
1654 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1,n2,n3,n4,n5,n6,n7,n8,
1659 myScript->AddVolume(anElem->GetID(), n1->GetID(), n2->GetID(),
1660 n3->GetID(), n4->GetID(), n5->GetID(),
1661 n6->GetID(), n7->GetID(), n8->GetID(),
1662 n12->GetID(), n23->GetID(), n34->GetID(), n41->GetID(),
1663 n56->GetID(), n67->GetID(), n78->GetID(), n85->GetID(),
1664 n15->GetID(), n26->GetID(), n37->GetID(), n48->GetID());
1668 //=======================================================================
1669 //function : AddVolumeWithID
1671 //=======================================================================
1672 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3, int n4,
1673 int n5, int n6, int n7, int n8,
1674 int n12,int n23,int n34,int n41,
1675 int n56,int n67,int n78,int n85,
1676 int n15,int n26,int n37,int n48, int ID)
1678 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolumeWithID(n1,n2,n3,n4,n5,n6,n7,n8,
1681 n15,n26,n37,n48,ID);
1682 if(anElem) myScript->AddVolume(ID,n1,n2,n3,n4,n5,n6,n7,n8,n12,n23,n34,n41,
1683 n56,n67,n78,n85,n15,n26,n37,n48);
1687 //=======================================================================
1688 //function : AddVolumeWithID
1689 //purpose : 2d order Hexahedrons with 20 nodes
1690 //=======================================================================
1691 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
1692 const SMDS_MeshNode * n2,
1693 const SMDS_MeshNode * n3,
1694 const SMDS_MeshNode * n4,
1695 const SMDS_MeshNode * n5,
1696 const SMDS_MeshNode * n6,
1697 const SMDS_MeshNode * n7,
1698 const SMDS_MeshNode * n8,
1699 const SMDS_MeshNode * n12,
1700 const SMDS_MeshNode * n23,
1701 const SMDS_MeshNode * n34,
1702 const SMDS_MeshNode * n41,
1703 const SMDS_MeshNode * n56,
1704 const SMDS_MeshNode * n67,
1705 const SMDS_MeshNode * n78,
1706 const SMDS_MeshNode * n85,
1707 const SMDS_MeshNode * n15,
1708 const SMDS_MeshNode * n26,
1709 const SMDS_MeshNode * n37,
1710 const SMDS_MeshNode * n48,
1713 return AddVolumeWithID(n1->GetID(), n2->GetID(), n3->GetID(), n4->GetID(),
1714 n5->GetID(), n6->GetID(), n7->GetID(), n8->GetID(),
1715 n12->GetID(), n23->GetID(), n34->GetID(), n41->GetID(),
1716 n56->GetID(), n67->GetID(), n78->GetID(), n85->GetID(),
1717 n15->GetID(), n26->GetID(), n37->GetID(), n48->GetID(),