From cd13321b214c0f221f6e9e9c5a2627c8a4fb4a04 Mon Sep 17 00:00:00 2001 From: azv Date: Wed, 19 Feb 2020 13:53:16 +0300 Subject: [PATCH] Fix crash in Symmetry and update the processing of the centers of circles and focuses of ellipses while geometric dumping. --- src/FeaturesPlugin/FeaturesPlugin_Tools.cpp | 2 +- src/ModelHighAPI/ModelHighAPI_Dumper.cpp | 46 +++++++++++++++++++-- 2 files changed, 43 insertions(+), 5 deletions(-) diff --git a/src/FeaturesPlugin/FeaturesPlugin_Tools.cpp b/src/FeaturesPlugin/FeaturesPlugin_Tools.cpp index 9880565de..f77919fe1 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Tools.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Tools.cpp @@ -259,7 +259,7 @@ bool FeaturesPlugin_Tools::shapesFromSelectionList( return false; } ResultPtr aContext = anObjectAttr->context(); - if (aContext->groupName() == ModelAPI_ResultPart::group()) + if (aContext && aContext->groupName() == ModelAPI_ResultPart::group()) theParts.push_back(aContext); else { // store full shape hierarchy for the corresponding version only diff --git a/src/ModelHighAPI/ModelHighAPI_Dumper.cpp b/src/ModelHighAPI/ModelHighAPI_Dumper.cpp index 1d655bbdf..1e676ade4 100644 --- a/src/ModelHighAPI/ModelHighAPI_Dumper.cpp +++ b/src/ModelHighAPI/ModelHighAPI_Dumper.cpp @@ -21,11 +21,15 @@ #include +#include +#include +#include +#include #include #include -#include #include #include +#include #include #include @@ -370,8 +374,10 @@ static int possibleSelectionsByPoint(const GeomPointPtr& thePoint, std::list anApproproate; if (ModelGeomAlgo_Shape::findSubshapeByPoint(*aFIt, thePoint, theShape->shapeType(), anApproproate)) { + bool isContinue = true; + std::list > aCenters; std::list::iterator anApIt = anApproproate.begin(); - for (; anApIt != anApproproate.end(); ++anApIt) { + for (; anApIt != anApproproate.end() && isContinue; ++anApIt) { ++aNbPossibleSelections; // stop if the target shape and result are found @@ -379,9 +385,41 @@ static int possibleSelectionsByPoint(const GeomPointPtr& thePoint, if (!aCurShape) aCurShape = anApIt->myResult->shape(); - if (anApIt->myResult->isSame(theResult) && aCurShape->isSame(theShape)) - break; + if (anApIt->myResult->isSame(theResult)) { + if (anApIt->myCenterType == (int)ModelAPI_AttributeSelection::NOT_CENTER) + isContinue = !aCurShape->isSame(theShape); + else if (theShape->isVertex() && aCurShape->isEdge()) { + GeomEdgePtr aCurEdge = aCurShape->edge(); + GeomVertexPtr aVertex = theShape->vertex(); + GeomPointPtr aCenter; + switch (anApIt->myCenterType) { + case (int)ModelAPI_AttributeSelection::CIRCLE_CENTER: { + GeomCirclePtr aCirc = aCurEdge->circle(); + if (aCirc) + aCenter = aCirc->center(); + break; + } + case (int)ModelAPI_AttributeSelection::ELLIPSE_FIRST_FOCUS: { + GeomEllipsePtr anEllipse = aCurEdge->ellipse(); + if (anEllipse) + aCenter = anEllipse->firstFocus(); + break; + } + case (int)ModelAPI_AttributeSelection::ELLIPSE_SECOND_FOCUS: { + GeomEllipsePtr anEllipse = aCurEdge->ellipse(); + if (anEllipse) + aCenter = anEllipse->secondFocus(); + break; + } + } + if (aCenter && aCenter->distance(aVertex->point()) < 1.e-7) + aCenters.push_back(std::pair(aCurShape, aNbPossibleSelections)); + } + } } + // passed till the appropriate shape, check the center of circle or a focus of ellipse is selected + if (isContinue && !aCenters.empty()) + aNbPossibleSelections = aCenters.front().second; } } return aNbPossibleSelections; -- 2.39.2