From df7983fe10ad7c62048b4bfd5ed2a5f9978cf8a6 Mon Sep 17 00:00:00 2001 From: jrheinlaender Date: Mon, 8 Apr 2013 20:25:59 +0430 Subject: [PATCH] Moved BaseFeature Property from SketchBased to PartDesign::Feature because all PartDesign features need it --- src/Mod/PartDesign/App/Feature.cpp | 29 +++++++++++++++++++ src/Mod/PartDesign/App/Feature.h | 10 ++++++- src/Mod/PartDesign/App/FeatureSketchBased.cpp | 26 ++--------------- src/Mod/PartDesign/App/FeatureSketchBased.h | 4 --- 4 files changed, 40 insertions(+), 29 deletions(-) diff --git a/src/Mod/PartDesign/App/Feature.cpp b/src/Mod/PartDesign/App/Feature.cpp index dfb1d050c..01247100b 100644 --- a/src/Mod/PartDesign/App/Feature.cpp +++ b/src/Mod/PartDesign/App/Feature.cpp @@ -47,6 +47,15 @@ PROPERTY_SOURCE(PartDesign::Feature,Part::Feature) Feature::Feature() { + ADD_PROPERTY(BaseFeature,(0)); + +} + +short Feature::mustExecute() const +{ + if (BaseFeature.isTouched()) + return 1; + return Part::Feature::mustExecute(); } TopoDS_Shape Feature::getSolid(const TopoDS_Shape& shape) @@ -77,4 +86,24 @@ const gp_Pnt Feature::getPointFromFace(const TopoDS_Face& f) throw Base::Exception("getPointFromFace(): Not implemented yet for this case"); } +const TopoDS_Shape& Feature::getBaseShape() const { + App::DocumentObject* BaseLink = BaseFeature.getValue(); + if (BaseLink == NULL) throw Base::Exception("Base property not set"); + Part::Feature* BaseObject = NULL; + if (BaseLink->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) + BaseObject = static_cast(BaseLink); + + if (BaseObject == NULL) + throw Base::Exception("No base feature linked"); + + const TopoDS_Shape& result = BaseObject->Shape.getValue(); + if (result.IsNull()) + throw Base::Exception("Base feature's shape is invalid"); + TopExp_Explorer xp (result, TopAbs_SOLID); + if (!xp.More()) + throw Base::Exception("Base feature's shape is not a solid"); + + return result; +} + } diff --git a/src/Mod/PartDesign/App/Feature.h b/src/Mod/PartDesign/App/Feature.h index 41125fb64..3fe92e761 100644 --- a/src/Mod/PartDesign/App/Feature.h +++ b/src/Mod/PartDesign/App/Feature.h @@ -45,9 +45,17 @@ class PartDesignExport Feature : public Part::Feature PROPERTY_HEADER(PartDesign::Feature); public: - Feature(); + Feature(); + + /// Base feature which this feature will be fused into or cut out of + App::PropertyLink BaseFeature; + + short mustExecute() const; protected: + /// Returns the BaseFeature property's shape (if any) + const TopoDS_Shape& getBaseShape() const; + /** * Get a solid of the given shape. If no solid is found an exception is raised. */ diff --git a/src/Mod/PartDesign/App/FeatureSketchBased.cpp b/src/Mod/PartDesign/App/FeatureSketchBased.cpp index 2d7c2db95..3a46b1994 100644 --- a/src/Mod/PartDesign/App/FeatureSketchBased.cpp +++ b/src/Mod/PartDesign/App/FeatureSketchBased.cpp @@ -98,7 +98,6 @@ PROPERTY_SOURCE(PartDesign::SketchBased, PartDesign::Feature) SketchBased::SketchBased() { - ADD_PROPERTY(BaseFeature,(0)); ADD_PROPERTY_TYPE(Sketch,(0),"SketchBased", App::Prop_None, "Reference to sketch"); ADD_PROPERTY_TYPE(Midplane,(0),"SketchBased", App::Prop_None, "Extrude symmetric to sketch face"); ADD_PROPERTY_TYPE(Reversed, (0),"SketchBased", App::Prop_None, "Reverse extrusion direction"); @@ -106,12 +105,11 @@ SketchBased::SketchBased() short SketchBased::mustExecute() const { - if (BaseFeature.isTouched() || - Sketch.isTouched() || + if (Sketch.isTouched() || Midplane.isTouched() || Reversed.isTouched()) return 1; - return 0; // PartDesign::Feature::mustExecute(); + return PartDesign::Feature::mustExecute(); } void SketchBased::positionBySketch(void) @@ -233,26 +231,6 @@ const TopoDS_Shape& SketchBased::getSupportShape() const { return result; } -const TopoDS_Shape& SketchBased::getBaseShape() const { - App::DocumentObject* BaseLink = BaseFeature.getValue(); - if (BaseLink == NULL) throw Base::Exception("Base property not set"); - Part::Feature* BaseObject = NULL; - if (BaseLink->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) - BaseObject = static_cast(BaseLink); - - if (BaseObject == NULL) - throw Base::Exception("No base feature linked"); - - const TopoDS_Shape& result = BaseObject->Shape.getValue(); - if (result.IsNull()) - throw Base::Exception("Base feature's shape is invalid"); - TopExp_Explorer xp (result, TopAbs_SOLID); - if (!xp.More()) - throw Base::Exception("Base feature's shape is not a solid"); - - return result; -} - int SketchBased::getSketchAxisCount(void) const { Part::Part2DObject *sketch = static_cast(Sketch.getValue()); diff --git a/src/Mod/PartDesign/App/FeatureSketchBased.h b/src/Mod/PartDesign/App/FeatureSketchBased.h index b663fb125..7284df649 100644 --- a/src/Mod/PartDesign/App/FeatureSketchBased.h +++ b/src/Mod/PartDesign/App/FeatureSketchBased.h @@ -45,8 +45,6 @@ public: SketchBased(); // Common properties for all sketch based features - /// Base feature which this feature will be fused into or cut out of - App::PropertyLink BaseFeature; /// Sketch used to create this feature App::PropertyLink Sketch; /// Reverse extrusion direction @@ -75,8 +73,6 @@ public: Part::Feature* getSupport() const; /// Returns the sketch support shape (if any) const TopoDS_Shape& getSupportShape() const; - /// Returns the base property's shape (if any) - const TopoDS_Shape& getBaseShape() const; /// retrieves the number of axes in the linked sketch (defined as construction lines) int getSketchAxisCount(void) const;