#include <ModelAPI_AttributeReference.h>
#include <ModelAPI_AttributeInteger.h>
#include <ModelAPI_ResultBody.h>
+#include <ModelAPI_AttributeSelectionList.h>
#include <GeomAlgoAPI_Boolean.h>
using namespace std;
+//#define DEBUG_ONE_OBJECT
+
#define FACE 4
#define _MODIFY_TAG 1
#define _DELETED_TAG 2
void FeaturesPlugin_Boolean::initAttributes()
{
data()->addAttribute(FeaturesPlugin_Boolean::TYPE_ID(), ModelAPI_AttributeInteger::typeId());
+
+#ifdef DEBUG_ONE_OBJECT
data()->addAttribute(FeaturesPlugin_Boolean::OBJECT_ID(), ModelAPI_AttributeReference::typeId());
+#else
+ AttributeSelectionListPtr aSelection =
+ std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(data()->addAttribute(
+ FeaturesPlugin_Boolean::OBJECT_LIST_ID(), ModelAPI_AttributeSelectionList::typeId()));
+ // extrusion works with faces always
+ aSelection->setSelectionType("SOLID");
+#endif
+
+#ifdef DEBUG_ONE_OBJECT
data()->addAttribute(FeaturesPlugin_Boolean::TOOL_ID(), ModelAPI_AttributeReference::typeId());
+#else
+ aSelection = std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(data()->addAttribute(
+ FeaturesPlugin_Boolean::TOOL_LIST_ID(), ModelAPI_AttributeSelectionList::typeId()));
+ // extrusion works with faces always
+ aSelection->setSelectionType("SOLID");
+#endif
}
std::shared_ptr<GeomAPI_Shape> FeaturesPlugin_Boolean::getShape(const std::string& theAttrName)
if (!aTypeAttr)
return;
int aType = aTypeAttr->value();
-
+#ifdef DEBUG_ONE_OBJECT
std::shared_ptr<GeomAPI_Shape> anObject = this->getShape(FeaturesPlugin_Boolean::OBJECT_ID());
+#else
+ std::shared_ptr<GeomAPI_Shape> anObject;
+ {
+ AttributeSelectionListPtr anObjects = selectionList(FeaturesPlugin_Boolean::OBJECT_LIST_ID());
+ if (anObjects->size() == 0)
+ return;
+
+ // Getting bounding planes.
+ std::shared_ptr<ModelAPI_AttributeSelection> anObjRef = anObjects->value(0);
+ if (!anObjRef.get())
+ return;
+ anObject = std::dynamic_pointer_cast<GeomAPI_Shape>(anObjRef->value());
+ }
+#endif
if (!anObject)
return;
+#ifdef DEBUG_ONE_OBJECT
std::shared_ptr<GeomAPI_Shape> aTool = this->getShape(FeaturesPlugin_Boolean::TOOL_ID());
+#else
+ std::shared_ptr<GeomAPI_Shape> aTool;
+ {
+ AttributeSelectionListPtr anObjects = selectionList(FeaturesPlugin_Boolean::TOOL_LIST_ID());
+ if (anObjects->size() == 0)
+ return;
+
+ // Getting bounding planes.
+ std::shared_ptr<ModelAPI_AttributeSelection> anObjRef = anObjects->value(0);
+ if (!anObjRef.get())
+ return;
+ aTool = std::dynamic_pointer_cast<GeomAPI_Shape>(anObjRef->value());
+ }
+#endif
if (!aTool)
return;
return MY_ID;
}
/// attribute name of referenced object
+ inline static const std::string& OBJECT_LIST_ID()
+ {
+ static const std::string MY_OBJECT_LIST_ID("main_objects");
+ return MY_OBJECT_LIST_ID;
+ }
+ /// attribute name of referenced object
inline static const std::string& OBJECT_ID()
{
static const std::string MY_OBJECT_ID("main_object");
static const std::string MY_TOOL_ID("tool_object");
return MY_TOOL_ID;
}
+ /// attribute name of tool object
+ inline static const std::string& TOOL_LIST_ID()
+ {
+ static const std::string MY_TOOL_LIST_ID("tool_objects");
+ return MY_TOOL_LIST_ID;
+ }
/// attribute name of operation type
inline static const std::string& TYPE_ID()
{
<!-- Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
<source>
- <shape_selector id="main_object"
+ <!--<shape_selector id="main_object"
label="Main object"
icon=":icons/cut_shape.png"
tooltip="Select an object solid"
shape_types="solid shell"
concealment="true"
+ />-->
+ <multi_selector id="main_objects"
+ label="Main object"
+ icon=":icons/cut_shape.png"
+ tooltip="Select an object solid"
+ type_choice="Solids"
+ concealment="true"
/>
- <shape_selector id="tool_object"
+ <multi_selector id="tool_objects"
+ label="Tool object"
+ icon=":icons/cut_tool.png"
+ tooltip="Select a tool solid"
+ type_choice="Solids"
+ concealment="true" >
+ <validator id="PartSet_DifferentObjects"/>
+ </multi_selector>
+ <!--<shape_selector id="tool_object"
label="Tool object"
icon=":icons/cut_tool.png"
tooltip="Select a tool solid"
shape_types="solid"
concealment="true" >
<validator id="PartSet_DifferentObjects"/>
- </shape_selector>
+ </shape_selector>-->
<choice id="bool_type"
label="Type"
tooltip="Type of boolean operation"
string_list="Cut Fuse Common"
+ default="0"
/>
</source>
#include <BRepAdaptor_Surface.hxx>
#include <Geom_Surface.hxx>
#include <Geom_Plane.hxx>
+#include <GeomLib_IsPlanarSurface.hxx>
GeomAPI_Face::GeomAPI_Face()
: GeomAPI_Shape()
{
const TopoDS_Shape& aShape = const_cast<GeomAPI_Face*>(this)->impl<TopoDS_Shape>();
Handle(Geom_Surface) aSurf = BRep_Tool::Surface(TopoDS::Face(aShape));
- if (aSurf->IsKind(STANDARD_TYPE(Geom_Plane)))
- return true;
- return false;
+ GeomLib_IsPlanarSurface isPlanar(aSurf);
+ return isPlanar.IsPlanar();
}
std::shared_ptr<GeomAPI_Pln> GeomAPI_Face::getPlane() const
#include <TopoDS.hxx>
#include <BRep_Tool.hxx>
#include <Geom_Plane.hxx>
+#include <GeomLib_IsPlanarSurface.hxx>
std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_FaceBuilder::square(
Handle(Geom_Surface) aSurf = BRep_Tool::Surface(aFace);
if (aSurf.IsNull())
return aResult; // no surface
- Handle(Geom_Plane) aPlane = Handle(Geom_Plane)::DownCast(aSurf);
- if (aPlane.IsNull())
- return aResult; // not planar
+ GeomLib_IsPlanarSurface isPlanar(aSurf);
+ if(!isPlanar.IsPlanar()) {
+ return aResult;
+ }
+ gp_Pln aPln = isPlanar.Plan();
double aA, aB, aC, aD;
- aPlane->Coefficients(aA, aB, aC, aD);
+ aPln.Coefficients(aA, aB, aC, aD);
aResult = std::shared_ptr<GeomAPI_Pln>(new GeomAPI_Pln(aA, aB, aC, aD));
return aResult;
}