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.salome-platform.org/ or email : webmaster.salome@opencascade.com
24 // File : SMESH_Script.cxx
25 // Author : Yves FRICAUD, OCC
29 #include "SMESHDS_Script.hxx"
33 //=======================================================================
34 //function : Constructor
36 //=======================================================================
37 SMESHDS_Script::SMESHDS_Script(bool theIsEmbeddedMode):
38 myIsEmbeddedMode(theIsEmbeddedMode)
41 //=======================================================================
42 //function : Destructor
44 //=======================================================================
45 SMESHDS_Script::~SMESHDS_Script()
50 //=======================================================================
51 void SMESHDS_Script::SetModified(bool theModified)
53 myIsModified = theModified;
56 //=======================================================================
57 bool SMESHDS_Script::IsModified()
62 //=======================================================================
63 //function : getCommand
65 //=======================================================================
66 SMESHDS_Command* SMESHDS_Script::getCommand(const SMESHDS_CommandType aType)
69 if (myCommands.empty())
71 com = new SMESHDS_Command(aType);
72 myCommands.insert(myCommands.end(),com);
76 com = myCommands.back();
77 if (com->GetType() != aType)
79 com = new SMESHDS_Command(aType);
80 myCommands.insert(myCommands.end(),com);
86 //=======================================================================
89 //=======================================================================
90 void SMESHDS_Script::AddNode(int NewNodeID, double x, double y, double z)
96 getCommand(SMESHDS_AddNode)->AddNode(NewNodeID, x, y, z);
99 //=======================================================================
102 //=======================================================================
103 void SMESHDS_Script::AddEdge(int NewEdgeID, int idnode1, int idnode2)
105 if(myIsEmbeddedMode){
109 getCommand(SMESHDS_AddEdge)->AddEdge(NewEdgeID, idnode1, idnode2);
112 //=======================================================================
115 //=======================================================================
116 void SMESHDS_Script::AddFace(int NewFaceID,
117 int idnode1, int idnode2, int idnode3)
119 if(myIsEmbeddedMode){
123 getCommand(SMESHDS_AddTriangle)->AddFace(NewFaceID,
124 idnode1, idnode2, idnode3);
127 //=======================================================================
130 //=======================================================================
131 void SMESHDS_Script::AddFace(int NewFaceID,
132 int idnode1, int idnode2,
133 int idnode3, int idnode4)
135 if(myIsEmbeddedMode){
139 getCommand(SMESHDS_AddQuadrangle)->AddFace(NewFaceID,
144 //=======================================================================
147 //=======================================================================
148 void SMESHDS_Script::AddVolume(int NewID,
149 int idnode1, int idnode2,
150 int idnode3, int idnode4)
152 if(myIsEmbeddedMode){
156 getCommand(SMESHDS_AddTetrahedron)->AddVolume(NewID,
161 //=======================================================================
164 //=======================================================================
165 void SMESHDS_Script::AddVolume(int NewID,
166 int idnode1, int idnode2,
167 int idnode3, int idnode4, int idnode5)
169 if(myIsEmbeddedMode){
173 getCommand(SMESHDS_AddPyramid)->AddVolume(NewID,
175 idnode3, idnode4, idnode5);
178 //=======================================================================
181 //=======================================================================
182 void SMESHDS_Script::AddVolume(int NewID,
183 int idnode1, int idnode2, int idnode3,
184 int idnode4, int idnode5, int idnode6)
186 if(myIsEmbeddedMode){
190 getCommand(SMESHDS_AddPrism)->AddVolume(NewID,
191 idnode1, idnode2, idnode3,
192 idnode4, idnode5, idnode6);
195 //=======================================================================
198 //=======================================================================
199 void SMESHDS_Script::AddVolume(int NewID,
200 int idnode1, int idnode2, int idnode3, int idnode4,
201 int idnode5, int idnode6, int idnode7, int idnode8)
203 if(myIsEmbeddedMode){
207 getCommand(SMESHDS_AddHexahedron)->AddVolume(NewID,
208 idnode1, idnode2, idnode3, idnode4,
209 idnode5, idnode6, idnode7, idnode8);
212 //=======================================================================
213 //function : AddPolygonalFace
215 //=======================================================================
216 void SMESHDS_Script::AddPolygonalFace (int NewFaceID, std::vector<int> nodes_ids)
218 if(myIsEmbeddedMode){
222 getCommand(SMESHDS_AddPolygon)->AddPolygonalFace(NewFaceID, nodes_ids);
225 //=======================================================================
226 //function : AddPolyhedralVolume
228 //=======================================================================
229 void SMESHDS_Script::AddPolyhedralVolume (int NewID,
230 std::vector<int> nodes_ids,
231 std::vector<int> quantities)
233 if(myIsEmbeddedMode){
237 getCommand(SMESHDS_AddPolyhedron)->AddPolyhedralVolume
238 (NewID, nodes_ids, quantities);
241 //=======================================================================
244 //=======================================================================
245 void SMESHDS_Script::MoveNode(int NewNodeID, double x, double y, double z)
247 if(myIsEmbeddedMode){
251 getCommand(SMESHDS_MoveNode)->MoveNode(NewNodeID, x, y, z);
254 //=======================================================================
257 //=======================================================================
258 void SMESHDS_Script::RemoveNode(int ID)
260 if(myIsEmbeddedMode){
264 getCommand(SMESHDS_RemoveNode)->RemoveNode(ID);
267 //=======================================================================
270 //=======================================================================
271 void SMESHDS_Script::RemoveElement(int ElementID)
273 if(myIsEmbeddedMode){
277 getCommand(SMESHDS_RemoveElement)->RemoveElement(ElementID);
280 //=======================================================================
281 //function : ChangeElementNodes
283 //=======================================================================
285 void SMESHDS_Script::ChangeElementNodes(int ElementID, int nodes[], int nbnodes)
287 if(myIsEmbeddedMode){
291 getCommand(SMESHDS_ChangeElementNodes)->ChangeElementNodes( ElementID, nodes, nbnodes );
294 //=======================================================================
295 //function : ChangePolyhedronNodes
297 //=======================================================================
298 void SMESHDS_Script::ChangePolyhedronNodes (const int ElementID,
299 std::vector<int> nodes_ids,
300 std::vector<int> quantities)
302 if(myIsEmbeddedMode){
306 getCommand(SMESHDS_ChangePolyhedronNodes)->ChangePolyhedronNodes
307 (ElementID, nodes_ids, quantities);
310 //=======================================================================
311 //function : Renumber
313 //=======================================================================
314 void SMESHDS_Script::Renumber (const bool isNodes, const int startID, const int deltaID)
316 if(myIsEmbeddedMode){
320 getCommand(SMESHDS_Renumber)->Renumber( isNodes, startID, deltaID );
323 //=======================================================================
326 //=======================================================================
327 void SMESHDS_Script::Clear()
329 list<SMESHDS_Command*>::iterator anIt = myCommands.begin();
330 for (; anIt != myCommands.end(); anIt++) {
336 //=======================================================================
339 //=======================================================================
340 const list<SMESHDS_Command*>& SMESHDS_Script::GetCommands()
346 //********************************************************************
347 //***** Methods for quadratic elements ******
348 //********************************************************************
350 //=======================================================================
353 //=======================================================================
354 void SMESHDS_Script::AddEdge(int NewEdgeID, int n1, int n2, int n12)
356 if(myIsEmbeddedMode){
360 getCommand(SMESHDS_AddQuadEdge)->AddEdge(NewEdgeID, n1, n2, n12);
363 //=======================================================================
366 //=======================================================================
367 void SMESHDS_Script::AddFace(int NewFaceID, int n1, int n2, int n3,
368 int n12, int n23, int n31)
370 if(myIsEmbeddedMode){
374 getCommand(SMESHDS_AddQuadTriangle)->AddFace(NewFaceID, n1, n2, n3,
378 //=======================================================================
381 //=======================================================================
382 void SMESHDS_Script::AddFace(int NewFaceID, int n1, int n2, int n3, int n4,
383 int n12, int n23, int n34, int n41)
385 if(myIsEmbeddedMode){
389 getCommand(SMESHDS_AddQuadQuadrangle)->AddFace(NewFaceID, n1, n2, n3, n4,
393 //=======================================================================
394 //function : AddVolume
396 //=======================================================================
397 void SMESHDS_Script::AddVolume(int NewVolID, int n1, int n2, int n3, int n4,
398 int n12, int n23, int n31,
399 int n14, int n24, int n34)
401 if(myIsEmbeddedMode){
405 getCommand(SMESHDS_AddQuadTetrahedron)->AddVolume(NewVolID, n1, n2, n3, n4,
410 //=======================================================================
411 //function : AddVolume
413 //=======================================================================
414 void SMESHDS_Script::AddVolume(int NewVolID, int n1, int n2, int n3, int n4,
415 int n5, int n12, int n23, int n34, int n41,
416 int n15, int n25, int n35, int n45)
418 if(myIsEmbeddedMode){
422 getCommand(SMESHDS_AddQuadPyramid)->AddVolume(NewVolID, n1, n2, n3, n4, n5,
427 //=======================================================================
428 //function : AddVolume
430 //=======================================================================
431 void SMESHDS_Script::AddVolume(int NewVolID, int n1, int n2, int n3, int n4,
432 int n5,int n6, int n12, int n23, int n31,
433 int n45, int n56, int n64,
434 int n14, int n25, int n36)
436 if(myIsEmbeddedMode){
440 getCommand(SMESHDS_AddQuadPentahedron)->AddVolume(NewVolID, n1,n2,n3,n4,n5,n6,
446 //=======================================================================
447 //function : AddVolume
449 //=======================================================================
450 void SMESHDS_Script::AddVolume(int NewVolID, int n1, int n2, int n3,
451 int n4, int n5, int n6, int n7, int n8,
452 int n12, int n23, int n34, int n41,
453 int n56, int n67, int n78, int n85,
454 int n15, int n26, int n37, int n48)
456 if(myIsEmbeddedMode){
460 getCommand(SMESHDS_AddQuadHexahedron)->AddVolume(NewVolID, n1, n2, n3, n4,