X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSketchPlugin%2FSketchPlugin_Fillet.cpp;h=ece5689f626b13ca6a84ee9107a01bcc6acc68a0;hb=05e2e4a31fa248d71445c40e35eeafa44f5d3b1b;hp=b38352be8d2a28726c086e7cd5693f337676b99b;hpb=5d4a94f71bdfac29da59f832e76825f323c4b1dd;p=modules%2Fshaper.git diff --git a/src/SketchPlugin/SketchPlugin_Fillet.cpp b/src/SketchPlugin/SketchPlugin_Fillet.cpp index b38352be8..ece5689f6 100644 --- a/src/SketchPlugin/SketchPlugin_Fillet.cpp +++ b/src/SketchPlugin/SketchPlugin_Fillet.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2017 CEA/DEN, EDF R&D +// Copyright (C) 2014-2022 CEA/DEN, EDF R&D // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -12,10 +12,9 @@ // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or -// email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #include "SketchPlugin_Fillet.h" @@ -32,6 +31,7 @@ #include "SketchPlugin_ConstraintTangent.h" #include "SketchPlugin_ConstraintRadius.h" #include "SketchPlugin_Tools.h" +#include "SketchPlugin_Validators.h" #include #include @@ -54,6 +54,7 @@ #include #include +#include #include @@ -82,8 +83,9 @@ static std::set findFeaturesToRemove(const FeaturePtr theFeature, const AttributePtr theAttribute); SketchPlugin_Fillet::SketchPlugin_Fillet() -: myFilletCreated(false) +: myIsReversed(false), myFilletCreated(false) { + myIsNotInversed[0] = myIsNotInversed[1] = true; } void SketchPlugin_Fillet::initAttributes() @@ -104,6 +106,10 @@ void SketchPlugin_Fillet::execute() // create feature for fillet arc FeaturePtr aFilletArc = createFilletArc(); + if (!aFilletArc) { + setError("Error: unable to create a fillet arc."); + return; + } // collect features referred to the edges participating in fillet AttributePoint2DPtr aFilletPoints[2]; @@ -189,6 +195,11 @@ AISObjectPtr SketchPlugin_Fillet::getAISObject(AISObjectPtr thePrevious) anAISObject = AISObjectPtr(new GeomAPI_AISObject); } anAISObject->createShape(anArcShape); + bool isAxiliary = false; + AttributeBooleanPtr aAttr = boolean(AUXILIARY_ID()); + if (aAttr.get()) + isAxiliary = aAttr->value(); + SketchPlugin_Tools::customizeFeaturePrs(anAISObject, isAxiliary); return anAISObject; } @@ -203,16 +214,15 @@ bool SketchPlugin_Fillet::calculateFilletParameters() if (!aFilletPoint2D.get()) return false; - std::set aFilletFeatures = - SketchPlugin_Tools::findFeaturesCoincidentToPoint(aFilletPoint2D); - if (aFilletFeatures.size() != 2) { - setError("Error: Selected point does not have two suitable edges for fillet."); + Events_InfoMessage anError; + FeaturePtr anEdge1, anEdge2; + if (!SketchPlugin_FilletVertexValidator::isValidVertex + (aPointRefAttr, anError, anEdge1, anEdge2)) { + setError(anError.messageString()); return false; } - - std::set::iterator aFIt = aFilletFeatures.begin(); - myBaseFeatures[0] = *aFIt; - myBaseFeatures[1] = *(++aFIt); + myBaseFeatures[0] = anEdge1; + myBaseFeatures[1] = anEdge2; std::shared_ptr aFilletPnt2d = aFilletPoint2D->pnt(); double aRadius = calculateFilletRadius(myBaseFeatures); @@ -299,6 +309,10 @@ FeaturePtr SketchPlugin_Fillet::createFilletArc() if (!myBaseFeatures[0] || !myBaseFeatures[1]) calculateFilletParameters(); + // fix for issue #2810 (sometimes, myCenterXY is NULL, fillet should report an error) + if (!myCenterXY) + return FeaturePtr(); + // Create arc feature. FeaturePtr aFilletArc = sketch()->addFeature(SketchPlugin_Arc::ID()); @@ -332,6 +346,7 @@ FeaturePtr SketchPlugin_Fillet::createFilletApex(const GeomPnt2dPtr& theCoordina AttributePoint2DPtr aCoord = std::dynamic_pointer_cast( anApex->attribute(SketchPlugin_Point::COORD_ID())); aCoord->setValue(theCoordinates); + anApex->boolean(SketchPlugin_Point::AUXILIARY_ID())->setValue(true); // additional coincidence constraints static Events_ID anUpdateEvent = Events_Loop::eventByName(EVENT_OBJECT_UPDATED); @@ -350,7 +365,7 @@ FeaturePtr SketchPlugin_Fillet::createFilletApex(const GeomPnt2dPtr& theCoordina struct Length { AttributePtr myPoints[2]; - std::string myValueText; + std::wstring myValueText; double myValueDouble; GeomPnt2dPtr myFlyoutPoint; int myLocationType; @@ -416,7 +431,7 @@ void SketchPlugin_Fillet::removeReferencesButKeepDistances( AttributePoint2DPtr aFlyoutAttr = std::dynamic_pointer_cast( aLength->attribute(SketchPlugin_ConstraintLength::FLYOUT_VALUE_PNT())); if (aFlyoutAttr && aFlyoutAttr->isInitialized()) - aNewLength.myFlyoutPoint = aFlyoutAttr->pnt(); + aNewLength.myFlyoutPoint = SketchPlugin_Tools::flyoutPointCoordinates(aLength); AttributeIntegerPtr aLocationAttr = aLength->integer(SketchPlugin_ConstraintLength::LOCATION_TYPE_ID()); if (aLocationAttr && aLocationAttr->isInitialized()) @@ -555,7 +570,7 @@ double calculateFilletRadius(FeaturePtr theFilletFeatures[2]) if (anEdge) aLengths[i] = anEdge->length(); } - return std::min(aLengths[0], aLengths[1]) / 6.0; + return (aLengths[0] < aLengths[1] ? aLengths[0] : aLengths[1]) / 6.0; } std::set findFeaturesToRemove(const FeaturePtr theFeature,