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_Script.cxx
25 // Author : Yves FRICAUD, OCC
30 #include "SMESHDS_Script.hxx"
32 //=======================================================================
35 //=======================================================================
36 void SMESHDS_Script::AddNode(int NewNodeID, double x, double y, double z)
39 if (myCommands.empty())
41 com = new SMESHDS_Command(SMESHDS_AddNode);
42 myCommands.insert(myCommands.end(),com);
46 com = myCommands.back();
47 if (com->GetType() != SMESHDS_AddNode)
49 com = new SMESHDS_Command(SMESHDS_AddNode);
50 myCommands.insert(myCommands.end(),com);
53 com->AddNode(NewNodeID, x, y, z);
56 //=======================================================================
59 //=======================================================================
60 void SMESHDS_Script::AddEdge(int NewEdgeID, int idnode1, int idnode2)
63 if (myCommands.empty())
65 com = new SMESHDS_Command(SMESHDS_AddEdge);
66 myCommands.insert(myCommands.end(), com);
70 com = myCommands.back();
71 if (com->GetType() != SMESHDS_AddEdge)
73 com = new SMESHDS_Command(SMESHDS_AddEdge);
74 myCommands.insert(myCommands.end(), com);
77 com->AddEdge(NewEdgeID, idnode1, idnode2);
80 //=======================================================================
83 //=======================================================================
84 void SMESHDS_Script::AddFace(int NewFaceID,
85 int idnode1, int idnode2, int idnode3)
87 SMESHDS_Command * com;
88 if (myCommands.empty())
90 com = new SMESHDS_Command(SMESHDS_AddTriangle);
91 myCommands.insert(myCommands.end(),com);
95 com = myCommands.back();
96 if (com->GetType() != SMESHDS_AddTriangle)
98 com = new SMESHDS_Command(SMESHDS_AddTriangle);
99 myCommands.insert(myCommands.end(),com);
102 com->AddFace(NewFaceID, idnode1, idnode2, idnode3);
105 //=======================================================================
108 //=======================================================================
109 void SMESHDS_Script::AddFace(int NewFaceID,
110 int idnode1, int idnode2, int idnode3, int idnode4)
112 SMESHDS_Command * com;
113 if (myCommands.empty())
115 com = new SMESHDS_Command(SMESHDS_AddQuadrangle);
116 myCommands.insert(myCommands.end(),com);
120 com = myCommands.back();
121 if (com->GetType() != SMESHDS_AddQuadrangle)
123 com = new SMESHDS_Command(SMESHDS_AddQuadrangle);
124 myCommands.insert(myCommands.end(),com);
127 com->AddFace(NewFaceID, idnode1, idnode2, idnode3, idnode4);
130 //=======================================================================
133 //=======================================================================
134 void SMESHDS_Script::AddVolume(int NewID,
135 int idnode1, int idnode2, int idnode3, int idnode4)
137 SMESHDS_Command * com;
138 if (myCommands.empty())
140 com = new SMESHDS_Command(SMESHDS_AddTetrahedron);
141 myCommands.insert(myCommands.end(),com);
145 com = myCommands.back();
146 if (com->GetType() != SMESHDS_AddTetrahedron)
148 com = new SMESHDS_Command(SMESHDS_AddTetrahedron);
149 myCommands.insert(myCommands.end(),com);
152 com->AddVolume(NewID, idnode1, idnode2, idnode3, idnode4);
155 //=======================================================================
158 //=======================================================================
159 void SMESHDS_Script::AddVolume(int NewID,
160 int idnode1, int idnode2, int idnode3, int idnode4, int idnode5)
162 SMESHDS_Command * com;
163 if (myCommands.empty())
165 com = new SMESHDS_Command(SMESHDS_AddPyramid);
166 myCommands.insert(myCommands.end(),com);
170 com = myCommands.back();
171 if (com->GetType() != SMESHDS_AddPyramid)
173 com = new SMESHDS_Command(SMESHDS_AddPyramid);
174 myCommands.insert(myCommands.end(),com);
177 com->AddVolume(NewID, idnode1, idnode2, idnode3, idnode4, idnode5);
180 //=======================================================================
183 //=======================================================================
184 void SMESHDS_Script::AddVolume(int NewID,
186 int idnode2, int idnode3, int idnode4, int idnode5, int idnode6)
188 SMESHDS_Command * com;
189 if (myCommands.empty())
191 com = new SMESHDS_Command(SMESHDS_AddPrism);
192 myCommands.insert(myCommands.end(),com);
196 com = myCommands.back();
197 if (com->GetType() != SMESHDS_AddPrism)
199 com = new SMESHDS_Command(SMESHDS_AddPrism);
200 myCommands.insert(myCommands.end(),com);
203 com->AddVolume(NewID, idnode1, idnode2, idnode3, idnode4, idnode5, idnode6);
206 //=======================================================================
209 //=======================================================================
210 void SMESHDS_Script::AddVolume(int NewID,
214 int idnode4, int idnode5, int idnode6, int idnode7, int idnode8)
216 SMESHDS_Command * com;
217 if (myCommands.empty())
219 com = new SMESHDS_Command(SMESHDS_AddHexahedron);
220 myCommands.insert(myCommands.end(),com);
224 com = myCommands.back();
225 if (com->GetType() != SMESHDS_AddHexahedron)
227 com = new SMESHDS_Command(SMESHDS_AddHexahedron);
228 myCommands.insert(myCommands.end(),com);
231 com->AddVolume(NewID, idnode1, idnode2, idnode3, idnode4,
232 idnode5, idnode6, idnode7, idnode8);
235 //=======================================================================
238 //=======================================================================
239 void SMESHDS_Script::MoveNode(int NewNodeID, double x, double y, double z)
241 SMESHDS_Command * com;
242 if (myCommands.empty())
244 com = new SMESHDS_Command(SMESHDS_MoveNode);
245 myCommands.insert(myCommands.end(),com);
249 com = myCommands.back();
250 if (com->GetType() != SMESHDS_MoveNode)
252 com = new SMESHDS_Command(SMESHDS_MoveNode);
253 myCommands.insert(myCommands.end(),com);
256 com->MoveNode(NewNodeID, x, y, z);
259 //=======================================================================
262 //=======================================================================
263 void SMESHDS_Script::RemoveNode(int ID)
265 SMESHDS_Command * com;
266 if (myCommands.empty())
268 com = new SMESHDS_Command(SMESHDS_RemoveNode);
269 myCommands.insert(myCommands.end(),com);
273 com = myCommands.back();
274 if (com->GetType() != SMESHDS_RemoveNode)
276 com = new SMESHDS_Command(SMESHDS_RemoveNode);
277 myCommands.insert(myCommands.end(),com);
283 //=======================================================================
286 //=======================================================================
287 void SMESHDS_Script::RemoveElement(int ElementID)
289 SMESHDS_Command * com;
290 if (myCommands.empty())
292 com = new SMESHDS_Command(SMESHDS_RemoveElement);
293 myCommands.insert(myCommands.end(),com);
297 com = myCommands.back();
298 if (com->GetType() != SMESHDS_RemoveElement)
300 com = new SMESHDS_Command(SMESHDS_RemoveElement);
301 myCommands.insert(myCommands.end(),com);
304 com->RemoveElement(ElementID);
307 //=======================================================================
310 //=======================================================================
311 void SMESHDS_Script::Clear()
316 //=======================================================================
319 //=======================================================================
320 const list<SMESHDS_Command*>& SMESHDS_Script::GetCommands()