1 // Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 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
23 // SMESH SMESHDS : management of mesh data and SMESH document
24 // File : SMESH_Script.cxx
25 // Author : Yves FRICAUD, OCC
28 #include "SMESHDS_Script.hxx"
33 //=======================================================================
34 //function : Constructor
36 //=======================================================================
37 SMESHDS_Script::SMESHDS_Script(bool theIsEmbeddedMode):
38 myIsEmbeddedMode(theIsEmbeddedMode)
40 //cerr << "=========================== myIsEmbeddedMode " << myIsEmbeddedMode << endl;
43 //=======================================================================
44 //function : Destructor
46 //=======================================================================
47 SMESHDS_Script::~SMESHDS_Script()
52 //=======================================================================
53 void SMESHDS_Script::SetModified(bool theModified)
55 myIsModified = theModified;
58 //=======================================================================
59 bool SMESHDS_Script::IsModified()
64 //=======================================================================
65 //function : getCommand
67 //=======================================================================
68 SMESHDS_Command* SMESHDS_Script::getCommand(const SMESHDS_CommandType aType)
71 if (myCommands.empty())
73 com = new SMESHDS_Command(aType);
74 myCommands.insert(myCommands.end(),com);
78 com = myCommands.back();
79 if (com->GetType() != aType)
81 com = new SMESHDS_Command(aType);
82 myCommands.insert(myCommands.end(),com);
88 //=======================================================================
91 //=======================================================================
92 void SMESHDS_Script::AddNode(int NewNodeID, double x, double y, double z)
98 getCommand(SMESHDS_AddNode)->AddNode(NewNodeID, x, y, z);
101 //=======================================================================
104 //=======================================================================
105 void SMESHDS_Script::Add0DElement (int New0DElementID, int idnode)
107 if (myIsEmbeddedMode) {
111 getCommand(SMESHDS_Add0DElement)->Add0DElement(New0DElementID, idnode);
114 //=======================================================================
117 //=======================================================================
118 void SMESHDS_Script::AddEdge(int NewEdgeID, int idnode1, int idnode2)
120 if(myIsEmbeddedMode){
124 getCommand(SMESHDS_AddEdge)->AddEdge(NewEdgeID, idnode1, idnode2);
127 //=======================================================================
130 //=======================================================================
131 void SMESHDS_Script::AddFace(int NewFaceID,
132 int idnode1, int idnode2, int idnode3)
134 if(myIsEmbeddedMode){
138 getCommand(SMESHDS_AddTriangle)->AddFace(NewFaceID,
139 idnode1, idnode2, idnode3);
142 //=======================================================================
145 //=======================================================================
146 void SMESHDS_Script::AddFace(int NewFaceID,
147 int idnode1, int idnode2,
148 int idnode3, int idnode4)
150 if(myIsEmbeddedMode){
154 getCommand(SMESHDS_AddQuadrangle)->AddFace(NewFaceID,
159 //=======================================================================
162 //=======================================================================
163 void SMESHDS_Script::AddVolume(int NewID,
164 int idnode1, int idnode2,
165 int idnode3, int idnode4)
167 if(myIsEmbeddedMode){
171 getCommand(SMESHDS_AddTetrahedron)->AddVolume(NewID,
176 //=======================================================================
179 //=======================================================================
180 void SMESHDS_Script::AddVolume(int NewID,
181 int idnode1, int idnode2,
182 int idnode3, int idnode4, int idnode5)
184 if(myIsEmbeddedMode){
188 getCommand(SMESHDS_AddPyramid)->AddVolume(NewID,
190 idnode3, idnode4, idnode5);
193 //=======================================================================
196 //=======================================================================
197 void SMESHDS_Script::AddVolume(int NewID,
198 int idnode1, int idnode2, int idnode3,
199 int idnode4, int idnode5, int idnode6)
201 if(myIsEmbeddedMode){
205 getCommand(SMESHDS_AddPrism)->AddVolume(NewID,
206 idnode1, idnode2, idnode3,
207 idnode4, idnode5, idnode6);
210 //=======================================================================
213 //=======================================================================
214 void SMESHDS_Script::AddVolume(int NewID,
215 int idnode1, int idnode2, int idnode3, int idnode4,
216 int idnode5, int idnode6, int idnode7, int idnode8)
218 if(myIsEmbeddedMode){
222 getCommand(SMESHDS_AddHexahedron)->AddVolume(NewID,
223 idnode1, idnode2, idnode3, idnode4,
224 idnode5, idnode6, idnode7, idnode8);
227 //=======================================================================
230 //=======================================================================
231 void SMESHDS_Script::AddVolume(int NewVolID, int idnode1, int idnode2, int idnode3,
232 int idnode4, int idnode5, int idnode6, int idnode7, int idnode8,
233 int idnode9, int idnode10, int idnode11, int idnode12)
235 if(myIsEmbeddedMode){
239 getCommand(SMESHDS_AddHexagonalPrism)->AddVolume(NewVolID,
240 idnode1, idnode2, idnode3, idnode4,
241 idnode5, idnode6, idnode7, idnode8,
242 idnode9, idnode10, idnode11, idnode12);
245 //=======================================================================
246 //function : AddPolygonalFace
248 //=======================================================================
249 void SMESHDS_Script::AddPolygonalFace (int NewFaceID, const std::vector<int>& nodes_ids)
251 if(myIsEmbeddedMode){
255 getCommand(SMESHDS_AddPolygon)->AddPolygonalFace(NewFaceID, nodes_ids);
258 //=======================================================================
259 //function : AddPolyhedralVolume
261 //=======================================================================
262 void SMESHDS_Script::AddPolyhedralVolume (int NewID,
263 const std::vector<int>& nodes_ids,
264 const std::vector<int>& quantities)
266 if(myIsEmbeddedMode){
270 getCommand(SMESHDS_AddPolyhedron)->AddPolyhedralVolume
271 (NewID, nodes_ids, quantities);
274 //=======================================================================
276 //purpose : Record adding a Ball
277 //=======================================================================
279 void SMESHDS_Script::AddBall(int NewBallID, int node, double diameter)
281 if ( myIsEmbeddedMode )
284 getCommand(SMESHDS_AddBall)->AddBall(NewBallID, node, diameter);
287 //=======================================================================
290 //=======================================================================
291 void SMESHDS_Script::MoveNode(int NewNodeID, double x, double y, double z)
293 if(myIsEmbeddedMode){
297 getCommand(SMESHDS_MoveNode)->MoveNode(NewNodeID, x, y, z);
300 //=======================================================================
303 //=======================================================================
304 void SMESHDS_Script::RemoveNode(int ID)
306 if(myIsEmbeddedMode){
310 getCommand(SMESHDS_RemoveNode)->RemoveNode(ID);
313 //=======================================================================
316 //=======================================================================
317 void SMESHDS_Script::RemoveElement(int ElementID)
319 if(myIsEmbeddedMode){
323 getCommand(SMESHDS_RemoveElement)->RemoveElement(ElementID);
326 //=======================================================================
327 //function : ChangeElementNodes
329 //=======================================================================
331 void SMESHDS_Script::ChangeElementNodes(int ElementID, int nodes[], int nbnodes)
333 if(myIsEmbeddedMode){
337 getCommand(SMESHDS_ChangeElementNodes)->ChangeElementNodes( ElementID, nodes, nbnodes );
340 //=======================================================================
341 //function : ChangePolyhedronNodes
343 //=======================================================================
344 void SMESHDS_Script::ChangePolyhedronNodes (const int ElementID,
345 const std::vector<int>& nodes_ids,
346 const std::vector<int>& quantities)
348 if(myIsEmbeddedMode){
352 getCommand(SMESHDS_ChangePolyhedronNodes)->ChangePolyhedronNodes
353 (ElementID, nodes_ids, quantities);
356 //=======================================================================
357 //function : Renumber
359 //=======================================================================
360 void SMESHDS_Script::Renumber (const bool isNodes, const int startID, const int deltaID)
362 if(myIsEmbeddedMode){
366 getCommand(SMESHDS_Renumber)->Renumber( isNodes, startID, deltaID );
369 //=======================================================================
370 //function : ClearMesh
372 //=======================================================================
373 void SMESHDS_Script::ClearMesh ()
375 if(myIsEmbeddedMode){
379 Clear();// previous commands become useless to reproduce on client side
380 getCommand(SMESHDS_ClearAll);
383 //=======================================================================
386 //=======================================================================
387 void SMESHDS_Script::Clear()
389 list<SMESHDS_Command*>::iterator anIt = myCommands.begin();
390 for (; anIt != myCommands.end(); anIt++) {
396 //=======================================================================
399 //=======================================================================
400 const list<SMESHDS_Command*>& SMESHDS_Script::GetCommands()
406 //********************************************************************
407 //***** Methods for quadratic elements ******
408 //********************************************************************
410 //=======================================================================
413 //=======================================================================
414 void SMESHDS_Script::AddEdge(int NewEdgeID, int n1, int n2, int n12)
416 if(myIsEmbeddedMode){
420 getCommand(SMESHDS_AddQuadEdge)->AddEdge(NewEdgeID, n1, n2, n12);
423 //=======================================================================
426 //=======================================================================
427 void SMESHDS_Script::AddFace(int NewFaceID, int n1, int n2, int n3,
428 int n12, int n23, int n31)
430 if(myIsEmbeddedMode){
434 getCommand(SMESHDS_AddQuadTriangle)->AddFace(NewFaceID, n1, n2, n3,
438 //=======================================================================
441 //=======================================================================
442 void SMESHDS_Script::AddFace(int NewFaceID, int n1, int n2, int n3, int n4,
443 int n12, int n23, int n34, int n41)
445 if(myIsEmbeddedMode){
449 getCommand(SMESHDS_AddQuadQuadrangle)->AddFace(NewFaceID, n1, n2, n3, n4,
453 //=======================================================================
456 //=======================================================================
457 void SMESHDS_Script::AddFace(int NewFaceID, int n1, int n2, int n3, int n4,
458 int n12, int n23, int n34, int n41, int nCenter)
460 if(myIsEmbeddedMode){
464 getCommand(SMESHDS_AddBiQuadQuadrangle)->AddFace(NewFaceID, n1, n2, n3, n4,
465 n12, n23, n34, n41, nCenter);
468 //=======================================================================
469 //function : AddVolume
471 //=======================================================================
472 void SMESHDS_Script::AddVolume(int NewVolID, int n1, int n2, int n3, int n4,
473 int n12, int n23, int n31,
474 int n14, int n24, int n34)
476 if(myIsEmbeddedMode){
480 getCommand(SMESHDS_AddQuadTetrahedron)->AddVolume(NewVolID, n1, n2, n3, n4,
485 //=======================================================================
486 //function : AddVolume
488 //=======================================================================
489 void SMESHDS_Script::AddVolume(int NewVolID, int n1, int n2, int n3, int n4,
490 int n5, int n12, int n23, int n34, int n41,
491 int n15, int n25, int n35, int n45)
493 if(myIsEmbeddedMode){
497 getCommand(SMESHDS_AddQuadPyramid)->AddVolume(NewVolID, n1, n2, n3, n4, n5,
502 //=======================================================================
503 //function : AddVolume
505 //=======================================================================
506 void SMESHDS_Script::AddVolume(int NewVolID, int n1, int n2, int n3, int n4,
507 int n5,int n6, int n12, int n23, int n31,
508 int n45, int n56, int n64,
509 int n14, int n25, int n36)
511 if(myIsEmbeddedMode){
515 getCommand(SMESHDS_AddQuadPentahedron)->AddVolume(NewVolID, n1,n2,n3,n4,n5,n6,
521 //=======================================================================
522 //function : AddVolume
524 //=======================================================================
525 void SMESHDS_Script::AddVolume(int NewVolID, int n1, int n2, int n3,
526 int n4, int n5, int n6, int n7, int n8,
527 int n12, int n23, int n34, int n41,
528 int n56, int n67, int n78, int n85,
529 int n15, int n26, int n37, int n48)
531 if(myIsEmbeddedMode){
535 getCommand(SMESHDS_AddQuadHexahedron)->AddVolume(NewVolID, n1, n2, n3, n4,
542 //=======================================================================
543 //function : AddVolume
545 //=======================================================================
546 void SMESHDS_Script::AddVolume(int NewVolID, int n1, int n2, int n3,
547 int n4, int n5, int n6, int n7, int n8,
548 int n12, int n23, int n34, int n41,
549 int n56, int n67, int n78, int n85,
550 int n15, int n26, int n37, int n48,
551 int n1234,int n1256,int n2367,int n3478,
552 int n1458,int n5678,int nCenter)
554 if(myIsEmbeddedMode){
558 getCommand(SMESHDS_AddTriQuadHexa)->AddVolume(NewVolID, n1, n2, n3, n4,
563 n1234, n1256, n2367, n3478,
564 n1458, n5678, nCenter);