Salome HOME
NPAL15379: Fuse error with partitionned shape. Roll back the fix because of regressions.
[modules/geom.git] / src / GEOM_I / GEOM_IHealingOperations_i.cc
index ea8fe487fc2c7450999d2afe28e083a17e083ecf..cdd3f1efec13f02368601a86dfef46afbaa98045 100644 (file)
@@ -1,5 +1,25 @@
+// Copyright (C) 2005  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+// 
+// 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.
+// 
+// This library is distributed in the hope that it will be useful 
+// but WITHOUT ANY WARRANTY; without even the implied warranty of 
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public  
+// License along with this library; if not, write to the Free Software 
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+#include <Standard_Stream.hxx>
+
 #include <list>
-using namespace std;
 
 #include "GEOM_IHealingOperations_i.hh"
 #include "GEOM_Engine.hxx"
@@ -123,6 +143,10 @@ void GEOM_IHealingOperations_i::GetShapeProcessParameters(GEOM::string_array_out
                                                           GEOM::string_array_out theParams,
                                                           GEOM::string_array_out theValues)
 {
+  GEOM::string_array_var anOpArray = new GEOM::string_array();
+  GEOM::string_array_var aParArray = new GEOM::string_array();
+  GEOM::string_array_var aValArray = new GEOM::string_array();
+
   // retrieve the values as stl-lists
   list<string> operationsList, paramsList, valuesList;
   GetOperations()->GetShapeProcessParameters( operationsList, paramsList, valuesList );
@@ -130,33 +154,64 @@ void GEOM_IHealingOperations_i::GetShapeProcessParameters(GEOM::string_array_out
   parSize = paramsList.size(),
   valSize = valuesList.size();
 
-  // returns in case of an error
-  if ( opSize < 0 || parSize < 0 || parSize != valSize )
-    return;
+  if ( opSize >= 0 && parSize >= 0 && parSize == valSize ) {
+    // allocate the CORBA arrays, sizes == returned lists' sizes
+    anOpArray->length(opSize);
+    aParArray->length(parSize);
+    aValArray->length(valSize);
+
+    // fill the local CORBA arrays with values from lists
+    list<string>::iterator opIt, parIt, valIt;
+    int i = 0;
+    for ( opIt = operationsList.begin(); opIt != operationsList.end(); i++,++opIt )
+      anOpArray[i] = CORBA::string_dup( (*opIt).c_str() );
+
+    for ( i = 0, parIt = paramsList.begin(), valIt = valuesList.begin();
+         parIt != paramsList.end(); i++, ++parIt,++valIt ) {
+      aParArray[i] = CORBA::string_dup( (*parIt).c_str() );
+      aValArray[i] = CORBA::string_dup( (*valIt).c_str() );
+    }
+  }
 
-  // allocate the CORBA arrays, sizes == returned lists' sizes
-  GEOM::string_array_var anOpArray = new GEOM::string_array();
+  // initialize out-parameters with local arrays
+  theOperations = anOpArray._retn();
+  theParams = aParArray._retn();
+  theValues = aValArray._retn();
+}
+
+//=============================================================================
+/*!
+ *  GetOperatorParameters
+ */
+//=============================================================================
+void GEOM_IHealingOperations_i::GetOperatorParameters (const char* theOperator,  
+                                                      GEOM::string_array_out theParams, 
+                                                      GEOM::string_array_out theValues)
+{
   GEOM::string_array_var aParArray = new GEOM::string_array();
   GEOM::string_array_var aValArray = new GEOM::string_array();
-  anOpArray->length(opSize);
-  aParArray->length(parSize);
-  aValArray->length(valSize);
-
-  // fill the local CORBA arrays with values from lists
-  list<string>::iterator opIt, parIt, valIt;
-  int i = 0;
-  for ( opIt = operationsList.begin(); opIt != operationsList.end(); i++,++opIt )
-    anOpArray[i] = CORBA::string_dup( (*opIt).c_str() );
-
-  for ( i = 0, parIt = paramsList.begin(), valIt = valuesList.begin();
-       parIt != paramsList.end(); i++, ++parIt,++valIt )
-  {
-    aParArray[i] = CORBA::string_dup( (*parIt).c_str() );
-    aValArray[i] = CORBA::string_dup( (*valIt).c_str() );
+
+  // retrieve the values as stl-lists
+  list<string> paramsList, valuesList;
+  if ( GetOperations()->GetOperatorParameters( theOperator, paramsList, valuesList ) ) {
+    const int parSize = paramsList.size(), valSize = valuesList.size();
+
+    if ( parSize == valSize ) {
+      aParArray->length(parSize);
+      aValArray->length(valSize);
+
+      // fill the local CORBA arrays with values from lists
+      list<string>::iterator parIt, valIt;
+      int i;
+      for ( i = 0, parIt = paramsList.begin(), valIt = valuesList.begin();
+            parIt != paramsList.end(); i++, ++parIt,++valIt ) {
+       aParArray[i] = CORBA::string_dup( (*parIt).c_str() );
+       aValArray[i] = CORBA::string_dup( (*valIt).c_str() );
+      }
+    }
   }
 
   // initialize out-parameters with local arrays
-  theOperations = anOpArray._retn();
   theParams = aParArray._retn();
   theValues = aValArray._retn();
 }
@@ -399,3 +454,71 @@ CORBA::Boolean GEOM_IHealingOperations_i::GetFreeBoundary ( GEOM::GEOM_Object_pt
 
   return true;
 }
+
+
+//=============================================================================
+/*!
+ *  ChangeOrientation
+ */
+//=============================================================================
+GEOM::GEOM_Object_ptr GEOM_IHealingOperations_i::ChangeOrientation (GEOM::GEOM_Object_ptr theObject)
+{
+  GEOM::GEOM_Object_var aGEOMObject;
+
+  // Set a not done flag
+  GetOperations()->SetNotDone();
+
+  // Check parameters
+  if ( CORBA::is_nil(theObject) )
+    return aGEOMObject._retn();
+
+  aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
+
+  // Get the object itself
+  Handle(GEOM_Object) anObject =
+    GetOperations()->GetEngine()->GetObject(theObject->GetStudyID(), theObject->GetEntry());
+  if (anObject.IsNull())
+    return aGEOMObject._retn();
+
+  // Perform
+//  Handle(GEOM_Object) aNewObject =
+    GetOperations()->ChangeOrientation( anObject );
+//  if (!GetOperations()->IsDone() || aNewObject.IsNull())
+//    return aGEOMObject._retn();
+
+  //return GetObject(aNewObject);
+  return aGEOMObject._retn();  
+}
+
+
+//=============================================================================
+/*!
+ *  ChangeOrientationCopy
+ */
+//=============================================================================
+GEOM::GEOM_Object_ptr GEOM_IHealingOperations_i::ChangeOrientationCopy (GEOM::GEOM_Object_ptr theObject)
+{
+  GEOM::GEOM_Object_var aGEOMObject;
+
+  // Set a not done flag
+  GetOperations()->SetNotDone();
+
+  // Check parameters
+  if ( CORBA::is_nil(theObject) )
+    return aGEOMObject._retn();
+
+  // Get the object itself
+  Handle(GEOM_Object) anObject =
+    GetOperations()->GetEngine()->GetObject(theObject->GetStudyID(), theObject->GetEntry());
+  if (anObject.IsNull())
+    return aGEOMObject._retn();
+
+  // Perform
+  Handle(GEOM_Object) aNewObject =
+    GetOperations()->ChangeOrientationCopy( anObject );
+  if (!GetOperations()->IsDone() || aNewObject.IsNull())
+    return aGEOMObject._retn();
+
+  return GetObject(aNewObject);
+}
+