1 // Copyright (C) 2007-2015 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 //MESSAGE("SMESHDS_Mesh::ChangeElementNodes");
224 if ( ! SMDS_Mesh::ChangeElementNodes( elem, nodes, nbnodes ))
227 vector<int> IDs( nbnodes );
228 for ( int i = 0; i < nbnodes; i++ )
229 IDs [ i ] = nodes[ i ]->GetID();
230 myScript->ChangeElementNodes( elem->GetID(), &IDs[0], nbnodes);
235 //=======================================================================
236 //function : ChangePolygonNodes
238 //=======================================================================
239 bool SMESHDS_Mesh::ChangePolygonNodes
240 (const SMDS_MeshElement * elem,
241 vector<const SMDS_MeshNode*> nodes)
243 ASSERT(nodes.size() > 3);
245 return ChangeElementNodes(elem, &nodes[0], nodes.size());
248 //=======================================================================
249 //function : ChangePolyhedronNodes
251 //=======================================================================
252 bool SMESHDS_Mesh::ChangePolyhedronNodes
253 (const SMDS_MeshElement * elem,
254 std::vector<const SMDS_MeshNode*> nodes,
255 std::vector<int> quantities)
257 ASSERT(nodes.size() > 3);
259 if (!SMDS_Mesh::ChangePolyhedronNodes(elem, nodes, quantities))
262 int i, len = nodes.size();
263 std::vector<int> nodes_ids (len);
264 for (i = 0; i < len; i++) {
265 nodes_ids[i] = nodes[i]->GetID();
267 myScript->ChangePolyhedronNodes(elem->GetID(), nodes_ids, quantities);
272 //=======================================================================
273 //function : Renumber
275 //=======================================================================
277 void SMESHDS_Mesh::Renumber (const bool isNodes, const int startID, const int deltaID)
279 // TODO not possible yet to have node numbers not starting to O and continuous.
280 if (!this->isCompacted())
282 // SMDS_Mesh::Renumber( isNodes, startID, deltaID );
283 // myScript->Renumber( isNodes, startID, deltaID );
286 //=======================================================================
287 //function : Add0DElement
289 //=======================================================================
290 SMDS_Mesh0DElement* SMESHDS_Mesh::Add0DElementWithID(int nodeID, int ID)
292 SMDS_Mesh0DElement* anElem = SMDS_Mesh::Add0DElementWithID(nodeID, ID);
293 if (anElem) myScript->Add0DElement(ID, nodeID);
297 SMDS_Mesh0DElement* SMESHDS_Mesh::Add0DElementWithID
298 (const SMDS_MeshNode * node, int ID)
300 return Add0DElementWithID(node->GetID(), ID);
303 SMDS_Mesh0DElement* SMESHDS_Mesh::Add0DElement(const SMDS_MeshNode * node)
305 SMDS_Mesh0DElement* anElem = SMDS_Mesh::Add0DElement(node);
306 if (anElem) myScript->Add0DElement(anElem->GetID(), node->GetID());
310 //=======================================================================
311 //function :AddBallWithID
313 //=======================================================================
315 SMDS_BallElement* SMESHDS_Mesh::AddBallWithID(int node, double diameter, int ID)
317 SMDS_BallElement* anElem = SMDS_Mesh::AddBallWithID(node,diameter,ID);
318 if (anElem) myScript->AddBall(anElem->GetID(), node, diameter);
322 SMDS_BallElement* SMESHDS_Mesh::AddBallWithID(const SMDS_MeshNode * node,
326 SMDS_BallElement* anElem = SMDS_Mesh::AddBallWithID(node,diameter,ID);
327 if (anElem) myScript->AddBall(anElem->GetID(), node->GetID(), diameter);
331 SMDS_BallElement* SMESHDS_Mesh::AddBall (const SMDS_MeshNode * node,
334 SMDS_BallElement* anElem = SMDS_Mesh::AddBall(node,diameter);
335 if (anElem) myScript->AddBall(anElem->GetID(), node->GetID(), diameter);
339 //=======================================================================
340 //function :AddEdgeWithID
342 //=======================================================================
344 SMDS_MeshEdge* SMESHDS_Mesh::AddEdgeWithID(int n1, int n2, int ID)
346 SMDS_MeshEdge* anElem = SMDS_Mesh::AddEdgeWithID(n1,n2,ID);
347 if(anElem) myScript->AddEdge(ID,n1,n2);
351 SMDS_MeshEdge* SMESHDS_Mesh::AddEdgeWithID(const SMDS_MeshNode * n1,
352 const SMDS_MeshNode * n2,
355 return AddEdgeWithID(n1->GetID(),
360 SMDS_MeshEdge* SMESHDS_Mesh::AddEdge(const SMDS_MeshNode * n1,
361 const SMDS_MeshNode * n2)
363 SMDS_MeshEdge* anElem = SMDS_Mesh::AddEdge(n1,n2);
364 if(anElem) myScript->AddEdge(anElem->GetID(),
370 //=======================================================================
373 //=======================================================================
374 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(int n1, int n2, int n3, int ID)
376 SMDS_MeshFace *anElem = SMDS_Mesh::AddFaceWithID(n1, n2, n3, ID);
377 if(anElem) myScript->AddFace(ID,n1,n2,n3);
381 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(const SMDS_MeshNode * n1,
382 const SMDS_MeshNode * n2,
383 const SMDS_MeshNode * n3,
386 return AddFaceWithID(n1->GetID(),
392 SMDS_MeshFace* SMESHDS_Mesh::AddFace( const SMDS_MeshNode * n1,
393 const SMDS_MeshNode * n2,
394 const SMDS_MeshNode * n3)
396 SMDS_MeshFace *anElem = SMDS_Mesh::AddFace(n1, n2, n3);
397 if(anElem) myScript->AddFace(anElem->GetID(),
404 //=======================================================================
407 //=======================================================================
408 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(int n1, int n2, int n3, int n4, int ID)
410 SMDS_MeshFace *anElem = SMDS_Mesh::AddFaceWithID(n1, n2, n3, n4, ID);
411 if(anElem) myScript->AddFace(ID, n1, n2, n3, n4);
415 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(const SMDS_MeshNode * n1,
416 const SMDS_MeshNode * n2,
417 const SMDS_MeshNode * n3,
418 const SMDS_MeshNode * n4,
421 return AddFaceWithID(n1->GetID(),
428 SMDS_MeshFace* SMESHDS_Mesh::AddFace(const SMDS_MeshNode * n1,
429 const SMDS_MeshNode * n2,
430 const SMDS_MeshNode * n3,
431 const SMDS_MeshNode * n4)
433 SMDS_MeshFace *anElem = SMDS_Mesh::AddFace(n1, n2, n3, n4);
434 if(anElem) myScript->AddFace(anElem->GetID(),
442 //=======================================================================
443 //function :AddVolume
445 //=======================================================================
446 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3, int n4, int ID)
448 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolumeWithID(n1, n2, n3, n4, ID);
449 if(anElem) myScript->AddVolume(ID, n1, n2, n3, n4);
453 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
454 const SMDS_MeshNode * n2,
455 const SMDS_MeshNode * n3,
456 const SMDS_MeshNode * n4,
459 return AddVolumeWithID(n1->GetID(),
466 SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
467 const SMDS_MeshNode * n2,
468 const SMDS_MeshNode * n3,
469 const SMDS_MeshNode * n4)
471 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1, n2, n3, n4);
472 if(anElem) myScript->AddVolume(anElem->GetID(),
480 //=======================================================================
481 //function :AddVolume
483 //=======================================================================
484 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3, int n4, int n5, int ID)
486 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolumeWithID(n1, n2, n3, n4, n5, ID);
487 if(anElem) myScript->AddVolume(ID, n1, n2, n3, n4, n5);
491 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
492 const SMDS_MeshNode * n2,
493 const SMDS_MeshNode * n3,
494 const SMDS_MeshNode * n4,
495 const SMDS_MeshNode * n5,
498 return AddVolumeWithID(n1->GetID(),
506 SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
507 const SMDS_MeshNode * n2,
508 const SMDS_MeshNode * n3,
509 const SMDS_MeshNode * n4,
510 const SMDS_MeshNode * n5)
512 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1, n2, n3, n4, n5);
513 if(anElem) myScript->AddVolume(anElem->GetID(),
522 //=======================================================================
523 //function :AddVolume
525 //=======================================================================
526 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3, int n4, int n5, int n6, int ID)
528 SMDS_MeshVolume *anElem= SMDS_Mesh::AddVolumeWithID(n1, n2, n3, n4, n5, n6, ID);
529 if(anElem) myScript->AddVolume(ID, n1, n2, n3, n4, n5, n6);
533 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
534 const SMDS_MeshNode * n2,
535 const SMDS_MeshNode * n3,
536 const SMDS_MeshNode * n4,
537 const SMDS_MeshNode * n5,
538 const SMDS_MeshNode * n6,
541 return AddVolumeWithID(n1->GetID(),
550 SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
551 const SMDS_MeshNode * n2,
552 const SMDS_MeshNode * n3,
553 const SMDS_MeshNode * n4,
554 const SMDS_MeshNode * n5,
555 const SMDS_MeshNode * n6)
557 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1, n2, n3, n4, n5, n6);
558 if(anElem) myScript->AddVolume(anElem->GetID(),
568 //=======================================================================
569 //function :AddVolume
571 //=======================================================================
572 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3, int n4, int n5, int n6, int n7, int n8, int ID)
574 SMDS_MeshVolume *anElem= SMDS_Mesh::AddVolumeWithID(n1, n2, n3, n4, n5, n6, n7, n8, ID);
575 if(anElem) myScript->AddVolume(ID, n1, n2, n3, n4, n5, n6, n7, n8);
579 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
580 const SMDS_MeshNode * n2,
581 const SMDS_MeshNode * n3,
582 const SMDS_MeshNode * n4,
583 const SMDS_MeshNode * n5,
584 const SMDS_MeshNode * n6,
585 const SMDS_MeshNode * n7,
586 const SMDS_MeshNode * n8,
589 return AddVolumeWithID(n1->GetID(),
600 SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
601 const SMDS_MeshNode * n2,
602 const SMDS_MeshNode * n3,
603 const SMDS_MeshNode * n4,
604 const SMDS_MeshNode * n5,
605 const SMDS_MeshNode * n6,
606 const SMDS_MeshNode * n7,
607 const SMDS_MeshNode * n8)
609 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1, n2, n3, n4, n5, n6, n7, n8);
610 if(anElem) myScript->AddVolume(anElem->GetID(),
623 //=======================================================================
624 //function :AddVolume
625 //purpose : add hexagonal prism
626 //=======================================================================
627 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3, int n4,
628 int n5, int n6, int n7, int n8,
629 int n9, int n10, int n11, int n12,
632 SMDS_MeshVolume *anElem= SMDS_Mesh::AddVolumeWithID(n1, n2, n3, n4, n5, n6, n7, n8, n9, n10, n11, n12, ID);
633 if(anElem) myScript->AddVolume(ID, n1, n2, n3, n4, n5, n6, n7, n8, n9, n10, n11, n12);
637 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
638 const SMDS_MeshNode * n2,
639 const SMDS_MeshNode * n3,
640 const SMDS_MeshNode * n4,
641 const SMDS_MeshNode * n5,
642 const SMDS_MeshNode * n6,
643 const SMDS_MeshNode * n7,
644 const SMDS_MeshNode * n8,
645 const SMDS_MeshNode * n9,
646 const SMDS_MeshNode * n10,
647 const SMDS_MeshNode * n11,
648 const SMDS_MeshNode * n12,
651 return AddVolumeWithID(n1->GetID(),
666 SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
667 const SMDS_MeshNode * n2,
668 const SMDS_MeshNode * n3,
669 const SMDS_MeshNode * n4,
670 const SMDS_MeshNode * n5,
671 const SMDS_MeshNode * n6,
672 const SMDS_MeshNode * n7,
673 const SMDS_MeshNode * n8,
674 const SMDS_MeshNode * n9,
675 const SMDS_MeshNode * n10,
676 const SMDS_MeshNode * n11,
677 const SMDS_MeshNode * n12)
679 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1, n2, n3, n4, n5, n6, n7, n8, n9, n10, n11, n12);
680 if(anElem) myScript->AddVolume(anElem->GetID(),
697 //=======================================================================
698 //function : AddPolygonalFace
700 //=======================================================================
701 SMDS_MeshFace* SMESHDS_Mesh::AddPolygonalFaceWithID (const std::vector<int>& nodes_ids,
704 SMDS_MeshFace *anElem = SMDS_Mesh::AddPolygonalFaceWithID(nodes_ids, ID);
706 myScript->AddPolygonalFace(ID, nodes_ids);
712 SMESHDS_Mesh::AddPolygonalFaceWithID (const std::vector<const SMDS_MeshNode*>& nodes,
715 SMDS_MeshFace *anElem = SMDS_Mesh::AddPolygonalFaceWithID(nodes, ID);
717 int i, len = nodes.size();
718 std::vector<int> nodes_ids (len);
719 for (i = 0; i < len; i++) {
720 nodes_ids[i] = nodes[i]->GetID();
722 myScript->AddPolygonalFace(ID, nodes_ids);
728 SMESHDS_Mesh::AddPolygonalFace (const std::vector<const SMDS_MeshNode*>& nodes)
730 SMDS_MeshFace *anElem = SMDS_Mesh::AddPolygonalFace(nodes);
732 int i, len = nodes.size();
733 std::vector<int> nodes_ids (len);
734 for (i = 0; i < len; i++) {
735 nodes_ids[i] = nodes[i]->GetID();
737 myScript->AddPolygonalFace(anElem->GetID(), nodes_ids);
743 //=======================================================================
744 //function : AddQuadPolygonalFace
746 //=======================================================================
747 SMDS_MeshFace* SMESHDS_Mesh::AddQuadPolygonalFaceWithID (const std::vector<int>& nodes_ids,
750 SMDS_MeshFace *anElem = SMDS_Mesh::AddQuadPolygonalFaceWithID(nodes_ids, ID);
752 myScript->AddQuadPolygonalFace(ID, nodes_ids);
758 SMESHDS_Mesh::AddQuadPolygonalFaceWithID (const std::vector<const SMDS_MeshNode*>& nodes,
761 SMDS_MeshFace *anElem = SMDS_Mesh::AddQuadPolygonalFaceWithID(nodes, ID);
763 int i, len = nodes.size();
764 std::vector<int> nodes_ids (len);
765 for (i = 0; i < len; i++) {
766 nodes_ids[i] = nodes[i]->GetID();
768 myScript->AddQuadPolygonalFace(ID, nodes_ids);
774 SMESHDS_Mesh::AddQuadPolygonalFace (const std::vector<const SMDS_MeshNode*>& nodes)
776 SMDS_MeshFace *anElem = SMDS_Mesh::AddQuadPolygonalFace(nodes);
778 int i, len = nodes.size();
779 std::vector<int> nodes_ids (len);
780 for (i = 0; i < len; i++) {
781 nodes_ids[i] = nodes[i]->GetID();
783 myScript->AddQuadPolygonalFace(anElem->GetID(), nodes_ids);
789 //=======================================================================
790 //function : AddPolyhedralVolume
792 //=======================================================================
793 SMDS_MeshVolume* SMESHDS_Mesh::AddPolyhedralVolumeWithID (const std::vector<int>& nodes_ids,
794 const std::vector<int>& quantities,
797 SMDS_MeshVolume *anElem = SMDS_Mesh::AddPolyhedralVolumeWithID(nodes_ids, quantities, ID);
799 myScript->AddPolyhedralVolume(ID, nodes_ids, quantities);
804 SMDS_MeshVolume* SMESHDS_Mesh::AddPolyhedralVolumeWithID
805 (const std::vector<const SMDS_MeshNode*>& nodes,
806 const std::vector<int>& quantities,
809 SMDS_MeshVolume *anElem = SMDS_Mesh::AddPolyhedralVolumeWithID(nodes, quantities, ID);
811 int i, len = nodes.size();
812 std::vector<int> nodes_ids (len);
813 for (i = 0; i < len; i++) {
814 nodes_ids[i] = nodes[i]->GetID();
816 myScript->AddPolyhedralVolume(ID, nodes_ids, quantities);
821 SMDS_MeshVolume* SMESHDS_Mesh::AddPolyhedralVolume
822 (const std::vector<const SMDS_MeshNode*>& nodes,
823 const std::vector<int>& quantities)
825 SMDS_MeshVolume *anElem = SMDS_Mesh::AddPolyhedralVolume(nodes, quantities);
827 int i, len = nodes.size();
828 std::vector<int> nodes_ids (len);
829 for (i = 0; i < len; i++) {
830 nodes_ids[i] = nodes[i]->GetID();
832 myScript->AddPolyhedralVolume(anElem->GetID(), nodes_ids, quantities);
837 //=======================================================================
838 //function : removeFromContainers
840 //=======================================================================
842 static void removeFromContainers (SMESHDS_Mesh* theMesh,
843 set<SMESHDS_GroupBase*>& theGroups,
844 list<const SMDS_MeshElement*>& theElems,
847 if ( theElems.empty() )
851 // Element can belong to several groups
852 if ( !theGroups.empty() )
854 set<SMESHDS_GroupBase*>::iterator GrIt = theGroups.begin();
855 for ( ; GrIt != theGroups.end(); GrIt++ )
857 SMESHDS_Group* group = dynamic_cast<SMESHDS_Group*>( *GrIt );
858 if ( !group || group->IsEmpty() ) continue;
860 list<const SMDS_MeshElement *>::iterator elIt = theElems.begin();
861 for ( ; elIt != theElems.end(); elIt++ )
863 group->SMDSGroup().Remove( *elIt );
864 if ( group->IsEmpty() ) break;
869 const bool deleted=true;
871 // Rm from sub-meshes
872 // Element should belong to only one sub-mesh
873 if ( theMesh->SubMeshes()->more() )
875 list<const SMDS_MeshElement *>::iterator elIt = theElems.begin();
877 for ( ; elIt != theElems.end(); ++elIt )
878 if ( SMESHDS_SubMesh* sm = theMesh->MeshElements( (*elIt)->getshapeId() ))
879 sm->RemoveNode( static_cast<const SMDS_MeshNode*> (*elIt), deleted );
882 for ( ; elIt != theElems.end(); ++elIt )
883 if ( SMESHDS_SubMesh* sm = theMesh->MeshElements( (*elIt)->getshapeId() ))
884 sm->RemoveElement( *elIt, deleted );
889 //=======================================================================
890 //function : RemoveNode
892 //=======================================================================
893 void SMESHDS_Mesh::RemoveNode(const SMDS_MeshNode * n)
895 if ( n->NbInverseElements() == 0 && !(hasConstructionEdges() || hasConstructionFaces()))
897 RemoveFreeNode( n, 0, true );
901 myScript->RemoveNode(n->GetID());
903 list<const SMDS_MeshElement *> removedElems;
904 list<const SMDS_MeshElement *> removedNodes;
906 SMDS_Mesh::RemoveElement( n, removedElems, removedNodes, true );
908 removeFromContainers( this, myGroups, removedElems, false );
909 removeFromContainers( this, myGroups, removedNodes, true );
912 //=======================================================================
913 //function : RemoveFreeNode
915 //=======================================================================
916 void SMESHDS_Mesh::RemoveFreeNode(const SMDS_MeshNode * n,
917 SMESHDS_SubMesh * subMesh,
920 myScript->RemoveNode(n->GetID());
923 // Node can belong to several groups
924 if (fromGroups && !myGroups.empty()) {
925 set<SMESHDS_GroupBase*>::iterator GrIt = myGroups.begin();
926 for (; GrIt != myGroups.end(); GrIt++) {
927 SMESHDS_Group* group = dynamic_cast<SMESHDS_Group*>(*GrIt);
928 if (group && !group->IsEmpty())
929 group->SMDSGroup().Remove(n);
934 // Node should belong to only one sub-mesh
935 if ( !subMesh || !subMesh->RemoveNode(n,/*deleted=*/false))
936 if (( subMesh = MeshElements( n->getshapeId() )))
937 subMesh->RemoveNode(n,/*deleted=*/false );
939 SMDS_Mesh::RemoveFreeElement(n);
942 //=======================================================================
943 //function : RemoveElement
945 //========================================================================
946 void SMESHDS_Mesh::RemoveElement(const SMDS_MeshElement * elt)
948 if (elt->GetType() == SMDSAbs_Node)
950 RemoveNode( static_cast<const SMDS_MeshNode*>( elt ));
953 if (!hasConstructionEdges() && !hasConstructionFaces())
955 SMESHDS_SubMesh* subMesh=0;
956 if ( elt->getshapeId() > 0 )
957 subMesh = MeshElements( elt->getshapeId() );
959 RemoveFreeElement( elt, subMesh, true );
963 myScript->RemoveElement(elt->GetID());
965 list<const SMDS_MeshElement *> removedElems;
966 list<const SMDS_MeshElement *> removedNodes;
968 SMDS_Mesh::RemoveElement(elt, removedElems, removedNodes, false );
970 removeFromContainers( this, myGroups, removedElems, false );
973 //=======================================================================
974 //function : RemoveFreeElement
976 //========================================================================
977 void SMESHDS_Mesh::RemoveFreeElement(const SMDS_MeshElement * elt,
978 SMESHDS_SubMesh * subMesh,
981 //MESSAGE(" --------------------------------> SMESHDS_Mesh::RemoveFreeElement " << subMesh << " " << fromGroups);
982 if (elt->GetType() == SMDSAbs_Node) {
983 RemoveFreeNode( static_cast<const SMDS_MeshNode*>(elt), subMesh, fromGroups);
987 if (hasConstructionEdges() || hasConstructionFaces())
988 // this methods is only for meshes without descendants
991 myScript->RemoveElement(elt->GetID());
994 // Element can belong to several groups
995 if ( fromGroups && !myGroups.empty() ) {
996 set<SMESHDS_GroupBase*>::iterator GrIt = myGroups.begin();
997 for (; GrIt != myGroups.end(); GrIt++) {
998 SMESHDS_Group* group = dynamic_cast<SMESHDS_Group*>(*GrIt);
999 if (group && !group->IsEmpty())
1000 group->SMDSGroup().Remove(elt);
1005 // Element should belong to only one sub-mesh
1006 if ( !subMesh && elt->getshapeId() > 0 )
1007 subMesh = MeshElements( elt->getshapeId() );
1009 subMesh->RemoveElement( elt, /*deleted=*/false );
1011 SMDS_Mesh::RemoveFreeElement( elt );
1014 //================================================================================
1016 * \brief Remove all data from the mesh
1018 //================================================================================
1020 void SMESHDS_Mesh::ClearMesh()
1022 myScript->ClearMesh();
1026 SMESHDS_SubMeshIteratorPtr smIt = SubMeshes();
1027 while ( SMESHDS_SubMesh* sm = const_cast< SMESHDS_SubMesh* >( smIt->next() ))
1031 TGroups::iterator group, groupEnd = myGroups.end();
1032 for ( group = myGroups.begin(); group != groupEnd; ++group ) {
1033 if ( SMESHDS_Group* g = dynamic_cast<SMESHDS_Group*>(*group)) {
1034 SMDSAbs_ElementType groupType = g->GetType();
1036 g->SetType( groupType );
1040 (*group)->Extent(); // to free cashed elements in GroupOnFilter's
1045 //================================================================================
1047 * \brief return submesh by shape
1048 * \param shape - the sub-shape
1049 * \retval SMESHDS_SubMesh* - the found submesh
1051 //================================================================================
1053 SMESHDS_SubMesh* SMESHDS_Mesh::getSubmesh( const TopoDS_Shape & shape )
1055 if ( shape.IsNull() )
1058 return NewSubMesh( ShapeToIndex( shape ));
1061 //================================================================================
1063 * \brief Add element or node to submesh
1064 * \param elem - element to add
1065 * \param subMesh - submesh to be filled in
1067 //================================================================================
1069 bool SMESHDS_Mesh::add(const SMDS_MeshElement* elem, SMESHDS_SubMesh* subMesh )
1071 if ( elem && subMesh ) {
1072 if ( elem->GetType() == SMDSAbs_Node )
1073 subMesh->AddNode( static_cast<const SMDS_MeshNode* >( elem ));
1075 subMesh->AddElement( elem );
1081 //=======================================================================
1082 //function : SetNodeOnVolume
1084 //=======================================================================
1085 void SMESHDS_Mesh::SetNodeInVolume(const SMDS_MeshNode* aNode,
1086 const TopoDS_Shell & S)
1088 if ( add( aNode, getSubmesh(S) ))
1089 const_cast< SMDS_MeshNode* >
1090 ( aNode )->SetPosition( SMDS_SpacePosition::originSpacePosition() );
1093 //=======================================================================
1094 //function : SetNodeOnVolume
1096 //=======================================================================
1097 void SMESHDS_Mesh::SetNodeInVolume(const SMDS_MeshNode * aNode,
1098 const TopoDS_Solid & S)
1100 if ( add( aNode, getSubmesh(S) ))
1101 const_cast< SMDS_MeshNode* >
1102 ( aNode )->SetPosition( SMDS_SpacePosition::originSpacePosition() );
1105 //=======================================================================
1106 //function : SetNodeOnFace
1108 //=======================================================================
1109 void SMESHDS_Mesh::SetNodeOnFace(const SMDS_MeshNode * aNode,
1110 const TopoDS_Face & S,
1114 if ( add( aNode, getSubmesh(S) ))
1115 const_cast< SMDS_MeshNode* >
1116 ( aNode )->SetPosition(SMDS_PositionPtr(new SMDS_FacePosition( u, v)));
1119 //=======================================================================
1120 //function : SetNodeOnEdge
1122 //=======================================================================
1123 void SMESHDS_Mesh::SetNodeOnEdge(const SMDS_MeshNode * aNode,
1124 const TopoDS_Edge & S,
1127 if ( add( aNode, getSubmesh(S) ))
1128 const_cast< SMDS_MeshNode* >
1129 ( aNode )->SetPosition(SMDS_PositionPtr(new SMDS_EdgePosition(u)));
1132 //=======================================================================
1133 //function : SetNodeOnVertex
1135 //=======================================================================
1136 void SMESHDS_Mesh::SetNodeOnVertex(const SMDS_MeshNode * aNode,
1137 const TopoDS_Vertex & S)
1139 if ( add( aNode, getSubmesh(S) ))
1140 const_cast< SMDS_MeshNode* >
1141 ( aNode )->SetPosition(SMDS_PositionPtr(new SMDS_VertexPosition()));
1144 //=======================================================================
1145 //function : UnSetNodeOnShape
1147 //=======================================================================
1148 void SMESHDS_Mesh::UnSetNodeOnShape(const SMDS_MeshNode* aNode)
1150 int shapeId = aNode->getshapeId();
1152 if ( SMESHDS_SubMesh* sm = MeshElements( shapeId ))
1153 sm->RemoveNode(aNode, /*deleted=*/false);
1156 //=======================================================================
1157 //function : SetMeshElementOnShape
1159 //=======================================================================
1160 void SMESHDS_Mesh::SetMeshElementOnShape(const SMDS_MeshElement * anElement,
1161 const TopoDS_Shape & S)
1163 add( anElement, getSubmesh(S) );
1166 //=======================================================================
1167 //function : UnSetMeshElementOnShape
1169 //=======================================================================
1170 void SMESHDS_Mesh::UnSetMeshElementOnShape(const SMDS_MeshElement * elem,
1171 const TopoDS_Shape & S)
1173 if ( SMESHDS_SubMesh* sm = MeshElements( S ))
1175 if (elem->GetType() == SMDSAbs_Node)
1176 sm->RemoveNode(static_cast<const SMDS_MeshNode*> (elem), /*deleted=*/false);
1178 sm->RemoveElement(elem, /*deleted=*/false);
1182 //=======================================================================
1183 //function : ShapeToMesh
1185 //=======================================================================
1186 TopoDS_Shape SMESHDS_Mesh::ShapeToMesh() const
1191 //=======================================================================
1192 //function : IsGroupOfSubShapes
1193 //purpose : return true if at least one sub-shape of theShape is a sub-shape
1194 // of myShape or theShape == myShape
1195 //=======================================================================
1197 bool SMESHDS_Mesh::IsGroupOfSubShapes (const TopoDS_Shape& theShape) const
1199 if ( myIndexToShape.Contains(theShape) )
1202 for ( TopoDS_Iterator it( theShape ); it.More(); it.Next() )
1203 if (IsGroupOfSubShapes( it.Value() ))
1209 ///////////////////////////////////////////////////////////////////////////////
1210 /// Return the sub mesh linked to the a given TopoDS_Shape or NULL if the given
1211 /// TopoDS_Shape is unknown
1212 ///////////////////////////////////////////////////////////////////////////////
1213 SMESHDS_SubMesh * SMESHDS_Mesh::MeshElements(const TopoDS_Shape & S) const
1215 int Index = ShapeToIndex(S);
1216 return (SMESHDS_SubMesh *) ( Index ? mySubMeshHolder->Get( Index ) : 0 );
1219 ///////////////////////////////////////////////////////////////////////////////
1220 /// Return the sub mesh by Id of shape it is linked to
1221 ///////////////////////////////////////////////////////////////////////////////
1222 SMESHDS_SubMesh * SMESHDS_Mesh::MeshElements(const int Index) const
1224 return const_cast< SMESHDS_SubMesh* >( mySubMeshHolder->Get( Index ));
1227 //=======================================================================
1228 //function : SubMeshIndices
1230 //=======================================================================
1231 list<int> SMESHDS_Mesh::SubMeshIndices() const
1233 list<int> anIndices;
1234 SMESHDS_SubMeshIteratorPtr smIt = SubMeshes();
1235 while ( const SMESHDS_SubMesh* sm = smIt->next() )
1236 anIndices.push_back( sm->GetID() );
1241 //=======================================================================
1242 //function : SubMeshes
1244 //=======================================================================
1246 SMESHDS_SubMeshIteratorPtr SMESHDS_Mesh::SubMeshes() const
1248 return SMESHDS_SubMeshIteratorPtr( mySubMeshHolder->GetIterator() );
1251 //=======================================================================
1252 //function : GetHypothesis
1254 //=======================================================================
1256 const list<const SMESHDS_Hypothesis*>&
1257 SMESHDS_Mesh::GetHypothesis(const TopoDS_Shape & S) const
1259 if ( myShapeToHypothesis.IsBound( S/*.Oriented(TopAbs_FORWARD)*/ ) ) // ignore orientation of S
1260 return myShapeToHypothesis.Find( S/*.Oriented(TopAbs_FORWARD)*/ );
1262 static list<const SMESHDS_Hypothesis*> empty;
1266 //================================================================================
1268 * \brief returns true if the hypothesis is assigned to any sub-shape
1270 //================================================================================
1272 bool SMESHDS_Mesh::IsUsedHypothesis(const SMESHDS_Hypothesis * H) const
1274 ShapeToHypothesis::Iterator s2h( myShapeToHypothesis );
1275 for ( ; s2h.More(); s2h.Next() )
1276 if ( std::find( s2h.Value().begin(), s2h.Value().end(), H ) != s2h.Value().end() )
1281 //=======================================================================
1282 //function : GetScript
1284 //=======================================================================
1285 SMESHDS_Script* SMESHDS_Mesh::GetScript()
1290 //=======================================================================
1291 //function : ClearScript
1293 //=======================================================================
1294 void SMESHDS_Mesh::ClearScript()
1299 //=======================================================================
1300 //function : HasMeshElements
1302 //=======================================================================
1303 bool SMESHDS_Mesh::HasMeshElements(const TopoDS_Shape & S) const
1305 int Index = myIndexToShape.FindIndex(S);
1306 return mySubMeshHolder->Get( Index );
1309 //=======================================================================
1310 //function : HasHypothesis
1312 //=======================================================================
1313 bool SMESHDS_Mesh::HasHypothesis(const TopoDS_Shape & S)
1315 return myShapeToHypothesis.IsBound(S/*.Oriented(TopAbs_FORWARD)*/);
1318 //=======================================================================
1319 //function : NewSubMesh
1321 //=======================================================================
1322 SMESHDS_SubMesh * SMESHDS_Mesh::NewSubMesh(int Index)
1324 SMESHDS_SubMesh* SM = MeshElements( Index );
1327 SM = new SMESHDS_SubMesh(this, Index);
1328 mySubMeshHolder->Add( Index, SM );
1333 //=======================================================================
1334 //function : AddCompoundSubmesh
1336 //=======================================================================
1338 int SMESHDS_Mesh::AddCompoundSubmesh(const TopoDS_Shape& S,
1339 TopAbs_ShapeEnum type)
1342 if ( IsGroupOfSubShapes( S ))
1344 aMainIndex = myIndexToShape.Add( S );
1345 bool all = ( type == TopAbs_SHAPE );
1346 if ( all ) // corresponding simple submesh may exist
1347 aMainIndex = -aMainIndex;
1348 //MESSAGE("AddCompoundSubmesh index = " << aMainIndex );
1349 SMESHDS_SubMesh * aNewSub = NewSubMesh( aMainIndex );
1350 if ( !aNewSub->IsComplexSubmesh() ) // is empty
1352 int shapeType = Max( TopAbs_SOLID, all ? myShape.ShapeType() : type );
1353 int typeLimit = all ? TopAbs_VERTEX : type;
1354 for ( ; shapeType <= typeLimit; shapeType++ )
1356 TopExp_Explorer exp( S, TopAbs_ShapeEnum( shapeType ));
1357 for ( ; exp.More(); exp.Next() )
1359 int index = myIndexToShape.FindIndex( exp.Current() );
1361 aNewSub->AddSubMesh( NewSubMesh( index ));
1369 //=======================================================================
1370 //function : IndexToShape
1372 //=======================================================================
1373 const TopoDS_Shape& SMESHDS_Mesh::IndexToShape(int ShapeIndex) const
1377 if ( ShapeIndex > 0 )
1378 return myIndexToShape.FindKey(ShapeIndex);
1380 catch ( Standard_OutOfRange )
1383 static TopoDS_Shape nullShape;
1387 //================================================================================
1389 * \brief Return max index of sub-mesh
1391 //================================================================================
1393 int SMESHDS_Mesh::MaxSubMeshIndex() const
1395 return mySubMeshHolder->GetMaxID();
1398 //=======================================================================
1399 //function : ShapeToIndex
1401 //=======================================================================
1402 int SMESHDS_Mesh::ShapeToIndex(const TopoDS_Shape & S) const
1404 if (myShape.IsNull())
1405 MESSAGE("myShape is NULL");
1407 int index = myIndexToShape.FindIndex(S);
1412 //=======================================================================
1413 //function : SetNodeOnVolume
1415 //=======================================================================
1416 void SMESHDS_Mesh::SetNodeInVolume(const SMDS_MeshNode* aNode, int Index)
1418 if ( add( aNode, NewSubMesh( Index )))
1419 ((SMDS_MeshNode*) aNode)->SetPosition( SMDS_SpacePosition::originSpacePosition());
1422 //=======================================================================
1423 //function : SetNodeOnFace
1425 //=======================================================================
1426 void SMESHDS_Mesh::SetNodeOnFace(const SMDS_MeshNode* aNode, int Index, double u, double v)
1428 //Set Position on Node
1429 if ( add( aNode, NewSubMesh( Index )))
1430 const_cast< SMDS_MeshNode* >
1431 ( aNode )->SetPosition(SMDS_PositionPtr(new SMDS_FacePosition( u, v)));
1434 //=======================================================================
1435 //function : SetNodeOnEdge
1437 //=======================================================================
1438 void SMESHDS_Mesh::SetNodeOnEdge(const SMDS_MeshNode* aNode,
1442 //Set Position on Node
1443 if ( add( aNode, NewSubMesh( Index )))
1444 const_cast< SMDS_MeshNode* >
1445 ( aNode )->SetPosition(SMDS_PositionPtr(new SMDS_EdgePosition(u)));
1448 //=======================================================================
1449 //function : SetNodeOnVertex
1451 //=======================================================================
1452 void SMESHDS_Mesh::SetNodeOnVertex(const SMDS_MeshNode* aNode, int Index)
1454 //Set Position on Node
1455 if ( add( aNode, NewSubMesh( Index )))
1456 const_cast< SMDS_MeshNode* >
1457 ( aNode )->SetPosition(SMDS_PositionPtr(new SMDS_VertexPosition()));
1460 //=======================================================================
1461 //function : SetMeshElementOnShape
1463 //=======================================================================
1464 void SMESHDS_Mesh::SetMeshElementOnShape(const SMDS_MeshElement* anElement,
1467 add( anElement, NewSubMesh( Index ));
1470 //=======================================================================
1471 //function : ~SMESHDS_Mesh
1473 //=======================================================================
1474 SMESHDS_Mesh::~SMESHDS_Mesh()
1479 delete mySubMeshHolder;
1483 //********************************************************************
1484 //********************************************************************
1485 //******** *********
1486 //***** Methods for addition of quadratic elements ******
1487 //******** *********
1488 //********************************************************************
1489 //********************************************************************
1491 //=======================================================================
1492 //function : AddEdgeWithID
1494 //=======================================================================
1495 SMDS_MeshEdge* SMESHDS_Mesh::AddEdgeWithID(int n1, int n2, int n12, int ID)
1497 SMDS_MeshEdge* anElem = SMDS_Mesh::AddEdgeWithID(n1,n2,n12,ID);
1498 if(anElem) myScript->AddEdge(ID,n1,n2,n12);
1502 //=======================================================================
1503 //function : AddEdge
1505 //=======================================================================
1506 SMDS_MeshEdge* SMESHDS_Mesh::AddEdge(const SMDS_MeshNode* n1,
1507 const SMDS_MeshNode* n2,
1508 const SMDS_MeshNode* n12)
1510 SMDS_MeshEdge* anElem = SMDS_Mesh::AddEdge(n1,n2,n12);
1511 if(anElem) myScript->AddEdge(anElem->GetID(),
1518 //=======================================================================
1519 //function : AddEdgeWithID
1521 //=======================================================================
1522 SMDS_MeshEdge* SMESHDS_Mesh::AddEdgeWithID(const SMDS_MeshNode * n1,
1523 const SMDS_MeshNode * n2,
1524 const SMDS_MeshNode * n12,
1527 return AddEdgeWithID(n1->GetID(),
1534 //=======================================================================
1535 //function : AddFace
1537 //=======================================================================
1538 SMDS_MeshFace* SMESHDS_Mesh::AddFace(const SMDS_MeshNode * n1,
1539 const SMDS_MeshNode * n2,
1540 const SMDS_MeshNode * n3,
1541 const SMDS_MeshNode * n12,
1542 const SMDS_MeshNode * n23,
1543 const SMDS_MeshNode * n31)
1545 SMDS_MeshFace *anElem = SMDS_Mesh::AddFace(n1,n2,n3,n12,n23,n31);
1546 if(anElem) myScript->AddFace(anElem->GetID(),
1547 n1->GetID(), n2->GetID(), n3->GetID(),
1548 n12->GetID(), n23->GetID(), n31->GetID());
1552 //=======================================================================
1553 //function : AddFaceWithID
1555 //=======================================================================
1556 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(int n1, int n2, int n3,
1557 int n12,int n23,int n31, int ID)
1559 SMDS_MeshFace *anElem = SMDS_Mesh::AddFaceWithID(n1,n2,n3,n12,n23,n31,ID);
1560 if(anElem) myScript->AddFace(ID,n1,n2,n3,n12,n23,n31);
1564 //=======================================================================
1565 //function : AddFaceWithID
1567 //=======================================================================
1568 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(const SMDS_MeshNode * n1,
1569 const SMDS_MeshNode * n2,
1570 const SMDS_MeshNode * n3,
1571 const SMDS_MeshNode * n12,
1572 const SMDS_MeshNode * n23,
1573 const SMDS_MeshNode * n31,
1576 return AddFaceWithID(n1->GetID(), n2->GetID(), n3->GetID(),
1577 n12->GetID(), n23->GetID(), n31->GetID(),
1581 //=======================================================================
1582 //function : AddFace
1584 //=======================================================================
1585 SMDS_MeshFace* SMESHDS_Mesh::AddFace(const SMDS_MeshNode * n1,
1586 const SMDS_MeshNode * n2,
1587 const SMDS_MeshNode * n3,
1588 const SMDS_MeshNode * n12,
1589 const SMDS_MeshNode * n23,
1590 const SMDS_MeshNode * n31,
1591 const SMDS_MeshNode * nCenter)
1593 SMDS_MeshFace *anElem = SMDS_Mesh::AddFace(n1,n2,n3,n12,n23,n31,nCenter);
1594 if(anElem) myScript->AddFace(anElem->GetID(),
1595 n1->GetID(), n2->GetID(), n3->GetID(),
1596 n12->GetID(), n23->GetID(), n31->GetID(),
1601 //=======================================================================
1602 //function : AddFaceWithID
1604 //=======================================================================
1605 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(int n1, int n2, int n3,
1606 int n12,int n23,int n31, int nCenter, int ID)
1608 SMDS_MeshFace *anElem = SMDS_Mesh::AddFaceWithID(n1,n2,n3,n12,n23,n31,nCenter,ID);
1609 if(anElem) myScript->AddFace(ID,n1,n2,n3,n12,n23,n31,nCenter);
1613 //=======================================================================
1614 //function : AddFaceWithID
1616 //=======================================================================
1617 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(const SMDS_MeshNode * n1,
1618 const SMDS_MeshNode * n2,
1619 const SMDS_MeshNode * n3,
1620 const SMDS_MeshNode * n12,
1621 const SMDS_MeshNode * n23,
1622 const SMDS_MeshNode * n31,
1623 const SMDS_MeshNode * nCenter,
1626 return AddFaceWithID(n1->GetID(), n2->GetID(), n3->GetID(),
1627 n12->GetID(), n23->GetID(), n31->GetID(),
1628 nCenter->GetID(), ID);
1632 //=======================================================================
1633 //function : AddFace
1635 //=======================================================================
1636 SMDS_MeshFace* SMESHDS_Mesh::AddFace(const SMDS_MeshNode * n1,
1637 const SMDS_MeshNode * n2,
1638 const SMDS_MeshNode * n3,
1639 const SMDS_MeshNode * n4,
1640 const SMDS_MeshNode * n12,
1641 const SMDS_MeshNode * n23,
1642 const SMDS_MeshNode * n34,
1643 const SMDS_MeshNode * n41)
1645 SMDS_MeshFace *anElem = SMDS_Mesh::AddFace(n1,n2,n3,n4,n12,n23,n34,n41);
1646 if(anElem) myScript->AddFace(anElem->GetID(),
1647 n1->GetID(), n2->GetID(), n3->GetID(), n4->GetID(),
1648 n12->GetID(), n23->GetID(), n34->GetID(), n41->GetID());
1652 //=======================================================================
1653 //function : AddFaceWithID
1655 //=======================================================================
1656 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(int n1, int n2, int n3, int n4,
1657 int n12,int n23,int n34,int n41, int ID)
1659 SMDS_MeshFace *anElem = SMDS_Mesh::AddFaceWithID(n1,n2,n3,n4,n12,n23,n34,n41,ID);
1660 if(anElem) myScript->AddFace(ID,n1,n2,n3,n4,n12,n23,n34,n41);
1664 //=======================================================================
1665 //function : AddFaceWithID
1667 //=======================================================================
1668 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(const SMDS_MeshNode * n1,
1669 const SMDS_MeshNode * n2,
1670 const SMDS_MeshNode * n3,
1671 const SMDS_MeshNode * n4,
1672 const SMDS_MeshNode * n12,
1673 const SMDS_MeshNode * n23,
1674 const SMDS_MeshNode * n34,
1675 const SMDS_MeshNode * n41,
1678 return AddFaceWithID(n1->GetID(), n2->GetID(), n3->GetID(), n4->GetID(),
1679 n12->GetID(), n23->GetID(), n34->GetID(), n41->GetID(),
1684 //=======================================================================
1685 //function : AddFace
1687 //=======================================================================
1688 SMDS_MeshFace* SMESHDS_Mesh::AddFace(const SMDS_MeshNode * n1,
1689 const SMDS_MeshNode * n2,
1690 const SMDS_MeshNode * n3,
1691 const SMDS_MeshNode * n4,
1692 const SMDS_MeshNode * n12,
1693 const SMDS_MeshNode * n23,
1694 const SMDS_MeshNode * n34,
1695 const SMDS_MeshNode * n41,
1696 const SMDS_MeshNode * nCenter)
1698 SMDS_MeshFace *anElem = SMDS_Mesh::AddFace(n1,n2,n3,n4,n12,n23,n34,n41,nCenter);
1699 if(anElem) myScript->AddFace(anElem->GetID(),
1700 n1->GetID(), n2->GetID(), n3->GetID(), n4->GetID(),
1701 n12->GetID(), n23->GetID(), n34->GetID(), n41->GetID(),
1706 //=======================================================================
1707 //function : AddFaceWithID
1709 //=======================================================================
1710 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(int n1, int n2, int n3, int n4,
1711 int n12,int n23,int n34,int n41,
1712 int nCenter, int ID)
1714 SMDS_MeshFace *anElem = SMDS_Mesh::AddFaceWithID(n1,n2,n3,n4,n12,n23,n34,n41,nCenter,ID);
1715 if(anElem) myScript->AddFace(ID,n1,n2,n3,n4,n12,n23,n34,n41,nCenter);
1719 //=======================================================================
1720 //function : AddFaceWithID
1722 //=======================================================================
1723 SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(const SMDS_MeshNode * n1,
1724 const SMDS_MeshNode * n2,
1725 const SMDS_MeshNode * n3,
1726 const SMDS_MeshNode * n4,
1727 const SMDS_MeshNode * n12,
1728 const SMDS_MeshNode * n23,
1729 const SMDS_MeshNode * n34,
1730 const SMDS_MeshNode * n41,
1731 const SMDS_MeshNode * nCenter,
1734 return AddFaceWithID(n1->GetID(), n2->GetID(), n3->GetID(), n4->GetID(),
1735 n12->GetID(), n23->GetID(), n34->GetID(), n41->GetID(),
1736 nCenter->GetID(), ID);
1740 //=======================================================================
1741 //function : AddVolume
1743 //=======================================================================
1744 SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
1745 const SMDS_MeshNode * n2,
1746 const SMDS_MeshNode * n3,
1747 const SMDS_MeshNode * n4,
1748 const SMDS_MeshNode * n12,
1749 const SMDS_MeshNode * n23,
1750 const SMDS_MeshNode * n31,
1751 const SMDS_MeshNode * n14,
1752 const SMDS_MeshNode * n24,
1753 const SMDS_MeshNode * n34)
1755 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1,n2,n3,n4,n12,n23,n31,n14,n24,n34);
1756 if(anElem) myScript->AddVolume(anElem->GetID(),
1757 n1->GetID(), n2->GetID(), n3->GetID(), n4->GetID(),
1758 n12->GetID(), n23->GetID(), n31->GetID(),
1759 n14->GetID(), n24->GetID(), n34->GetID());
1763 //=======================================================================
1764 //function : AddVolumeWithID
1766 //=======================================================================
1767 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3, int n4,
1768 int n12,int n23,int n31,
1769 int n14,int n24,int n34, int ID)
1771 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolumeWithID(n1,n2,n3,n4,n12,n23,
1772 n31,n14,n24,n34,ID);
1773 if(anElem) myScript->AddVolume(ID,n1,n2,n3,n4,n12,n23,n31,n14,n24,n34);
1777 //=======================================================================
1778 //function : AddVolumeWithID
1779 //purpose : 2d order tetrahedron of 10 nodes
1780 //=======================================================================
1781 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
1782 const SMDS_MeshNode * n2,
1783 const SMDS_MeshNode * n3,
1784 const SMDS_MeshNode * n4,
1785 const SMDS_MeshNode * n12,
1786 const SMDS_MeshNode * n23,
1787 const SMDS_MeshNode * n31,
1788 const SMDS_MeshNode * n14,
1789 const SMDS_MeshNode * n24,
1790 const SMDS_MeshNode * n34,
1793 return AddVolumeWithID(n1->GetID(), n2->GetID(), n3->GetID(), n4->GetID(),
1794 n12->GetID(), n23->GetID(), n31->GetID(),
1795 n14->GetID(), n24->GetID(), n34->GetID(), ID);
1799 //=======================================================================
1800 //function : AddVolume
1802 //=======================================================================
1803 SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
1804 const SMDS_MeshNode * n2,
1805 const SMDS_MeshNode * n3,
1806 const SMDS_MeshNode * n4,
1807 const SMDS_MeshNode * n5,
1808 const SMDS_MeshNode * n12,
1809 const SMDS_MeshNode * n23,
1810 const SMDS_MeshNode * n34,
1811 const SMDS_MeshNode * n41,
1812 const SMDS_MeshNode * n15,
1813 const SMDS_MeshNode * n25,
1814 const SMDS_MeshNode * n35,
1815 const SMDS_MeshNode * n45)
1817 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1,n2,n3,n4,n5,n12,n23,n34,n41,
1820 myScript->AddVolume(anElem->GetID(), n1->GetID(), n2->GetID(),
1821 n3->GetID(), n4->GetID(), n5->GetID(),
1822 n12->GetID(), n23->GetID(), n34->GetID(), n41->GetID(),
1823 n15->GetID(), n25->GetID(), n35->GetID(), n45->GetID());
1827 //=======================================================================
1828 //function : AddVolumeWithID
1830 //=======================================================================
1831 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3, int n4, int n5,
1832 int n12,int n23,int n34,int n41,
1833 int n15,int n25,int n35,int n45, int ID)
1835 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolumeWithID(n1,n2,n3,n4,n5,
1837 n15,n25,n35,n45,ID);
1838 if(anElem) myScript->AddVolume(ID,n1,n2,n3,n4,n5,n12,n23,n34,n41,
1843 //=======================================================================
1844 //function : AddVolumeWithID
1845 //purpose : 2d order pyramid of 13 nodes
1846 //=======================================================================
1847 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
1848 const SMDS_MeshNode * n2,
1849 const SMDS_MeshNode * n3,
1850 const SMDS_MeshNode * n4,
1851 const SMDS_MeshNode * n5,
1852 const SMDS_MeshNode * n12,
1853 const SMDS_MeshNode * n23,
1854 const SMDS_MeshNode * n34,
1855 const SMDS_MeshNode * n41,
1856 const SMDS_MeshNode * n15,
1857 const SMDS_MeshNode * n25,
1858 const SMDS_MeshNode * n35,
1859 const SMDS_MeshNode * n45,
1862 return AddVolumeWithID(n1->GetID(), n2->GetID(), n3->GetID(),
1863 n4->GetID(), n5->GetID(),
1864 n12->GetID(), n23->GetID(), n34->GetID(), n41->GetID(),
1865 n15->GetID(), n25->GetID(), n35->GetID(), n45->GetID(),
1870 //=======================================================================
1871 //function : AddVolume
1873 //=======================================================================
1874 SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
1875 const SMDS_MeshNode * n2,
1876 const SMDS_MeshNode * n3,
1877 const SMDS_MeshNode * n4,
1878 const SMDS_MeshNode * n5,
1879 const SMDS_MeshNode * n6,
1880 const SMDS_MeshNode * n12,
1881 const SMDS_MeshNode * n23,
1882 const SMDS_MeshNode * n31,
1883 const SMDS_MeshNode * n45,
1884 const SMDS_MeshNode * n56,
1885 const SMDS_MeshNode * n64,
1886 const SMDS_MeshNode * n14,
1887 const SMDS_MeshNode * n25,
1888 const SMDS_MeshNode * n36)
1890 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1,n2,n3,n4,n5,n6,n12,n23,n31,
1891 n45,n56,n64,n14,n25,n36);
1893 myScript->AddVolume(anElem->GetID(), n1->GetID(), n2->GetID(),
1894 n3->GetID(), n4->GetID(), n5->GetID(), n6->GetID(),
1895 n12->GetID(), n23->GetID(), n31->GetID(),
1896 n45->GetID(), n56->GetID(), n64->GetID(),
1897 n14->GetID(), n25->GetID(), n36->GetID());
1901 //=======================================================================
1902 //function : AddVolumeWithID
1904 //=======================================================================
1905 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3,
1906 int n4, int n5, int n6,
1907 int n12,int n23,int n31,
1908 int n45,int n56,int n64,
1909 int n14,int n25,int n36, int ID)
1911 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolumeWithID(n1,n2,n3,n4,n5,n6,
1915 if(anElem) myScript->AddVolume(ID,n1,n2,n3,n4,n5,n6,n12,n23,n31,
1916 n45,n56,n64,n14,n25,n36);
1920 //=======================================================================
1921 //function : AddVolumeWithID
1922 //purpose : 2d order Pentahedron with 15 nodes
1923 //=======================================================================
1924 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
1925 const SMDS_MeshNode * n2,
1926 const SMDS_MeshNode * n3,
1927 const SMDS_MeshNode * n4,
1928 const SMDS_MeshNode * n5,
1929 const SMDS_MeshNode * n6,
1930 const SMDS_MeshNode * n12,
1931 const SMDS_MeshNode * n23,
1932 const SMDS_MeshNode * n31,
1933 const SMDS_MeshNode * n45,
1934 const SMDS_MeshNode * n56,
1935 const SMDS_MeshNode * n64,
1936 const SMDS_MeshNode * n14,
1937 const SMDS_MeshNode * n25,
1938 const SMDS_MeshNode * n36,
1941 return AddVolumeWithID(n1->GetID(), n2->GetID(), n3->GetID(),
1942 n4->GetID(), n5->GetID(), n6->GetID(),
1943 n12->GetID(), n23->GetID(), n31->GetID(),
1944 n45->GetID(), n56->GetID(), n64->GetID(),
1945 n14->GetID(), n25->GetID(), n36->GetID(),
1950 //=======================================================================
1951 //function : AddVolume
1952 //purpose : add quadratic hexahedron
1953 //=======================================================================
1954 SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
1955 const SMDS_MeshNode * n2,
1956 const SMDS_MeshNode * n3,
1957 const SMDS_MeshNode * n4,
1958 const SMDS_MeshNode * n5,
1959 const SMDS_MeshNode * n6,
1960 const SMDS_MeshNode * n7,
1961 const SMDS_MeshNode * n8,
1962 const SMDS_MeshNode * n12,
1963 const SMDS_MeshNode * n23,
1964 const SMDS_MeshNode * n34,
1965 const SMDS_MeshNode * n41,
1966 const SMDS_MeshNode * n56,
1967 const SMDS_MeshNode * n67,
1968 const SMDS_MeshNode * n78,
1969 const SMDS_MeshNode * n85,
1970 const SMDS_MeshNode * n15,
1971 const SMDS_MeshNode * n26,
1972 const SMDS_MeshNode * n37,
1973 const SMDS_MeshNode * n48)
1975 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1,n2,n3,n4,n5,n6,n7,n8,
1980 myScript->AddVolume(anElem->GetID(), n1->GetID(), n2->GetID(),
1981 n3->GetID(), n4->GetID(), n5->GetID(),
1982 n6->GetID(), n7->GetID(), n8->GetID(),
1983 n12->GetID(), n23->GetID(), n34->GetID(), n41->GetID(),
1984 n56->GetID(), n67->GetID(), n78->GetID(), n85->GetID(),
1985 n15->GetID(), n26->GetID(), n37->GetID(), n48->GetID());
1989 //=======================================================================
1990 //function : AddVolumeWithID
1992 //=======================================================================
1993 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3, int n4,
1994 int n5, int n6, int n7, int n8,
1995 int n12,int n23,int n34,int n41,
1996 int n56,int n67,int n78,int n85,
1997 int n15,int n26,int n37,int n48, int ID)
1999 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolumeWithID(n1,n2,n3,n4,n5,n6,n7,n8,
2002 n15,n26,n37,n48,ID);
2003 if(anElem) myScript->AddVolume(ID,n1,n2,n3,n4,n5,n6,n7,n8,n12,n23,n34,n41,
2004 n56,n67,n78,n85,n15,n26,n37,n48);
2008 //=======================================================================
2009 //function : AddVolumeWithID
2010 //purpose : 2d order Hexahedrons with 20 nodes
2011 //=======================================================================
2012 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
2013 const SMDS_MeshNode * n2,
2014 const SMDS_MeshNode * n3,
2015 const SMDS_MeshNode * n4,
2016 const SMDS_MeshNode * n5,
2017 const SMDS_MeshNode * n6,
2018 const SMDS_MeshNode * n7,
2019 const SMDS_MeshNode * n8,
2020 const SMDS_MeshNode * n12,
2021 const SMDS_MeshNode * n23,
2022 const SMDS_MeshNode * n34,
2023 const SMDS_MeshNode * n41,
2024 const SMDS_MeshNode * n56,
2025 const SMDS_MeshNode * n67,
2026 const SMDS_MeshNode * n78,
2027 const SMDS_MeshNode * n85,
2028 const SMDS_MeshNode * n15,
2029 const SMDS_MeshNode * n26,
2030 const SMDS_MeshNode * n37,
2031 const SMDS_MeshNode * n48,
2034 return AddVolumeWithID(n1->GetID(), n2->GetID(), n3->GetID(), n4->GetID(),
2035 n5->GetID(), n6->GetID(), n7->GetID(), n8->GetID(),
2036 n12->GetID(), n23->GetID(), n34->GetID(), n41->GetID(),
2037 n56->GetID(), n67->GetID(), n78->GetID(), n85->GetID(),
2038 n15->GetID(), n26->GetID(), n37->GetID(), n48->GetID(),
2042 //=======================================================================
2043 //function : AddVolume
2044 //purpose : add tri-quadratic hexahedron of 27 nodes
2045 //=======================================================================
2047 SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
2048 const SMDS_MeshNode * n2,
2049 const SMDS_MeshNode * n3,
2050 const SMDS_MeshNode * n4,
2051 const SMDS_MeshNode * n5,
2052 const SMDS_MeshNode * n6,
2053 const SMDS_MeshNode * n7,
2054 const SMDS_MeshNode * n8,
2055 const SMDS_MeshNode * n12,
2056 const SMDS_MeshNode * n23,
2057 const SMDS_MeshNode * n34,
2058 const SMDS_MeshNode * n41,
2059 const SMDS_MeshNode * n56,
2060 const SMDS_MeshNode * n67,
2061 const SMDS_MeshNode * n78,
2062 const SMDS_MeshNode * n85,
2063 const SMDS_MeshNode * n15,
2064 const SMDS_MeshNode * n26,
2065 const SMDS_MeshNode * n37,
2066 const SMDS_MeshNode * n48,
2067 const SMDS_MeshNode * n1234,
2068 const SMDS_MeshNode * n1256,
2069 const SMDS_MeshNode * n2367,
2070 const SMDS_MeshNode * n3478,
2071 const SMDS_MeshNode * n1458,
2072 const SMDS_MeshNode * n5678,
2073 const SMDS_MeshNode * nCenter)
2075 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1,n2,n3,n4,n5,n6,n7,n8,
2079 n1234,n1256,n2367,n3478,n1458,n5678,nCenter);
2081 myScript->AddVolume(anElem->GetID(), n1->GetID(), n2->GetID(),
2082 n3->GetID(), n4->GetID(), n5->GetID(),
2083 n6->GetID(), n7->GetID(), n8->GetID(),
2084 n12->GetID(), n23->GetID(), n34->GetID(), n41->GetID(),
2085 n56->GetID(), n67->GetID(), n78->GetID(), n85->GetID(),
2086 n15->GetID(), n26->GetID(), n37->GetID(), n48->GetID(),
2087 n1234->GetID(),n1256->GetID(),n2367->GetID(),n3478->GetID(),
2088 n1458->GetID(),n5678->GetID(),nCenter->GetID());
2092 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3, int n4,
2093 int n5, int n6, int n7, int n8,
2094 int n12,int n23,int n34,int n41,
2095 int n56,int n67,int n78,int n85,
2096 int n15,int n26,int n37,int n48,
2097 int n1234,int n1256,int n2367,int n3478,
2098 int n1458,int n5678,int nCenter,
2101 SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolumeWithID(n1,n2,n3,n4,n5,n6,n7,n8,
2105 n1234, n1256, n2367, n3478,
2106 n1458, n5678, nCenter,
2108 if(anElem) myScript->AddVolume(ID,n1,n2,n3,n4,n5,n6,n7,n8,n12,n23,n34,n41,
2109 n56,n67,n78,n85,n15,n26,n37,n48,
2110 n1234, n1256, n2367, n3478,
2111 n1458, n5678, nCenter);
2115 SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
2116 const SMDS_MeshNode * n2,
2117 const SMDS_MeshNode * n3,
2118 const SMDS_MeshNode * n4,
2119 const SMDS_MeshNode * n5,
2120 const SMDS_MeshNode * n6,
2121 const SMDS_MeshNode * n7,
2122 const SMDS_MeshNode * n8,
2123 const SMDS_MeshNode * n12,
2124 const SMDS_MeshNode * n23,
2125 const SMDS_MeshNode * n34,
2126 const SMDS_MeshNode * n41,
2127 const SMDS_MeshNode * n56,
2128 const SMDS_MeshNode * n67,
2129 const SMDS_MeshNode * n78,
2130 const SMDS_MeshNode * n85,
2131 const SMDS_MeshNode * n15,
2132 const SMDS_MeshNode * n26,
2133 const SMDS_MeshNode * n37,
2134 const SMDS_MeshNode * n48,
2135 const SMDS_MeshNode * n1234,
2136 const SMDS_MeshNode * n1256,
2137 const SMDS_MeshNode * n2367,
2138 const SMDS_MeshNode * n3478,
2139 const SMDS_MeshNode * n1458,
2140 const SMDS_MeshNode * n5678,
2141 const SMDS_MeshNode * nCenter,
2144 return AddVolumeWithID(n1->GetID(), n2->GetID(), n3->GetID(), n4->GetID(),
2145 n5->GetID(), n6->GetID(), n7->GetID(), n8->GetID(),
2146 n12->GetID(), n23->GetID(), n34->GetID(), n41->GetID(),
2147 n56->GetID(), n67->GetID(), n78->GetID(), n85->GetID(),
2148 n15->GetID(), n26->GetID(), n37->GetID(), n48->GetID(),
2149 n1234->GetID(),n1256->GetID(),n2367->GetID(),n3478->GetID(),
2150 n1458->GetID(),n5678->GetID(),nCenter->GetID(), ID);
2153 void SMESHDS_Mesh::compactMesh()
2155 int newNodeSize = 0;
2156 int nbNodes = myNodes.size();
2157 int nbVtkNodes = myGrid->GetNumberOfPoints();
2158 MESSAGE("nbNodes=" << nbNodes << " nbVtkNodes=" << nbVtkNodes);
2159 int nbNodeTemp = nbVtkNodes;
2160 if (nbNodes > nbVtkNodes)
2161 nbNodeTemp = nbNodes;
2162 vector<int> idNodesOldToNew;
2163 idNodesOldToNew.clear();
2164 idNodesOldToNew.resize(nbNodeTemp, -1); // all unused id will be -1
2166 for (int i = 0; i < nbNodes; i++)
2170 int vtkid = myNodes[i]->getVtkId();
2171 idNodesOldToNew[vtkid] = i; // old vtkId --> old smdsId (valid smdsId are >= 0)
2175 bool areNodesModified = (newNodeSize < nbVtkNodes);
2176 MESSAGE("------------------------- compactMesh Nodes Modified: " << areNodesModified);
2177 areNodesModified = true;
2179 int newCellSize = 0;
2180 int nbCells = myCells.size();
2181 int nbVtkCells = myGrid->GetNumberOfCells();
2182 MESSAGE("nbCells=" << nbCells << " nbVtkCells=" << nbVtkCells);
2183 int nbCellTemp = nbVtkCells;
2184 if (nbCells > nbVtkCells)
2185 nbCellTemp = nbCells;
2186 vector<int> idCellsOldToNew;
2187 idCellsOldToNew.clear();
2188 idCellsOldToNew.resize(nbCellTemp, -1); // all unused id will be -1
2190 for (int i = 0; i < nbCells; i++)
2194 // //idCellsOldToNew[i] = myCellIdVtkToSmds[i]; // valid vtk indexes are > = 0
2195 // int vtkid = myCells[i]->getVtkId();
2196 // idCellsOldToNew[vtkid] = i; // old vtkId --> old smdsId (not used in input)
2200 if (areNodesModified)
2201 myGrid->compactGrid(idNodesOldToNew, newNodeSize, idCellsOldToNew, newCellSize);
2203 myGrid->compactGrid(idNodesOldToNew, 0, idCellsOldToNew, newCellSize);
2205 int nbVtkPts = myGrid->GetNumberOfPoints();
2206 nbVtkCells = myGrid->GetNumberOfCells();
2207 if (nbVtkPts != newNodeSize)
2209 MESSAGE("===> nbVtkPts != newNodeSize " << nbVtkPts << " " << newNodeSize);
2210 if (nbVtkPts > newNodeSize) newNodeSize = nbVtkPts; // several points with same SMDS Id
2212 if (nbVtkCells != newCellSize)
2214 MESSAGE("===> nbVtkCells != newCellSize " << nbVtkCells << " " << newCellSize);
2215 if (nbVtkCells > newCellSize) newCellSize = nbVtkCells; // several cells with same SMDS Id
2218 // --- SMDS_MeshNode and myNodes (id in SMDS and in VTK are the same), myNodeIdFactory
2220 if (areNodesModified)
2222 MESSAGE("-------------- modify myNodes");
2223 SetOfNodes newNodes;
2224 newNodes.resize(newNodeSize+1,0); // 0 not used, SMDS numbers 1..n
2226 for (int i = 0; i < nbNodes; i++)
2230 newSmdsId++; // SMDS id start to 1
2231 int oldVtkId = myNodes[i]->getVtkId();
2232 int newVtkId = idNodesOldToNew[oldVtkId];
2233 //MESSAGE("myNodes["<< i << "] vtkId " << oldVtkId << " --> " << newVtkId);
2234 myNodes[i]->setVtkId(newVtkId);
2235 myNodes[i]->setId(newSmdsId);
2236 newNodes[newSmdsId] = myNodes[i];
2237 //MESSAGE("myNodes["<< i << "] --> newNodes[" << newSmdsId << "]");
2240 myNodes.swap(newNodes);
2241 this->myNodeIDFactory->emptyPool(newSmdsId); // newSmdsId = number of nodes
2242 MESSAGE("myNodes.size " << myNodes.size());
2245 // --- SMDS_MeshCell, myCellIdVtkToSmds, myCellIdSmdsToVtk, myCells
2247 int vtkIndexSize = myCellIdVtkToSmds.size();
2249 for (int oldVtkId = 0; oldVtkId < vtkIndexSize; oldVtkId++)
2251 int oldSmdsId = this->myCellIdVtkToSmds[oldVtkId];
2254 int newVtkId = idCellsOldToNew[oldVtkId];
2255 if (newVtkId > maxVtkId)
2256 maxVtkId = newVtkId;
2257 //MESSAGE("myCells["<< oldSmdsId << "] vtkId " << oldVtkId << " --> " << newVtkId);
2258 myCells[oldSmdsId]->setVtkId(newVtkId);
2261 // MESSAGE("myCells.size()=" << myCells.size()
2262 // << " myCellIdSmdsToVtk.size()=" << myCellIdSmdsToVtk.size()
2263 // << " myCellIdVtkToSmds.size()=" << myCellIdVtkToSmds.size() );
2265 SetOfCells newCells;
2266 //vector<int> newSmdsToVtk;
2267 vector<int> newVtkToSmds;
2269 assert(maxVtkId < newCellSize);
2270 newCells.resize(newCellSize+1, 0); // 0 not used, SMDS numbers 1..n
2271 //newSmdsToVtk.resize(newCellSize+1, -1);
2272 newVtkToSmds.resize(newCellSize+1, -1);
2274 int myCellsSize = myCells.size();
2276 for (int i = 0; i < myCellsSize; i++)
2280 newSmdsId++; // SMDS id start to 1
2281 assert(newSmdsId <= newCellSize);
2282 newCells[newSmdsId] = myCells[i];
2283 newCells[newSmdsId]->setId(newSmdsId);
2284 //MESSAGE("myCells["<< i << "] --> newCells[" << newSmdsId << "]");
2285 int idvtk = myCells[i]->getVtkId();
2286 //newSmdsToVtk[newSmdsId] = idvtk;
2287 assert(idvtk < newCellSize);
2288 newVtkToSmds[idvtk] = newSmdsId;
2292 myCells.swap(newCells);
2293 //myCellIdSmdsToVtk.swap(newSmdsToVtk);
2294 myCellIdVtkToSmds.swap(newVtkToSmds);
2295 MESSAGE("myCells.size()=" << myCells.size()
2296 << " myCellIdVtkToSmds.size()=" << myCellIdVtkToSmds.size() );
2297 this->myElementIDFactory->emptyPool(newSmdsId);
2299 this->myScript->SetModified(true); // notify GUI client for buildPrs when update
2301 // --- compact list myNodes and myElements in submeshes
2303 SMESHDS_SubMeshIteratorPtr smIt = SubMeshes();
2304 while ( SMESHDS_SubMesh* sm = const_cast< SMESHDS_SubMesh* >( smIt->next() ))
2308 void SMESHDS_Mesh::CleanDownWardConnectivity()
2310 myGrid->CleanDownwardConnectivity();
2313 void SMESHDS_Mesh::BuildDownWardConnectivity(bool withEdges)
2315 myGrid->BuildDownwardConnectivity(withEdges);
2318 /*! change some nodes in cell without modifying type or internal connectivity.
2319 * Nodes inverse connectivity is maintained up to date.
2320 * @param vtkVolId vtk id of the cell.
2321 * @param localClonedNodeIds map old node id to new node id.
2322 * @return ok if success.
2324 bool SMESHDS_Mesh::ModifyCellNodes(int vtkVolId, std::map<int,int> localClonedNodeIds)
2326 myGrid->ModifyCellNodes(vtkVolId, localClonedNodeIds);