Version: 6.3.1

src/SMESHDS/SMESHDS_Script.cxx

Go to the documentation of this file.
00001 // Copyright (C) 2007-2011  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 //  SMESH SMESHDS : management of mesh data and SMESH document
00024 //  File   : SMESH_Script.cxx
00025 //  Author : Yves FRICAUD, OCC
00026 //  Module : SMESH
00027 //  $Header: 
00028 //
00029 #include "SMESHDS_Script.hxx"
00030 #include <iostream>
00031 
00032 using namespace std;
00033 
00034 //=======================================================================
00035 //function : Constructor
00036 //purpose  : 
00037 //=======================================================================
00038 SMESHDS_Script::SMESHDS_Script(bool theIsEmbeddedMode):
00039   myIsEmbeddedMode(theIsEmbeddedMode)
00040 {
00041   //cerr << "=========================== myIsEmbeddedMode " << myIsEmbeddedMode << endl;
00042 }
00043 
00044 //=======================================================================
00045 //function : Destructor
00046 //purpose  : 
00047 //=======================================================================
00048 SMESHDS_Script::~SMESHDS_Script()
00049 {
00050   Clear();
00051 }
00052 
00053 //=======================================================================
00054 void SMESHDS_Script::SetModified(bool theModified)
00055 {
00056   myIsModified = theModified;
00057 }
00058 
00059 //=======================================================================
00060 bool SMESHDS_Script::IsModified()
00061 {
00062   return myIsModified;
00063 }
00064 
00065 //=======================================================================
00066 //function : getCommand
00067 //purpose  : 
00068 //=======================================================================
00069 SMESHDS_Command* SMESHDS_Script::getCommand(const SMESHDS_CommandType aType)
00070 {
00071   SMESHDS_Command* com;
00072   if (myCommands.empty())
00073   {
00074     com = new SMESHDS_Command(aType);
00075     myCommands.insert(myCommands.end(),com);
00076   }
00077   else
00078   {
00079     com = myCommands.back();
00080     if (com->GetType() != aType)
00081     {
00082       com = new SMESHDS_Command(aType);
00083       myCommands.insert(myCommands.end(),com);
00084     }
00085   }
00086   return com;
00087 }
00088 
00089 //=======================================================================
00090 //function : 
00091 //purpose  : 
00092 //=======================================================================
00093 void SMESHDS_Script::AddNode(int NewNodeID, double x, double y, double z)
00094 {
00095   if(myIsEmbeddedMode){
00096     myIsModified = true;
00097     return;
00098   }
00099   getCommand(SMESHDS_AddNode)->AddNode(NewNodeID, x, y, z);
00100 }
00101 
00102 //=======================================================================
00103 //function :
00104 //purpose  :
00105 //=======================================================================
00106 void SMESHDS_Script::Add0DElement (int New0DElementID, int idnode)
00107 {
00108   if (myIsEmbeddedMode) {
00109     myIsModified = true;
00110     return;
00111   }
00112   getCommand(SMESHDS_Add0DElement)->Add0DElement(New0DElementID, idnode);
00113 }
00114 
00115 //=======================================================================
00116 //function : 
00117 //purpose  : 
00118 //=======================================================================
00119 void SMESHDS_Script::AddEdge(int NewEdgeID, int idnode1, int idnode2)
00120 {
00121   if(myIsEmbeddedMode){
00122     myIsModified = true;
00123     return;
00124   }
00125   getCommand(SMESHDS_AddEdge)->AddEdge(NewEdgeID, idnode1, idnode2);
00126 }
00127 
00128 //=======================================================================
00129 //function : 
00130 //purpose  : 
00131 //=======================================================================
00132 void SMESHDS_Script::AddFace(int NewFaceID,
00133                              int idnode1, int idnode2, int idnode3)
00134 {
00135   if(myIsEmbeddedMode){
00136     myIsModified = true;
00137     return;
00138   }
00139   getCommand(SMESHDS_AddTriangle)->AddFace(NewFaceID,
00140                                            idnode1, idnode2, idnode3);
00141 }
00142 
00143 //=======================================================================
00144 //function : 
00145 //purpose  : 
00146 //=======================================================================
00147 void SMESHDS_Script::AddFace(int NewFaceID,
00148                              int idnode1, int idnode2,
00149                              int idnode3, int idnode4)
00150 {
00151   if(myIsEmbeddedMode){
00152     myIsModified = true;
00153     return;
00154   }
00155   getCommand(SMESHDS_AddQuadrangle)->AddFace(NewFaceID,
00156                                              idnode1, idnode2,
00157                                              idnode3, idnode4);
00158 }
00159 
00160 //=======================================================================
00161 //function : 
00162 //purpose  : 
00163 //=======================================================================
00164 void SMESHDS_Script::AddVolume(int NewID,
00165                                int idnode1, int idnode2,
00166                                int idnode3, int idnode4)
00167 {
00168   if(myIsEmbeddedMode){
00169     myIsModified = true;
00170     return;
00171   }
00172   getCommand(SMESHDS_AddTetrahedron)->AddVolume(NewID,
00173                                                 idnode1, idnode2,
00174                                                 idnode3, idnode4);
00175 }
00176 
00177 //=======================================================================
00178 //function : 
00179 //purpose  : 
00180 //=======================================================================
00181 void SMESHDS_Script::AddVolume(int NewID,
00182                                int idnode1, int idnode2,
00183                                int idnode3, int idnode4, int idnode5)
00184 {
00185   if(myIsEmbeddedMode){
00186     myIsModified = true;
00187     return;
00188   }
00189   getCommand(SMESHDS_AddPyramid)->AddVolume(NewID,
00190                                             idnode1, idnode2,
00191                                             idnode3, idnode4, idnode5);
00192 }
00193 
00194 //=======================================================================
00195 //function : 
00196 //purpose  : 
00197 //=======================================================================
00198 void SMESHDS_Script::AddVolume(int NewID,
00199                                int idnode1, int idnode2, int idnode3,
00200                                int idnode4, int idnode5, int idnode6)
00201 {
00202   if(myIsEmbeddedMode){
00203     myIsModified = true;
00204     return;
00205   }
00206   getCommand(SMESHDS_AddPrism)->AddVolume(NewID,
00207                                           idnode1, idnode2, idnode3,
00208                                           idnode4, idnode5, idnode6);
00209 }
00210 
00211 //=======================================================================
00212 //function : 
00213 //purpose  : 
00214 //=======================================================================
00215 void SMESHDS_Script::AddVolume(int NewID,
00216                                int idnode1, int idnode2, int idnode3, int idnode4,
00217                                int idnode5, int idnode6, int idnode7, int idnode8)
00218 {
00219   if(myIsEmbeddedMode){
00220     myIsModified = true;
00221     return;
00222   }
00223   getCommand(SMESHDS_AddHexahedron)->AddVolume(NewID,
00224                                                idnode1, idnode2, idnode3, idnode4,
00225                                                idnode5, idnode6, idnode7, idnode8);
00226 }
00227 
00228 //=======================================================================
00229 //function : AddPolygonalFace
00230 //purpose  : 
00231 //=======================================================================
00232 void SMESHDS_Script::AddPolygonalFace (int NewFaceID, std::vector<int> nodes_ids)
00233 {
00234   if(myIsEmbeddedMode){
00235     myIsModified = true;
00236     return;
00237   }
00238   getCommand(SMESHDS_AddPolygon)->AddPolygonalFace(NewFaceID, nodes_ids);
00239 }
00240 
00241 //=======================================================================
00242 //function : AddPolyhedralVolume
00243 //purpose  : 
00244 //=======================================================================
00245 void SMESHDS_Script::AddPolyhedralVolume (int NewID,
00246                                           std::vector<int> nodes_ids,
00247                                           std::vector<int> quantities)
00248 {
00249   if(myIsEmbeddedMode){
00250     myIsModified = true;
00251     return;
00252   }
00253   getCommand(SMESHDS_AddPolyhedron)->AddPolyhedralVolume
00254     (NewID, nodes_ids, quantities);
00255 }
00256 
00257 //=======================================================================
00258 //function : 
00259 //purpose  : 
00260 //=======================================================================
00261 void SMESHDS_Script::MoveNode(int NewNodeID, double x, double y, double z)
00262 {
00263   if(myIsEmbeddedMode){
00264     myIsModified = true;
00265     return;
00266   }
00267   getCommand(SMESHDS_MoveNode)->MoveNode(NewNodeID, x, y, z);
00268 }
00269 
00270 //=======================================================================
00271 //function : 
00272 //purpose  : 
00273 //=======================================================================
00274 void SMESHDS_Script::RemoveNode(int ID)
00275 {
00276   if(myIsEmbeddedMode){
00277     myIsModified = true;
00278     return;
00279   }
00280   getCommand(SMESHDS_RemoveNode)->RemoveNode(ID);
00281 }
00282 
00283 //=======================================================================
00284 //function : 
00285 //purpose  : 
00286 //=======================================================================
00287 void SMESHDS_Script::RemoveElement(int ElementID)
00288 {
00289   if(myIsEmbeddedMode){
00290     myIsModified = true;
00291     return;
00292   }
00293   getCommand(SMESHDS_RemoveElement)->RemoveElement(ElementID);
00294 }
00295 
00296 //=======================================================================
00297 //function : ChangeElementNodes
00298 //purpose  : 
00299 //=======================================================================
00300 
00301 void SMESHDS_Script::ChangeElementNodes(int ElementID, int nodes[], int nbnodes)
00302 {
00303   if(myIsEmbeddedMode){
00304     myIsModified = true;
00305     return;
00306   }
00307   getCommand(SMESHDS_ChangeElementNodes)->ChangeElementNodes( ElementID, nodes, nbnodes );
00308 }
00309 
00310 //=======================================================================
00311 //function : ChangePolyhedronNodes
00312 //purpose  : 
00313 //=======================================================================
00314 void SMESHDS_Script::ChangePolyhedronNodes (const int        ElementID,
00315                                             std::vector<int> nodes_ids,
00316                                             std::vector<int> quantities)
00317 {
00318   if(myIsEmbeddedMode){
00319     myIsModified = true;
00320     return;
00321   }
00322   getCommand(SMESHDS_ChangePolyhedronNodes)->ChangePolyhedronNodes
00323     (ElementID, nodes_ids, quantities);
00324 }
00325 
00326 //=======================================================================
00327 //function : Renumber
00328 //purpose  : 
00329 //=======================================================================
00330 void SMESHDS_Script::Renumber (const bool isNodes, const int startID, const int deltaID)
00331 {
00332   if(myIsEmbeddedMode){
00333     myIsModified = true;
00334     return;
00335   }
00336   getCommand(SMESHDS_Renumber)->Renumber( isNodes, startID, deltaID );
00337 }
00338 
00339 //=======================================================================
00340 //function : ClearMesh
00341 //purpose  : 
00342 //=======================================================================
00343 void SMESHDS_Script::ClearMesh ()
00344 {
00345   if(myIsEmbeddedMode){
00346     myIsModified = true;
00347     return;
00348   }
00349   Clear();// previous commands become useless to reproduce on client side
00350   getCommand(SMESHDS_ClearAll);
00351 }
00352 
00353 //=======================================================================
00354 //function : 
00355 //purpose  : 
00356 //=======================================================================
00357 void SMESHDS_Script::Clear()
00358 {
00359   list<SMESHDS_Command*>::iterator anIt = myCommands.begin();
00360   for (; anIt != myCommands.end(); anIt++) {
00361     delete (*anIt);
00362   }
00363   myCommands.clear();
00364 }
00365 
00366 //=======================================================================
00367 //function : 
00368 //purpose  : 
00369 //=======================================================================
00370 const list<SMESHDS_Command*>& SMESHDS_Script::GetCommands()
00371 {
00372   return myCommands;
00373 }
00374 
00375 
00376 //********************************************************************
00377 //*****             Methods for quadratic elements              ******
00378 //********************************************************************
00379 
00380 //=======================================================================
00381 //function : AddEdge
00382 //purpose  : 
00383 //=======================================================================
00384 void SMESHDS_Script::AddEdge(int NewEdgeID, int n1, int n2, int n12)
00385 {
00386   if(myIsEmbeddedMode){
00387     myIsModified = true;
00388     return;
00389   }
00390   getCommand(SMESHDS_AddQuadEdge)->AddEdge(NewEdgeID, n1, n2, n12);
00391 }
00392 
00393 //=======================================================================
00394 //function : AddFace
00395 //purpose  : 
00396 //=======================================================================
00397 void SMESHDS_Script::AddFace(int NewFaceID, int n1, int n2, int n3,
00398                              int n12, int n23, int n31)
00399 {
00400   if(myIsEmbeddedMode){
00401     myIsModified = true;
00402     return;
00403   }
00404   getCommand(SMESHDS_AddQuadTriangle)->AddFace(NewFaceID, n1, n2, n3,
00405                                                n12, n23, n31);
00406 }
00407 
00408 //=======================================================================
00409 //function : AddFace
00410 //purpose  : 
00411 //=======================================================================
00412 void SMESHDS_Script::AddFace(int NewFaceID, int n1, int n2, int n3, int n4,
00413                              int n12, int n23, int n34, int n41)
00414 {
00415   if(myIsEmbeddedMode){
00416     myIsModified = true;
00417     return;
00418   }
00419   getCommand(SMESHDS_AddQuadQuadrangle)->AddFace(NewFaceID, n1, n2, n3, n4,
00420                                                  n12, n23, n34, n41);
00421 }
00422 
00423 //=======================================================================
00424 //function : AddVolume
00425 //purpose  : 
00426 //=======================================================================
00427 void SMESHDS_Script::AddVolume(int NewVolID, int n1, int n2, int n3, int n4,
00428                                int n12, int n23, int n31,
00429                                int n14, int n24, int n34)
00430 {
00431   if(myIsEmbeddedMode){
00432     myIsModified = true;
00433     return;
00434   }
00435   getCommand(SMESHDS_AddQuadTetrahedron)->AddVolume(NewVolID, n1, n2, n3, n4,
00436                                                     n12, n23, n31,
00437                                                     n14, n24, n34);
00438 }
00439 
00440 //=======================================================================
00441 //function : AddVolume
00442 //purpose  : 
00443 //=======================================================================
00444 void SMESHDS_Script::AddVolume(int NewVolID, int n1, int n2, int n3, int n4,
00445                                int n5, int n12, int n23, int n34, int n41,
00446                                int n15, int n25, int n35, int n45)
00447 {
00448   if(myIsEmbeddedMode){
00449     myIsModified = true;
00450     return;
00451   }
00452   getCommand(SMESHDS_AddQuadPyramid)->AddVolume(NewVolID, n1, n2, n3, n4, n5,
00453                                                 n12, n23, n34, n41,
00454                                                 n15, n25, n35, n45);
00455 }
00456 
00457 //=======================================================================
00458 //function : AddVolume
00459 //purpose  : 
00460 //=======================================================================
00461 void SMESHDS_Script::AddVolume(int NewVolID, int n1, int n2, int n3, int n4,
00462                                 int n5,int n6, int n12, int n23, int n31,
00463                                 int n45, int n56, int n64,
00464                                 int n14, int n25, int n36)
00465 {
00466   if(myIsEmbeddedMode){
00467     myIsModified = true;
00468     return;
00469   }
00470   getCommand(SMESHDS_AddQuadPentahedron)->AddVolume(NewVolID, n1,n2,n3,n4,n5,n6,
00471                                                     n12, n23, n31,
00472                                                     n45, n56, n64,
00473                                                     n14, n25, n36);
00474 }
00475 
00476 //=======================================================================
00477 //function : AddVolume
00478 //purpose  : 
00479 //=======================================================================
00480 void SMESHDS_Script::AddVolume(int NewVolID, int n1, int n2, int n3,
00481                                int n4, int n5, int n6, int n7, int n8,
00482                                int n12, int n23, int n34, int n41,
00483                                int n56, int n67, int n78, int n85,
00484                                int n15, int n26, int n37, int n48)
00485 {
00486   if(myIsEmbeddedMode){
00487     myIsModified = true;
00488     return;
00489   }
00490   getCommand(SMESHDS_AddQuadHexahedron)->AddVolume(NewVolID, n1, n2, n3, n4,
00491                                                    n5, n6, n7, n8,
00492                                                    n12, n23, n34, n41,
00493                                                    n56, n67, n78, n85,
00494                                                    n15, n26, n37, n48);
00495 }
00496 
Copyright © 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
Copyright © 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS