From: nds Date: Thu, 2 Jun 2016 12:45:48 +0000 (+0300) Subject: Issue #1530 The arcs representation is not fine enough X-Git-Tag: V_2.3.1~2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=61a55a09650c0e6e68a5ebf786c51664ed2a9001;p=modules%2Fshaper.git Issue #1530 The arcs representation is not fine enough --- diff --git a/src/ModuleBase/ModuleBase_Tools.cpp b/src/ModuleBase/ModuleBase_Tools.cpp index 11842fe9b..6b83432a8 100755 --- a/src/ModuleBase/ModuleBase_Tools.cpp +++ b/src/ModuleBase/ModuleBase_Tools.cpp @@ -35,6 +35,7 @@ #include #include +#include #include #include @@ -54,6 +55,7 @@ #include const double tolerance = 1e-7; +const double DEFAULT_DEVIATION_COEFFICIENT = 1.e-4; //#define DEBUG_ACTIVATE_WINDOW //#define DEBUG_SET_FOCUS @@ -557,14 +559,34 @@ void checkObjects(const QObjectPtrList& theObjects, bool& hasResult, bool& hasFe } } +bool setDefaultDeviationCoefficient(std::shared_ptr theGeomShape) +{ + if (!theGeomShape.get()) + return false; + // if the shape could not be exploded on faces, it contains only wires, edges, and vertices + // correction of deviation for them should not influence to the application performance + GeomAPI_ShapeExplorer anExp(theGeomShape, GeomAPI_Shape::FACE); + bool anEmpty = anExp.empty(); + return !anExp.more(); +} + void setDefaultDeviationCoefficient(const std::shared_ptr& theResult, const Handle(Prs3d_Drawer)& theDrawer) { if (!theResult.get()) return; - - if (theResult->groupName() == ModelAPI_ResultConstruction::group()) - theDrawer->SetDeviationCoefficient(1.e-4); + bool aUseDeviation = false; + + std::string aResultGroup = theResult->groupName(); + if (aResultGroup == ModelAPI_ResultConstruction::group()) + aUseDeviation = true; + else if (aResultGroup == ModelAPI_ResultBody::group()) { + GeomShapePtr aGeomShape = theResult->shape(); + if (aGeomShape.get()) + aUseDeviation = setDefaultDeviationCoefficient(aGeomShape); + } + if (aUseDeviation) + theDrawer->SetDeviationCoefficient(DEFAULT_DEVIATION_COEFFICIENT); } void setDefaultDeviationCoefficient(const TopoDS_Shape& theShape, @@ -572,9 +594,11 @@ void setDefaultDeviationCoefficient(const TopoDS_Shape& theShape, { if (theShape.IsNull()) return; - TopAbs_ShapeEnum aType = theShape.ShapeType(); - if ((aType == TopAbs_EDGE) || (aType == TopAbs_WIRE)) - theDrawer->SetDeviationCoefficient(1.e-4); + + std::shared_ptr aGeomShape(new GeomAPI_Shape()); + aGeomShape->setImpl(new TopoDS_Shape(theShape)); + if (setDefaultDeviationCoefficient(aGeomShape)) + theDrawer->SetDeviationCoefficient(DEFAULT_DEVIATION_COEFFICIENT); } Quantity_Color color(const std::string& theSection, diff --git a/src/XGUI/XGUI_Displayer.cpp b/src/XGUI/XGUI_Displayer.cpp index 95d589966..851f977a1 100644 --- a/src/XGUI/XGUI_Displayer.cpp +++ b/src/XGUI/XGUI_Displayer.cpp @@ -149,6 +149,18 @@ bool XGUI_Displayer::display(ObjectPtr theObject, bool theUpdateViewer) bool isShading = false; if (aPrs.get() != NULL) { anAIS = aPrs->getAISObject(anAIS); + if (anAIS.get()) { + // correct deviation coefficient for + Handle(AIS_InteractiveObject) anAISPrs = anAIS->impl(); + if (!anAISPrs.IsNull()) { + Handle(AIS_Shape) aShapePrs = Handle(AIS_Shape)::DownCast(anAISPrs); + if (!aShapePrs.IsNull()) { + TopoDS_Shape aShape = aShapePrs->Shape(); + if (!aShape.IsNull()) + ModuleBase_Tools::setDefaultDeviationCoefficient(aShape, anAISPrs->Attributes()); + } + } + } } else { ResultPtr aResult = std::dynamic_pointer_cast(theObject); if (aResult.get() != NULL) {