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"
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)
92 getCommand(SMESHDS_AddNode)->AddNode(NewNodeID, x, y, z);
95 //=======================================================================
98 //=======================================================================
99 void SMESHDS_Script::AddEdge(int NewEdgeID, int idnode1, int idnode2)
101 if(myIsEmbeddedMode){
105 getCommand(SMESHDS_AddEdge)->AddEdge(NewEdgeID, idnode1, idnode2);
108 //=======================================================================
111 //=======================================================================
112 void SMESHDS_Script::AddFace(int NewFaceID,
113 int idnode1, int idnode2, int idnode3)
115 if(myIsEmbeddedMode){
119 getCommand(SMESHDS_AddTriangle)->AddFace(NewFaceID,
120 idnode1, idnode2, idnode3);
123 //=======================================================================
126 //=======================================================================
127 void SMESHDS_Script::AddFace(int NewFaceID,
128 int idnode1, int idnode2,
129 int idnode3, int idnode4)
131 if(myIsEmbeddedMode){
135 getCommand(SMESHDS_AddQuadrangle)->AddFace(NewFaceID,
140 //=======================================================================
143 //=======================================================================
144 void SMESHDS_Script::AddVolume(int NewID,
145 int idnode1, int idnode2,
146 int idnode3, int idnode4)
148 if(myIsEmbeddedMode){
152 getCommand(SMESHDS_AddTetrahedron)->AddVolume(NewID,
157 //=======================================================================
160 //=======================================================================
161 void SMESHDS_Script::AddVolume(int NewID,
162 int idnode1, int idnode2,
163 int idnode3, int idnode4, int idnode5)
165 if(myIsEmbeddedMode){
169 getCommand(SMESHDS_AddPyramid)->AddVolume(NewID,
171 idnode3, idnode4, idnode5);
174 //=======================================================================
177 //=======================================================================
178 void SMESHDS_Script::AddVolume(int NewID,
179 int idnode1, int idnode2, int idnode3,
180 int idnode4, int idnode5, int idnode6)
182 if(myIsEmbeddedMode){
186 getCommand(SMESHDS_AddPrism)->AddVolume(NewID,
187 idnode1, idnode2, idnode3,
188 idnode4, idnode5, idnode6);
191 //=======================================================================
194 //=======================================================================
195 void SMESHDS_Script::AddVolume(int NewID,
196 int idnode1, int idnode2, int idnode3, int idnode4,
197 int idnode5, int idnode6, int idnode7, int idnode8)
199 if(myIsEmbeddedMode){
203 getCommand(SMESHDS_AddHexahedron)->AddVolume(NewID,
204 idnode1, idnode2, idnode3, idnode4,
205 idnode5, idnode6, idnode7, idnode8);
208 //=======================================================================
209 //function : AddPolygonalFace
211 //=======================================================================
212 void SMESHDS_Script::AddPolygonalFace (int NewFaceID, std::vector<int> nodes_ids)
214 if(myIsEmbeddedMode){
218 getCommand(SMESHDS_AddPolygon)->AddPolygonalFace(NewFaceID, nodes_ids);
221 //=======================================================================
222 //function : AddPolyhedralVolume
224 //=======================================================================
225 void SMESHDS_Script::AddPolyhedralVolume (int NewID,
226 std::vector<int> nodes_ids,
227 std::vector<int> quantities)
229 if(myIsEmbeddedMode){
233 getCommand(SMESHDS_AddPolyhedron)->AddPolyhedralVolume
234 (NewID, nodes_ids, quantities);
237 //=======================================================================
240 //=======================================================================
241 void SMESHDS_Script::MoveNode(int NewNodeID, double x, double y, double z)
243 if(myIsEmbeddedMode){
247 getCommand(SMESHDS_MoveNode)->MoveNode(NewNodeID, x, y, z);
250 //=======================================================================
253 //=======================================================================
254 void SMESHDS_Script::RemoveNode(int ID)
256 if(myIsEmbeddedMode){
260 getCommand(SMESHDS_RemoveNode)->RemoveNode(ID);
263 //=======================================================================
266 //=======================================================================
267 void SMESHDS_Script::RemoveElement(int ElementID)
269 if(myIsEmbeddedMode){
273 getCommand(SMESHDS_RemoveElement)->RemoveElement(ElementID);
276 //=======================================================================
277 //function : ChangeElementNodes
279 //=======================================================================
281 void SMESHDS_Script::ChangeElementNodes(int ElementID, int nodes[], int nbnodes)
283 if(myIsEmbeddedMode){
287 getCommand(SMESHDS_ChangeElementNodes)->ChangeElementNodes( ElementID, nodes, nbnodes );
290 //=======================================================================
291 //function : ChangePolyhedronNodes
293 //=======================================================================
294 void SMESHDS_Script::ChangePolyhedronNodes (const int ElementID,
295 std::vector<int> nodes_ids,
296 std::vector<int> quantities)
298 if(myIsEmbeddedMode){
302 getCommand(SMESHDS_ChangePolyhedronNodes)->ChangePolyhedronNodes
303 (ElementID, nodes_ids, quantities);
306 //=======================================================================
307 //function : Renumber
309 //=======================================================================
310 void SMESHDS_Script::Renumber (const bool isNodes, const int startID, const int deltaID)
312 if(myIsEmbeddedMode){
316 getCommand(SMESHDS_Renumber)->Renumber( isNodes, startID, deltaID );
319 //=======================================================================
322 //=======================================================================
323 void SMESHDS_Script::Clear()
325 list<SMESHDS_Command*>::iterator anIt = myCommands.begin();
326 for (; anIt != myCommands.end(); anIt++) {
332 //=======================================================================
335 //=======================================================================
336 const list<SMESHDS_Command*>& SMESHDS_Script::GetCommands()
342 //********************************************************************
343 //***** Methods for quadratic elements ******
344 //********************************************************************
346 //=======================================================================
349 //=======================================================================
350 void SMESHDS_Script::AddEdge(int NewEdgeID, int n1, int n2, int n12)
352 if(myIsEmbeddedMode){
356 getCommand(SMESHDS_AddQuadEdge)->AddEdge(NewEdgeID, n1, n2, n12);
359 //=======================================================================
362 //=======================================================================
363 void SMESHDS_Script::AddFace(int NewFaceID, int n1, int n2, int n3,
364 int n12, int n23, int n31)
366 if(myIsEmbeddedMode){
370 getCommand(SMESHDS_AddQuadTriangle)->AddFace(NewFaceID, n1, n2, n3,
374 //=======================================================================
377 //=======================================================================
378 void SMESHDS_Script::AddFace(int NewFaceID, int n1, int n2, int n3, int n4,
379 int n12, int n23, int n34, int n41)
381 if(myIsEmbeddedMode){
385 getCommand(SMESHDS_AddQuadQuadrangle)->AddFace(NewFaceID, n1, n2, n3, n4,
389 //=======================================================================
390 //function : AddVolume
392 //=======================================================================
393 void SMESHDS_Script::AddVolume(int NewVolID, int n1, int n2, int n3, int n4,
394 int n12, int n23, int n31,
395 int n14, int n24, int n34)
397 if(myIsEmbeddedMode){
401 getCommand(SMESHDS_AddQuadTetrahedron)->AddVolume(NewVolID, n1, n2, n3, n4,
406 //=======================================================================
407 //function : AddVolume
409 //=======================================================================
410 void SMESHDS_Script::AddVolume(int NewVolID, int n1, int n2, int n3, int n4,
411 int n5, int n12, int n23, int n34, int n41,
412 int n15, int n25, int n35, int n45)
414 if(myIsEmbeddedMode){
418 getCommand(SMESHDS_AddQuadPyramid)->AddVolume(NewVolID, n1, n2, n3, n4, n5,
423 //=======================================================================
424 //function : AddVolume
426 //=======================================================================
427 void SMESHDS_Script::AddVolume(int NewVolID, int n1, int n2, int n3, int n4,
428 int n5,int n6, int n12, int n23, int n31,
429 int n45, int n56, int n64,
430 int n14, int n25, int n36)
432 if(myIsEmbeddedMode){
436 getCommand(SMESHDS_AddQuadPentahedron)->AddVolume(NewVolID, n1,n2,n3,n4,n5,n6,
442 //=======================================================================
443 //function : AddVolume
445 //=======================================================================
446 void SMESHDS_Script::AddVolume(int NewVolID, int n1, int n2, int n3,
447 int n4, int n5, int n6, int n7, int n8,
448 int n12, int n23, int n34, int n41,
449 int n56, int n67, int n78, int n85,
450 int n15, int n26, int n37, int n48)
452 if(myIsEmbeddedMode){
456 getCommand(SMESHDS_AddQuadHexahedron)->AddVolume(NewVolID, n1, n2, n3, n4,