Salome HOME
PAL13473 (Build repetitive mesh):
authoreap <eap@opencascade.com>
Thu, 7 Dec 2006 17:17:06 +0000 (17:17 +0000)
committereap <eap@opencascade.com>
Thu, 7 Dec 2006 17:17:06 +0000 (17:17 +0000)
fix problem with 1) not wrapped mesh as hypo parameter
2) removal of repeated settings of "Nb.Segments" hypo

src/SMESH_I/SMESH_2smeshpy.cxx
src/SMESH_I/SMESH_2smeshpy.hxx

index db50e628525cbd323601c5e42751f60c39562a94..e232506b6b15e6d9f71183066b84909b12d12b8b 100644 (file)
@@ -188,17 +188,10 @@ void _pyGen::AddCommand( const TCollection_AsciiString& theCommand)
     }
 
   // Add access to a wrapped mesh
-  for ( id_mesh = myMeshes.begin(); id_mesh != myMeshes.end(); ++id_mesh ) {
-    if ( aCommand->AddAccessorMethod( id_mesh->first, id_mesh->second->AccessorMethod() ))
-      break;
-  }
+  AddMeshAccessorMethod( aCommand );
 
   // Add access to a wrapped algorithm
-  for ( hyp = myHypos.begin(); hyp != myHypos.end(); ++hyp ) {
-    if ( (*hyp)->IsAlgo() &&
-         aCommand->AddAccessorMethod( (*hyp)->GetID(), (*hyp)->AccessorMethod() ))
-      break;
-  }
+  AddAlgoAccessorMethod( aCommand );
 
   // PAL12227. PythonDump was not updated at proper time; result is
   //     aCriteria.append(SMESH.Filter.Criterion(17,26,0,'L1',26,25,1e-07,SMESH.EDGE,-1))
@@ -297,6 +290,43 @@ void _pyGen::Flush()
     }
 }
 
+//================================================================================
+/*!
+ * \brief Add access method to mesh that is object or arg
+  * \param theCmd - command to add access method
+  * \retval bool - true if added
+ */
+//================================================================================
+
+bool _pyGen::AddMeshAccessorMethod( Handle(_pyCommand) theCmd ) const
+{
+  map< _pyID, Handle(_pyMesh) >::const_iterator id_mesh = myMeshes.begin();
+  for ( ; id_mesh != myMeshes.end(); ++id_mesh ) {
+    if ( theCmd->AddAccessorMethod( id_mesh->first, id_mesh->second->AccessorMethod() ))
+      return true;
+  }
+  return false;
+}
+
+//================================================================================
+/*!
+ * \brief Add access method to algo that is object or arg
+  * \param theCmd - command to add access method
+  * \retval bool - true if added
+ */
+//================================================================================
+
+bool _pyGen::AddAlgoAccessorMethod( Handle(_pyCommand) theCmd ) const
+{
+  list< Handle(_pyHypothesis) >::const_iterator hyp = myHypos.begin();
+  for ( ; hyp != myHypos.end(); ++hyp ) {
+    if ( (*hyp)->IsAlgo() &&
+         theCmd->AddAccessorMethod( (*hyp)->GetID(), (*hyp)->AccessorMethod() ))
+      return true;
+  }
+  return false;
+}
+
 //================================================================================
 /*!
  * \brief Find hypothesis by ID (entry)
@@ -945,10 +975,26 @@ void _pyHypothesis::Process( const Handle(_pyCommand)& theCommand)
 void _pyHypothesis::Flush()
 {
   if ( IsWrapped() ) {
-    // forget previous hypothesis modifications
-    myArgCommands.clear();
-    myUnknownCommands.clear();
   }
+  else {
+    list < Handle(_pyCommand) >::iterator cmd = myArgCommands.begin();
+    for ( ; cmd != myArgCommands.end(); ++cmd ) {
+      // Add access to a wrapped mesh
+      theGen->AddMeshAccessorMethod( *cmd );
+      // Add access to a wrapped algorithm
+      theGen->AddAlgoAccessorMethod( *cmd );
+    }
+    cmd = myUnknownCommands.begin();
+    for ( ; cmd != myUnknownCommands.end(); ++cmd ) {
+      // Add access to a wrapped mesh
+      theGen->AddMeshAccessorMethod( *cmd );
+      // Add access to a wrapped algorithm
+      theGen->AddAlgoAccessorMethod( *cmd );
+    }
+  }
+  // forget previous hypothesis modifications
+  myArgCommands.clear();
+  myUnknownCommands.clear();
 }
 
 //================================================================================
@@ -1150,15 +1196,27 @@ bool _pyNumberOfSegmentsHyp::Addition2Creation( const Handle(_pyCommand)& theCmd
 
 void _pyNumberOfSegmentsHyp::Flush()
 {
-  const int nbCmdLists = 2;
-  list<Handle(_pyCommand)> * cmds[nbCmdLists] = { &myArgCommands, &myUnknownCommands };
-  for ( int i = 0; i < nbCmdLists; ++i ) {
+  // find number of the last SetDistrType() command
+  list<Handle(_pyCommand)>::reverse_iterator cmd = myUnknownCommands.rbegin();
+  int distrTypeNb = 0;
+  for ( ; !distrTypeNb && cmd != myUnknownCommands.rend(); ++cmd )
+    if ( (*cmd)->GetMethod() == "SetDistrType" )
+      distrTypeNb = (*cmd)->GetOrderNb();
+
+  // clear commands before the last SetDistrType()
+  list<Handle(_pyCommand)> * cmds[2] = { &myArgCommands, &myUnknownCommands };
+  for ( int i = 0; i < 2; ++i ) {
     set<TCollection_AsciiString> uniqueMethods;
     list<Handle(_pyCommand)> & cmdList = *cmds[i];
-    list<Handle(_pyCommand)>::reverse_iterator cmd = cmdList.rbegin();
-    for ( ; cmd != cmdList.rend(); ++cmd ) {
-      bool isNewInSet = uniqueMethods.insert( (*cmd)->GetMethod() ).second;
-      if ( ! isNewInSet )
+    for ( cmd = cmdList.rbegin(); cmd != cmdList.rend(); ++cmd )
+    {
+      bool clear = ( (*cmd)->GetOrderNb() < distrTypeNb );
+      const TCollection_AsciiString& method = (*cmd)->GetMethod();
+      if ( !clear || method == "SetNumberOfSegments" ) {
+        bool isNewInSet = uniqueMethods.insert( method ).second;
+        clear = !isNewInSet;
+      }
+      if ( clear )
         (*cmd)->Clear();
     }
     cmdList.clear();
index b6f17c046476444337c791f1594f6107c5201d24..f5717cd2a386538862b3c5e4d42572d33de00829 100644 (file)
@@ -201,6 +201,8 @@ public:
   void SetCommandAfter( Handle(_pyCommand) theCmd, Handle(_pyCommand) theAfterCmd );
   std::list< Handle(_pyCommand) >& GetCommands() { return myCommands; }
   void SetAccessorMethod(const _pyID& theID, const char* theMethod );
+  bool AddMeshAccessorMethod( Handle(_pyCommand) theCmd ) const;
+  bool AddAlgoAccessorMethod( Handle(_pyCommand) theCmd ) const;
   const char* AccessorMethod() const { return SMESH_2smeshpy::GenName(); }
 private:
   std::map< _pyID, Handle(_pyMesh) > myMeshes;