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.ixx"
31 #include "SMESHDS_Command.hxx"
32 #include "SMESHDS_CommandType.hxx"
33 #include "SMESHDS_ListOfCommand.hxx"
35 //=======================================================================
38 //=======================================================================
39 void SMESHDS_Script::AddNode(const Standard_Integer NewNodeID,
40 const Standard_Real x,
41 const Standard_Real y,
42 const Standard_Real z)
44 Handle(SMESHDS_Command) com;
45 if (myCommands.IsEmpty()) {
46 com = new SMESHDS_Command(SMESHDS_AddNode);
47 myCommands.Append (com);
50 com = myCommands.Last();
51 if (com->GetType() != SMESHDS_AddNode) {
52 com = new SMESHDS_Command(SMESHDS_AddNode);
53 myCommands.Append (com);
56 com->AddNode (NewNodeID,x,y,z);
60 //=======================================================================
63 //=======================================================================
64 void SMESHDS_Script::AddEdge(const Standard_Integer NewEdgeID,
65 const Standard_Integer idnode1,
66 const Standard_Integer idnode2)
68 Handle(SMESHDS_Command) com;
69 if (myCommands.IsEmpty()) {
70 com = new SMESHDS_Command(SMESHDS_AddEdge);
71 myCommands.Append (com);
74 com = myCommands.Last();
75 if (com->GetType() != SMESHDS_AddEdge) {
76 com = new SMESHDS_Command(SMESHDS_AddEdge);
77 myCommands.Append (com);
80 com->AddEdge (NewEdgeID,idnode1,idnode2);
83 //=======================================================================
86 //=======================================================================
87 void SMESHDS_Script::AddFace(const Standard_Integer NewFaceID,
88 const Standard_Integer idnode1,
89 const Standard_Integer idnode2,
90 const Standard_Integer idnode3)
92 Handle(SMESHDS_Command) com;
93 if (myCommands.IsEmpty()) {
94 com = new SMESHDS_Command(SMESHDS_AddTriangle);
95 myCommands.Append (com);
98 com = myCommands.Last();
99 if (com->GetType() != SMESHDS_AddTriangle) {
100 com = new SMESHDS_Command(SMESHDS_AddTriangle);
101 myCommands.Append (com);
104 com->AddFace (NewFaceID,idnode1,idnode2,idnode3);
107 //=======================================================================
110 //=======================================================================
111 void SMESHDS_Script::AddFace(const Standard_Integer NewFaceID,
112 const Standard_Integer idnode1,
113 const Standard_Integer idnode2,
114 const Standard_Integer idnode3,
115 const Standard_Integer idnode4)
117 Handle(SMESHDS_Command) com;
118 if (myCommands.IsEmpty()) {
119 com = new SMESHDS_Command(SMESHDS_AddQuadrangle);
120 myCommands.Append (com);
123 com = myCommands.Last();
124 if (com->GetType() != SMESHDS_AddQuadrangle) {
125 com = new SMESHDS_Command(SMESHDS_AddQuadrangle);
126 myCommands.Append (com);
129 com->AddFace (NewFaceID,idnode1,idnode2,idnode3,idnode4);
132 //=======================================================================
135 //=======================================================================
136 void SMESHDS_Script::AddVolume(const Standard_Integer NewID,
137 const Standard_Integer idnode1,
138 const Standard_Integer idnode2,
139 const Standard_Integer idnode3,
140 const Standard_Integer idnode4)
142 Handle(SMESHDS_Command) com;
143 if (myCommands.IsEmpty()) {
144 com = new SMESHDS_Command(SMESHDS_AddTetrahedron);
145 myCommands.Append (com);
148 com = myCommands.Last();
149 if (com->GetType() != SMESHDS_AddQuadrangle) {
150 com = new SMESHDS_Command(SMESHDS_AddQuadrangle);
151 myCommands.Append (com);
154 com->AddVolume (NewID,idnode1,idnode2,idnode3,idnode4);
157 //=======================================================================
160 //=======================================================================
161 void SMESHDS_Script::AddVolume(const Standard_Integer NewID,
162 const Standard_Integer idnode1,
163 const Standard_Integer idnode2,
164 const Standard_Integer idnode3,
165 const Standard_Integer idnode4,
166 const Standard_Integer idnode5)
168 Handle(SMESHDS_Command) com;
169 if (myCommands.IsEmpty()) {
170 com = new SMESHDS_Command(SMESHDS_AddPyramid);
171 myCommands.Append (com);
174 com = myCommands.Last();
175 if (com->GetType() != SMESHDS_AddPyramid) {
176 com = new SMESHDS_Command(SMESHDS_AddPyramid);
177 myCommands.Append (com);
180 com->AddVolume (NewID,idnode1,idnode2,idnode3,idnode4,idnode5);
183 //=======================================================================
186 //=======================================================================
187 void SMESHDS_Script::AddVolume(const Standard_Integer NewID,
188 const Standard_Integer idnode1,
189 const Standard_Integer idnode2,
190 const Standard_Integer idnode3,
191 const Standard_Integer idnode4,
192 const Standard_Integer idnode5,
193 const Standard_Integer idnode6)
195 Handle(SMESHDS_Command) com;
196 if (myCommands.IsEmpty()) {
197 com = new SMESHDS_Command(SMESHDS_AddPrism);
198 myCommands.Append (com);
201 com = myCommands.Last();
202 if (com->GetType() != SMESHDS_AddPrism) {
203 com = new SMESHDS_Command(SMESHDS_AddPrism);
204 myCommands.Append (com);
207 com->AddVolume (NewID,idnode1,idnode2,idnode3,idnode4,idnode5,idnode6);
210 //=======================================================================
213 //=======================================================================
214 void SMESHDS_Script::AddVolume(const Standard_Integer NewID,
215 const Standard_Integer idnode1,
216 const Standard_Integer idnode2,
217 const Standard_Integer idnode3,
218 const Standard_Integer idnode4,
219 const Standard_Integer idnode5,
220 const Standard_Integer idnode6,
221 const Standard_Integer idnode7,
222 const Standard_Integer idnode8)
224 Handle(SMESHDS_Command) com;
225 if (myCommands.IsEmpty()) {
226 com = new SMESHDS_Command(SMESHDS_AddHexahedron);
227 myCommands.Append (com);
230 com = myCommands.Last();
231 if (com->GetType() != SMESHDS_AddHexahedron) {
232 com = new SMESHDS_Command(SMESHDS_AddHexahedron);
233 myCommands.Append (com);
236 com->AddVolume (NewID,idnode1,idnode2,idnode3,idnode4,
237 idnode5,idnode6,idnode7,idnode8);
240 //=======================================================================
243 //=======================================================================
244 void SMESHDS_Script::MoveNode(const Standard_Integer NewNodeID,
245 const Standard_Real x,
246 const Standard_Real y,
247 const Standard_Real z)
249 Handle(SMESHDS_Command) com;
250 if (myCommands.IsEmpty()) {
251 com = new SMESHDS_Command(SMESHDS_MoveNode);
252 myCommands.Append (com);
255 com = myCommands.Last();
256 if (com->GetType() != SMESHDS_MoveNode) {
257 com = new SMESHDS_Command(SMESHDS_MoveNode);
258 myCommands.Append (com);
261 com->MoveNode (NewNodeID,x,y,z);
265 //=======================================================================
268 //=======================================================================
269 void SMESHDS_Script::RemoveNode(const Standard_Integer ID)
271 Handle(SMESHDS_Command) com;
272 if (myCommands.IsEmpty()) {
273 com = new SMESHDS_Command(SMESHDS_RemoveNode);
274 myCommands.Append (com);
277 com = myCommands.Last();
278 if (com->GetType() != SMESHDS_RemoveNode) {
279 com = new SMESHDS_Command(SMESHDS_RemoveNode);
280 myCommands.Append (com);
283 com->RemoveNode (ID);
286 //=======================================================================
289 //=======================================================================
290 void SMESHDS_Script::RemoveElement(const Standard_Integer ElementID)
292 Handle(SMESHDS_Command) com;
293 if (myCommands.IsEmpty()) {
294 com = new SMESHDS_Command(SMESHDS_RemoveElement);
295 myCommands.Append (com);
298 com = myCommands.Last();
299 if (com->GetType() != SMESHDS_RemoveElement) {
300 com = new SMESHDS_Command(SMESHDS_RemoveElement);
301 myCommands.Append (com);
304 com->RemoveElement (ElementID);
307 //=======================================================================
310 //=======================================================================
311 void SMESHDS_Script::Clear()
316 //=======================================================================
319 //=======================================================================
320 const SMESHDS_ListOfCommand& SMESHDS_Script::GetCommands()