PartDesign: modernize type checking
This commit is contained in:
@@ -189,7 +189,7 @@ bool Body::isMemberOfMultiTransform(const App::DocumentObject* obj)
|
||||
// to auto set it when the originals are not null. See:
|
||||
// App::DocumentObjectExecReturn *Transformed::execute(void)
|
||||
//
|
||||
return (obj->getTypeId().isDerivedFrom(PartDesign::Transformed::getClassTypeId()) &&
|
||||
return (obj->isDerivedFrom<PartDesign::Transformed>() &&
|
||||
static_cast<const PartDesign::Transformed*>(obj)->Originals.getValues().empty());
|
||||
}
|
||||
|
||||
@@ -198,7 +198,7 @@ bool Body::isSolidFeature(const App::DocumentObject *obj)
|
||||
if (!obj)
|
||||
return false;
|
||||
|
||||
if (obj->getTypeId().isDerivedFrom(PartDesign::Feature::getClassTypeId()) &&
|
||||
if (obj->isDerivedFrom<PartDesign::Feature>() &&
|
||||
!PartDesign::Feature::isDatum(obj)) {
|
||||
// Transformed Features inside a MultiTransform are not solid features
|
||||
return !isMemberOfMultiTransform(obj);
|
||||
@@ -212,15 +212,15 @@ bool Body::isAllowed(const App::DocumentObject *obj)
|
||||
return false;
|
||||
|
||||
// TODO: Should we introduce a PartDesign::FeaturePython class? This should then also return true for isSolidFeature()
|
||||
return (obj->getTypeId().isDerivedFrom(PartDesign::Feature::getClassTypeId()) ||
|
||||
obj->getTypeId().isDerivedFrom(Part::Datum::getClassTypeId()) ||
|
||||
return (obj->isDerivedFrom<PartDesign::Feature>() ||
|
||||
obj->isDerivedFrom<Part::Datum>() ||
|
||||
// TODO Shouldn't we replace it with Sketcher::SketchObject? (2015-08-13, Fat-Zer)
|
||||
obj->getTypeId().isDerivedFrom(Part::Part2DObject::getClassTypeId()) ||
|
||||
obj->getTypeId().isDerivedFrom(PartDesign::ShapeBinder::getClassTypeId()) ||
|
||||
obj->getTypeId().isDerivedFrom(PartDesign::SubShapeBinder::getClassTypeId())
|
||||
obj->isDerivedFrom<Part::Part2DObject>() ||
|
||||
obj->isDerivedFrom<PartDesign::ShapeBinder>() ||
|
||||
obj->isDerivedFrom<PartDesign::SubShapeBinder>()
|
||||
// TODO Why this lines was here? why should we allow anything of those? (2015-08-13, Fat-Zer)
|
||||
//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())
|
||||
//obj->isDerivedFrom<Part::FeaturePython>() // trouble with this line on Windows!? Linker fails to find getClassTypeId() of the Part::FeaturePython...
|
||||
//obj->isDerivedFrom<Part::Feature>()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -116,7 +116,7 @@ Part::Feature* Feature::getBaseObject(bool silent) const {
|
||||
const char *err = nullptr;
|
||||
|
||||
if (BaseLink) {
|
||||
if (BaseLink->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) {
|
||||
if (BaseLink->isDerivedFrom<Part::Feature>()) {
|
||||
BaseObject = static_cast<Part::Feature*>(BaseLink);
|
||||
}
|
||||
if (!BaseObject) {
|
||||
@@ -191,8 +191,8 @@ PyObject* Feature::getPyObject()
|
||||
|
||||
bool Feature::isDatum(const App::DocumentObject* feature)
|
||||
{
|
||||
return feature->getTypeId().isDerivedFrom(App::OriginFeature::getClassTypeId()) ||
|
||||
feature->getTypeId().isDerivedFrom(Part::Datum::getClassTypeId());
|
||||
return feature->isDerivedFrom<App::OriginFeature>() ||
|
||||
feature->isDerivedFrom<Part::Datum>();
|
||||
}
|
||||
|
||||
gp_Pln Feature::makePlnFromPlane(const App::DocumentObject* obj)
|
||||
|
||||
@@ -125,11 +125,11 @@ App::DocumentObjectExecReturn *Draft::execute()
|
||||
gp_Dir pullDirection;
|
||||
App::DocumentObject* refDirection = PullDirection.getValue();
|
||||
if (refDirection) {
|
||||
if (refDirection->getTypeId().isDerivedFrom(PartDesign::Line::getClassTypeId())) {
|
||||
if (refDirection->isDerivedFrom<PartDesign::Line>()) {
|
||||
PartDesign::Line* line = static_cast<PartDesign::Line*>(refDirection);
|
||||
Base::Vector3d d = line->getDirection();
|
||||
pullDirection = gp_Dir(d.x, d.y, d.z);
|
||||
} else if (refDirection->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) {
|
||||
} else if (refDirection->isDerivedFrom<Part::Feature>()) {
|
||||
std::vector<std::string> subStrings = PullDirection.getSubValues();
|
||||
if (subStrings.empty() || subStrings[0].empty())
|
||||
throw Base::ValueError("No pull direction reference specified");
|
||||
@@ -209,14 +209,14 @@ App::DocumentObjectExecReturn *Draft::execute()
|
||||
if (!found)
|
||||
throw Base::RuntimeError("No neutral plane specified and none can be guessed");
|
||||
} else {
|
||||
if (refPlane->getTypeId().isDerivedFrom(PartDesign::Plane::getClassTypeId())) {
|
||||
if (refPlane->isDerivedFrom<PartDesign::Plane>()) {
|
||||
PartDesign::Plane* plane = static_cast<PartDesign::Plane*>(refPlane);
|
||||
Base::Vector3d b = plane->getBasePoint();
|
||||
Base::Vector3d n = plane->getNormal();
|
||||
neutralPlane = gp_Pln(gp_Pnt(b.x, b.y, b.z), gp_Dir(n.x, n.y, n.z));
|
||||
} else if (refPlane->getTypeId().isDerivedFrom(App::Plane::getClassTypeId())) {
|
||||
} else if (refPlane->isDerivedFrom<App::Plane>()) {
|
||||
neutralPlane = Feature::makePlnFromPlane(refPlane);
|
||||
} else if (refPlane->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) {
|
||||
} else if (refPlane->isDerivedFrom<Part::Feature>()) {
|
||||
std::vector<std::string> subStrings = NeutralPlane.getSubValues();
|
||||
if (subStrings.empty() || subStrings[0].empty())
|
||||
throw Base::ValueError("No neutral plane reference specified");
|
||||
|
||||
@@ -66,7 +66,7 @@ short DressUp::mustExecute() const
|
||||
void DressUp::positionByBaseFeature()
|
||||
{
|
||||
Part::Feature *base = static_cast<Part::Feature*>(BaseFeature.getValue());
|
||||
if (base && base->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId()))
|
||||
if (base && base->isDerivedFrom<Part::Feature>())
|
||||
this->Placement.setValue(base->Placement.getValue());
|
||||
}
|
||||
|
||||
|
||||
@@ -110,7 +110,7 @@ const std::list<gp_Trsf> LinearPattern::getTransformations(const std::vector<App
|
||||
throw Base::ValueError("No direction reference specified");
|
||||
|
||||
gp_Dir dir;
|
||||
if (refObject->getTypeId().isDerivedFrom(Part::Part2DObject::getClassTypeId())) {
|
||||
if (refObject->isDerivedFrom<Part::Part2DObject>()) {
|
||||
Part::Part2DObject* refSketch = static_cast<Part::Part2DObject*>(refObject);
|
||||
Base::Axis axis;
|
||||
if (subStrings[0] == "H_Axis") {
|
||||
@@ -151,21 +151,21 @@ const std::list<gp_Trsf> LinearPattern::getTransformations(const std::vector<App
|
||||
axis.setDirection(Base::Vector3d(d.X(), d.Y(), d.Z()));
|
||||
}
|
||||
dir = gp_Dir(axis.getDirection().x, axis.getDirection().y, axis.getDirection().z);
|
||||
} else if (refObject->getTypeId().isDerivedFrom(PartDesign::Plane::getClassTypeId())) {
|
||||
} else if (refObject->isDerivedFrom<PartDesign::Plane>()) {
|
||||
PartDesign::Plane* plane = static_cast<PartDesign::Plane*>(refObject);
|
||||
Base::Vector3d d = plane->getNormal();
|
||||
dir = gp_Dir(d.x, d.y, d.z);
|
||||
} else if (refObject->getTypeId().isDerivedFrom(PartDesign::Line::getClassTypeId())) {
|
||||
} else if (refObject->isDerivedFrom<PartDesign::Line>()) {
|
||||
PartDesign::Line* line = static_cast<PartDesign::Line*>(refObject);
|
||||
Base::Vector3d d = line->getDirection();
|
||||
dir = gp_Dir(d.x, d.y, d.z);
|
||||
} else if (refObject->getTypeId().isDerivedFrom(App::Line::getClassTypeId())) {
|
||||
} else if (refObject->isDerivedFrom<App::Line>()) {
|
||||
App::Line* line = static_cast<App::Line*>(refObject);
|
||||
Base::Rotation rot = line->Placement.getValue().getRotation();
|
||||
Base::Vector3d d(1,0,0);
|
||||
rot.multVec(d, d);
|
||||
dir = gp_Dir(d.x, d.y, d.z);
|
||||
} else if (refObject->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) {
|
||||
} else if (refObject->isDerivedFrom<Part::Feature>()) {
|
||||
if (subStrings[0].empty())
|
||||
throw Base::ValueError("No direction reference specified");
|
||||
Part::Feature* refFeature = static_cast<Part::Feature*>(refObject);
|
||||
|
||||
@@ -68,7 +68,7 @@ const std::list<gp_Trsf> Mirrored::getTransformations(const std::vector<App::Doc
|
||||
|
||||
gp_Pnt axbase;
|
||||
gp_Dir axdir;
|
||||
if (refObject->getTypeId().isDerivedFrom(Part::Part2DObject::getClassTypeId())) {
|
||||
if (refObject->isDerivedFrom<Part::Part2DObject>()) {
|
||||
Part::Part2DObject* refSketch = static_cast<Part::Part2DObject*>(refObject);
|
||||
Base::Axis axis;
|
||||
if (subStrings[0] == "H_Axis")
|
||||
@@ -88,13 +88,13 @@ const std::list<gp_Trsf> Mirrored::getTransformations(const std::vector<App::Doc
|
||||
axis *= refSketch->Placement.getValue();
|
||||
axbase = gp_Pnt(axis.getBase().x, axis.getBase().y, axis.getBase().z);
|
||||
axdir = gp_Dir(axis.getDirection().x, axis.getDirection().y, axis.getDirection().z);
|
||||
} else if (refObject->getTypeId().isDerivedFrom(PartDesign::Plane::getClassTypeId())) {
|
||||
} else if (refObject->isDerivedFrom<PartDesign::Plane>()) {
|
||||
PartDesign::Plane* plane = static_cast<PartDesign::Plane*>(refObject);
|
||||
Base::Vector3d base = plane->getBasePoint();
|
||||
axbase = gp_Pnt(base.x, base.y, base.z);
|
||||
Base::Vector3d dir = plane->getNormal();
|
||||
axdir = gp_Dir(dir.x, dir.y, dir.z);
|
||||
} else if (refObject->getTypeId().isDerivedFrom(App::Plane::getClassTypeId())) {
|
||||
} else if (refObject->isDerivedFrom<App::Plane>()) {
|
||||
App::Plane* plane = static_cast<App::Plane*>(refObject);
|
||||
Base::Vector3d base = plane->Placement.getValue().getPosition();
|
||||
axbase = gp_Pnt(base.x, base.y, base.z);
|
||||
@@ -102,7 +102,7 @@ const std::list<gp_Trsf> Mirrored::getTransformations(const std::vector<App::Doc
|
||||
Base::Vector3d dir(0,0,1);
|
||||
rot.multVec(dir, dir);
|
||||
axdir = gp_Dir(dir.x, dir.y, dir.z);
|
||||
} else if (refObject->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) {
|
||||
} else if (refObject->isDerivedFrom<Part::Feature>()) {
|
||||
if (subStrings[0].empty())
|
||||
throw Base::ValueError("No direction reference specified");
|
||||
Part::TopoShape baseShape = static_cast<Part::Feature*>(refObject)->Shape.getShape();
|
||||
|
||||
@@ -51,7 +51,7 @@ void MultiTransform::positionBySupport()
|
||||
PartDesign::Transformed::positionBySupport();
|
||||
std::vector<App::DocumentObject*> transFeatures = Transformations.getValues();
|
||||
for (auto f : transFeatures) {
|
||||
if (!(f->getTypeId().isDerivedFrom(PartDesign::Transformed::getClassTypeId())))
|
||||
if (!(f->isDerivedFrom<PartDesign::Transformed>()))
|
||||
throw Base::TypeError("Transformation features must be subclasses of Transformed");
|
||||
PartDesign::Transformed* transFeature = static_cast<PartDesign::Transformed*>(f);
|
||||
transFeature->Placement.setValue(this->Placement.getValue());
|
||||
@@ -80,7 +80,7 @@ const std::list<gp_Trsf> MultiTransform::getTransformations(const std::vector<Ap
|
||||
Part::Feature* originalFeature = static_cast<Part::Feature*>(originals.front());
|
||||
TopoDS_Shape original;
|
||||
|
||||
if (originalFeature->getTypeId().isDerivedFrom(PartDesign::FeatureAddSub::getClassTypeId())) {
|
||||
if (originalFeature->isDerivedFrom<PartDesign::FeatureAddSub>()) {
|
||||
PartDesign::FeatureAddSub* addFeature = static_cast<PartDesign::FeatureAddSub*>(originalFeature);
|
||||
//if (addFeature->getAddSubType() == FeatureAddSub::Additive)
|
||||
// original = addFeature->AddSubShape.getShape().getShape();
|
||||
@@ -97,7 +97,7 @@ const std::list<gp_Trsf> MultiTransform::getTransformations(const std::vector<Ap
|
||||
std::vector<App::DocumentObject*>::const_iterator f;
|
||||
|
||||
for (f = transFeatures.begin(); f != transFeatures.end(); ++f) {
|
||||
if (!((*f)->getTypeId().isDerivedFrom(PartDesign::Transformed::getClassTypeId())))
|
||||
if (!((*f)->isDerivedFrom<PartDesign::Transformed>()))
|
||||
throw Base::TypeError("Transformation features must be subclasses of Transformed");
|
||||
PartDesign::Transformed* transFeature = static_cast<PartDesign::Transformed*>(*f);
|
||||
std::list<gp_Trsf> newTransformations = transFeature->getTransformations(originals);
|
||||
@@ -116,7 +116,7 @@ const std::list<gp_Trsf> MultiTransform::getTransformations(const std::vector<Ap
|
||||
std::list<gp_Pnt> oldCogs;
|
||||
cogs.swap(oldCogs); // empty cogs to receive new cogs
|
||||
|
||||
if ((*f)->getTypeId() == PartDesign::Scaled::getClassTypeId()) {
|
||||
if ((*f)->is<PartDesign::Scaled>()) {
|
||||
// Diagonal method
|
||||
// Multiply every element in the old transformations' slices with the corresponding
|
||||
// element in the newTransformations. Example:
|
||||
|
||||
@@ -173,7 +173,7 @@ App::DocumentObjectExecReturn *Pipe::execute()
|
||||
|
||||
// build the paths
|
||||
App::DocumentObject* spine = Spine.getValue();
|
||||
if (!(spine && spine->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())))
|
||||
if (!(spine && spine->isDerivedFrom<Part::Feature>()))
|
||||
return new App::DocumentObjectExecReturn(QT_TRANSLATE_NOOP("Exception", "No spine linked"));
|
||||
|
||||
std::vector<std::string> subedge = Spine.getSubValues();
|
||||
@@ -186,7 +186,7 @@ App::DocumentObjectExecReturn *Pipe::execute()
|
||||
TopoDS_Shape auxpath;
|
||||
if (Mode.getValue() == 3) {
|
||||
App::DocumentObject* auxspine = AuxillerySpine.getValue();
|
||||
if (!(auxspine && auxspine->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())))
|
||||
if (!(auxspine && auxspine->isDerivedFrom<Part::Feature>()))
|
||||
return new App::DocumentObjectExecReturn(QT_TRANSLATE_NOOP("Exception", "No auxiliary spine linked."));
|
||||
std::vector<std::string> auxsubedge = AuxillerySpine.getSubValues();
|
||||
|
||||
|
||||
@@ -104,7 +104,7 @@ const std::list<gp_Trsf> PolarPattern::getTransformations(const std::vector<App:
|
||||
|
||||
gp_Pnt axbase;
|
||||
gp_Dir axdir;
|
||||
if (refObject->getTypeId().isDerivedFrom(Part::Part2DObject::getClassTypeId())) {
|
||||
if (refObject->isDerivedFrom<Part::Part2DObject>()) {
|
||||
Part::Part2DObject* refSketch = static_cast<Part::Part2DObject*>(refObject);
|
||||
Base::Axis axis;
|
||||
if (subStrings[0] == "H_Axis")
|
||||
@@ -121,19 +121,19 @@ const std::list<gp_Trsf> PolarPattern::getTransformations(const std::vector<App:
|
||||
axis *= refSketch->Placement.getValue();
|
||||
axbase = gp_Pnt(axis.getBase().x, axis.getBase().y, axis.getBase().z);
|
||||
axdir = gp_Dir(axis.getDirection().x, axis.getDirection().y, axis.getDirection().z);
|
||||
} else if (refObject->getTypeId().isDerivedFrom(PartDesign::Line::getClassTypeId())) {
|
||||
} else if (refObject->isDerivedFrom<PartDesign::Line>()) {
|
||||
PartDesign::Line* line = static_cast<PartDesign::Line*>(refObject);
|
||||
Base::Vector3d base = line->getBasePoint();
|
||||
axbase = gp_Pnt(base.x, base.y, base.z);
|
||||
Base::Vector3d dir = line->getDirection();
|
||||
axdir = gp_Dir(dir.x, dir.y, dir.z);
|
||||
} else if (refObject->getTypeId().isDerivedFrom(App::Line::getClassTypeId())) {
|
||||
} else if (refObject->isDerivedFrom<App::Line>()) {
|
||||
App::Line* line = static_cast<App::Line*>(refObject);
|
||||
Base::Rotation rot = line->Placement.getValue().getRotation();
|
||||
Base::Vector3d d(1,0,0);
|
||||
rot.multVec(d, d);
|
||||
axdir = gp_Dir(d.x, d.y, d.z);
|
||||
} else if (refObject->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) {
|
||||
} else if (refObject->isDerivedFrom<Part::Feature>()) {
|
||||
if (subStrings[0].empty())
|
||||
throw Base::ValueError("No axis reference specified");
|
||||
Part::Feature* refFeature = static_cast<Part::Feature*>(refObject);
|
||||
|
||||
@@ -69,7 +69,7 @@ const std::list<gp_Trsf> Scaled::getTransformations(const std::vector<App::Docum
|
||||
Part::Feature* originalFeature = static_cast<Part::Feature*>(originals.front());
|
||||
TopoDS_Shape original;
|
||||
|
||||
if (originalFeature->getTypeId().isDerivedFrom(PartDesign::FeatureAddSub::getClassTypeId())) {
|
||||
if (originalFeature->isDerivedFrom<PartDesign::FeatureAddSub>()) {
|
||||
PartDesign::FeatureAddSub* Feature = static_cast<PartDesign::FeatureAddSub*>(originalFeature);
|
||||
//if(Feature->getAddSubType() == FeatureAddSub::Additive)
|
||||
// original = Feature->AddSubShape.getShape().getShape();
|
||||
|
||||
@@ -130,7 +130,7 @@ Part::Part2DObject* ProfileBased::getVerifiedSketch(bool silent) const {
|
||||
err = "No profile linked at all";
|
||||
}
|
||||
else {
|
||||
if (!result->getTypeId().isDerivedFrom(Part::Part2DObject::getClassTypeId())) {
|
||||
if (!result->isDerivedFrom<Part::Part2DObject>()) {
|
||||
err = "Linked object is not a Sketch or Part2DObject";
|
||||
result = nullptr;
|
||||
}
|
||||
@@ -152,7 +152,7 @@ Part::Feature* ProfileBased::getVerifiedObject(bool silent) const {
|
||||
err = "No object linked";
|
||||
}
|
||||
else {
|
||||
if (!result->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId()))
|
||||
if (!result->isDerivedFrom<Part::Feature>())
|
||||
err = "Linked object is not a Sketch, Part2DObject or Feature";
|
||||
}
|
||||
|
||||
@@ -213,12 +213,12 @@ TopoDS_Shape ProfileBased::getVerifiedFace(bool silent) const {
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (result->getTypeId().isDerivedFrom(Part::Part2DObject::getClassTypeId())) {
|
||||
if (result->isDerivedFrom<Part::Part2DObject>()) {
|
||||
|
||||
auto wires = getProfileWires();
|
||||
return Part::FaceMakerCheese::makeFace(wires);
|
||||
}
|
||||
else if (result->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) {
|
||||
else if (result->isDerivedFrom<Part::Feature>()) {
|
||||
if (Profile.getSubValues().empty())
|
||||
err = "Linked object has no subshape specified";
|
||||
else {
|
||||
@@ -424,17 +424,17 @@ void ProfileBased::getFaceFromLinkSub(TopoDS_Face& upToFace, const App::Property
|
||||
if (!ref)
|
||||
throw Base::ValueError("SketchBased: No face selected");
|
||||
|
||||
if (ref->getTypeId().isDerivedFrom(App::Plane::getClassTypeId())) {
|
||||
if (ref->isDerivedFrom<App::Plane>()) {
|
||||
upToFace = TopoDS::Face(makeShapeFromPlane(ref));
|
||||
return;
|
||||
}
|
||||
else if (ref->getTypeId().isDerivedFrom(PartDesign::Plane::getClassTypeId())) {
|
||||
else if (ref->isDerivedFrom<PartDesign::Plane>()) {
|
||||
Part::Datum* datum = static_cast<Part::Datum*>(ref);
|
||||
upToFace = TopoDS::Face(datum->getShape());
|
||||
return;
|
||||
}
|
||||
|
||||
if (!ref->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId()))
|
||||
if (!ref->isDerivedFrom<Part::Feature>())
|
||||
throw Base::TypeError("SketchBased: Must be face of a feature");
|
||||
Part::TopoShape baseShape = static_cast<Part::Feature*>(ref)->Shape.getShape();
|
||||
|
||||
@@ -1008,7 +1008,7 @@ void ProfileBased::getAxis(const App::DocumentObject * pcReferenceAxis, const st
|
||||
App::DocumentObject* profile = Profile.getValue();
|
||||
gp_Pln sketchplane;
|
||||
|
||||
if (profile->getTypeId().isDerivedFrom(Part::Part2DObject::getClassTypeId())) {
|
||||
if (profile->isDerivedFrom<Part::Part2DObject>()) {
|
||||
Part::Part2DObject* sketch = getVerifiedSketch();
|
||||
Base::Placement SketchPlm = sketch->Placement.getValue();
|
||||
Base::Vector3d SketchVector = Base::Vector3d(0, 0, 1);
|
||||
@@ -1048,7 +1048,7 @@ void ProfileBased::getAxis(const App::DocumentObject * pcReferenceAxis, const st
|
||||
}
|
||||
|
||||
}
|
||||
else if (profile->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) {
|
||||
else if (profile->isDerivedFrom<Part::Feature>()) {
|
||||
Base::Placement SketchPlm = getVerifiedObject()->Placement.getValue();
|
||||
Base::Vector3d SketchVector = getProfileNormal();
|
||||
Base::Vector3d SketchPos = SketchPlm.getPosition();
|
||||
@@ -1056,7 +1056,7 @@ void ProfileBased::getAxis(const App::DocumentObject * pcReferenceAxis, const st
|
||||
}
|
||||
|
||||
// get reference axis
|
||||
if (pcReferenceAxis->getTypeId().isDerivedFrom(PartDesign::Line::getClassTypeId())) {
|
||||
if (pcReferenceAxis->isDerivedFrom<PartDesign::Line>()) {
|
||||
const PartDesign::Line* line = static_cast<const PartDesign::Line*>(pcReferenceAxis);
|
||||
base = line->getBasePoint();
|
||||
dir = line->getDirection();
|
||||
@@ -1065,7 +1065,7 @@ void ProfileBased::getAxis(const App::DocumentObject * pcReferenceAxis, const st
|
||||
return;
|
||||
}
|
||||
|
||||
if (pcReferenceAxis->getTypeId().isDerivedFrom(App::Line::getClassTypeId())) {
|
||||
if (pcReferenceAxis->isDerivedFrom<App::Line>()) {
|
||||
const App::Line* line = static_cast<const App::Line*>(pcReferenceAxis);
|
||||
base = Base::Vector3d(0, 0, 0);
|
||||
line->Placement.getValue().multVec(Base::Vector3d(1, 0, 0), dir);
|
||||
@@ -1074,7 +1074,7 @@ void ProfileBased::getAxis(const App::DocumentObject * pcReferenceAxis, const st
|
||||
return;
|
||||
}
|
||||
|
||||
if (pcReferenceAxis->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) {
|
||||
if (pcReferenceAxis->isDerivedFrom<Part::Feature>()) {
|
||||
if (subReferenceAxis.empty())
|
||||
throw Base::ValueError("No rotation axis reference specified");
|
||||
const Part::Feature* refFeature = static_cast<const Part::Feature*>(pcReferenceAxis);
|
||||
|
||||
@@ -107,23 +107,23 @@ Part::Feature* Transformed::getBaseObject(bool silent) const {
|
||||
App::DocumentObject* Transformed::getSketchObject() const
|
||||
{
|
||||
std::vector<DocumentObject*> originals = Originals.getValues();
|
||||
if (!originals.empty() && originals.front()->getTypeId().isDerivedFrom(PartDesign::ProfileBased::getClassTypeId())) {
|
||||
if (!originals.empty() && originals.front()->isDerivedFrom<PartDesign::ProfileBased>()) {
|
||||
return (static_cast<PartDesign::ProfileBased*>(originals.front()))->getVerifiedSketch(true);
|
||||
}
|
||||
else if (!originals.empty() && originals.front()->getTypeId().isDerivedFrom(PartDesign::FeatureAddSub::getClassTypeId())) {
|
||||
else if (!originals.empty() && originals.front()->isDerivedFrom<PartDesign::FeatureAddSub>()) {
|
||||
return nullptr;
|
||||
}
|
||||
else if (this->getTypeId().isDerivedFrom(LinearPattern::getClassTypeId())) {
|
||||
else if (this->isDerivedFrom<LinearPattern>()) {
|
||||
// if Originals is empty then try the linear pattern's Direction property
|
||||
const LinearPattern* pattern = static_cast<const LinearPattern*>(this);
|
||||
return pattern->Direction.getValue();
|
||||
}
|
||||
else if (this->getTypeId().isDerivedFrom(PolarPattern::getClassTypeId())) {
|
||||
else if (this->isDerivedFrom<PolarPattern>()) {
|
||||
// if Originals is empty then try the polar pattern's Axis property
|
||||
const PolarPattern* pattern = static_cast<const PolarPattern*>(this);
|
||||
return pattern->Axis.getValue();
|
||||
}
|
||||
else if (this->getTypeId().isDerivedFrom(Mirrored::getClassTypeId())) {
|
||||
else if (this->isDerivedFrom<Mirrored>()) {
|
||||
// if Originals is empty then try the mirror pattern's MirrorPlane property
|
||||
const Mirrored* pattern = static_cast<const Mirrored*>(this);
|
||||
return pattern->MirrorPlane.getValue();
|
||||
@@ -143,7 +143,7 @@ void Transformed::handleChangedPropertyType(Base::XMLReader &reader, const char
|
||||
// The property 'Angle' of PolarPattern has changed from PropertyFloat
|
||||
// to PropertyAngle and the property 'Length' has changed to PropertyLength.
|
||||
Base::Type inputType = Base::Type::fromName(TypeName);
|
||||
if (prop->getTypeId().isDerivedFrom(App::PropertyFloat::getClassTypeId()) &&
|
||||
if (prop->isDerivedFrom<App::PropertyFloat>() &&
|
||||
inputType.isDerivedFrom(App::PropertyFloat::getClassTypeId())) {
|
||||
// Do not directly call the property's Restore method in case the implementation
|
||||
// has changed. So, create a temporary PropertyFloat object and assign the value.
|
||||
@@ -254,7 +254,7 @@ App::DocumentObjectExecReturn *Transformed::execute()
|
||||
Part::TopoShape fuseShape;
|
||||
Part::TopoShape cutShape;
|
||||
|
||||
if (original->getTypeId().isDerivedFrom(PartDesign::FeatureAddSub::getClassTypeId())) {
|
||||
if (original->isDerivedFrom<PartDesign::FeatureAddSub>()) {
|
||||
PartDesign::FeatureAddSub* feature = static_cast<PartDesign::FeatureAddSub*>(original);
|
||||
feature->getAddSubShape(fuseShape, cutShape);
|
||||
if (fuseShape.isNull() && cutShape.isNull())
|
||||
|
||||
@@ -151,7 +151,7 @@ void ShapeBinder::getFilteredReferences(const App::PropertyLinkSubList* prop,
|
||||
//we only allow one part feature, so get the first one we find
|
||||
size_t index = 0;
|
||||
for (auto* it : objs) {
|
||||
if (it && it->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) {
|
||||
if (it && it->isDerivedFrom<Part::Feature>()) {
|
||||
obj = static_cast<Part::Feature*>(it);
|
||||
break;
|
||||
}
|
||||
@@ -182,11 +182,11 @@ void ShapeBinder::getFilteredReferences(const App::PropertyLinkSubList* prop,
|
||||
else {
|
||||
// search for Origin features
|
||||
for (auto* it : objs) {
|
||||
if (it && it->getTypeId().isDerivedFrom(App::Line::getClassTypeId())) {
|
||||
if (it && it->isDerivedFrom<App::Line>()) {
|
||||
obj = static_cast<App::GeoFeature*>(it);
|
||||
break;
|
||||
}
|
||||
else if (it && it->getTypeId().isDerivedFrom(App::Plane::getClassTypeId())) {
|
||||
else if (it && it->isDerivedFrom<App::Plane>()) {
|
||||
obj = static_cast<App::GeoFeature*>(it);
|
||||
break;
|
||||
}
|
||||
@@ -199,7 +199,7 @@ Part::TopoShape ShapeBinder::buildShapeFromReferences(App::GeoFeature* obj, std:
|
||||
if (!obj)
|
||||
return TopoDS_Shape();
|
||||
|
||||
if (obj->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) {
|
||||
if (obj->isDerivedFrom<Part::Feature>()) {
|
||||
Part::Feature* part = static_cast<Part::Feature*>(obj);
|
||||
if (subs.empty())
|
||||
return part->Shape.getValue();
|
||||
@@ -224,14 +224,14 @@ Part::TopoShape ShapeBinder::buildShapeFromReferences(App::GeoFeature* obj, std:
|
||||
return cmp;
|
||||
}
|
||||
}
|
||||
else if (obj->getTypeId().isDerivedFrom(App::Line::getClassTypeId())) {
|
||||
else if (obj->isDerivedFrom<App::Line>()) {
|
||||
gp_Lin line;
|
||||
BRepBuilderAPI_MakeEdge mkEdge(line);
|
||||
Part::TopoShape shape(mkEdge.Shape());
|
||||
shape.setPlacement(obj->Placement.getValue());
|
||||
return shape;
|
||||
}
|
||||
else if (obj->getTypeId().isDerivedFrom(App::Plane::getClassTypeId())) {
|
||||
else if (obj->isDerivedFrom<App::Plane>()) {
|
||||
gp_Pln plane;
|
||||
BRepBuilderAPI_MakeFace mkFace(plane);
|
||||
Part::TopoShape shape(mkFace.Shape());
|
||||
@@ -273,7 +273,7 @@ void ShapeBinder::slotChangedObject(const App::DocumentObject& Obj, const App::P
|
||||
return;
|
||||
if (!TraceSupport.getValue())
|
||||
return;
|
||||
if (!Prop.getTypeId().isDerivedFrom(App::PropertyPlacement::getClassTypeId()))
|
||||
if (!Prop.isDerivedFrom<App::PropertyPlacement>())
|
||||
return;
|
||||
|
||||
App::GeoFeature* obj = nullptr;
|
||||
|
||||
Reference in New Issue
Block a user