X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2FGEOMImpl%2FGEOMImpl_IHealingOperations.cxx;h=265a35f6cf926ae57200f367ea257eda1dbd1ad8;hb=de2617e3f55fc12bac2da61fcbaf2d96f1e38926;hp=d78c82d4ee5ccaa0da22bf5068504fd483b1f54e;hpb=004197ec827d52331f0d529202eb4e52a1c4388f;p=modules%2Fgeom.git diff --git a/src/GEOMImpl/GEOMImpl_IHealingOperations.cxx b/src/GEOMImpl/GEOMImpl_IHealingOperations.cxx index d78c82d4e..265a35f6c 100644 --- a/src/GEOMImpl/GEOMImpl_IHealingOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_IHealingOperations.cxx @@ -1,24 +1,23 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2011 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 +// Copyright (C) 2003-2007 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 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. +// 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 +// 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 #ifdef WNT #pragma warning( disable:4786 ) @@ -34,14 +33,18 @@ #include #include #include +#include +#include #include -#include +#include #include "utilities.h" #include #include +#include + #include #include @@ -56,19 +59,11 @@ #include #include // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC -#ifdef OCC_VERSION_SERVICEPACK -#define OCC_VERSION_LARGE (OCC_VERSION_MAJOR << 24 | OCC_VERSION_MINOR << 16 | OCC_VERSION_MAINTENANCE << 8 | OCC_VERSION_SERVICEPACK) -#else -#define OCC_VERSION_LARGE (OCC_VERSION_MAJOR << 24 | OCC_VERSION_MINOR << 16 | OCC_VERSION_MAINTENANCE << 8) -#endif - - //============================================================================= /*! * constructor: */ //============================================================================= - GEOMImpl_IHealingOperations::GEOMImpl_IHealingOperations (GEOM_Engine* theEngine, int theDocID) : GEOM_IOperations(theEngine, theDocID) { @@ -80,7 +75,6 @@ GEOMImpl_IHealingOperations::GEOMImpl_IHealingOperations (GEOM_Engine* theEngine * destructor */ //============================================================================= - GEOMImpl_IHealingOperations::~GEOMImpl_IHealingOperations() { MESSAGE("GEOMImpl_IHealingOperations::~GEOMImpl_IHealingOperations"); @@ -146,7 +140,7 @@ Handle(GEOM_Object) GEOMImpl_IHealingOperations::ShapeProcess (Handle(GEOM_Objec //Compute the translation try { -#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 +#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; #endif if (!GetSolver()->ComputeFunction(aFunction)) @@ -355,7 +349,7 @@ Handle(GEOM_Object) GEOMImpl_IHealingOperations::SuppressFaces //Compute the translation try { -#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 +#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; #endif if (!GetSolver()->ComputeFunction(aFunction)) @@ -425,7 +419,7 @@ Handle(GEOM_Object) GEOMImpl_IHealingOperations::CloseContour //Compute the translation try { -#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 +#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; #endif if (!GetSolver()->ComputeFunction(aFunction)) @@ -494,7 +488,7 @@ Handle(GEOM_Object) GEOMImpl_IHealingOperations::RemoveIntWires //Compute the translation try { -#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 +#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; #endif if (!GetSolver()->ComputeFunction(aFunction)) @@ -562,7 +556,7 @@ Handle(GEOM_Object) GEOMImpl_IHealingOperations::FillHoles (Handle(GEOM_Object) //Compute the translation try { -#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 +#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; #endif if (!GetSolver()->ComputeFunction(aFunction)) @@ -630,7 +624,7 @@ Handle(GEOM_Object) GEOMImpl_IHealingOperations::Sew (Handle(GEOM_Object) theObj //Compute the translation try { -#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 +#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; #endif if (!GetSolver()->ComputeFunction(aFunction)) @@ -693,7 +687,7 @@ Handle(GEOM_Object) GEOMImpl_IHealingOperations::DivideEdge (Handle(GEOM_Object) //Compute the translation try { -#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 +#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; #endif if (!GetSolver()->ComputeFunction(aFunction)) @@ -827,22 +821,34 @@ Handle(GEOM_Object) GEOMImpl_IHealingOperations::ChangeOrientation (Handle(GEOM_ if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be processed - //Add the function - aFunction = theObject->AddFunction(GEOMImpl_HealingDriver::GetID(), CHANGE_ORIENTATION); + if (theObject->GetType() == GEOM_VECTOR) { // Mantis issue 21066 + //Add the function + aFunction = theObject->AddFunction(GEOMImpl_VectorDriver::GetID(), VECTOR_REVERSE); - if (aFunction.IsNull()) - return NULL; + //Check if the function is set correctly + if (aFunction.IsNull()) return NULL; + if (aFunction->GetDriverGUID() != GEOMImpl_VectorDriver::GetID()) return NULL; - //Check if the function is set correctly - if (aFunction->GetDriverGUID() != GEOMImpl_HealingDriver::GetID()) return NULL; + // prepare "data container" class IVector + GEOMImpl_IVector aVI (aFunction); + aVI.SetCurve(aLastFunction); + } + else { + //Add the function + aFunction = theObject->AddFunction(GEOMImpl_HealingDriver::GetID(), CHANGE_ORIENTATION); - // prepare "data container" class IHealing - GEOMImpl_IHealing HI(aFunction); - HI.SetOriginal( aLastFunction ); + //Check if the function is set correctly + if (aFunction.IsNull()) return NULL; + if (aFunction->GetDriverGUID() != GEOMImpl_HealingDriver::GetID()) return NULL; + + // prepare "data container" class IHealing + GEOMImpl_IHealing HI (aFunction); + HI.SetOriginal(aLastFunction); + } //Compute the translation try { -#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 +#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; #endif if (!GetSolver()->ComputeFunction(aFunction)) { @@ -864,7 +870,6 @@ Handle(GEOM_Object) GEOMImpl_IHealingOperations::ChangeOrientation (Handle(GEOM_ return theObject; } - //============================================================================= /*! * ChangeOrientationCopy @@ -883,24 +888,36 @@ Handle(GEOM_Object) GEOMImpl_IHealingOperations::ChangeOrientationCopy (Handle(G return NULL; //There is no function which creates an object to be processed // Add a new object - Handle(GEOM_Object) aNewObject = GetEngine()->AddObject( GetDocID(), theObject->GetType() ); + Handle(GEOM_Object) aNewObject = GetEngine()->AddObject(GetDocID(), theObject->GetType()); - //Add the function - aFunction = aNewObject->AddFunction(GEOMImpl_HealingDriver::GetID(), CHANGE_ORIENTATION); + if (theObject->GetType() == GEOM_VECTOR) { // Mantis issue 21066 + //Add the function + aFunction = aNewObject->AddFunction(GEOMImpl_VectorDriver::GetID(), VECTOR_REVERSE); - if (aFunction.IsNull()) - return NULL; + //Check if the function is set correctly + if (aFunction.IsNull()) return NULL; + if (aFunction->GetDriverGUID() != GEOMImpl_VectorDriver::GetID()) return NULL; - //Check if the function is set correctly - if (aFunction->GetDriverGUID() != GEOMImpl_HealingDriver::GetID()) return NULL; + // prepare "data container" class IVector + GEOMImpl_IVector aVI (aFunction); + aVI.SetCurve(aLastFunction); + } + else { + //Add the function + aFunction = aNewObject->AddFunction(GEOMImpl_HealingDriver::GetID(), CHANGE_ORIENTATION); - // prepare "data container" class IHealing - GEOMImpl_IHealing HI(aFunction); - HI.SetOriginal( aLastFunction ); + //Check if the function is set correctly + if (aFunction.IsNull()) return NULL; + if (aFunction->GetDriverGUID() != GEOMImpl_HealingDriver::GetID()) return NULL; - //Compute the translation + // prepare "data container" class IHealing + GEOMImpl_IHealing aHI (aFunction); + aHI.SetOriginal(aLastFunction); + } + + // Compute the result try { -#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 +#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; #endif if (!GetSolver()->ComputeFunction(aFunction)) { @@ -921,3 +938,62 @@ Handle(GEOM_Object) GEOMImpl_IHealingOperations::ChangeOrientationCopy (Handle(G SetErrorCode(OK); return aNewObject; } + +//============================================================================= +/*! + * LimitTolerance + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_IHealingOperations::LimitTolerance (Handle(GEOM_Object) theObject, + double theTolerance) +{ + // Set error code, check parameters + SetErrorCode(KO); + + if (theObject.IsNull()) + return NULL; + + Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction(); + if (aLastFunction.IsNull()) + return NULL; // There is no function which creates an object to be processed + + // Add a new object + Handle(GEOM_Object) aNewObject = GetEngine()->AddObject(GetDocID(), theObject->GetType()); + + // Add the function + aFunction = aNewObject->AddFunction(GEOMImpl_HealingDriver::GetID(), LIMIT_TOLERANCE); + + if (aFunction.IsNull()) + return NULL; + + // Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_HealingDriver::GetID()) return NULL; + + // Prepare "data container" class IHealing + GEOMImpl_IHealing HI (aFunction); + HI.SetOriginal(aLastFunction); + HI.SetTolerance(theTolerance); + + // Compute + try { +#if OCC_VERSION_LARGE > 0x06010000 + OCC_CATCH_SIGNALS; +#endif + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Healing driver failed"); + return NULL; + } + } + catch (Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode(aFail->GetMessageString()); + return NULL; + } + + // Make a Python command + GEOM::TPythonDump(aFunction) << aNewObject << " = geompy.LimitTolerance(" + << theObject << ", " << theTolerance << ")"; + + SetErrorCode(OK); + return aNewObject; +}