#include <GeomAlgoAPI_Boolean.h>
#include <GeomAlgoAPI_MakeShapeList.h>
+#include <GeomAlgoAPI_Partition.h>
#include <GeomAlgoAPI_PaveFiller.h>
#include <GeomAlgoAPI_ShapeTools.h>
#include <GeomAPI_ShapeExplorer.h>
switch(aType) {
case BOOL_CUT:
- case BOOL_COMMON:{
+ case BOOL_COMMON:
+ case BOOL_FILL: {
if((anObjects.empty() && aCompSolidsObjects.empty()) || aTools.empty()) {
std::string aFeatureError = "Error: Not enough objects for boolean operation.";
setError(aFeatureError);
std::shared_ptr<GeomAPI_Shape> anObject = *anObjectsIt;
ListOfShape aListWithObject;
aListWithObject.push_back(anObject);
- GeomAlgoAPI_Boolean aBoolAlgo(aListWithObject, aTools, (GeomAlgoAPI_Boolean::OperationType)aType);
+ GeomAlgoAPI_MakeShape aBoolAlgo; (aListWithObject, aTools, (GeomAlgoAPI_Boolean::OperationType)aType);
+
+ switch(aType) {
+ case BOOL_CUT: aBoolAlgo = GeomAlgoAPI_Boolean(aListWithObject, aTools, GeomAlgoAPI_Boolean::BOOL_CUT); break;
+ case BOOL_COMMON: aBoolAlgo = GeomAlgoAPI_Boolean(aListWithObject, aTools, GeomAlgoAPI_Boolean::BOOL_COMMON); break;
+ case BOOL_FILL: aBoolAlgo = GeomAlgoAPI_Partition(aListWithObject, aTools); break;
+ }
// Checking that the algorithm worked properly.
if(!aBoolAlgo.isDone()) {
}
}
- std::shared_ptr<GeomAlgoAPI_Boolean> aBoolAlgo(new GeomAlgoAPI_Boolean(aUsedInOperationSolids,
- aTools,
- (GeomAlgoAPI_Boolean::OperationType)aType));
+ std::shared_ptr<GeomAlgoAPI_MakeShape> aBoolAlgo;
+
+ switch(aType) {
+ case BOOL_CUT: {
+ aBoolAlgo.reset(new GeomAlgoAPI_Boolean(aUsedInOperationSolids,
+ aTools,
+ GeomAlgoAPI_Boolean::BOOL_CUT));
+ break;
+ }
+ case BOOL_COMMON: {
+ aBoolAlgo.reset(new GeomAlgoAPI_Boolean(aUsedInOperationSolids,
+ aTools,
+ GeomAlgoAPI_Boolean::BOOL_COMMON));
+ break;
+ }
+ case BOOL_FILL: {
+ aBoolAlgo.reset(new GeomAlgoAPI_Partition(aUsedInOperationSolids, aTools));
+ break;
+ }
+ }
// Checking that the algorithm worked properly.
if(!aBoolAlgo->isDone()) {
BOOL_CUT,
BOOL_FUSE,
BOOL_COMMON,
+ BOOL_FILL,
BOOL_SMASH
};
new FeaturesPlugin_ValidatorPipeLocations);
aFactory->registerValidator("FeaturesPlugin_ValidatorCanBeEmpty",
new FeaturesPlugin_ValidatorCanBeEmpty);
+ aFactory->registerValidator("FeaturesPlugin_BooleanSelection",
+ new FeaturesPlugin_BooleanSelection);
// register this plugin
ModelAPI_Session::get()->registerPlugin(this);
#include "FeaturesPlugin_Validators.h"
#include <ModelAPI_Attribute.h>
+#include <ModelAPI_AttributeInteger.h>
#include <ModelAPI_AttributeSelectionList.h>
#include <ModelAPI_AttributeString.h>
-#include <ModelAPI_ResultConstruction.h>
#include <ModelAPI_AttributeReference.h>
+#include <ModelAPI_Feature.h>
+#include <ModelAPI_ResultConstruction.h>
#include <Events_Error.h>
#include <GeomAPI_ShapeExplorer.h>
#include <GeomAlgoAPI_WireBuilder.h>
-//=================================================================================================
+//==================================================================================================
bool FeaturesPlugin_ValidatorPipeLocations::isValid(const std::shared_ptr<ModelAPI_Feature>& theFeature,
const std::list<std::string>& theArguments,
std::string& theError) const
return true;
}
-//=================================================================================================
+//==================================================================================================
bool FeaturesPlugin_ValidatorPipeLocations::isNotObligatory(std::string theFeature, std::string theAttribute)
{
return false;
}
-//=================================================================================================
+//==================================================================================================
bool FeaturesPlugin_ValidatorBaseForGeneration::isValid(const AttributePtr& theAttribute,
const std::list<std::string>& theArguments,
std::string& theError) const
return true;
}
-//=================================================================================================
+//==================================================================================================
bool FeaturesPlugin_ValidatorBaseForGeneration::isValidAttribute(const AttributePtr& theAttribute,
const std::list<std::string>& theArguments,
std::string& theError) const
return true;
}
-//=================================================================================================
+//==================================================================================================
bool FeaturesPlugin_ValidatorCompositeLauncher::isValid(const AttributePtr& theAttribute,
const std::list<std::string>& theArguments,
std::string& theError) const
return aValid;
}
-//=================================================================================================
+//==================================================================================================
bool FeaturesPlugin_ValidatorCanBeEmpty::isValid(const std::shared_ptr<ModelAPI_Feature>& theFeature,
const std::list<std::string>& theArguments,
std::string& theError) const
return true;
}
-//=================================================================================================
+//==================================================================================================
bool FeaturesPlugin_ValidatorCanBeEmpty::isNotObligatory(std::string theFeature, std::string theAttribute)
{
return false;
}
-//=================================================================================================
+//==================================================================================================
bool FeaturesPlugin_ValidatorCanBeEmpty::isShapesCanBeEmpty(const AttributePtr& theAttribute,
std::string& theError) const
{
return true;
}
-//=================================================================================================
+//==================================================================================================
bool FeaturesPlugin_ValidatorBaseForWire::isValid(const AttributePtr& theAttribute,
const std::list<std::string>& theArguments,
std::string& theError) const
}
return true;
-}
\ No newline at end of file
+}
+
+//==================================================================================================
+bool FeaturesPlugin_BooleanSelection::isValid(const AttributePtr& theAttribute,
+ const std::list<std::string>& theArguments,
+ std::string& theError) const
+{
+ AttributeSelectionListPtr anAttrSelectionList = std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(theAttribute);
+ if(!anAttrSelectionList.get()) {
+ theError = "Error: this validator can only work with selection list attributes in Boolean feature.";
+ return false;
+ }
+ FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(theAttribute->owner());
+ int anOperationType = aFeature->integer("bool_type")->value();
+
+ for(int anIndex = 0; anIndex < anAttrSelectionList->size(); ++anIndex) {
+ AttributeSelectionPtr anAttrSelection = anAttrSelectionList->value(anIndex);
+ if(!anAttrSelection.get()) {
+ theError = "Error: empty attribute selection.";
+ return false;
+ }
+ ResultPtr aContext = anAttrSelection->context();
+ if(!aContext.get()) {
+ theError = "Error: empty selection context.";
+ return false;
+ }
+ ResultConstructionPtr aResultConstruction =
+ std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aContext);
+ if(aResultConstruction.get()) {
+ theError = "Error: Result construction not allowed for selection.";
+ return false;
+ }
+ std::shared_ptr<GeomAPI_Shape> aShape = anAttrSelection->value();
+ if(!aShape.get()) {
+ aShape = aContext->shape();
+ }
+ if(!aShape.get()) {
+ theError = "Error: empty shape.";
+ return false;
+ }
+ int aShapeType = aShape->shapeType();
+ if(anOperationType == 1) {
+ // Fuse operation. Allow to select edges, faces and solids.
+ if(aShapeType != GeomAPI_Shape::EDGE &&
+ aShapeType != GeomAPI_Shape::FACE &&
+ aShapeType != GeomAPI_Shape::SOLID &&
+ aShapeType != GeomAPI_Shape::COMPSOLID &&
+ aShapeType != GeomAPI_Shape::COMPOUND) {
+ theError = "Error: selected shape has the wrong type.";
+ return false;
+ }
+ } else {
+ if(aShapeType != GeomAPI_Shape::SOLID &&
+ aShapeType != GeomAPI_Shape::COMPSOLID &&
+ aShapeType != GeomAPI_Shape::COMPOUND) {
+ theError = "Error: selected shape has the wrong type.";
+ return false;
+ }
+ }
+ }
+
+ return true;
+}
/// \class FeaturesPlugin_ValidatorCanBeEmpty
/// \ingroup Validators
-/// \brief A validator for extrusion direction attribute and bounding planes for extrusion and
-/// revolution. Allows them to be empty if base objects are planar and do not contain
-/// vertices and edges.
+/// \brief A validator for extrusion direction attribute. Allows it to be empty if base objects are
+/// planar and do not contain vertices and edges.
class FeaturesPlugin_ValidatorCanBeEmpty: public ModelAPI_FeatureValidator
{
public:
std::string& theError) const;
};
+/// \class FeaturesPlugin_BooleanSelection
+/// \ingroup Validators
+/// \brief Validates selection for boolean operation.
+class FeaturesPlugin_BooleanSelection: public ModelAPI_AttributeValidator
+{
+public:
+ /// \return True if the attribute is valid. It checks whether the selection
+ /// is acceptable for boolean operation.
+ /// \param[in] theAttribute an attribute to check.
+ /// \param[in] theArguments a filter parameters.
+ /// \param[out] theError error message.
+ virtual bool isValid(const AttributePtr& theAttribute,
+ const std::list<std::string>& theArguments,
+ std::string& theError) const;
+};
+
#endif
buttons_dir="horizontal"
label="Operation type"
tooltip="Type of boolean operation"
- string_list="Cut Fuse Common Smash"
+ string_list="Cut Fuse Common Fill Smash"
use_in_title="true"
- icons_list="icons/Features/bool_cut.png icons/Features/bool_fuse.png icons/Features/bool_common.png icons/Features/bool_smash.png"
+ icons_list="icons/Features/bool_cut.png icons/Features/bool_fuse.png icons/Features/bool_common.png icons/Features/bool_fill.png icons/Features/bool_smash.png"
default="0"
/>
<multi_selector id="main_objects"
use_choice="false"
concealment="true">
<validator id="PartSet_DifferentObjects"/>
- <!--<validator id="GeomValidators_ShapeType" parameters="empty,edge,face,solid"/>-->
- <validator id="GeomValidators_BooleanSelection"/>
+ <validator id="FeaturesPlugin_BooleanSelection"/>
</multi_selector>
<multi_selector id="tool_objects"
label="Tool objects"
use_choice="false"
concealment="true" >
<validator id="PartSet_DifferentObjects"/>
- <!--<validator id="GeomValidators_ShapeType" parameters="empty,edge,face,solid"/>-->
- <validator id="GeomValidators_BooleanSelection"/>
+ <validator id="FeaturesPlugin_BooleanSelection"/>
</multi_selector>
<validator id="GeomValidators_BooleanArguments" parameters="main_objects,tool_objects,bool_type"/>
</source>
#include "GeomAlgoAPI_Boolean.h"
#include <GeomAlgoAPI_DFLoader.h>
+#include <GeomAlgoAPI_ShapeTools.h>
#include <BOPAlgo_BOP.hxx>
#include <TopTools_ListOfShape.hxx>
if(aResult.ShapeType() == TopAbs_COMPOUND) {
aResult = GeomAlgoAPI_DFLoader::refineResult(aResult);
}
+ if(aResult.ShapeType() == TopAbs_COMPOUND) {
+ std::shared_ptr<GeomAPI_Shape> aGeomShape(new GeomAPI_Shape);
+ aGeomShape->setImpl(new TopoDS_Shape(aResult));
+ ListOfShape aCompSolids, aFreeSolids;
+ aGeomShape = GeomAlgoAPI_ShapeTools::combineShapes(aGeomShape,
+ GeomAPI_Shape::COMPSOLID,
+ aCompSolids,
+ aFreeSolids);
+ aResult = aGeomShape->impl<TopoDS_Shape>();
+ }
std::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape());
aShape->setImpl(new TopoDS_Shape(aResult));
aResult = GeomAlgoAPI_DFLoader::refineResult(aResult);
}
if(aResult.ShapeType() == TopAbs_COMPOUND) {
- std::shared_ptr<GeomAPI_Shape> aCompound(new GeomAPI_Shape);
- aCompound->setImpl(new TopoDS_Shape(aResult));
+ std::shared_ptr<GeomAPI_Shape> aGeomShape(new GeomAPI_Shape);
+ aGeomShape->setImpl(new TopoDS_Shape(aResult));
ListOfShape aCompSolids, aFreeSolids;
- GeomAlgoAPI_ShapeTools::combineShapes(aCompound, GeomAPI_Shape::COMPSOLID, aCompSolids, aFreeSolids);
- if(aCompSolids.size() == 1 && aFreeSolids.size() == 0) {
- aResult = aCompSolids.front()->impl<TopoDS_Shape>();
- } else if (aCompSolids.size() > 1 || (aCompSolids.size() >= 1 && aFreeSolids.size() >= 1)) {
- TopoDS_Compound aResultComp;
- TopoDS_Builder aBuilder;
- aBuilder.MakeCompound(aResultComp);
- for(ListOfShape::const_iterator anIter = aCompSolids.cbegin(); anIter != aCompSolids.cend(); anIter++) {
- aBuilder.Add(aResultComp, (*anIter)->impl<TopoDS_Shape>());
- }
- for(ListOfShape::const_iterator anIter = aFreeSolids.cbegin(); anIter != aFreeSolids.cend(); anIter++) {
- aBuilder.Add(aResultComp, (*anIter)->impl<TopoDS_Shape>());
- }
- aResult = aResultComp;
- }
+ aGeomShape = GeomAlgoAPI_ShapeTools::combineShapes(aGeomShape,
+ GeomAPI_Shape::COMPSOLID,
+ aCompSolids,
+ aFreeSolids);
+ aResult = aGeomShape->impl<TopoDS_Shape>();
}
// Setting result.
aResult = GeomAlgoAPI_DFLoader::refineResult(aResult);
}
if(theIsMakeCompSolids && aResult.ShapeType() == TopAbs_COMPOUND) {
- std::shared_ptr<GeomAPI_Shape> aCompound(new GeomAPI_Shape);
- aCompound->setImpl(new TopoDS_Shape(aResult));
+ std::shared_ptr<GeomAPI_Shape> aGeomShape(new GeomAPI_Shape);
+ aGeomShape->setImpl(new TopoDS_Shape(aResult));
ListOfShape aCompSolids, aFreeSolids;
- GeomAlgoAPI_ShapeTools::combineShapes(aCompound, GeomAPI_Shape::COMPSOLID, aCompSolids, aFreeSolids);
- if(aCompSolids.size() == 1 && aFreeSolids.size() == 0) {
- aResult = aCompSolids.front()->impl<TopoDS_Shape>();
- } else if (aCompSolids.size() > 1 || (aCompSolids.size() >= 1 && aFreeSolids.size() >= 1)) {
- TopoDS_Compound aResultComp;
- TopoDS_Builder aBuilder;
- aBuilder.MakeCompound(aResultComp);
- for(ListOfShape::const_iterator anIter = aCompSolids.cbegin(); anIter != aCompSolids.cend(); anIter++) {
- aBuilder.Add(aResultComp, (*anIter)->impl<TopoDS_Shape>());
- }
- for(ListOfShape::const_iterator anIter = aFreeSolids.cbegin(); anIter != aFreeSolids.cend(); anIter++) {
- aBuilder.Add(aResultComp, (*anIter)->impl<TopoDS_Shape>());
- }
- aResult = aResultComp;
- }
+ aGeomShape = GeomAlgoAPI_ShapeTools::combineShapes(aGeomShape,
+ GeomAPI_Shape::COMPSOLID,
+ aCompSolids,
+ aFreeSolids);
+ aResult = aGeomShape->impl<TopoDS_Shape>();
}
std::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape());
}
if(aResult.ShapeType() == TopAbs_COMPOUND) {
- GeomShapePtr aCompound(new GeomAPI_Shape);
- aCompound->setImpl(new TopoDS_Shape(aResult));
+ std::shared_ptr<GeomAPI_Shape> aGeomShape(new GeomAPI_Shape);
+ aGeomShape->setImpl(new TopoDS_Shape(aResult));
ListOfShape aCompSolids, aFreeSolids;
- GeomAlgoAPI_ShapeTools::combineShapes(aCompound, GeomAPI_Shape::COMPSOLID, aCompSolids, aFreeSolids);
- if(aCompSolids.size() == 1 && aFreeSolids.size() == 0) {
- aResult = aCompSolids.front()->impl<TopoDS_Shape>();
- } else if (aCompSolids.size() > 1 || (aCompSolids.size() >= 1 && aFreeSolids.size() >= 1)) {
- TopoDS_Compound aResultComp;
- TopoDS_Builder aBuilder;
- aBuilder.MakeCompound(aResultComp);
- for(ListOfShape::const_iterator anIter = aCompSolids.cbegin(); anIter != aCompSolids.cend(); anIter++) {
- aBuilder.Add(aResultComp, (*anIter)->impl<TopoDS_Shape>());
- }
- for(ListOfShape::const_iterator anIter = aFreeSolids.cbegin(); anIter != aFreeSolids.cend(); anIter++) {
- aBuilder.Add(aResultComp, (*anIter)->impl<TopoDS_Shape>());
- }
- aResult = aResultComp;
- }
+ aGeomShape = GeomAlgoAPI_ShapeTools::combineShapes(aGeomShape,
+ GeomAPI_Shape::COMPSOLID,
+ aCompSolids,
+ aFreeSolids);
+ aResult = aGeomShape->impl<TopoDS_Shape>();
}
}
aResult = GeomAlgoAPI_DFLoader::refineResult(aResult);
}
if(aResult.ShapeType() == TopAbs_COMPOUND) {
- GeomShapePtr aCompound(new GeomAPI_Shape);
- aCompound->setImpl(new TopoDS_Shape(aResult));
+ std::shared_ptr<GeomAPI_Shape> aGeomShape(new GeomAPI_Shape);
+ aGeomShape->setImpl(new TopoDS_Shape(aResult));
ListOfShape aCompSolids, aFreeSolids;
- GeomAlgoAPI_ShapeTools::combineShapes(aCompound, GeomAPI_Shape::COMPSOLID, aCompSolids, aFreeSolids);
- if(aCompSolids.size() == 1 && aFreeSolids.size() == 0) {
- aResult = aCompSolids.front()->impl<TopoDS_Shape>();
- } else if (aCompSolids.size() > 1 || (aCompSolids.size() >= 1 && aFreeSolids.size() >= 1)) {
- TopoDS_Compound aResultComp;
- TopoDS_Builder aBuilder;
- aBuilder.MakeCompound(aResultComp);
- for(ListOfShape::const_iterator anIter = aCompSolids.cbegin(); anIter != aCompSolids.cend(); anIter++) {
- aBuilder.Add(aResultComp, (*anIter)->impl<TopoDS_Shape>());
- }
- for(ListOfShape::const_iterator anIter = aFreeSolids.cbegin(); anIter != aFreeSolids.cend(); anIter++) {
- aBuilder.Add(aResultComp, (*anIter)->impl<TopoDS_Shape>());
- }
- aResult = aResultComp;
- }
+ aGeomShape = GeomAlgoAPI_ShapeTools::combineShapes(aGeomShape,
+ GeomAPI_Shape::COMPSOLID,
+ aCompSolids,
+ aFreeSolids);
+ aResult = aGeomShape->impl<TopoDS_Shape>();
}
// If after cut we got more than one solids then take closest to the center of mass of the base face.
}
if(aResult.ShapeType() == TopAbs_COMPOUND) {
- GeomShapePtr aCompound(new GeomAPI_Shape);
- aCompound->setImpl(new TopoDS_Shape(aResult));
+ std::shared_ptr<GeomAPI_Shape> aGeomShape(new GeomAPI_Shape);
+ aGeomShape->setImpl(new TopoDS_Shape(aResult));
ListOfShape aCompSolids, aFreeSolids;
- GeomAlgoAPI_ShapeTools::combineShapes(aCompound, GeomAPI_Shape::COMPSOLID, aCompSolids, aFreeSolids);
- if(aCompSolids.size() == 1 && aFreeSolids.size() == 0) {
- aResult = aCompSolids.front()->impl<TopoDS_Shape>();
- } else if (aCompSolids.size() > 1 || (aCompSolids.size() >= 1 && aFreeSolids.size() >= 1)) {
- TopoDS_Compound aResultComp;
- TopoDS_Builder aBuilder;
- aBuilder.MakeCompound(aResultComp);
- for(ListOfShape::const_iterator anIter = aCompSolids.cbegin(); anIter != aCompSolids.cend(); anIter++) {
- aBuilder.Add(aResultComp, (*anIter)->impl<TopoDS_Shape>());
- }
- for(ListOfShape::const_iterator anIter = aFreeSolids.cbegin(); anIter != aFreeSolids.cend(); anIter++) {
- aBuilder.Add(aResultComp, (*anIter)->impl<TopoDS_Shape>());
- }
- aResult = aResultComp;
- }
+ aGeomShape = GeomAlgoAPI_ShapeTools::combineShapes(aGeomShape,
+ GeomAPI_Shape::COMPSOLID,
+ aCompSolids,
+ aFreeSolids);
+ aResult = aGeomShape->impl<TopoDS_Shape>();
}
// If after cut we got more than one solids then take closest to the center of mass of the base face.
}
//=================================================================================================
-void GeomAlgoAPI_ShapeTools::combineShapes(const std::shared_ptr<GeomAPI_Shape> theCompound,
- const GeomAPI_Shape::ShapeType theType,
- ListOfShape& theCombinedShapes,
- ListOfShape& theFreeShapes)
+std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeTools::combineShapes(const std::shared_ptr<GeomAPI_Shape> theCompound,
+ const GeomAPI_Shape::ShapeType theType,
+ ListOfShape& theCombinedShapes,
+ ListOfShape& theFreeShapes)
{
+ GeomShapePtr aResult = theCompound;
+
if(!theCompound.get()) {
- return;
+ return aResult;
}
if(theType != GeomAPI_Shape::SHELL && theType != GeomAPI_Shape::COMPSOLID) {
- return;
+ return aResult;
}
TopAbs_ShapeEnum aTS = TopAbs_EDGE;
BOPCol_IndexedDataMapOfShapeListOfShape aMapSA;
BOPTools::MapShapesAndAncestors(aShapesComp, aTS, aTA, aMapSA);
if(aMapSA.IsEmpty()) {
- return;
+ return aResult;
}
// Get all shapes with common subshapes and free shapes.
theFreeShapes.push_back(aGeomShape);
}
}
+
+ if(theCombinedShapes.size() == 1 && theFreeShapes.size() == 0) {
+ aResult = theCombinedShapes.front();
+ } else if (theCombinedShapes.size() > 1 || (theCombinedShapes.size() >= 1 && theFreeShapes.size() >= 1)) {
+ TopoDS_Compound aResultComp;
+ TopoDS_Builder aBuilder;
+ aBuilder.MakeCompound(aResultComp);
+ for(ListOfShape::const_iterator anIter = theCombinedShapes.cbegin(); anIter != theCombinedShapes.cend(); anIter++) {
+ aBuilder.Add(aResultComp, (*anIter)->impl<TopoDS_Shape>());
+ }
+ for(ListOfShape::const_iterator anIter = theFreeShapes.cbegin(); anIter != theFreeShapes.cend(); anIter++) {
+ aBuilder.Add(aResultComp, (*anIter)->impl<TopoDS_Shape>());
+ }
+ aResult->setImpl(new TopoDS_Shape(aResultComp));
+ }
+
+ return aResult;
}
//=================================================================================================
/// \param[in] theType type of combine.
/// \param[out] theCombinedShapes resulting shapes.
/// \param[out] theFreeShapes shapes that does not have common subshapes.
- static void combineShapes(const std::shared_ptr<GeomAPI_Shape> theCompound,
- const GeomAPI_Shape::ShapeType theType,
- ListOfShape& theCombinedShapes,
- ListOfShape& theFreeShapes);
+ static std::shared_ptr<GeomAPI_Shape> combineShapes(const std::shared_ptr<GeomAPI_Shape> theCompound,
+ const GeomAPI_Shape::ShapeType theType,
+ ListOfShape& theCombinedShapes,
+ ListOfShape& theFreeShapes);
/// \brief Calculates bounding box for theShapes
/// \return list of eight points.
GeomValidators_Tools.h
GeomValidators_ZeroOffset.h
GeomValidators_Different.h
- GeomValidators_BooleanSelection.h
GeomValidators_IntersectionSelection.h
)
GeomValidators_Tools.cpp
GeomValidators_ZeroOffset.cpp
GeomValidators_Different.cpp
- GeomValidators_BooleanSelection.cpp
GeomValidators_IntersectionSelection.cpp
)
+++ /dev/null
-// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
-
-// File: GeomValidators_BooleanSelection.cpp
-// Created: 3 Feb 2016
-// Author: Dmitry Bobylev
-
-#include "GeomValidators_BooleanSelection.h"
-
-#include <ModelAPI_AttributeInteger.h>
-#include <ModelAPI_AttributeSelectionList.h>
-#include <ModelAPI_Feature.h>
-
-bool GeomValidators_BooleanSelection::isValid(const AttributePtr& theAttribute,
- const std::list<std::string>& theArguments,
- std::string& theError) const
-{
- if(!theAttribute.get()) {
- theError = "Error: empty selection.";
- return false;
- }
- FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(theAttribute->owner());
- int anOperationType = aFeature->integer("bool_type")->value();
- AttributeSelectionListPtr anAttrSelectionList = std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(theAttribute);
- for(int anIndex = 0; anIndex < anAttrSelectionList->size(); ++anIndex) {
- AttributeSelectionPtr anAttrSelection = anAttrSelectionList->value(anIndex);
- if(!anAttrSelection.get()) {
- theError = "Error: empty attribute selection.";
- return false;
- }
- ResultPtr aContext = anAttrSelection->context();
- if(!aContext.get()) {
- theError = "Error: empty selection context.";
- return false;
- }
- FeaturePtr aFeature = ModelAPI_Feature::feature(aContext);
- if(!aFeature.get()) {
- theError = "Error: empty feature.";
- return false;
- }
- std::string aFeatureKind = aFeature->getKind();
- if(aFeatureKind == "Sketch" ||
- aFeatureKind == "Plane" ||
- aFeatureKind == "Axis") {
- theError = "Error: ";
- theError += aFeatureKind;
- theError += " shape is not allowed for selection.";
- return false;
- }
- std::shared_ptr<GeomAPI_Shape> aShape = anAttrSelection->value();
- if(!aShape.get()) {
- aShape = aContext->shape();
- }
- if(!aShape.get()) {
- theError = "Error: empty shape.";
- return false;
- }
- int aShapeType = aShape->shapeType();
- if(anOperationType == 1) {
- // Fuse operation. Allow to select edges, faces and solids.
- if(aShapeType != GeomAPI_Shape::EDGE &&
- aShapeType != GeomAPI_Shape::FACE &&
- aShapeType != GeomAPI_Shape::SOLID &&
- aShapeType != GeomAPI_Shape::COMPSOLID &&
- aShapeType != GeomAPI_Shape::COMPOUND) {
- theError = "Error: selected shape has the wrong type.";
- return false;
- }
- } else {
- if(aShapeType != GeomAPI_Shape::SOLID &&
- aShapeType != GeomAPI_Shape::COMPSOLID &&
- aShapeType != GeomAPI_Shape::COMPOUND) {
- theError = "Error: selected shape has the wrong type.";
- return false;
- }
- }
- }
-
- return true;
-}
+++ /dev/null
-// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
-
-// File: GeomValidators_BooleanSelection.h
-// Created: 3 Feb 2016
-// Author: Dmitry Bobylev
-
-#ifndef GeomValidators_BooleanSelection_H
-#define GeomValidators_BooleanSelection_H
-
-#include <GeomValidators.h>
-
-#include <ModelAPI_AttributeValidator.h>
-#include <ModelAPI_Attribute.h>
-
-/// \class GeomValidators_BooleanSelection
-/// \ingroup Validators
-/// \brief Validates selection for boolean operation.
-class GeomValidators_BooleanSelection: public ModelAPI_AttributeValidator
-{
-public:
- /// \return True if the attribute is valid. It checks whether the selection
- /// is acceptable for boolean operation.
- /// \param[in] theAttribute an attribute to check.
- /// \param[in] theArguments a filter parameters.
- /// \param[out] theError error message.
- GEOMVALIDATORS_EXPORT virtual bool isValid(const AttributePtr& theAttribute,
- const std::list<std::string>& theArguments,
- std::string& theError) const;
-};
-
-#endif
#include <GeomValidators_BodyShapes.h>
#include <GeomValidators_BooleanArguments.h>
-#include <GeomValidators_BooleanSelection.h>
#include <GeomValidators_ConstructionComposite.h>
#include <GeomValidators_Different.h>
#include <GeomValidators_DifferentShapes.h>
aFactory->registerValidator("GeomValidators_PartitionArguments", new GeomValidators_PartitionArguments);
aFactory->registerValidator("GeomValidators_ShapeType", new GeomValidators_ShapeType);
aFactory->registerValidator("GeomValidators_ZeroOffset", new GeomValidators_ZeroOffset);
- aFactory->registerValidator("GeomValidators_BooleanSelection", new GeomValidators_BooleanSelection);
aFactory->registerValidator("GeomValidators_IntersectionSelection", new GeomValidators_IntersectionSelection);
aFactory->registerValidator("GeomValidators_FeatureKind", new GeomValidators_FeatureKind);