From 74da3f1682a21155302ebd0f5eb69ecc27a08c52 Mon Sep 17 00:00:00 2001 From: nds Date: Tue, 7 Jul 2015 09:09:19 +0300 Subject: [PATCH] Issue #700 Fillet for edges with not shared point question --- src/SketchPlugin/SketchPlugin_Plugin.cpp | 2 + src/SketchPlugin/SketchPlugin_Validators.cpp | 54 +++++++++++++++----- src/SketchPlugin/SketchPlugin_Validators.h | 14 +++++ src/SketchPlugin/plugin-Sketch.xml | 8 ++- 4 files changed, 64 insertions(+), 14 deletions(-) diff --git a/src/SketchPlugin/SketchPlugin_Plugin.cpp b/src/SketchPlugin/SketchPlugin_Plugin.cpp index 7742fa5c1..4e29b3bfc 100644 --- a/src/SketchPlugin/SketchPlugin_Plugin.cpp +++ b/src/SketchPlugin/SketchPlugin_Plugin.cpp @@ -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", diff --git a/src/SketchPlugin/SketchPlugin_Validators.cpp b/src/SketchPlugin/SketchPlugin_Validators.cpp index 597f17d47..40cfd995d 100644 --- a/src/SketchPlugin/SketchPlugin_Validators.cpp +++ b/src/SketchPlugin/SketchPlugin_Validators.cpp @@ -77,7 +77,8 @@ bool SketchPlugin_DistanceAttrValidator::isValid( } return false; } -bool SketchPlugin_TangentAttrValidator::isValid( + +bool SketchPlugin_CoincidentAttr::isValid( const AttributePtr& theAttribute, const std::list& 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 aCoinList; @@ -146,6 +139,43 @@ bool SketchPlugin_TangentAttrValidator::isValid( return false; } +bool SketchPlugin_TangentAttrValidator::isValid( + const AttributePtr& theAttribute, const std::list& 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(theAttribute->owner()); + AttributeRefAttrPtr aRefAttr = std::dynamic_pointer_cast(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& theArguments) const { diff --git a/src/SketchPlugin/SketchPlugin_Validators.h b/src/SketchPlugin/SketchPlugin_Validators.h index cd7a7d533..6b1f29c0a 100644 --- a/src/SketchPlugin/SketchPlugin_Validators.h +++ b/src/SketchPlugin/SketchPlugin_Validators.h @@ -26,6 +26,20 @@ class SketchPlugin_DistanceAttrValidator : public ModelAPI_AttributeValidator const std::list& 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& theArguments) const; +}; /**\class SketchPlugin_TangentAttrValidator * \ingroup Validators diff --git a/src/SketchPlugin/plugin-Sketch.xml b/src/SketchPlugin/plugin-Sketch.xml index fceacf5c4..9cdbb2b0e 100644 --- a/src/SketchPlugin/plugin-Sketch.xml +++ b/src/SketchPlugin/plugin-Sketch.xml @@ -205,13 +205,15 @@ + - - + + + @@ -225,11 +227,13 @@ + + -- 2.30.2