[PD] App: remove superfluous nullptr checks
- also Body: get rid of some nasty single-letter variables
This commit is contained in:
@@ -173,9 +173,9 @@ bool Body::isAfterInsertPoint(App::DocumentObject* feature) {
|
||||
}
|
||||
}
|
||||
|
||||
bool Body::isMemberOfMultiTransform(const App::DocumentObject* f)
|
||||
bool Body::isMemberOfMultiTransform(const App::DocumentObject* obj)
|
||||
{
|
||||
if (f == nullptr)
|
||||
if (!obj)
|
||||
return false;
|
||||
|
||||
// ORIGINAL COMMENT:
|
||||
@@ -189,38 +189,38 @@ bool Body::isMemberOfMultiTransform(const App::DocumentObject* f)
|
||||
// to auto set it when the originals are not null. See:
|
||||
// App::DocumentObjectExecReturn *Transformed::execute(void)
|
||||
//
|
||||
return (f->getTypeId().isDerivedFrom(PartDesign::Transformed::getClassTypeId()) &&
|
||||
static_cast<const PartDesign::Transformed*>(f)->Originals.getValues().empty());
|
||||
return (obj->getTypeId().isDerivedFrom(PartDesign::Transformed::getClassTypeId()) &&
|
||||
static_cast<const PartDesign::Transformed*>(obj)->Originals.getValues().empty());
|
||||
}
|
||||
|
||||
bool Body::isSolidFeature(const App::DocumentObject* f)
|
||||
bool Body::isSolidFeature(const App::DocumentObject *obj)
|
||||
{
|
||||
if (f == nullptr)
|
||||
if (!obj)
|
||||
return false;
|
||||
|
||||
if (f->getTypeId().isDerivedFrom(PartDesign::Feature::getClassTypeId()) &&
|
||||
!PartDesign::Feature::isDatum(f)) {
|
||||
if (obj->getTypeId().isDerivedFrom(PartDesign::Feature::getClassTypeId()) &&
|
||||
!PartDesign::Feature::isDatum(obj)) {
|
||||
// Transformed Features inside a MultiTransform are not solid features
|
||||
return !isMemberOfMultiTransform(f);
|
||||
return !isMemberOfMultiTransform(obj);
|
||||
}
|
||||
return false;//DeepSOIC: work-in-progress?
|
||||
}
|
||||
|
||||
bool Body::isAllowed(const App::DocumentObject* f)
|
||||
bool Body::isAllowed(const App::DocumentObject *obj)
|
||||
{
|
||||
if (f == nullptr)
|
||||
if (!obj)
|
||||
return false;
|
||||
|
||||
// TODO: Should we introduce a PartDesign::FeaturePython class? This should then also return true for isSolidFeature()
|
||||
return (f->getTypeId().isDerivedFrom(PartDesign::Feature::getClassTypeId()) ||
|
||||
f->getTypeId().isDerivedFrom(Part::Datum::getClassTypeId()) ||
|
||||
return (obj->getTypeId().isDerivedFrom(PartDesign::Feature::getClassTypeId()) ||
|
||||
obj->getTypeId().isDerivedFrom(Part::Datum::getClassTypeId()) ||
|
||||
// TODO Shouldn't we replace it with Sketcher::SketchObject? (2015-08-13, Fat-Zer)
|
||||
f->getTypeId().isDerivedFrom(Part::Part2DObject::getClassTypeId()) ||
|
||||
f->getTypeId().isDerivedFrom(PartDesign::ShapeBinder::getClassTypeId()) ||
|
||||
f->getTypeId().isDerivedFrom(PartDesign::SubShapeBinder::getClassTypeId())
|
||||
obj->getTypeId().isDerivedFrom(Part::Part2DObject::getClassTypeId()) ||
|
||||
obj->getTypeId().isDerivedFrom(PartDesign::ShapeBinder::getClassTypeId()) ||
|
||||
obj->getTypeId().isDerivedFrom(PartDesign::SubShapeBinder::getClassTypeId())
|
||||
// TODO Why this lines was here? why should we allow anything of those? (2015-08-13, Fat-Zer)
|
||||
//f->getTypeId().isDerivedFrom(Part::FeaturePython::getClassTypeId()) // trouble with this line on Windows!? Linker fails to find getClassTypeId() of the Part::FeaturePython...
|
||||
//f->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())
|
||||
//obj->getTypeId().isDerivedFrom(Part::FeaturePython::getClassTypeId()) // trouble with this line on Windows!? Linker fails to find getClassTypeId() of the Part::FeaturePython...
|
||||
//obj->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -91,21 +91,23 @@ public:
|
||||
bool isAfterInsertPoint(App::DocumentObject* feature);
|
||||
|
||||
/// Return true if the given feature is member of a MultiTransform feature
|
||||
static bool isMemberOfMultiTransform(const App::DocumentObject* f);
|
||||
static bool isMemberOfMultiTransform(const App::DocumentObject *obj);
|
||||
|
||||
/**
|
||||
* Return true if the given feature is a solid feature allowed in a Body. Currently this is only valid
|
||||
* for features derived from PartDesign::Feature
|
||||
* Return false if the given feature is a Sketch or a Part::Datum feature
|
||||
*/
|
||||
static bool isSolidFeature(const App::DocumentObject* f);
|
||||
static bool isSolidFeature(const App::DocumentObject *obj);
|
||||
|
||||
/**
|
||||
* Return true if the given feature is allowed in a Body. Currently allowed are
|
||||
* all features derived from PartDesign::Feature and Part::Datum and sketches
|
||||
*/
|
||||
static bool isAllowed(const App::DocumentObject* f);
|
||||
virtual bool allowObject(DocumentObject* f) override {return isAllowed(f);}
|
||||
static bool isAllowed(const App::DocumentObject *obj);
|
||||
virtual bool allowObject(DocumentObject *obj) override {
|
||||
return isAllowed(obj);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the body which this feature belongs too, or NULL
|
||||
|
||||
@@ -197,7 +197,7 @@ bool Feature::isDatum(const App::DocumentObject* feature)
|
||||
gp_Pln Feature::makePlnFromPlane(const App::DocumentObject* obj)
|
||||
{
|
||||
const App::GeoFeature* plane = static_cast<const App::GeoFeature*>(obj);
|
||||
if (plane == nullptr)
|
||||
if (!plane)
|
||||
throw Base::ValueError("Feature: Null object");
|
||||
|
||||
Base::Vector3d pos = plane->Placement.getValue().getPosition();
|
||||
|
||||
@@ -155,7 +155,7 @@ App::DocumentObjectExecReturn *Draft::execute(void)
|
||||
// Neutral plane
|
||||
gp_Pln neutralPlane;
|
||||
App::DocumentObject* refPlane = NeutralPlane.getValue();
|
||||
if (refPlane == nullptr) {
|
||||
if (!refPlane) {
|
||||
// Try to guess a neutral plane from the first selected face
|
||||
// Get edges of first selected face
|
||||
TopoDS_Shape face = TopShape.getSubShape(SubVals[0].c_str());
|
||||
@@ -255,7 +255,7 @@ App::DocumentObjectExecReturn *Draft::execute(void)
|
||||
neutralPlane.Transform(invObjLoc.Transformation());
|
||||
}
|
||||
|
||||
if (refDirection == nullptr) {
|
||||
if (!refDirection) {
|
||||
// Choose pull direction normal to neutral plane
|
||||
pullDirection = neutralPlane.Axis().Direction();
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ const std::list<gp_Trsf> LinearPattern::getTransformations(const std::vector<App
|
||||
bool reversed = Reversed.getValue();
|
||||
|
||||
App::DocumentObject* refObject = Direction.getValue();
|
||||
if (refObject == nullptr)
|
||||
if (!refObject)
|
||||
throw Base::ValueError("No direction reference specified");
|
||||
|
||||
std::vector<std::string> subStrings = Direction.getSubValues();
|
||||
|
||||
@@ -60,7 +60,7 @@ short Mirrored::mustExecute() const
|
||||
const std::list<gp_Trsf> Mirrored::getTransformations(const std::vector<App::DocumentObject*>)
|
||||
{
|
||||
App::DocumentObject* refObject = MirrorPlane.getValue();
|
||||
if (refObject == nullptr)
|
||||
if (!refObject)
|
||||
throw Base::ValueError("No mirror plane reference specified");
|
||||
std::vector<std::string> subStrings = MirrorPlane.getSubValues();
|
||||
if (subStrings.empty())
|
||||
|
||||
@@ -73,7 +73,7 @@ App::DocumentObjectExecReturn *Pocket::execute()
|
||||
// Handle legacy features, these typically have Type set to 3 (previously NULL, now UpToFace),
|
||||
// empty FaceName (because it didn't exist) and a value for Length
|
||||
if (std::string(Type.getValueAsString()) == "UpToFace" &&
|
||||
(UpToFace.getValue() == nullptr && Length.getValue() > Precision::Confusion()))
|
||||
(!UpToFace.getValue() && Length.getValue() > Precision::Confusion()))
|
||||
Type.setValue("Length");
|
||||
|
||||
// Validate parameters
|
||||
|
||||
@@ -98,7 +98,7 @@ const std::list<gp_Trsf> PolarPattern::getTransformations(const std::vector<App:
|
||||
offset = radians / (occurrences - 1);
|
||||
|
||||
App::DocumentObject* refObject = Axis.getValue();
|
||||
if (refObject == nullptr)
|
||||
if (!refObject)
|
||||
throw Base::ValueError("No axis reference specified");
|
||||
std::vector<std::string> subStrings = Axis.getSubValues();
|
||||
if (subStrings.empty())
|
||||
|
||||
@@ -422,7 +422,7 @@ void ProfileBased::getFaceFromLinkSub(TopoDS_Face& upToFace, const App::Property
|
||||
App::DocumentObject* ref = refFace.getValue();
|
||||
std::vector<std::string> subStrings = refFace.getSubValues();
|
||||
|
||||
if (ref == nullptr)
|
||||
if (!ref)
|
||||
throw Base::ValueError("SketchBased: No face selected");
|
||||
|
||||
if (ref->getTypeId().isDerivedFrom(App::Plane::getClassTypeId())) {
|
||||
|
||||
Reference in New Issue
Block a user