]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #2535: Intersection - Include into sketch result does not work
authorazv <azv@opencascade.com>
Wed, 4 Jul 2018 11:18:34 +0000 (14:18 +0300)
committerazv <azv@opencascade.com>
Wed, 4 Jul 2018 11:19:15 +0000 (14:19 +0300)
Improve PartSet plugin to avoid showing elements not included to sketch result as auxiliary objects.

src/PartSet/PartSet_ResultSketchPrs.cpp
src/PartSet/PartSet_Tools.cpp
src/PartSet/PartSet_Tools.h
src/SketchPlugin/SketchPlugin_Sketch.cpp

index dc3c1c8315e7b3221893349618487fe763aeb3e1..7e62e4b9fb559cd2df26c16b49a6bb450d98a0bf 100755 (executable)
@@ -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<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++) {
index 4d00067fe084ec46420f2b670291c89d69ce9143..4c77d6c16993bb4fd95b4cb1696a2fe57a4fd3be 100755 (executable)
@@ -71,6 +71,7 @@
 #include <SketchPlugin_Line.h>
 #include <SketchPlugin_Point.h>
 #include <SketchPlugin_Projection.h>
+#include <SketchPlugin_IntersectionPoint.h>
 
 #include <ModuleBase_IWorkshop.h>
 #include <ModuleBase_ViewerPrs.h>
@@ -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<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,
index 1f5bf51b12ae1b4c36a5e8d4a91a80660e42fea1..b76e1dd4449892fedd0047668f439fcacda3d8c0 100755 (executable)
@@ -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<GeomAPI_Edge>& theEdge,
                                                ModelAPI_AttributeSelection::CenterType theType,
index aabee0fa3fc9b6ee43fee64d1ce46c7cf2849765..d23ad07d0118e0c581692eef8bca4e006d6d9d26 100755 (executable)
@@ -43,6 +43,7 @@
 
 #include <SketchPlugin_Sketch.h>
 #include <SketchPlugin_Feature.h>
+#include <SketchPlugin_IntersectionPoint.h>
 #include <SketchPlugin_Projection.h>
 #include <SketchPlugin_SketchEntity.h>
 #include <SketchPlugin_Tools.h>
@@ -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;
         }