Salome HOME
Update copyrights 2014.
[modules/smesh.git] / src / SMESH_I / SMESH_2smeshpy.cxx
index 6051ea1e95555d5a8a90da6b762536550116278b..e12cd7f5a5b6b323af282eb2e8ebd4a6b0c8970f 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2014  CEA/DEN, EDF R&D, OPEN CASCADE
 //
 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
@@ -6,7 +6,7 @@
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
 // License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// version 2.1 of the License, or (at your option) any later version.
 //
 // This library is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -44,7 +44,7 @@
 
 #include <LDOMParser.hxx>
 
-#ifdef WNT
+#ifdef WIN32
 #include <windows.h>
 #else
 #include <unistd.h>
@@ -201,6 +201,9 @@ namespace {
     _AString comment;
 
     _pyID obj = cmd->GetObject();
+    if ( obj.Search( "print " ) == 1 )
+      return; // print statement
+
     if ( !obj.IsEmpty() && obj.Value( obj.Length() ) == ')' )
       // remove an accessor method
       obj = _pyCommand( obj ).GetObject();
@@ -369,7 +372,7 @@ namespace {
    */
   //================================================================================
 
-  void StructToList( Handle( _pyCommand)& theCommand )
+  void StructToList( Handle( _pyCommand)& theCommand, const bool checkMethod=true )
   {
     static TStringSet methodsAcceptingList;
     if ( methodsAcceptingList.empty() ) {
@@ -383,11 +386,11 @@ namespace {
         "ExtrusionSweepObject2D","ExtrusionSweepObject2DMakeGroups",
         "Translate","TranslateMakeGroups","TranslateMakeMesh",
         "TranslateObject","TranslateObjectMakeGroups", "TranslateObjectMakeMesh",
-        "ExtrusionAlongPathX","ExtrusionAlongPathObjX"
+        "ExtrusionAlongPathX","ExtrusionAlongPathObjX","SplitHexahedraIntoPrisms"
         ,"" }; // <- mark of the end
       methodsAcceptingList.Insert( methodNames );
     }
-    if ( methodsAcceptingList.Contains( theCommand->GetMethod() ))
+    if ( !checkMethod || methodsAcceptingList.Contains( theCommand->GetMethod() ))
     {
       for ( int i = theCommand->GetNbArgs(); i > 0; --i )
       {
@@ -2072,6 +2075,7 @@ bool _pyMesh::NeedMeshAccess( const Handle(_pyCommand)& theCommand )
         "GetSubMeshElementsId","GetSubMeshNodesId","GetSubMeshElementType","Dump","GetNodeXYZ",
         "GetNodeInverseElements","GetShapeID","GetShapeIDForElem","GetElemNbNodes",
         "GetElemNode","IsMediumNode","IsMediumNodeOfAnyElem","ElemNbEdges","ElemNbFaces",
+        "GetElemFaceNodes", "GetFaceNormal", "FindElementByNodes",
         "IsPoly","IsQuadratic","BaryCenter","GetHypothesisList", "SetAutoColor", "GetAutoColor",
         "Clear", "ConvertToStandalone", "GetMeshOrder", "SetMeshOrder"
         ,"" }; // <- mark of end
@@ -2372,7 +2376,7 @@ void _pyMeshEditor::Process( const Handle(_pyCommand)& theCommand)
       "GetLastCreatedElems",
       "MirrorMakeMesh","MirrorObjectMakeMesh","TranslateMakeMesh","TranslateObjectMakeMesh",
       "Scale","ScaleMakeMesh","RotateMakeMesh","RotateObjectMakeMesh","MakeBoundaryMesh",
-      "MakeBoundaryElements", "SplitVolumesIntoTetra",
+      "MakeBoundaryElements", "SplitVolumesIntoTetra","SplitHexahedraIntoPrisms",
       "DoubleElements","DoubleNodes","DoubleNode","DoubleNodeGroup","DoubleNodeGroups",
       "DoubleNodeElem","DoubleNodeElemInRegion","DoubleNodeElemGroup",
       "DoubleNodeElemGroupInRegion","DoubleNodeElemGroups","DoubleNodeElemGroupsInRegion",
@@ -2628,6 +2632,8 @@ Handle(_pyHypothesis) _pyHypothesis::NewHypothesis( const Handle(_pyCommand)& th
     hyp->SetConvMethodAndType( "SetGrid", "Cartesian_3D");
     for ( int iArg = 0; iArg < 4; ++iArg )
       hyp->setCreationArg( iArg+1, "[]");
+    hyp->AddAccumulativeMethod( "SetGrid" );
+    hyp->AddAccumulativeMethod( "SetGridSpacing" );
   }
   else
   {
@@ -3086,9 +3092,11 @@ void _pyComplexParamHypo::Process( const Handle(_pyCommand)& theCommand)
   {
     // CartesianParameters3D hyp
 
-    if ( theCommand->GetMethod() == "SetSizeThreshold" )
+    if ( theCommand->GetMethod() == "SetSizeThreshold"  ||
+         theCommand->GetMethod() == "SetToAddEdges" )
     {
-      setCreationArg( 4, theCommand->GetArg( 1 ));
+      int iEdges = ( theCommand->GetMethod().Value( 4 ) == 'T' );
+      setCreationArg( 4+iEdges, theCommand->GetArg( 1 ));
       myArgCommands.push_back( theCommand );
       return;
     }
@@ -3110,7 +3118,9 @@ void _pyComplexParamHypo::Process( const Handle(_pyCommand)& theCommand)
         myCurCrMethod->myArgs[ iArg ] += "]";
       }
       myArgCommands.push_back( theCommand );
-      rememberCmdOfParameter( theCommand );
+      //rememberCmdOfParameter( theCommand ); -- these commands are marked as
+      //                                  accumulative, else, if the creation
+      //                 is not converted, commands for axes 1 and 2 are lost
       return;
     }
   }
@@ -3151,13 +3161,23 @@ void _pyComplexParamHypo::Flush()
     for ( ; cmd != myUnusedCommands.end(); ++cmd )
       if ((*cmd)->GetMethod() == "SetObjectEntry" )
         (*cmd)->Clear();
+
+    if ( GetAlgoType() == "Cartesian_3D" )
+    {
+      _pyID algo = myCreationCmd->GetObject();
+      for ( cmd = myProcessedCmds.begin(); cmd != myProcessedCmds.end(); ++cmd )
+      {
+        StructToList( *cmd, /*checkMethod=*/false );
+        (*cmd)->SetObject( algo );
+      }
+    }
   }
 }
 
 //================================================================================
 /*!
  * \brief Convert methods of 1D hypotheses to my own methods
 * \param theCommand - The called hypothesis method
+ * \param theCommand - The called hypothesis method
  */
 //================================================================================
 
@@ -4246,10 +4266,13 @@ bool _pySelfEraser::CanClear()
   {
     int nbCalls = 0;
     std::list< Handle(_pyCommand) >& cmds = GetProcessedCmds();
-    std::list< Handle(_pyCommand) >::const_iterator cmd = cmds.begin();
-    for ( ; cmd != cmds.end(); ++cmd )
+    std::list< Handle(_pyCommand) >::iterator cmd = cmds.begin();
+    for ( ; cmd != cmds.end();  )
       // check of cmd emptiness is not enough as object can change
-      nbCalls += ( ( *cmd )->GetString().Search( GetID() ) > 0 );
+      if (( *cmd )->GetString().Search( GetID() ) > 0 )
+        ++nbCalls, ++cmd;
+      else
+        cmd = cmds.erase( cmd ); // save the cmd from clearing
 
     toErase = ( nbCalls < 1 );
   }
@@ -4641,12 +4664,12 @@ void _pyFilter::Process( const Handle(_pyCommand)& theCommand)
     theCommand->SetMethod( "GetFilterFromCriteria" );
 
     // Swap "aFilterManager.CreateFilter()" and "smesh.GetFilterFromCriteria(criteria)"
-    // GetCreationCmd()->Clear();
-    // GetCreationCmd()->GetString() = theCommand->GetString();
-    // theCommand->Clear();
-    // theCommand->AddDependantCmd( GetCreationCmd() );
-    // why swap?
     GetCreationCmd()->Clear();
+    GetCreationCmd()->GetString() = theCommand->GetString();
+    theCommand->Clear();
+    theCommand->AddDependantCmd( GetCreationCmd() );
+    // why swap? -- it's needed
+    //GetCreationCmd()->Clear();
   }
   else if ( theCommand->GetMethod() == "SetMesh" )
   {