Use is<T>() when possible

This commit is contained in:
Benjamin Nauck
2025-01-15 22:31:36 +01:00
parent 02aa90f6c7
commit 6a3eb2ab49
10 changed files with 46 additions and 39 deletions

View File

@@ -46,15 +46,16 @@ std::string PythonConverter::convert(const Part::Geometry* geo, Mode mode)
command = boost::str(boost::format("addGeometry(%s,%s)\n") % sg.creation
% (sg.construction ? "True" : "False"));
if ((geo->getTypeId() != Part::GeomEllipse::getClassTypeId()
|| geo->getTypeId() != Part::GeomArcOfEllipse::getClassTypeId()
|| geo->getTypeId() != Part::GeomArcOfHyperbola::getClassTypeId()
|| geo->getTypeId() != Part::GeomArcOfParabola::getClassTypeId()
|| geo->getTypeId() != Part::GeomBSplineCurve::getClassTypeId())
&& mode == Mode::CreateInternalGeometry) {
// clang-format off: keep line breaks for readability
if ((!geo->is<Part::GeomEllipse>()
|| !geo->is<Part::GeomArcOfEllipse>()
|| !geo->is<Part::GeomArcOfHyperbola>()
|| !geo->is<Part::GeomArcOfParabola>()
|| !geo->is<Part::GeomBSplineCurve>()) && mode == Mode::CreateInternalGeometry) {
command +=
boost::str(boost::format("exposeInternalGeometry(len(ActiveSketch.Geometry))\n"));
}
// clang-format on
return command;
}
@@ -149,15 +150,17 @@ std::string PythonConverter::convert(const std::string& doc,
if (mode == Mode::CreateInternalGeometry) {
for (auto geo : geos) {
index++;
if (geo->getTypeId() != Part::GeomEllipse::getClassTypeId()
|| geo->getTypeId() != Part::GeomArcOfEllipse::getClassTypeId()
|| geo->getTypeId() != Part::GeomArcOfHyperbola::getClassTypeId()
|| geo->getTypeId() != Part::GeomArcOfParabola::getClassTypeId()
|| geo->getTypeId() != Part::GeomBSplineCurve::getClassTypeId()) {
// clang-format off: keep line breaks for readability
if (!geo->is<Part::GeomEllipse>()
|| !geo->is<Part::GeomArcOfEllipse>()
|| !geo->is<Part::GeomArcOfHyperbola>()
|| !geo->is<Part::GeomArcOfParabola>()
|| !geo->is<Part::GeomBSplineCurve>()) {
std::string newcommand =
boost::str(boost::format("exposeInternalGeometry(lastGeoId + %d)\n") % (index));
command += newcommand;
}
// clang-format on
}
}