1 // Copyright (C) 2007-2014 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, or (at your option) any later version.
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,
443 int n12, int n23, int n31, int nCenter)
445 if(myIsEmbeddedMode){
449 getCommand(SMESHDS_AddBiQuadTriangle)->AddFace(NewFaceID, n1, n2, n3,
450 n12, n23, n31, nCenter);
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)
460 if(myIsEmbeddedMode){
464 getCommand(SMESHDS_AddQuadQuadrangle)->AddFace(NewFaceID, n1, n2, n3, n4,
468 //=======================================================================
471 //=======================================================================
472 void SMESHDS_Script::AddFace(int NewFaceID, int n1, int n2, int n3, int n4,
473 int n12, int n23, int n34, int n41, int nCenter)
475 if(myIsEmbeddedMode){
479 getCommand(SMESHDS_AddBiQuadQuadrangle)->AddFace(NewFaceID, n1, n2, n3, n4,
480 n12, n23, n34, n41, nCenter);
483 //=======================================================================
484 //function : AddVolume
486 //=======================================================================
487 void SMESHDS_Script::AddVolume(int NewVolID, int n1, int n2, int n3, int n4,
488 int n12, int n23, int n31,
489 int n14, int n24, int n34)
491 if(myIsEmbeddedMode){
495 getCommand(SMESHDS_AddQuadTetrahedron)->AddVolume(NewVolID, n1, n2, n3, n4,
500 //=======================================================================
501 //function : AddVolume
503 //=======================================================================
504 void SMESHDS_Script::AddVolume(int NewVolID, int n1, int n2, int n3, int n4,
505 int n5, int n12, int n23, int n34, int n41,
506 int n15, int n25, int n35, int n45)
508 if(myIsEmbeddedMode){
512 getCommand(SMESHDS_AddQuadPyramid)->AddVolume(NewVolID, n1, n2, n3, n4, n5,
517 //=======================================================================
518 //function : AddVolume
520 //=======================================================================
521 void SMESHDS_Script::AddVolume(int NewVolID, int n1, int n2, int n3, int n4,
522 int n5,int n6, int n12, int n23, int n31,
523 int n45, int n56, int n64,
524 int n14, int n25, int n36)
526 if(myIsEmbeddedMode){
530 getCommand(SMESHDS_AddQuadPentahedron)->AddVolume(NewVolID, n1,n2,n3,n4,n5,n6,
536 //=======================================================================
537 //function : AddVolume
539 //=======================================================================
540 void SMESHDS_Script::AddVolume(int NewVolID, int n1, int n2, int n3,
541 int n4, int n5, int n6, int n7, int n8,
542 int n12, int n23, int n34, int n41,
543 int n56, int n67, int n78, int n85,
544 int n15, int n26, int n37, int n48)
546 if(myIsEmbeddedMode){
550 getCommand(SMESHDS_AddQuadHexahedron)->AddVolume(NewVolID, n1, n2, n3, n4,
557 //=======================================================================
558 //function : AddVolume
560 //=======================================================================
561 void SMESHDS_Script::AddVolume(int NewVolID, int n1, int n2, int n3,
562 int n4, int n5, int n6, int n7, int n8,
563 int n12, int n23, int n34, int n41,
564 int n56, int n67, int n78, int n85,
565 int n15, int n26, int n37, int n48,
566 int n1234,int n1256,int n2367,int n3478,
567 int n1458,int n5678,int nCenter)
569 if(myIsEmbeddedMode){
573 getCommand(SMESHDS_AddTriQuadHexa)->AddVolume(NewVolID, n1, n2, n3, n4,
578 n1234, n1256, n2367, n3478,
579 n1458, n5678, nCenter);