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 _myMeshDS->RemoveElement(index);
65 MESSAGE("Element " << index << " was removed")
70 //=============================================================================
74 //=============================================================================
76 CORBA::Boolean SMESH_MeshEditor_i::RemoveNodes(const SMESH::
77 long_array & IDsOfNodes)
79 // It's nodes' turn to die
80 for (int i = 0; i < IDsOfNodes.length(); i++)
82 const SMDS_MeshNode * node=_myMeshDS->FindNode(IDsOfNodes[i]);
85 MESSAGE("SMESH_MeshEditor_i::RemoveNodes: Node "<<IDsOfNodes[i]
89 _myMeshDS->RemoveNode(IDsOfNodes[i]);
90 MESSAGE("Node " << index << " was removed")
95 //=============================================================================
99 //=============================================================================
101 CORBA::Boolean SMESH_MeshEditor_i::AddEdge(const SMESH::long_array & IDsOfNodes)
103 int NbNodes = IDsOfNodes.length();
106 CORBA::Long index1 = IDsOfNodes[0];
107 CORBA::Long index2 = IDsOfNodes[1];
108 _myMeshDS->AddEdge(index1, index2);
113 //=============================================================================
117 //=============================================================================
119 CORBA::Boolean SMESH_MeshEditor_i::AddNode(CORBA::Double x,
120 CORBA::Double y, CORBA::Double z)
122 MESSAGE(" AddNode " << x << " , " << y << " , " << z)
123 int idNode = _myMeshDS->AddNode(x, y, z)->GetID();
124 MESSAGE(" idNode " << idNode) return true;
127 //=============================================================================
131 //=============================================================================
133 CORBA::Boolean SMESH_MeshEditor_i::AddFace(const SMESH::long_array & IDsOfNodes)
135 int NbNodes = IDsOfNodes.length();
138 CORBA::Long index1 = IDsOfNodes[0];
139 CORBA::Long index2 = IDsOfNodes[1];
140 CORBA::Long index3 = IDsOfNodes[2];
141 _myMeshDS->AddFace(index1, index2, index3);
143 else if (NbNodes == 4)
145 CORBA::Long index1 = IDsOfNodes[0];
146 CORBA::Long index2 = IDsOfNodes[1];
147 CORBA::Long index3 = IDsOfNodes[2];
148 CORBA::Long index4 = IDsOfNodes[3];
149 _myMeshDS->AddFace(index1, index2, index3, index4);
154 //=============================================================================
158 //=============================================================================
160 CORBA::Boolean SMESH_MeshEditor_i::AddVolume(const SMESH::
161 long_array & IDsOfNodes)
163 int NbNodes = IDsOfNodes.length();
166 CORBA::Long index1 = IDsOfNodes[0];
167 CORBA::Long index2 = IDsOfNodes[1];
168 CORBA::Long index3 = IDsOfNodes[2];
169 CORBA::Long index4 = IDsOfNodes[3];
170 _myMeshDS->AddVolume(index1, index2, index3, index4);
172 else if (NbNodes == 5)
174 CORBA::Long index1 = IDsOfNodes[0];
175 CORBA::Long index2 = IDsOfNodes[1];
176 CORBA::Long index3 = IDsOfNodes[2];
177 CORBA::Long index4 = IDsOfNodes[3];
178 CORBA::Long index5 = IDsOfNodes[4];
179 _myMeshDS->AddVolume(index1, index2, index3, index4, index5);
181 else if (NbNodes == 6)
183 CORBA::Long index1 = IDsOfNodes[0];
184 CORBA::Long index2 = IDsOfNodes[1];
185 CORBA::Long index3 = IDsOfNodes[2];
186 CORBA::Long index4 = IDsOfNodes[3];
187 CORBA::Long index5 = IDsOfNodes[4];
188 CORBA::Long index6 = IDsOfNodes[5];
189 _myMeshDS->AddVolume(index1, index2, index3, index4, index5, index6);
191 else if (NbNodes == 8)
193 CORBA::Long index1 = IDsOfNodes[0];
194 CORBA::Long index2 = IDsOfNodes[1];
195 CORBA::Long index3 = IDsOfNodes[2];
196 CORBA::Long index4 = IDsOfNodes[3];
197 CORBA::Long index5 = IDsOfNodes[4];
198 CORBA::Long index6 = IDsOfNodes[5];
199 CORBA::Long index7 = IDsOfNodes[6];
200 CORBA::Long index8 = IDsOfNodes[7];
201 _myMeshDS->AddVolume(index1, index2, index3, index4, index5, index6,