1 // SMESH SMESH_I : idl implementation based on 'SMESH' unit's calsses
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
24 // File : SMESH_MeshEditor_i.cxx
25 // Author : Nicolas REJNERI
30 #include "SMESH_MeshEditor_i.hxx"
32 #include "SMDS_MeshEdge.hxx"
33 #include "SMDS_MeshFace.hxx"
34 #include "SMDS_MeshVolume.hxx"
36 #include "utilities.h"
38 #include <TColStd_MapOfInteger.hxx>
39 #include <TColStd_MapIteratorOfMapOfInteger.hxx>
41 //=============================================================================
45 //=============================================================================
47 SMESH_MeshEditor_i::SMESH_MeshEditor_i(SMESHDS_Mesh* theMesh)
52 //=============================================================================
56 //=============================================================================
58 CORBA::Boolean SMESH_MeshEditor_i::RemoveElements(const SMESH::
59 long_array & IDsOfElements)
61 for (int i = 0; i < IDsOfElements.length(); i++)
63 CORBA::Long index = IDsOfElements[i];
64 const SMDS_MeshElement * elem = _myMeshDS->FindElement(index);
65 // an element may be removed as a result of preceding
69 _myMeshDS->RemoveElement( elem );
70 MESSAGE("Element " << index << " was removed");
76 //=============================================================================
80 //=============================================================================
82 CORBA::Boolean SMESH_MeshEditor_i::RemoveNodes(const SMESH::
83 long_array & IDsOfNodes)
85 // It's nodes' turn to die
86 for (int i = 0; i < IDsOfNodes.length(); i++)
88 const SMDS_MeshNode * node=_myMeshDS->FindNode(IDsOfNodes[i]);
91 MESSAGE("SMESH_MeshEditor_i::RemoveNodes: Node "<<IDsOfNodes[i]
95 _myMeshDS->RemoveNode(node);
96 MESSAGE("Node " << IDsOfNodes[i] << " was removed")
101 //=============================================================================
105 //=============================================================================
107 CORBA::Boolean SMESH_MeshEditor_i::AddEdge(const SMESH::long_array & IDsOfNodes)
109 int NbNodes = IDsOfNodes.length();
112 CORBA::Long index1 = IDsOfNodes[0];
113 CORBA::Long index2 = IDsOfNodes[1];
114 _myMeshDS->AddEdge(_myMeshDS->FindNode(index1), _myMeshDS->FindNode(index2));
119 //=============================================================================
123 //=============================================================================
125 CORBA::Boolean SMESH_MeshEditor_i::AddNode(CORBA::Double x,
126 CORBA::Double y, CORBA::Double z)
128 MESSAGE(" AddNode " << x << " , " << y << " , " << z)
129 int idNode = _myMeshDS->AddNode(x, y, z)->GetID();
130 MESSAGE(" idNode " << idNode) return true;
133 //=============================================================================
137 //=============================================================================
139 CORBA::Boolean SMESH_MeshEditor_i::AddFace(const SMESH::long_array & IDsOfNodes)
141 int NbNodes = IDsOfNodes.length();
142 const SMDS_MeshNode* nodes[4];
143 for(int i=0;i<NbNodes;i++) nodes[i]=_myMeshDS->FindNode(IDsOfNodes[i]);
146 _myMeshDS->AddFace(nodes[0], nodes[1], nodes[2]);
148 else if (NbNodes == 4)
150 _myMeshDS->AddFace(nodes[0], nodes[1], nodes[2], nodes[3]);
155 //=============================================================================
159 //=============================================================================
161 CORBA::Boolean SMESH_MeshEditor_i::AddVolume(const SMESH::
162 long_array & IDsOfNodes)
164 int NbNodes = IDsOfNodes.length();
165 const SMDS_MeshNode* n[8];
166 for(int i=0;i<NbNodes;i++) n[i]=_myMeshDS->FindNode(IDsOfNodes[i]);
170 case 4:_myMeshDS->AddVolume(n[0],n[1],n[2],n[3]); break;
171 case 5:_myMeshDS->AddVolume(n[0],n[1],n[2],n[3],n[4]); break;
172 case 6:_myMeshDS->AddVolume(n[0],n[1],n[2],n[3],n[4],n[5]); break;
173 case 8:_myMeshDS->AddVolume(n[0],n[1],n[2],n[3],n[4],n[5],n[6],n[7]); break;