2 //=============================================================================
3 // File : SMESH_Script.cxx
5 // Author : Yves FRICAUD, OCC
7 // Copyright : OCC 2002
9 //=============================================================================
11 #include "SMESHDS_Script.ixx"
12 #include "SMESHDS_Command.hxx"
13 #include "SMESHDS_CommandType.hxx"
14 #include "SMESHDS_ListOfCommand.hxx"
16 //=======================================================================
19 //=======================================================================
20 void SMESHDS_Script::AddNode(const Standard_Integer NewNodeID,
21 const Standard_Real x,
22 const Standard_Real y,
23 const Standard_Real z)
25 Handle(SMESHDS_Command) com;
26 if (myCommands.IsEmpty()) {
27 com = new SMESHDS_Command(SMESHDS_AddNode);
28 myCommands.Append (com);
31 com = myCommands.Last();
32 if (com->GetType() != SMESHDS_AddNode) {
33 com = new SMESHDS_Command(SMESHDS_AddNode);
34 myCommands.Append (com);
37 com->AddNode (NewNodeID,x,y,z);
41 //=======================================================================
44 //=======================================================================
45 void SMESHDS_Script::AddEdge(const Standard_Integer NewEdgeID,
46 const Standard_Integer idnode1,
47 const Standard_Integer idnode2)
49 Handle(SMESHDS_Command) com;
50 if (myCommands.IsEmpty()) {
51 com = new SMESHDS_Command(SMESHDS_AddEdge);
52 myCommands.Append (com);
55 com = myCommands.Last();
56 if (com->GetType() != SMESHDS_AddEdge) {
57 com = new SMESHDS_Command(SMESHDS_AddEdge);
58 myCommands.Append (com);
61 com->AddEdge (NewEdgeID,idnode1,idnode2);
64 //=======================================================================
67 //=======================================================================
68 void SMESHDS_Script::AddFace(const Standard_Integer NewFaceID,
69 const Standard_Integer idnode1,
70 const Standard_Integer idnode2,
71 const Standard_Integer idnode3)
73 Handle(SMESHDS_Command) com;
74 if (myCommands.IsEmpty()) {
75 com = new SMESHDS_Command(SMESHDS_AddTriangle);
76 myCommands.Append (com);
79 com = myCommands.Last();
80 if (com->GetType() != SMESHDS_AddTriangle) {
81 com = new SMESHDS_Command(SMESHDS_AddTriangle);
82 myCommands.Append (com);
85 com->AddFace (NewFaceID,idnode1,idnode2,idnode3);
88 //=======================================================================
91 //=======================================================================
92 void SMESHDS_Script::AddFace(const Standard_Integer NewFaceID,
93 const Standard_Integer idnode1,
94 const Standard_Integer idnode2,
95 const Standard_Integer idnode3,
96 const Standard_Integer idnode4)
98 Handle(SMESHDS_Command) com;
99 if (myCommands.IsEmpty()) {
100 com = new SMESHDS_Command(SMESHDS_AddQuadrangle);
101 myCommands.Append (com);
104 com = myCommands.Last();
105 if (com->GetType() != SMESHDS_AddQuadrangle) {
106 com = new SMESHDS_Command(SMESHDS_AddQuadrangle);
107 myCommands.Append (com);
110 com->AddFace (NewFaceID,idnode1,idnode2,idnode3,idnode4);
113 //=======================================================================
116 //=======================================================================
117 void SMESHDS_Script::AddVolume(const Standard_Integer NewID,
118 const Standard_Integer idnode1,
119 const Standard_Integer idnode2,
120 const Standard_Integer idnode3,
121 const Standard_Integer idnode4)
123 Handle(SMESHDS_Command) com;
124 if (myCommands.IsEmpty()) {
125 com = new SMESHDS_Command(SMESHDS_AddTetrahedron);
126 myCommands.Append (com);
129 com = myCommands.Last();
130 if (com->GetType() != SMESHDS_AddQuadrangle) {
131 com = new SMESHDS_Command(SMESHDS_AddQuadrangle);
132 myCommands.Append (com);
135 com->AddVolume (NewID,idnode1,idnode2,idnode3,idnode4);
138 //=======================================================================
141 //=======================================================================
142 void SMESHDS_Script::AddVolume(const Standard_Integer NewID,
143 const Standard_Integer idnode1,
144 const Standard_Integer idnode2,
145 const Standard_Integer idnode3,
146 const Standard_Integer idnode4,
147 const Standard_Integer idnode5)
149 Handle(SMESHDS_Command) com;
150 if (myCommands.IsEmpty()) {
151 com = new SMESHDS_Command(SMESHDS_AddPyramid);
152 myCommands.Append (com);
155 com = myCommands.Last();
156 if (com->GetType() != SMESHDS_AddPyramid) {
157 com = new SMESHDS_Command(SMESHDS_AddPyramid);
158 myCommands.Append (com);
161 com->AddVolume (NewID,idnode1,idnode2,idnode3,idnode4,idnode5);
164 //=======================================================================
167 //=======================================================================
168 void SMESHDS_Script::AddVolume(const Standard_Integer NewID,
169 const Standard_Integer idnode1,
170 const Standard_Integer idnode2,
171 const Standard_Integer idnode3,
172 const Standard_Integer idnode4,
173 const Standard_Integer idnode5,
174 const Standard_Integer idnode6)
176 Handle(SMESHDS_Command) com;
177 if (myCommands.IsEmpty()) {
178 com = new SMESHDS_Command(SMESHDS_AddPrism);
179 myCommands.Append (com);
182 com = myCommands.Last();
183 if (com->GetType() != SMESHDS_AddPrism) {
184 com = new SMESHDS_Command(SMESHDS_AddPrism);
185 myCommands.Append (com);
188 com->AddVolume (NewID,idnode1,idnode2,idnode3,idnode4,idnode5,idnode6);
191 //=======================================================================
194 //=======================================================================
195 void SMESHDS_Script::AddVolume(const Standard_Integer NewID,
196 const Standard_Integer idnode1,
197 const Standard_Integer idnode2,
198 const Standard_Integer idnode3,
199 const Standard_Integer idnode4,
200 const Standard_Integer idnode5,
201 const Standard_Integer idnode6,
202 const Standard_Integer idnode7,
203 const Standard_Integer idnode8)
205 Handle(SMESHDS_Command) com;
206 if (myCommands.IsEmpty()) {
207 com = new SMESHDS_Command(SMESHDS_AddHexahedron);
208 myCommands.Append (com);
211 com = myCommands.Last();
212 if (com->GetType() != SMESHDS_AddHexahedron) {
213 com = new SMESHDS_Command(SMESHDS_AddHexahedron);
214 myCommands.Append (com);
217 com->AddVolume (NewID,idnode1,idnode2,idnode3,idnode4,
218 idnode5,idnode6,idnode7,idnode8);
221 //=======================================================================
224 //=======================================================================
225 void SMESHDS_Script::MoveNode(const Standard_Integer NewNodeID,
226 const Standard_Real x,
227 const Standard_Real y,
228 const Standard_Real z)
230 Handle(SMESHDS_Command) com;
231 if (myCommands.IsEmpty()) {
232 com = new SMESHDS_Command(SMESHDS_MoveNode);
233 myCommands.Append (com);
236 com = myCommands.Last();
237 if (com->GetType() != SMESHDS_MoveNode) {
238 com = new SMESHDS_Command(SMESHDS_MoveNode);
239 myCommands.Append (com);
242 com->MoveNode (NewNodeID,x,y,z);
246 //=======================================================================
249 //=======================================================================
250 void SMESHDS_Script::RemoveNode(const Standard_Integer ID)
252 Handle(SMESHDS_Command) com;
253 if (myCommands.IsEmpty()) {
254 com = new SMESHDS_Command(SMESHDS_RemoveNode);
255 myCommands.Append (com);
258 com = myCommands.Last();
259 if (com->GetType() != SMESHDS_RemoveNode) {
260 com = new SMESHDS_Command(SMESHDS_RemoveNode);
261 myCommands.Append (com);
264 com->RemoveNode (ID);
267 //=======================================================================
270 //=======================================================================
271 void SMESHDS_Script::RemoveElement(const Standard_Integer ElementID)
273 Handle(SMESHDS_Command) com;
274 if (myCommands.IsEmpty()) {
275 com = new SMESHDS_Command(SMESHDS_RemoveElement);
276 myCommands.Append (com);
279 com = myCommands.Last();
280 if (com->GetType() != SMESHDS_RemoveElement) {
281 com = new SMESHDS_Command(SMESHDS_RemoveElement);
282 myCommands.Append (com);
285 com->RemoveElement (ElementID);
288 //=======================================================================
291 //=======================================================================
292 void SMESHDS_Script::Clear()
297 //=======================================================================
300 //=======================================================================
301 const SMESHDS_ListOfCommand& SMESHDS_Script::GetCommands()