Part: Use freecad_cast whenever possible

This commit is contained in:
Kacper Donat
2025-04-25 00:05:48 +02:00
committed by Benjamin Nauck
parent a5071587de
commit 2fb8b2d7f1
3 changed files with 11 additions and 11 deletions

View File

@@ -1934,17 +1934,17 @@ AttachEngine3D::_calculateAttachedPlacement(const std::vector<App::DocumentObjec
switch (shape->shapeType()) {
case TopAbs_VERTEX: {
if (auto point = dynamic_cast<GeomPoint*>(geom.get())) {
if (auto point = freecad_cast<GeomPoint*>(geom.get())) {
placement.setPosition(point->getPoint());
}
}
break;
case TopAbs_EDGE: {
if (auto conic = dynamic_cast<GeomConic*>(geom.get())) {
if (auto conic = freecad_cast<GeomConic*>(geom.get())) {
placement.setPosition(conic->getLocation());
placement.setRotation(conic->getRotation().value_or(Base::Rotation {}));
} else if (auto line = dynamic_cast<GeomCurve*>(geom.get())) {
} else if (auto line = freecad_cast<GeomCurve*>(geom.get())) {
auto u1 = line->getFirstParameter();
auto u2 = line->getLastParameter();
@@ -1963,11 +1963,11 @@ AttachEngine3D::_calculateAttachedPlacement(const std::vector<App::DocumentObjec
break;
case TopAbs_FACE: {
auto surface = dynamic_cast<GeomSurface*>(geom.get());
auto surface = freecad_cast<GeomSurface*>(geom.get());
if (auto sphere = dynamic_cast<GeomSphere*>(geom.get())) {
if (auto sphere = freecad_cast<GeomSphere*>(geom.get())) {
placement.setPosition(sphere->getLocation());
} else if (auto cone = dynamic_cast<GeomCone*>(geom.get())) {
} else if (auto cone = freecad_cast<GeomCone*>(geom.get())) {
placement.setPosition(cone->getApex());
} else if (auto com = shape->centerOfGravity()) {
placement.setPosition(*com);

View File

@@ -1285,7 +1285,7 @@ void GeomBezierCurve::Restore(Base::XMLReader& reader)
PyObject *GeomBezierCurve::getPyObject()
{
return new BezierCurvePy(dynamic_cast<GeomBezierCurve*>(this->clone()));
return new BezierCurvePy(freecad_cast<GeomBezierCurve*>(this->clone()));
}
bool GeomBezierCurve::isSame(const Geometry &_other, double tol, double) const
@@ -2059,7 +2059,7 @@ void GeomBSplineCurve::Restore(Base::XMLReader& reader)
PyObject *GeomBSplineCurve::getPyObject()
{
return new BSplineCurvePy(dynamic_cast<GeomBSplineCurve*>(this->clone()));
return new BSplineCurvePy(freecad_cast<GeomBSplineCurve*>(this->clone()));
}
bool GeomBSplineCurve::isSame(const Geometry &_other, double tol, double atol) const
@@ -4698,7 +4698,7 @@ void GeomLineSegment::Restore (Base::XMLReader &reader)
PyObject *GeomLineSegment::getPyObject()
{
return new LineSegmentPy(dynamic_cast<GeomLineSegment*>(this->clone()));
return new LineSegmentPy(freecad_cast<GeomLineSegment*>(this->clone()));
}
// -------------------------------------------------
@@ -4769,7 +4769,7 @@ void GeomOffsetCurve::Restore(Base::XMLReader &/*reader*/)
PyObject *GeomOffsetCurve::getPyObject()
{
return new OffsetCurvePy(dynamic_cast<GeomOffsetCurve*>(this->clone()));
return new OffsetCurvePy(freecad_cast<GeomOffsetCurve*>(this->clone()));
}
bool GeomOffsetCurve::isSame(const Geometry &_other, double tol, double atol) const

View File

@@ -146,7 +146,7 @@ PyObject *PropertyGeometryList::getPyObject()
void PropertyGeometryList::setPyObject(PyObject *value)
{
// check container of this property to notify about changes
Part2DObject* part2d = dynamic_cast<Part2DObject*>(this->getContainer());
Part2DObject* part2d = freecad_cast<Part2DObject*>(this->getContainer());
if (PySequence_Check(value)) {
Py::Sequence sequence(value);