#include "FeaturesPlugin_Partition.h"
#include <ModelAPI_AttributeBoolean.h>
+#include <ModelAPI_AttributeDouble.h>
#include <ModelAPI_AttributeInteger.h>
#include <ModelAPI_AttributeReference.h>
#include <ModelAPI_AttributeSelectionList.h>
void FeaturesPlugin_Partition::initAttributes()
{
data()->addAttribute(BASE_OBJECTS_ID(), ModelAPI_AttributeSelectionList::typeId());
+
+ data()->addAttribute(FUZZY_PARAM_ID(), ModelAPI_AttributeDouble::typeId());
+ // Initialize the fuzzy parameter with a value below Precision::Confusion() to indicate,
+ // that the internal algorithms should use their default fuzzy value, if none was specified
+ // by the user.
+ real(FUZZY_PARAM_ID())->setValue(1.e-8);
+
initVersion(BOP_VERSION_9_4(), selectionList(BASE_OBJECTS_ID()));
}
return;
}
+ // Getting fuzzy parameter.
+ // Used as additional tolerance to eliminate tiny results.
+ double aFuzzy = real(FUZZY_PARAM_ID())->value();
+
ListOfShape aBaseObjects = anObjects.objects();
aBaseObjects.insert(aBaseObjects.end(), aPlanes.begin(), aPlanes.end());
// cut unused solids of composolids from the objects of partition
ListOfShape aTargetObjects, anUnusedSubs;
std::string aError;
- if (!cutSubs(anObjects, aTargetObjects, anUnusedSubs, aMakeShapeList, aError)) {
+ if (!cutSubs(anObjects, aTargetObjects, anUnusedSubs, aFuzzy, aMakeShapeList, aError)) {
setError(aError);
return;
}
// perform partition first time to split target solids by planes
std::shared_ptr<GeomAlgoAPI_Partition> aPartitionAlgo(
- new GeomAlgoAPI_Partition(aTargetObjects, aPlanes));
+ new GeomAlgoAPI_Partition(aTargetObjects, aPlanes, aFuzzy));
// Checking that the algorithm worked properly.
if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aPartitionAlgo, getKind(), aError)) {
//=================================================================================================
-
static bool cutSubs(ListOfShape& theSubsToCut,
const ListOfShape& theTools,
+ const double theFuzzy,
std::shared_ptr<GeomAlgoAPI_MakeShapeList>& theMakeShapeList,
std::string& theError)
{
// cut from current list of solids
std::shared_ptr<GeomAlgoAPI_MakeShape> aCutAlgo(
- new GeomAlgoAPI_Boolean(theSubsToCut, theTools, GeomAlgoAPI_Tools::BOOL_CUT));
+ new GeomAlgoAPI_Boolean(theSubsToCut, theTools, GeomAlgoAPI_Tools::BOOL_CUT, theFuzzy));
if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aCutAlgo, "", theError))
return false;
theMakeShapeList->appendAlgo(aCutAlgo);
return true;
}
+//=================================================================================================
bool FeaturesPlugin_Partition::cutSubs(
GeomAPI_ShapeHierarchy& theHierarchy,
ListOfShape& theUsed,
ListOfShape& theNotUsed,
+ const double theFuzzy,
std::shared_ptr<GeomAlgoAPI_MakeShapeList>& theMakeShapeList,
std::string& theError)
{
else
aUsed.push_back(*anIt);
- isOk = ::cutSubs(aUsed, aToolsForUsed, theMakeShapeList, theError)
- && ::cutSubs(aNotUsed, aToolsForUnused, theMakeShapeList, theError);
+ isOk = ::cutSubs(aUsed, aToolsForUsed, theFuzzy, theMakeShapeList, theError)
+ && ::cutSubs(aNotUsed, aToolsForUnused, theFuzzy, theMakeShapeList, theError);
if (isOk) {
theUsed.insert(theUsed.end(), aUsed.begin(), aUsed.end());
theNotUsed.insert(theNotUsed.end(), aNotUsed.begin(), aNotUsed.end());