From: azv Date: Wed, 4 Jul 2018 11:18:34 +0000 (+0300) Subject: Issue #2535: Intersection - Include into sketch result does not work X-Git-Tag: EDF_2018-1~22 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=d5b5ce2284869d8b97ce638502c58c810bbeb0c7;p=modules%2Fshaper.git Issue #2535: Intersection - Include into sketch result does not work Improve PartSet plugin to avoid showing elements not included to sketch result as auxiliary objects. --- diff --git a/src/PartSet/PartSet_ResultSketchPrs.cpp b/src/PartSet/PartSet_ResultSketchPrs.cpp index dc3c1c831..7e62e4b9f 100755 --- a/src/PartSet/PartSet_ResultSketchPrs.cpp +++ b/src/PartSet/PartSet_ResultSketchPrs.cpp @@ -292,8 +292,10 @@ void PartSet_ResultSketchPrs::fillShapes(TopoDS_Shape& theResultShape, 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 >& aRes = aFeature->results(); std::list >::const_iterator aResIter = aRes.cbegin(); for (; aResIter != aRes.cend(); aResIter++) { diff --git a/src/PartSet/PartSet_Tools.cpp b/src/PartSet/PartSet_Tools.cpp index 4d00067fe..4c77d6c16 100755 --- a/src/PartSet/PartSet_Tools.cpp +++ b/src/PartSet/PartSet_Tools.cpp @@ -71,6 +71,7 @@ #include #include #include +#include #include #include @@ -686,6 +687,35 @@ bool PartSet_Tools::isAuxiliarySketchEntity(const ObjectPtr& theObject) 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& aRefs = theObject->data()->refsToMe(); + for (std::set::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, diff --git a/src/PartSet/PartSet_Tools.h b/src/PartSet/PartSet_Tools.h index 1f5bf51b1..b76e1dd44 100755 --- a/src/PartSet/PartSet_Tools.h +++ b/src/PartSet/PartSet_Tools.h @@ -273,12 +273,18 @@ public: 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& theEdge, ModelAPI_AttributeSelection::CenterType theType, diff --git a/src/SketchPlugin/SketchPlugin_Sketch.cpp b/src/SketchPlugin/SketchPlugin_Sketch.cpp index aabee0fa3..d23ad07d0 100755 --- a/src/SketchPlugin/SketchPlugin_Sketch.cpp +++ b/src/SketchPlugin/SketchPlugin_Sketch.cpp @@ -43,6 +43,7 @@ #include #include +#include #include #include #include @@ -106,8 +107,11 @@ void SketchPlugin_Sketch::execute() // 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; }