Salome HOME
[bos #29971] [CEA 29586] doing a fillet
[modules/shaper.git] / src / SketchPlugin / SketchPlugin_Fillet.cpp
index 7503f75365558869fed8a96aba7844ff7930cea4..25aa311ecaa3ce75218d50d05f1681a1172153c9 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2014-2017  CEA/DEN, EDF R&D
+// Copyright (C) 2014-2021  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
 //
 // 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<mailto: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 <ModelAPI_AttributeDouble.h>
 #include <ModelAPI_AttributeInteger.h>
@@ -54,6 +54,7 @@
 #include <GeomDataAPI_Point2D.h>
 
 #include <Events_Loop.h>
+#include <Events_InfoMessage.h>
 
 #include <math.h>
 
@@ -82,7 +83,7 @@ static std::set<FeaturePtr> findFeaturesToRemove(const FeaturePtr theFeature,
                                                  const AttributePtr theAttribute);
 
 SketchPlugin_Fillet::SketchPlugin_Fillet()
-: myFilletCreated(false), myIsReversed(false)
+: myIsReversed(false), myFilletCreated(false)
 {
   myIsNotInversed[0] = myIsNotInversed[1] = true;
 }
@@ -194,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;
 }
 
@@ -208,25 +214,15 @@ bool SketchPlugin_Fillet::calculateFilletParameters()
   if (!aFilletPoint2D.get())
     return false;
 
-  std::set<AttributePoint2DPtr> aCoincidentPoints =
-      SketchPlugin_Tools::findPointsCoincidentToPoint(aFilletPoint2D);
-  std::set<FeaturePtr> aFilletFeatures;
-  for (std::set<AttributePoint2DPtr>::iterator aCPIt = aCoincidentPoints.begin();
-       aCPIt != aCoincidentPoints.end(); ++aCPIt) {
-    std::shared_ptr<SketchPlugin_Feature> anOwner =
-        std::dynamic_pointer_cast<SketchPlugin_Feature>(
-        ModelAPI_Feature::feature((*aCPIt)->owner()));
-    if (anOwner && !anOwner->isExternal())
-      aFilletFeatures.insert(anOwner);
-  }
-  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<FeaturePtr>::iterator aFIt = aFilletFeatures.begin();
-  myBaseFeatures[0] = *aFIt;
-  myBaseFeatures[1] = *(++aFIt);
+  myBaseFeatures[0] = anEdge1;
+  myBaseFeatures[1] = anEdge2;
 
   std::shared_ptr<GeomAPI_Pnt2d> aFilletPnt2d = aFilletPoint2D->pnt();
   double aRadius = calculateFilletRadius(myBaseFeatures);
@@ -369,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;