Back to index

salome-geom  6.5.0
Functions
GEOMImpl_IBooleanOperations.cxx File Reference
#include <Standard_Stream.hxx>
#include <GEOMImpl_IBooleanOperations.hxx>
#include <GEOM_Function.hxx>
#include <GEOM_PythonDump.hxx>
#include <GEOMImpl_Types.hxx>
#include <GEOMImpl_BooleanDriver.hxx>
#include <GEOMImpl_IBoolean.hxx>
#include <GEOMImpl_PartitionDriver.hxx>
#include <GEOMImpl_IPartition.hxx>
#include <Basics_OCCTVersion.hxx>
#include <TDF_Tool.hxx>
#include "utilities.h"
#include <Standard_Failure.hxx>
#include <Standard_ErrorHandler.hxx>

Go to the source code of this file.

Functions

 Handle (GEOM_Object) GEOMImpl_IBooleanOperations
 MakeBoolean.

Function Documentation

MakeBoolean.

GetObject.

MakeHalfPartition.

MakePartition.

Definition at line 74 of file GEOMImpl_IBooleanOperations.cxx.

{
  SetErrorCode(KO);

  if (theShape1.IsNull() || theShape2.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;
  if (theOp == 1) {
    aFunction = aBool->AddFunction(GEOMImpl_BooleanDriver::GetID(), BOOLEAN_COMMON);
  } else if (theOp == 2) {
    aFunction = aBool->AddFunction(GEOMImpl_BooleanDriver::GetID(), BOOLEAN_CUT);
  } else if (theOp == 3) {
    aFunction = aBool->AddFunction(GEOMImpl_BooleanDriver::GetID(), BOOLEAN_FUSE);
  } else if (theOp == 4) {
    aFunction = aBool->AddFunction(GEOMImpl_BooleanDriver::GetID(), BOOLEAN_SECTION);
  } else {
  }
  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);

  //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 << ")";

  SetErrorCode(OK);
  return aBool;
}

Here is the call graph for this function: