X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FGEOMImpl%2FGEOMImpl_IBooleanOperations.cxx;h=be4bfb3d3757ff306d8725eb3181a79e247c8753;hb=982407874b25696ca989bf21ce96e1d309045fcf;hp=ad6fba6f4992e19bb78f8b9213d4886535da2556;hpb=d3dd282390888d7dc091ba2c2ffe7923bd7458e6;p=modules%2Fgeom.git diff --git a/src/GEOMImpl/GEOMImpl_IBooleanOperations.cxx b/src/GEOMImpl/GEOMImpl_IBooleanOperations.cxx index ad6fba6f4..be4bfb3d3 100644 --- a/src/GEOMImpl/GEOMImpl_IBooleanOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_IBooleanOperations.cxx @@ -1,20 +1,47 @@ -using namespace std; - -#include "GEOMImpl_IBooleanOperations.hxx" - -#include "GEOM_Function.hxx" -#include "GEOMImpl_Types.hxx" - -#include "GEOMImpl_BooleanDriver.hxx" -#include "GEOMImpl_IBoolean.hxx" - -#include "GEOMImpl_PartitionDriver.hxx" -#include "GEOMImpl_IPartition.hxx" +// Copyright (C) 2007-2013 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 +// +// 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 + +#include + +#include +#include + +#include + +#include +#include + +#include +#include + +#include #include #include "utilities.h" +#include #include // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC //============================================================================= @@ -22,7 +49,7 @@ using namespace std; * constructor: */ //============================================================================= -GEOMImpl_IBooleanOperations::GEOMImpl_IBooleanOperations (GEOM_Engine* theEngine, int theDocID) +GEOMImpl_IBooleanOperations::GEOMImpl_IBooleanOperations (GEOM_Engine* theEngine, int theDocID) : GEOM_IOperations(theEngine, theDocID) { MESSAGE("GEOMImpl_IBooleanOperations::GEOMImpl_IBooleanOperations"); @@ -44,17 +71,19 @@ GEOMImpl_IBooleanOperations::~GEOMImpl_IBooleanOperations() * MakeBoolean */ //============================================================================= -Handle(GEOM_Object) GEOMImpl_IBooleanOperations::MakeBoolean (Handle(GEOM_Object) theShape1, - Handle(GEOM_Object) theShape2, - Standard_Integer theOp) +Handle(GEOM_Object) GEOMImpl_IBooleanOperations::MakeBoolean + (Handle(GEOM_Object) theShape1, + Handle(GEOM_Object) theShape2, + const Standard_Integer theOp, + const Standard_Boolean IsCheckSelfInte) { SetErrorCode(KO); if (theShape1.IsNull() || theShape2.IsNull()) return NULL; - - //Add a new Boolean object + + //Add a new Boolean object Handle(GEOM_Object) aBool = GetEngine()->AddObject(GetDocID(), GEOM_BOOLEAN); - + //Add a new Boolean function Handle(GEOM_Function) aFunction; if (theOp == 1) { @@ -70,10 +99,10 @@ Handle(GEOM_Object) GEOMImpl_IBooleanOperations::MakeBoolean (Handle(GEOM_Object if (aFunction.IsNull()) return NULL; //Check if the function is set correctly - if (aFunction->GetDriverGUID() != GEOMImpl_BooleanDriver::GetID()) return NULL; + if (aFunction->GetDriverGUID() != GEOMImpl_BooleanDriver::GetID()) return NULL; GEOMImpl_IBoolean aCI (aFunction); - + Handle(GEOM_Function) aRef1 = theShape1->GetLastFunction(); Handle(GEOM_Function) aRef2 = theShape2->GetLastFunction(); @@ -81,9 +110,226 @@ Handle(GEOM_Object) GEOMImpl_IBooleanOperations::MakeBoolean (Handle(GEOM_Object aCI.SetShape1(aRef1); aCI.SetShape2(aRef2); + aCI.SetCheckSelfIntersection(IsCheckSelfInte); + + //Compute the Boolean value + try { +#if OCC_VERSION_LARGE > 0x06010000 + OCC_CATCH_SIGNALS; +#endif + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Boolean 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 pd (aFunction); + pd << aBool; + if (theOp == 1) pd << " = geompy.MakeCommon("; + else if (theOp == 2) pd << " = geompy.MakeCut("; + else if (theOp == 3) pd << " = geompy.MakeFuse("; + else if (theOp == 4) pd << " = geompy.MakeSection("; + else {} + pd << theShape1 << ", " << theShape2; + + if (IsCheckSelfInte) { + pd << ", True"; + } + + pd << ")"; + + SetErrorCode(OK); + return aBool; +} + +//============================================================================= +/*! + * MakeFuseList + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_IBooleanOperations::MakeFuseList + (const Handle(TColStd_HSequenceOfTransient)& theShapes, + const Standard_Boolean IsCheckSelfInte) +{ + SetErrorCode(KO); + + if (theShapes.IsNull()) return NULL; + + //Add a new Boolean object + Handle(GEOM_Object) aBool = GetEngine()->AddObject(GetDocID(), GEOM_BOOLEAN); + + //Add a new Boolean function + Handle(GEOM_Function) aFunction = + aBool->AddFunction(GEOMImpl_BooleanDriver::GetID(), BOOLEAN_FUSE_LIST); + + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_BooleanDriver::GetID()) return NULL; + + GEOMImpl_IBoolean aCI (aFunction); + + TCollection_AsciiString aDescription; + Handle(TColStd_HSequenceOfTransient) aShapesSeq = + getShapeFunctions(theShapes, aDescription); + + if (aShapesSeq.IsNull()) return NULL; + + aCI.SetShapes(aShapesSeq); + aCI.SetCheckSelfIntersection(IsCheckSelfInte); + + //Compute the Boolean value + try { +#if OCC_VERSION_LARGE > 0x06010000 + OCC_CATCH_SIGNALS; +#endif + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Boolean 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 pd (aFunction); + + pd << aBool << + " = geompy.MakeFuseList([" << aDescription.ToCString() << "]"; + + if (IsCheckSelfInte) { + pd << ", True"; + } + + pd << ")"; + + SetErrorCode(OK); + return aBool; +} + +//============================================================================= +/*! + * MakeCommonList + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_IBooleanOperations::MakeCommonList + (const Handle(TColStd_HSequenceOfTransient)& theShapes, + const Standard_Boolean IsCheckSelfInte) +{ + SetErrorCode(KO); + + if (theShapes.IsNull()) return NULL; + + //Add a new Boolean object + Handle(GEOM_Object) aBool = GetEngine()->AddObject(GetDocID(), GEOM_BOOLEAN); + + //Add a new Boolean function + Handle(GEOM_Function) aFunction = + aBool->AddFunction(GEOMImpl_BooleanDriver::GetID(), BOOLEAN_COMMON_LIST); + + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_BooleanDriver::GetID()) return NULL; + + GEOMImpl_IBoolean aCI (aFunction); + + TCollection_AsciiString aDescription; + Handle(TColStd_HSequenceOfTransient) aShapesSeq = + getShapeFunctions(theShapes, aDescription); + + if (aShapesSeq.IsNull()) return NULL; + + aCI.SetShapes(aShapesSeq); + aCI.SetCheckSelfIntersection(IsCheckSelfInte); + + //Compute the Boolean value + try { +#if OCC_VERSION_LARGE > 0x06010000 + OCC_CATCH_SIGNALS; +#endif + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Boolean 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 pd (aFunction); + + pd << aBool << + " = geompy.MakeCommonList([" << aDescription.ToCString() << "]"; + + if (IsCheckSelfInte) { + pd << ", True"; + } + + pd << ")"; + + SetErrorCode(OK); + return aBool; +} + +//============================================================================= +/*! + * MakeCutList + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_IBooleanOperations::MakeCutList + (Handle(GEOM_Object) theMainShape, + const Handle(TColStd_HSequenceOfTransient)& theShapes, + const Standard_Boolean IsCheckSelfInte) +{ + SetErrorCode(KO); + + if (theShapes.IsNull()) return NULL; + + //Add a new Boolean object + Handle(GEOM_Object) aBool = GetEngine()->AddObject(GetDocID(), GEOM_BOOLEAN); + + //Add a new Boolean function + Handle(GEOM_Function) aFunction = + aBool->AddFunction(GEOMImpl_BooleanDriver::GetID(), BOOLEAN_CUT_LIST); + + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_BooleanDriver::GetID()) return NULL; + + GEOMImpl_IBoolean aCI (aFunction); + Handle(GEOM_Function) aMainRef = theMainShape->GetLastFunction(); + + if (aMainRef.IsNull()) return NULL; + + TCollection_AsciiString aDescription; + Handle(TColStd_HSequenceOfTransient) aShapesSeq = + getShapeFunctions(theShapes, aDescription); + + if (aShapesSeq.IsNull()) return NULL; + + aCI.SetShape1(aMainRef); + aCI.SetShapes(aShapesSeq); + aCI.SetCheckSelfIntersection(IsCheckSelfInte); //Compute the Boolean value try { +#if OCC_VERSION_LARGE > 0x06010000 + OCC_CATCH_SIGNALS; +#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Boolean driver failed"); return NULL; @@ -95,21 +341,20 @@ Handle(GEOM_Object) GEOMImpl_IBooleanOperations::MakeBoolean (Handle(GEOM_Object return NULL; } - //Make a Python command - TCollection_AsciiString anEntry, aDescr(""); - TDF_Tool::Entry(aBool->GetEntry(), anEntry); - aDescr += anEntry; - aDescr += " = IBooleanOperations.MakeBoolean("; - TDF_Tool::Entry(theShape1->GetEntry(), anEntry); - aDescr += (anEntry+", "); - TDF_Tool::Entry(theShape2->GetEntry(), anEntry); - aDescr += (anEntry+", "); - aDescr += (TCollection_AsciiString(theOp)+")"); + //Make a Python command + GEOM::TPythonDump pd (aFunction); + + pd << aBool << " = geompy.MakeCutList(" + << theMainShape << ", [" << aDescription.ToCString() << "]"; - aFunction->SetDescription(aDescr); + if (IsCheckSelfInte) { + pd << ", True"; + } + + pd << ")"; SetErrorCode(OK); - return aBool; + return aBool; } //============================================================================= @@ -118,121 +363,87 @@ Handle(GEOM_Object) GEOMImpl_IBooleanOperations::MakeBoolean (Handle(GEOM_Object */ //============================================================================= Handle(GEOM_Object) GEOMImpl_IBooleanOperations::MakePartition - (const Handle(TColStd_HSequenceOfTransient)& theShapes, + (const Handle(TColStd_HSequenceOfTransient)& theShapes, const Handle(TColStd_HSequenceOfTransient)& theTools, const Handle(TColStd_HSequenceOfTransient)& theKeepIns, const Handle(TColStd_HSequenceOfTransient)& theRemoveIns, - const Standard_Integer theLimit, - const Standard_Boolean theRemoveWebs, - const Handle(TColStd_HArray1OfInteger)& theMaterials) + const Standard_Integer theLimit, + const Standard_Boolean theRemoveWebs, + const Handle(TColStd_HArray1OfInteger)& theMaterials, + const Standard_Integer theKeepNonlimitShapes, + const Standard_Boolean thePerformSelfIntersections) { SetErrorCode(KO); - //Add a new Partition object + //Add a new Partition object Handle(GEOM_Object) aPartition = GetEngine()->AddObject(GetDocID(), GEOM_PARTITION); - + //Add a new Partition function - Handle(GEOM_Function) aFunction = - aPartition->AddFunction(GEOMImpl_PartitionDriver::GetID(), PARTITION_PARTITION); + Handle(GEOM_Function) aFunction; + if (thePerformSelfIntersections) + aFunction = aPartition->AddFunction(GEOMImpl_PartitionDriver::GetID(), PARTITION_PARTITION); + else + aFunction = aPartition->AddFunction(GEOMImpl_PartitionDriver::GetID(), PARTITION_NO_SELF_INTERSECTIONS); if (aFunction.IsNull()) return NULL; //Check if the function is set correctly - if (aFunction->GetDriverGUID() != GEOMImpl_PartitionDriver::GetID()) return NULL; + if (aFunction->GetDriverGUID() != GEOMImpl_PartitionDriver::GetID()) return NULL; GEOMImpl_IPartition aCI (aFunction); - -// int aLen = theShapes.size(); -// aCI.SetLength(aLen); - - Handle(TColStd_HSequenceOfTransient) aShapesSeq = new TColStd_HSequenceOfTransient; - Handle(TColStd_HSequenceOfTransient) aToolsSeq = new TColStd_HSequenceOfTransient; - Handle(TColStd_HSequenceOfTransient) aKeepInsSeq = new TColStd_HSequenceOfTransient; - Handle(TColStd_HSequenceOfTransient) aRemInsSeq = new TColStd_HSequenceOfTransient; - Standard_Integer ind, aLen; - TCollection_AsciiString anEntry; + Handle(TColStd_HSequenceOfTransient) aShapesSeq; + Handle(TColStd_HSequenceOfTransient) aToolsSeq; + Handle(TColStd_HSequenceOfTransient) aKeepInsSeq; + Handle(TColStd_HSequenceOfTransient) aRemInsSeq; TCollection_AsciiString aShapesDescr, aToolsDescr, aKeepInsDescr, aRemoveInsDescr; // Shapes - aLen = theShapes->Length(); - for (ind = 1; ind <= aLen; ind++) { - Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(theShapes->Value(ind)); - Handle(GEOM_Function) aRefSh = anObj->GetLastFunction(); - if (aRefSh.IsNull()) { - SetErrorCode("NULL shape for Partition"); - return NULL; - } - aShapesSeq->Append(aRefSh); + aShapesSeq = getShapeFunctions(theShapes, aShapesDescr); - // For Python command - TDF_Tool::Entry(anObj->GetEntry(), anEntry); - if (ind > 1) aShapesDescr += ", "; - aShapesDescr += anEntry; + if (aShapesSeq.IsNull()) { + SetErrorCode("NULL shape for Partition"); + return NULL; } - aCI.SetShapes(aShapesSeq); // Tools - aLen = theTools->Length(); - for (ind = 1; ind <= aLen; ind++) { - Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(theTools->Value(ind)); - Handle(GEOM_Function) aRefSh = anObj->GetLastFunction(); - if (aRefSh.IsNull()) { - SetErrorCode("NULL tool shape for Partition"); - return NULL; - } - aToolsSeq->Append(aRefSh); + aToolsSeq = getShapeFunctions(theTools, aToolsDescr); - // For Python command - TDF_Tool::Entry(anObj->GetEntry(), anEntry); - if (ind > 1) aToolsDescr += ", "; - aToolsDescr += anEntry; + if (aToolsSeq.IsNull()) { + SetErrorCode("NULL tool shape for Partition"); + return NULL; } - aCI.SetTools(aToolsSeq); // Keep Inside - aLen = theKeepIns->Length(); - for (ind = 1; ind <= aLen; ind++) { - Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(theKeepIns->Value(ind)); - Handle(GEOM_Function) aRefSh = anObj->GetLastFunction(); - if (aRefSh.IsNull()) { - SetErrorCode("NULL shape for Partition"); - return NULL; - } - aKeepInsSeq->Append(aRefSh); + aKeepInsSeq = getShapeFunctions(theKeepIns, aKeepInsDescr); - // For Python command - TDF_Tool::Entry(anObj->GetEntry(), anEntry); - if (ind > 1) aKeepInsDescr += ", "; - aKeepInsDescr += anEntry; + if (aKeepInsSeq.IsNull()) { + SetErrorCode("NULL shape for Partition"); + return NULL; } - aCI.SetKeepIns(aKeepInsSeq); // Remove Inside - aLen = theRemoveIns->Length(); - for (ind = 1; ind <= aLen; ind++) { - Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(theRemoveIns->Value(ind)); - Handle(GEOM_Function) aRefSh = anObj->GetLastFunction(); - if (aRefSh.IsNull()) { - SetErrorCode("NULL shape for Partition"); - return NULL; - } - aRemInsSeq->Append(aRefSh); + aRemInsSeq = getShapeFunctions(theRemoveIns, aRemoveInsDescr); - // For Python command - TDF_Tool::Entry(anObj->GetEntry(), anEntry); - if (ind > 1) aRemoveInsDescr += ", "; - aRemoveInsDescr += anEntry; + if (aRemInsSeq.IsNull()) { + SetErrorCode("NULL shape for Partition"); + return NULL; } + + aCI.SetShapes(aShapesSeq); + aCI.SetTools(aToolsSeq); + aCI.SetKeepIns(aKeepInsSeq); aCI.SetRemoveIns(aRemInsSeq); // Limit aCI.SetLimit(theLimit); + aCI.SetKeepNonlimitShapes(theKeepNonlimitShapes); // Materials if (theRemoveWebs) { if (theMaterials.IsNull()) { Handle(TColStd_HArray1OfInteger) aMaterials = new TColStd_HArray1OfInteger (1, aShapesSeq->Length()); + aMaterials->Init(0); aCI.SetMaterials(aMaterials); } else { aCI.SetMaterials(theMaterials); @@ -241,6 +452,9 @@ Handle(GEOM_Object) GEOMImpl_IBooleanOperations::MakePartition //Compute the Partition try { +#if OCC_VERSION_LARGE > 0x06010000 + OCC_CATCH_SIGNALS; +#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Partition driver failed"); return NULL; @@ -252,40 +466,32 @@ Handle(GEOM_Object) GEOMImpl_IBooleanOperations::MakePartition return NULL; } - //Make a Python command - TCollection_AsciiString aDescr; - TDF_Tool::Entry(aPartition->GetEntry(), anEntry); - aDescr += anEntry; - aDescr += " = IBooleanOperations.MakePartition(["; - // Shapes - aDescr += aShapesDescr + "], ["; - // Tools - aDescr += aToolsDescr + "], ["; - // Keep Ins - aDescr += aKeepInsDescr + "], ["; - // Remove Ins - aDescr += aRemoveInsDescr + "], "; - // Limit - aDescr += TCollection_AsciiString(theLimit) + ", "; - // Remove Webs - if (theRemoveWebs) aDescr += "1, ["; - else aDescr += "0, ["; + //Make a Python command + GEOM::TPythonDump pd (aFunction); + if (thePerformSelfIntersections) + pd << aPartition << " = geompy.MakePartition(["; + else + pd << aPartition << " = geompy.MakePartitionNonSelfIntersectedShape(["; + + // Shapes, Tools + pd << aShapesDescr.ToCString() << "], [" << aToolsDescr.ToCString() << "], ["; + // Keep Ins, Remove Ins + pd << aKeepInsDescr.ToCString() << "], [" << aRemoveInsDescr.ToCString() << "], "; + // Limit, Remove Webs + pd << TopAbs_ShapeEnum(theLimit) << ", " << (int)theRemoveWebs << ", ["; // Materials - if (theMaterials->Length() > 0) { + if (!theMaterials.IsNull() && theMaterials->Length() > 0) { int i = theMaterials->Lower(); - aDescr += TCollection_AsciiString(theMaterials->Value(i)); + pd << theMaterials->Value(i); i++; for (; i <= theMaterials->Upper(); i++) { - aDescr += ", "; - aDescr += TCollection_AsciiString(theMaterials->Value(i)); + pd << ", " << theMaterials->Value(i); } } - aDescr += "])"; - - aFunction->SetDescription(aDescr); + pd << "], " << theKeepNonlimitShapes <<")"; SetErrorCode(OK); - return aPartition; + return aPartition; } //============================================================================= @@ -299,20 +505,20 @@ Handle(GEOM_Object) GEOMImpl_IBooleanOperations::MakeHalfPartition SetErrorCode(KO); if (theShape.IsNull() || thePlane.IsNull()) return NULL; - - //Add a new Boolean object - Handle(GEOM_Object) aPart = GetEngine()->AddObject(GetDocID(), GEOM_BOOLEAN); - + + //Add a new Boolean object + Handle(GEOM_Object) aPart = GetEngine()->AddObject(GetDocID(), GEOM_PARTITION); + //Add a new Partition function Handle(GEOM_Function) aFunction = aPart->AddFunction(GEOMImpl_PartitionDriver::GetID(), PARTITION_HALF); if (aFunction.IsNull()) return NULL; //Check if the function is set correctly - if (aFunction->GetDriverGUID() != GEOMImpl_PartitionDriver::GetID()) return NULL; + if (aFunction->GetDriverGUID() != GEOMImpl_PartitionDriver::GetID()) return NULL; GEOMImpl_IPartition aCI (aFunction); - + Handle(GEOM_Function) aRef1 = theShape->GetLastFunction(); Handle(GEOM_Function) aRef2 = thePlane->GetLastFunction(); @@ -323,6 +529,9 @@ Handle(GEOM_Object) GEOMImpl_IBooleanOperations::MakeHalfPartition //Compute the Partition value try { +#if OCC_VERSION_LARGE > 0x06010000 + OCC_CATCH_SIGNALS; +#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Partition driver failed"); return NULL; @@ -334,18 +543,53 @@ Handle(GEOM_Object) GEOMImpl_IBooleanOperations::MakeHalfPartition return NULL; } - //Make a Python command - TCollection_AsciiString anEntry, aDescr; - TDF_Tool::Entry(aPart->GetEntry(), anEntry); - aDescr += anEntry; - aDescr += " = IBooleanOperations.MakePartition("; - TDF_Tool::Entry(theShape->GetEntry(), anEntry); - aDescr += (anEntry+", "); - TDF_Tool::Entry(thePlane->GetEntry(), anEntry); - aDescr += (anEntry+")"); - - aFunction->SetDescription(aDescr); + //Make a Python command + GEOM::TPythonDump(aFunction) << aPart << " = geompy.MakeHalfPartition(" + << theShape << ", " << thePlane << ")"; SetErrorCode(OK); - return aPart; + return aPart; +} + +//============================================================================= +/*! + * getShapeFunctions + */ +//============================================================================= +Handle(TColStd_HSequenceOfTransient) + GEOMImpl_IBooleanOperations::getShapeFunctions + (const Handle(TColStd_HSequenceOfTransient)& theObjects, + TCollection_AsciiString &theDescription) +{ + Handle(TColStd_HSequenceOfTransient) aResult = + new TColStd_HSequenceOfTransient; + Standard_Integer aNbObjects = theObjects->Length(); + Standard_Integer i; + TCollection_AsciiString anEntry; + Handle(GEOM_Object) anObj; + Handle(GEOM_Function) aRefObj; + + // Shapes + for (i = 1; i <= aNbObjects; i++) { + anObj = Handle(GEOM_Object)::DownCast(theObjects->Value(i)); + aRefObj = anObj->GetLastFunction(); + + if (aRefObj.IsNull()) { + aResult.Nullify(); + break; + } + + aResult->Append(aRefObj); + + // For Python command + TDF_Tool::Entry(anObj->GetEntry(), anEntry); + + if (i > 1) { + theDescription += ", "; + } + + theDescription += anEntry; + } + + return aResult; }