+ 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
This commit is contained in:
logari81 2011-12-10 15:23:59 +00:00
parent fad7696ad4
commit ac695ad67b
2 changed files with 20 additions and 2 deletions

View File

@ -49,6 +49,7 @@
#include "FeatureSketchBased.h"
#include <Mod/Part/App/Part2DObject.h>
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<Part::Part2DObject*>(Sketch.getValue());
if (sketch && sketch->getTypeId().isDerivedFrom(Part::Part2DObject::getClassTypeId())) {
Part::Feature *part = static_cast<Part::Feature*>(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<TopoDS_Wire>& 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);

View File

@ -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<TopoDS_Wire>&) const;