From: nds Date: Thu, 3 Sep 2015 04:39:09 +0000 (+0300) Subject: Fix for a crash: Create sketch, circle, Radius constraint with 0 value. X-Git-Tag: V_1.4.0_beta4~146 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=07ff3c02f47a2efa7b51a661716262291fd5ccfd;p=modules%2Fshaper.git Fix for a crash: Create sketch, circle, Radius constraint with 0 value. --- diff --git a/src/SketcherPrs/SketcherPrs_Radius.cpp b/src/SketcherPrs/SketcherPrs_Radius.cpp index 6fc31d0d5..011555ffa 100644 --- a/src/SketcherPrs/SketcherPrs_Radius.cpp +++ b/src/SketcherPrs/SketcherPrs_Radius.cpp @@ -18,6 +18,8 @@ #include #include +#include + static const gp_Circ MyDefCirc(gp_Ax2(gp_Pnt(0,0,0), gp_Dir(0,0,1)), 1); IMPLEMENT_STANDARD_HANDLE(SketcherPrs_Radius, AIS_RadiusDimension); @@ -39,7 +41,6 @@ SketcherPrs_Radius::SketcherPrs_Radius(ModelAPI_Feature* theConstraint, SetSelToleranceForText2d(SketcherPrs_Tools::getDefaultTextHeight()); } - void SketcherPrs_Radius::Compute(const Handle(PrsMgr_PresentationManager3d)& thePresentationManager, const Handle(Prs3d_Presentation)& thePresentation, const Standard_Integer theMode) @@ -62,6 +63,10 @@ void SketcherPrs_Radius::Compute(const Handle(PrsMgr_PresentationManager3d)& the std::shared_ptr aCyrcFeature = ModelAPI_Feature::feature(anAttr->object()); double aRadius = 1; std::shared_ptr aCenterAttr; + // it is possible that circle result becomes zero, in this case the presentation should disappear + // for example, it happens when circle radius is set to zero + if (!aCyrcFeature) + return; if (aCyrcFeature->getKind() == SketchPlugin_Circle::ID()) { // circle aCenterAttr = std::dynamic_pointer_cast( aCyrcFeature->data()->attribute(SketchPlugin_Circle::CENTER_ID())); @@ -84,7 +89,13 @@ void SketcherPrs_Radius::Compute(const Handle(PrsMgr_PresentationManager3d)& the std::shared_ptr anAnchor = SketcherPrs_Tools::getAnchorPoint(myConstraint, myPlane); - SetMeasuredGeometry(aCircle.impl(), anAnchor->impl()); + gp_Circ aCirc = aCircle.impl(); + gp_Pnt anAncorPnt = anAnchor->impl(); + // anchor point should not coincide to the location point of the circle + // OCCT does not process this case. + if (anAncorPnt.Distance(aCirc.Location()) < 1e-7) + return; + SetMeasuredGeometry(aCirc, anAncorPnt); SetCustomValue(aRadius); myAspect->SetExtensionSize(myAspect->ArrowAspect()->Length());