1 // Copyright (C) 2007-2011 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
29 #include "SMESHDS_Script.hxx"
34 //=======================================================================
35 //function : Constructor
37 //=======================================================================
38 SMESHDS_Script::SMESHDS_Script(bool theIsEmbeddedMode):
39 myIsEmbeddedMode(theIsEmbeddedMode)
41 //cerr << "=========================== myIsEmbeddedMode " << myIsEmbeddedMode << endl;
44 //=======================================================================
45 //function : Destructor
47 //=======================================================================
48 SMESHDS_Script::~SMESHDS_Script()
53 //=======================================================================
54 void SMESHDS_Script::SetModified(bool theModified)
56 myIsModified = theModified;
59 //=======================================================================
60 bool SMESHDS_Script::IsModified()
65 //=======================================================================
66 //function : getCommand
68 //=======================================================================
69 SMESHDS_Command* SMESHDS_Script::getCommand(const SMESHDS_CommandType aType)
72 if (myCommands.empty())
74 com = new SMESHDS_Command(aType);
75 myCommands.insert(myCommands.end(),com);
79 com = myCommands.back();
80 if (com->GetType() != aType)
82 com = new SMESHDS_Command(aType);
83 myCommands.insert(myCommands.end(),com);
89 //=======================================================================
92 //=======================================================================
93 void SMESHDS_Script::AddNode(int NewNodeID, double x, double y, double z)
99 getCommand(SMESHDS_AddNode)->AddNode(NewNodeID, x, y, z);
102 //=======================================================================
105 //=======================================================================
106 void SMESHDS_Script::Add0DElement (int New0DElementID, int idnode)
108 if (myIsEmbeddedMode) {
112 getCommand(SMESHDS_Add0DElement)->Add0DElement(New0DElementID, idnode);
115 //=======================================================================
118 //=======================================================================
119 void SMESHDS_Script::AddEdge(int NewEdgeID, int idnode1, int idnode2)
121 if(myIsEmbeddedMode){
125 getCommand(SMESHDS_AddEdge)->AddEdge(NewEdgeID, idnode1, idnode2);
128 //=======================================================================
131 //=======================================================================
132 void SMESHDS_Script::AddFace(int NewFaceID,
133 int idnode1, int idnode2, int idnode3)
135 if(myIsEmbeddedMode){
139 getCommand(SMESHDS_AddTriangle)->AddFace(NewFaceID,
140 idnode1, idnode2, idnode3);
143 //=======================================================================
146 //=======================================================================
147 void SMESHDS_Script::AddFace(int NewFaceID,
148 int idnode1, int idnode2,
149 int idnode3, int idnode4)
151 if(myIsEmbeddedMode){
155 getCommand(SMESHDS_AddQuadrangle)->AddFace(NewFaceID,
160 //=======================================================================
163 //=======================================================================
164 void SMESHDS_Script::AddVolume(int NewID,
165 int idnode1, int idnode2,
166 int idnode3, int idnode4)
168 if(myIsEmbeddedMode){
172 getCommand(SMESHDS_AddTetrahedron)->AddVolume(NewID,
177 //=======================================================================
180 //=======================================================================
181 void SMESHDS_Script::AddVolume(int NewID,
182 int idnode1, int idnode2,
183 int idnode3, int idnode4, int idnode5)
185 if(myIsEmbeddedMode){
189 getCommand(SMESHDS_AddPyramid)->AddVolume(NewID,
191 idnode3, idnode4, idnode5);
194 //=======================================================================
197 //=======================================================================
198 void SMESHDS_Script::AddVolume(int NewID,
199 int idnode1, int idnode2, int idnode3,
200 int idnode4, int idnode5, int idnode6)
202 if(myIsEmbeddedMode){
206 getCommand(SMESHDS_AddPrism)->AddVolume(NewID,
207 idnode1, idnode2, idnode3,
208 idnode4, idnode5, idnode6);
211 //=======================================================================
214 //=======================================================================
215 void SMESHDS_Script::AddVolume(int NewID,
216 int idnode1, int idnode2, int idnode3, int idnode4,
217 int idnode5, int idnode6, int idnode7, int idnode8)
219 if(myIsEmbeddedMode){
223 getCommand(SMESHDS_AddHexahedron)->AddVolume(NewID,
224 idnode1, idnode2, idnode3, idnode4,
225 idnode5, idnode6, idnode7, idnode8);
228 //=======================================================================
231 //=======================================================================
232 void SMESHDS_Script::AddVolume(int NewVolID, int idnode1, int idnode2, int idnode3,
233 int idnode4, int idnode5, int idnode6, int idnode7, int idnode8,
234 int idnode9, int idnode10, int idnode11, int idnode12)
236 if(myIsEmbeddedMode){
240 getCommand(SMESHDS_AddHexagonalPrism)->AddVolume(NewVolID,
241 idnode1, idnode2, idnode3, idnode4,
242 idnode5, idnode6, idnode7, idnode8,
243 idnode9, idnode10, idnode11, idnode12);
246 //=======================================================================
247 //function : AddPolygonalFace
249 //=======================================================================
250 void SMESHDS_Script::AddPolygonalFace (int NewFaceID, std::vector<int> nodes_ids)
252 if(myIsEmbeddedMode){
256 getCommand(SMESHDS_AddPolygon)->AddPolygonalFace(NewFaceID, nodes_ids);
259 //=======================================================================
260 //function : AddPolyhedralVolume
262 //=======================================================================
263 void SMESHDS_Script::AddPolyhedralVolume (int NewID,
264 std::vector<int> nodes_ids,
265 std::vector<int> quantities)
267 if(myIsEmbeddedMode){
271 getCommand(SMESHDS_AddPolyhedron)->AddPolyhedralVolume
272 (NewID, nodes_ids, quantities);
275 //=======================================================================
278 //=======================================================================
279 void SMESHDS_Script::MoveNode(int NewNodeID, double x, double y, double z)
281 if(myIsEmbeddedMode){
285 getCommand(SMESHDS_MoveNode)->MoveNode(NewNodeID, x, y, z);
288 //=======================================================================
291 //=======================================================================
292 void SMESHDS_Script::RemoveNode(int ID)
294 if(myIsEmbeddedMode){
298 getCommand(SMESHDS_RemoveNode)->RemoveNode(ID);
301 //=======================================================================
304 //=======================================================================
305 void SMESHDS_Script::RemoveElement(int ElementID)
307 if(myIsEmbeddedMode){
311 getCommand(SMESHDS_RemoveElement)->RemoveElement(ElementID);
314 //=======================================================================
315 //function : ChangeElementNodes
317 //=======================================================================
319 void SMESHDS_Script::ChangeElementNodes(int ElementID, int nodes[], int nbnodes)
321 if(myIsEmbeddedMode){
325 getCommand(SMESHDS_ChangeElementNodes)->ChangeElementNodes( ElementID, nodes, nbnodes );
328 //=======================================================================
329 //function : ChangePolyhedronNodes
331 //=======================================================================
332 void SMESHDS_Script::ChangePolyhedronNodes (const int ElementID,
333 std::vector<int> nodes_ids,
334 std::vector<int> quantities)
336 if(myIsEmbeddedMode){
340 getCommand(SMESHDS_ChangePolyhedronNodes)->ChangePolyhedronNodes
341 (ElementID, nodes_ids, quantities);
344 //=======================================================================
345 //function : Renumber
347 //=======================================================================
348 void SMESHDS_Script::Renumber (const bool isNodes, const int startID, const int deltaID)
350 if(myIsEmbeddedMode){
354 getCommand(SMESHDS_Renumber)->Renumber( isNodes, startID, deltaID );
357 //=======================================================================
358 //function : ClearMesh
360 //=======================================================================
361 void SMESHDS_Script::ClearMesh ()
363 if(myIsEmbeddedMode){
367 Clear();// previous commands become useless to reproduce on client side
368 getCommand(SMESHDS_ClearAll);
371 //=======================================================================
374 //=======================================================================
375 void SMESHDS_Script::Clear()
377 list<SMESHDS_Command*>::iterator anIt = myCommands.begin();
378 for (; anIt != myCommands.end(); anIt++) {
384 //=======================================================================
387 //=======================================================================
388 const list<SMESHDS_Command*>& SMESHDS_Script::GetCommands()
394 //********************************************************************
395 //***** Methods for quadratic elements ******
396 //********************************************************************
398 //=======================================================================
401 //=======================================================================
402 void SMESHDS_Script::AddEdge(int NewEdgeID, int n1, int n2, int n12)
404 if(myIsEmbeddedMode){
408 getCommand(SMESHDS_AddQuadEdge)->AddEdge(NewEdgeID, n1, n2, n12);
411 //=======================================================================
414 //=======================================================================
415 void SMESHDS_Script::AddFace(int NewFaceID, int n1, int n2, int n3,
416 int n12, int n23, int n31)
418 if(myIsEmbeddedMode){
422 getCommand(SMESHDS_AddQuadTriangle)->AddFace(NewFaceID, n1, n2, n3,
426 //=======================================================================
429 //=======================================================================
430 void SMESHDS_Script::AddFace(int NewFaceID, int n1, int n2, int n3, int n4,
431 int n12, int n23, int n34, int n41)
433 if(myIsEmbeddedMode){
437 getCommand(SMESHDS_AddQuadQuadrangle)->AddFace(NewFaceID, n1, n2, n3, n4,
441 //=======================================================================
444 //=======================================================================
445 void SMESHDS_Script::AddFace(int NewFaceID, int n1, int n2, int n3, int n4,
446 int n12, int n23, int n34, int n41, int nCenter)
448 if(myIsEmbeddedMode){
452 getCommand(SMESHDS_AddBiQuadQuadrangle)->AddFace(NewFaceID, n1, n2, n3, n4,
453 n12, n23, n34, n41, nCenter);
456 //=======================================================================
457 //function : AddVolume
459 //=======================================================================
460 void SMESHDS_Script::AddVolume(int NewVolID, int n1, int n2, int n3, int n4,
461 int n12, int n23, int n31,
462 int n14, int n24, int n34)
464 if(myIsEmbeddedMode){
468 getCommand(SMESHDS_AddQuadTetrahedron)->AddVolume(NewVolID, n1, n2, n3, n4,
473 //=======================================================================
474 //function : AddVolume
476 //=======================================================================
477 void SMESHDS_Script::AddVolume(int NewVolID, int n1, int n2, int n3, int n4,
478 int n5, int n12, int n23, int n34, int n41,
479 int n15, int n25, int n35, int n45)
481 if(myIsEmbeddedMode){
485 getCommand(SMESHDS_AddQuadPyramid)->AddVolume(NewVolID, n1, n2, n3, n4, n5,
490 //=======================================================================
491 //function : AddVolume
493 //=======================================================================
494 void SMESHDS_Script::AddVolume(int NewVolID, int n1, int n2, int n3, int n4,
495 int n5,int n6, int n12, int n23, int n31,
496 int n45, int n56, int n64,
497 int n14, int n25, int n36)
499 if(myIsEmbeddedMode){
503 getCommand(SMESHDS_AddQuadPentahedron)->AddVolume(NewVolID, n1,n2,n3,n4,n5,n6,
509 //=======================================================================
510 //function : AddVolume
512 //=======================================================================
513 void SMESHDS_Script::AddVolume(int NewVolID, int n1, int n2, int n3,
514 int n4, int n5, int n6, int n7, int n8,
515 int n12, int n23, int n34, int n41,
516 int n56, int n67, int n78, int n85,
517 int n15, int n26, int n37, int n48)
519 if(myIsEmbeddedMode){
523 getCommand(SMESHDS_AddQuadHexahedron)->AddVolume(NewVolID, n1, n2, n3, n4,
530 //=======================================================================
531 //function : AddVolume
533 //=======================================================================
534 void SMESHDS_Script::AddVolume(int NewVolID, int n1, int n2, int n3,
535 int n4, int n5, int n6, int n7, int n8,
536 int n12, int n23, int n34, int n41,
537 int n56, int n67, int n78, int n85,
538 int n15, int n26, int n37, int n48,
539 int n1234,int n1256,int n2367,int n3478,
540 int n1458,int n5678,int nCenter)
542 if(myIsEmbeddedMode){
546 getCommand(SMESHDS_AddTriQuadHexa)->AddVolume(NewVolID, n1, n2, n3, n4,
551 n1234, n1256, n2367, n3478,
552 n1458, n5678, nCenter);