]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
[bos #29971] [CEA 29586] doing a fillet
authorjfa <jfa@opencascade.com>
Mon, 23 May 2022 08:24:16 +0000 (11:24 +0300)
committerjfa <jfa@opencascade.com>
Mon, 23 May 2022 08:24:16 +0000 (11:24 +0300)
src/SketchPlugin/SketchPlugin_Fillet.cpp
src/SketchPlugin/SketchPlugin_Validators.cpp
src/SketchPlugin/SketchPlugin_Validators.h

index 8fd28ecb690f14be18060d8e64c5d54a54b5cddd..25aa311ecaa3ce75218d50d05f1681a1172153c9 100644 (file)
@@ -31,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>
@@ -53,6 +54,7 @@
 #include <GeomDataAPI_Point2D.h>
 
 #include <Events_Loop.h>
+#include <Events_InfoMessage.h>
 
 #include <math.h>
 
@@ -212,37 +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);
-  }
-  // remove auxilary entities from set of coincident features
-  if (aFilletFeatures.size() > 2) {
-    std::set<FeaturePtr>::iterator anIt = aFilletFeatures.begin();
-    while (anIt != aFilletFeatures.end()) {
-      if ((*anIt)->boolean(SketchPlugin_SketchEntity::AUXILIARY_ID())->value()) {
-        std::set<FeaturePtr>::iterator aRemoveIt = anIt++;
-        aFilletFeatures.erase(aRemoveIt);
-      }
-      else
-        ++anIt;
-    }
-  }
-  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);
index bd8408eea736922fd5c00a05b2b27e8e71cac874..73ec0900a11779d5a0e6778aebbbe5e8eeab6859 100644 (file)
@@ -669,6 +669,15 @@ static bool isPointPointCoincidence(const FeaturePtr& theCoincidence)
 bool SketchPlugin_FilletVertexValidator::isValid(const AttributePtr& theAttribute,
                                                  const std::list<std::string>& theArguments,
                                                  Events_InfoMessage& theError) const
+{
+  FeaturePtr anEdge1, anEdge2;
+  return isValidVertex(theAttribute, theError, anEdge1, anEdge2);
+}
+
+bool SketchPlugin_FilletVertexValidator::isValidVertex(const AttributePtr& theAttribute,
+                                                       Events_InfoMessage& theError,
+                                                       FeaturePtr&         theEdge1,
+                                                       FeaturePtr&         theEdge2)
 {
   AttributeRefAttrPtr aPointRefAttr =
     std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(theAttribute);
@@ -723,13 +732,13 @@ bool SketchPlugin_FilletVertexValidator::isValid(const AttributePtr& theAttribut
   // Get coincides from constraint.
   std::set<FeaturePtr> aCoinsides;
   SketchPlugin_Tools::findCoincidences(aConstraintCoincidence,
-                                        SketchPlugin_ConstraintCoincidence::ENTITY_A(),
-                                        aCoinsides,
-                                        true);
+                                       SketchPlugin_ConstraintCoincidence::ENTITY_A(),
+                                       aCoinsides,
+                                       true);
   SketchPlugin_Tools::findCoincidences(aConstraintCoincidence,
-                                        SketchPlugin_ConstraintCoincidence::ENTITY_B(),
-                                        aCoinsides,
-                                        true);
+                                       SketchPlugin_ConstraintCoincidence::ENTITY_B(),
+                                       aCoinsides,
+                                       true);
 
   // Remove points and external lines from set of coincides.
   std::set<FeaturePtr> aNewSetOfCoincides;
@@ -774,6 +783,11 @@ bool SketchPlugin_FilletVertexValidator::isValid(const AttributePtr& theAttribut
     return false;
   }
 
+  // output edges
+  std::set<FeaturePtr>::iterator aFIt = aCoinsides.begin();
+  theEdge1 = *aFIt;
+  theEdge2 = *(++aFIt);
+
   // Check that selected edges don't have tangent constraint.
   std::set<FeaturePtr>::iterator anIt = aCoinsides.begin();
   FeaturePtr aFirstFeature = *anIt++;
index 3cb49701fed6bbc61b0584856d79893572982978..1516d555496475dedaa27b5ddedc5528d4fce375 100644 (file)
@@ -209,6 +209,16 @@ public:
   virtual bool isValid(const AttributePtr& theAttribute,
                        const std::list<std::string>& theArguments,
                        Events_InfoMessage& theError) const;
+
+  //! returns true if attribute is a good point for fillet
+  //! \param theAttribute the checked point attribute
+  //! \param theError error message
+  //! \param theEdge1 adjacent edge feature
+  //! \param theEdge2 adjacent edge feature
+  static bool isValidVertex(const AttributePtr& theAttribute,
+                            Events_InfoMessage& theError,
+                            FeaturePtr&         theEdge1,
+                            FeaturePtr&         theEdge2);
 };