Salome HOME
Uncomment deviation coefficient.
[modules/shaper.git] / src / PartSet / PartSet_OperationPrs.cpp
index 13690107113100a0c7eee61bb24f0e27f6366f84..f243fca538038bb2b7eeb26d872c53011c612d51 100755 (executable)
@@ -11,6 +11,8 @@
 #include "XGUI_ModuleConnector.h"
 #include "XGUI_Displayer.h"
 
+#include "ModuleBase_Tools.h"
+
 #include <ModelAPI_Result.h>
 #include <ModelAPI_Attribute.h>
 #include <ModelAPI_AttributeRefAttr.h>
@@ -82,8 +84,14 @@ void PartSet_OperationPrs::Compute(const Handle(PrsMgr_PresentationManager3d)& t
     QList<GeomShapePtr>::const_iterator aShIt = aShapes.begin(), aShLast = aShapes.end();
     for (; aShIt != aShLast; aShIt++) {
       GeomShapePtr aGeomShape = *aShIt;
+      if (!aGeomShape.get())
+        continue;
       TopoDS_Shape aShape = aGeomShape->impl<TopoDS_Shape>();
+      // change deviation coefficient to provide more precise circle
+      Standard_Real aPrevDeviation = aDrawer->DeviationCoefficient();
+      aDrawer->SetDeviationCoefficient(ModuleBase_Tools::defaultDeviationCoefficient());
       StdPrs_WFDeflectionShape::Add(thePresentation, aShape, aDrawer);
+      aDrawer->SetDeviationCoefficient(aPrevDeviation);
     }
   }
 }
@@ -114,15 +122,36 @@ bool PartSet_OperationPrs::isVisible(XGUI_Displayer* theDisplayer, const ObjectP
   return aVisible;
 }
 
+bool isSubObject(const ObjectPtr& theObject, const FeaturePtr& theFeature)
+{
+  bool isSub = false;
+  CompositeFeaturePtr aComposite = std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(theFeature);
+  if (aComposite.get())
+    isSub = aComposite->isSub(theObject);
+
+  return isSub;
+}
+
 void addValue(const ObjectPtr& theObject, const GeomShapePtr& theShape,
+              const FeaturePtr& theFeature,
               QMap<ObjectPtr, QList<GeomShapePtr> >& theObjectShapes)
 {
-  if (theObjectShapes.contains(theObject))
-    theObjectShapes[theObject].append(theShape);
-  else {
-    QList<GeomShapePtr> aShapes;
-    aShapes.append(theShape);
-    theObjectShapes[theObject] = aShapes;
+  if (theObject.get()) {
+    GeomShapePtr aShape = theShape;
+    if (!aShape.get()) {
+      ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(theObject);
+      if (aResult.get())
+        aShape = aResult->shape();
+    }
+    if (!isSubObject(theObject, theFeature)) {
+      if (theObjectShapes.contains(theObject))
+        theObjectShapes[theObject].append(aShape);
+      else {
+        QList<GeomShapePtr> aShapes;
+        aShapes.append(aShape);
+        theObjectShapes[theObject] = aShapes;
+      }
+    }
   }
 }
 
@@ -148,9 +177,7 @@ void PartSet_OperationPrs::getFeatureShapes(QMap<ObjectPtr, QList<GeomShapePtr>
         std::shared_ptr<ModelAPI_AttributeSelection> aSelAttribute = aCurSelList->value(i);
         ResultPtr aResult = aSelAttribute->context();
         GeomShapePtr aShape = aSelAttribute->value();
-        if (!aShape.get())
-          aShape = aResult->shape();
-        addValue(aResult, aShape, theObjectShapes);
+        addValue(aResult, aShape, myFeature, theObjectShapes);
       }
     }
     else {
@@ -179,15 +206,7 @@ void PartSet_OperationPrs::getFeatureShapes(QMap<ObjectPtr, QList<GeomShapePtr>
         AttributeReferencePtr anAttr = std::dynamic_pointer_cast<ModelAPI_AttributeReference>(anAttribute);
         anObject = anAttr->value();
       }
-
-      if (anObject.get()) {
-        if (!aShape.get()) {
-          ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(anObject);
-          if (aResult.get())
-            aShape = aResult->shape();
-        }
-        addValue(anObject, aShape, theObjectShapes);
-      }
+      addValue(anObject, aShape, myFeature, theObjectShapes);
     }
   }
 }