Part: modernize type checking
This commit is contained in:
@@ -805,7 +805,7 @@ private:
|
||||
PyObject* item = (*it).ptr();
|
||||
if (PyObject_TypeCheck(item, &(App::DocumentObjectPy::Type))) {
|
||||
App::DocumentObject* obj = static_cast<App::DocumentObjectPy*>(item)->getDocumentObjectPtr();
|
||||
if (obj->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) {
|
||||
if (obj->isDerivedFrom<Part::Feature>()) {
|
||||
Part::Feature* part = static_cast<Part::Feature*>(obj);
|
||||
const TopoDS_Shape& shape = part->Shape.getValue();
|
||||
if (!shape.IsNull())
|
||||
|
||||
@@ -765,7 +765,7 @@ void AttachEngine::readLinks(const App::PropertyLinkSubList &references,
|
||||
shapes.resize(objs.size());
|
||||
types.resize(objs.size());
|
||||
for (std::size_t i = 0; i < objs.size(); i++) {
|
||||
if (!objs[i]->getTypeId().isDerivedFrom(App::GeoFeature::getClassTypeId())) {
|
||||
if (!objs[i]->isDerivedFrom<App::GeoFeature>()) {
|
||||
throw AttachEngineException("AttachEngine3D: link points to something that is not App::GeoFeature");
|
||||
}
|
||||
App::GeoFeature* geof = static_cast<App::GeoFeature*>(objs[i]);
|
||||
|
||||
@@ -82,7 +82,7 @@ int CurveConstraintPy::PyInit(PyObject* args, PyObject* kwds)
|
||||
|
||||
#if OCC_VERSION_HEX >= 0x070600
|
||||
Handle(Adaptor3d_Curve) hCurve;
|
||||
if (curve->getTypeId().isDerivedFrom(GeomTrimmedCurve::getClassTypeId())) {
|
||||
if (curve->isDerivedFrom<GeomTrimmedCurve>()) {
|
||||
GeomTrimmedCurve* trim = static_cast<GeomTrimmedCurve*>(curve);
|
||||
hCurve = new GeomAdaptor_Curve(handle, trim->getFirstParameter(), trim->getLastParameter());
|
||||
}
|
||||
@@ -91,7 +91,7 @@ int CurveConstraintPy::PyInit(PyObject* args, PyObject* kwds)
|
||||
}
|
||||
#else
|
||||
Handle(Adaptor3d_HCurve) hCurve;
|
||||
if (curve->getTypeId().isDerivedFrom(GeomTrimmedCurve::getClassTypeId())) {
|
||||
if (curve->isDerivedFrom<GeomTrimmedCurve>()) {
|
||||
GeomTrimmedCurve* trim = static_cast<GeomTrimmedCurve*>(curve);
|
||||
GeomAdaptor_Curve adapt(handle, trim->getFirstParameter(), trim->getLastParameter());
|
||||
hCurve = new GeomAdaptor_HCurve(adapt);
|
||||
|
||||
@@ -157,7 +157,7 @@ bool Part2DObject::seekTrimPoints(const std::vector<Geometry *> &geomlist,
|
||||
// this is just a work-around until that bug is fixed.
|
||||
// https://www.freecad.org/tracker/view.php?id=2463
|
||||
// https://tracker.dev.opencascade.org/view.php?id=30217
|
||||
if (geomlist[id]->getTypeId().isDerivedFrom(Part::GeomBoundedCurve::getClassTypeId())) {
|
||||
if (geomlist[id]->isDerivedFrom<Part::GeomBoundedCurve>()) {
|
||||
|
||||
Part::GeomBoundedCurve * bcurve = static_cast<Part::GeomBoundedCurve *>(geomlist[id]);
|
||||
|
||||
|
||||
@@ -128,7 +128,7 @@ void Primitive::handleChangedPropertyType(Base::XMLReader &reader, const char *
|
||||
// types don't match if both inherit from PropertyFloat because all derived
|
||||
// classes do not re-implement the Save/Restore methods.
|
||||
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.
|
||||
|
||||
@@ -3771,7 +3771,7 @@ void TopoShape::getLinesFromSubElement(const Data::Segment* element,
|
||||
std::vector<Base::Vector3d> &vertices,
|
||||
std::vector<Line> &lines) const
|
||||
{
|
||||
if (element->getTypeId() == ShapeSegment::getClassTypeId()) {
|
||||
if (element->is<ShapeSegment>()) {
|
||||
const TopoDS_Shape& shape = static_cast<const ShapeSegment*>(element)->Shape;
|
||||
if (shape.IsNull())
|
||||
return;
|
||||
@@ -3785,7 +3785,7 @@ void TopoShape::getFacesFromSubElement(const Data::Segment* element,
|
||||
std::vector<Base::Vector3d> &pointNormals,
|
||||
std::vector<Facet> &faces) const
|
||||
{
|
||||
if (element->getTypeId() == ShapeSegment::getClassTypeId()) {
|
||||
if (element->is<ShapeSegment>()) {
|
||||
const TopoDS_Shape& shape = static_cast<const ShapeSegment*>(element)->Shape;
|
||||
if (shape.IsNull() || shape.ShapeType() != TopAbs_FACE)
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user