]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #700 Fillet for edges with not shared point question
authornds <natalia.donis@opencascade.com>
Tue, 7 Jul 2015 06:09:19 +0000 (09:09 +0300)
committernds <natalia.donis@opencascade.com>
Tue, 7 Jul 2015 06:09:19 +0000 (09:09 +0300)
src/SketchPlugin/SketchPlugin_Plugin.cpp
src/SketchPlugin/SketchPlugin_Validators.cpp
src/SketchPlugin/SketchPlugin_Validators.h
src/SketchPlugin/plugin-Sketch.xml

index 7742fa5c10c94fd84a6fbbc853cbf94d2a7b1a22..4e29b3bfc08b11ac6d5b47f7bd921f8ae9fcc7d2 100644 (file)
@@ -57,6 +57,8 @@ SketchPlugin_Plugin::SketchPlugin_Plugin()
                               new SketchPlugin_ExternalValidator);
   aFactory->registerValidator("SketchPlugin_TangentAttr",
                               new SketchPlugin_TangentAttrValidator);
+  aFactory->registerValidator("SketchPlugin_CoincidentAttr",
+                              new SketchPlugin_CoincidentAttr);
   aFactory->registerValidator("SketchPlugin_NotFixed",
                               new SketchPlugin_NotFixedValidator);
   aFactory->registerValidator("SketchPlugin_EqualAttr",
index 597f17d47a7e6d63a0df4f0d63a987e10099b801..40cfd995dd5857aeedcd912945173d2baa79a5c0 100644 (file)
@@ -77,7 +77,8 @@ bool SketchPlugin_DistanceAttrValidator::isValid(
   }
   return false;
 }
-bool SketchPlugin_TangentAttrValidator::isValid(
+
+bool SketchPlugin_CoincidentAttr::isValid(
   const AttributePtr& theAttribute, const std::list<std::string>& theArguments ) const
 {
   // there is a check whether the feature contains a point and a linear edge or two point values
@@ -94,21 +95,13 @@ bool SketchPlugin_TangentAttrValidator::isValid(
   ObjectPtr anObject = aRefAttr->object();
   if (isObject && anObject) {
     FeaturePtr aRefFea = ModelAPI_Feature::feature(anObject);
-
     AttributeRefAttrPtr aOtherAttr = aFeature->data()->refattr(aParamA);
     ObjectPtr aOtherObject = aOtherAttr->object();
+    // if the other attribute is not filled still, the result is true
+    if (!aOtherObject.get())
+      return true;
     FeaturePtr aOtherFea = ModelAPI_Feature::feature(aOtherObject);
 
-    if (aRefFea->getKind() == SketchPlugin_Line::ID()) {
-      if (aOtherFea->getKind() != SketchPlugin_Arc::ID())
-        return false;
-    } else if (aRefFea->getKind() == SketchPlugin_Arc::ID()) {
-      if (aOtherFea->getKind() != SketchPlugin_Line::ID() &&
-          aOtherFea->getKind() != SketchPlugin_Arc::ID())
-        return false;
-    } else
-      return false;
-
     // check that both have coincidence
     FeaturePtr aConstrFeature;
     std::set<FeaturePtr> aCoinList;
@@ -146,6 +139,43 @@ bool SketchPlugin_TangentAttrValidator::isValid(
   return false;
 }
 
+bool SketchPlugin_TangentAttrValidator::isValid(
+  const AttributePtr& theAttribute, const std::list<std::string>& theArguments ) const
+{
+  // there is a check whether the feature contains a point and a linear edge or two point values
+  std::string aParamA = theArguments.front();
+  SessionPtr aMgr = ModelAPI_Session::get();
+  ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
+
+  FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(theAttribute->owner());
+  AttributeRefAttrPtr aRefAttr = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(theAttribute);
+  if (!aRefAttr)
+    return false;
+
+  bool isObject = aRefAttr->isObject();
+  ObjectPtr anObject = aRefAttr->object();
+  if (isObject && anObject) {
+    FeaturePtr aRefFea = ModelAPI_Feature::feature(anObject);
+
+    AttributeRefAttrPtr aOtherAttr = aFeature->data()->refattr(aParamA);
+    ObjectPtr aOtherObject = aOtherAttr->object();
+    FeaturePtr aOtherFea = ModelAPI_Feature::feature(aOtherObject);
+
+    if (aRefFea->getKind() == SketchPlugin_Line::ID()) {
+      if (aOtherFea->getKind() != SketchPlugin_Arc::ID())
+        return false;
+    } else if (aRefFea->getKind() == SketchPlugin_Arc::ID()) {
+      if (aOtherFea->getKind() != SketchPlugin_Line::ID() &&
+          aOtherFea->getKind() != SketchPlugin_Arc::ID())
+        return false;
+    } else
+      return false;
+
+    return true;
+  }
+  return false;
+}
+
 bool SketchPlugin_NotFixedValidator::isValid(
     const AttributePtr& theAttribute, const std::list<std::string>& theArguments) const
 {
index cd7a7d5336dba141f1df7bb9b44f8302130aad57..6b1f29c0a12d1dbeab534f88a74610b639927849 100644 (file)
@@ -26,6 +26,20 @@ class SketchPlugin_DistanceAttrValidator : public ModelAPI_AttributeValidator
                        const std::list<std::string>& theArguments) const;
 };
 
+/**\class SketchPlugin_CoincidentAttr
+ * \ingroup Validators
+ * \brief Validator to check whether there is a coincident constraint between
+ * the attribute and attribute of argument.
+ */
+class SketchPlugin_CoincidentAttr : public ModelAPI_AttributeValidator
+{
+ public:
+  //! returns true if attribute is valid
+  //! \param theAttribute the checked attribute
+  //! \param theArguments arguments of the attribute
+  virtual bool isValid(const AttributePtr& theAttribute,
+                       const std::list<std::string>& theArguments) const;
+};
 
 /**\class SketchPlugin_TangentAttrValidator
  * \ingroup Validators
index fceacf5c47ae62f2e28d2030168826d958ce1df6..9cdbb2b0e88e4c21f8677a7162993aadfcca2220 100644 (file)
       <feature id="SketchConstraintTangent" title="Tangent" tooltip="Create constraint defining tangency of two objects" icon=":icons/tangent.png">
         <sketch_shape_selector id="ConstraintEntityA" 
             label="First object" tooltip="Select line or arc" shape_types="edge">
+          <validator id="SketchPlugin_CoincidentAttr" parameters="ConstraintEntityB"/>
           <validator id="PartSet_DifferentObjects"/>
         </sketch_shape_selector>
         
         <sketch_shape_selector id="ConstraintEntityB"
             label="Second object" tooltip="Select line or arc" shape_types="edge">
-        <validator id="SketchPlugin_TangentAttr" parameters="ConstraintEntityA"/>
-        <validator id="PartSet_DifferentObjects"/>
+          <validator id="SketchPlugin_CoincidentAttr" parameters="ConstraintEntityA"/>
+          <validator id="SketchPlugin_TangentAttr" parameters="ConstraintEntityA"/>
+          <validator id="PartSet_DifferentObjects"/>
         </sketch_shape_selector>
         <validator id="PartSet_TangentSelection"/>
       </feature>
         <sketch_shape_selector id="ConstraintEntityA" 
             label="First object" tooltip="Select line or arc" shape_types="edge">
           <validator id="PartSet_DifferentObjects"/>
+          <validator id="SketchPlugin_CoincidentAttr" parameters="ConstraintEntityB"/>
         </sketch_shape_selector>
 
         <sketch_shape_selector id="ConstraintEntityB"
             label="Second object" tooltip="Select line or arc" shape_types="edge">
           <validator id="PartSet_DifferentObjects"/>
+          <validator id="SketchPlugin_CoincidentAttr" parameters="ConstraintEntityA"/>
         </sketch_shape_selector>
 
         <doublevalue label="Value" tooltip="Fillet radius" id="ConstraintValue" min="0" default="1" use_reset="false">