From 9271fd6f93a7680e65bb4addda0296eaa5e1f1a6 Mon Sep 17 00:00:00 2001 From: vsv Date: Fri, 28 Sep 2018 09:55:06 +0300 Subject: [PATCH] Issue #2504: Fix to avoid crashes on non-valid geometry --- src/FeaturesPlugin/FeaturesPlugin_Measurement.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/FeaturesPlugin/FeaturesPlugin_Measurement.cpp b/src/FeaturesPlugin/FeaturesPlugin_Measurement.cpp index ee4d1ea1f..fb7d2e102 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Measurement.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Measurement.cpp @@ -318,6 +318,11 @@ void FeaturesPlugin_Measurement::computeAngleByPoints() AISObjectPtr FeaturesPlugin_Measurement::getAISObject(AISObjectPtr thePrevious) { + AttributeDoubleArrayPtr aValues = + std::dynamic_pointer_cast(attribute(RESULT_VALUES_ID())); + if ((aValues->size() == 0) || (aValues->value(0) <= Precision::Confusion())) + return thePrevious; + AISObjectPtr anAIS; std::string aKind = string(MEASURE_KIND())->value(); if (aKind == MEASURE_LENGTH()) @@ -522,6 +527,7 @@ AISObjectPtr FeaturesPlugin_Measurement::angleDimension(AISObjectPtr thePrevious if (anEdge1.get() && anEdge2.get()) { TopoDS_Edge aTEdge1 = TopoDS::Edge(anEdge1->impl()); TopoDS_Edge aTEdge2 = TopoDS::Edge(anEdge2->impl()); + Handle(AIS_AngleDimension) aDim; if (thePrevious.get()) { aAISObj = thePrevious; @@ -556,6 +562,11 @@ AISObjectPtr FeaturesPlugin_Measurement::angleByPointsDimension(AISObjectPtr the gp_Pnt aPnt2(aPoint2->impl()); gp_Pnt aPnt3(aPoint3->impl()); + if (aPnt1.IsEqual(aPnt2, Precision::Confusion()) || + aPnt1.IsEqual(aPnt3, Precision::Confusion()) || + aPnt2.IsEqual(aPnt3, Precision::Confusion())) + return thePrevious; + if (thePrevious.get()) { aAISObj = thePrevious; Handle(AIS_InteractiveObject) aAIS = aAISObj->impl(); -- 2.39.2