Sketcher: Offset & tranforms: enable external geos input. (#17615)

* Sketcher: Offset & tranforms: enable external geos input.
* Sketcher: enable delGeometries to handle external geos.
This commit is contained in:
PaddleStroke
2024-11-25 17:57:16 +01:00
committed by GitHub
parent 145f95202a
commit 223877873b
2 changed files with 52 additions and 23 deletions

View File

@@ -1681,10 +1681,33 @@ int SketchObject::delGeometry(int GeoId, bool deleteinternalgeo)
return 0;
}
int SketchObject::delGeometries(const std::vector<int>& GeoIds)
{
std::vector<int> sGeoIds(GeoIds);
std::vector<int> sGeoIds;
std::vector<int> negativeGeoIds;
// Separate GeoIds into negative (external) and non-negative GeoIds
for (int geoId : GeoIds) {
if (geoId < 0 && geoId <= GeoEnum::RefExt) {
negativeGeoIds.push_back(geoId);
}
else if (geoId >= 0){
sGeoIds.push_back(geoId);
}
}
// Handle negative GeoIds by calling delExternal
if (!negativeGeoIds.empty()) {
int result = delExternal(negativeGeoIds);
if (result != 0) {
return result; // Return if deletion of external geometries failed
}
}
// Proceed with non-negative GeoIds
if (sGeoIds.empty()) {
return 0; // No positive GeoIds to delete
}
// if a GeoId has internal geometry, it must delete internal geometries too
for (auto c : Constraints.getValues()) {
@@ -7732,7 +7755,7 @@ int SketchObject::delExternal(const std::vector<int>& ExtGeoIds)
{
std::set<long> geoIds;
for (int ExtGeoId : ExtGeoIds) {
int GeoId = GeoEnum::RefExt - ExtGeoId;
int GeoId = ExtGeoId > 0 ? GeoEnum::RefExt - ExtGeoId : ExtGeoId;
if (GeoId > GeoEnum::RefExt || -GeoId - 1 >= ExternalGeo.getSize())
return -1;