From ac695ad67b52f4104701bf7583a74903fdf0c4b2 Mon Sep 17 00:00:00 2001 From: logari81 Date: Sat, 10 Dec 2011 15:23:59 +0000 Subject: [PATCH] + infrastructure for placement synchronization of SketchBased features git-svn-id: https://free-cad.svn.sourceforge.net/svnroot/free-cad/trunk@5255 e8eeb9e2-ec13-0410-a4a9-efa5cf37419d --- src/Mod/PartDesign/App/FeatureSketchBased.cpp | 17 +++++++++++++++-- src/Mod/PartDesign/App/FeatureSketchBased.h | 5 +++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/Mod/PartDesign/App/FeatureSketchBased.cpp b/src/Mod/PartDesign/App/FeatureSketchBased.cpp index 661aafd77..1ebd2db1c 100644 --- a/src/Mod/PartDesign/App/FeatureSketchBased.cpp +++ b/src/Mod/PartDesign/App/FeatureSketchBased.cpp @@ -49,6 +49,7 @@ #include "FeatureSketchBased.h" +#include using namespace PartDesign; @@ -65,7 +66,7 @@ struct Wire_Compare { BRepBndLib::Add(w2, box2); box2.SetGap(0.0); - + return box1.SquareExtent() < box2.SquareExtent(); } }; @@ -77,6 +78,18 @@ SketchBased::SketchBased() ADD_PROPERTY(Sketch,(0)); } +void SketchBased::positionBySketch(void) +{ + Part::Part2DObject *sketch = static_cast(Sketch.getValue()); + if (sketch && sketch->getTypeId().isDerivedFrom(Part::Part2DObject::getClassTypeId())) { + Part::Feature *part = static_cast(sketch->Support.getValue()); + if (part && part->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) + this->Placement.setValue(part->Placement.getValue()); + else + this->Placement.setValue(sketch->Placement.getValue()); + } +} + bool SketchBased::isInside(const TopoDS_Wire& wire1, const TopoDS_Wire& wire2) const { Bnd_Box box1; @@ -180,7 +193,7 @@ TopoDS_Shape SketchBased::makeFace(std::list& wires) const inner_axis = adapt.Plane().Axis().Direction(); } // It seems that orientation is always 'Forward' and we only have to reverse - // if the underlying plane have opposite normals. + // if the underlying plane have opposite normals. if (axis.Dot(inner_axis) < 0) it->Reverse(); mkFace.Add(*it); diff --git a/src/Mod/PartDesign/App/FeatureSketchBased.h b/src/Mod/PartDesign/App/FeatureSketchBased.h index c65033dda..947c0356e 100644 --- a/src/Mod/PartDesign/App/FeatureSketchBased.h +++ b/src/Mod/PartDesign/App/FeatureSketchBased.h @@ -42,6 +42,11 @@ public: App::PropertyLink Sketch; + /** calculates and updates the Placement property based on the Sketch + * or its support if it has one + */ + void positionBySketch(void); + protected: TopoDS_Face validateFace(const TopoDS_Face&) const; TopoDS_Shape makeFace(const std::vector&) const;