1 // Copyright (C) 2007-2016 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, or (at your option) any later version.
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
23 // SMESH SMESHDS : management of mesh data and SMESH document
24 // File : SMESH_Mesh.cxx
25 // Author : Yves FRICAUD, OCC
28 #include "SMESHDS_Mesh.hxx"
30 #include "SMDS_Downward.hxx"
31 #include "SMDS_EdgePosition.hxx"
32 #include "SMDS_FacePosition.hxx"
33 #include "SMDS_SpacePosition.hxx"
34 #include "SMDS_VertexPosition.hxx"
35 #include "SMESHDS_Group.hxx"
36 #include "SMESHDS_GroupOnGeom.hxx"
37 #include "SMESHDS_Script.hxx"
38 #include "SMESHDS_TSubMeshHolder.hxx"
40 #include <Standard_ErrorHandler.hxx>
41 #include <Standard_OutOfRange.hxx>
43 #include <TopExp_Explorer.hxx>
44 #include <TopoDS_Edge.hxx>
45 #include <TopoDS_Face.hxx>
46 #include <TopoDS_Iterator.hxx>
47 #include <TopoDS_Shell.hxx>
48 #include <TopoDS_Solid.hxx>
49 #include <TopoDS_Vertex.hxx>
51 #include "utilities.h"
55 class SMESHDS_Mesh::SubMeshHolder : public SMESHDS_TSubMeshHolder< const SMESHDS_SubMesh >
59 //=======================================================================
62 //=======================================================================
63 SMESHDS_Mesh::SMESHDS_Mesh(int theMeshID, bool theIsEmbeddedMode):
65 mySubMeshHolder( new SubMeshHolder ),
66 myIsEmbeddedMode(theIsEmbeddedMode)
68 myScript = new SMESHDS_Script(theIsEmbeddedMode);
69 SetPersistentId(theMeshID);
72 //=======================================================================
73 bool SMESHDS_Mesh::IsEmbeddedMode()
75 return myIsEmbeddedMode;
78 //================================================================================
80 * \brief Store ID persistent during lifecycle
82 * Initially it was used to have a persistent reference to the mesh from the hypothesis
84 //================================================================================
86 void SMESHDS_Mesh::SetPersistentId(int id)
91 //================================================================================
93 * \brief Return ID persistent during lifecycle
95 //================================================================================
97 int SMESHDS_Mesh::GetPersistentId() const
99 return myPersistentID;
102 //=======================================================================
103 //function : ShapeToMesh
105 //=======================================================================
106 void SMESHDS_Mesh::ShapeToMesh(const TopoDS_Shape & S)
108 if ( !myShape.IsNull() && S.IsNull() )
110 // removal of a shape to mesh, delete ...
112 myShapeToHypothesis.Clear();
113 // - shape indices in SMDS_Position of nodes
114 SMESHDS_SubMeshIteratorPtr smIt = SubMeshes();
115 while ( SMESHDS_SubMesh* sm = const_cast< SMESHDS_SubMesh* >( smIt->next() )) {
116 if ( !sm->IsComplexSubmesh() ) {
117 SMDS_NodeIteratorPtr nIt = sm->GetNodes();
118 while ( nIt->more() )
119 sm->RemoveNode(nIt->next(), false);
123 mySubMeshHolder->DeleteAll();
125 myIndexToShape.Clear();
126 // - groups on geometry
127 set<SMESHDS_GroupBase*>::iterator gr = myGroups.begin();
128 while ( gr != myGroups.end() ) {
129 if ( dynamic_cast<SMESHDS_GroupOnGeom*>( *gr ))
130 myGroups.erase( gr++ );
138 TopExp::MapShapes(myShape, myIndexToShape);
142 //=======================================================================
143 //function : AddHypothesis
145 //=======================================================================
147 bool SMESHDS_Mesh::AddHypothesis(const TopoDS_Shape & SS,
148 const SMESHDS_Hypothesis * H)
150 if (!myShapeToHypothesis.IsBound(SS/*.Oriented(TopAbs_FORWARD)*/)) {
151 list<const SMESHDS_Hypothesis *> aList;
152 myShapeToHypothesis.Bind(SS/*.Oriented(TopAbs_FORWARD)*/, aList);
154 list<const SMESHDS_Hypothesis *>& alist =
155 myShapeToHypothesis(SS/*.Oriented(TopAbs_FORWARD)*/); // ignore orientation of SS
157 //Check if the Hypothesis is still present
158 list<const SMESHDS_Hypothesis*>::iterator ith = find(alist.begin(),alist.end(), H );
160 if (alist.end() != ith) return false;
166 //=======================================================================
167 //function : RemoveHypothesis
169 //=======================================================================
171 bool SMESHDS_Mesh::RemoveHypothesis(const TopoDS_Shape & S,
172 const SMESHDS_Hypothesis * H)
174 if( myShapeToHypothesis.IsBound( S/*.Oriented(TopAbs_FORWARD)*/ ) )
176 list<const SMESHDS_Hypothesis *>& alist=myShapeToHypothesis.ChangeFind( S/*.Oriented(TopAbs_FORWARD)*/ );
177 list<const SMESHDS_Hypothesis*>::iterator ith=find(alist.begin(),alist.end(), H );
178 if (ith != alist.end())
187 //=======================================================================
190 //=======================================================================
191 SMDS_MeshNode* SMESHDS_Mesh::AddNode(double x, double y, double z){
192 SMDS_MeshNode* node = SMDS_Mesh::AddNode(x, y, z);
193 if(node!=NULL) myScript->AddNode(node->GetID(), x, y, z);
197 SMDS_MeshNode* SMESHDS_Mesh::AddNodeWithID(double x, double y, double z, int ID){
198 SMDS_MeshNode* node = SMDS_Mesh::AddNodeWithID(x,y,z,ID);
199 if(node!=NULL) myScript->AddNode(node->GetID(), x, y, z);
203 //=======================================================================
204 //function : MoveNode
206 //=======================================================================
208 void SMESHDS_Mesh::MoveNode(const SMDS_MeshNode *n, double x, double y, double z)
210 SMDS_Mesh::MoveNode( n, x, y, z );
211 myScript->MoveNode(n->GetID(), x, y, z);
214 //=======================================================================
215 //function : ChangeElementNodes
216 //purpose : Changed nodes of an element provided that nb of nodes does not change
217 //=======================================================================
219 bool SMESHDS_Mesh::ChangeElementNodes(const SMDS_MeshElement * elem,
220 const SMDS_MeshNode * nodes[],
223 if ( ! SMDS_Mesh::ChangeElementNodes( elem, nodes, nbnodes ))
226 vector<int> IDs( nbnodes );
227 for ( int i = 0; i < nbnodes; i++ )
228 IDs [ i ] = nodes[ i ]->GetID();
229 myScript->ChangeElementNodes( elem->GetID(), &IDs[0], nbnodes);
234 //=======================================================================
235 //function : ChangePolygonNodes
237 //=======================================================================
238 bool SMESHDS_Mesh::ChangePolygonNodes
239 (const SMDS_MeshElement * elem,
240 vector<const SMDS_MeshNode*> nodes)
242 ASSERT(nodes.size() > 3);
244 return ChangeElementNodes(elem, &nodes[0], nodes.size());
247 //=======================================================================
248 //function : ChangePolyhedronNodes
250 //=======================================================================
251 bool SMESHDS_Mesh::ChangePolyhedronNodes
252 (const SMDS_MeshElement * elem,
253 std::vector<const SMDS_MeshNode*> nodes,
254 std::vector<int> quantities)
256 ASSERT(nodes.size() > 3);
258 if (!SMDS_Mesh::ChangePolyhedronNodes(elem, nodes, quantities))
261 int i, len = nodes.size();
262 std::vector<int> nodes_ids (len);
263 for (i = 0; i < len; i++) {
264 nodes_ids[i] = nodes[i]->GetID();
266 myScript->ChangePolyhedronNodes(elem->GetID(), nodes_ids, quantities);
271 //=======================================================================
272 //function : Renumber
274 //=======================================================================
276 void SMESHDS_Mesh::Renumber (const bool isNodes, const int startID, const int deltaID)
278 // TODO not possible yet to have node numbers not starting to O and continuous.
279 if (!this->isCompacted())
281 // SMDS_Mesh::Renumber( isNodes, startID, deltaID );
282 // myScript->Renumber( isNodes, startID, deltaID );
285 //=======================================================================
286 //function : Add0DElement
288 //=======================================================================
289 SMDS_Mesh0DElement* SMESHDS_Mesh::Add0DElementWithID(int nodeID, int ID)
291 SMDS_Mesh0DElement* anElem = SMDS_Mesh::Add0DElementWithID(nodeID, ID);
292 if (anElem) myScript->Add0DElement(ID, nodeID);
296 SMDS_Mesh0DElement* SMESHDS_Mesh::Add0DElementWithID
297 (const SMDS_MeshNode * node, int ID)
299 return Add0DElementWithID(node->GetID(), ID);
302 SMDS_Mesh0DElement* SMESHDS_Mesh::Add0DElement(const SMDS_MeshNode * node)
304 SMDS_Mesh0DElement* anElem = SMDS_Mesh::Add0DElement(node);
305 if (anElem) myScript->Add0DElement(anElem->GetID(), node->GetID());
309 //=======================================================================
310 //function :AddBallWithID
312 //=======================================================================
314 SMDS_BallElement* SMESHDS_Mesh::AddBallWithID(int node, double diameter, int ID)
316 SMDS_BallElement* anElem = SMDS_Mesh::AddBallWithID(node,diameter,ID);
317 if (anElem) myScript->AddBall(anElem->GetID(), node, diameter);
321 SMDS_BallElement* SMESHDS_Mesh::AddBallWithID(const SMDS_MeshNode * node,
325 SMDS_BallElement* anElem = SMDS_Mesh::AddBallWithID(node,diameter,ID);
326 if (anElem) myScript->AddBall(anElem->GetID(), node->GetID(), diameter);
330 SMDS_BallElement* SMESHDS_Mesh::AddBall (const SMDS_MeshNode * node,
333 SMDS_BallElement* anElem = SMDS_Mesh::AddBall(node,diameter);
334 if (anElem) myScript->AddBall(anElem->GetID(), node->GetID(), diameter);
338 //=======================================================================
339 //function :AddEdgeWithID
341 //=======================================================================
343 SMDS_MeshEdge* SMESHDS_Mesh::AddEdgeWithID(int n1, int n2, int ID)
345 SMDS_MeshEdge* anElem = SMDS_Mesh::AddEdgeWithID(n1,n2,ID);
346 if(anElem) myScript->AddEdge(ID,n1,n2);
350 SMDS_MeshEdge* SMESHDS_Mesh::AddEdgeWithID(const SMDS_MeshNode * n1,
351 const SMDS_MeshNode * n2,
354 return AddEdgeWithID(n1->GetID(),
359 SMDS_MeshEdge* SMESHDS_Mesh::AddEdge(const SMDS_MeshNode * n1,
360 const SMDS_MeshNode * n2)
362 SMDS_MeshEdge* anElem = SMDS_Mesh::AddEdge(n1,n2);
363 if(anElem) myScript->AddEdge(anElem->GetID(),
369 //=======================================================================
372 //=======================================================================
373 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(int n1, int n2, int n3, int ID)
375 SMDS_MeshFace *anElem = SMDS_Mesh::AddFaceWithID(n1, n2, n3, ID);
376 if(anElem) myScript->AddFace(ID,n1,n2,n3);
380 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(const SMDS_MeshNode * n1,
381 const SMDS_MeshNode * n2,
382 const SMDS_MeshNode * n3,
385 return AddFaceWithID(n1->GetID(),
391 SMDS_MeshFace* SMESHDS_Mesh::AddFace( const SMDS_MeshNode * n1,
392 const SMDS_MeshNode * n2,
393 const SMDS_MeshNode * n3)
395 SMDS_MeshFace *anElem = SMDS_Mesh::AddFace(n1, n2, n3);
396 if(anElem) myScript->AddFace(anElem->GetID(),
403 //=======================================================================
406 //=======================================================================
407 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(int n1, int n2, int n3, int n4, int ID)
409 SMDS_MeshFace *anElem = SMDS_Mesh::AddFaceWithID(n1, n2, n3, n4, ID);
410 if(anElem) myScript->AddFace(ID, n1, n2, n3, n4);
414 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(const SMDS_MeshNode * n1,
415 const SMDS_MeshNode * n2,
416 const SMDS_MeshNode * n3,
417 const SMDS_MeshNode * n4,
420 return AddFaceWithID(n1->GetID(),
427 SMDS_MeshFace* SMESHDS_Mesh::AddFace(const SMDS_MeshNode * n1,
428 const SMDS_MeshNode * n2,
429 const SMDS_MeshNode * n3,
430 const SMDS_MeshNode * n4)
432 SMDS_MeshFace *anElem = SMDS_Mesh::AddFace(n1, n2, n3, n4);
433 if(anElem) myScript->AddFace(anElem->GetID(),
441 //=======================================================================
442 //function :AddVolume
444 //=======================================================================
445 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3, int n4, int ID)
447 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolumeWithID(n1, n2, n3, n4, ID);
448 if(anElem) myScript->AddVolume(ID, n1, n2, n3, n4);
452 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
453 const SMDS_MeshNode * n2,
454 const SMDS_MeshNode * n3,
455 const SMDS_MeshNode * n4,
458 return AddVolumeWithID(n1->GetID(),
465 SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
466 const SMDS_MeshNode * n2,
467 const SMDS_MeshNode * n3,
468 const SMDS_MeshNode * n4)
470 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1, n2, n3, n4);
471 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 ID)
485 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolumeWithID(n1, n2, n3, n4, n5, ID);
486 if(anElem) myScript->AddVolume(ID, n1, n2, n3, n4, n5);
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,
497 return AddVolumeWithID(n1->GetID(),
505 SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
506 const SMDS_MeshNode * n2,
507 const SMDS_MeshNode * n3,
508 const SMDS_MeshNode * n4,
509 const SMDS_MeshNode * n5)
511 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1, n2, n3, n4, n5);
512 if(anElem) myScript->AddVolume(anElem->GetID(),
521 //=======================================================================
522 //function :AddVolume
524 //=======================================================================
525 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3, int n4, int n5, int n6, int ID)
527 SMDS_MeshVolume *anElem= SMDS_Mesh::AddVolumeWithID(n1, n2, n3, n4, n5, n6, ID);
528 if(anElem) myScript->AddVolume(ID, n1, n2, n3, n4, n5, n6);
532 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
533 const SMDS_MeshNode * n2,
534 const SMDS_MeshNode * n3,
535 const SMDS_MeshNode * n4,
536 const SMDS_MeshNode * n5,
537 const SMDS_MeshNode * n6,
540 return AddVolumeWithID(n1->GetID(),
549 SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
550 const SMDS_MeshNode * n2,
551 const SMDS_MeshNode * n3,
552 const SMDS_MeshNode * n4,
553 const SMDS_MeshNode * n5,
554 const SMDS_MeshNode * n6)
556 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1, n2, n3, n4, n5, n6);
557 if(anElem) myScript->AddVolume(anElem->GetID(),
567 //=======================================================================
568 //function :AddVolume
570 //=======================================================================
571 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3, int n4, int n5, int n6, int n7, int n8, int ID)
573 SMDS_MeshVolume *anElem= SMDS_Mesh::AddVolumeWithID(n1, n2, n3, n4, n5, n6, n7, n8, ID);
574 if(anElem) myScript->AddVolume(ID, n1, n2, n3, n4, n5, n6, n7, n8);
578 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
579 const SMDS_MeshNode * n2,
580 const SMDS_MeshNode * n3,
581 const SMDS_MeshNode * n4,
582 const SMDS_MeshNode * n5,
583 const SMDS_MeshNode * n6,
584 const SMDS_MeshNode * n7,
585 const SMDS_MeshNode * n8,
588 return AddVolumeWithID(n1->GetID(),
599 SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
600 const SMDS_MeshNode * n2,
601 const SMDS_MeshNode * n3,
602 const SMDS_MeshNode * n4,
603 const SMDS_MeshNode * n5,
604 const SMDS_MeshNode * n6,
605 const SMDS_MeshNode * n7,
606 const SMDS_MeshNode * n8)
608 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1, n2, n3, n4, n5, n6, n7, n8);
609 if(anElem) myScript->AddVolume(anElem->GetID(),
622 //=======================================================================
623 //function :AddVolume
624 //purpose : add hexagonal prism
625 //=======================================================================
626 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3, int n4,
627 int n5, int n6, int n7, int n8,
628 int n9, int n10, int n11, int n12,
631 SMDS_MeshVolume *anElem= SMDS_Mesh::AddVolumeWithID(n1, n2, n3, n4, n5, n6, n7, n8, n9, n10, n11, n12, ID);
632 if(anElem) myScript->AddVolume(ID, n1, n2, n3, n4, n5, n6, n7, n8, n9, n10, n11, n12);
636 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
637 const SMDS_MeshNode * n2,
638 const SMDS_MeshNode * n3,
639 const SMDS_MeshNode * n4,
640 const SMDS_MeshNode * n5,
641 const SMDS_MeshNode * n6,
642 const SMDS_MeshNode * n7,
643 const SMDS_MeshNode * n8,
644 const SMDS_MeshNode * n9,
645 const SMDS_MeshNode * n10,
646 const SMDS_MeshNode * n11,
647 const SMDS_MeshNode * n12,
650 return AddVolumeWithID(n1->GetID(),
665 SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
666 const SMDS_MeshNode * n2,
667 const SMDS_MeshNode * n3,
668 const SMDS_MeshNode * n4,
669 const SMDS_MeshNode * n5,
670 const SMDS_MeshNode * n6,
671 const SMDS_MeshNode * n7,
672 const SMDS_MeshNode * n8,
673 const SMDS_MeshNode * n9,
674 const SMDS_MeshNode * n10,
675 const SMDS_MeshNode * n11,
676 const SMDS_MeshNode * n12)
678 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1, n2, n3, n4, n5, n6, n7, n8, n9, n10, n11, n12);
679 if(anElem) myScript->AddVolume(anElem->GetID(),
696 //=======================================================================
697 //function : AddPolygonalFace
699 //=======================================================================
700 SMDS_MeshFace* SMESHDS_Mesh::AddPolygonalFaceWithID (const std::vector<int>& nodes_ids,
703 SMDS_MeshFace *anElem = SMDS_Mesh::AddPolygonalFaceWithID(nodes_ids, ID);
705 myScript->AddPolygonalFace(ID, nodes_ids);
711 SMESHDS_Mesh::AddPolygonalFaceWithID (const std::vector<const SMDS_MeshNode*>& nodes,
714 SMDS_MeshFace *anElem = SMDS_Mesh::AddPolygonalFaceWithID(nodes, ID);
716 int i, len = nodes.size();
717 std::vector<int> nodes_ids (len);
718 for (i = 0; i < len; i++) {
719 nodes_ids[i] = nodes[i]->GetID();
721 myScript->AddPolygonalFace(ID, nodes_ids);
727 SMESHDS_Mesh::AddPolygonalFace (const std::vector<const SMDS_MeshNode*>& nodes)
729 SMDS_MeshFace *anElem = SMDS_Mesh::AddPolygonalFace(nodes);
731 int i, len = nodes.size();
732 std::vector<int> nodes_ids (len);
733 for (i = 0; i < len; i++) {
734 nodes_ids[i] = nodes[i]->GetID();
736 myScript->AddPolygonalFace(anElem->GetID(), nodes_ids);
742 //=======================================================================
743 //function : AddQuadPolygonalFace
745 //=======================================================================
746 SMDS_MeshFace* SMESHDS_Mesh::AddQuadPolygonalFaceWithID (const std::vector<int>& nodes_ids,
749 SMDS_MeshFace *anElem = SMDS_Mesh::AddQuadPolygonalFaceWithID(nodes_ids, ID);
751 myScript->AddQuadPolygonalFace(ID, nodes_ids);
757 SMESHDS_Mesh::AddQuadPolygonalFaceWithID (const std::vector<const SMDS_MeshNode*>& nodes,
760 SMDS_MeshFace *anElem = SMDS_Mesh::AddQuadPolygonalFaceWithID(nodes, ID);
762 int i, len = nodes.size();
763 std::vector<int> nodes_ids (len);
764 for (i = 0; i < len; i++) {
765 nodes_ids[i] = nodes[i]->GetID();
767 myScript->AddQuadPolygonalFace(ID, nodes_ids);
773 SMESHDS_Mesh::AddQuadPolygonalFace (const std::vector<const SMDS_MeshNode*>& nodes)
775 SMDS_MeshFace *anElem = SMDS_Mesh::AddQuadPolygonalFace(nodes);
777 int i, len = nodes.size();
778 std::vector<int> nodes_ids (len);
779 for (i = 0; i < len; i++) {
780 nodes_ids[i] = nodes[i]->GetID();
782 myScript->AddQuadPolygonalFace(anElem->GetID(), nodes_ids);
788 //=======================================================================
789 //function : AddPolyhedralVolume
791 //=======================================================================
792 SMDS_MeshVolume* SMESHDS_Mesh::AddPolyhedralVolumeWithID (const std::vector<int>& nodes_ids,
793 const std::vector<int>& quantities,
796 SMDS_MeshVolume *anElem = SMDS_Mesh::AddPolyhedralVolumeWithID(nodes_ids, quantities, ID);
798 myScript->AddPolyhedralVolume(ID, nodes_ids, quantities);
803 SMDS_MeshVolume* SMESHDS_Mesh::AddPolyhedralVolumeWithID
804 (const std::vector<const SMDS_MeshNode*>& nodes,
805 const std::vector<int>& quantities,
808 SMDS_MeshVolume *anElem = SMDS_Mesh::AddPolyhedralVolumeWithID(nodes, quantities, ID);
810 int i, len = nodes.size();
811 std::vector<int> nodes_ids (len);
812 for (i = 0; i < len; i++) {
813 nodes_ids[i] = nodes[i]->GetID();
815 myScript->AddPolyhedralVolume(ID, nodes_ids, quantities);
820 SMDS_MeshVolume* SMESHDS_Mesh::AddPolyhedralVolume
821 (const std::vector<const SMDS_MeshNode*>& nodes,
822 const std::vector<int>& quantities)
824 SMDS_MeshVolume *anElem = SMDS_Mesh::AddPolyhedralVolume(nodes, quantities);
826 int i, len = nodes.size();
827 std::vector<int> nodes_ids (len);
828 for (i = 0; i < len; i++) {
829 nodes_ids[i] = nodes[i]->GetID();
831 myScript->AddPolyhedralVolume(anElem->GetID(), nodes_ids, quantities);
836 //=======================================================================
837 //function : removeFromContainers
839 //=======================================================================
841 static void removeFromContainers (SMESHDS_Mesh* theMesh,
842 set<SMESHDS_GroupBase*>& theGroups,
843 list<const SMDS_MeshElement*>& theElems,
846 if ( theElems.empty() )
850 // Element can belong to several groups
851 if ( !theGroups.empty() )
853 set<SMESHDS_GroupBase*>::iterator GrIt = theGroups.begin();
854 for ( ; GrIt != theGroups.end(); GrIt++ )
856 SMESHDS_Group* group = dynamic_cast<SMESHDS_Group*>( *GrIt );
857 if ( !group || group->IsEmpty() ) continue;
859 list<const SMDS_MeshElement *>::iterator elIt = theElems.begin();
860 for ( ; elIt != theElems.end(); elIt++ )
862 group->SMDSGroup().Remove( *elIt );
863 if ( group->IsEmpty() ) break;
868 const bool deleted=true;
870 // Rm from sub-meshes
871 // Element should belong to only one sub-mesh
872 if ( theMesh->SubMeshes()->more() )
874 list<const SMDS_MeshElement *>::iterator elIt = theElems.begin();
876 for ( ; elIt != theElems.end(); ++elIt )
877 if ( SMESHDS_SubMesh* sm = theMesh->MeshElements( (*elIt)->getshapeId() ))
878 sm->RemoveNode( static_cast<const SMDS_MeshNode*> (*elIt), deleted );
881 for ( ; elIt != theElems.end(); ++elIt )
882 if ( SMESHDS_SubMesh* sm = theMesh->MeshElements( (*elIt)->getshapeId() ))
883 sm->RemoveElement( *elIt, deleted );
888 //=======================================================================
889 //function : RemoveNode
891 //=======================================================================
892 void SMESHDS_Mesh::RemoveNode(const SMDS_MeshNode * n)
894 if ( n->NbInverseElements() == 0 && !(hasConstructionEdges() || hasConstructionFaces()))
896 RemoveFreeNode( n, 0, true );
900 myScript->RemoveNode(n->GetID());
902 list<const SMDS_MeshElement *> removedElems;
903 list<const SMDS_MeshElement *> removedNodes;
905 SMDS_Mesh::RemoveElement( n, removedElems, removedNodes, true );
907 removeFromContainers( this, myGroups, removedElems, false );
908 removeFromContainers( this, myGroups, removedNodes, true );
911 //=======================================================================
912 //function : RemoveFreeNode
914 //=======================================================================
915 void SMESHDS_Mesh::RemoveFreeNode(const SMDS_MeshNode * n,
916 SMESHDS_SubMesh * subMesh,
919 myScript->RemoveNode(n->GetID());
922 // Node can belong to several groups
923 if (fromGroups && !myGroups.empty()) {
924 set<SMESHDS_GroupBase*>::iterator GrIt = myGroups.begin();
925 for (; GrIt != myGroups.end(); GrIt++) {
926 SMESHDS_Group* group = dynamic_cast<SMESHDS_Group*>(*GrIt);
927 if (group && !group->IsEmpty())
928 group->SMDSGroup().Remove(n);
933 // Node should belong to only one sub-mesh
934 if ( !subMesh || !subMesh->RemoveNode(n,/*deleted=*/false))
935 if (( subMesh = MeshElements( n->getshapeId() )))
936 subMesh->RemoveNode(n,/*deleted=*/false );
938 SMDS_Mesh::RemoveFreeElement(n);
941 //=======================================================================
942 //function : RemoveElement
944 //========================================================================
945 void SMESHDS_Mesh::RemoveElement(const SMDS_MeshElement * elt)
947 if (elt->GetType() == SMDSAbs_Node)
949 RemoveNode( static_cast<const SMDS_MeshNode*>( elt ));
952 if (!hasConstructionEdges() && !hasConstructionFaces())
954 SMESHDS_SubMesh* subMesh=0;
955 if ( elt->getshapeId() > 0 )
956 subMesh = MeshElements( elt->getshapeId() );
958 RemoveFreeElement( elt, subMesh, true );
962 myScript->RemoveElement(elt->GetID());
964 list<const SMDS_MeshElement *> removedElems;
965 list<const SMDS_MeshElement *> removedNodes;
967 SMDS_Mesh::RemoveElement(elt, removedElems, removedNodes, false );
969 removeFromContainers( this, myGroups, removedElems, false );
972 //=======================================================================
973 //function : RemoveFreeElement
975 //========================================================================
976 void SMESHDS_Mesh::RemoveFreeElement(const SMDS_MeshElement * elt,
977 SMESHDS_SubMesh * subMesh,
980 if (elt->GetType() == SMDSAbs_Node) {
981 RemoveFreeNode( static_cast<const SMDS_MeshNode*>(elt), subMesh, fromGroups);
985 if (hasConstructionEdges() || hasConstructionFaces())
986 // this methods is only for meshes without descendants
989 myScript->RemoveElement(elt->GetID());
992 // Element can belong to several groups
993 if ( fromGroups && !myGroups.empty() ) {
994 set<SMESHDS_GroupBase*>::iterator GrIt = myGroups.begin();
995 for (; GrIt != myGroups.end(); GrIt++) {
996 SMESHDS_Group* group = dynamic_cast<SMESHDS_Group*>(*GrIt);
997 if (group && !group->IsEmpty())
998 group->SMDSGroup().Remove(elt);
1003 // Element should belong to only one sub-mesh
1004 if ( !subMesh && elt->getshapeId() > 0 )
1005 subMesh = MeshElements( elt->getshapeId() );
1007 subMesh->RemoveElement( elt, /*deleted=*/false );
1009 SMDS_Mesh::RemoveFreeElement( elt );
1012 //================================================================================
1014 * \brief Remove all data from the mesh
1016 //================================================================================
1018 void SMESHDS_Mesh::ClearMesh()
1020 myScript->ClearMesh();
1024 SMESHDS_SubMeshIteratorPtr smIt = SubMeshes();
1025 while ( SMESHDS_SubMesh* sm = const_cast< SMESHDS_SubMesh* >( smIt->next() ))
1029 TGroups::iterator group, groupEnd = myGroups.end();
1030 for ( group = myGroups.begin(); group != groupEnd; ++group ) {
1031 if ( SMESHDS_Group* g = dynamic_cast<SMESHDS_Group*>(*group)) {
1032 SMDSAbs_ElementType groupType = g->GetType();
1034 g->SetType( groupType );
1038 (*group)->Extent(); // to free cashed elements in GroupOnFilter's
1043 //================================================================================
1045 * \brief return submesh by shape
1046 * \param shape - the sub-shape
1047 * \retval SMESHDS_SubMesh* - the found submesh
1049 //================================================================================
1051 SMESHDS_SubMesh* SMESHDS_Mesh::getSubmesh( const TopoDS_Shape & shape )
1053 if ( shape.IsNull() )
1056 return NewSubMesh( ShapeToIndex( shape ));
1059 //================================================================================
1061 * \brief Add element or node to submesh
1062 * \param elem - element to add
1063 * \param subMesh - submesh to be filled in
1065 //================================================================================
1067 bool SMESHDS_Mesh::add(const SMDS_MeshElement* elem, SMESHDS_SubMesh* subMesh )
1069 if ( elem && subMesh ) {
1070 if ( elem->GetType() == SMDSAbs_Node )
1071 subMesh->AddNode( static_cast<const SMDS_MeshNode* >( elem ));
1073 subMesh->AddElement( elem );
1079 //=======================================================================
1080 //function : SetNodeOnVolume
1082 //=======================================================================
1083 void SMESHDS_Mesh::SetNodeInVolume(const SMDS_MeshNode* aNode,
1084 const TopoDS_Shell & S)
1086 if ( add( aNode, getSubmesh(S) ))
1087 const_cast< SMDS_MeshNode* >
1088 ( aNode )->SetPosition( SMDS_SpacePosition::originSpacePosition() );
1091 //=======================================================================
1092 //function : SetNodeOnVolume
1094 //=======================================================================
1095 void SMESHDS_Mesh::SetNodeInVolume(const SMDS_MeshNode * aNode,
1096 const TopoDS_Solid & S)
1098 if ( add( aNode, getSubmesh(S) ))
1099 const_cast< SMDS_MeshNode* >
1100 ( aNode )->SetPosition( SMDS_SpacePosition::originSpacePosition() );
1103 //=======================================================================
1104 //function : SetNodeOnFace
1106 //=======================================================================
1107 void SMESHDS_Mesh::SetNodeOnFace(const SMDS_MeshNode * aNode,
1108 const TopoDS_Face & S,
1112 if ( add( aNode, getSubmesh(S) ))
1113 const_cast< SMDS_MeshNode* >
1114 ( aNode )->SetPosition(SMDS_PositionPtr(new SMDS_FacePosition( u, v)));
1117 //=======================================================================
1118 //function : SetNodeOnEdge
1120 //=======================================================================
1121 void SMESHDS_Mesh::SetNodeOnEdge(const SMDS_MeshNode * aNode,
1122 const TopoDS_Edge & S,
1125 if ( add( aNode, getSubmesh(S) ))
1126 const_cast< SMDS_MeshNode* >
1127 ( aNode )->SetPosition(SMDS_PositionPtr(new SMDS_EdgePosition(u)));
1130 //=======================================================================
1131 //function : SetNodeOnVertex
1133 //=======================================================================
1134 void SMESHDS_Mesh::SetNodeOnVertex(const SMDS_MeshNode * aNode,
1135 const TopoDS_Vertex & S)
1137 if ( add( aNode, getSubmesh(S) ))
1138 const_cast< SMDS_MeshNode* >
1139 ( aNode )->SetPosition(SMDS_PositionPtr(new SMDS_VertexPosition()));
1142 //=======================================================================
1143 //function : UnSetNodeOnShape
1145 //=======================================================================
1146 void SMESHDS_Mesh::UnSetNodeOnShape(const SMDS_MeshNode* aNode)
1148 int shapeId = aNode->getshapeId();
1150 if ( SMESHDS_SubMesh* sm = MeshElements( shapeId ))
1151 sm->RemoveNode(aNode, /*deleted=*/false);
1154 //=======================================================================
1155 //function : SetMeshElementOnShape
1157 //=======================================================================
1158 void SMESHDS_Mesh::SetMeshElementOnShape(const SMDS_MeshElement * anElement,
1159 const TopoDS_Shape & S)
1161 add( anElement, getSubmesh(S) );
1164 //=======================================================================
1165 //function : UnSetMeshElementOnShape
1167 //=======================================================================
1168 void SMESHDS_Mesh::UnSetMeshElementOnShape(const SMDS_MeshElement * elem,
1169 const TopoDS_Shape & S)
1171 if ( SMESHDS_SubMesh* sm = MeshElements( S ))
1173 if (elem->GetType() == SMDSAbs_Node)
1174 sm->RemoveNode(static_cast<const SMDS_MeshNode*> (elem), /*deleted=*/false);
1176 sm->RemoveElement(elem, /*deleted=*/false);
1180 //=======================================================================
1181 //function : ShapeToMesh
1183 //=======================================================================
1184 TopoDS_Shape SMESHDS_Mesh::ShapeToMesh() const
1189 //=======================================================================
1190 //function : IsGroupOfSubShapes
1191 //purpose : return true if at least one sub-shape of theShape is a sub-shape
1192 // of myShape or theShape == myShape
1193 //=======================================================================
1195 bool SMESHDS_Mesh::IsGroupOfSubShapes (const TopoDS_Shape& theShape) const
1197 if ( myIndexToShape.Contains(theShape) )
1200 for ( TopoDS_Iterator it( theShape ); it.More(); it.Next() )
1201 if (IsGroupOfSubShapes( it.Value() ))
1207 ///////////////////////////////////////////////////////////////////////////////
1208 /// Return the sub mesh linked to the a given TopoDS_Shape or NULL if the given
1209 /// TopoDS_Shape is unknown
1210 ///////////////////////////////////////////////////////////////////////////////
1211 SMESHDS_SubMesh * SMESHDS_Mesh::MeshElements(const TopoDS_Shape & S) const
1213 int Index = ShapeToIndex(S);
1214 return (SMESHDS_SubMesh *) ( Index ? mySubMeshHolder->Get( Index ) : 0 );
1217 ///////////////////////////////////////////////////////////////////////////////
1218 /// Return the sub mesh by Id of shape it is linked to
1219 ///////////////////////////////////////////////////////////////////////////////
1220 SMESHDS_SubMesh * SMESHDS_Mesh::MeshElements(const int Index) const
1222 return const_cast< SMESHDS_SubMesh* >( mySubMeshHolder->Get( Index ));
1225 //=======================================================================
1226 //function : SubMeshIndices
1228 //=======================================================================
1229 list<int> SMESHDS_Mesh::SubMeshIndices() const
1231 list<int> anIndices;
1232 SMESHDS_SubMeshIteratorPtr smIt = SubMeshes();
1233 while ( const SMESHDS_SubMesh* sm = smIt->next() )
1234 anIndices.push_back( sm->GetID() );
1239 //=======================================================================
1240 //function : SubMeshes
1242 //=======================================================================
1244 SMESHDS_SubMeshIteratorPtr SMESHDS_Mesh::SubMeshes() const
1246 return SMESHDS_SubMeshIteratorPtr( mySubMeshHolder->GetIterator() );
1249 //=======================================================================
1250 //function : GetHypothesis
1252 //=======================================================================
1254 const list<const SMESHDS_Hypothesis*>&
1255 SMESHDS_Mesh::GetHypothesis(const TopoDS_Shape & S) const
1257 if ( myShapeToHypothesis.IsBound( S/*.Oriented(TopAbs_FORWARD)*/ ) ) // ignore orientation of S
1258 return myShapeToHypothesis.Find( S/*.Oriented(TopAbs_FORWARD)*/ );
1260 static list<const SMESHDS_Hypothesis*> empty;
1264 //================================================================================
1266 * \brief returns true if the hypothesis is assigned to any sub-shape
1268 //================================================================================
1270 bool SMESHDS_Mesh::IsUsedHypothesis(const SMESHDS_Hypothesis * H) const
1272 ShapeToHypothesis::Iterator s2h( myShapeToHypothesis );
1273 for ( ; s2h.More(); s2h.Next() )
1274 if ( std::find( s2h.Value().begin(), s2h.Value().end(), H ) != s2h.Value().end() )
1279 //=======================================================================
1280 //function : GetScript
1282 //=======================================================================
1283 SMESHDS_Script* SMESHDS_Mesh::GetScript()
1288 //=======================================================================
1289 //function : ClearScript
1291 //=======================================================================
1292 void SMESHDS_Mesh::ClearScript()
1297 //=======================================================================
1298 //function : HasMeshElements
1300 //=======================================================================
1301 bool SMESHDS_Mesh::HasMeshElements(const TopoDS_Shape & S) const
1303 int Index = myIndexToShape.FindIndex(S);
1304 return mySubMeshHolder->Get( Index );
1307 //=======================================================================
1308 //function : HasHypothesis
1310 //=======================================================================
1311 bool SMESHDS_Mesh::HasHypothesis(const TopoDS_Shape & S)
1313 return myShapeToHypothesis.IsBound(S/*.Oriented(TopAbs_FORWARD)*/);
1316 //=======================================================================
1317 //function : NewSubMesh
1319 //=======================================================================
1320 SMESHDS_SubMesh * SMESHDS_Mesh::NewSubMesh(int Index)
1322 SMESHDS_SubMesh* SM = MeshElements( Index );
1325 SM = new SMESHDS_SubMesh(this, Index);
1326 mySubMeshHolder->Add( Index, SM );
1331 //=======================================================================
1332 //function : AddCompoundSubmesh
1334 //=======================================================================
1336 int SMESHDS_Mesh::AddCompoundSubmesh(const TopoDS_Shape& S,
1337 TopAbs_ShapeEnum type)
1340 if ( IsGroupOfSubShapes( S ))
1342 aMainIndex = myIndexToShape.Add( S );
1343 bool all = ( type == TopAbs_SHAPE );
1344 if ( all ) // corresponding simple submesh may exist
1345 aMainIndex = -aMainIndex;
1346 SMESHDS_SubMesh * aNewSub = NewSubMesh( aMainIndex );
1347 if ( !aNewSub->IsComplexSubmesh() ) // is empty
1349 int shapeType = Max( TopAbs_SOLID, all ? myShape.ShapeType() : type );
1350 int typeLimit = all ? TopAbs_VERTEX : type;
1351 for ( ; shapeType <= typeLimit; shapeType++ )
1353 TopExp_Explorer exp( S, TopAbs_ShapeEnum( shapeType ));
1354 for ( ; exp.More(); exp.Next() )
1356 int index = myIndexToShape.FindIndex( exp.Current() );
1358 aNewSub->AddSubMesh( NewSubMesh( index ));
1366 //=======================================================================
1367 //function : IndexToShape
1369 //=======================================================================
1370 const TopoDS_Shape& SMESHDS_Mesh::IndexToShape(int ShapeIndex) const
1374 if ( ShapeIndex > 0 )
1375 return myIndexToShape.FindKey(ShapeIndex);
1380 static TopoDS_Shape nullShape;
1384 //================================================================================
1386 * \brief Return max index of sub-mesh
1388 //================================================================================
1390 int SMESHDS_Mesh::MaxSubMeshIndex() const
1392 return mySubMeshHolder->GetMaxID();
1395 //=======================================================================
1396 //function : ShapeToIndex
1398 //=======================================================================
1399 int SMESHDS_Mesh::ShapeToIndex(const TopoDS_Shape & S) const
1401 int index = myIndexToShape.FindIndex(S);
1405 //=======================================================================
1406 //function : SetNodeOnVolume
1408 //=======================================================================
1409 void SMESHDS_Mesh::SetNodeInVolume(const SMDS_MeshNode* aNode, int Index)
1411 if ( add( aNode, NewSubMesh( Index )))
1412 ((SMDS_MeshNode*) aNode)->SetPosition( SMDS_SpacePosition::originSpacePosition());
1415 //=======================================================================
1416 //function : SetNodeOnFace
1418 //=======================================================================
1419 void SMESHDS_Mesh::SetNodeOnFace(const SMDS_MeshNode* aNode, int Index, double u, double v)
1421 //Set Position on Node
1422 if ( add( aNode, NewSubMesh( Index )))
1423 const_cast< SMDS_MeshNode* >
1424 ( aNode )->SetPosition(SMDS_PositionPtr(new SMDS_FacePosition( u, v)));
1427 //=======================================================================
1428 //function : SetNodeOnEdge
1430 //=======================================================================
1431 void SMESHDS_Mesh::SetNodeOnEdge(const SMDS_MeshNode* aNode,
1435 //Set Position on Node
1436 if ( add( aNode, NewSubMesh( Index )))
1437 const_cast< SMDS_MeshNode* >
1438 ( aNode )->SetPosition(SMDS_PositionPtr(new SMDS_EdgePosition(u)));
1441 //=======================================================================
1442 //function : SetNodeOnVertex
1444 //=======================================================================
1445 void SMESHDS_Mesh::SetNodeOnVertex(const SMDS_MeshNode* aNode, int Index)
1447 //Set Position on Node
1448 if ( add( aNode, NewSubMesh( Index )))
1449 const_cast< SMDS_MeshNode* >
1450 ( aNode )->SetPosition(SMDS_PositionPtr(new SMDS_VertexPosition()));
1453 //=======================================================================
1454 //function : SetMeshElementOnShape
1456 //=======================================================================
1457 void SMESHDS_Mesh::SetMeshElementOnShape(const SMDS_MeshElement* anElement,
1460 add( anElement, NewSubMesh( Index ));
1463 //=======================================================================
1464 //function : ~SMESHDS_Mesh
1466 //=======================================================================
1467 SMESHDS_Mesh::~SMESHDS_Mesh()
1472 delete mySubMeshHolder;
1476 //********************************************************************
1477 //********************************************************************
1478 //******** *********
1479 //***** Methods for addition of quadratic elements ******
1480 //******** *********
1481 //********************************************************************
1482 //********************************************************************
1484 //=======================================================================
1485 //function : AddEdgeWithID
1487 //=======================================================================
1488 SMDS_MeshEdge* SMESHDS_Mesh::AddEdgeWithID(int n1, int n2, int n12, int ID)
1490 SMDS_MeshEdge* anElem = SMDS_Mesh::AddEdgeWithID(n1,n2,n12,ID);
1491 if(anElem) myScript->AddEdge(ID,n1,n2,n12);
1495 //=======================================================================
1496 //function : AddEdge
1498 //=======================================================================
1499 SMDS_MeshEdge* SMESHDS_Mesh::AddEdge(const SMDS_MeshNode* n1,
1500 const SMDS_MeshNode* n2,
1501 const SMDS_MeshNode* n12)
1503 SMDS_MeshEdge* anElem = SMDS_Mesh::AddEdge(n1,n2,n12);
1504 if(anElem) myScript->AddEdge(anElem->GetID(),
1511 //=======================================================================
1512 //function : AddEdgeWithID
1514 //=======================================================================
1515 SMDS_MeshEdge* SMESHDS_Mesh::AddEdgeWithID(const SMDS_MeshNode * n1,
1516 const SMDS_MeshNode * n2,
1517 const SMDS_MeshNode * n12,
1520 return AddEdgeWithID(n1->GetID(),
1527 //=======================================================================
1528 //function : AddFace
1530 //=======================================================================
1531 SMDS_MeshFace* SMESHDS_Mesh::AddFace(const SMDS_MeshNode * n1,
1532 const SMDS_MeshNode * n2,
1533 const SMDS_MeshNode * n3,
1534 const SMDS_MeshNode * n12,
1535 const SMDS_MeshNode * n23,
1536 const SMDS_MeshNode * n31)
1538 SMDS_MeshFace *anElem = SMDS_Mesh::AddFace(n1,n2,n3,n12,n23,n31);
1539 if(anElem) myScript->AddFace(anElem->GetID(),
1540 n1->GetID(), n2->GetID(), n3->GetID(),
1541 n12->GetID(), n23->GetID(), n31->GetID());
1545 //=======================================================================
1546 //function : AddFaceWithID
1548 //=======================================================================
1549 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(int n1, int n2, int n3,
1550 int n12,int n23,int n31, int ID)
1552 SMDS_MeshFace *anElem = SMDS_Mesh::AddFaceWithID(n1,n2,n3,n12,n23,n31,ID);
1553 if(anElem) myScript->AddFace(ID,n1,n2,n3,n12,n23,n31);
1557 //=======================================================================
1558 //function : AddFaceWithID
1560 //=======================================================================
1561 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(const SMDS_MeshNode * n1,
1562 const SMDS_MeshNode * n2,
1563 const SMDS_MeshNode * n3,
1564 const SMDS_MeshNode * n12,
1565 const SMDS_MeshNode * n23,
1566 const SMDS_MeshNode * n31,
1569 return AddFaceWithID(n1->GetID(), n2->GetID(), n3->GetID(),
1570 n12->GetID(), n23->GetID(), n31->GetID(),
1574 //=======================================================================
1575 //function : AddFace
1577 //=======================================================================
1578 SMDS_MeshFace* SMESHDS_Mesh::AddFace(const SMDS_MeshNode * n1,
1579 const SMDS_MeshNode * n2,
1580 const SMDS_MeshNode * n3,
1581 const SMDS_MeshNode * n12,
1582 const SMDS_MeshNode * n23,
1583 const SMDS_MeshNode * n31,
1584 const SMDS_MeshNode * nCenter)
1586 SMDS_MeshFace *anElem = SMDS_Mesh::AddFace(n1,n2,n3,n12,n23,n31,nCenter);
1587 if(anElem) myScript->AddFace(anElem->GetID(),
1588 n1->GetID(), n2->GetID(), n3->GetID(),
1589 n12->GetID(), n23->GetID(), n31->GetID(),
1594 //=======================================================================
1595 //function : AddFaceWithID
1597 //=======================================================================
1598 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(int n1, int n2, int n3,
1599 int n12,int n23,int n31, int nCenter, int ID)
1601 SMDS_MeshFace *anElem = SMDS_Mesh::AddFaceWithID(n1,n2,n3,n12,n23,n31,nCenter,ID);
1602 if(anElem) myScript->AddFace(ID,n1,n2,n3,n12,n23,n31,nCenter);
1606 //=======================================================================
1607 //function : AddFaceWithID
1609 //=======================================================================
1610 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(const SMDS_MeshNode * n1,
1611 const SMDS_MeshNode * n2,
1612 const SMDS_MeshNode * n3,
1613 const SMDS_MeshNode * n12,
1614 const SMDS_MeshNode * n23,
1615 const SMDS_MeshNode * n31,
1616 const SMDS_MeshNode * nCenter,
1619 return AddFaceWithID(n1->GetID(), n2->GetID(), n3->GetID(),
1620 n12->GetID(), n23->GetID(), n31->GetID(),
1621 nCenter->GetID(), ID);
1625 //=======================================================================
1626 //function : AddFace
1628 //=======================================================================
1629 SMDS_MeshFace* SMESHDS_Mesh::AddFace(const SMDS_MeshNode * n1,
1630 const SMDS_MeshNode * n2,
1631 const SMDS_MeshNode * n3,
1632 const SMDS_MeshNode * n4,
1633 const SMDS_MeshNode * n12,
1634 const SMDS_MeshNode * n23,
1635 const SMDS_MeshNode * n34,
1636 const SMDS_MeshNode * n41)
1638 SMDS_MeshFace *anElem = SMDS_Mesh::AddFace(n1,n2,n3,n4,n12,n23,n34,n41);
1639 if(anElem) myScript->AddFace(anElem->GetID(),
1640 n1->GetID(), n2->GetID(), n3->GetID(), n4->GetID(),
1641 n12->GetID(), n23->GetID(), n34->GetID(), n41->GetID());
1645 //=======================================================================
1646 //function : AddFaceWithID
1648 //=======================================================================
1649 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(int n1, int n2, int n3, int n4,
1650 int n12,int n23,int n34,int n41, int ID)
1652 SMDS_MeshFace *anElem = SMDS_Mesh::AddFaceWithID(n1,n2,n3,n4,n12,n23,n34,n41,ID);
1653 if(anElem) myScript->AddFace(ID,n1,n2,n3,n4,n12,n23,n34,n41);
1657 //=======================================================================
1658 //function : AddFaceWithID
1660 //=======================================================================
1661 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(const SMDS_MeshNode * n1,
1662 const SMDS_MeshNode * n2,
1663 const SMDS_MeshNode * n3,
1664 const SMDS_MeshNode * n4,
1665 const SMDS_MeshNode * n12,
1666 const SMDS_MeshNode * n23,
1667 const SMDS_MeshNode * n34,
1668 const SMDS_MeshNode * n41,
1671 return AddFaceWithID(n1->GetID(), n2->GetID(), n3->GetID(), n4->GetID(),
1672 n12->GetID(), n23->GetID(), n34->GetID(), n41->GetID(),
1677 //=======================================================================
1678 //function : AddFace
1680 //=======================================================================
1681 SMDS_MeshFace* SMESHDS_Mesh::AddFace(const SMDS_MeshNode * n1,
1682 const SMDS_MeshNode * n2,
1683 const SMDS_MeshNode * n3,
1684 const SMDS_MeshNode * n4,
1685 const SMDS_MeshNode * n12,
1686 const SMDS_MeshNode * n23,
1687 const SMDS_MeshNode * n34,
1688 const SMDS_MeshNode * n41,
1689 const SMDS_MeshNode * nCenter)
1691 SMDS_MeshFace *anElem = SMDS_Mesh::AddFace(n1,n2,n3,n4,n12,n23,n34,n41,nCenter);
1692 if(anElem) myScript->AddFace(anElem->GetID(),
1693 n1->GetID(), n2->GetID(), n3->GetID(), n4->GetID(),
1694 n12->GetID(), n23->GetID(), n34->GetID(), n41->GetID(),
1699 //=======================================================================
1700 //function : AddFaceWithID
1702 //=======================================================================
1703 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(int n1, int n2, int n3, int n4,
1704 int n12,int n23,int n34,int n41,
1705 int nCenter, int ID)
1707 SMDS_MeshFace *anElem = SMDS_Mesh::AddFaceWithID(n1,n2,n3,n4,n12,n23,n34,n41,nCenter,ID);
1708 if(anElem) myScript->AddFace(ID,n1,n2,n3,n4,n12,n23,n34,n41,nCenter);
1712 //=======================================================================
1713 //function : AddFaceWithID
1715 //=======================================================================
1716 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(const SMDS_MeshNode * n1,
1717 const SMDS_MeshNode * n2,
1718 const SMDS_MeshNode * n3,
1719 const SMDS_MeshNode * n4,
1720 const SMDS_MeshNode * n12,
1721 const SMDS_MeshNode * n23,
1722 const SMDS_MeshNode * n34,
1723 const SMDS_MeshNode * n41,
1724 const SMDS_MeshNode * nCenter,
1727 return AddFaceWithID(n1->GetID(), n2->GetID(), n3->GetID(), n4->GetID(),
1728 n12->GetID(), n23->GetID(), n34->GetID(), n41->GetID(),
1729 nCenter->GetID(), ID);
1733 //=======================================================================
1734 //function : AddVolume
1736 //=======================================================================
1737 SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
1738 const SMDS_MeshNode * n2,
1739 const SMDS_MeshNode * n3,
1740 const SMDS_MeshNode * n4,
1741 const SMDS_MeshNode * n12,
1742 const SMDS_MeshNode * n23,
1743 const SMDS_MeshNode * n31,
1744 const SMDS_MeshNode * n14,
1745 const SMDS_MeshNode * n24,
1746 const SMDS_MeshNode * n34)
1748 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1,n2,n3,n4,n12,n23,n31,n14,n24,n34);
1749 if(anElem) myScript->AddVolume(anElem->GetID(),
1750 n1->GetID(), n2->GetID(), n3->GetID(), n4->GetID(),
1751 n12->GetID(), n23->GetID(), n31->GetID(),
1752 n14->GetID(), n24->GetID(), n34->GetID());
1756 //=======================================================================
1757 //function : AddVolumeWithID
1759 //=======================================================================
1760 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3, int n4,
1761 int n12,int n23,int n31,
1762 int n14,int n24,int n34, int ID)
1764 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolumeWithID(n1,n2,n3,n4,n12,n23,
1765 n31,n14,n24,n34,ID);
1766 if(anElem) myScript->AddVolume(ID,n1,n2,n3,n4,n12,n23,n31,n14,n24,n34);
1770 //=======================================================================
1771 //function : AddVolumeWithID
1772 //purpose : 2d order tetrahedron of 10 nodes
1773 //=======================================================================
1774 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
1775 const SMDS_MeshNode * n2,
1776 const SMDS_MeshNode * n3,
1777 const SMDS_MeshNode * n4,
1778 const SMDS_MeshNode * n12,
1779 const SMDS_MeshNode * n23,
1780 const SMDS_MeshNode * n31,
1781 const SMDS_MeshNode * n14,
1782 const SMDS_MeshNode * n24,
1783 const SMDS_MeshNode * n34,
1786 return AddVolumeWithID(n1->GetID(), n2->GetID(), n3->GetID(), n4->GetID(),
1787 n12->GetID(), n23->GetID(), n31->GetID(),
1788 n14->GetID(), n24->GetID(), n34->GetID(), ID);
1792 //=======================================================================
1793 //function : AddVolume
1795 //=======================================================================
1796 SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
1797 const SMDS_MeshNode * n2,
1798 const SMDS_MeshNode * n3,
1799 const SMDS_MeshNode * n4,
1800 const SMDS_MeshNode * n5,
1801 const SMDS_MeshNode * n12,
1802 const SMDS_MeshNode * n23,
1803 const SMDS_MeshNode * n34,
1804 const SMDS_MeshNode * n41,
1805 const SMDS_MeshNode * n15,
1806 const SMDS_MeshNode * n25,
1807 const SMDS_MeshNode * n35,
1808 const SMDS_MeshNode * n45)
1810 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1,n2,n3,n4,n5,n12,n23,n34,n41,
1813 myScript->AddVolume(anElem->GetID(), n1->GetID(), n2->GetID(),
1814 n3->GetID(), n4->GetID(), n5->GetID(),
1815 n12->GetID(), n23->GetID(), n34->GetID(), n41->GetID(),
1816 n15->GetID(), n25->GetID(), n35->GetID(), n45->GetID());
1820 //=======================================================================
1821 //function : AddVolumeWithID
1823 //=======================================================================
1824 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3, int n4, int n5,
1825 int n12,int n23,int n34,int n41,
1826 int n15,int n25,int n35,int n45, int ID)
1828 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolumeWithID(n1,n2,n3,n4,n5,
1830 n15,n25,n35,n45,ID);
1831 if(anElem) myScript->AddVolume(ID,n1,n2,n3,n4,n5,n12,n23,n34,n41,
1836 //=======================================================================
1837 //function : AddVolumeWithID
1838 //purpose : 2d order pyramid of 13 nodes
1839 //=======================================================================
1840 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
1841 const SMDS_MeshNode * n2,
1842 const SMDS_MeshNode * n3,
1843 const SMDS_MeshNode * n4,
1844 const SMDS_MeshNode * n5,
1845 const SMDS_MeshNode * n12,
1846 const SMDS_MeshNode * n23,
1847 const SMDS_MeshNode * n34,
1848 const SMDS_MeshNode * n41,
1849 const SMDS_MeshNode * n15,
1850 const SMDS_MeshNode * n25,
1851 const SMDS_MeshNode * n35,
1852 const SMDS_MeshNode * n45,
1855 return AddVolumeWithID(n1->GetID(), n2->GetID(), n3->GetID(),
1856 n4->GetID(), n5->GetID(),
1857 n12->GetID(), n23->GetID(), n34->GetID(), n41->GetID(),
1858 n15->GetID(), n25->GetID(), n35->GetID(), n45->GetID(),
1863 //=======================================================================
1864 //function : AddVolume
1866 //=======================================================================
1867 SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
1868 const SMDS_MeshNode * n2,
1869 const SMDS_MeshNode * n3,
1870 const SMDS_MeshNode * n4,
1871 const SMDS_MeshNode * n5,
1872 const SMDS_MeshNode * n6,
1873 const SMDS_MeshNode * n12,
1874 const SMDS_MeshNode * n23,
1875 const SMDS_MeshNode * n31,
1876 const SMDS_MeshNode * n45,
1877 const SMDS_MeshNode * n56,
1878 const SMDS_MeshNode * n64,
1879 const SMDS_MeshNode * n14,
1880 const SMDS_MeshNode * n25,
1881 const SMDS_MeshNode * n36)
1883 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1,n2,n3,n4,n5,n6,n12,n23,n31,
1884 n45,n56,n64,n14,n25,n36);
1886 myScript->AddVolume(anElem->GetID(), n1->GetID(), n2->GetID(),
1887 n3->GetID(), n4->GetID(), n5->GetID(), n6->GetID(),
1888 n12->GetID(), n23->GetID(), n31->GetID(),
1889 n45->GetID(), n56->GetID(), n64->GetID(),
1890 n14->GetID(), n25->GetID(), n36->GetID());
1894 //=======================================================================
1895 //function : AddVolumeWithID
1897 //=======================================================================
1898 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3,
1899 int n4, int n5, int n6,
1900 int n12,int n23,int n31,
1901 int n45,int n56,int n64,
1902 int n14,int n25,int n36, int ID)
1904 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolumeWithID(n1,n2,n3,n4,n5,n6,
1908 if(anElem) myScript->AddVolume(ID,n1,n2,n3,n4,n5,n6,n12,n23,n31,
1909 n45,n56,n64,n14,n25,n36);
1913 //=======================================================================
1914 //function : AddVolumeWithID
1915 //purpose : 2d order Pentahedron with 15 nodes
1916 //=======================================================================
1917 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
1918 const SMDS_MeshNode * n2,
1919 const SMDS_MeshNode * n3,
1920 const SMDS_MeshNode * n4,
1921 const SMDS_MeshNode * n5,
1922 const SMDS_MeshNode * n6,
1923 const SMDS_MeshNode * n12,
1924 const SMDS_MeshNode * n23,
1925 const SMDS_MeshNode * n31,
1926 const SMDS_MeshNode * n45,
1927 const SMDS_MeshNode * n56,
1928 const SMDS_MeshNode * n64,
1929 const SMDS_MeshNode * n14,
1930 const SMDS_MeshNode * n25,
1931 const SMDS_MeshNode * n36,
1934 return AddVolumeWithID(n1->GetID(), n2->GetID(), n3->GetID(),
1935 n4->GetID(), n5->GetID(), n6->GetID(),
1936 n12->GetID(), n23->GetID(), n31->GetID(),
1937 n45->GetID(), n56->GetID(), n64->GetID(),
1938 n14->GetID(), n25->GetID(), n36->GetID(),
1943 //=======================================================================
1944 //function : AddVolume
1945 //purpose : add quadratic hexahedron
1946 //=======================================================================
1947 SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
1948 const SMDS_MeshNode * n2,
1949 const SMDS_MeshNode * n3,
1950 const SMDS_MeshNode * n4,
1951 const SMDS_MeshNode * n5,
1952 const SMDS_MeshNode * n6,
1953 const SMDS_MeshNode * n7,
1954 const SMDS_MeshNode * n8,
1955 const SMDS_MeshNode * n12,
1956 const SMDS_MeshNode * n23,
1957 const SMDS_MeshNode * n34,
1958 const SMDS_MeshNode * n41,
1959 const SMDS_MeshNode * n56,
1960 const SMDS_MeshNode * n67,
1961 const SMDS_MeshNode * n78,
1962 const SMDS_MeshNode * n85,
1963 const SMDS_MeshNode * n15,
1964 const SMDS_MeshNode * n26,
1965 const SMDS_MeshNode * n37,
1966 const SMDS_MeshNode * n48)
1968 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1,n2,n3,n4,n5,n6,n7,n8,
1973 myScript->AddVolume(anElem->GetID(), n1->GetID(), n2->GetID(),
1974 n3->GetID(), n4->GetID(), n5->GetID(),
1975 n6->GetID(), n7->GetID(), n8->GetID(),
1976 n12->GetID(), n23->GetID(), n34->GetID(), n41->GetID(),
1977 n56->GetID(), n67->GetID(), n78->GetID(), n85->GetID(),
1978 n15->GetID(), n26->GetID(), n37->GetID(), n48->GetID());
1982 //=======================================================================
1983 //function : AddVolumeWithID
1985 //=======================================================================
1986 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3, int n4,
1987 int n5, int n6, int n7, int n8,
1988 int n12,int n23,int n34,int n41,
1989 int n56,int n67,int n78,int n85,
1990 int n15,int n26,int n37,int n48, int ID)
1992 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolumeWithID(n1,n2,n3,n4,n5,n6,n7,n8,
1995 n15,n26,n37,n48,ID);
1996 if(anElem) myScript->AddVolume(ID,n1,n2,n3,n4,n5,n6,n7,n8,n12,n23,n34,n41,
1997 n56,n67,n78,n85,n15,n26,n37,n48);
2001 //=======================================================================
2002 //function : AddVolumeWithID
2003 //purpose : 2d order Hexahedrons with 20 nodes
2004 //=======================================================================
2005 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
2006 const SMDS_MeshNode * n2,
2007 const SMDS_MeshNode * n3,
2008 const SMDS_MeshNode * n4,
2009 const SMDS_MeshNode * n5,
2010 const SMDS_MeshNode * n6,
2011 const SMDS_MeshNode * n7,
2012 const SMDS_MeshNode * n8,
2013 const SMDS_MeshNode * n12,
2014 const SMDS_MeshNode * n23,
2015 const SMDS_MeshNode * n34,
2016 const SMDS_MeshNode * n41,
2017 const SMDS_MeshNode * n56,
2018 const SMDS_MeshNode * n67,
2019 const SMDS_MeshNode * n78,
2020 const SMDS_MeshNode * n85,
2021 const SMDS_MeshNode * n15,
2022 const SMDS_MeshNode * n26,
2023 const SMDS_MeshNode * n37,
2024 const SMDS_MeshNode * n48,
2027 return AddVolumeWithID(n1->GetID(), n2->GetID(), n3->GetID(), n4->GetID(),
2028 n5->GetID(), n6->GetID(), n7->GetID(), n8->GetID(),
2029 n12->GetID(), n23->GetID(), n34->GetID(), n41->GetID(),
2030 n56->GetID(), n67->GetID(), n78->GetID(), n85->GetID(),
2031 n15->GetID(), n26->GetID(), n37->GetID(), n48->GetID(),
2035 //=======================================================================
2036 //function : AddVolume
2037 //purpose : add tri-quadratic hexahedron of 27 nodes
2038 //=======================================================================
2040 SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
2041 const SMDS_MeshNode * n2,
2042 const SMDS_MeshNode * n3,
2043 const SMDS_MeshNode * n4,
2044 const SMDS_MeshNode * n5,
2045 const SMDS_MeshNode * n6,
2046 const SMDS_MeshNode * n7,
2047 const SMDS_MeshNode * n8,
2048 const SMDS_MeshNode * n12,
2049 const SMDS_MeshNode * n23,
2050 const SMDS_MeshNode * n34,
2051 const SMDS_MeshNode * n41,
2052 const SMDS_MeshNode * n56,
2053 const SMDS_MeshNode * n67,
2054 const SMDS_MeshNode * n78,
2055 const SMDS_MeshNode * n85,
2056 const SMDS_MeshNode * n15,
2057 const SMDS_MeshNode * n26,
2058 const SMDS_MeshNode * n37,
2059 const SMDS_MeshNode * n48,
2060 const SMDS_MeshNode * n1234,
2061 const SMDS_MeshNode * n1256,
2062 const SMDS_MeshNode * n2367,
2063 const SMDS_MeshNode * n3478,
2064 const SMDS_MeshNode * n1458,
2065 const SMDS_MeshNode * n5678,
2066 const SMDS_MeshNode * nCenter)
2068 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1,n2,n3,n4,n5,n6,n7,n8,
2072 n1234,n1256,n2367,n3478,n1458,n5678,nCenter);
2074 myScript->AddVolume(anElem->GetID(), n1->GetID(), n2->GetID(),
2075 n3->GetID(), n4->GetID(), n5->GetID(),
2076 n6->GetID(), n7->GetID(), n8->GetID(),
2077 n12->GetID(), n23->GetID(), n34->GetID(), n41->GetID(),
2078 n56->GetID(), n67->GetID(), n78->GetID(), n85->GetID(),
2079 n15->GetID(), n26->GetID(), n37->GetID(), n48->GetID(),
2080 n1234->GetID(),n1256->GetID(),n2367->GetID(),n3478->GetID(),
2081 n1458->GetID(),n5678->GetID(),nCenter->GetID());
2085 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3, int n4,
2086 int n5, int n6, int n7, int n8,
2087 int n12,int n23,int n34,int n41,
2088 int n56,int n67,int n78,int n85,
2089 int n15,int n26,int n37,int n48,
2090 int n1234,int n1256,int n2367,int n3478,
2091 int n1458,int n5678,int nCenter,
2094 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolumeWithID(n1,n2,n3,n4,n5,n6,n7,n8,
2098 n1234, n1256, n2367, n3478,
2099 n1458, n5678, nCenter,
2101 if(anElem) myScript->AddVolume(ID,n1,n2,n3,n4,n5,n6,n7,n8,n12,n23,n34,n41,
2102 n56,n67,n78,n85,n15,n26,n37,n48,
2103 n1234, n1256, n2367, n3478,
2104 n1458, n5678, nCenter);
2108 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
2109 const SMDS_MeshNode * n2,
2110 const SMDS_MeshNode * n3,
2111 const SMDS_MeshNode * n4,
2112 const SMDS_MeshNode * n5,
2113 const SMDS_MeshNode * n6,
2114 const SMDS_MeshNode * n7,
2115 const SMDS_MeshNode * n8,
2116 const SMDS_MeshNode * n12,
2117 const SMDS_MeshNode * n23,
2118 const SMDS_MeshNode * n34,
2119 const SMDS_MeshNode * n41,
2120 const SMDS_MeshNode * n56,
2121 const SMDS_MeshNode * n67,
2122 const SMDS_MeshNode * n78,
2123 const SMDS_MeshNode * n85,
2124 const SMDS_MeshNode * n15,
2125 const SMDS_MeshNode * n26,
2126 const SMDS_MeshNode * n37,
2127 const SMDS_MeshNode * n48,
2128 const SMDS_MeshNode * n1234,
2129 const SMDS_MeshNode * n1256,
2130 const SMDS_MeshNode * n2367,
2131 const SMDS_MeshNode * n3478,
2132 const SMDS_MeshNode * n1458,
2133 const SMDS_MeshNode * n5678,
2134 const SMDS_MeshNode * nCenter,
2137 return AddVolumeWithID(n1->GetID(), n2->GetID(), n3->GetID(), n4->GetID(),
2138 n5->GetID(), n6->GetID(), n7->GetID(), n8->GetID(),
2139 n12->GetID(), n23->GetID(), n34->GetID(), n41->GetID(),
2140 n56->GetID(), n67->GetID(), n78->GetID(), n85->GetID(),
2141 n15->GetID(), n26->GetID(), n37->GetID(), n48->GetID(),
2142 n1234->GetID(),n1256->GetID(),n2367->GetID(),n3478->GetID(),
2143 n1458->GetID(),n5678->GetID(),nCenter->GetID(), ID);
2146 void SMESHDS_Mesh::compactMesh()
2148 if ( isCompacted() )
2150 SMDS_Mesh::compactMesh();
2152 int newNodeSize = 0;
2153 int nbNodes = myNodes.size();
2154 int nbVtkNodes = myGrid->GetNumberOfPoints();
2155 int nbNodeTemp = Max( nbVtkNodes, nbNodes );
2156 vector<int> idNodesOldToNew(nbNodeTemp, -1); // all unused id will be -1
2158 for (int i = 0; i < nbNodes; i++)
2162 int vtkid = myNodes[i]->getVtkId();
2163 idNodesOldToNew[vtkid] = i; // old vtkId --> old smdsId (valid smdsId are >= 0)
2167 bool areNodesModified = (newNodeSize != nbVtkNodes);
2168 areNodesModified = true;
2170 int newCellSize = 0;
2171 int nbCells = myCells.size();
2172 int nbVtkCells = myGrid->GetNumberOfCells();
2173 int nbCellTemp = Max( nbVtkCells, nbCells );
2174 vector<int> idCellsOldToNew(nbCellTemp, -1); // all unused id will be -1
2176 for (int i = 0; i < nbCells; i++)
2183 if (areNodesModified)
2184 myGrid->compactGrid(idNodesOldToNew, newNodeSize, idCellsOldToNew, newCellSize);
2186 myGrid->compactGrid(idNodesOldToNew, 0, idCellsOldToNew, newCellSize);
2188 int nbVtkPts = myGrid->GetNumberOfPoints();
2189 nbVtkCells = myGrid->GetNumberOfCells();
2190 if (nbVtkPts != newNodeSize)
2192 MESSAGE("===> nbVtkPts != newNodeSize " << nbVtkPts << " " << newNodeSize);
2193 if (nbVtkPts > newNodeSize) newNodeSize = nbVtkPts; // several points with same SMDS Id
2195 if (nbVtkCells != newCellSize)
2197 MESSAGE("===> nbVtkCells != newCellSize " << nbVtkCells << " " << newCellSize);
2198 if (nbVtkCells > newCellSize) newCellSize = nbVtkCells; // several cells with same SMDS Id
2201 // --- SMDS_MeshNode and myNodes, myNodeIdFactory
2205 SetOfNodes newNodes(newNodeSize+1,NULL); // 0 not used, SMDS numbers 1..n
2207 for (int i = 0; i < nbNodes; i++)
2211 newSmdsId++; // SMDS id starts from 1
2212 int oldVtkId = myNodes[i]->getVtkId();
2213 int newVtkId = idNodesOldToNew[oldVtkId];
2214 myNodes[i]->setVtkId(newVtkId);
2215 myNodes[i]->setId(newSmdsId);
2216 newNodes[newSmdsId] = myNodes[i];
2219 myNodes.swap(newNodes);
2220 this->myNodeIDFactory->emptyPool(newSmdsId); // newSmdsId = number of nodes
2223 // --- SMDS_MeshCell, myCellIdVtkToSmds, myCellIdSmdsToVtk, myCells
2225 int vtkIndexSize = myCellIdVtkToSmds.size();
2226 for (int oldVtkId = 0; oldVtkId < vtkIndexSize; oldVtkId++)
2228 int oldSmdsId = this->myCellIdVtkToSmds[oldVtkId];
2231 int newVtkId = idCellsOldToNew[oldVtkId];
2232 myCells[oldSmdsId]->setVtkId(newVtkId);
2236 SetOfCells newCells(newCellSize+1, NULL); // 0 not used, SMDS numbers 1..n
2237 vector<int> newVtkToSmds(newCellSize+1, -1);
2239 int myCellsSize = myCells.size();
2241 for (int i = 0; i < myCellsSize; i++)
2245 newSmdsId++; // SMDS id starts from 1
2246 assert(newSmdsId <= newCellSize);
2247 newCells[newSmdsId] = myCells[i];
2248 newCells[newSmdsId]->setId(newSmdsId);
2249 int idvtk = myCells[i]->getVtkId();
2250 assert(idvtk < newCellSize);
2251 newVtkToSmds[idvtk] = newSmdsId;
2255 myCells.swap(newCells);
2256 myCellIdVtkToSmds.swap(newVtkToSmds);
2257 this->myElementIDFactory->emptyPool(newSmdsId);
2259 this->myScript->SetModified(true); // notify GUI client for buildPrs when update
2261 // --- compact list myNodes and myElements in submeshes
2263 SMESHDS_SubMeshIteratorPtr smIt = SubMeshes();
2264 while ( SMESHDS_SubMesh* sm = const_cast< SMESHDS_SubMesh* >( smIt->next() ))
2268 void SMESHDS_Mesh::CleanDownWardConnectivity()
2270 myGrid->CleanDownwardConnectivity();
2273 void SMESHDS_Mesh::BuildDownWardConnectivity(bool withEdges)
2275 myGrid->BuildDownwardConnectivity(withEdges);
2278 /*! change some nodes in cell without modifying type or internal connectivity.
2279 * Nodes inverse connectivity is maintained up to date.
2280 * @param vtkVolId vtk id of the cell.
2281 * @param localClonedNodeIds map old node id to new node id.
2282 * @return ok if success.
2284 bool SMESHDS_Mesh::ModifyCellNodes(int vtkVolId, std::map<int,int> localClonedNodeIds)
2286 myGrid->ModifyCellNodes(vtkVolId, localClonedNodeIds);