diff --git a/src/Mod/Sketcher/App/SketchObject.cpp b/src/Mod/Sketcher/App/SketchObject.cpp index 6962824016..4cfa280206 100644 --- a/src/Mod/Sketcher/App/SketchObject.cpp +++ b/src/Mod/Sketcher/App/SketchObject.cpp @@ -1667,6 +1667,15 @@ int SketchObject::addGeometry(std::unique_ptr newgeo, bool const return Geometry.getSize() - 1; } +bool SketchObject::hasInternalGeometry(const Part::Geometry* geo) +{ + return (geo->is() + || geo->is() + || geo->is() + || geo->is() + || geo->is()); +} + int SketchObject::delGeometry(int GeoId, bool deleteinternalgeo) { if (GeoId < 0) { @@ -1682,19 +1691,10 @@ int SketchObject::delGeometry(int GeoId, bool deleteinternalgeo) if (GeoId < 0 || GeoId >= int(vals.size())) return -1; - if (deleteinternalgeo) { - const Part::Geometry* geo = getGeometry(GeoId); + if (deleteinternalgeo && hasInternalGeometry(getGeometry(GeoId))) { // Only for supported types - if ((geo->is() - || geo->is() - || geo->is() - || geo->is() - || geo->is())) { - - this->deleteUnusedInternalGeometry(GeoId, true); - - return 0; - } + this->deleteUnusedInternalGeometry(GeoId, true); + return 0; } std::vector newVals(vals); @@ -1703,14 +1703,12 @@ int SketchObject::delGeometry(int GeoId, bool deleteinternalgeo) // Find coincident points to replace the points of the deleted geometry std::vector GeoIdList; std::vector PosIdList; - for (PointPos PosId = PointPos::start; PosId != PointPos::mid;) { + for (PointPos PosId: {PointPos::start, PointPos::end, PointPos::mid}) { getDirectlyCoincidentPoints(GeoId, PosId, GeoIdList, PosIdList); if (GeoIdList.size() > 1) { delConstraintOnPoint(GeoId, PosId, true /* only coincidence */); transferConstraints(GeoIdList[0], PosIdList[0], GeoIdList[1], PosIdList[1]); } - // loop through [start, end, mid] - PosId = (PosId == PointPos::start) ? PointPos::end : PointPos::mid; } const std::vector& constraints = this->Constraints.getValues(); diff --git a/src/Mod/Sketcher/App/SketchObject.h b/src/Mod/Sketcher/App/SketchObject.h index 9d72c010ee..d16dfa3ef6 100644 --- a/src/Mod/Sketcher/App/SketchObject.h +++ b/src/Mod/Sketcher/App/SketchObject.h @@ -447,6 +447,7 @@ public: double perpscale = 1.0); int removeAxesAlignment(const std::vector& geoIdList); + static bool hasInternalGeometry(const Part::Geometry* geo); /// Exposes all internal geometry of an object supporting internal geometry /*! * \return -1 on error