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
29 #include "SMESHDS_Script.hxx"
31 //=======================================================================
34 //=======================================================================
35 void SMESHDS_Script::AddNode(int NewNodeID, double x, double y, double z)
38 if (myCommands.empty())
40 com = new SMESHDS_Command(SMESHDS_AddNode);
41 myCommands.insert(myCommands.end(),com);
45 com = myCommands.back();
46 if (com->GetType() != SMESHDS_AddNode)
48 com = new SMESHDS_Command(SMESHDS_AddNode);
49 myCommands.insert(myCommands.end(),com);
52 com->AddNode(NewNodeID, x, y, z);
55 //=======================================================================
58 //=======================================================================
59 void SMESHDS_Script::AddEdge(int NewEdgeID, int idnode1, int idnode2)
62 if (myCommands.empty())
64 com = new SMESHDS_Command(SMESHDS_AddEdge);
65 myCommands.insert(myCommands.end(), com);
69 com = myCommands.back();
70 if (com->GetType() != SMESHDS_AddEdge)
72 com = new SMESHDS_Command(SMESHDS_AddEdge);
73 myCommands.insert(myCommands.end(), com);
76 com->AddEdge(NewEdgeID, idnode1, idnode2);
79 //=======================================================================
82 //=======================================================================
83 void SMESHDS_Script::AddFace(int NewFaceID,
84 int idnode1, int idnode2, int idnode3)
86 SMESHDS_Command * com;
87 if (myCommands.empty())
89 com = new SMESHDS_Command(SMESHDS_AddTriangle);
90 myCommands.insert(myCommands.end(),com);
94 com = myCommands.back();
95 if (com->GetType() != SMESHDS_AddTriangle)
97 com = new SMESHDS_Command(SMESHDS_AddTriangle);
98 myCommands.insert(myCommands.end(),com);
101 com->AddFace(NewFaceID, idnode1, idnode2, idnode3);
104 //=======================================================================
107 //=======================================================================
108 void SMESHDS_Script::AddFace(int NewFaceID,
109 int idnode1, int idnode2, int idnode3, int idnode4)
111 SMESHDS_Command * com;
112 if (myCommands.empty())
114 com = new SMESHDS_Command(SMESHDS_AddQuadrangle);
115 myCommands.insert(myCommands.end(),com);
119 com = myCommands.back();
120 if (com->GetType() != SMESHDS_AddQuadrangle)
122 com = new SMESHDS_Command(SMESHDS_AddQuadrangle);
123 myCommands.insert(myCommands.end(),com);
126 com->AddFace(NewFaceID, idnode1, idnode2, idnode3, idnode4);
129 //=======================================================================
132 //=======================================================================
133 void SMESHDS_Script::AddVolume(int NewID,
134 int idnode1, int idnode2, int idnode3, int idnode4)
136 SMESHDS_Command * com;
137 if (myCommands.empty())
139 com = new SMESHDS_Command(SMESHDS_AddTetrahedron);
140 myCommands.insert(myCommands.end(),com);
144 com = myCommands.back();
145 if (com->GetType() != SMESHDS_AddTetrahedron)
147 com = new SMESHDS_Command(SMESHDS_AddTetrahedron);
148 myCommands.insert(myCommands.end(),com);
151 com->AddVolume(NewID, idnode1, idnode2, idnode3, idnode4);
154 //=======================================================================
157 //=======================================================================
158 void SMESHDS_Script::AddVolume(int NewID,
159 int idnode1, int idnode2, int idnode3, int idnode4, int idnode5)
161 SMESHDS_Command * com;
162 if (myCommands.empty())
164 com = new SMESHDS_Command(SMESHDS_AddPyramid);
165 myCommands.insert(myCommands.end(),com);
169 com = myCommands.back();
170 if (com->GetType() != SMESHDS_AddPyramid)
172 com = new SMESHDS_Command(SMESHDS_AddPyramid);
173 myCommands.insert(myCommands.end(),com);
176 com->AddVolume(NewID, idnode1, idnode2, idnode3, idnode4, idnode5);
179 //=======================================================================
182 //=======================================================================
183 void SMESHDS_Script::AddVolume(int NewID,
185 int idnode2, int idnode3, int idnode4, int idnode5, int idnode6)
187 SMESHDS_Command * com;
188 if (myCommands.empty())
190 com = new SMESHDS_Command(SMESHDS_AddPrism);
191 myCommands.insert(myCommands.end(),com);
195 com = myCommands.back();
196 if (com->GetType() != SMESHDS_AddPrism)
198 com = new SMESHDS_Command(SMESHDS_AddPrism);
199 myCommands.insert(myCommands.end(),com);
202 com->AddVolume(NewID, idnode1, idnode2, idnode3, idnode4, idnode5, idnode6);
205 //=======================================================================
208 //=======================================================================
209 void SMESHDS_Script::AddVolume(int NewID,
213 int idnode4, int idnode5, int idnode6, int idnode7, int idnode8)
215 SMESHDS_Command * com;
216 if (myCommands.empty())
218 com = new SMESHDS_Command(SMESHDS_AddHexahedron);
219 myCommands.insert(myCommands.end(),com);
223 com = myCommands.back();
224 if (com->GetType() != SMESHDS_AddHexahedron)
226 com = new SMESHDS_Command(SMESHDS_AddHexahedron);
227 myCommands.insert(myCommands.end(),com);
230 com->AddVolume(NewID, idnode1, idnode2, idnode3, idnode4,
231 idnode5, idnode6, idnode7, idnode8);
234 //=======================================================================
237 //=======================================================================
238 void SMESHDS_Script::MoveNode(int NewNodeID, double x, double y, double z)
240 SMESHDS_Command * com;
241 if (myCommands.empty())
243 com = new SMESHDS_Command(SMESHDS_MoveNode);
244 myCommands.insert(myCommands.end(),com);
248 com = myCommands.back();
249 if (com->GetType() != SMESHDS_MoveNode)
251 com = new SMESHDS_Command(SMESHDS_MoveNode);
252 myCommands.insert(myCommands.end(),com);
255 com->MoveNode(NewNodeID, x, y, z);
258 //=======================================================================
261 //=======================================================================
262 void SMESHDS_Script::RemoveNode(int ID)
264 SMESHDS_Command * com;
265 if (myCommands.empty())
267 com = new SMESHDS_Command(SMESHDS_RemoveNode);
268 myCommands.insert(myCommands.end(),com);
272 com = myCommands.back();
273 if (com->GetType() != SMESHDS_RemoveNode)
275 com = new SMESHDS_Command(SMESHDS_RemoveNode);
276 myCommands.insert(myCommands.end(),com);
282 //=======================================================================
285 //=======================================================================
286 void SMESHDS_Script::RemoveElement(int ElementID)
288 SMESHDS_Command * com;
289 if (myCommands.empty())
291 com = new SMESHDS_Command(SMESHDS_RemoveElement);
292 myCommands.insert(myCommands.end(),com);
296 com = myCommands.back();
297 if (com->GetType() != SMESHDS_RemoveElement)
299 com = new SMESHDS_Command(SMESHDS_RemoveElement);
300 myCommands.insert(myCommands.end(),com);
303 com->RemoveElement(ElementID);
306 //=======================================================================
309 //=======================================================================
310 void SMESHDS_Script::Clear()
315 //=======================================================================
318 //=======================================================================
319 const list<SMESHDS_Command*>& SMESHDS_Script::GetCommands()
325 * Add UpdateAll command to the log of this mesh. Once interpreted by the
326 * graphical client it will (re)draw the full mesh.
328 void SMESHDS_Script::UpdateAll()
330 myCommands.insert(myCommands.end(), new SMESHDS_Command(SMESHDS_UpdateAll));