PartDesign: tidy up PartDesign feature dependencies
This commit is contained in:
parent
3743d99816
commit
ded5b893a8
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -39,6 +39,7 @@ public:
|
|||
|
||||
App::PropertyLinkSub Base;
|
||||
|
||||
short mustExecute() const;
|
||||
/// updates the Placement property from the Placement of Base
|
||||
void positionByBase(void);
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@ short Face::mustExecute() const
|
|||
{
|
||||
if (Sources.isTouched())
|
||||
return 1;
|
||||
return 0;
|
||||
return Part::Part2DObject::mustExecute();
|
||||
}
|
||||
|
||||
App::DocumentObjectExecReturn *Face::execute(void)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue
Block a user