PartDesign: tidy up PartDesign feature dependencies

This commit is contained in:
jrheinlaender 2012-09-09 10:05:43 +02:00 committed by logari81
parent 3743d99816
commit ded5b893a8
15 changed files with 42 additions and 29 deletions

View File

@ -83,7 +83,7 @@ void PartDesignExport initPartDesign()
PartDesign::Pocket ::init();
PartDesign::Fillet ::init();
PartDesign::Revolution ::init();
PartDesign::Groove ::init();
PartDesign::Groove ::init();
PartDesign::Chamfer ::init();
PartDesign::Face ::init();
}

View File

@ -52,11 +52,9 @@ Chamfer::Chamfer()
short Chamfer::mustExecute() const
{
if (Placement.isTouched() || Base.isTouched() || Size.isTouched())
if (Placement.isTouched() || Size.isTouched())
return 1;
if (Base.getValue() && Base.getValue()->isTouched())
return 1;
return 0;
return DressUp::mustExecute();
}
App::DocumentObjectExecReturn *Chamfer::execute(void)

View File

@ -41,6 +41,14 @@ DressUp::DressUp()
ADD_PROPERTY(Base,(0));
}
short DressUp::mustExecute() const
{
if (Base.getValue() && Base.getValue()->isTouched())
return 1;
return PartDesign::Feature::mustExecute();
}
void DressUp::positionByBase(void)
{
Part::Feature *base = static_cast<Part::Feature*>(Base.getValue());

View File

@ -39,6 +39,7 @@ public:
App::PropertyLinkSub Base;
short mustExecute() const;
/// updates the Placement property from the Placement of Base
void positionByBase(void);

View File

@ -62,7 +62,7 @@ short Face::mustExecute() const
{
if (Sources.isTouched())
return 1;
return 0;
return Part::Part2DObject::mustExecute();
}
App::DocumentObjectExecReturn *Face::execute(void)

View File

@ -49,11 +49,9 @@ Fillet::Fillet()
short Fillet::mustExecute() const
{
if (Placement.isTouched() || Base.isTouched() || Radius.isTouched())
if (Placement.isTouched() || Radius.isTouched())
return 1;
if (Base.getValue() && Base.getValue()->isTouched())
return 1;
return 0;
return DressUp::mustExecute();
}
App::DocumentObjectExecReturn *Fillet::execute(void)

View File

@ -48,7 +48,7 @@ using namespace PartDesign;
namespace PartDesign {
PROPERTY_SOURCE(PartDesign::Groove, PartDesign::SketchBased)
PROPERTY_SOURCE(PartDesign::Groove, PartDesign::Subtractive)
Groove::Groove()
{
@ -63,7 +63,6 @@ Groove::Groove()
short Groove::mustExecute() const
{
if (Placement.isTouched() ||
Sketch.isTouched() ||
ReferenceAxis.isTouched() ||
Axis.isTouched() ||
Base.isTouched() ||
@ -71,7 +70,7 @@ short Groove::mustExecute() const
Midplane.isTouched() ||
Reversed.isTouched())
return 1;
return 0;
return Subtractive::mustExecute();
}
App::DocumentObjectExecReturn *Groove::execute(void)

View File

@ -25,12 +25,12 @@
#define PARTDESIGN_Groove_H
#include <App/PropertyUnits.h>
#include "FeatureSketchBased.h"
#include "FeatureSubtractive.h"
namespace PartDesign
{
class PartDesignExport Groove : public SketchBased
class PartDesignExport Groove : public Subtractive
{
PROPERTY_HEADER(PartDesign::Groove);

View File

@ -53,7 +53,7 @@ const char* Hole::TypeEnums[] = {"Dimension","UpToLast","UpToFirst",NULL};
const char* Hole::HoleTypeEnums[]= {"Simple","Counterbore","Countersunk",NULL};
const char* Hole::ThreadEnums[] = {"None","Metric","MetricFine",NULL};
PROPERTY_SOURCE(PartDesign::Hole, PartDesign::SketchBased)
PROPERTY_SOURCE(PartDesign::Hole, PartDesign::Subtractive)
Hole::Hole()
{
@ -72,7 +72,7 @@ Hole::Hole()
// if (Sketch.isTouched() ||
// Length.isTouched())
// return 1;
// return 0;
// return Subtractive::mustExecute();
//}
App::DocumentObjectExecReturn *Hole::execute(void)
@ -134,6 +134,8 @@ App::DocumentObjectExecReturn *Hole::execute(void)
//if (PrismMaker.IsDone()) {
// // if the sketch has a support fuse them to get one result object (PAD!)
// if (SupportObject) {
// // Set the subtractive shape property for later usage in e.g. pattern
// this->SubShape.setValue(PrismMaker.Shape());
// const TopoDS_Shape& support = SupportObject->Shape.getValue();
// if (support.IsNull())
// return new App::DocumentObjectExecReturn("Support shape is invalid");

View File

@ -68,14 +68,13 @@ Pad::Pad()
short Pad::mustExecute() const
{
if (Placement.isTouched() ||
Sketch.isTouched() ||
Length.isTouched() ||
Midplane.isTouched() ||
Reversed.isTouched() ||
Length2.isTouched() ||
FaceName.isTouched())
return 1;
return 0;
return Additive::mustExecute();
}
App::DocumentObjectExecReturn *Pad::execute(void)

View File

@ -56,7 +56,7 @@ using namespace PartDesign;
const char* Pocket::TypeEnums[]= {"Length","UpToLast","UpToFirst","ThroughAll","UpToFace",NULL};
PROPERTY_SOURCE(PartDesign::Pocket, PartDesign::SketchBased)
PROPERTY_SOURCE(PartDesign::Pocket, PartDesign::Subtractive)
Pocket::Pocket()
{
@ -69,11 +69,10 @@ Pocket::Pocket()
short Pocket::mustExecute() const
{
if (Placement.isTouched() ||
Sketch.isTouched() ||
Length.isTouched() ||
FaceName.isTouched())
return 1;
return 0;
return Subtractive::mustExecute();
}
App::DocumentObjectExecReturn *Pocket::execute(void)
@ -255,8 +254,7 @@ App::DocumentObjectExecReturn *Pocket::execute(void)
return new App::DocumentObjectExecReturn("Internal error: Unknown type for Pocket feature");
}
// TODO: Set the subtractive shape property for later usage in e.g. pattern
//this->SubShape.setValue(prism); // This crashes with "Illegal storage access". Why?
this->SubShape.setValue(prism);
// Cut out the pocket
BRepAlgoAPI_Cut mkCut(support.Moved(invObjLoc), prism);

View File

@ -48,7 +48,7 @@ using namespace PartDesign;
namespace PartDesign {
PROPERTY_SOURCE(PartDesign::Revolution, PartDesign::SketchBased)
PROPERTY_SOURCE(PartDesign::Revolution, PartDesign::Additive)
Revolution::Revolution()
{
@ -63,7 +63,6 @@ Revolution::Revolution()
short Revolution::mustExecute() const
{
if (Placement.isTouched() ||
Sketch.isTouched() ||
ReferenceAxis.isTouched() ||
Axis.isTouched() ||
Base.isTouched() ||
@ -71,7 +70,7 @@ short Revolution::mustExecute() const
Midplane.isTouched() ||
Reversed.isTouched())
return 1;
return 0;
return Additive::mustExecute();
}
App::DocumentObjectExecReturn *Revolution::execute(void)
@ -183,6 +182,8 @@ App::DocumentObjectExecReturn *Revolution::execute(void)
if (SupportObject) {
const TopoDS_Shape& support = SupportObject->Shape.getValue();
if (!support.IsNull() && support.ShapeType() == TopAbs_SOLID) {
// set the additive shape property for later usage in e.g. pattern
this->AddShape.setValue(result);
// Let's call algorithm computing a fuse operation:
BRepAlgoAPI_Fuse mkFuse(support.Moved(invObjLoc), result);
// Let's check if the fusion has been successful

View File

@ -25,12 +25,12 @@
#define PARTDESIGN_Revolution_H
#include <App/PropertyUnits.h>
#include "FeatureSketchBased.h"
#include "FeatureAdditive.h"
namespace PartDesign
{
class PartDesignExport Revolution : public SketchBased
class PartDesignExport Revolution : public Additive
{
PROPERTY_HEADER(PartDesign::Revolution);

View File

@ -77,6 +77,13 @@ SketchBased::SketchBased()
ADD_PROPERTY(Sketch,(0));
}
short SketchBased::mustExecute() const
{
if (Sketch.isTouched())
return 1;
return 0; // PartDesign::Feature::mustExecute();
}
void SketchBased::positionBySketch(void)
{
Part::Part2DObject *sketch = static_cast<Part::Part2DObject*>(Sketch.getValue());

View File

@ -42,6 +42,8 @@ public:
App::PropertyLink Sketch;
short mustExecute() const;
/** calculates and updates the Placement property based on the Sketch
* or its support if it has one
*/