1 // Copyright (C) 2007-2020 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 : AddQuadPolygonalFace
261 //=======================================================================
262 void SMESHDS_Script::AddQuadPolygonalFace(int NewFaceID, const std::vector<int>& nodes_ids)
264 if(myIsEmbeddedMode){
268 getCommand(SMESHDS_AddQuadPolygon)->AddQuadPolygonalFace(NewFaceID, nodes_ids);
271 //=======================================================================
272 //function : AddPolyhedralVolume
274 //=======================================================================
275 void SMESHDS_Script::AddPolyhedralVolume (int NewID,
276 const std::vector<int>& nodes_ids,
277 const std::vector<int>& quantities)
279 if(myIsEmbeddedMode){
283 getCommand(SMESHDS_AddPolyhedron)->AddPolyhedralVolume
284 (NewID, nodes_ids, quantities);
287 //=======================================================================
289 //purpose : Record adding a Ball
290 //=======================================================================
292 void SMESHDS_Script::AddBall(int NewBallID, int node, double diameter)
294 if ( myIsEmbeddedMode )
297 getCommand(SMESHDS_AddBall)->AddBall(NewBallID, node, diameter);
300 //=======================================================================
303 //=======================================================================
304 void SMESHDS_Script::MoveNode(int NewNodeID, double x, double y, double z)
306 if(myIsEmbeddedMode){
310 getCommand(SMESHDS_MoveNode)->MoveNode(NewNodeID, x, y, z);
313 //=======================================================================
316 //=======================================================================
317 void SMESHDS_Script::RemoveNode(int ID)
319 if(myIsEmbeddedMode){
323 getCommand(SMESHDS_RemoveNode)->RemoveNode(ID);
326 //=======================================================================
329 //=======================================================================
330 void SMESHDS_Script::RemoveElement(int ElementID)
332 if(myIsEmbeddedMode){
336 getCommand(SMESHDS_RemoveElement)->RemoveElement(ElementID);
339 //=======================================================================
340 //function : ChangeElementNodes
342 //=======================================================================
344 void SMESHDS_Script::ChangeElementNodes(int ElementID, int nodes[], int nbnodes)
346 if(myIsEmbeddedMode){
350 getCommand(SMESHDS_ChangeElementNodes)->ChangeElementNodes( ElementID, nodes, nbnodes );
353 //=======================================================================
354 //function : ChangePolyhedronNodes
356 //=======================================================================
357 void SMESHDS_Script::ChangePolyhedronNodes (const int ElementID,
358 const std::vector<int>& nodes_ids,
359 const std::vector<int>& quantities)
361 if(myIsEmbeddedMode){
365 getCommand(SMESHDS_ChangePolyhedronNodes)->ChangePolyhedronNodes
366 (ElementID, nodes_ids, quantities);
369 //=======================================================================
370 //function : Renumber
372 //=======================================================================
373 void SMESHDS_Script::Renumber (const bool isNodes, const int startID, const int deltaID)
375 if(myIsEmbeddedMode){
379 getCommand(SMESHDS_Renumber)->Renumber( isNodes, startID, deltaID );
382 //=======================================================================
383 //function : ClearMesh
385 //=======================================================================
386 void SMESHDS_Script::ClearMesh ()
388 if(myIsEmbeddedMode){
392 Clear();// previous commands become useless to reproduce on client side
393 getCommand(SMESHDS_ClearAll);
396 //=======================================================================
399 //=======================================================================
400 void SMESHDS_Script::Clear()
402 list<SMESHDS_Command*>::iterator anIt = myCommands.begin();
403 for (; anIt != myCommands.end(); anIt++) {
409 //=======================================================================
412 //=======================================================================
413 const list<SMESHDS_Command*>& SMESHDS_Script::GetCommands()
419 //********************************************************************
420 //***** Methods for quadratic elements ******
421 //********************************************************************
423 //=======================================================================
426 //=======================================================================
427 void SMESHDS_Script::AddEdge(int NewEdgeID, int n1, int n2, int n12)
429 if(myIsEmbeddedMode){
433 getCommand(SMESHDS_AddQuadEdge)->AddEdge(NewEdgeID, n1, n2, n12);
436 //=======================================================================
439 //=======================================================================
440 void SMESHDS_Script::AddFace(int NewFaceID, int n1, int n2, int n3,
441 int n12, int n23, int n31)
443 if(myIsEmbeddedMode){
447 getCommand(SMESHDS_AddQuadTriangle)->AddFace(NewFaceID, n1, n2, n3,
451 //=======================================================================
454 //=======================================================================
455 void SMESHDS_Script::AddFace(int NewFaceID, int n1, int n2, int n3,
456 int n12, int n23, int n31, int nCenter)
458 if(myIsEmbeddedMode){
462 getCommand(SMESHDS_AddBiQuadTriangle)->AddFace(NewFaceID, n1, n2, n3,
463 n12, n23, n31, nCenter);
466 //=======================================================================
469 //=======================================================================
470 void SMESHDS_Script::AddFace(int NewFaceID, int n1, int n2, int n3, int n4,
471 int n12, int n23, int n34, int n41)
473 if(myIsEmbeddedMode){
477 getCommand(SMESHDS_AddQuadQuadrangle)->AddFace(NewFaceID, n1, n2, n3, n4,
481 //=======================================================================
484 //=======================================================================
485 void SMESHDS_Script::AddFace(int NewFaceID, int n1, int n2, int n3, int n4,
486 int n12, int n23, int n34, int n41, int nCenter)
488 if(myIsEmbeddedMode){
492 getCommand(SMESHDS_AddBiQuadQuadrangle)->AddFace(NewFaceID, n1, n2, n3, n4,
493 n12, n23, n34, n41, nCenter);
496 //=======================================================================
497 //function : AddVolume
499 //=======================================================================
500 void SMESHDS_Script::AddVolume(int NewVolID, int n1, int n2, int n3, int n4,
501 int n12, int n23, int n31,
502 int n14, int n24, int n34)
504 if(myIsEmbeddedMode){
508 getCommand(SMESHDS_AddQuadTetrahedron)->AddVolume(NewVolID, n1, n2, n3, n4,
513 //=======================================================================
514 //function : AddVolume
516 //=======================================================================
517 void SMESHDS_Script::AddVolume(int NewVolID, int n1, int n2, int n3, int n4,
518 int n5, int n12, int n23, int n34, int n41,
519 int n15, int n25, int n35, int n45)
521 if(myIsEmbeddedMode){
525 getCommand(SMESHDS_AddQuadPyramid)->AddVolume(NewVolID, n1, n2, n3, n4, n5,
530 //=======================================================================
531 //function : AddVolume
533 //=======================================================================
534 void SMESHDS_Script::AddVolume(int NewVolID, int n1, int n2, int n3, int n4,
535 int n5,int n6, int n12, int n23, int n31,
536 int n45, int n56, int n64,
537 int n14, int n25, int n36)
539 if(myIsEmbeddedMode){
543 getCommand(SMESHDS_AddQuadPentahedron)->AddVolume(NewVolID, n1,n2,n3,n4,n5,n6,
549 //=======================================================================
550 //function : AddVolume
552 //=======================================================================
553 void SMESHDS_Script::AddVolume(int NewVolID, int n1, int n2, int n3, int n4,
554 int n5,int n6, int n12, int n23, int n31,
555 int n45, int n56, int n64,
556 int n14, int n25, int n36,
557 int n1245, int n2356, int n1346)
559 if(myIsEmbeddedMode){
563 getCommand(SMESHDS_AddBiQuadPentahedron)->AddVolume(NewVolID, n1,n2,n3,n4,n5,n6,
567 n1245, n2356, n1346);
570 //=======================================================================
571 //function : AddVolume
573 //=======================================================================
574 void SMESHDS_Script::AddVolume(int NewVolID, int n1, int n2, int n3,
575 int n4, int n5, int n6, int n7, int n8,
576 int n12, int n23, int n34, int n41,
577 int n56, int n67, int n78, int n85,
578 int n15, int n26, int n37, int n48)
580 if(myIsEmbeddedMode){
584 getCommand(SMESHDS_AddQuadHexahedron)->AddVolume(NewVolID, n1, n2, n3, n4,
591 //=======================================================================
592 //function : AddVolume
594 //=======================================================================
595 void SMESHDS_Script::AddVolume(int NewVolID, int n1, int n2, int n3,
596 int n4, int n5, int n6, int n7, int n8,
597 int n12, int n23, int n34, int n41,
598 int n56, int n67, int n78, int n85,
599 int n15, int n26, int n37, int n48,
600 int n1234,int n1256,int n2367,int n3478,
601 int n1458,int n5678,int nCenter)
603 if(myIsEmbeddedMode){
607 getCommand(SMESHDS_AddTriQuadHexa)->AddVolume(NewVolID, n1, n2, n3, n4,
612 n1234, n1256, n2367, n3478,
613 n1458, n5678, nCenter);