Improve PartSet plugin to avoid showing elements not included to sketch result as auxiliary objects.
anAuxiliaryResults.push_back(aResult);
}
}
- else {
- /// append not-edges shapes, e.g. center of a circle, an arc, a point feature
+ else if (PartSet_Tools::isIncludeIntoSketchResult(aFeature)) {
+ // Append not-edges shapes, e.g. center of a circle, an arc, a point feature.
+ // Issue #2535: do not show elements produced by Projection or Intersection features,
+ // which should not be included into the sketch result.
const std::list<std::shared_ptr<ModelAPI_Result> >& aRes = aFeature->results();
std::list<std::shared_ptr<ModelAPI_Result> >::const_iterator aResIter = aRes.cbegin();
for (; aResIter != aRes.cend(); aResIter++) {
#include <SketchPlugin_Line.h>
#include <SketchPlugin_Point.h>
#include <SketchPlugin_Projection.h>
+#include <SketchPlugin_IntersectionPoint.h>
#include <ModuleBase_IWorkshop.h>
#include <ModuleBase_ViewerPrs.h>
return isAuxiliaryFeature;
}
+bool PartSet_Tools::isIncludeIntoSketchResult(const ObjectPtr& theObject)
+{
+ // check the feature is neither Projection nor IntersectionPoint feature
+ FeaturePtr aFeature = ModelAPI_Feature::feature(theObject);
+ if (aFeature->getKind() == SketchPlugin_Projection::ID() ||
+ aFeature->getKind() == SketchPlugin_IntersectionPoint::ID())
+ return false;
+
+ // go through the references to the feature to check
+ // if it was created by Projection or Intersection
+ const std::set<AttributePtr>& aRefs = theObject->data()->refsToMe();
+ for (std::set<AttributePtr>::const_iterator aRefIt = aRefs.begin();
+ aRefIt != aRefs.end(); ++aRefIt) {
+ AttributePtr anAttr = *aRefIt;
+ std::string anIncludeToResultAttrName;
+ if (anAttr->id() == SketchPlugin_Projection::PROJECTED_FEATURE_ID())
+ anIncludeToResultAttrName = SketchPlugin_Projection::INCLUDE_INTO_RESULT();
+ else if (anAttr->id() == SketchPlugin_IntersectionPoint::INTERSECTION_POINTS_ID())
+ anIncludeToResultAttrName = SketchPlugin_IntersectionPoint::INCLUDE_INTO_RESULT();
+
+ if (!anIncludeToResultAttrName.empty()) {
+ // check "include into result" flag
+ FeaturePtr aParent = ModelAPI_Feature::feature(anAttr->owner());
+ return aParent->boolean(anIncludeToResultAttrName)->value();
+ }
+ }
+ return true;
+}
+
ResultPtr PartSet_Tools::createFixedByExternalCenter(
const ObjectPtr& theObject,
const Events_ID theId);
/**
- * Returns true if the object is a sketch entity, where auxiliary attribute has true vlaue
+ * Returns true if the object is a sketch entity, where auxiliary attribute has true value
* \param theObject a result or feature
* \return boolean result
*/
static bool isAuxiliarySketchEntity(const ObjectPtr& theObject);
+ /**
+ * Returns true if the object is a sketch entity produced by projection or intersection feature
+ * and if it should not be included into the sketch result
+ */
+ static bool isIncludeIntoSketchResult(const ObjectPtr& theObject);
+
static ResultPtr createFixedByExternalCenter(const ObjectPtr& theObject,
const std::shared_ptr<GeomAPI_Edge>& theEdge,
ModelAPI_AttributeSelection::CenterType theType,
#include <SketchPlugin_Sketch.h>
#include <SketchPlugin_Feature.h>
+#include <SketchPlugin_IntersectionPoint.h>
#include <SketchPlugin_Projection.h>
#include <SketchPlugin_SketchEntity.h>
#include <SketchPlugin_Tools.h>
// do not include into the result the external edges with disabled flag "Include into result"
if (aFeature->data()->attribute(SketchPlugin_SketchEntity::EXTERNAL_ID())) {
if (aFeature->data()->selection(SketchPlugin_SketchEntity::EXTERNAL_ID())->context()) {
- AttributeBooleanPtr aKeepResult =
- aFeature->boolean(SketchPlugin_Projection::INCLUDE_INTO_RESULT());
+ const std::string& anAttrName =
+ aFeature->getKind() == SketchPlugin_Projection::ID() ?
+ SketchPlugin_Projection::INCLUDE_INTO_RESULT() :
+ SketchPlugin_IntersectionPoint::INCLUDE_INTO_RESULT();
+ AttributeBooleanPtr aKeepResult = aFeature->boolean(anAttrName);
if (!aKeepResult || !aKeepResult->value())
continue;
}