1 // SMESH SMESHDS : management of mesh data and SMESH document
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_Command.cxx
25 // Author : Yves FRICAUD, OCC
29 #include "SMESHDS_Command.hxx"
31 #include "utilities.h"
35 //=======================================================================
38 //=======================================================================
39 SMESHDS_Command::SMESHDS_Command(const SMESHDS_CommandType aType):myType(aType),
44 //=======================================================================
47 //=======================================================================
48 void SMESHDS_Command::AddNode(int NewNodeID, double x, double y, double z)
50 if (!myType == SMESHDS_AddNode)
52 MESSAGE("SMESHDS_Command::AddNode : Bad Type");
55 myIntegers.push_back(NewNodeID);
62 //=======================================================================
65 //=======================================================================
66 void SMESHDS_Command::MoveNode(int NodeID, double x, double y, double z)
68 if (!myType == SMESHDS_MoveNode)
70 MESSAGE("SMESHDS_Command::MoveNode : Bad Type");
73 myIntegers.push_back(NodeID);
80 //=======================================================================
83 //=======================================================================
84 void SMESHDS_Command::AddEdge(int NewEdgeID, int idnode1, int idnode2)
86 if (!myType == SMESHDS_AddEdge)
88 MESSAGE("SMESHDS_Command::AddEdge : Bad Type");
91 myIntegers.push_back(NewEdgeID);
92 myIntegers.push_back(idnode1);
93 myIntegers.push_back(idnode2);
97 //=======================================================================
100 //=======================================================================
101 void SMESHDS_Command::AddFace(int NewFaceID,
102 int idnode1, int idnode2, int idnode3)
104 if (!myType == SMESHDS_AddTriangle)
106 MESSAGE("SMESHDS_Command::AddFace : Bad Type");
109 myIntegers.push_back(NewFaceID);
110 myIntegers.push_back(idnode1);
111 myIntegers.push_back(idnode2);
112 myIntegers.push_back(idnode3);
116 //=======================================================================
119 //=======================================================================
120 void SMESHDS_Command::AddFace(int NewFaceID,
121 int idnode1, int idnode2, int idnode3, int idnode4)
123 if (!myType == SMESHDS_AddQuadrangle)
125 MESSAGE("SMESHDS_Command::AddFace : Bad Type");
128 myIntegers.push_back(NewFaceID);
129 myIntegers.push_back(idnode1);
130 myIntegers.push_back(idnode2);
131 myIntegers.push_back(idnode3);
132 myIntegers.push_back(idnode4);
136 //=======================================================================
139 //=======================================================================
140 void SMESHDS_Command::AddVolume(int NewVolID,
141 int idnode1, int idnode2, int idnode3, int idnode4)
143 if (!myType == SMESHDS_AddTetrahedron)
145 MESSAGE("SMESHDS_Command::AddVolume : Bad Type");
148 myIntegers.push_back(NewVolID);
149 myIntegers.push_back(idnode1);
150 myIntegers.push_back(idnode2);
151 myIntegers.push_back(idnode3);
152 myIntegers.push_back(idnode4);
156 //=======================================================================
159 //=======================================================================
160 void SMESHDS_Command::AddVolume(int NewVolID,
161 int idnode1, int idnode2, int idnode3, int idnode4, int idnode5)
163 if (!myType == SMESHDS_AddPyramid)
165 MESSAGE("SMESHDS_Command::AddVolume : Bad Type");
168 myIntegers.push_back(NewVolID);
169 myIntegers.push_back(idnode1);
170 myIntegers.push_back(idnode2);
171 myIntegers.push_back(idnode3);
172 myIntegers.push_back(idnode4);
173 myIntegers.push_back(idnode5);
177 //=======================================================================
180 //=======================================================================
181 void SMESHDS_Command::AddVolume(int NewVolID,
183 int idnode2, int idnode3, int idnode4, int idnode5, int idnode6)
185 if (!myType == SMESHDS_AddPrism)
187 MESSAGE("SMESHDS_Command::AddVolume : Bad Type");
190 myIntegers.push_back(NewVolID);
191 myIntegers.push_back(idnode1);
192 myIntegers.push_back(idnode2);
193 myIntegers.push_back(idnode3);
194 myIntegers.push_back(idnode4);
195 myIntegers.push_back(idnode5);
196 myIntegers.push_back(idnode6);
200 //=======================================================================
203 //=======================================================================
204 void SMESHDS_Command::AddVolume(int NewVolID,
208 int idnode4, int idnode5, int idnode6, int idnode7, int idnode8)
210 if (!myType == SMESHDS_AddHexahedron)
212 MESSAGE("SMESHDS_Command::AddVolume : Bad Type");
215 myIntegers.push_back(NewVolID);
216 myIntegers.push_back(idnode1);
217 myIntegers.push_back(idnode2);
218 myIntegers.push_back(idnode3);
219 myIntegers.push_back(idnode4);
220 myIntegers.push_back(idnode5);
221 myIntegers.push_back(idnode6);
222 myIntegers.push_back(idnode7);
223 myIntegers.push_back(idnode8);
227 //=======================================================================
228 //function : AddPolygonalFace
230 //=======================================================================
231 void SMESHDS_Command::AddPolygonalFace (const int ElementID,
232 std::vector<int> nodes_ids)
234 if (!myType == SMESHDS_AddPolygon) {
235 MESSAGE("SMESHDS_Command::AddPolygonalFace : Bad Type");
238 myIntegers.push_back(ElementID);
240 int i, nbNodes = nodes_ids.size();
241 myIntegers.push_back(nbNodes);
242 for (i = 0; i < nbNodes; i++) {
243 myIntegers.push_back(nodes_ids[i]);
249 //=======================================================================
250 //function : AddPolyhedralVolume
252 //=======================================================================
253 void SMESHDS_Command::AddPolyhedralVolume (const int ElementID,
254 std::vector<int> nodes_ids,
255 std::vector<int> quantities)
257 if (!myType == SMESHDS_AddPolyhedron) {
258 MESSAGE("SMESHDS_Command::AddPolyhedralVolume : Bad Type");
261 myIntegers.push_back(ElementID);
263 int i, nbNodes = nodes_ids.size();
264 myIntegers.push_back(nbNodes);
265 for (i = 0; i < nbNodes; i++) {
266 myIntegers.push_back(nodes_ids[i]);
269 int nbFaces = quantities.size();
270 myIntegers.push_back(nbFaces);
271 for (i = 0; i < nbFaces; i++) {
272 myIntegers.push_back(quantities[i]);
278 //=======================================================================
281 //=======================================================================
282 void SMESHDS_Command::RemoveNode(int NodeID)
284 if (!myType == SMESHDS_RemoveNode)
286 MESSAGE("SMESHDS_Command::RemoveNode : Bad Type");
289 myIntegers.push_back(NodeID);
293 //=======================================================================
296 //=======================================================================
297 void SMESHDS_Command::RemoveElement(int ElementID)
299 if (!myType == SMESHDS_RemoveElement)
301 MESSAGE("SMESHDS_Command::RemoveElement : Bad Type");
304 myIntegers.push_back(ElementID);
308 //=======================================================================
309 //function : ChangeElementNodes
311 //=======================================================================
313 void SMESHDS_Command::ChangeElementNodes(int ElementID, int nodes[], int nbnodes)
315 if (!myType == SMESHDS_ChangeElementNodes)
317 MESSAGE("SMESHDS_Command::ChangeElementNodes : Bad Type");
320 myIntegers.push_back(ElementID);
321 myIntegers.push_back(nbnodes);
322 for ( int i = 0; i < nbnodes; i++ )
323 myIntegers.push_back( nodes[ i ] );
328 //=======================================================================
329 //function : ChangePolyhedronNodes
331 //=======================================================================
332 void SMESHDS_Command::ChangePolyhedronNodes (const int ElementID,
333 std::vector<int> nodes_ids,
334 std::vector<int> quantities)
336 if (myType != SMESHDS_ChangePolyhedronNodes)
338 MESSAGE("SMESHDS_Command::ChangePolyhedronNodes : Bad Type");
341 myIntegers.push_back(ElementID);
343 int i, nbNodes = nodes_ids.size();
344 myIntegers.push_back(nbNodes);
345 for (i = 0; i < nbNodes; i++) {
346 myIntegers.push_back(nodes_ids[i]);
349 int nbFaces = quantities.size();
350 myIntegers.push_back(nbFaces);
351 for (i = 0; i < nbFaces; i++) {
352 myIntegers.push_back(quantities[i]);
358 //=======================================================================
359 //function : Renumber
361 //=======================================================================
363 void SMESHDS_Command::Renumber (const bool isNodes, const int startID, const int deltaID)
365 if (!myType == SMESHDS_Renumber)
367 MESSAGE("SMESHDS_Command::Renumber : Bad Type");
370 myIntegers.push_back(isNodes);
371 myIntegers.push_back(startID);
372 myIntegers.push_back(deltaID);
376 //=======================================================================
379 //=======================================================================
380 SMESHDS_CommandType SMESHDS_Command::GetType()
385 //=======================================================================
388 //=======================================================================
389 int SMESHDS_Command::GetNumber()
394 //=======================================================================
397 //=======================================================================
398 const list < int >&SMESHDS_Command::GetIndexes()
403 //=======================================================================
406 //=======================================================================
407 const list < double >&SMESHDS_Command::GetCoords()