diff --git a/src/Mod/Sketcher/App/GeoList.cpp b/src/Mod/Sketcher/App/GeoList.cpp index 33fd95a054..d477d6cb12 100644 --- a/src/Mod/Sketcher/App/GeoList.cpp +++ b/src/Mod/Sketcher/App/GeoList.cpp @@ -171,13 +171,13 @@ Base::Vector3d GeoListModel::getPoint(const Part::Geometry* geo, Sketcher::Po { using namespace Sketcher; - if (geo->getTypeId() == Part::GeomPoint::getClassTypeId()) { + if (geo->is()) { const Part::GeomPoint* p = static_cast(geo); if (pos == PointPos::start || pos == PointPos::mid || pos == PointPos::end) { return p->getPoint(); } } - else if (geo->getTypeId() == Part::GeomLineSegment::getClassTypeId()) { + else if (geo->is()) { const Part::GeomLineSegment* lineSeg = static_cast(geo); if (pos == PointPos::start) { return lineSeg->getStartPoint(); @@ -186,19 +186,19 @@ Base::Vector3d GeoListModel::getPoint(const Part::Geometry* geo, Sketcher::Po return lineSeg->getEndPoint(); } } - else if (geo->getTypeId() == Part::GeomCircle::getClassTypeId()) { + else if (geo->is()) { const Part::GeomCircle* circle = static_cast(geo); if (pos == PointPos::mid) { return circle->getCenter(); } } - else if (geo->getTypeId() == Part::GeomEllipse::getClassTypeId()) { + else if (geo->is()) { const Part::GeomEllipse* ellipse = static_cast(geo); if (pos == PointPos::mid) { return ellipse->getCenter(); } } - else if (geo->getTypeId() == Part::GeomArcOfCircle::getClassTypeId()) { + else if (geo->is()) { const Part::GeomArcOfCircle* aoc = static_cast(geo); if (pos == PointPos::start) { return aoc->getStartPoint(/*emulateCCW=*/true); @@ -210,7 +210,7 @@ Base::Vector3d GeoListModel::getPoint(const Part::Geometry* geo, Sketcher::Po return aoc->getCenter(); } } - else if (geo->getTypeId() == Part::GeomArcOfEllipse::getClassTypeId()) { + else if (geo->is()) { const Part::GeomArcOfEllipse* aoc = static_cast(geo); if (pos == PointPos::start) { return aoc->getStartPoint(/*emulateCCW=*/true); @@ -222,7 +222,7 @@ Base::Vector3d GeoListModel::getPoint(const Part::Geometry* geo, Sketcher::Po return aoc->getCenter(); } } - else if (geo->getTypeId() == Part::GeomArcOfHyperbola::getClassTypeId()) { + else if (geo->is()) { const Part::GeomArcOfHyperbola* aoh = static_cast(geo); if (pos == PointPos::start) { return aoh->getStartPoint(); @@ -234,7 +234,7 @@ Base::Vector3d GeoListModel::getPoint(const Part::Geometry* geo, Sketcher::Po return aoh->getCenter(); } } - else if (geo->getTypeId() == Part::GeomArcOfParabola::getClassTypeId()) { + else if (geo->is()) { const Part::GeomArcOfParabola* aop = static_cast(geo); if (pos == PointPos::start) { return aop->getStartPoint(); @@ -246,7 +246,7 @@ Base::Vector3d GeoListModel::getPoint(const Part::Geometry* geo, Sketcher::Po return aop->getCenter(); } } - else if (geo->getTypeId() == Part::GeomBSplineCurve::getClassTypeId()) { + else if (geo->is()) { const Part::GeomBSplineCurve* bsp = static_cast(geo); if (pos == PointPos::start) { return bsp->getStartPoint(); diff --git a/src/Mod/Sketcher/App/GeometryFacade.h b/src/Mod/Sketcher/App/GeometryFacade.h index b7aab2ee34..8e8f513bbe 100644 --- a/src/Mod/Sketcher/App/GeometryFacade.h +++ b/src/Mod/Sketcher/App/GeometryFacade.h @@ -82,7 +82,7 @@ class GeometryFacadePy; * Examples getting and setting the construction stations without creating a Facade: * * if ((*geo) && GeometryFacade::getConstruction(*geo) && - * (*geo)->getTypeId() == Part::GeomLineSegment::getClassTypeId()) + * (*geo)->is()) * count++; * * Part::Geometry* copy = v->copy(); diff --git a/src/Mod/Sketcher/App/Sketch.cpp b/src/Mod/Sketcher/App/Sketch.cpp index bab148ca46..71560d5ce2 100644 --- a/src/Mod/Sketcher/App/Sketch.cpp +++ b/src/Mod/Sketcher/App/Sketch.cpp @@ -682,48 +682,48 @@ const char* nameByType(Sketch::GeoType type) int Sketch::addGeometry(const Part::Geometry* geo, bool fixed) { - if (geo->getTypeId() == GeomPoint::getClassTypeId()) { // add a point + if (geo->is()) { // add a point const GeomPoint* point = static_cast(geo); auto pointf = GeometryFacade::getFacade(point); // create the definition struct for that geom return addPoint(*point, fixed); } - else if (geo->getTypeId() == GeomLineSegment::getClassTypeId()) { // add a line + else if (geo->is()) { // add a line const GeomLineSegment* lineSeg = static_cast(geo); // create the definition struct for that geom return addLineSegment(*lineSeg, fixed); } - else if (geo->getTypeId() == GeomCircle::getClassTypeId()) { // add a circle + else if (geo->is()) { // add a circle const GeomCircle* circle = static_cast(geo); // create the definition struct for that geom return addCircle(*circle, fixed); } - else if (geo->getTypeId() == GeomEllipse::getClassTypeId()) { // add a ellipse + else if (geo->is()) { // add a ellipse const GeomEllipse* ellipse = static_cast(geo); // create the definition struct for that geom return addEllipse(*ellipse, fixed); } - else if (geo->getTypeId() == GeomArcOfCircle::getClassTypeId()) { // add an arc + else if (geo->is()) { // add an arc const GeomArcOfCircle* aoc = static_cast(geo); // create the definition struct for that geom return addArc(*aoc, fixed); } - else if (geo->getTypeId() == GeomArcOfEllipse::getClassTypeId()) { // add an arc + else if (geo->is()) { // add an arc const GeomArcOfEllipse* aoe = static_cast(geo); // create the definition struct for that geom return addArcOfEllipse(*aoe, fixed); } - else if (geo->getTypeId() == GeomArcOfHyperbola::getClassTypeId()) { // add an arc of hyperbola + else if (geo->is()) { // add an arc of hyperbola const GeomArcOfHyperbola* aoh = static_cast(geo); // create the definition struct for that geom return addArcOfHyperbola(*aoh, fixed); } - else if (geo->getTypeId() == GeomArcOfParabola::getClassTypeId()) { // add an arc of parabola + else if (geo->is()) { // add an arc of parabola const GeomArcOfParabola* aop = static_cast(geo); // create the definition struct for that geom return addArcOfParabola(*aop, fixed); } - else if (geo->getTypeId() == GeomBSplineCurve::getClassTypeId()) { // add a bspline + else if (geo->is()) { // add a bspline const GeomBSplineCurve* bsp = static_cast(geo); // Current B-Spline implementation relies on OCCT calculations, so a second solve diff --git a/src/Mod/Sketcher/App/SketchAnalysis.cpp b/src/Mod/Sketcher/App/SketchAnalysis.cpp index b778660929..c51e6db205 100644 --- a/src/Mod/Sketcher/App/SketchAnalysis.cpp +++ b/src/Mod/Sketcher/App/SketchAnalysis.cpp @@ -165,7 +165,7 @@ int SketchAnalysis::detectMissingPointOnPointConstraints(double precision, continue; } - if (gf->getGeometry()->getTypeId() == Part::GeomLineSegment::getClassTypeId()) { + if (gf->getGeometry()->is()) { const Part::GeomLineSegment* segm = static_cast(gf->getGeometry()); VertexIds id; @@ -178,7 +178,7 @@ int SketchAnalysis::detectMissingPointOnPointConstraints(double precision, id.v = segm->getEndPoint(); vertexIds.push_back(id); } - else if (gf->getGeometry()->getTypeId() == Part::GeomArcOfCircle::getClassTypeId()) { + else if (gf->getGeometry()->is()) { const Part::GeomArcOfCircle* segm = static_cast(gf->getGeometry()); VertexIds id; @@ -191,7 +191,7 @@ int SketchAnalysis::detectMissingPointOnPointConstraints(double precision, id.v = segm->getEndPoint(/*emulateCCW=*/true); vertexIds.push_back(id); } - else if (gf->getGeometry()->getTypeId() == Part::GeomArcOfEllipse::getClassTypeId()) { + else if (gf->getGeometry()->is()) { const Part::GeomArcOfEllipse* segm = static_cast(gf->getGeometry()); VertexIds id; @@ -204,7 +204,7 @@ int SketchAnalysis::detectMissingPointOnPointConstraints(double precision, id.v = segm->getEndPoint(/*emulateCCW=*/true); vertexIds.push_back(id); } - else if (gf->getGeometry()->getTypeId() == Part::GeomArcOfHyperbola::getClassTypeId()) { + else if (gf->getGeometry()->is()) { const Part::GeomArcOfHyperbola* segm = static_cast(gf->getGeometry()); VertexIds id; @@ -217,7 +217,7 @@ int SketchAnalysis::detectMissingPointOnPointConstraints(double precision, id.v = segm->getEndPoint(); vertexIds.push_back(id); } - else if (gf->getGeometry()->getTypeId() == Part::GeomArcOfParabola::getClassTypeId()) { + else if (gf->getGeometry()->is()) { const Part::GeomArcOfParabola* segm = static_cast(gf->getGeometry()); VertexIds id; @@ -230,7 +230,7 @@ int SketchAnalysis::detectMissingPointOnPointConstraints(double precision, id.v = segm->getEndPoint(); vertexIds.push_back(id); } - else if (gf->getGeometry()->getTypeId() == Part::GeomBSplineCurve::getClassTypeId()) { + else if (gf->getGeometry()->is()) { const Part::GeomBSplineCurve* segm = static_cast(gf->getGeometry()); VertexIds id; @@ -402,8 +402,7 @@ void SketchAnalysis::analyseMissingPointOnPointCoincident(double angleprecision) if (curve1 && curve2) { - if (geo1->getTypeId() == Part::GeomLineSegment::getClassTypeId() - && geo2->getTypeId() == Part::GeomLineSegment::getClassTypeId()) { + if (geo1->is() && geo2->is()) { const Part::GeomLineSegment* segm1 = static_cast(geo1); @@ -508,7 +507,7 @@ int SketchAnalysis::detectMissingVerticalHorizontalConstraints(double anglepreci for (std::size_t i = 0; i < geom.size(); i++) { Part::Geometry* g = geom[i]; - if (g->getTypeId() == Part::GeomLineSegment::getClassTypeId()) { + if (g->is()) { const Part::GeomLineSegment* segm = static_cast(g); Base::Vector3d dir = segm->getEndPoint() - segm->getStartPoint(); @@ -606,21 +605,21 @@ int SketchAnalysis::detectMissingEqualityConstraints(double precision) for (std::size_t i = 0; i < geom.size(); i++) { Part::Geometry* g = geom[i]; - if (g->getTypeId() == Part::GeomLineSegment::getClassTypeId()) { + if (g->is()) { const Part::GeomLineSegment* segm = static_cast(g); EdgeIds id; id.GeoId = (int)i; id.l = (segm->getEndPoint() - segm->getStartPoint()).Length(); lineedgeIds.push_back(id); } - else if (g->getTypeId() == Part::GeomArcOfCircle::getClassTypeId()) { + else if (g->is()) { const Part::GeomArcOfCircle* segm = static_cast(g); EdgeIds id; id.GeoId = (int)i; id.l = segm->getRadius(); radiusedgeIds.push_back(id); } - else if (g->getTypeId() == Part::GeomCircle::getClassTypeId()) { + else if (g->is()) { const Part::GeomCircle* segm = static_cast(g); EdgeIds id; id.GeoId = (int)i; @@ -988,7 +987,7 @@ int SketchAnalysis::detectDegeneratedGeometries(double tolerance) continue; } - if (gf->getGeometry()->getTypeId().isDerivedFrom(Part::GeomCurve::getClassTypeId())) { + if (gf->getGeometry()->isDerivedFrom()) { Part::GeomCurve* curve = static_cast(gf->getGeometry()); double len = curve->length(curve->getFirstParameter(), curve->getLastParameter()); if (len < tolerance) { @@ -1011,7 +1010,7 @@ int SketchAnalysis::removeDegeneratedGeometries(double tolerance) continue; } - if (gf->getGeometry()->getTypeId().isDerivedFrom(Part::GeomCurve::getClassTypeId())) { + if (gf->getGeometry()->isDerivedFrom()) { Part::GeomCurve* curve = static_cast(gf->getGeometry()); double len = curve->length(curve->getFirstParameter(), curve->getLastParameter()); if (len < tolerance) { diff --git a/src/Mod/Sketcher/App/SketchObject.cpp b/src/Mod/Sketcher/App/SketchObject.cpp index 3773396bc2..fca1a0abf9 100644 --- a/src/Mod/Sketcher/App/SketchObject.cpp +++ b/src/Mod/Sketcher/App/SketchObject.cpp @@ -918,25 +918,25 @@ Base::Vector3d SketchObject::getPoint(const Part::Geometry *geo, PointPos PosId) const Part::GeomPoint *p = static_cast(geo); if (PosId == PointPos::start || PosId == PointPos::mid || PosId == PointPos::end) return p->getPoint(); - } else if (geo->getTypeId() == Part::GeomLineSegment::getClassTypeId()) { + } else if (geo->is()) { const Part::GeomLineSegment *lineSeg = static_cast(geo); if (PosId == PointPos::start) return lineSeg->getStartPoint(); else if (PosId == PointPos::end) return lineSeg->getEndPoint(); - } else if (geo->getTypeId() == Part::GeomCircle::getClassTypeId()) { + } else if (geo->is()) { const Part::GeomCircle *circle = static_cast(geo); auto pt = circle->getCenter(); if(PosId != PointPos::mid) pt.x += circle->getRadius(); return pt; - } else if (geo->getTypeId() == Part::GeomEllipse::getClassTypeId()) { + } else if (geo->is()) { const Part::GeomEllipse *ellipse = static_cast(geo); auto pt = ellipse->getCenter(); if(PosId != PointPos::mid) pt += ellipse->getMajorAxisDir()*ellipse->getMajorRadius(); return pt; - } else if (geo->getTypeId() == Part::GeomArcOfCircle::getClassTypeId()) { + } else if (geo->is()) { const Part::GeomArcOfCircle *aoc = static_cast(geo); if (PosId == PointPos::start) return aoc->getStartPoint(/*emulateCCW=*/true); @@ -944,7 +944,7 @@ Base::Vector3d SketchObject::getPoint(const Part::Geometry *geo, PointPos PosId) return aoc->getEndPoint(/*emulateCCW=*/true); else if (PosId == PointPos::mid) return aoc->getCenter(); - } else if (geo->getTypeId() == Part::GeomArcOfEllipse::getClassTypeId()) { + } else if (geo->is()) { const Part::GeomArcOfEllipse *aoc = static_cast(geo); if (PosId == PointPos::start) return aoc->getStartPoint(/*emulateCCW=*/true); @@ -952,7 +952,7 @@ Base::Vector3d SketchObject::getPoint(const Part::Geometry *geo, PointPos PosId) return aoc->getEndPoint(/*emulateCCW=*/true); else if (PosId == PointPos::mid) return aoc->getCenter(); - } else if (geo->getTypeId() == Part::GeomArcOfHyperbola::getClassTypeId()) { + } else if (geo->is()) { const Part::GeomArcOfHyperbola *aoh = static_cast(geo); if (PosId == PointPos::start) return aoh->getStartPoint(); @@ -960,7 +960,7 @@ Base::Vector3d SketchObject::getPoint(const Part::Geometry *geo, PointPos PosId) return aoh->getEndPoint(); else if (PosId == PointPos::mid) return aoh->getCenter(); - } else if (geo->getTypeId() == Part::GeomArcOfParabola::getClassTypeId()) { + } else if (geo->is()) { const Part::GeomArcOfParabola *aop = static_cast(geo); if (PosId == PointPos::start) return aop->getStartPoint(); @@ -968,7 +968,7 @@ Base::Vector3d SketchObject::getPoint(const Part::Geometry *geo, PointPos PosId) return aop->getEndPoint(); else if (PosId == PointPos::mid) return aop->getCenter(); - } else if (geo->getTypeId() == Part::GeomBSplineCurve::getClassTypeId()) { + } else if (geo->is()) { const Part::GeomBSplineCurve *bsp = static_cast(geo); if (PosId == PointPos::start) return bsp->getStartPoint(); @@ -994,7 +994,7 @@ int SketchObject::getAxisCount() const int count = 0; for (std::vector::const_iterator geo = vals.begin(); geo != vals.end(); geo++) if ((*geo) && GeometryFacade::getConstruction(*geo) - && (*geo)->getTypeId() == Part::GeomLineSegment::getClassTypeId()) + && (*geo)->is()) count++; return count; @@ -1009,7 +1009,7 @@ Base::Axis SketchObject::getAxis(int axId) const int count = 0; for (std::vector::const_iterator geo = vals.begin(); geo != vals.end(); geo++) if ((*geo) && GeometryFacade::getConstruction(*geo) - && (*geo)->getTypeId() == Part::GeomLineSegment::getClassTypeId()) { + && (*geo)->is()) { if (count == axId) { Part::GeomLineSegment* lineSeg = static_cast(*geo); Base::Vector3d start = lineSeg->getStartPoint(); @@ -1030,18 +1030,18 @@ void SketchObject::acceptGeometry() bool SketchObject::isSupportedGeometry(const Part::Geometry* geo) const { - if (geo->getTypeId() == Part::GeomPoint::getClassTypeId() - || geo->getTypeId() == Part::GeomCircle::getClassTypeId() - || geo->getTypeId() == Part::GeomEllipse::getClassTypeId() - || geo->getTypeId() == Part::GeomArcOfCircle::getClassTypeId() - || geo->getTypeId() == Part::GeomArcOfEllipse::getClassTypeId() - || geo->getTypeId() == Part::GeomArcOfHyperbola::getClassTypeId() - || geo->getTypeId() == Part::GeomArcOfParabola::getClassTypeId() - || geo->getTypeId() == Part::GeomBSplineCurve::getClassTypeId() - || geo->getTypeId() == Part::GeomLineSegment::getClassTypeId()) { + if (geo->is() + || geo->is() + || geo->is() + || geo->is() + || geo->is() + || geo->is() + || geo->is() + || geo->is() + || geo->is()) { return true; } - if (geo->getTypeId() == Part::GeomTrimmedCurve::getClassTypeId()) { + if (geo->is()) { Handle(Geom_TrimmedCurve) trim = Handle(Geom_TrimmedCurve)::DownCast(geo->handle()); Handle(Geom_Circle) circle = Handle(Geom_Circle)::DownCast(trim->BasisCurve()); Handle(Geom_Ellipse) ellipse = Handle(Geom_Ellipse)::DownCast(trim->BasisCurve()); @@ -1081,7 +1081,7 @@ int SketchObject::addGeometry(const std::vector& geoList, for (auto& v : geoList) { Part::Geometry* copy = v->copy(); - if (copy->getTypeId() == Part::GeomPoint::getClassTypeId()) { + if (copy->is()) { // creation mode for points is always construction not to // break legacy code GeometryFacade::setConstruction(copy, true); @@ -1119,7 +1119,7 @@ int SketchObject::addGeometry(std::unique_ptr newgeo, bool const auto* geoNew = newgeo.release(); - if (geoNew->getTypeId() == Part::GeomPoint::getClassTypeId()) { + if (geoNew->is()) { // creation mode for points is always construction not to // break legacy code GeometryFacade::setConstruction(geoNew, true); @@ -1149,11 +1149,11 @@ int SketchObject::delGeometry(int GeoId, bool deleteinternalgeo) if (deleteinternalgeo) { const Part::Geometry* geo = getGeometry(GeoId); // Only for supported types - 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())) { + if ((geo->is() + || geo->is() + || geo->is() + || geo->is() + || geo->is())) { this->deleteUnusedInternalGeometry(GeoId, true); @@ -1997,8 +1997,8 @@ int SketchObject::fillet(int GeoId, PointPos PosId, double radius, bool trim, bo if (GeoIdList.size() == 2 && GeoIdList[0] >= 0 && GeoIdList[1] >= 0) { const Part::Geometry* geo1 = getGeometry(GeoIdList[0]); const Part::Geometry* geo2 = getGeometry(GeoIdList[1]); - if (geo1->getTypeId() == Part::GeomLineSegment::getClassTypeId() - && geo2->getTypeId() == Part::GeomLineSegment::getClassTypeId()) { + if (geo1->is() + && geo2->is()) { const Part::GeomLineSegment* lineSeg1 = static_cast(geo1); const Part::GeomLineSegment* lineSeg2 = static_cast(geo2); @@ -2025,8 +2025,8 @@ int SketchObject::fillet(int GeoId1, int GeoId2, const Base::Vector3d& refPnt1, trim = false; } - if (geo1->getTypeId() == Part::GeomLineSegment::getClassTypeId() - && geo2->getTypeId() == Part::GeomLineSegment::getClassTypeId()) { + if (geo1->is() + && geo2->is()) { const Part::GeomLineSegment* lineSeg1 = static_cast(geo1); const Part::GeomLineSegment* lineSeg2 = static_cast(geo2); @@ -2629,7 +2629,7 @@ int SketchObject::extend(int GeoId, double increment, PointPos endpoint) const std::vector& geomList = getInternalGeometry(); Part::Geometry* geom = geomList[GeoId]; int retcode = -1; - if (geom->getTypeId() == Part::GeomLineSegment::getClassTypeId()) { + if (geom->is()) { Part::GeomLineSegment* seg = static_cast(geom); Base::Vector3d startVec = seg->getStartPoint(); Base::Vector3d endVec = seg->getEndPoint(); @@ -2650,7 +2650,7 @@ int SketchObject::extend(int GeoId, double increment, PointPos endpoint) retcode = movePoint(GeoId, Sketcher::PointPos::end, newPoint, false, true); } } - else if (geom->getTypeId() == Part::GeomArcOfCircle::getClassTypeId()) { + else if (geom->is()) { Part::GeomArcOfCircle* arc = static_cast(geom); double startArc, endArc; arc->getRange(startArc, endArc, true); @@ -2867,7 +2867,7 @@ int SketchObject::trim(int GeoId, const Base::Vector3d& point) // Removes all internal geometry of a BSplineCurve and updates the GeoId index after removal auto ifBSplineRemoveInternalAlignmentGeometry = [this](int& GeoId) { const Part::Geometry* geo = getGeometry(GeoId); - if (geo->getTypeId() == Part::GeomBSplineCurve::getClassTypeId()) { + if (geo->is()) { // We need to remove the internal geometry of the BSpline, as BSplines change in number // of poles and knots We save the tags of the relevant geometry to retrieve the new // GeoIds later on. @@ -2936,15 +2936,15 @@ int SketchObject::trim(int GeoId, const Base::Vector3d& point) // Trimmed B-Spline internal geometry cannot be reused geo = getGeometry(GeoId); - auto isBSpline = geo->getTypeId() == Part::GeomBSplineCurve::getClassTypeId(); + auto isBSpline = geo->is(); auto isPeriodicBSpline = isBSpline && static_cast(geo)->isPeriodic(); auto isNonPeriodicBSpline = isBSpline && !static_cast(geo)->isPeriodic(); - auto isLineSegment = geo->getTypeId() == Part::GeomLineSegment::getClassTypeId(); + auto isLineSegment = geo->is(); auto isDerivedFromTrimmedCurve = geo->isDerivedFrom(Part::GeomTrimmedCurve::getClassTypeId()); - auto isCircle = geo->getTypeId() == Part::GeomCircle::getClassTypeId(); - auto isEllipse = geo->getTypeId() == Part::GeomEllipse::getClassTypeId(); + auto isCircle = geo->is(); + auto isEllipse = geo->is(); if (isBSpline) { @@ -3459,7 +3459,7 @@ int SketchObject::split(int GeoId, const Base::Vector3d& point) }; bool ok = false; - if (geo->getTypeId() == Part::GeomLineSegment::getClassTypeId()) { + if (geo->is()) { ok = createGeosFromNonPeriodic( static_cast(geo), [](const Part::GeomCurve* curve, double startParam, double endParam) { @@ -3481,7 +3481,7 @@ int SketchObject::split(int GeoId, const Base::Vector3d& point) transferConstraints(GeoId, PointPos::end, newId1, PointPos::end); }); } - else if (geo->getTypeId() == Part::GeomCircle::getClassTypeId()) { + else if (geo->is()) { ok = createGeosFromPeriodic( static_cast(geo), [](const Part::GeomCurve* curve, double startParam, double endParam) { @@ -3494,7 +3494,7 @@ int SketchObject::split(int GeoId, const Base::Vector3d& point) transferConstraints(GeoId, PointPos::mid, newId, PointPos::mid); }); } - else if (geo->getTypeId() == Part::GeomEllipse::getClassTypeId()) { + else if (geo->is()) { ok = createGeosFromPeriodic( static_cast(geo), [](const Part::GeomCurve* curve, double startParam, double endParam) { @@ -3507,7 +3507,7 @@ int SketchObject::split(int GeoId, const Base::Vector3d& point) transferConstraints(GeoId, PointPos::mid, newId, PointPos::mid); }); } - else if (geo->getTypeId() == Part::GeomArcOfCircle::getClassTypeId()) { + else if (geo->is()) { ok = createGeosFromNonPeriodic( static_cast(geo), [](const Part::GeomCurve* curve, double startParam, double endParam) { @@ -3564,7 +3564,7 @@ int SketchObject::split(int GeoId, const Base::Vector3d& point) transferConstraints(GeoId, PointPos::end, newId1, PointPos::end, true); }); } - else if (geo->getTypeId() == Part::GeomBSplineCurve::getClassTypeId()) { + else if (geo->is()) { const Part::GeomBSplineCurve* bsp = static_cast(geo); // what to do for periodic b-splines? @@ -3638,7 +3638,7 @@ int SketchObject::split(int GeoId, const Base::Vector3d& point) case Horizontal: case Vertical: case Parallel: { - transferToAll = geo->getTypeId() == Part::GeomLineSegment::getClassTypeId(); + transferToAll = geo->is(); break; } case Tangent: @@ -3697,7 +3697,7 @@ int SketchObject::split(int GeoId, const Base::Vector3d& point) int targetId = newIds[0]; // for non-periodic curves, see if second curve is more appropriate - if (geo->getTypeId() == Part::GeomLineSegment::getClassTypeId()) { + if (geo->is()) { Base::Vector3d projPoint( conPoint.Perpendicular(startPoint, endPoint - startPoint)); Base::Vector3d splitDir = splitPoint - startPoint; @@ -3721,8 +3721,8 @@ int SketchObject::split(int GeoId, const Base::Vector3d& point) case Radius: case Diameter: case Equal: { - transferToAll = geo->getTypeId() == Part::GeomCircle::getClassTypeId() - || geo->getTypeId() == Part::GeomArcOfCircle::getClassTypeId(); + transferToAll = geo->is() + || geo->is(); break; } default: @@ -4156,7 +4156,7 @@ int SketchObject::addSymmetric(const std::vector& geoIdList, int refGeoId, } // Handle Geometry - if (geosym->getTypeId() == Part::GeomLineSegment::getClassTypeId()) { + if (geosym->is()) { Part::GeomLineSegment* geosymline = static_cast(geosym); Base::Vector3d sp = geosymline->getStartPoint(); Base::Vector3d ep = geosymline->getEndPoint(); @@ -4166,7 +4166,7 @@ int SketchObject::addSymmetric(const std::vector& geoIdList, int refGeoId, ep + 2.0 * (ep.Perpendicular(refGeoLine->getStartPoint(), vectline) - ep)); isStartEndInverted.insert(std::make_pair(*it, false)); } - else if (geosym->getTypeId() == Part::GeomCircle::getClassTypeId()) { + else if (geosym->is()) { Part::GeomCircle* geosymcircle = static_cast(geosym); Base::Vector3d cp = geosymcircle->getCenter(); @@ -4174,7 +4174,7 @@ int SketchObject::addSymmetric(const std::vector& geoIdList, int refGeoId, cp + 2.0 * (cp.Perpendicular(refGeoLine->getStartPoint(), vectline) - cp)); isStartEndInverted.insert(std::make_pair(*it, false)); } - else if (geosym->getTypeId() == Part::GeomArcOfCircle::getClassTypeId()) { + else if (geosym->is()) { Part::GeomArcOfCircle* geoaoc = static_cast(geosym); Base::Vector3d sp = geoaoc->getStartPoint(true); Base::Vector3d ep = geoaoc->getEndPoint(true); @@ -4194,7 +4194,7 @@ int SketchObject::addSymmetric(const std::vector& geoIdList, int refGeoId, geoaoc->setRange(theta1, theta2, true); isStartEndInverted.insert(std::make_pair(*it, true)); } - else if (geosym->getTypeId() == Part::GeomEllipse::getClassTypeId()) { + else if (geosym->is()) { Part::GeomEllipse* geosymellipse = static_cast(geosym); Base::Vector3d cp = geosymellipse->getCenter(); @@ -4214,7 +4214,7 @@ int SketchObject::addSymmetric(const std::vector& geoIdList, int refGeoId, geosymellipse->setCenter(scp); isStartEndInverted.insert(std::make_pair(*it, false)); } - else if (geosym->getTypeId() == Part::GeomArcOfEllipse::getClassTypeId()) { + else if (geosym->is()) { Part::GeomArcOfEllipse* geosymaoe = static_cast(geosym); Base::Vector3d cp = geosymaoe->getCenter(); @@ -4246,7 +4246,7 @@ int SketchObject::addSymmetric(const std::vector& geoIdList, int refGeoId, geosymaoe->setRange(theta1, theta2, true); isStartEndInverted.insert(std::make_pair(*it, true)); } - else if (geosym->getTypeId() == Part::GeomArcOfHyperbola::getClassTypeId()) { + else if (geosym->is()) { Part::GeomArcOfHyperbola* geosymaoe = static_cast(geosym); Base::Vector3d cp = geosymaoe->getCenter(); @@ -4275,7 +4275,7 @@ int SketchObject::addSymmetric(const std::vector& geoIdList, int refGeoId, geosymaoe->setRange(theta1, theta2, true); isStartEndInverted.insert(std::make_pair(*it, true)); } - else if (geosym->getTypeId() == Part::GeomArcOfParabola::getClassTypeId()) { + else if (geosym->is()) { Part::GeomArcOfParabola* geosymaoe = static_cast(geosym); Base::Vector3d cp = geosymaoe->getCenter(); @@ -4299,7 +4299,7 @@ int SketchObject::addSymmetric(const std::vector& geoIdList, int refGeoId, geosymaoe->setRange(theta1, theta2, true); isStartEndInverted.insert(std::make_pair(*it, true)); } - else if (geosym->getTypeId() == Part::GeomBSplineCurve::getClassTypeId()) { + else if (geosym->is()) { Part::GeomBSplineCurve* geosymbsp = static_cast(geosym); std::vector poles = geosymbsp->getPoles(); @@ -4316,7 +4316,7 @@ int SketchObject::addSymmetric(const std::vector& geoIdList, int refGeoId, isStartEndInverted.insert(std::make_pair(*it, false)); } - else if (geosym->getTypeId() == Part::GeomPoint::getClassTypeId()) { + else if (geosym->is()) { Part::GeomPoint* geosympoint = static_cast(geosym); Base::Vector3d cp = geosympoint->getPoint(); @@ -4339,7 +4339,7 @@ int SketchObject::addSymmetric(const std::vector& geoIdList, int refGeoId, Vector3d refpoint; const Part::Geometry* georef = getGeometry(refGeoId); - if (georef->getTypeId() == Part::GeomPoint::getClassTypeId()) { + if (georef->is()) { refpoint = static_cast(georef)->getPoint(); } else if (refGeoId == -1 && refPosId == Sketcher::PointPos::start) { @@ -4348,96 +4348,96 @@ int SketchObject::addSymmetric(const std::vector& geoIdList, int refGeoId, else { switch (refPosId) { case Sketcher::PointPos::start: - if (georef->getTypeId() == Part::GeomLineSegment::getClassTypeId()) { + if (georef->is()) { const Part::GeomLineSegment* geosymline = static_cast(georef); refpoint = geosymline->getStartPoint(); } - else if (georef->getTypeId() == Part::GeomArcOfCircle::getClassTypeId()) { + else if (georef->is()) { const Part::GeomArcOfCircle* geoaoc = static_cast(georef); refpoint = geoaoc->getStartPoint(true); } - else if (georef->getTypeId() == Part::GeomArcOfEllipse::getClassTypeId()) { + else if (georef->is()) { const Part::GeomArcOfEllipse* geosymaoe = static_cast(georef); refpoint = geosymaoe->getStartPoint(true); } - else if (georef->getTypeId() == Part::GeomArcOfHyperbola::getClassTypeId()) { + else if (georef->is()) { const Part::GeomArcOfHyperbola* geosymaoe = static_cast(georef); refpoint = geosymaoe->getStartPoint(true); } - else if (georef->getTypeId() == Part::GeomArcOfParabola::getClassTypeId()) { + else if (georef->is()) { const Part::GeomArcOfParabola* geosymaoe = static_cast(georef); refpoint = geosymaoe->getStartPoint(true); } - else if (georef->getTypeId() == Part::GeomBSplineCurve::getClassTypeId()) { + else if (georef->is()) { const Part::GeomBSplineCurve* geosymbsp = static_cast(georef); refpoint = geosymbsp->getStartPoint(); } break; case Sketcher::PointPos::end: - if (georef->getTypeId() == Part::GeomLineSegment::getClassTypeId()) { + if (georef->is()) { const Part::GeomLineSegment* geosymline = static_cast(georef); refpoint = geosymline->getEndPoint(); } - else if (georef->getTypeId() == Part::GeomArcOfCircle::getClassTypeId()) { + else if (georef->is()) { const Part::GeomArcOfCircle* geoaoc = static_cast(georef); refpoint = geoaoc->getEndPoint(true); } - else if (georef->getTypeId() == Part::GeomArcOfEllipse::getClassTypeId()) { + else if (georef->is()) { const Part::GeomArcOfEllipse* geosymaoe = static_cast(georef); refpoint = geosymaoe->getEndPoint(true); } - else if (georef->getTypeId() == Part::GeomArcOfHyperbola::getClassTypeId()) { + else if (georef->is()) { const Part::GeomArcOfHyperbola* geosymaoe = static_cast(georef); refpoint = geosymaoe->getEndPoint(true); } - else if (georef->getTypeId() == Part::GeomArcOfParabola::getClassTypeId()) { + else if (georef->is()) { const Part::GeomArcOfParabola* geosymaoe = static_cast(georef); refpoint = geosymaoe->getEndPoint(true); } - else if (georef->getTypeId() == Part::GeomBSplineCurve::getClassTypeId()) { + else if (georef->is()) { const Part::GeomBSplineCurve* geosymbsp = static_cast(georef); refpoint = geosymbsp->getEndPoint(); } break; case Sketcher::PointPos::mid: - if (georef->getTypeId() == Part::GeomCircle::getClassTypeId()) { + if (georef->is()) { const Part::GeomCircle* geosymcircle = static_cast(georef); refpoint = geosymcircle->getCenter(); } - else if (georef->getTypeId() == Part::GeomArcOfCircle::getClassTypeId()) { + else if (georef->is()) { const Part::GeomArcOfCircle* geoaoc = static_cast(georef); refpoint = geoaoc->getCenter(); } - else if (georef->getTypeId() == Part::GeomEllipse::getClassTypeId()) { + else if (georef->is()) { const Part::GeomEllipse* geosymellipse = static_cast(georef); refpoint = geosymellipse->getCenter(); } - else if (georef->getTypeId() == Part::GeomArcOfEllipse::getClassTypeId()) { + else if (georef->is()) { const Part::GeomArcOfEllipse* geosymaoe = static_cast(georef); refpoint = geosymaoe->getCenter(); } - else if (georef->getTypeId() == Part::GeomArcOfHyperbola::getClassTypeId()) { + else if (georef->is()) { const Part::GeomArcOfHyperbola* geosymaoe = static_cast(georef); refpoint = geosymaoe->getCenter(); } - else if (georef->getTypeId() == Part::GeomArcOfParabola::getClassTypeId()) { + else if (georef->is()) { const Part::GeomArcOfParabola* geosymaoe = static_cast(georef); refpoint = geosymaoe->getCenter(); @@ -4481,7 +4481,7 @@ int SketchObject::addSymmetric(const std::vector& geoIdList, int refGeoId, } // Handle Geometry - if (geosym->getTypeId() == Part::GeomLineSegment::getClassTypeId()) { + if (geosym->is()) { Part::GeomLineSegment* geosymline = static_cast(geosym); Base::Vector3d sp = geosymline->getStartPoint(); Base::Vector3d ep = geosymline->getEndPoint(); @@ -4491,14 +4491,14 @@ int SketchObject::addSymmetric(const std::vector& geoIdList, int refGeoId, geosymline->setPoints(ssp, sep); isStartEndInverted.insert(std::make_pair(*it, false)); } - else if (geosym->getTypeId() == Part::GeomCircle::getClassTypeId()) { + else if (geosym->is()) { Part::GeomCircle* geosymcircle = static_cast(geosym); Base::Vector3d cp = geosymcircle->getCenter(); geosymcircle->setCenter(cp + 2.0 * (refpoint - cp)); isStartEndInverted.insert(std::make_pair(*it, false)); } - else if (geosym->getTypeId() == Part::GeomArcOfCircle::getClassTypeId()) { + else if (geosym->is()) { Part::GeomArcOfCircle* geoaoc = static_cast(geosym); Base::Vector3d sp = geoaoc->getStartPoint(true); Base::Vector3d ep = geoaoc->getEndPoint(true); @@ -4515,7 +4515,7 @@ int SketchObject::addSymmetric(const std::vector& geoIdList, int refGeoId, geoaoc->setRange(theta1, theta2, true); isStartEndInverted.insert(std::make_pair(*it, false)); } - else if (geosym->getTypeId() == Part::GeomEllipse::getClassTypeId()) { + else if (geosym->is()) { Part::GeomEllipse* geosymellipse = static_cast(geosym); Base::Vector3d cp = geosymellipse->getCenter(); @@ -4533,7 +4533,7 @@ int SketchObject::addSymmetric(const std::vector& geoIdList, int refGeoId, geosymellipse->setCenter(scp); isStartEndInverted.insert(std::make_pair(*it, false)); } - else if (geosym->getTypeId() == Part::GeomArcOfEllipse::getClassTypeId()) { + else if (geosym->is()) { Part::GeomArcOfEllipse* geosymaoe = static_cast(geosym); Base::Vector3d cp = geosymaoe->getCenter(); @@ -4551,7 +4551,7 @@ int SketchObject::addSymmetric(const std::vector& geoIdList, int refGeoId, geosymaoe->setCenter(scp); isStartEndInverted.insert(std::make_pair(*it, false)); } - else if (geosym->getTypeId() == Part::GeomArcOfHyperbola::getClassTypeId()) { + else if (geosym->is()) { Part::GeomArcOfHyperbola* geosymaoe = static_cast(geosym); Base::Vector3d cp = geosymaoe->getCenter(); @@ -4570,7 +4570,7 @@ int SketchObject::addSymmetric(const std::vector& geoIdList, int refGeoId, geosymaoe->setCenter(scp); isStartEndInverted.insert(std::make_pair(*it, false)); } - else if (geosym->getTypeId() == Part::GeomArcOfParabola::getClassTypeId()) { + else if (geosym->is()) { Part::GeomArcOfParabola* geosymaoe = static_cast(geosym); Base::Vector3d cp = geosymaoe->getCenter(); @@ -4585,7 +4585,7 @@ int SketchObject::addSymmetric(const std::vector& geoIdList, int refGeoId, isStartEndInverted.insert(std::make_pair(*it, false)); } - else if (geosym->getTypeId() == Part::GeomBSplineCurve::getClassTypeId()) { + else if (geosym->is()) { Part::GeomBSplineCurve* geosymbsp = static_cast(geosym); std::vector poles = geosymbsp->getPoles(); @@ -4599,7 +4599,7 @@ int SketchObject::addSymmetric(const std::vector& geoIdList, int refGeoId, // isStartEndInverted.insert(std::make_pair(*it, false)); } - else if (geosym->getTypeId() == Part::GeomPoint::getClassTypeId()) { + else if (geosym->is()) { Part::GeomPoint* geosympoint = static_cast(geosym); Base::Vector3d cp = geosympoint->getPoint(); @@ -4828,8 +4828,8 @@ int SketchObject::addCopy(const std::vector& geoIdList, const Base::Vector3 refgeoid = *(newgeoIdList.begin()); currentrowfirstgeoid = refgeoid; iterfirstgeoid = refgeoid; - if (geo->getTypeId() == Part::GeomCircle::getClassTypeId() - || geo->getTypeId() == Part::GeomEllipse::getClassTypeId()) { + if (geo->is() + || geo->is()) { refposId = Sketcher::PointPos::mid; } else @@ -4886,7 +4886,7 @@ int SketchObject::addCopy(const std::vector& geoIdList, const Base::Vector3 geocopy = newgeoVals[*it]; // Handle Geometry - if (geocopy->getTypeId() == Part::GeomLineSegment::getClassTypeId()) { + if (geocopy->is()) { Part::GeomLineSegment* geosymline = static_cast(geocopy); Base::Vector3d ep = geosymline->getEndPoint(); @@ -4899,7 +4899,7 @@ int SketchObject::addCopy(const std::vector& geoIdList, const Base::Vector3 if (it == newgeoIdList.begin()) iterfirstpoint = ssp; } - else if (geocopy->getTypeId() == Part::GeomCircle::getClassTypeId()) { + else if (geocopy->is()) { Part::GeomCircle* geosymcircle = static_cast(geocopy); Base::Vector3d cp = geosymcircle->getCenter(); Base::Vector3d scp = @@ -4910,7 +4910,7 @@ int SketchObject::addCopy(const std::vector& geoIdList, const Base::Vector3 if (it == newgeoIdList.begin()) iterfirstpoint = scp; } - else if (geocopy->getTypeId() == Part::GeomArcOfCircle::getClassTypeId()) { + else if (geocopy->is()) { Part::GeomArcOfCircle* geoaoc = static_cast(geocopy); Base::Vector3d cp = geoaoc->getCenter(); Base::Vector3d scp = @@ -4921,7 +4921,7 @@ int SketchObject::addCopy(const std::vector& geoIdList, const Base::Vector3 if (it == newgeoIdList.begin()) iterfirstpoint = geoaoc->getStartPoint(true); } - else if (geocopy->getTypeId() == Part::GeomEllipse::getClassTypeId()) { + else if (geocopy->is()) { Part::GeomEllipse* geosymellipse = static_cast(geocopy); Base::Vector3d cp = geosymellipse->getCenter(); Base::Vector3d scp = @@ -4932,7 +4932,7 @@ int SketchObject::addCopy(const std::vector& geoIdList, const Base::Vector3 if (it == newgeoIdList.begin()) iterfirstpoint = scp; } - else if (geocopy->getTypeId() == Part::GeomArcOfEllipse::getClassTypeId()) { + else if (geocopy->is()) { Part::GeomArcOfEllipse* geoaoe = static_cast(geocopy); Base::Vector3d cp = geoaoe->getCenter(); Base::Vector3d scp = @@ -4943,7 +4943,7 @@ int SketchObject::addCopy(const std::vector& geoIdList, const Base::Vector3 if (it == newgeoIdList.begin()) iterfirstpoint = geoaoe->getStartPoint(true); } - else if (geocopy->getTypeId() == Part::GeomArcOfHyperbola::getClassTypeId()) { + else if (geocopy->is()) { Part::GeomArcOfHyperbola* geoaoe = static_cast(geocopy); Base::Vector3d cp = geoaoe->getCenter(); @@ -4955,7 +4955,7 @@ int SketchObject::addCopy(const std::vector& geoIdList, const Base::Vector3 if (it == newgeoIdList.begin()) iterfirstpoint = geoaoe->getStartPoint(true); } - else if (geocopy->getTypeId() == Part::GeomArcOfParabola::getClassTypeId()) { + else if (geocopy->is()) { Part::GeomArcOfParabola* geoaoe = static_cast(geocopy); Base::Vector3d cp = geoaoe->getCenter(); @@ -4967,7 +4967,7 @@ int SketchObject::addCopy(const std::vector& geoIdList, const Base::Vector3 if (it == newgeoIdList.begin()) iterfirstpoint = geoaoe->getStartPoint(true); } - else if (geocopy->getTypeId() == Part::GeomBSplineCurve::getClassTypeId()) { + else if (geocopy->is()) { Part::GeomBSplineCurve* geobsp = static_cast(geocopy); std::vector poles = geobsp->getPoles(); @@ -4985,7 +4985,7 @@ int SketchObject::addCopy(const std::vector& geoIdList, const Base::Vector3 if (it == newgeoIdList.begin()) iterfirstpoint = geobsp->getStartPoint(); } - else if (geocopy->getTypeId() == Part::GeomPoint::getClassTypeId()) { + else if (geocopy->is()) { Part::GeomPoint* geopoint = static_cast(geocopy); Base::Vector3d cp = geopoint->getPoint(); Base::Vector3d scp = @@ -5040,8 +5040,7 @@ int SketchObject::addCopy(const std::vector& geoIdList, const Base::Vector3 newconstrVals.push_back(constNew); } else if ((*it)->Type == Sketcher::Angle && clone) { - if (getGeometry((*it)->First)->getTypeId() - == Part::GeomLineSegment::getClassTypeId()) { + if (getGeometry((*it)->First)->is()) { // Angles on a single Element are mapped to parallel // constraints in clone mode Constraint* constNew = (*it)->copy(); @@ -5426,8 +5425,8 @@ int SketchObject::exposeInternalGeometry(int GeoId) const Part::Geometry* geo = getGeometry(GeoId); // Only for supported types - if (geo->getTypeId() == Part::GeomEllipse::getClassTypeId() - || geo->getTypeId() == Part::GeomArcOfEllipse::getClassTypeId()) { + if (geo->is() + || geo->is()) { // First we search what has to be restored bool major = false; bool minor = false; @@ -5469,7 +5468,7 @@ int SketchObject::exposeInternalGeometry(int GeoId) std::vector igeo; std::vector icon; - if (geo->getTypeId() == Part::GeomEllipse::getClassTypeId()) { + if (geo->is()) { const Part::GeomEllipse* ellipse = static_cast(geo); center = ellipse->getCenter(); @@ -5577,7 +5576,7 @@ int SketchObject::exposeInternalGeometry(int GeoId) return incrgeo;// number of added elements } - else if (geo->getTypeId() == Part::GeomArcOfHyperbola::getClassTypeId()) { + else if (geo->is()) { // First we search what has to be restored bool major = false; bool minor = false; @@ -5692,7 +5691,7 @@ int SketchObject::exposeInternalGeometry(int GeoId) return incrgeo;// number of added elements } - else if (geo->getTypeId() == Part::GeomArcOfParabola::getClassTypeId()) { + else if (geo->is()) { // First we search what has to be restored bool focus = false; bool focus_to_vertex = false; @@ -5779,7 +5778,7 @@ int SketchObject::exposeInternalGeometry(int GeoId) return incrgeo;// number of added elements } - else if (geo->getTypeId() == Part::GeomBSplineCurve::getClassTypeId()) { + else if (geo->is()) { const Part::GeomBSplineCurve* bsp = static_cast(geo); // First we search what has to be restored @@ -5965,9 +5964,9 @@ int SketchObject::deleteUnusedInternalGeometry(int GeoId, bool delgeoid) const Part::Geometry* geo = getGeometry(GeoId); // Only for supported types - if (geo->getTypeId() == Part::GeomEllipse::getClassTypeId() - || geo->getTypeId() == Part::GeomArcOfEllipse::getClassTypeId() - || geo->getTypeId() == Part::GeomArcOfHyperbola::getClassTypeId()) { + if (geo->is() + || geo->is() + || geo->is()) { int majorelementindex = -1; int minorelementindex = -1; @@ -6059,7 +6058,7 @@ int SketchObject::deleteUnusedInternalGeometry(int GeoId, bool delgeoid) return ndeleted;// number of deleted elements } - else if (geo->getTypeId() == Part::GeomArcOfParabola::getClassTypeId()) { + else if (geo->is()) { // if the focus-to-vertex line is constrained, then never delete the focus // if the line is unconstrained, then the line may be deleted, // in this case the focus may be deleted if unconstrained. @@ -6130,7 +6129,7 @@ int SketchObject::deleteUnusedInternalGeometry(int GeoId, bool delgeoid) return ndeleted;// number of deleted elements } - else if (geo->getTypeId() == Part::GeomBSplineCurve::getClassTypeId()) { + else if (geo->is()) { const Part::GeomBSplineCurve* bsp = static_cast(geo); @@ -6265,7 +6264,7 @@ bool SketchObject::convertToNURBS(int GeoId) const Part::Geometry* geo = getGeometry(GeoId); - if (geo->getTypeId() == Part::GeomPoint::getClassTypeId()) + if (geo->is()) return false; const Part::GeomCurve* geo1 = static_cast(geo); @@ -7295,7 +7294,7 @@ bool SketchObject::evaluateSupport() { // returns false if the shape is broken, null or non-planar App::DocumentObject* link = Support.getValue(); - if (!link || !link->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) + if (!link || !link->isDerivedFrom()) return false; return true; } @@ -7316,7 +7315,7 @@ void SketchObject::validateExternalLinks() TopoDS_Shape refSubShape; try { - if (Obj->getTypeId().isDerivedFrom(Part::Datum::getClassTypeId())) { + if (Obj->isDerivedFrom()) { const Part::Datum* datum = static_cast(Obj); refSubShape = datum->getShape(); } @@ -7421,11 +7420,11 @@ void SketchObject::rebuildExternalGeometry() TopoDS_Shape refSubShape; - if (Obj->getTypeId().isDerivedFrom(Part::Datum::getClassTypeId())) { + if (Obj->isDerivedFrom()) { const Part::Datum* datum = static_cast(Obj); refSubShape = datum->getShape(); } - else if (Obj->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) { + else if (Obj->isDerivedFrom()) { try { const Part::Feature* refObj = static_cast(Obj); const Part::TopoShape& refShape = refObj->Shape.getShape(); @@ -7435,7 +7434,7 @@ void SketchObject::rebuildExternalGeometry() throw Base::CADKernelError(e.GetMessageString()); } } - else if (Obj->getTypeId().isDerivedFrom(App::Plane::getClassTypeId())) { + else if (Obj->isDerivedFrom()) { const App::Plane* pl = static_cast(Obj); Base::Placement plm = pl->Placement.getValue(); Base::Vector3d base = plm.getPosition(); @@ -8039,25 +8038,25 @@ void SketchObject::rebuildVertexIndex() ++it, i++) { if (i > imax) i = -getExternalGeometryCount(); - if ((*it)->getTypeId() == Part::GeomPoint::getClassTypeId()) { + if ((*it)->is()) { VertexId2GeoId.push_back(i); VertexId2PosId.push_back(PointPos::start); } - else if ((*it)->getTypeId() == Part::GeomLineSegment::getClassTypeId()) { + else if ((*it)->is()) { VertexId2GeoId.push_back(i); VertexId2PosId.push_back(PointPos::start); VertexId2GeoId.push_back(i); VertexId2PosId.push_back(PointPos::end); } - else if ((*it)->getTypeId() == Part::GeomCircle::getClassTypeId()) { + else if ((*it)->is()) { VertexId2GeoId.push_back(i); VertexId2PosId.push_back(PointPos::mid); } - else if ((*it)->getTypeId() == Part::GeomEllipse::getClassTypeId()) { + else if ((*it)->is()) { VertexId2GeoId.push_back(i); VertexId2PosId.push_back(PointPos::mid); } - else if ((*it)->getTypeId() == Part::GeomArcOfCircle::getClassTypeId()) { + else if ((*it)->is()) { VertexId2GeoId.push_back(i); VertexId2PosId.push_back(PointPos::start); VertexId2GeoId.push_back(i); @@ -8065,7 +8064,7 @@ void SketchObject::rebuildVertexIndex() VertexId2GeoId.push_back(i); VertexId2PosId.push_back(PointPos::mid); } - else if ((*it)->getTypeId() == Part::GeomArcOfEllipse::getClassTypeId()) { + else if ((*it)->is()) { VertexId2GeoId.push_back(i); VertexId2PosId.push_back(PointPos::start); VertexId2GeoId.push_back(i); @@ -8073,7 +8072,7 @@ void SketchObject::rebuildVertexIndex() VertexId2GeoId.push_back(i); VertexId2PosId.push_back(PointPos::mid); } - else if ((*it)->getTypeId() == Part::GeomArcOfHyperbola::getClassTypeId()) { + else if ((*it)->is()) { VertexId2GeoId.push_back(i); VertexId2PosId.push_back(PointPos::start); VertexId2GeoId.push_back(i); @@ -8081,7 +8080,7 @@ void SketchObject::rebuildVertexIndex() VertexId2GeoId.push_back(i); VertexId2PosId.push_back(PointPos::mid); } - else if ((*it)->getTypeId() == Part::GeomArcOfParabola::getClassTypeId()) { + else if ((*it)->is()) { VertexId2GeoId.push_back(i); VertexId2PosId.push_back(PointPos::start); VertexId2GeoId.push_back(i); @@ -8089,7 +8088,7 @@ void SketchObject::rebuildVertexIndex() VertexId2GeoId.push_back(i); VertexId2PosId.push_back(PointPos::mid); } - else if ((*it)->getTypeId() == Part::GeomBSplineCurve::getClassTypeId()) { + else if ((*it)->is()) { VertexId2GeoId.push_back(i); VertexId2PosId.push_back(PointPos::start); VertexId2GeoId.push_back(i); @@ -8970,7 +8969,7 @@ void SketchObject::migrateSketch() bool oldconstr = ext->getConstruction(); - if (g->getTypeId() == Part::GeomPoint::getClassTypeId() + if (g->is() && !gf->isInternalAligned()) oldconstr = true; @@ -8986,8 +8985,8 @@ void SketchObject::migrateSketch() auto constraints = Constraints.getValues(); auto geometries = getInternalGeometry(); - auto parabolafound = std::find_if(geometries.begin(), geometries.end(), [](auto g) { - return g->getTypeId() == Part::GeomArcOfParabola::getClassTypeId(); + auto parabolafound = std::find_if(geometries.begin(), geometries.end(), [](Part::Geometry* g) { + return g->is(); }); if (parabolafound != geometries.end()) { @@ -9219,7 +9218,7 @@ int SketchObject::port_reversedExternalArcs(bool justAnalyze) && (posId == Sketcher::PointPos::start || posId == Sketcher::PointPos::end)) { // we are dealing with a link to an endpoint of external geom Part::Geometry* g = this->ExternalGeo[-geoId - 1]; - if (g->getTypeId() == Part::GeomArcOfCircle::getClassTypeId()) { + if (g->is()) { const Part::GeomArcOfCircle* segm = static_cast(g); if (segm->isReversed()) { diff --git a/src/Mod/Sketcher/App/SketchObjectPyImp.cpp b/src/Mod/Sketcher/App/SketchObjectPyImp.cpp index a91c05fb82..79f814ce43 100644 --- a/src/Mod/Sketcher/App/SketchObjectPyImp.cpp +++ b/src/Mod/Sketcher/App/SketchObjectPyImp.cpp @@ -87,7 +87,7 @@ PyObject* SketchObjectPy::addGeometry(PyObject* args) Part::Geometry* geo = static_cast(pcObj)->getGeometryPtr(); int ret; // An arc created with Part.Arc will be converted into a Part.ArcOfCircle - if (geo->getTypeId() == Part::GeomTrimmedCurve::getClassTypeId()) { + if (geo->is()) { Handle(Geom_TrimmedCurve) trim = Handle(Geom_TrimmedCurve)::DownCast(geo->handle()); Handle(Geom_Circle) circle = Handle(Geom_Circle)::DownCast(trim->BasisCurve()); Handle(Geom_Ellipse) ellipse = Handle(Geom_Ellipse)::DownCast(trim->BasisCurve()); @@ -110,15 +110,11 @@ PyObject* SketchObjectPy::addGeometry(PyObject* args) return nullptr; } } - else if (geo->getTypeId() == Part::GeomPoint::getClassTypeId() - || geo->getTypeId() == Part::GeomCircle::getClassTypeId() - || geo->getTypeId() == Part::GeomEllipse::getClassTypeId() - || geo->getTypeId() == Part::GeomArcOfCircle::getClassTypeId() - || geo->getTypeId() == Part::GeomArcOfEllipse::getClassTypeId() - || geo->getTypeId() == Part::GeomArcOfHyperbola::getClassTypeId() - || geo->getTypeId() == Part::GeomArcOfParabola::getClassTypeId() - || geo->getTypeId() == Part::GeomBSplineCurve::getClassTypeId() - || geo->getTypeId() == Part::GeomLineSegment::getClassTypeId()) { + else if (geo->is() || geo->is() + || geo->is() || geo->is() + || geo->is() || geo->is() + || geo->is() || geo->is() + || geo->is()) { ret = this->getSketchObjectPtr()->addGeometry(geo, isConstruction); } else { @@ -139,7 +135,7 @@ PyObject* SketchObjectPy::addGeometry(PyObject* args) Part::Geometry* geo = static_cast((*it).ptr())->getGeometryPtr(); // An arc created with Part.Arc will be converted into a Part.ArcOfCircle - if (geo->getTypeId() == Part::GeomTrimmedCurve::getClassTypeId()) { + if (geo->is()) { Handle(Geom_TrimmedCurve) trim = Handle(Geom_TrimmedCurve)::DownCast(geo->handle()); Handle(Geom_Circle) circle = Handle(Geom_Circle)::DownCast(trim->BasisCurve()); @@ -166,15 +162,11 @@ PyObject* SketchObjectPy::addGeometry(PyObject* args) return nullptr; } } - else if (geo->getTypeId() == Part::GeomPoint::getClassTypeId() - || geo->getTypeId() == Part::GeomCircle::getClassTypeId() - || geo->getTypeId() == Part::GeomEllipse::getClassTypeId() - || geo->getTypeId() == Part::GeomArcOfCircle::getClassTypeId() - || geo->getTypeId() == Part::GeomArcOfEllipse::getClassTypeId() - || geo->getTypeId() == Part::GeomArcOfHyperbola::getClassTypeId() - || geo->getTypeId() == Part::GeomArcOfParabola::getClassTypeId() - || geo->getTypeId() == Part::GeomBSplineCurve::getClassTypeId() - || geo->getTypeId() == Part::GeomLineSegment::getClassTypeId()) { + else if (geo->is() || geo->is() + || geo->is() || geo->is() + || geo->is() || geo->is() + || geo->is() || geo->is() + || geo->is()) { geoList.push_back(geo); } else { diff --git a/src/Mod/Sketcher/Gui/CommandAlterGeometry.cpp b/src/Mod/Sketcher/Gui/CommandAlterGeometry.cpp index 53c2b750ae..a6401e4bc4 100644 --- a/src/Mod/Sketcher/Gui/CommandAlterGeometry.cpp +++ b/src/Mod/Sketcher/Gui/CommandAlterGeometry.cpp @@ -197,7 +197,7 @@ void CmdSketcherToggleConstruction::activated(int iMsg) auto geo = Obj->getGeometry(geoId); - if (geo && geo->getTypeId() == Part::GeomPoint::getClassTypeId()) { + if (geo && geo->is()) { // issue the actual commands to toggle Gui::cmdAppObjectArgs(selection[0].getObject(), "toggleConstruction(%d) ", diff --git a/src/Mod/Sketcher/Gui/CommandConstraints.cpp b/src/Mod/Sketcher/Gui/CommandConstraints.cpp index 2142e8dd73..265075a407 100644 --- a/src/Mod/Sketcher/Gui/CommandConstraints.cpp +++ b/src/Mod/Sketcher/Gui/CommandConstraints.cpp @@ -238,8 +238,8 @@ bool SketcherGui::calculateAngle(Sketcher::SketchObject* Obj, int& GeoId1, int& const Part::Geometry* geom1 = Obj->getGeometry(GeoId1); const Part::Geometry* geom2 = Obj->getGeometry(GeoId2); - if (!(geom1->getTypeId() == Part::GeomLineSegment::getClassTypeId()) || - !(geom2->getTypeId() == Part::GeomLineSegment::getClassTypeId())) { + if (!(geom1->is()) || + !(geom2->is())) { return false; } @@ -787,8 +787,7 @@ int SketchSelection::setUp() // only one sketch with its subelements are allowed to be selected if (selection.size() == 1) { // if one selectetd, only sketch allowed. should be done by activity of command - if (!selection[0].getObject()->getTypeId().isDerivedFrom( - Sketcher::SketchObject::getClassTypeId())) { + if (!selection[0].getObject()->isDerivedFrom()) { ErrorMsg = QObject::tr("Only sketch and its support are allowed to be selected."); return -1; } @@ -797,8 +796,7 @@ int SketchSelection::setUp() SketchSubNames = selection[0].getSubNames(); } else if (selection.size() == 2) { - if (selection[0].getObject()->getTypeId().isDerivedFrom( - Sketcher::SketchObject::getClassTypeId())) { + if (selection[0].getObject()->isDerivedFrom()) { SketchObj = static_cast(selection[0].getObject()); // check if the none sketch object is the support of the sketch if (selection[1].getObject() != SketchObj->Support.getValue()) { @@ -806,13 +804,11 @@ int SketchSelection::setUp() return -1; } // assume always a Part::Feature derived object as support - assert(selection[1].getObject()->getTypeId().isDerivedFrom( - Part::Feature::getClassTypeId())); + assert(selection[1].getObject()->isDerivedFrom()); SketchSubNames = selection[0].getSubNames(); SupportSubNames = selection[1].getSubNames(); } - else if (selection[1].getObject()->getTypeId().isDerivedFrom( - Sketcher::SketchObject::getClassTypeId())) { + else if (selection[1].getObject()->isDerivedFrom()) { SketchObj = static_cast(selection[1].getObject()); // check if the none sketch object is the support of the sketch if (selection[0].getObject() != SketchObj->Support.getValue()) { @@ -820,8 +816,7 @@ int SketchSelection::setUp() return -1; } // assume always a Part::Feature derived object as support - assert(selection[0].getObject()->getTypeId().isDerivedFrom( - Part::Feature::getClassTypeId())); + assert(selection[0].getObject()->isDerivedFrom()); SketchSubNames = selection[1].getSubNames(); SupportSubNames = selection[0].getSubNames(); } diff --git a/src/Mod/Sketcher/Gui/CommandSketcherBSpline.cpp b/src/Mod/Sketcher/Gui/CommandSketcherBSpline.cpp index e16b1448ef..3fa34fcbed 100644 --- a/src/Mod/Sketcher/Gui/CommandSketcherBSpline.cpp +++ b/src/Mod/Sketcher/Gui/CommandSketcherBSpline.cpp @@ -84,7 +84,7 @@ bool findBSplineAndKnotIndex(Sketcher::SketchObject* Obj, // TODO: what to do if multiple splines have the same first/last point? const Part::Geometry* geo = Obj->getGeometry(knotGeoId); - if (geo->getTypeId() == Part::GeomBSplineCurve::getClassTypeId()) { + if (geo->is()) { splineGeoId = knotGeoId; switch (knotPosId) { case Sketcher::PointPos::start: @@ -224,7 +224,7 @@ void CmdSketcherIncreaseDegree::activated(int iMsg) int GeoId = std::atoi(SubNames[i].substr(4, 4000).c_str()) - 1; const Part::Geometry* geo = Obj->getGeometry(GeoId); - if (geo->getTypeId() == Part::GeomBSplineCurve::getClassTypeId()) { + if (geo->is()) { Gui::cmdAppObjectArgs(selection[0].getObject(), "increaseBSplineDegree(%d) ", GeoId); @@ -303,7 +303,7 @@ void CmdSketcherDecreaseDegree::activated(int iMsg) int GeoId = std::atoi(SubNames[i].substr(4, 4000).c_str()) - 1; const Part::Geometry* geo = Obj->getGeometry(GeoId); - if (geo->getTypeId() == Part::GeomBSplineCurve::getClassTypeId()) { + if (geo->is()) { Gui::cmdAppObjectArgs(selection[0].getObject(), "decreaseBSplineDegree(%d) ", GeoId); @@ -928,7 +928,7 @@ void CmdSketcherInsertKnot::activated(int iMsg) int GeoId = std::atoi(SubNames[0].substr(4, 4000).c_str()) - 1; const Part::Geometry* geo = Obj->getGeometry(GeoId); - if (geo->getTypeId() == Part::GeomBSplineCurve::getClassTypeId()) { + if (geo->is()) { ActivateBSplineHandler(getActiveGuiDocument(), new DrawSketchHandlerBSplineInsertKnot(Obj, GeoId)); } diff --git a/src/Mod/Sketcher/Gui/CommandSketcherTools.cpp b/src/Mod/Sketcher/Gui/CommandSketcherTools.cpp index 0692c65983..21b6036bd5 100644 --- a/src/Mod/Sketcher/Gui/CommandSketcherTools.cpp +++ b/src/Mod/Sketcher/Gui/CommandSketcherTools.cpp @@ -794,11 +794,11 @@ void CmdSketcherRestoreInternalAlignmentGeometry::activated(int iMsg) auto noInternalGeo = [&Obj](const auto& GeoId) { const Part::Geometry* geo = Obj->getGeometry(GeoId); bool hasInternalGeo = geo - && (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()); + && (geo->is() + || geo->is() + || geo->is() + || geo->is() + || geo->is()); return !hasInternalGeo;// so it's removed }; @@ -930,7 +930,7 @@ void CmdSketcherSymmetry::activated(int iMsg) // reference can be external or non-external LastGeo = Obj->getGeometry(LastGeoId); // Only for supported types - if (LastGeo->getTypeId() == Part::GeomLineSegment::getClassTypeId()) + if (LastGeo->is()) lastgeotype = line; else lastgeotype = invalid; @@ -948,7 +948,7 @@ void CmdSketcherSymmetry::activated(int iMsg) Sketcher::PointPos PosId; Obj->getGeoVertexIndex(VtId, GeoId, PosId); - if (Obj->getGeometry(GeoId)->getTypeId() == Part::GeomPoint::getClassTypeId()) { + if (Obj->getGeometry(GeoId)->is()) { LastGeoId = GeoId; LastPointPos = Sketcher::PointPos::start; lastgeotype = point; @@ -1314,7 +1314,7 @@ void SketcherCopy::activate(SketcherCopy::Op op) int GeoId; Sketcher::PointPos PosId; Obj->getGeoVertexIndex(VtId, GeoId, PosId); - if (Obj->getGeometry(GeoId)->getTypeId() == Part::GeomPoint::getClassTypeId()) { + if (Obj->getGeometry(GeoId)->is()) { LastGeoId = GeoId; LastPointPos = Sketcher::PointPos::start; // points to copy @@ -1359,8 +1359,8 @@ void SketcherCopy::activate(SketcherCopy::Op op) // then make the start point of the last element the copy reference (if it exists, if not the // center point) if (LastPointPos == Sketcher::PointPos::none) { - if (LastGeo->getTypeId() == Part::GeomCircle::getClassTypeId() - || LastGeo->getTypeId() == Part::GeomEllipse::getClassTypeId()) { + if (LastGeo->is() + || LastGeo->is()) { LastPointPos = Sketcher::PointPos::mid; } else { @@ -1917,7 +1917,7 @@ void CmdSketcherRectangularArray::activated(int iMsg) int GeoId; Sketcher::PointPos PosId; Obj->getGeoVertexIndex(VtId, GeoId, PosId); - if (Obj->getGeometry(GeoId)->getTypeId() == Part::GeomPoint::getClassTypeId()) { + if (Obj->getGeometry(GeoId)->is()) { LastGeoId = GeoId; LastPointPos = Sketcher::PointPos::start; // points to copy @@ -1962,8 +1962,8 @@ void CmdSketcherRectangularArray::activated(int iMsg) // then make the start point of the last element the copy reference (if it exists, if not the // center point) if (LastPointPos == Sketcher::PointPos::none) { - if (LastGeo->getTypeId() == Part::GeomCircle::getClassTypeId() - || LastGeo->getTypeId() == Part::GeomEllipse::getClassTypeId()) { + if (LastGeo->is() + || LastGeo->is()) { LastPointPos = Sketcher::PointPos::mid; } else { @@ -2205,7 +2205,7 @@ void CmdSketcherRemoveAxesAlignment::activated(int iMsg) int GeoId; Sketcher::PointPos PosId; Obj->getGeoVertexIndex(VtId, GeoId, PosId); - if (Obj->getGeometry(GeoId)->getTypeId() == Part::GeomPoint::getClassTypeId()) { + if (Obj->getGeometry(GeoId)->is()) { LastGeoId = GeoId; // points to copy if (LastGeoId >= 0) { diff --git a/src/Mod/Sketcher/Gui/DrawSketchHandler.cpp b/src/Mod/Sketcher/Gui/DrawSketchHandler.cpp index c7e3fcdc75..62e8bc2a02 100644 --- a/src/Mod/Sketcher/Gui/DrawSketchHandler.cpp +++ b/src/Mod/Sketcher/Gui/DrawSketchHandler.cpp @@ -648,7 +648,7 @@ int DrawSketchHandler::seekAutoConstraint(std::vector& suggested // ensure geom exists in case object was called before preselection is updated if (geom) { GeoId = preSelCrv; - if (geom->getTypeId() == Part::GeomLineSegment::getClassTypeId()) { + if (geom->is()) { const Part::GeomLineSegment* line = static_cast(geom); hitShapeDir = line->getEndPoint() - line->getStartPoint(); } @@ -768,7 +768,7 @@ int DrawSketchHandler::seekAutoConstraint(std::vector& suggested for (std::vector::const_iterator it = geomlist.begin(); it != geomlist.end(); ++it, i++) { - if ((*it)->getTypeId() == Part::GeomCircle::getClassTypeId()) { + if ((*it)->is()) { const Part::GeomCircle* circle = static_cast((*it)); Base::Vector3d center = circle->getCenter(); @@ -790,7 +790,7 @@ int DrawSketchHandler::seekAutoConstraint(std::vector& suggested tangDeviation = projDist; } } - else if ((*it)->getTypeId() == Part::GeomEllipse::getClassTypeId()) { + else if ((*it)->is()) { const Part::GeomEllipse* ellipse = static_cast((*it)); @@ -819,7 +819,7 @@ int DrawSketchHandler::seekAutoConstraint(std::vector& suggested tangDeviation = error; } } - else if ((*it)->getTypeId() == Part::GeomArcOfCircle::getClassTypeId()) { + else if ((*it)->is()) { const Part::GeomArcOfCircle* arc = static_cast((*it)); Base::Vector3d center = arc->getCenter(); @@ -850,7 +850,7 @@ int DrawSketchHandler::seekAutoConstraint(std::vector& suggested } } } - else if ((*it)->getTypeId() == Part::GeomArcOfEllipse::getClassTypeId()) { + else if ((*it)->is()) { const Part::GeomArcOfEllipse* aoe = static_cast((*it)); Base::Vector3d center = aoe->getCenter(); @@ -993,8 +993,7 @@ void DrawSketchHandler::createAutoConstraints(const std::vector& // ellipse tangency support using construction elements (lines) if (geom1 && geom2 - && (geom1->getTypeId() == Part::GeomEllipse::getClassTypeId() - || geom2->getTypeId() == Part::GeomEllipse::getClassTypeId())) { + && (geom1->is() || geom2->is())) { if (geom1->getTypeId() != Part::GeomEllipse::getClassTypeId()) { std::swap(geoId1, geoId2); @@ -1004,10 +1003,9 @@ void DrawSketchHandler::createAutoConstraints(const std::vector& geom1 = Obj->getGeometry(geoId1); geom2 = Obj->getGeometry(geoId2); - if (geom2->getTypeId() == Part::GeomEllipse::getClassTypeId() - || geom2->getTypeId() == Part::GeomArcOfEllipse::getClassTypeId() - || geom2->getTypeId() == Part::GeomCircle::getClassTypeId() - || geom2->getTypeId() == Part::GeomArcOfCircle::getClassTypeId()) { + if (geom2->is() || geom2->is() + || geom2->is() + || geom2->is()) { // in all these cases an intermediate element is needed makeTangentToEllipseviaNewPoint( Obj, @@ -1021,8 +1019,8 @@ void DrawSketchHandler::createAutoConstraints(const std::vector& // arc of ellipse tangency support using external elements if (geom1 && geom2 - && (geom1->getTypeId() == Part::GeomArcOfEllipse::getClassTypeId() - || geom2->getTypeId() == Part::GeomArcOfEllipse::getClassTypeId())) { + && (geom1->is() + || geom2->is())) { if (geom1->getTypeId() != Part::GeomArcOfEllipse::getClassTypeId()) { std::swap(geoId1, geoId2); @@ -1032,9 +1030,8 @@ void DrawSketchHandler::createAutoConstraints(const std::vector& geom1 = Obj->getGeometry(geoId1); geom2 = Obj->getGeometry(geoId2); - if (geom2->getTypeId() == Part::GeomArcOfEllipse::getClassTypeId() - || geom2->getTypeId() == Part::GeomCircle::getClassTypeId() - || geom2->getTypeId() == Part::GeomArcOfCircle::getClassTypeId()) { + if (geom2->is() || geom2->is() + || geom2->is()) { // in all these cases an intermediate element is needed makeTangentToArcOfEllipseviaNewPoint( Obj, diff --git a/src/Mod/Sketcher/Gui/DrawSketchHandlerCarbonCopy.h b/src/Mod/Sketcher/Gui/DrawSketchHandlerCarbonCopy.h index 14c1b44243..aff63e1b25 100644 --- a/src/Mod/Sketcher/Gui/DrawSketchHandlerCarbonCopy.h +++ b/src/Mod/Sketcher/Gui/DrawSketchHandlerCarbonCopy.h @@ -147,7 +147,7 @@ public: throw Base::ValueError("Sketcher: Carbon Copy: Invalid object in selection"); } - if (obj->getTypeId() == Sketcher::SketchObject::getClassTypeId()) { + if (obj->is()) { try { Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "Create a carbon copy")); diff --git a/src/Mod/Sketcher/Gui/DrawSketchHandlerExtend.h b/src/Mod/Sketcher/Gui/DrawSketchHandlerExtend.h index da3c128a29..357b2636fc 100644 --- a/src/Mod/Sketcher/Gui/DrawSketchHandlerExtend.h +++ b/src/Mod/Sketcher/Gui/DrawSketchHandlerExtend.h @@ -60,8 +60,7 @@ public: int GeoId = std::atoi(element.substr(4, 4000).c_str()) - 1; Sketcher::SketchObject* Sketch = static_cast(object); const Part::Geometry* geom = Sketch->getGeometry(GeoId); - if (geom->getTypeId() == Part::GeomLineSegment::getClassTypeId() - || geom->getTypeId() == Part::GeomArcOfCircle::getClassTypeId()) { + if (geom->is() || geom->is()) { return true; } } @@ -105,7 +104,7 @@ public: Q_UNUSED(onSketchPos); if (Mode == STATUS_SEEK_Second) { const Part::Geometry* geom = sketchgui->getSketchObject()->getGeometry(BaseGeoId); - if (geom->getTypeId() == Part::GeomLineSegment::getClassTypeId()) { + if (geom->is()) { const Part::GeomLineSegment* lineSeg = static_cast(geom); // project point to the existing curve @@ -151,7 +150,7 @@ public: } drawEdit(EditCurve); } - else if (geom->getTypeId() == Part::GeomArcOfCircle::getClassTypeId()) { + else if (geom->is()) { const Part::GeomArcOfCircle* arc = static_cast(geom); Base::Vector3d center = arc->getCenter(); double radius = arc->getRadius(); @@ -246,7 +245,7 @@ public: BaseGeoId = getPreselectCurve(); if (BaseGeoId > -1) { const Part::Geometry* geom = sketchgui->getSketchObject()->getGeometry(BaseGeoId); - if (geom->getTypeId() == Part::GeomLineSegment::getClassTypeId()) { + if (geom->is()) { const Part::GeomLineSegment* seg = static_cast(geom); Base::Vector3d start3d = seg->getStartPoint(); @@ -258,7 +257,7 @@ public: ExtendFromStart = SavedExtendFromStart; Mode = STATUS_SEEK_Second; } - else if (geom->getTypeId() == Part::GeomArcOfCircle::getClassTypeId()) { + else if (geom->is()) { const Part::GeomArcOfCircle* arc = static_cast(geom); double start, end; diff --git a/src/Mod/Sketcher/Gui/DrawSketchHandlerExternal.h b/src/Mod/Sketcher/Gui/DrawSketchHandlerExternal.h index c15abdeecf..a6260b50d4 100644 --- a/src/Mod/Sketcher/Gui/DrawSketchHandlerExternal.h +++ b/src/Mod/Sketcher/Gui/DrawSketchHandlerExternal.h @@ -92,8 +92,7 @@ public: || (element.size() > 4 && element.substr(0, 4) == "Face")) { return true; } - if (pObj->getTypeId().isDerivedFrom(App::Plane::getClassTypeId()) - || pObj->getTypeId().isDerivedFrom(Part::Datum::getClassTypeId())) { + if (pObj->isDerivedFrom() || pObj->isDerivedFrom()) { return true; } return false; @@ -142,8 +141,7 @@ public: throw Base::ValueError("Sketcher: External geometry: Invalid object in selection"); } std::string subName(msg.pSubName); - if (obj->getTypeId().isDerivedFrom(App::Plane::getClassTypeId()) - || obj->getTypeId().isDerivedFrom(Part::Datum::getClassTypeId()) + if (obj->isDerivedFrom() || obj->isDerivedFrom() || (subName.size() > 4 && subName.substr(0, 4) == "Edge") || (subName.size() > 6 && subName.substr(0, 6) == "Vertex") || (subName.size() > 4 && subName.substr(0, 4) == "Face")) { diff --git a/src/Mod/Sketcher/Gui/DrawSketchHandlerFillet.h b/src/Mod/Sketcher/Gui/DrawSketchHandlerFillet.h index 3e6fb02bbf..a6174a67a4 100644 --- a/src/Mod/Sketcher/Gui/DrawSketchHandlerFillet.h +++ b/src/Mod/Sketcher/Gui/DrawSketchHandlerFillet.h @@ -56,7 +56,7 @@ public: int GeoId = std::atoi(element.substr(4, 4000).c_str()) - 1; Sketcher::SketchObject* Sketch = static_cast(object); const Part::Geometry* geom = Sketch->getGeometry(GeoId); - if (geom->getTypeId().isDerivedFrom(Part::GeomBoundedCurve::getClassTypeId())) { + if (geom->isDerivedFrom()) { return true; } } @@ -69,8 +69,7 @@ public: if (GeoIdList.size() == 2 && GeoIdList[0] >= 0 && GeoIdList[1] >= 0) { const Part::Geometry* geom1 = Sketch->getGeometry(GeoIdList[0]); const Part::Geometry* geom2 = Sketch->getGeometry(GeoIdList[1]); - if (geom1->getTypeId() == Part::GeomLineSegment::getClassTypeId() - && geom2->getTypeId() == Part::GeomLineSegment::getClassTypeId()) { + if (geom1->is() && geom2->is()) { return true; } } @@ -125,7 +124,7 @@ public: Sketcher::PointPos PosId = Sketcher::PointPos::none; sketchgui->getSketchObject()->getGeoVertexIndex(VtId, GeoId, PosId); const Part::Geometry* geom = sketchgui->getSketchObject()->getGeometry(GeoId); - if (geom->getTypeId() == Part::GeomLineSegment::getClassTypeId() + if (geom->is() && (PosId == Sketcher::PointPos::start || PosId == Sketcher::PointPos::end)) { // guess fillet radius @@ -143,8 +142,7 @@ public: sketchgui->getSketchObject()->getGeometry(GeoIdList[1]); construction = Sketcher::GeometryFacade::getConstruction(geom1) && Sketcher::GeometryFacade::getConstruction(geom2); - if (geom1->getTypeId() == Part::GeomLineSegment::getClassTypeId() - && geom2->getTypeId() == Part::GeomLineSegment::getClassTypeId()) { + if (geom1->is() && geom2->is()) { const Part::GeomLineSegment* lineSeg1 = static_cast(geom1); const Part::GeomLineSegment* lineSeg2 = @@ -205,7 +203,7 @@ public: int GeoId = getPreselectCurve(); if (GeoId > -1) { const Part::Geometry* geom = sketchgui->getSketchObject()->getGeometry(GeoId); - if (geom->getTypeId().isDerivedFrom(Part::GeomBoundedCurve::getClassTypeId())) { + if (geom->isDerivedFrom()) { if (Mode == STATUS_SEEK_First) { firstCurve = GeoId; firstPos = onSketchPos; @@ -233,8 +231,7 @@ public: double radius = 0; - if (geom->getTypeId() == Part::GeomLineSegment::getClassTypeId() - && geom1->getTypeId() == Part::GeomLineSegment::getClassTypeId()) { + if (geom->is() && geom1->is()) { // guess fillet radius const Part::GeomLineSegment* lineSeg1 = static_cast( diff --git a/src/Mod/Sketcher/Gui/DrawSketchHandlerLineSet.h b/src/Mod/Sketcher/Gui/DrawSketchHandlerLineSet.h index f025cacbc0..917718dbc0 100644 --- a/src/Mod/Sketcher/Gui/DrawSketchHandlerLineSet.h +++ b/src/Mod/Sketcher/Gui/DrawSketchHandlerLineSet.h @@ -117,8 +117,7 @@ public: if (SegmentMode == SEGMENT_MODE_Line) { switch (TransitionMode) { case TRANSITION_MODE_Free: - if (geom->getTypeId() - == Part::GeomArcOfCircle::getClassTypeId()) { // 3rd mode + if (geom->is()) { // 3rd mode SegmentMode = SEGMENT_MODE_Arc; TransitionMode = TRANSITION_MODE_Tangent; } @@ -127,7 +126,7 @@ public: } break; case TRANSITION_MODE_Perpendicular_L: // 2nd mode - if (geom->getTypeId() == Part::GeomArcOfCircle::getClassTypeId()) { + if (geom->is()) { TransitionMode = TRANSITION_MODE_Free; } else { @@ -135,8 +134,7 @@ public: } break; case TRANSITION_MODE_Tangent: - if (geom->getTypeId() - == Part::GeomArcOfCircle::getClassTypeId()) { // 1st mode + if (geom->is()) { // 1st mode TransitionMode = TRANSITION_MODE_Perpendicular_L; } else { // 3rd mode @@ -159,7 +157,7 @@ public: break; default: // 6th mode (Perpendicular_R) + unexpected mode SegmentMode = SEGMENT_MODE_Line; - if (geom->getTypeId() == Part::GeomArcOfCircle::getClassTypeId()) { + if (geom->is()) { TransitionMode = TRANSITION_MODE_Tangent; } else { @@ -342,15 +340,14 @@ public: if (sugConstr1[i].Type == Sketcher::Coincident) { const Part::Geometry* geom = sketchgui->getSketchObject()->getGeometry(sugConstr1[i].GeoId); - if ((geom->getTypeId() == Part::GeomLineSegment::getClassTypeId() - || geom->getTypeId() == Part::GeomArcOfCircle::getClassTypeId()) + if ((geom->is() || geom->is()) && (sugConstr1[i].PosId == Sketcher::PointPos::start || sugConstr1[i].PosId == Sketcher::PointPos::end)) { previousCurve = sugConstr1[i].GeoId; previousPosId = sugConstr1[i].PosId; updateTransitionData(previousCurve, previousPosId); // -> dirVec, EditCurve[0] - if (geom->getTypeId() == Part::GeomArcOfCircle::getClassTypeId()) { + if (geom->is()) { TransitionMode = TRANSITION_MODE_Tangent; SnapMode = SNAP_MODE_Free; } @@ -785,7 +782,7 @@ protected: // Use updated startPoint/endPoint as autoconstraints can modify the position const Part::Geometry* geom = sketchgui->getSketchObject()->getGeometry(GeoId); - if (geom->getTypeId() == Part::GeomLineSegment::getClassTypeId()) { + if (geom->is()) { const Part::GeomLineSegment* lineSeg = static_cast(geom); dirVec.Set(lineSeg->getEndPoint().x - lineSeg->getStartPoint().x, lineSeg->getEndPoint().y - lineSeg->getStartPoint().y, @@ -799,7 +796,7 @@ protected: EditCurve[0] = Base::Vector2d(lineSeg->getEndPoint().x, lineSeg->getEndPoint().y); } } - else if (geom->getTypeId() == Part::GeomArcOfCircle::getClassTypeId()) { + else if (geom->is()) { const Part::GeomArcOfCircle* arcSeg = static_cast(geom); if (PosId == Sketcher::PointPos::start) { EditCurve[0] = Base::Vector2d(arcSeg->getStartPoint(/*emulateCCW=*/true).x, diff --git a/src/Mod/Sketcher/Gui/DrawSketchHandlerSplitting.h b/src/Mod/Sketcher/Gui/DrawSketchHandlerSplitting.h index 59dfd499c1..fcab7f1113 100644 --- a/src/Mod/Sketcher/Gui/DrawSketchHandlerSplitting.h +++ b/src/Mod/Sketcher/Gui/DrawSketchHandlerSplitting.h @@ -57,11 +57,10 @@ public: int GeoId = std::atoi(element.substr(4, 4000).c_str()) - 1; Sketcher::SketchObject* Sketch = static_cast(object); const Part::Geometry* geom = Sketch->getGeometry(GeoId); - if (geom->getTypeId() == Part::GeomLineSegment::getClassTypeId() - || geom->getTypeId() == Part::GeomCircle::getClassTypeId() - || geom->getTypeId() == Part::GeomEllipse::getClassTypeId() + if (geom->is() || geom->is() + || geom->is() || geom->isDerivedFrom(Part::GeomArcOfConic::getClassTypeId()) - || geom->getTypeId() == Part::GeomBSplineCurve::getClassTypeId()) { + || geom->is()) { return true; } } @@ -107,11 +106,10 @@ public: int curveGeoId = getPreselectCurve(); if (curveGeoId >= 0) { const Part::Geometry* geom = sketchgui->getSketchObject()->getGeometry(curveGeoId); - if (geom->getTypeId() == Part::GeomLineSegment::getClassTypeId() - || geom->getTypeId() == Part::GeomCircle::getClassTypeId() - || geom->getTypeId() == Part::GeomEllipse::getClassTypeId() + if (geom->is() || geom->is() + || geom->is() || geom->isDerivedFrom(Part::GeomArcOfConic::getClassTypeId()) - || geom->getTypeId() == Part::GeomBSplineCurve::getClassTypeId()) { + || geom->is()) { GeoId = curveGeoId; } } diff --git a/src/Mod/Sketcher/Gui/DrawSketchHandlerTrimming.h b/src/Mod/Sketcher/Gui/DrawSketchHandlerTrimming.h index 8aa73ee176..39e11db84d 100644 --- a/src/Mod/Sketcher/Gui/DrawSketchHandlerTrimming.h +++ b/src/Mod/Sketcher/Gui/DrawSketchHandlerTrimming.h @@ -56,10 +56,8 @@ public: int GeoId = std::atoi(element.substr(4, 4000).c_str()) - 1; Sketcher::SketchObject* Sketch = static_cast(object); const Part::Geometry* geom = Sketch->getGeometry(GeoId); - if (geom->getTypeId().isDerivedFrom(Part::GeomTrimmedCurve::getClassTypeId()) - || geom->getTypeId() == Part::GeomCircle::getClassTypeId() - || geom->getTypeId() == Part::GeomEllipse::getClassTypeId() - || geom->getTypeId() == Part::GeomBSplineCurve::getClassTypeId()) { + if (geom->isDerivedFrom() || geom->is() + || geom->is() || geom->is()) { // We do not trim internal geometry of complex geometries if (Sketcher::GeometryFacade::isInternalType(geom, Sketcher::InternalType::None)) { return true; @@ -135,10 +133,8 @@ public: int GeoId = getPreselectCurve(); if (GeoId > -1) { const Part::Geometry* geom = sketchgui->getSketchObject()->getGeometry(GeoId); - if (geom->getTypeId().isDerivedFrom(Part::GeomTrimmedCurve::getClassTypeId()) - || geom->getTypeId() == Part::GeomCircle::getClassTypeId() - || geom->getTypeId() == Part::GeomEllipse::getClassTypeId() - || geom->getTypeId() == Part::GeomBSplineCurve::getClassTypeId()) { + if (geom->isDerivedFrom() || geom->is() + || geom->is() || geom->is()) { try { Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "Trim edge")); Gui::cmdAppObjectArgs(sketchgui->getObject(), diff --git a/src/Mod/Sketcher/Gui/EditModeConstraintCoinManager.cpp b/src/Mod/Sketcher/Gui/EditModeConstraintCoinManager.cpp index 8a0b18198c..4a106dc268 100644 --- a/src/Mod/Sketcher/Gui/EditModeConstraintCoinManager.cpp +++ b/src/Mod/Sketcher/Gui/EditModeConstraintCoinManager.cpp @@ -217,7 +217,7 @@ Restart: Base::Vector3d dir; Base::Vector3d norm; - if (geo->getTypeId() == Part::GeomLineSegment::getClassTypeId()) { + if (geo->is()) { const Part::GeomLineSegment* lineSeg = static_cast(geo); @@ -229,7 +229,7 @@ Restart: norm = Base::Vector3d(-dir.y, dir.x, 0); } - else if (geo->getTypeId() == Part::GeomBSplineCurve::getClassTypeId()) { + else if (geo->is()) { const Part::GeomBSplineCurve* bsp = static_cast(geo); midpos = Base::Vector3d(0, 0, 0); @@ -258,14 +258,14 @@ Restart: double angle, angleplus = 0.; // angle = rotation of object as a whole; angleplus // = arc angle (t parameter for ellipses). - if (geo->getTypeId() == Part::GeomCircle::getClassTypeId()) { + if (geo->is()) { const Part::GeomCircle* circle = static_cast(geo); ra = circle->getRadius(); angle = M_PI / 4; midpos = circle->getCenter(); } - else if (geo->getTypeId() == Part::GeomArcOfCircle::getClassTypeId()) { + else if (geo->is()) { const Part::GeomArcOfCircle* arc = static_cast(geo); ra = arc->getRadius(); @@ -274,7 +274,7 @@ Restart: angle = (startangle + endangle) / 2; midpos = arc->getCenter(); } - else if (geo->getTypeId() == Part::GeomEllipse::getClassTypeId()) { + else if (geo->is()) { const Part::GeomEllipse* ellipse = static_cast(geo); ra = ellipse->getMajorRadius(); @@ -284,7 +284,7 @@ Restart: angleplus = M_PI / 4; midpos = ellipse->getCenter(); } - else if (geo->getTypeId() == Part::GeomArcOfEllipse::getClassTypeId()) { + else if (geo->is()) { const Part::GeomArcOfEllipse* aoe = static_cast(geo); ra = aoe->getMajorRadius(); @@ -296,8 +296,7 @@ Restart: angleplus = (startangle + endangle) / 2; midpos = aoe->getCenter(); } - else if (geo->getTypeId() - == Part::GeomArcOfHyperbola::getClassTypeId()) { + else if (geo->is()) { const Part::GeomArcOfHyperbola* aoh = static_cast(geo); ra = aoh->getMajorRadius(); @@ -309,8 +308,7 @@ Restart: angleplus = (startangle + endangle) / 2; midpos = aoh->getCenter(); } - else if (geo->getTypeId() - == Part::GeomArcOfParabola::getClassTypeId()) { + else if (geo->is()) { const Part::GeomArcOfParabola* aop = static_cast(geo); ra = aop->getFocal(); @@ -325,9 +323,8 @@ Restart: break; } - if (geo->getTypeId() == Part::GeomEllipse::getClassTypeId() - || geo->getTypeId() == Part::GeomArcOfEllipse::getClassTypeId() - || geo->getTypeId() == Part::GeomArcOfHyperbola::getClassTypeId()) { + if (geo->is() || geo->is() + || geo->is()) { Base::Vector3d majDir, minDir, rvec; majDir = Base::Vector3d(cos(angle), @@ -467,7 +464,7 @@ Restart: } else if (Constr->FirstPos == Sketcher::PointPos::none) { - if (geo1->getTypeId() == Part::GeomLineSegment::getClassTypeId()) { + if (geo1->is()) { const Part::GeomLineSegment* lineSeg1 = static_cast(geo1); midpos1 = ((lineSeg1->getEndPoint() + lineSeg1->getStartPoint()) / 2); @@ -475,7 +472,7 @@ Restart: (lineSeg1->getEndPoint() - lineSeg1->getStartPoint()).Normalize(); norm1 = Base::Vector3d(-dir1.y, dir1.x, 0.); } - else if (geo1->getTypeId() == Part::GeomArcOfCircle::getClassTypeId()) { + else if (geo1->is()) { const Part::GeomArcOfCircle* arc = static_cast(geo1); double startangle, endangle, midangle; @@ -485,7 +482,7 @@ Restart: dir1 = Base::Vector3d(-norm1.y, norm1.x, 0); midpos1 = arc->getCenter() + arc->getRadius() * norm1; } - else if (geo1->getTypeId() == Part::GeomCircle::getClassTypeId()) { + else if (geo1->is()) { const Part::GeomCircle* circle = static_cast(geo1); norm1 = Base::Vector3d(cos(M_PI / 4), sin(M_PI / 4), 0); @@ -496,7 +493,7 @@ Restart: break; } - if (geo2->getTypeId() == Part::GeomLineSegment::getClassTypeId()) { + if (geo2->is()) { const Part::GeomLineSegment* lineSeg2 = static_cast(geo2); midpos2 = ((lineSeg2->getEndPoint() + lineSeg2->getStartPoint()) / 2); @@ -504,7 +501,7 @@ Restart: (lineSeg2->getEndPoint() - lineSeg2->getStartPoint()).Normalize(); norm2 = Base::Vector3d(-dir2.y, dir2.x, 0.); } - else if (geo2->getTypeId() == Part::GeomArcOfCircle::getClassTypeId()) { + else if (geo2->is()) { const Part::GeomArcOfCircle* arc = static_cast(geo2); double startangle, endangle, midangle; @@ -514,7 +511,7 @@ Restart: dir2 = Base::Vector3d(-norm2.y, norm2.x, 0); midpos2 = arc->getCenter() + arc->getRadius() * norm2; } - else if (geo2->getTypeId() == Part::GeomCircle::getClassTypeId()) { + else if (geo2->is()) { const Part::GeomCircle* circle = static_cast(geo2); norm2 = Base::Vector3d(cos(M_PI / 4), sin(M_PI / 4), 0); @@ -576,14 +573,14 @@ Restart: angle2plus = 0.; // angle1 = rotation of object as a whole; angle1plus = arc // angle (t parameter for ellipses). - if (geo1->getTypeId() == Part::GeomCircle::getClassTypeId()) { + if (geo1->is()) { const Part::GeomCircle* circle = static_cast(geo1); r1a = circle->getRadius(); angle1 = M_PI / 4; midpos1 = circle->getCenter(); } - else if (geo1->getTypeId() == Part::GeomArcOfCircle::getClassTypeId()) { + else if (geo1->is()) { const Part::GeomArcOfCircle* arc = static_cast(geo1); r1a = arc->getRadius(); @@ -592,7 +589,7 @@ Restart: angle1 = (startangle + endangle) / 2; midpos1 = arc->getCenter(); } - else if (geo1->getTypeId() == Part::GeomEllipse::getClassTypeId()) { + else if (geo1->is()) { const Part::GeomEllipse* ellipse = static_cast(geo1); r1a = ellipse->getMajorRadius(); @@ -602,8 +599,7 @@ Restart: angle1plus = M_PI / 4; midpos1 = ellipse->getCenter(); } - else if (geo1->getTypeId() - == Part::GeomArcOfEllipse::getClassTypeId()) { + else if (geo1->is()) { const Part::GeomArcOfEllipse* aoe = static_cast(geo1); r1a = aoe->getMajorRadius(); @@ -615,8 +611,7 @@ Restart: angle1plus = (startangle + endangle) / 2; midpos1 = aoe->getCenter(); } - else if (geo1->getTypeId() - == Part::GeomArcOfHyperbola::getClassTypeId()) { + else if (geo1->is()) { const Part::GeomArcOfHyperbola* aoh = static_cast(geo1); r1a = aoh->getMajorRadius(); @@ -628,8 +623,7 @@ Restart: angle1plus = (startangle + endangle) / 2; midpos1 = aoh->getCenter(); } - else if (geo1->getTypeId() - == Part::GeomArcOfParabola::getClassTypeId()) { + else if (geo1->is()) { const Part::GeomArcOfParabola* aop = static_cast(geo1); r1a = aop->getFocal(); @@ -644,14 +638,14 @@ Restart: break; } - if (geo2->getTypeId() == Part::GeomCircle::getClassTypeId()) { + if (geo2->is()) { const Part::GeomCircle* circle = static_cast(geo2); r2a = circle->getRadius(); angle2 = M_PI / 4; midpos2 = circle->getCenter(); } - else if (geo2->getTypeId() == Part::GeomArcOfCircle::getClassTypeId()) { + else if (geo2->is()) { const Part::GeomArcOfCircle* arc = static_cast(geo2); r2a = arc->getRadius(); @@ -660,7 +654,7 @@ Restart: angle2 = (startangle + endangle) / 2; midpos2 = arc->getCenter(); } - else if (geo2->getTypeId() == Part::GeomEllipse::getClassTypeId()) { + else if (geo2->is()) { const Part::GeomEllipse* ellipse = static_cast(geo2); r2a = ellipse->getMajorRadius(); @@ -670,8 +664,7 @@ Restart: angle2plus = M_PI / 4; midpos2 = ellipse->getCenter(); } - else if (geo2->getTypeId() - == Part::GeomArcOfEllipse::getClassTypeId()) { + else if (geo2->is()) { const Part::GeomArcOfEllipse* aoe = static_cast(geo2); r2a = aoe->getMajorRadius(); @@ -683,8 +676,7 @@ Restart: angle2plus = (startangle + endangle) / 2; midpos2 = aoe->getCenter(); } - else if (geo2->getTypeId() - == Part::GeomArcOfHyperbola::getClassTypeId()) { + else if (geo2->is()) { const Part::GeomArcOfHyperbola* aoh = static_cast(geo2); r2a = aoh->getMajorRadius(); @@ -696,8 +688,7 @@ Restart: angle2plus = (startangle + endangle) / 2; midpos2 = aoh->getCenter(); } - else if (geo2->getTypeId() - == Part::GeomArcOfParabola::getClassTypeId()) { + else if (geo2->is()) { const Part::GeomArcOfParabola* aop = static_cast(geo2); r2a = aop->getFocal(); @@ -712,8 +703,7 @@ Restart: break; } - if (geo1->getTypeId() == Part::GeomEllipse::getClassTypeId() - || geo1->getTypeId() == Part::GeomArcOfEllipse::getClassTypeId() + if (geo1->is() || geo1->is() || geo1->getTypeId() == Part::GeomArcOfHyperbola::getClassTypeId()) { @@ -741,8 +731,7 @@ Restart: } - if (geo2->getTypeId() == Part::GeomEllipse::getClassTypeId() - || geo2->getTypeId() == Part::GeomArcOfEllipse::getClassTypeId() + if (geo2->is() || geo2->is() || geo2->getTypeId() == Part::GeomArcOfHyperbola::getClassTypeId()) { @@ -833,7 +822,7 @@ Restart: else if (Constr->Second != GeoEnum::GeoUndef) { const Part::Geometry* geo = geolistfacade.getGeometryFromGeoId(Constr->Second); - if (geo->getTypeId() == Part::GeomLineSegment::getClassTypeId()) { + if (geo->is()) { const Part::GeomLineSegment* lineSeg = static_cast(geo); Base::Vector3d l2p1 = lineSeg->getStartPoint(); @@ -848,9 +837,8 @@ Restart: else { const Part::Geometry* geo1 = geolistfacade.getGeometryFromGeoId(Constr->First); - if (geo1->getTypeId() - == Part::GeomCircle::getClassTypeId()) { // circle to line - // distance + if (geo1->is()) { // circle to line + // distance const Part::GeomCircle* circleSeg = static_cast(geo1); Base::Vector3d ct = circleSeg->getCenter(); @@ -865,12 +853,11 @@ Restart: } } } - else if (geo->getTypeId() == Part::GeomCircle::getClassTypeId()) { + else if (geo->is()) { const Part::Geometry* geo1 = geolistfacade.getGeometryFromGeoId(Constr->First); - if (geo1->getTypeId() - == Part::GeomCircle::getClassTypeId()) { // circle to circle - // distance + if (geo1->is()) { // circle to circle + // distance const Part::GeomCircle* circleSeg1 = static_cast(geo1); auto circleSeg2 = static_cast(geo); @@ -895,8 +882,7 @@ Restart: else if (Constr->First != GeoEnum::GeoUndef) { const Part::Geometry* geo = geolistfacade.getGeometryFromGeoId(Constr->First); - if (geo->getTypeId() - == Part::GeomLineSegment::getClassTypeId()) { // segment distance + if (geo->is()) { // segment distance const Part::GeomLineSegment* lineSeg = static_cast(geo); pnt1 = lineSeg->getStartPoint(); @@ -1009,8 +995,8 @@ Restart: const Part::Geometry* geo2 = geolistfacade.getGeometryFromGeoId(Constr->Second); - if (geo1->getTypeId() == Part::GeomLineSegment::getClassTypeId() - && geo2->getTypeId() == Part::GeomLineSegment::getClassTypeId()) { + if (geo1->is() + && geo2->is()) { const Part::GeomLineSegment* lineSeg1 = static_cast(geo1); const Part::GeomLineSegment* lineSeg2 = @@ -1059,17 +1045,17 @@ Restart: break; } - else if (geo2->getTypeId() == Part::GeomLineSegment::getClassTypeId()) { + else if (geo2->is()) { std::swap(geo1, geo2); } - if (geo1->getTypeId() == Part::GeomLineSegment::getClassTypeId()) { + if (geo1->is()) { const Part::GeomLineSegment* lineSeg = static_cast(geo1); Base::Vector3d dir = (lineSeg->getEndPoint() - lineSeg->getStartPoint()).Normalize(); Base::Vector3d norm(-dir.y, dir.x, 0); - if (geo2->getTypeId() == Part::GeomCircle::getClassTypeId()) { + if (geo2->is()) { const Part::GeomCircle* circle = static_cast(geo2); // tangency between a line and a circle @@ -1079,12 +1065,11 @@ Restart: pos = lineSeg->getStartPoint() + dir * length; relPos = norm * 1; // TODO Huh? } - else if (geo2->getTypeId() == Part::GeomEllipse::getClassTypeId() - || geo2->getTypeId() - == Part::GeomArcOfEllipse::getClassTypeId()) { + else if (geo2->is() + || geo2->is()) { Base::Vector3d center; - if (geo2->getTypeId() == Part::GeomEllipse::getClassTypeId()) { + if (geo2->is()) { const Part::GeomEllipse* ellipse = static_cast(geo2); center = ellipse->getCenter(); @@ -1101,7 +1086,7 @@ Restart: pos = lineSeg->getStartPoint() + dir * length; relPos = norm * 1; } - else if (geo2->getTypeId() == Part::GeomArcOfCircle::getClassTypeId()) { + else if (geo2->is()) { const Part::GeomArcOfCircle* arc = static_cast(geo2); // tangency between a line and an arc @@ -1112,8 +1097,7 @@ Restart: } } - if (geo1->getTypeId() == Part::GeomCircle::getClassTypeId() - && geo2->getTypeId() == Part::GeomCircle::getClassTypeId()) { + if (geo1->is() && geo2->is()) { const Part::GeomCircle* circle1 = static_cast(geo1); const Part::GeomCircle* circle2 = @@ -1124,12 +1108,11 @@ Restart: pos = circle1->getCenter() + dir * circle1->getRadius(); relPos = dir * 1; } - else if (geo2->getTypeId() == Part::GeomCircle::getClassTypeId()) { + else if (geo2->is()) { std::swap(geo1, geo2); } - if (geo1->getTypeId() == Part::GeomCircle::getClassTypeId() - && geo2->getTypeId() == Part::GeomArcOfCircle::getClassTypeId()) { + if (geo1->is() && geo2->is()) { const Part::GeomCircle* circle = static_cast(geo1); const Part::GeomArcOfCircle* arc = @@ -1140,8 +1123,8 @@ Restart: pos = circle->getCenter() + dir * circle->getRadius(); relPos = dir * 1; } - else if (geo1->getTypeId() == Part::GeomArcOfCircle::getClassTypeId() - && geo2->getTypeId() == Part::GeomArcOfCircle::getClassTypeId()) { + else if (geo1->is() + && geo2->is()) { const Part::GeomArcOfCircle* arc1 = static_cast(geo1); const Part::GeomArcOfCircle* arc2 = @@ -1284,7 +1267,7 @@ Restart: else if (Constr->First != GeoEnum::GeoUndef) { const Part::Geometry* geo = geolistfacade.getGeometryFromGeoId(Constr->First); - if (geo->getTypeId() == Part::GeomLineSegment::getClassTypeId()) { + if (geo->is()) { const Part::GeomLineSegment* lineSeg = static_cast(geo); p0 = Base::convertTo( @@ -1295,7 +1278,7 @@ Restart: range = atan2(dir.y, dir.x); endangle = startangle + range; } - else if (geo->getTypeId() == Part::GeomArcOfCircle::getClassTypeId()) { + else if (geo->is()) { const Part::GeomArcOfCircle* arc = static_cast(geo); p0 = Base::convertTo(arc->getCenter()); @@ -1336,7 +1319,7 @@ Restart: const Part::Geometry* geo = geolistfacade.getGeometryFromGeoId(Constr->First); - if (geo->getTypeId() == Part::GeomArcOfCircle::getClassTypeId()) { + if (geo->is()) { const Part::GeomArcOfCircle* arc = static_cast(geo); double radius = arc->getRadius(); @@ -1350,7 +1333,7 @@ Restart: pnt1 = center - radius * Base::Vector3d(cos(angle), sin(angle), 0.); pnt2 = center + radius * Base::Vector3d(cos(angle), sin(angle), 0.); } - else if (geo->getTypeId() == Part::GeomCircle::getClassTypeId()) { + else if (geo->is()) { const Part::GeomCircle* circle = static_cast(geo); double radius = circle->getRadius(); @@ -1402,7 +1385,7 @@ Restart: const Part::Geometry* geo = geolistfacade.getGeometryFromGeoId(Constr->First); - if (geo->getTypeId() == Part::GeomArcOfCircle::getClassTypeId()) { + if (geo->is()) { const Part::GeomArcOfCircle* arc = static_cast(geo); double radius = arc->getRadius(); @@ -1415,7 +1398,7 @@ Restart: pnt1 = arc->getCenter(); pnt2 = pnt1 + radius * Base::Vector3d(cos(angle), sin(angle), 0.); } - else if (geo->getTypeId() == Part::GeomCircle::getClassTypeId()) { + else if (geo->is()) { const Part::GeomCircle* circle = static_cast(geo); auto gf = GeometryFacade::getFacade(geo); @@ -1864,8 +1847,8 @@ void EditModeConstraintCoinManager::rebuildConstraintNodes( "EditModeConstraintCoinManager", "Tangent constraint references non-existing geometry\n"); } - else if (geo1->getTypeId() == Part::GeomLineSegment::getClassTypeId() - && geo2->getTypeId() == Part::GeomLineSegment::getClassTypeId()) { + else if (geo1->is() + && geo2->is()) { // #define CONSTRAINT_SEPARATOR_INDEX_SECOND_TRANSLATION 4 sep->addChild(new SoZoomTranslation()); // #define CONSTRAINT_SEPARATOR_INDEX_SECOND_ICON 5 @@ -2217,8 +2200,8 @@ void EditModeConstraintCoinManager::drawConstraintIcons(const GeoListFacade& geo case Tangent: { // second icon is available only for colinear line segments const Part::Geometry* geo1 = geolistfacade.getGeometryFromGeoId(constraint->First); const Part::Geometry* geo2 = geolistfacade.getGeometryFromGeoId(constraint->Second); - if (geo1 && geo1->getTypeId() == Part::GeomLineSegment::getClassTypeId() && geo2 - && geo2->getTypeId() == Part::GeomLineSegment::getClassTypeId()) { + if (geo1 && geo1->is() && geo2 + && geo2->is()) { multipleIcons = true; } } break; diff --git a/src/Mod/Sketcher/Gui/EditModeInformationOverlayCoinConverter.cpp b/src/Mod/Sketcher/Gui/EditModeInformationOverlayCoinConverter.cpp index 263cc4c423..9b106e45b8 100644 --- a/src/Mod/Sketcher/Gui/EditModeInformationOverlayCoinConverter.cpp +++ b/src/Mod/Sketcher/Gui/EditModeInformationOverlayCoinConverter.cpp @@ -60,7 +60,7 @@ EditModeInformationOverlayCoinConverter::EditModeInformationOverlayCoinConverter void EditModeInformationOverlayCoinConverter::convert(const Part::Geometry* geometry, int geoid) { - if (geometry->getTypeId() == Part::GeomBSplineCurve::getClassTypeId()) { + if (geometry->is()) { // at this point all calculations relate to BSplineCurves calculate(geometry, geoid); calculate(geometry, geoid); @@ -74,7 +74,7 @@ void EditModeInformationOverlayCoinConverter::convert(const Part::Geometry* geom addUpdateNode(knotMultiplicity); addUpdateNode(poleWeights); } - else if (geometry->getTypeId() == Part::GeomArcOfCircle::getClassTypeId()) { + else if (geometry->is()) { // at this point all calculations relate to ArcOfCircle calculate(geometry, geoid); addUpdateNode(circleHelper); diff --git a/src/Mod/Sketcher/Gui/PropertyConstraintListItem.cpp b/src/Mod/Sketcher/Gui/PropertyConstraintListItem.cpp index d2179d90d1..ba9a1ebca0 100644 --- a/src/Mod/Sketcher/Gui/PropertyConstraintListItem.cpp +++ b/src/Mod/Sketcher/Gui/PropertyConstraintListItem.cpp @@ -147,7 +147,7 @@ void PropertyConstraintListItem::assignProperty(const App::Property* prop) // Hint: When renaming a constraint that was unnamed before then it can happen that // a constraint appears twice in the property editor, one time in this group and a // second time inside the Unnamed group - if (!prop->getTypeId().isDerivedFrom(Sketcher::PropertyConstraintList::getClassTypeId())) { + if (!prop->isDerivedFrom()) { return; } @@ -240,8 +240,7 @@ void PropertyConstraintListItem::assignProperty(const App::Property* prop) QVariant PropertyConstraintListItem::value(const App::Property* prop) const { - assert(prop - && prop->getTypeId().isDerivedFrom(Sketcher::PropertyConstraintList::getClassTypeId())); + assert(prop && prop->isDerivedFrom()); PropertyConstraintListItem* self = const_cast(this); diff --git a/src/Mod/Sketcher/Gui/SnapManager.cpp b/src/Mod/Sketcher/Gui/SnapManager.cpp index 02c3a6cc55..399688add4 100644 --- a/src/Mod/Sketcher/Gui/SnapManager.cpp +++ b/src/Mod/Sketcher/Gui/SnapManager.cpp @@ -283,13 +283,13 @@ bool SnapManager::snapToObject(double& x, double& y) } // If it is a line, then we check if we need to snap to the middle. - if (geo->getTypeId() == Part::GeomLineSegment::getClassTypeId()) { + if (geo->is()) { const Part::GeomLineSegment* line = static_cast(geo); snapToLineMiddle(pointToOverride, line); } // If it is an arc, then we check if we need to snap to the middle (not the center). - if (geo->getTypeId() == Part::GeomArcOfCircle::getClassTypeId()) { + if (geo->is()) { const Part::GeomArcOfCircle* arc = static_cast(geo); snapToArcMiddle(pointToOverride, arc); } diff --git a/src/Mod/Sketcher/Gui/TaskSketcherValidation.cpp b/src/Mod/Sketcher/Gui/TaskSketcherValidation.cpp index 0db1bb55d6..4718f260af 100644 --- a/src/Mod/Sketcher/Gui/TaskSketcherValidation.cpp +++ b/src/Mod/Sketcher/Gui/TaskSketcherValidation.cpp @@ -281,7 +281,7 @@ void SketcherValidation::onFindReversedClicked() Part::Geometry* g = geom[i]; // only arcs of circles need to be repaired. Arcs of ellipse were so broken there should be // nothing to repair from. - if (g->getTypeId() == Part::GeomArcOfCircle::getClassTypeId()) { + if (g->is()) { const Part::GeomArcOfCircle* segm = static_cast(g); if (segm->isReversed()) { points.push_back(segm->getStartPoint(/*emulateCCW=*/true)); diff --git a/src/Mod/Sketcher/Gui/Utils.cpp b/src/Mod/Sketcher/Gui/Utils.cpp index 8f8bfb0c77..c6f24d716c 100644 --- a/src/Mod/Sketcher/Gui/Utils.cpp +++ b/src/Mod/Sketcher/Gui/Utils.cpp @@ -50,47 +50,47 @@ using namespace Sketcher; bool Sketcher::isCircle(const Part::Geometry& geom) { - return geom.getTypeId() == Part::GeomCircle::getClassTypeId(); + return geom.is(); } bool Sketcher::isArcOfCircle(const Part::Geometry& geom) { - return geom.getTypeId() == Part::GeomArcOfCircle::getClassTypeId(); + return geom.is(); } bool Sketcher::isEllipse(const Part::Geometry& geom) { - return geom.getTypeId() == Part::GeomEllipse::getClassTypeId(); + return geom.is(); } bool Sketcher::isArcOfEllipse(const Part::Geometry& geom) { - return geom.getTypeId() == Part::GeomArcOfEllipse::getClassTypeId(); + return geom.is(); } bool Sketcher::isLineSegment(const Part::Geometry& geom) { - return geom.getTypeId() == Part::GeomLineSegment::getClassTypeId(); + return geom.is(); } bool Sketcher::isArcOfHyperbola(const Part::Geometry& geom) { - return geom.getTypeId() == Part::GeomArcOfHyperbola::getClassTypeId(); + return geom.is(); } bool Sketcher::isArcOfParabola(const Part::Geometry& geom) { - return geom.getTypeId() == Part::GeomArcOfParabola::getClassTypeId(); + return geom.is(); } bool Sketcher::isBSplineCurve(const Part::Geometry& geom) { - return geom.getTypeId() == Part::GeomBSplineCurve::getClassTypeId(); + return geom.is(); } bool Sketcher::isPoint(const Part::Geometry& geom) { - return geom.getTypeId() == Part::GeomPoint::getClassTypeId(); + return geom.is(); } bool SketcherGui::tryAutoRecompute(Sketcher::SketchObject* obj, bool& autoremoveredundants) @@ -219,7 +219,7 @@ std::vector SketcherGui::getGeoIdsOfEdgesFromNames(const Sketcher::SketchOb Sketcher::PointPos PosId; Obj->getGeoVertexIndex(VtId, GeoId, PosId); const Part::Geometry* geo = Obj->getGeometry(GeoId); - if (geo->getTypeId() == Part::GeomPoint::getClassTypeId()) { + if (geo->is()) { geoids.push_back(GeoId); } } @@ -295,7 +295,7 @@ bool SketcherGui::isSimpleVertex(const Sketcher::SketchObject* Obj, int GeoId, P return true; } const Part::Geometry* geo = Obj->getGeometry(GeoId); - if (geo->getTypeId() == Part::GeomPoint::getClassTypeId()) { + if (geo->is()) { return true; } else if (PosId == Sketcher::PointPos::mid) { @@ -323,7 +323,7 @@ bool SketcherGui::isBsplineKnotOrEndPoint(const Sketcher::SketchObject* Obj, const Part::Geometry* geo = Obj->getGeometry(GeoId); // end points of B-Splines are also knots - if (geo->getTypeId() == Part::GeomBSplineCurve::getClassTypeId() + if (geo->is() && (PosId == Sketcher::PointPos::start || PosId == Sketcher::PointPos::end)) { return true; } @@ -349,7 +349,7 @@ bool SketcherGui::IsPointAlreadyOnCurve(int GeoIdCurve, // implemented. (Ajinkya) if (isBsplineKnot(Obj, GeoIdPoint)) { const Part::Geometry* geoCurve = Obj->getGeometry(GeoIdCurve); - if (geoCurve->getTypeId() == Part::GeomBSplineCurve::getClassTypeId()) { + if (geoCurve->is()) { const std::vector& constraints = Obj->Constraints.getValues(); for (const auto& constraint : constraints) { if (constraint->Type == Sketcher::ConstraintType::InternalAlignment diff --git a/src/Mod/Sketcher/Gui/ViewProviderPython.cpp b/src/Mod/Sketcher/Gui/ViewProviderPython.cpp index 1200c73cfc..1e9cb8c0ef 100644 --- a/src/Mod/Sketcher/Gui/ViewProviderPython.cpp +++ b/src/Mod/Sketcher/Gui/ViewProviderPython.cpp @@ -58,13 +58,12 @@ void ViewProviderCustom::onChanged(const App::Property* prop) void ViewProviderCustom::updateData(const App::Property* prop) { - if (prop->getTypeId().isDerivedFrom(App::PropertyComplexGeoData::getClassTypeId())) { + if (prop->isDerivedFrom()) { std::map::iterator it = propView.find(prop); if (it == propView.end()) { Gui::ViewProvider* view = Gui::ViewProviderBuilder::create(prop->getTypeId()); if (view) { - if (view->getTypeId().isDerivedFrom( - Gui::ViewProviderDocumentObject::getClassTypeId())) { + if (view->isDerivedFrom()) { static_cast(view)->attach(this->getObject()); static_cast(view)->setDisplayMode( this->getActiveDisplayMode().c_str()); diff --git a/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp b/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp index 8712ff1489..d0910a8f58 100644 --- a/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp +++ b/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp @@ -1056,14 +1056,14 @@ bool ViewProviderSketch::mouseButtonPressed(int Button, bool pressed, const SbVe case STATUS_SKETCH_DragCurve: if (drag.isDragCurveValid()) { const Part::Geometry* geo = getSketchObject()->getGeometry(drag.DragCurve); - if (geo->getTypeId() == Part::GeomLineSegment::getClassTypeId() - || geo->getTypeId() == Part::GeomArcOfCircle::getClassTypeId() - || geo->getTypeId() == Part::GeomCircle::getClassTypeId() - || geo->getTypeId() == Part::GeomEllipse::getClassTypeId() - || geo->getTypeId() == Part::GeomArcOfEllipse::getClassTypeId() - || geo->getTypeId() == Part::GeomArcOfParabola::getClassTypeId() - || geo->getTypeId() == Part::GeomArcOfHyperbola::getClassTypeId() - || geo->getTypeId() == Part::GeomBSplineCurve::getClassTypeId()) { + if (geo->is() + || geo->is() + || geo->is() + || geo->is() + || geo->is() + || geo->is() + || geo->is() + || geo->is()) { getDocument()->openCommand(QT_TRANSLATE_NOOP("Command", "Drag Curve")); auto geo = getSketchObject()->getGeometry(drag.DragCurve); @@ -1492,8 +1492,8 @@ bool ViewProviderSketch::mouseMove(const SbVec2s& cursorPos, Gui::View3DInventor } } - if (geo->getTypeId() == Part::GeomLineSegment::getClassTypeId() - || geo->getTypeId() == Part::GeomBSplineCurve::getClassTypeId()) { + if (geo->is() + || geo->is()) { drag.relative = true; // Since the cursor moved from where it was clicked, and this is a relative @@ -1508,7 +1508,7 @@ bool ViewProviderSketch::mouseMove(const SbVec2s& cursorPos, Gui::View3DInventor drag.resetVector(); } - if (geo->getTypeId() == Part::GeomBSplineCurve::getClassTypeId()) { + if (geo->is()) { getSketchObject()->initTemporaryBSplinePieceMove( drag.DragCurve, Sketcher::PointPos::none, @@ -1662,7 +1662,7 @@ void ViewProviderSketch::moveConstraint(int constNum, const Base::Vector2d& toPo else if (Constr->Second != GeoEnum::GeoUndef) { p1 = getSolvedSketch().getPoint(Constr->First, Constr->FirstPos); const Part::Geometry* geo = GeoList::getGeometryFromGeoId(geomlist, Constr->Second); - if (geo->getTypeId() == Part::GeomLineSegment::getClassTypeId()) { + if (geo->is()) { const Part::GeomLineSegment* lineSeg = static_cast(geo); Base::Vector3d l2p1 = lineSeg->getStartPoint(); @@ -1686,10 +1686,9 @@ void ViewProviderSketch::moveConstraint(int constNum, const Base::Vector2d& toPo p2 = ct + dir * radius; } } - else if (geo->getTypeId() - == Part::GeomCircle::getClassTypeId()) {// circle to circle distance + else if (geo->is()) {// circle to circle distance const Part::Geometry* geo1 = GeoList::getGeometryFromGeoId(geomlist, Constr->First); - if (geo1->getTypeId() == Part::GeomCircle::getClassTypeId()) { + if (geo1->is()) { const Part::GeomCircle* circleSeg1 = static_cast(geo1); const Part::GeomCircle* circleSeg2 = static_cast(geo); GetCirclesMinimalDistance(circleSeg1, circleSeg2, p1, p2); @@ -1709,13 +1708,13 @@ void ViewProviderSketch::moveConstraint(int constNum, const Base::Vector2d& toPo } else if (Constr->First != GeoEnum::GeoUndef) { const Part::Geometry* geo = GeoList::getGeometryFromGeoId(geomlist, Constr->First); - if (geo->getTypeId() == Part::GeomLineSegment::getClassTypeId()) { + if (geo->is()) { const Part::GeomLineSegment* lineSeg = static_cast(geo); p1 = lineSeg->getStartPoint(); p2 = lineSeg->getEndPoint(); } - else if (geo->getTypeId() == Part::GeomArcOfCircle::getClassTypeId()) { + else if (geo->is()) { const Part::GeomArcOfCircle* arc = static_cast(geo); double radius = arc->getRadius(); Base::Vector3d center = arc->getCenter(); @@ -1737,7 +1736,7 @@ void ViewProviderSketch::moveConstraint(int constNum, const Base::Vector2d& toPo p2 = center + radius * Base::Vector3d(cos(angle), sin(angle), 0.); } - else if (geo->getTypeId() == Part::GeomCircle::getClassTypeId()) { + else if (geo->is()) { const Part::GeomCircle* circle = static_cast(geo); double radius = circle->getRadius(); Base::Vector3d center = circle->getCenter(); @@ -2318,7 +2317,7 @@ void ViewProviderSketch::doBoxSelection(const SbVec2s& startPos, const SbVec2s& if (GeoId >= intGeoCount) GeoId = -extGeoCount; - if ((*it)->getTypeId() == Part::GeomPoint::getClassTypeId()) { + if ((*it)->is()) { // ----- Check if single point lies inside box selection -----/ const Part::GeomPoint* point = static_cast(*it); Plm.multVec(point->getPoint(), pnt0); @@ -2331,7 +2330,7 @@ void ViewProviderSketch::doBoxSelection(const SbVec2s& startPos, const SbVec2s& addSelection2(ss.str()); } } - else if ((*it)->getTypeId() == Part::GeomLineSegment::getClassTypeId()) { + else if ((*it)->is()) { // ----- Check if line segment lies inside box selection -----/ const Part::GeomLineSegment* lineSeg = static_cast(*it); Plm.multVec(lineSeg->getStartPoint(), pnt1); @@ -2373,7 +2372,7 @@ void ViewProviderSketch::doBoxSelection(const SbVec2s& startPos, const SbVec2s& } } } - else if ((*it)->getTypeId() == Part::GeomCircle::getClassTypeId()) { + else if ((*it)->is()) { // ----- Check if circle lies inside box selection -----/ /// TODO: Make it impossible to miss the circle if it's big and the selection pretty /// thin. @@ -2425,7 +2424,7 @@ void ViewProviderSketch::doBoxSelection(const SbVec2s& startPos, const SbVec2s& } } } - else if ((*it)->getTypeId() == Part::GeomEllipse::getClassTypeId()) { + else if ((*it)->is()) { // ----- Check if ellipse lies inside box selection -----/ const Part::GeomEllipse* ellipse = static_cast(*it); pnt0 = ellipse->getCenter(); @@ -2477,7 +2476,7 @@ void ViewProviderSketch::doBoxSelection(const SbVec2s& startPos, const SbVec2s& } } } - else if ((*it)->getTypeId() == Part::GeomArcOfCircle::getClassTypeId()) { + else if ((*it)->is()) { // Check if arc lies inside box selection const Part::GeomArcOfCircle* aoc = static_cast(*it); @@ -2556,7 +2555,7 @@ void ViewProviderSketch::doBoxSelection(const SbVec2s& startPos, const SbVec2s& addSelection2(ss.str()); } } - else if ((*it)->getTypeId() == Part::GeomArcOfEllipse::getClassTypeId()) { + else if ((*it)->is()) { // Check if arc lies inside box selection const Part::GeomArcOfEllipse* aoe = static_cast(*it); @@ -2638,7 +2637,7 @@ void ViewProviderSketch::doBoxSelection(const SbVec2s& startPos, const SbVec2s& addSelection2(ss.str()); } } - else if ((*it)->getTypeId() == Part::GeomArcOfHyperbola::getClassTypeId()) { + else if ((*it)->is()) { // Check if arc lies inside box selection const Part::GeomArcOfHyperbola* aoh = static_cast(*it); pnt0 = aoh->getStartPoint(); @@ -2723,7 +2722,7 @@ void ViewProviderSketch::doBoxSelection(const SbVec2s& startPos, const SbVec2s& } } } - else if ((*it)->getTypeId() == Part::GeomArcOfParabola::getClassTypeId()) { + else if ((*it)->is()) { // Check if arc lies inside box selection const Part::GeomArcOfParabola* aop = static_cast(*it); @@ -2809,7 +2808,7 @@ void ViewProviderSketch::doBoxSelection(const SbVec2s& startPos, const SbVec2s& } } } - else if ((*it)->getTypeId() == Part::GeomBSplineCurve::getClassTypeId()) { + else if ((*it)->is()) { const Part::GeomBSplineCurve* spline = static_cast(*it); // std::vector poles = spline->getPoles(); VertexId += 2; @@ -2916,7 +2915,7 @@ void ViewProviderSketch::scaleBSplinePoleCirclesAndUpdateSolverAndSketchObjectGe if (GeoId >= geolistfacade.getInternalCount()) GeoId = -geolistfacade.getExternalCount(); - if ((*it)->getGeometry()->getTypeId() == Part::GeomCircle::getClassTypeId()) {// circle + if ((*it)->getGeometry()->is()) {// circle const Part::GeomCircle* circle = static_cast((*it)->getGeometry()); auto& gf = (*it); @@ -3770,8 +3769,7 @@ bool ViewProviderSketch::onDelete(const std::vector& subList) int GeoId; Sketcher::PointPos PosId; getSketchObject()->getGeoVertexIndex(VtId, GeoId, PosId); - if (getSketchObject()->getGeometry(GeoId)->getTypeId() - == Part::GeomPoint::getClassTypeId()) { + if (getSketchObject()->getGeometry(GeoId)->is()) { if (GeoId >= 0) delInternalGeometries.insert(GeoId); else