-// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2022 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.
+// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
#include <GEOMImpl_PartitionDriver.hxx>
#include <GEOMImpl_IPartition.hxx>
-#include <Basics_OCCTVersion.hxx>
-
#include <TDF_Tool.hxx>
#include "utilities.h"
* constructor:
*/
//=============================================================================
-GEOMImpl_IBooleanOperations::GEOMImpl_IBooleanOperations (GEOM_Engine* theEngine, int theDocID)
-: GEOM_IOperations(theEngine, theDocID)
+GEOMImpl_IBooleanOperations::GEOMImpl_IBooleanOperations (GEOM_Engine* theEngine)
+: GEOM_IOperations(theEngine)
{
MESSAGE("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
- Handle(GEOM_Object) aBool = GetEngine()->AddObject(GetDocID(), GEOM_BOOLEAN);
+ Handle(GEOM_Object) aBool = GetEngine()->AddObject(GEOM_BOOLEAN);
//Add a new Boolean function
Handle(GEOM_Function) aFunction;
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());
+ catch (Standard_Failure& aFail) {
+ SetErrorCode(aFail.GetMessageString());
return NULL;
}
else if (theOp == 3) pd << " = geompy.MakeFuse(";
else if (theOp == 4) pd << " = geompy.MakeSection(";
else {}
- pd << theShape1 << ", " << theShape2 << ")";
+ pd << theShape1 << ", " << theShape2;
+
+ if (IsCheckSelfInte) {
+ pd << ", True";
+ }
+
+ pd << ")";
+
+ SetErrorCode(OK);
+ return aBool;
+}
+
+//=============================================================================
+/*!
+ * MakeFuse
+ */
+//=============================================================================
+Handle(GEOM_Object) GEOMImpl_IBooleanOperations::MakeFuse
+ (Handle(GEOM_Object) theShape1,
+ Handle(GEOM_Object) theShape2,
+ const bool IsCheckSelfInte,
+ const bool IsRmExtraEdges)
+{
+ SetErrorCode(KO);
+
+ if (theShape1.IsNull() || theShape2.IsNull()) return NULL;
+
+ //Add a new Boolean object
+ Handle(GEOM_Object) aBool = GetEngine()->AddObject(GEOM_BOOLEAN);
+
+ //Add a new Boolean function
+ Handle(GEOM_Function) aFunction =
+ aBool->AddFunction(GEOMImpl_BooleanDriver::GetID(), BOOLEAN_FUSE);
+
+ 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) aRef1 = theShape1->GetLastFunction();
+ Handle(GEOM_Function) aRef2 = theShape2->GetLastFunction();
+
+ if (aRef1.IsNull() || aRef2.IsNull()) return NULL;
+
+ aCI.SetShape1(aRef1);
+ aCI.SetShape2(aRef2);
+ aCI.SetCheckSelfIntersection(IsCheckSelfInte);
+ aCI.SetRmExtraEdges(IsRmExtraEdges);
+
+ //Compute the Boolean value
+ try {
+ OCC_CATCH_SIGNALS;
+ if (!GetSolver()->ComputeFunction(aFunction)) {
+ SetErrorCode("Boolean driver failed");
+ return NULL;
+ }
+ }
+ catch (Standard_Failure& aFail) {
+ SetErrorCode(aFail.GetMessageString());
+ return NULL;
+ }
+
+ //Make a Python command
+ GEOM::TPythonDump pd (aFunction);
+
+ pd << aBool << " = geompy.MakeFuse(";
+ pd << theShape1 << ", " << theShape2 << ", "
+ << IsCheckSelfInte << ", " << IsRmExtraEdges << ")";
SetErrorCode(OK);
return aBool;
*/
//=============================================================================
Handle(GEOM_Object) GEOMImpl_IBooleanOperations::MakeFuseList
- (const Handle(TColStd_HSequenceOfTransient)& theShapes)
+ (const Handle(TColStd_HSequenceOfTransient)& theShapes,
+ const bool IsCheckSelfInte,
+ const bool IsRmExtraEdges)
{
SetErrorCode(KO);
if (theShapes.IsNull()) return NULL;
//Add a new Boolean object
- Handle(GEOM_Object) aBool = GetEngine()->AddObject(GetDocID(), GEOM_BOOLEAN);
+ Handle(GEOM_Object) aBool = GetEngine()->AddObject(GEOM_BOOLEAN);
//Add a new Boolean function
Handle(GEOM_Function) aFunction =
if (aShapesSeq.IsNull()) return NULL;
aCI.SetShapes(aShapesSeq);
+ aCI.SetCheckSelfIntersection(IsCheckSelfInte);
+ aCI.SetRmExtraEdges(IsRmExtraEdges);
//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());
+ catch (Standard_Failure& aFail) {
+ SetErrorCode(aFail.GetMessageString());
return NULL;
}
//Make a Python command
- GEOM::TPythonDump(aFunction) << aBool <<
- " = geompy.MakeFuseList([" << aDescription.ToCString() << "])";
+ GEOM::TPythonDump pd (aFunction);
+
+ pd << aBool << " = geompy.MakeFuseList([" << aDescription.ToCString() << "], "
+ << IsCheckSelfInte << ", " << IsRmExtraEdges << ")";
SetErrorCode(OK);
return aBool;
*/
//=============================================================================
Handle(GEOM_Object) GEOMImpl_IBooleanOperations::MakeCommonList
- (const Handle(TColStd_HSequenceOfTransient)& theShapes)
+ (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);
+ Handle(GEOM_Object) aBool = GetEngine()->AddObject(GEOM_BOOLEAN);
//Add a new Boolean function
Handle(GEOM_Function) aFunction =
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());
+ catch (Standard_Failure& aFail) {
+ SetErrorCode(aFail.GetMessageString());
return NULL;
}
//Make a Python command
- GEOM::TPythonDump(aFunction) << aBool <<
- " = geompy.MakeCommonList([" << aDescription.ToCString() << "])";
+ GEOM::TPythonDump pd (aFunction);
+
+ pd << aBool <<
+ " = geompy.MakeCommonList([" << aDescription.ToCString() << "]";
+
+ if (IsCheckSelfInte) {
+ pd << ", True";
+ }
+
+ pd << ")";
SetErrorCode(OK);
return aBool;
//=============================================================================
Handle(GEOM_Object) GEOMImpl_IBooleanOperations::MakeCutList
(Handle(GEOM_Object) theMainShape,
- const Handle(TColStd_HSequenceOfTransient)& theShapes)
+ 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);
+ Handle(GEOM_Object) aBool = GetEngine()->AddObject(GEOM_BOOLEAN);
//Add a new Boolean function
Handle(GEOM_Function) aFunction =
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;
}
}
- catch (Standard_Failure) {
- Handle(Standard_Failure) aFail = Standard_Failure::Caught();
- SetErrorCode(aFail->GetMessageString());
+ catch (Standard_Failure& aFail) {
+ SetErrorCode(aFail.GetMessageString());
return NULL;
}
//Make a Python command
- GEOM::TPythonDump(aFunction) << aBool << " = geompy.MakeCutList("
- << theMainShape << ", [" << aDescription.ToCString() << "])";
+ GEOM::TPythonDump pd (aFunction);
+
+ pd << aBool << " = geompy.MakeCutList("
+ << theMainShape << ", [" << aDescription.ToCString() << "]";
+
+ if (IsCheckSelfInte) {
+ pd << ", True";
+ }
+
+ pd << ")";
SetErrorCode(OK);
return aBool;
const Standard_Boolean theRemoveWebs,
const Handle(TColStd_HArray1OfInteger)& theMaterials,
const Standard_Integer theKeepNonlimitShapes,
- const Standard_Boolean thePerformSelfIntersections)
+ const Standard_Boolean thePerformSelfIntersections,
+ const Standard_Boolean IsCheckSelfInte)
{
SetErrorCode(KO);
//Add a new Partition object
- Handle(GEOM_Object) aPartition = GetEngine()->AddObject(GetDocID(), GEOM_PARTITION);
+ Handle(GEOM_Object) aPartition = GetEngine()->AddObject(GEOM_PARTITION);
//Add a new Partition function
Handle(GEOM_Function) aFunction;
// Limit
aCI.SetLimit(theLimit);
aCI.SetKeepNonlimitShapes(theKeepNonlimitShapes);
+ aCI.SetCheckSelfIntersection(IsCheckSelfInte);
// Materials
if (theRemoveWebs) {
//Compute the Partition
try {
-#if OCC_VERSION_LARGE > 0x06010000
OCC_CATCH_SIGNALS;
-#endif
if (!GetSolver()->ComputeFunction(aFunction)) {
SetErrorCode("Partition driver failed");
return NULL;
}
}
- catch (Standard_Failure) {
- Handle(Standard_Failure) aFail = Standard_Failure::Caught();
- SetErrorCode(aFail->GetMessageString());
+ catch (Standard_Failure& aFail) {
+ SetErrorCode(aFail.GetMessageString());
return NULL;
}
pd << ", " << theMaterials->Value(i);
}
}
- pd << "], " << theKeepNonlimitShapes <<")";
+ pd << "], " << theKeepNonlimitShapes;
+
+ if (IsCheckSelfInte && !thePerformSelfIntersections) {
+ pd << ", True";
+ }
+
+ pd << ")";
SetErrorCode(OK);
return aPartition;
if (theShape.IsNull() || thePlane.IsNull()) return NULL;
//Add a new Boolean object
- Handle(GEOM_Object) aPart = GetEngine()->AddObject(GetDocID(), GEOM_PARTITION);
+ Handle(GEOM_Object) aPart = GetEngine()->AddObject(GEOM_PARTITION);
//Add a new Partition function
Handle(GEOM_Function) aFunction =
//Compute the Partition value
try {
-#if OCC_VERSION_LARGE > 0x06010000
OCC_CATCH_SIGNALS;
-#endif
if (!GetSolver()->ComputeFunction(aFunction)) {
SetErrorCode("Partition driver failed");
return NULL;
}
}
- catch (Standard_Failure) {
- Handle(Standard_Failure) aFail = Standard_Failure::Caught();
- SetErrorCode(aFail->GetMessageString());
+ catch (Standard_Failure& aFail) {
+ SetErrorCode(aFail.GetMessageString());
return NULL;
}
//Make a Python command
- GEOM::TPythonDump(aFunction) << aPart << " = geompy.MakeHalfPartition("
- << theShape << ", " << thePlane << ")";
+ GEOM::TPythonDump pd (aFunction);
+ pd << aPart << " = geompy.MakeHalfPartition("
+ << theShape << ", " << thePlane << ")";
SetErrorCode(OK);
return aPart;