From: azv Date: Wed, 19 Feb 2020 10:53:16 +0000 (+0300) Subject: Fix crash in Symmetry and update the processing of the centers of circles and focuses... X-Git-Tag: V9_5_0a1^2~6 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=cd13321b214c0f221f6e9e9c5a2627c8a4fb4a04;p=modules%2Fshaper.git Fix crash in Symmetry and update the processing of the centers of circles and focuses of ellipses while geometric dumping. --- 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;