Salome HOME
0020089: EDF 887 MED : Take into account 0D elements (MED_POINT1)
[modules/smesh.git] / src / SMESH_I / SMESH_2smeshpy.cxx
index 0fa541b7d04dbdf6634981c153449efd2f47bdad..0777667620f318c7f7304766f408d036cdf4df73 100644 (file)
@@ -1066,7 +1066,7 @@ void _pyMeshEditor::Process( const Handle(_pyCommand)& theCommand)
   static TStringSet sameMethods;
   if ( sameMethods.empty() ) {
     const char * names[] = {
-      "RemoveElements","RemoveNodes","AddNode","AddEdge","AddFace","AddPolygonalFace",
+      "RemoveElements","RemoveNodes","AddNode","Add0DElement","AddEdge","AddFace","AddPolygonalFace",
       "AddVolume","AddPolyhedralVolume","AddPolyhedralVolumeByFaces","MoveNode", "MoveClosestNodeToPoint",
       "InverseDiag","DeleteDiag","Reorient","ReorientObject","TriToQuad","SplitQuad","SplitQuadObject",
       "BestSplit","Smooth","SmoothObject","SmoothParametric","SmoothParametricObject",
@@ -1207,14 +1207,21 @@ Handle(_pyHypothesis) _pyHypothesis::NewHypothesis( const Handle(_pyCommand)& th
     hyp->AddArgMethod( "SetNumberOfSegments" );
     // arg of SetScaleFactor() will become the 2-nd arg of hyp creation command
     hyp->AddArgMethod( "SetScaleFactor" );
+    hyp->AddArgMethod( "SetReversedEdges" );
   }
   else if ( hypType == "Arithmetic1D" ) {
     hyp = new _pyComplexParamHypo( theCreationCmd );
     hyp->SetConvMethodAndType( "Arithmetic1D", "Regular_1D");
+    hyp->AddArgMethod( "SetStartLength" );
+    hyp->AddArgMethod( "SetEndLength" );
+    hyp->AddArgMethod( "SetReversedEdges" );
   }
   else if ( hypType == "StartEndLength" ) {
     hyp = new _pyComplexParamHypo( theCreationCmd );
     hyp->SetConvMethodAndType( "StartEndLength", "Regular_1D");
+    hyp->AddArgMethod( "SetStartLength" );
+    hyp->AddArgMethod( "SetEndLength" );
+    hyp->AddArgMethod( "SetReversedEdges" );
   }
   else if ( hypType == "Deflection1D" ) {
     hyp->SetConvMethodAndType( "Deflection1D", "Regular_1D");
@@ -1287,7 +1294,7 @@ Handle(_pyHypothesis) _pyHypothesis::NewHypothesis( const Handle(_pyCommand)& th
   }
   else if ( hypType == "NETGEN_SimpleParameters_2D") {
     hyp->SetConvMethodAndType( "Parameters", "NETGEN_2D");
-    hyp->myArgs.Append( "which=SIMPLE" );
+    hyp->myArgs.Append( "which=smesh.SIMPLE" );
   }
   else if ( hypType == "NETGEN_2D3D") { // 1D-2D-3D
     algo->SetConvMethodAndType( "Tetrahedron" , hypType.ToCString());
@@ -1298,7 +1305,7 @@ Handle(_pyHypothesis) _pyHypothesis::NewHypothesis( const Handle(_pyCommand)& th
   }
   else if ( hypType == "NETGEN_SimpleParameters_3D") {
     hyp->SetConvMethodAndType( "Parameters", "NETGEN_2D3D");
-    hyp->myArgs.Append( "which=SIMPLE" );
+    hyp->myArgs.Append( "which=smesh.SIMPLE" );
   }
   else if ( hypType == "NETGEN_2D_ONLY") { // 2D
     algo->SetConvMethodAndType( "Triangle" , hypType.ToCString());
@@ -1550,15 +1557,38 @@ void _pyHypothesis::Assign( const Handle(_pyHypothesis)& theOther,
 
 void _pyComplexParamHypo::Process( const Handle(_pyCommand)& theCommand)
 {
-  // ex: hyp.SetLength(start, 1)
-  //     hyp.SetLength(end,   0)
-  ASSERT(( theCommand->GetMethod() == "SetLength" ));
-  ASSERT(( theCommand->GetArg( 2 ).IsIntegerValue() ));
-  int i = 2 - theCommand->GetArg( 2 ).IntegerValue();
-  while ( myArgs.Length() < i )
-    myArgs.Append( "[]" );
-  myArgs( i ) = theCommand->GetArg( 1 ); // arg value
-  myArgCommands.push_back( theCommand );
+  if( theCommand->GetMethod() == "SetLength" )
+  {
+    // NOW it becomes OBSOLETE
+    // ex: hyp.SetLength(start, 1)
+    //     hyp.SetLength(end,   0)
+    ASSERT(( theCommand->GetArg( 2 ).IsIntegerValue() ));
+    int i = 2 - theCommand->GetArg( 2 ).IntegerValue();
+    while ( myArgs.Length() < i )
+      myArgs.Append( "[]" );
+    myArgs( i ) = theCommand->GetArg( 1 ); // arg value
+    myArgCommands.push_back( theCommand );
+  }
+  else
+  {
+    _pyHypothesis::Process( theCommand );
+  }
+}
+//================================================================================
+/*!
+ * \brief Clear SetObjectEntry() as it is called by methods of Mesh_Segment
+ */
+//================================================================================
+
+void _pyComplexParamHypo::Flush()
+{
+  if ( IsWrapped() )
+  {
+    list < Handle(_pyCommand) >::iterator cmd = myUnknownCommands.begin();
+    for ( ; cmd != myUnknownCommands.end(); ++cmd )
+      if ((*cmd)->GetMethod() == "SetObjectEntry" )
+        (*cmd)->Clear();
+  }
 }
 
 //================================================================================
@@ -1729,6 +1759,8 @@ void _pyNumberOfSegmentsHyp::Flush()
   for ( ; !distrTypeNb && cmd != myUnknownCommands.rend(); ++cmd )
     if ( (*cmd)->GetMethod() == "SetDistrType" )
       distrTypeNb = (*cmd)->GetOrderNb();
+    else if (IsWrapped() && (*cmd)->GetMethod() == "SetObjectEntry" )
+      (*cmd)->Clear();
 
   // clear commands before the last SetDistrType()
   list<Handle(_pyCommand)> * cmds[2] = { &myArgCommands, &myUnknownCommands };
@@ -2107,9 +2139,19 @@ TCollection_AsciiString _pyCommand::GetWord( const TCollection_AsciiString & the
       return theEmptyString; // no word found
     // end
     end = beg + 1;
-    while ( end <= theString.Length() && isWord( theString.Value( end ), dotIsWord))
-      ++end;
-    --end;
+    char begChar = theString.Value( beg );
+    if ( begChar == '"' || begChar == '\'' || begChar == '[') {
+      char endChar = ( begChar == '[' ) ? ']' : begChar;
+      // end is at the corresponding quoting mark or bracket
+      while ( end < theString.Length() &&
+              ( theString.Value( end ) != endChar || theString.Value( end-1 ) == '\\'))
+        ++end;
+    }
+    else {
+      while ( end <= theString.Length() && isWord( theString.Value( end ), dotIsWord))
+        ++end;
+      --end;
+    }
   }
   else {  // search backward
     // end
@@ -2118,9 +2160,18 @@ TCollection_AsciiString _pyCommand::GetWord( const TCollection_AsciiString & the
     if ( end == 0 )
       return theEmptyString; // no word found
     beg = end - 1;
-    while ( beg > 0 && isWord( theString.Value( beg ), dotIsWord))
-      --beg;
-    ++beg;
+    char endChar = theString.Value( end );
+    if ( endChar == '"' || endChar == '\'' ) {
+      // beg is at the corresponding quoting mark
+      while ( beg > 1 &&
+              ( theString.Value( beg ) != endChar || theString.Value( beg-1 ) == '\\'))
+        --beg;
+    }
+    else {
+      while ( beg > 0 && isWord( theString.Value( beg ), dotIsWord))
+        --beg;
+      ++beg;
+    }
   }
   theStartPos = beg;
   //cout << theString << " ---- " << beg << " - " << end << endl;