From bb3eb31d4e33d47a90e642a2658378ccbb08344c Mon Sep 17 00:00:00 2001 From: Florian Foinant-Willig Date: Sun, 15 Oct 2023 21:39:10 +0200 Subject: [PATCH] Surface: modernize type checking --- src/Mod/Surface/App/FeatureCut.cpp | 4 ++-- src/Mod/Surface/App/FeatureExtend.cpp | 2 +- src/Mod/Surface/App/FeatureFilling.cpp | 8 ++++---- src/Mod/Surface/App/FeatureGeomFillSurface.cpp | 2 +- src/Mod/Surface/App/FeatureSections.cpp | 2 +- src/Mod/Surface/App/FeatureSewing.cpp | 2 +- src/Mod/Surface/Gui/Command.cpp | 2 +- src/Mod/Surface/Gui/TaskFilling.cpp | 2 +- src/Mod/Surface/Gui/TaskFillingEdge.cpp | 2 +- 9 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/Mod/Surface/App/FeatureCut.cpp b/src/Mod/Surface/App/FeatureCut.cpp index c2de5a202c..e39a0cadce 100644 --- a/src/Mod/Surface/App/FeatureCut.cpp +++ b/src/Mod/Surface/App/FeatureCut.cpp @@ -63,7 +63,7 @@ App::DocumentObjectExecReturn* Cut::execute() Part::TopoShape ts2; // Get first toposhape - if (shapes[0]->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) { + if (shapes[0]->isDerivedFrom()) { ts1 = static_cast(shapes[0])->Shape.getShape(); // Part::TopoShape 1 } else { @@ -71,7 +71,7 @@ App::DocumentObjectExecReturn* Cut::execute() } // Get second toposhape - if (shapes[1]->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) { + if (shapes[1]->isDerivedFrom()) { ts2 = static_cast(shapes[1])->Shape.getShape(); } else { diff --git a/src/Mod/Surface/App/FeatureExtend.cpp b/src/Mod/Surface/App/FeatureExtend.cpp index a887d36733..83701ba824 100644 --- a/src/Mod/Surface/App/FeatureExtend.cpp +++ b/src/Mod/Surface/App/FeatureExtend.cpp @@ -95,7 +95,7 @@ short Extend::mustExecute() const App::DocumentObjectExecReturn* Extend::execute() { App::DocumentObject* part = Face.getValue(); - if (!part || !part->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) { + if (!part || !part->isDerivedFrom()) { return new App::DocumentObjectExecReturn("No shape linked."); } const auto& faces = Face.getSubValues(); diff --git a/src/Mod/Surface/App/FeatureFilling.cpp b/src/Mod/Surface/App/FeatureFilling.cpp index e5791c761f..68a1a68887 100644 --- a/src/Mod/Surface/App/FeatureFilling.cpp +++ b/src/Mod/Surface/App/FeatureFilling.cpp @@ -141,7 +141,7 @@ void Filling::addConstraints(BRepFill_Filling& builder, App::DocumentObject* obj = edge_obj[index]; const std::string& sub = edge_sub[index]; - if (obj && obj->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) { + if (obj && obj->isDerivedFrom()) { // get the sub-edge of the part's shape const Part::TopoShape& shape = static_cast(obj)->Shape.getShape(); TopoDS_Shape edge = shape.getSubShape(sub.c_str()); @@ -217,7 +217,7 @@ void Filling::addConstraints(BRepFill_Filling& builder, for (std::size_t index = 0; index < face_obj.size(); index++) { App::DocumentObject* obj = face_obj[index]; const std::string& sub = face_sub[index]; - if (obj && obj->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) { + if (obj && obj->isDerivedFrom()) { const Part::TopoShape& shape = static_cast(obj)->Shape.getShape(); TopoDS_Shape face = shape.getSubShape(sub.c_str()); if (!face.IsNull() && face.ShapeType() == TopAbs_FACE) { @@ -241,7 +241,7 @@ void Filling::addConstraints(BRepFill_Filling& builder, const App::PropertyLinkS for (const auto& it : points) { App::DocumentObject* obj = it.first; std::vector sub = it.second; - if (obj && obj->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) { + if (obj && obj->isDerivedFrom()) { const Part::TopoShape& shape = static_cast(obj)->Shape.getShape(); for (const auto& jt : sub) { TopoDS_Shape subShape = shape.getSubShape(jt.c_str()); @@ -287,7 +287,7 @@ App::DocumentObjectExecReturn* Filling::execute() // Load the initial surface if set App::DocumentObject* initFace = InitialFace.getValue(); - if (initFace && initFace->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) { + if (initFace && initFace->isDerivedFrom()) { const Part::TopoShape& shape = static_cast(initFace)->Shape.getShape(); std::vector subNames = InitialFace.getSubValues(); for (const auto& it : subNames) { diff --git a/src/Mod/Surface/App/FeatureGeomFillSurface.cpp b/src/Mod/Surface/App/FeatureGeomFillSurface.cpp index 798bf03678..8f63df3194 100644 --- a/src/Mod/Surface/App/FeatureGeomFillSurface.cpp +++ b/src/Mod/Surface/App/FeatureGeomFillSurface.cpp @@ -215,7 +215,7 @@ bool GeomFillSurface::getWire(TopoDS_Wire& aWire) ShapeValidator validator; for (const auto& set : boundary) { - if (set.first->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) { + if (set.first->isDerivedFrom()) { for (const auto& jt : set.second) { const Part::TopoShape& ts = static_cast(set.first)->Shape.getShape(); diff --git a/src/Mod/Surface/App/FeatureSections.cpp b/src/Mod/Surface/App/FeatureSections.cpp index c7333ed376..cd18b80eb8 100644 --- a/src/Mod/Surface/App/FeatureSections.cpp +++ b/src/Mod/Surface/App/FeatureSections.cpp @@ -56,7 +56,7 @@ App::DocumentObjectExecReturn* Sections::execute() // get the part object App::DocumentObject* obj = edge_obj[index]; const std::string& sub = edge_sub[index]; - if (obj && obj->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) { + if (obj && obj->isDerivedFrom()) { // get the sub-edge of the part's shape const Part::TopoShape& shape = static_cast(obj)->Shape.getShape(); TopoDS_Shape edge = shape.getSubShape(sub.c_str()); diff --git a/src/Mod/Surface/App/FeatureSewing.cpp b/src/Mod/Surface/App/FeatureSewing.cpp index d81836f1a2..2c821b9fb3 100644 --- a/src/Mod/Surface/App/FeatureSewing.cpp +++ b/src/Mod/Surface/App/FeatureSewing.cpp @@ -81,7 +81,7 @@ App::DocumentObjectExecReturn* Sewing::execute() for (const auto& it : subset) { // the subset has the documentobject and the element name which belongs to it, // in our case for example the cube object and the "Edge1" string - if (it.first->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) { + if (it.first->isDerivedFrom()) { // we get the shape of the document object which resemble the whole box Part::TopoShape ts = static_cast(it.first)->Shape.getShape(); diff --git a/src/Mod/Surface/Gui/Command.cpp b/src/Mod/Surface/Gui/Command.cpp index 678bd7db2b..ee39f7f32e 100644 --- a/src/Mod/Surface/Gui/Command.cpp +++ b/src/Mod/Surface/Gui/Command.cpp @@ -75,7 +75,7 @@ void CmdSurfaceCut::activated(int iMsg) bool askUser = false; for (std::vector::iterator it = Sel.begin(); it != Sel.end(); ++it) { App::DocumentObject* obj = it->getObject(); - if (obj->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) { + if (obj->isDerivedFrom()) { const TopoDS_Shape& shape = static_cast(obj)->Shape.getValue(); if (!PartGui::checkForSolids(shape) && !askUser) { int ret = QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Non-solids diff --git a/src/Mod/Surface/Gui/TaskFilling.cpp b/src/Mod/Surface/Gui/TaskFilling.cpp index 07fbbddce0..bddbfd5c06 100644 --- a/src/Mod/Surface/Gui/TaskFilling.cpp +++ b/src/Mod/Surface/Gui/TaskFilling.cpp @@ -584,7 +584,7 @@ void FillingPanel::onListBoundaryItemDoubleClicked(QListWidgetItem* item) try { App::Document* doc = App::GetApplication().getDocument(data[0].toByteArray()); App::DocumentObject* obj = doc ? doc->getObject(data[1].toByteArray()) : nullptr; - if (obj && obj->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) { + if (obj && obj->isDerivedFrom()) { const Part::TopoShape& shape = static_cast(obj)->Shape.getShape(); TopoDS_Shape edge = shape.getSubShape(data[2].toByteArray()); diff --git a/src/Mod/Surface/Gui/TaskFillingEdge.cpp b/src/Mod/Surface/Gui/TaskFillingEdge.cpp index e820cb44e6..fefa88cb3a 100644 --- a/src/Mod/Surface/Gui/TaskFillingEdge.cpp +++ b/src/Mod/Surface/Gui/TaskFillingEdge.cpp @@ -368,7 +368,7 @@ void FillingEdgePanel::onListUnboundItemDoubleClicked(QListWidgetItem* item) try { App::Document* doc = App::GetApplication().getDocument(data[0].toByteArray()); App::DocumentObject* obj = doc ? doc->getObject(data[1].toByteArray()) : nullptr; - if (obj && obj->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) { + if (obj && obj->isDerivedFrom()) { const Part::TopoShape& shape = static_cast(obj)->Shape.getShape(); TopoDS_Shape edge = shape.getSubShape(data[2].toByteArray());