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);
1377 catch ( Standard_OutOfRange )
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 if (myShape.IsNull())
1402 MESSAGE("myShape is NULL");
1404 int index = myIndexToShape.FindIndex(S);
1409 //=======================================================================
1410 //function : SetNodeOnVolume
1412 //=======================================================================
1413 void SMESHDS_Mesh::SetNodeInVolume(const SMDS_MeshNode* aNode, int Index)
1415 if ( add( aNode, NewSubMesh( Index )))
1416 ((SMDS_MeshNode*) aNode)->SetPosition( SMDS_SpacePosition::originSpacePosition());
1419 //=======================================================================
1420 //function : SetNodeOnFace
1422 //=======================================================================
1423 void SMESHDS_Mesh::SetNodeOnFace(const SMDS_MeshNode* aNode, int Index, double u, double v)
1425 //Set Position on Node
1426 if ( add( aNode, NewSubMesh( Index )))
1427 const_cast< SMDS_MeshNode* >
1428 ( aNode )->SetPosition(SMDS_PositionPtr(new SMDS_FacePosition( u, v)));
1431 //=======================================================================
1432 //function : SetNodeOnEdge
1434 //=======================================================================
1435 void SMESHDS_Mesh::SetNodeOnEdge(const SMDS_MeshNode* aNode,
1439 //Set Position on Node
1440 if ( add( aNode, NewSubMesh( Index )))
1441 const_cast< SMDS_MeshNode* >
1442 ( aNode )->SetPosition(SMDS_PositionPtr(new SMDS_EdgePosition(u)));
1445 //=======================================================================
1446 //function : SetNodeOnVertex
1448 //=======================================================================
1449 void SMESHDS_Mesh::SetNodeOnVertex(const SMDS_MeshNode* aNode, int Index)
1451 //Set Position on Node
1452 if ( add( aNode, NewSubMesh( Index )))
1453 const_cast< SMDS_MeshNode* >
1454 ( aNode )->SetPosition(SMDS_PositionPtr(new SMDS_VertexPosition()));
1457 //=======================================================================
1458 //function : SetMeshElementOnShape
1460 //=======================================================================
1461 void SMESHDS_Mesh::SetMeshElementOnShape(const SMDS_MeshElement* anElement,
1464 add( anElement, NewSubMesh( Index ));
1467 //=======================================================================
1468 //function : ~SMESHDS_Mesh
1470 //=======================================================================
1471 SMESHDS_Mesh::~SMESHDS_Mesh()
1476 delete mySubMeshHolder;
1480 //********************************************************************
1481 //********************************************************************
1482 //******** *********
1483 //***** Methods for addition of quadratic elements ******
1484 //******** *********
1485 //********************************************************************
1486 //********************************************************************
1488 //=======================================================================
1489 //function : AddEdgeWithID
1491 //=======================================================================
1492 SMDS_MeshEdge* SMESHDS_Mesh::AddEdgeWithID(int n1, int n2, int n12, int ID)
1494 SMDS_MeshEdge* anElem = SMDS_Mesh::AddEdgeWithID(n1,n2,n12,ID);
1495 if(anElem) myScript->AddEdge(ID,n1,n2,n12);
1499 //=======================================================================
1500 //function : AddEdge
1502 //=======================================================================
1503 SMDS_MeshEdge* SMESHDS_Mesh::AddEdge(const SMDS_MeshNode* n1,
1504 const SMDS_MeshNode* n2,
1505 const SMDS_MeshNode* n12)
1507 SMDS_MeshEdge* anElem = SMDS_Mesh::AddEdge(n1,n2,n12);
1508 if(anElem) myScript->AddEdge(anElem->GetID(),
1515 //=======================================================================
1516 //function : AddEdgeWithID
1518 //=======================================================================
1519 SMDS_MeshEdge* SMESHDS_Mesh::AddEdgeWithID(const SMDS_MeshNode * n1,
1520 const SMDS_MeshNode * n2,
1521 const SMDS_MeshNode * n12,
1524 return AddEdgeWithID(n1->GetID(),
1531 //=======================================================================
1532 //function : AddFace
1534 //=======================================================================
1535 SMDS_MeshFace* SMESHDS_Mesh::AddFace(const SMDS_MeshNode * n1,
1536 const SMDS_MeshNode * n2,
1537 const SMDS_MeshNode * n3,
1538 const SMDS_MeshNode * n12,
1539 const SMDS_MeshNode * n23,
1540 const SMDS_MeshNode * n31)
1542 SMDS_MeshFace *anElem = SMDS_Mesh::AddFace(n1,n2,n3,n12,n23,n31);
1543 if(anElem) myScript->AddFace(anElem->GetID(),
1544 n1->GetID(), n2->GetID(), n3->GetID(),
1545 n12->GetID(), n23->GetID(), n31->GetID());
1549 //=======================================================================
1550 //function : AddFaceWithID
1552 //=======================================================================
1553 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(int n1, int n2, int n3,
1554 int n12,int n23,int n31, int ID)
1556 SMDS_MeshFace *anElem = SMDS_Mesh::AddFaceWithID(n1,n2,n3,n12,n23,n31,ID);
1557 if(anElem) myScript->AddFace(ID,n1,n2,n3,n12,n23,n31);
1561 //=======================================================================
1562 //function : AddFaceWithID
1564 //=======================================================================
1565 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(const SMDS_MeshNode * n1,
1566 const SMDS_MeshNode * n2,
1567 const SMDS_MeshNode * n3,
1568 const SMDS_MeshNode * n12,
1569 const SMDS_MeshNode * n23,
1570 const SMDS_MeshNode * n31,
1573 return AddFaceWithID(n1->GetID(), n2->GetID(), n3->GetID(),
1574 n12->GetID(), n23->GetID(), n31->GetID(),
1578 //=======================================================================
1579 //function : AddFace
1581 //=======================================================================
1582 SMDS_MeshFace* SMESHDS_Mesh::AddFace(const SMDS_MeshNode * n1,
1583 const SMDS_MeshNode * n2,
1584 const SMDS_MeshNode * n3,
1585 const SMDS_MeshNode * n12,
1586 const SMDS_MeshNode * n23,
1587 const SMDS_MeshNode * n31,
1588 const SMDS_MeshNode * nCenter)
1590 SMDS_MeshFace *anElem = SMDS_Mesh::AddFace(n1,n2,n3,n12,n23,n31,nCenter);
1591 if(anElem) myScript->AddFace(anElem->GetID(),
1592 n1->GetID(), n2->GetID(), n3->GetID(),
1593 n12->GetID(), n23->GetID(), n31->GetID(),
1598 //=======================================================================
1599 //function : AddFaceWithID
1601 //=======================================================================
1602 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(int n1, int n2, int n3,
1603 int n12,int n23,int n31, int nCenter, int ID)
1605 SMDS_MeshFace *anElem = SMDS_Mesh::AddFaceWithID(n1,n2,n3,n12,n23,n31,nCenter,ID);
1606 if(anElem) myScript->AddFace(ID,n1,n2,n3,n12,n23,n31,nCenter);
1610 //=======================================================================
1611 //function : AddFaceWithID
1613 //=======================================================================
1614 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(const SMDS_MeshNode * n1,
1615 const SMDS_MeshNode * n2,
1616 const SMDS_MeshNode * n3,
1617 const SMDS_MeshNode * n12,
1618 const SMDS_MeshNode * n23,
1619 const SMDS_MeshNode * n31,
1620 const SMDS_MeshNode * nCenter,
1623 return AddFaceWithID(n1->GetID(), n2->GetID(), n3->GetID(),
1624 n12->GetID(), n23->GetID(), n31->GetID(),
1625 nCenter->GetID(), ID);
1629 //=======================================================================
1630 //function : AddFace
1632 //=======================================================================
1633 SMDS_MeshFace* SMESHDS_Mesh::AddFace(const SMDS_MeshNode * n1,
1634 const SMDS_MeshNode * n2,
1635 const SMDS_MeshNode * n3,
1636 const SMDS_MeshNode * n4,
1637 const SMDS_MeshNode * n12,
1638 const SMDS_MeshNode * n23,
1639 const SMDS_MeshNode * n34,
1640 const SMDS_MeshNode * n41)
1642 SMDS_MeshFace *anElem = SMDS_Mesh::AddFace(n1,n2,n3,n4,n12,n23,n34,n41);
1643 if(anElem) myScript->AddFace(anElem->GetID(),
1644 n1->GetID(), n2->GetID(), n3->GetID(), n4->GetID(),
1645 n12->GetID(), n23->GetID(), n34->GetID(), n41->GetID());
1649 //=======================================================================
1650 //function : AddFaceWithID
1652 //=======================================================================
1653 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(int n1, int n2, int n3, int n4,
1654 int n12,int n23,int n34,int n41, int ID)
1656 SMDS_MeshFace *anElem = SMDS_Mesh::AddFaceWithID(n1,n2,n3,n4,n12,n23,n34,n41,ID);
1657 if(anElem) myScript->AddFace(ID,n1,n2,n3,n4,n12,n23,n34,n41);
1661 //=======================================================================
1662 //function : AddFaceWithID
1664 //=======================================================================
1665 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(const SMDS_MeshNode * n1,
1666 const SMDS_MeshNode * n2,
1667 const SMDS_MeshNode * n3,
1668 const SMDS_MeshNode * n4,
1669 const SMDS_MeshNode * n12,
1670 const SMDS_MeshNode * n23,
1671 const SMDS_MeshNode * n34,
1672 const SMDS_MeshNode * n41,
1675 return AddFaceWithID(n1->GetID(), n2->GetID(), n3->GetID(), n4->GetID(),
1676 n12->GetID(), n23->GetID(), n34->GetID(), n41->GetID(),
1681 //=======================================================================
1682 //function : AddFace
1684 //=======================================================================
1685 SMDS_MeshFace* SMESHDS_Mesh::AddFace(const SMDS_MeshNode * n1,
1686 const SMDS_MeshNode * n2,
1687 const SMDS_MeshNode * n3,
1688 const SMDS_MeshNode * n4,
1689 const SMDS_MeshNode * n12,
1690 const SMDS_MeshNode * n23,
1691 const SMDS_MeshNode * n34,
1692 const SMDS_MeshNode * n41,
1693 const SMDS_MeshNode * nCenter)
1695 SMDS_MeshFace *anElem = SMDS_Mesh::AddFace(n1,n2,n3,n4,n12,n23,n34,n41,nCenter);
1696 if(anElem) myScript->AddFace(anElem->GetID(),
1697 n1->GetID(), n2->GetID(), n3->GetID(), n4->GetID(),
1698 n12->GetID(), n23->GetID(), n34->GetID(), n41->GetID(),
1703 //=======================================================================
1704 //function : AddFaceWithID
1706 //=======================================================================
1707 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(int n1, int n2, int n3, int n4,
1708 int n12,int n23,int n34,int n41,
1709 int nCenter, int ID)
1711 SMDS_MeshFace *anElem = SMDS_Mesh::AddFaceWithID(n1,n2,n3,n4,n12,n23,n34,n41,nCenter,ID);
1712 if(anElem) myScript->AddFace(ID,n1,n2,n3,n4,n12,n23,n34,n41,nCenter);
1716 //=======================================================================
1717 //function : AddFaceWithID
1719 //=======================================================================
1720 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(const SMDS_MeshNode * n1,
1721 const SMDS_MeshNode * n2,
1722 const SMDS_MeshNode * n3,
1723 const SMDS_MeshNode * n4,
1724 const SMDS_MeshNode * n12,
1725 const SMDS_MeshNode * n23,
1726 const SMDS_MeshNode * n34,
1727 const SMDS_MeshNode * n41,
1728 const SMDS_MeshNode * nCenter,
1731 return AddFaceWithID(n1->GetID(), n2->GetID(), n3->GetID(), n4->GetID(),
1732 n12->GetID(), n23->GetID(), n34->GetID(), n41->GetID(),
1733 nCenter->GetID(), ID);
1737 //=======================================================================
1738 //function : AddVolume
1740 //=======================================================================
1741 SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
1742 const SMDS_MeshNode * n2,
1743 const SMDS_MeshNode * n3,
1744 const SMDS_MeshNode * n4,
1745 const SMDS_MeshNode * n12,
1746 const SMDS_MeshNode * n23,
1747 const SMDS_MeshNode * n31,
1748 const SMDS_MeshNode * n14,
1749 const SMDS_MeshNode * n24,
1750 const SMDS_MeshNode * n34)
1752 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1,n2,n3,n4,n12,n23,n31,n14,n24,n34);
1753 if(anElem) myScript->AddVolume(anElem->GetID(),
1754 n1->GetID(), n2->GetID(), n3->GetID(), n4->GetID(),
1755 n12->GetID(), n23->GetID(), n31->GetID(),
1756 n14->GetID(), n24->GetID(), n34->GetID());
1760 //=======================================================================
1761 //function : AddVolumeWithID
1763 //=======================================================================
1764 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3, int n4,
1765 int n12,int n23,int n31,
1766 int n14,int n24,int n34, int ID)
1768 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolumeWithID(n1,n2,n3,n4,n12,n23,
1769 n31,n14,n24,n34,ID);
1770 if(anElem) myScript->AddVolume(ID,n1,n2,n3,n4,n12,n23,n31,n14,n24,n34);
1774 //=======================================================================
1775 //function : AddVolumeWithID
1776 //purpose : 2d order tetrahedron of 10 nodes
1777 //=======================================================================
1778 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
1779 const SMDS_MeshNode * n2,
1780 const SMDS_MeshNode * n3,
1781 const SMDS_MeshNode * n4,
1782 const SMDS_MeshNode * n12,
1783 const SMDS_MeshNode * n23,
1784 const SMDS_MeshNode * n31,
1785 const SMDS_MeshNode * n14,
1786 const SMDS_MeshNode * n24,
1787 const SMDS_MeshNode * n34,
1790 return AddVolumeWithID(n1->GetID(), n2->GetID(), n3->GetID(), n4->GetID(),
1791 n12->GetID(), n23->GetID(), n31->GetID(),
1792 n14->GetID(), n24->GetID(), n34->GetID(), ID);
1796 //=======================================================================
1797 //function : AddVolume
1799 //=======================================================================
1800 SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
1801 const SMDS_MeshNode * n2,
1802 const SMDS_MeshNode * n3,
1803 const SMDS_MeshNode * n4,
1804 const SMDS_MeshNode * n5,
1805 const SMDS_MeshNode * n12,
1806 const SMDS_MeshNode * n23,
1807 const SMDS_MeshNode * n34,
1808 const SMDS_MeshNode * n41,
1809 const SMDS_MeshNode * n15,
1810 const SMDS_MeshNode * n25,
1811 const SMDS_MeshNode * n35,
1812 const SMDS_MeshNode * n45)
1814 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1,n2,n3,n4,n5,n12,n23,n34,n41,
1817 myScript->AddVolume(anElem->GetID(), n1->GetID(), n2->GetID(),
1818 n3->GetID(), n4->GetID(), n5->GetID(),
1819 n12->GetID(), n23->GetID(), n34->GetID(), n41->GetID(),
1820 n15->GetID(), n25->GetID(), n35->GetID(), n45->GetID());
1824 //=======================================================================
1825 //function : AddVolumeWithID
1827 //=======================================================================
1828 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3, int n4, int n5,
1829 int n12,int n23,int n34,int n41,
1830 int n15,int n25,int n35,int n45, int ID)
1832 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolumeWithID(n1,n2,n3,n4,n5,
1834 n15,n25,n35,n45,ID);
1835 if(anElem) myScript->AddVolume(ID,n1,n2,n3,n4,n5,n12,n23,n34,n41,
1840 //=======================================================================
1841 //function : AddVolumeWithID
1842 //purpose : 2d order pyramid of 13 nodes
1843 //=======================================================================
1844 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
1845 const SMDS_MeshNode * n2,
1846 const SMDS_MeshNode * n3,
1847 const SMDS_MeshNode * n4,
1848 const SMDS_MeshNode * n5,
1849 const SMDS_MeshNode * n12,
1850 const SMDS_MeshNode * n23,
1851 const SMDS_MeshNode * n34,
1852 const SMDS_MeshNode * n41,
1853 const SMDS_MeshNode * n15,
1854 const SMDS_MeshNode * n25,
1855 const SMDS_MeshNode * n35,
1856 const SMDS_MeshNode * n45,
1859 return AddVolumeWithID(n1->GetID(), n2->GetID(), n3->GetID(),
1860 n4->GetID(), n5->GetID(),
1861 n12->GetID(), n23->GetID(), n34->GetID(), n41->GetID(),
1862 n15->GetID(), n25->GetID(), n35->GetID(), n45->GetID(),
1867 //=======================================================================
1868 //function : AddVolume
1870 //=======================================================================
1871 SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
1872 const SMDS_MeshNode * n2,
1873 const SMDS_MeshNode * n3,
1874 const SMDS_MeshNode * n4,
1875 const SMDS_MeshNode * n5,
1876 const SMDS_MeshNode * n6,
1877 const SMDS_MeshNode * n12,
1878 const SMDS_MeshNode * n23,
1879 const SMDS_MeshNode * n31,
1880 const SMDS_MeshNode * n45,
1881 const SMDS_MeshNode * n56,
1882 const SMDS_MeshNode * n64,
1883 const SMDS_MeshNode * n14,
1884 const SMDS_MeshNode * n25,
1885 const SMDS_MeshNode * n36)
1887 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1,n2,n3,n4,n5,n6,n12,n23,n31,
1888 n45,n56,n64,n14,n25,n36);
1890 myScript->AddVolume(anElem->GetID(), n1->GetID(), n2->GetID(),
1891 n3->GetID(), n4->GetID(), n5->GetID(), n6->GetID(),
1892 n12->GetID(), n23->GetID(), n31->GetID(),
1893 n45->GetID(), n56->GetID(), n64->GetID(),
1894 n14->GetID(), n25->GetID(), n36->GetID());
1898 //=======================================================================
1899 //function : AddVolumeWithID
1901 //=======================================================================
1902 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3,
1903 int n4, int n5, int n6,
1904 int n12,int n23,int n31,
1905 int n45,int n56,int n64,
1906 int n14,int n25,int n36, int ID)
1908 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolumeWithID(n1,n2,n3,n4,n5,n6,
1912 if(anElem) myScript->AddVolume(ID,n1,n2,n3,n4,n5,n6,n12,n23,n31,
1913 n45,n56,n64,n14,n25,n36);
1917 //=======================================================================
1918 //function : AddVolumeWithID
1919 //purpose : 2d order Pentahedron with 15 nodes
1920 //=======================================================================
1921 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
1922 const SMDS_MeshNode * n2,
1923 const SMDS_MeshNode * n3,
1924 const SMDS_MeshNode * n4,
1925 const SMDS_MeshNode * n5,
1926 const SMDS_MeshNode * n6,
1927 const SMDS_MeshNode * n12,
1928 const SMDS_MeshNode * n23,
1929 const SMDS_MeshNode * n31,
1930 const SMDS_MeshNode * n45,
1931 const SMDS_MeshNode * n56,
1932 const SMDS_MeshNode * n64,
1933 const SMDS_MeshNode * n14,
1934 const SMDS_MeshNode * n25,
1935 const SMDS_MeshNode * n36,
1938 return AddVolumeWithID(n1->GetID(), n2->GetID(), n3->GetID(),
1939 n4->GetID(), n5->GetID(), n6->GetID(),
1940 n12->GetID(), n23->GetID(), n31->GetID(),
1941 n45->GetID(), n56->GetID(), n64->GetID(),
1942 n14->GetID(), n25->GetID(), n36->GetID(),
1947 //=======================================================================
1948 //function : AddVolume
1949 //purpose : add quadratic hexahedron
1950 //=======================================================================
1951 SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
1952 const SMDS_MeshNode * n2,
1953 const SMDS_MeshNode * n3,
1954 const SMDS_MeshNode * n4,
1955 const SMDS_MeshNode * n5,
1956 const SMDS_MeshNode * n6,
1957 const SMDS_MeshNode * n7,
1958 const SMDS_MeshNode * n8,
1959 const SMDS_MeshNode * n12,
1960 const SMDS_MeshNode * n23,
1961 const SMDS_MeshNode * n34,
1962 const SMDS_MeshNode * n41,
1963 const SMDS_MeshNode * n56,
1964 const SMDS_MeshNode * n67,
1965 const SMDS_MeshNode * n78,
1966 const SMDS_MeshNode * n85,
1967 const SMDS_MeshNode * n15,
1968 const SMDS_MeshNode * n26,
1969 const SMDS_MeshNode * n37,
1970 const SMDS_MeshNode * n48)
1972 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1,n2,n3,n4,n5,n6,n7,n8,
1977 myScript->AddVolume(anElem->GetID(), n1->GetID(), n2->GetID(),
1978 n3->GetID(), n4->GetID(), n5->GetID(),
1979 n6->GetID(), n7->GetID(), n8->GetID(),
1980 n12->GetID(), n23->GetID(), n34->GetID(), n41->GetID(),
1981 n56->GetID(), n67->GetID(), n78->GetID(), n85->GetID(),
1982 n15->GetID(), n26->GetID(), n37->GetID(), n48->GetID());
1986 //=======================================================================
1987 //function : AddVolumeWithID
1989 //=======================================================================
1990 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3, int n4,
1991 int n5, int n6, int n7, int n8,
1992 int n12,int n23,int n34,int n41,
1993 int n56,int n67,int n78,int n85,
1994 int n15,int n26,int n37,int n48, int ID)
1996 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolumeWithID(n1,n2,n3,n4,n5,n6,n7,n8,
1999 n15,n26,n37,n48,ID);
2000 if(anElem) myScript->AddVolume(ID,n1,n2,n3,n4,n5,n6,n7,n8,n12,n23,n34,n41,
2001 n56,n67,n78,n85,n15,n26,n37,n48);
2005 //=======================================================================
2006 //function : AddVolumeWithID
2007 //purpose : 2d order Hexahedrons with 20 nodes
2008 //=======================================================================
2009 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
2010 const SMDS_MeshNode * n2,
2011 const SMDS_MeshNode * n3,
2012 const SMDS_MeshNode * n4,
2013 const SMDS_MeshNode * n5,
2014 const SMDS_MeshNode * n6,
2015 const SMDS_MeshNode * n7,
2016 const SMDS_MeshNode * n8,
2017 const SMDS_MeshNode * n12,
2018 const SMDS_MeshNode * n23,
2019 const SMDS_MeshNode * n34,
2020 const SMDS_MeshNode * n41,
2021 const SMDS_MeshNode * n56,
2022 const SMDS_MeshNode * n67,
2023 const SMDS_MeshNode * n78,
2024 const SMDS_MeshNode * n85,
2025 const SMDS_MeshNode * n15,
2026 const SMDS_MeshNode * n26,
2027 const SMDS_MeshNode * n37,
2028 const SMDS_MeshNode * n48,
2031 return AddVolumeWithID(n1->GetID(), n2->GetID(), n3->GetID(), n4->GetID(),
2032 n5->GetID(), n6->GetID(), n7->GetID(), n8->GetID(),
2033 n12->GetID(), n23->GetID(), n34->GetID(), n41->GetID(),
2034 n56->GetID(), n67->GetID(), n78->GetID(), n85->GetID(),
2035 n15->GetID(), n26->GetID(), n37->GetID(), n48->GetID(),
2039 //=======================================================================
2040 //function : AddVolume
2041 //purpose : add tri-quadratic hexahedron of 27 nodes
2042 //=======================================================================
2044 SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
2045 const SMDS_MeshNode * n2,
2046 const SMDS_MeshNode * n3,
2047 const SMDS_MeshNode * n4,
2048 const SMDS_MeshNode * n5,
2049 const SMDS_MeshNode * n6,
2050 const SMDS_MeshNode * n7,
2051 const SMDS_MeshNode * n8,
2052 const SMDS_MeshNode * n12,
2053 const SMDS_MeshNode * n23,
2054 const SMDS_MeshNode * n34,
2055 const SMDS_MeshNode * n41,
2056 const SMDS_MeshNode * n56,
2057 const SMDS_MeshNode * n67,
2058 const SMDS_MeshNode * n78,
2059 const SMDS_MeshNode * n85,
2060 const SMDS_MeshNode * n15,
2061 const SMDS_MeshNode * n26,
2062 const SMDS_MeshNode * n37,
2063 const SMDS_MeshNode * n48,
2064 const SMDS_MeshNode * n1234,
2065 const SMDS_MeshNode * n1256,
2066 const SMDS_MeshNode * n2367,
2067 const SMDS_MeshNode * n3478,
2068 const SMDS_MeshNode * n1458,
2069 const SMDS_MeshNode * n5678,
2070 const SMDS_MeshNode * nCenter)
2072 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1,n2,n3,n4,n5,n6,n7,n8,
2076 n1234,n1256,n2367,n3478,n1458,n5678,nCenter);
2078 myScript->AddVolume(anElem->GetID(), n1->GetID(), n2->GetID(),
2079 n3->GetID(), n4->GetID(), n5->GetID(),
2080 n6->GetID(), n7->GetID(), n8->GetID(),
2081 n12->GetID(), n23->GetID(), n34->GetID(), n41->GetID(),
2082 n56->GetID(), n67->GetID(), n78->GetID(), n85->GetID(),
2083 n15->GetID(), n26->GetID(), n37->GetID(), n48->GetID(),
2084 n1234->GetID(),n1256->GetID(),n2367->GetID(),n3478->GetID(),
2085 n1458->GetID(),n5678->GetID(),nCenter->GetID());
2089 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3, int n4,
2090 int n5, int n6, int n7, int n8,
2091 int n12,int n23,int n34,int n41,
2092 int n56,int n67,int n78,int n85,
2093 int n15,int n26,int n37,int n48,
2094 int n1234,int n1256,int n2367,int n3478,
2095 int n1458,int n5678,int nCenter,
2098 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolumeWithID(n1,n2,n3,n4,n5,n6,n7,n8,
2102 n1234, n1256, n2367, n3478,
2103 n1458, n5678, nCenter,
2105 if(anElem) myScript->AddVolume(ID,n1,n2,n3,n4,n5,n6,n7,n8,n12,n23,n34,n41,
2106 n56,n67,n78,n85,n15,n26,n37,n48,
2107 n1234, n1256, n2367, n3478,
2108 n1458, n5678, nCenter);
2112 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
2113 const SMDS_MeshNode * n2,
2114 const SMDS_MeshNode * n3,
2115 const SMDS_MeshNode * n4,
2116 const SMDS_MeshNode * n5,
2117 const SMDS_MeshNode * n6,
2118 const SMDS_MeshNode * n7,
2119 const SMDS_MeshNode * n8,
2120 const SMDS_MeshNode * n12,
2121 const SMDS_MeshNode * n23,
2122 const SMDS_MeshNode * n34,
2123 const SMDS_MeshNode * n41,
2124 const SMDS_MeshNode * n56,
2125 const SMDS_MeshNode * n67,
2126 const SMDS_MeshNode * n78,
2127 const SMDS_MeshNode * n85,
2128 const SMDS_MeshNode * n15,
2129 const SMDS_MeshNode * n26,
2130 const SMDS_MeshNode * n37,
2131 const SMDS_MeshNode * n48,
2132 const SMDS_MeshNode * n1234,
2133 const SMDS_MeshNode * n1256,
2134 const SMDS_MeshNode * n2367,
2135 const SMDS_MeshNode * n3478,
2136 const SMDS_MeshNode * n1458,
2137 const SMDS_MeshNode * n5678,
2138 const SMDS_MeshNode * nCenter,
2141 return AddVolumeWithID(n1->GetID(), n2->GetID(), n3->GetID(), n4->GetID(),
2142 n5->GetID(), n6->GetID(), n7->GetID(), n8->GetID(),
2143 n12->GetID(), n23->GetID(), n34->GetID(), n41->GetID(),
2144 n56->GetID(), n67->GetID(), n78->GetID(), n85->GetID(),
2145 n15->GetID(), n26->GetID(), n37->GetID(), n48->GetID(),
2146 n1234->GetID(),n1256->GetID(),n2367->GetID(),n3478->GetID(),
2147 n1458->GetID(),n5678->GetID(),nCenter->GetID(), ID);
2150 void SMESHDS_Mesh::compactMesh()
2152 int newNodeSize = 0;
2153 int nbNodes = myNodes.size();
2154 int nbVtkNodes = myGrid->GetNumberOfPoints();
2155 //MESSAGE("nbNodes=" << nbNodes << " nbVtkNodes=" << nbVtkNodes);
2156 int nbNodeTemp = nbVtkNodes;
2157 if (nbNodes > nbVtkNodes)
2158 nbNodeTemp = nbNodes;
2159 vector<int> idNodesOldToNew;
2160 idNodesOldToNew.clear();
2161 idNodesOldToNew.resize(nbNodeTemp, -1); // all unused id will be -1
2163 for (int i = 0; i < nbNodes; i++)
2167 int vtkid = myNodes[i]->getVtkId();
2168 idNodesOldToNew[vtkid] = i; // old vtkId --> old smdsId (valid smdsId are >= 0)
2172 bool areNodesModified = (newNodeSize < nbVtkNodes);
2173 //MESSAGE("------------------------- compactMesh Nodes Modified: " << areNodesModified);
2174 areNodesModified = true;
2176 int newCellSize = 0;
2177 int nbCells = myCells.size();
2178 int nbVtkCells = myGrid->GetNumberOfCells();
2179 //MESSAGE("nbCells=" << nbCells << " nbVtkCells=" << nbVtkCells);
2180 int nbCellTemp = nbVtkCells;
2181 if (nbCells > nbVtkCells)
2182 nbCellTemp = nbCells;
2183 vector<int> idCellsOldToNew;
2184 idCellsOldToNew.clear();
2185 idCellsOldToNew.resize(nbCellTemp, -1); // all unused id will be -1
2187 for (int i = 0; i < nbCells; i++)
2191 // //idCellsOldToNew[i] = myCellIdVtkToSmds[i]; // valid vtk indexes are > = 0
2192 // int vtkid = myCells[i]->getVtkId();
2193 // idCellsOldToNew[vtkid] = i; // old vtkId --> old smdsId (not used in input)
2197 if (areNodesModified)
2198 myGrid->compactGrid(idNodesOldToNew, newNodeSize, idCellsOldToNew, newCellSize);
2200 myGrid->compactGrid(idNodesOldToNew, 0, idCellsOldToNew, newCellSize);
2202 int nbVtkPts = myGrid->GetNumberOfPoints();
2203 nbVtkCells = myGrid->GetNumberOfCells();
2204 if (nbVtkPts != newNodeSize)
2206 MESSAGE("===> nbVtkPts != newNodeSize " << nbVtkPts << " " << newNodeSize);
2207 if (nbVtkPts > newNodeSize) newNodeSize = nbVtkPts; // several points with same SMDS Id
2209 if (nbVtkCells != newCellSize)
2211 MESSAGE("===> nbVtkCells != newCellSize " << nbVtkCells << " " << newCellSize);
2212 if (nbVtkCells > newCellSize) newCellSize = nbVtkCells; // several cells with same SMDS Id
2215 // --- SMDS_MeshNode and myNodes (id in SMDS and in VTK are the same), myNodeIdFactory
2217 if (areNodesModified)
2219 //MESSAGE("-------------- modify myNodes");
2220 SetOfNodes newNodes;
2221 newNodes.resize(newNodeSize+1,0); // 0 not used, SMDS numbers 1..n
2223 for (int i = 0; i < nbNodes; i++)
2227 newSmdsId++; // SMDS id start to 1
2228 int oldVtkId = myNodes[i]->getVtkId();
2229 int newVtkId = idNodesOldToNew[oldVtkId];
2230 //MESSAGE("myNodes["<< i << "] vtkId " << oldVtkId << " --> " << newVtkId);
2231 myNodes[i]->setVtkId(newVtkId);
2232 myNodes[i]->setId(newSmdsId);
2233 newNodes[newSmdsId] = myNodes[i];
2234 //MESSAGE("myNodes["<< i << "] --> newNodes[" << newSmdsId << "]");
2237 myNodes.swap(newNodes);
2238 this->myNodeIDFactory->emptyPool(newSmdsId); // newSmdsId = number of nodes
2239 //MESSAGE("myNodes.size " << myNodes.size());
2242 // --- SMDS_MeshCell, myCellIdVtkToSmds, myCellIdSmdsToVtk, myCells
2244 int vtkIndexSize = myCellIdVtkToSmds.size();
2246 for (int oldVtkId = 0; oldVtkId < vtkIndexSize; oldVtkId++)
2248 int oldSmdsId = this->myCellIdVtkToSmds[oldVtkId];
2251 int newVtkId = idCellsOldToNew[oldVtkId];
2252 if (newVtkId > maxVtkId)
2253 maxVtkId = newVtkId;
2254 //MESSAGE("myCells["<< oldSmdsId << "] vtkId " << oldVtkId << " --> " << newVtkId);
2255 myCells[oldSmdsId]->setVtkId(newVtkId);
2258 // MESSAGE("myCells.size()=" << myCells.size()
2259 // << " myCellIdSmdsToVtk.size()=" << myCellIdSmdsToVtk.size()
2260 // << " myCellIdVtkToSmds.size()=" << myCellIdVtkToSmds.size() );
2262 SetOfCells newCells;
2263 //vector<int> newSmdsToVtk;
2264 vector<int> newVtkToSmds;
2266 assert(maxVtkId < newCellSize);
2267 newCells.resize(newCellSize+1, 0); // 0 not used, SMDS numbers 1..n
2268 //newSmdsToVtk.resize(newCellSize+1, -1);
2269 newVtkToSmds.resize(newCellSize+1, -1);
2271 int myCellsSize = myCells.size();
2273 for (int i = 0; i < myCellsSize; i++)
2277 newSmdsId++; // SMDS id start to 1
2278 assert(newSmdsId <= newCellSize);
2279 newCells[newSmdsId] = myCells[i];
2280 newCells[newSmdsId]->setId(newSmdsId);
2281 //MESSAGE("myCells["<< i << "] --> newCells[" << newSmdsId << "]");
2282 int idvtk = myCells[i]->getVtkId();
2283 //newSmdsToVtk[newSmdsId] = idvtk;
2284 assert(idvtk < newCellSize);
2285 newVtkToSmds[idvtk] = newSmdsId;
2289 myCells.swap(newCells);
2290 //myCellIdSmdsToVtk.swap(newSmdsToVtk);
2291 myCellIdVtkToSmds.swap(newVtkToSmds);
2292 //MESSAGE("myCells.size()="<< myCells.size()<<" myCellIdVtkToSmds.size()="<<myCellIdVtkToSmds.size() );
2293 this->myElementIDFactory->emptyPool(newSmdsId);
2295 this->myScript->SetModified(true); // notify GUI client for buildPrs when update
2297 // --- compact list myNodes and myElements in submeshes
2299 SMESHDS_SubMeshIteratorPtr smIt = SubMeshes();
2300 while ( SMESHDS_SubMesh* sm = const_cast< SMESHDS_SubMesh* >( smIt->next() ))
2304 void SMESHDS_Mesh::CleanDownWardConnectivity()
2306 myGrid->CleanDownwardConnectivity();
2309 void SMESHDS_Mesh::BuildDownWardConnectivity(bool withEdges)
2311 myGrid->BuildDownwardConnectivity(withEdges);
2314 /*! change some nodes in cell without modifying type or internal connectivity.
2315 * Nodes inverse connectivity is maintained up to date.
2316 * @param vtkVolId vtk id of the cell.
2317 * @param localClonedNodeIds map old node id to new node id.
2318 * @return ok if success.
2320 bool SMESHDS_Mesh::ModifyCellNodes(int vtkVolId, std::map<int,int> localClonedNodeIds)
2322 myGrid->ModifyCellNodes(vtkVolId, localClonedNodeIds);