Skip to content

Commit

Permalink
Sketcher: delete internal alignment geometry using new delGeometries …
Browse files Browse the repository at this point in the history
…function
  • Loading branch information
abdullahtahiriyo committed Dec 19, 2020
1 parent 117c63a commit 70f8550
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 24 deletions.
27 changes: 5 additions & 22 deletions src/Mod/Sketcher/App/SketchObject.cpp
Expand Up @@ -146,7 +146,6 @@ SketchObject::SketchObject()

internaltransaction=false;
managedoperation=false;
deletinginternalgeometry=false;
}

SketchObject::~SketchObject()
Expand Down Expand Up @@ -957,10 +956,6 @@ int SketchObject::delGeometry(int GeoId, bool deleteinternalgeo)

this->deleteUnusedInternalGeometry(GeoId, true);

Geometry.touch();

if(noRecomputes) // if we do not have a recompute, the sketch must be solved to update the DoF of the solver
solve();
return 0;
}
}
Expand Down Expand Up @@ -1002,13 +997,12 @@ int SketchObject::delGeometry(int GeoId, bool deleteinternalgeo)
this->Geometry.setValues(newVals);
this->Constraints.setValues(std::move(newConstraints));
}

// Update geometry indices and rebuild vertexindex now via onChanged, so that ViewProvider::UpdateData is triggered.
if(!deletinginternalgeometry) {
Geometry.touch();
Geometry.touch();

if(noRecomputes) // if we do not have a recompute, the sketch must be solved to update the DoF of the solver
solve();
}
if(noRecomputes) // if we do not have a recompute, the sketch must be solved to update the DoF of the solver
solve();

return 0;
}
Expand Down Expand Up @@ -4979,8 +4973,6 @@ int SketchObject::exposeInternalGeometry(int GeoId)

int SketchObject::deleteUnusedInternalGeometry(int GeoId, bool delgeoid)
{
Base::StateLocker lock(deletinginternalgeometry, true);

if (GeoId < 0 || GeoId > getHighestCurveIndex())
return -1;

Expand Down Expand Up @@ -5264,16 +5256,7 @@ int SketchObject::deleteUnusedInternalGeometry(int GeoId, bool delgeoid)
if(delgeoid)
delgeometries.push_back(GeoId);

std::sort(delgeometries.begin(), delgeometries.end()); // indices over an erased element get automatically updated!!

if (delgeometries.size()>0) {
for (std::vector<int>::reverse_iterator it=delgeometries.rbegin(); it!=delgeometries.rend(); ++it) {
delGeometry(*it,false);
}
}

int ndeleted = delgeometries.size();
delgeometries.clear();
int ndeleted = delGeometries(delgeometries);

return ndeleted; //number of deleted elements
}
Expand Down
2 changes: 0 additions & 2 deletions src/Mod/Sketcher/App/SketchObject.h
Expand Up @@ -511,8 +511,6 @@ class SketcherExport SketchObject : public Part::Part2DObject
bool internaltransaction;

bool managedoperation; // indicates whether changes to properties are the deed of SketchObject or not (for input validation)

bool deletinginternalgeometry; // sets a lock to deletinginternalgeometryoperation so that no individual triggers are perform on each element.
};

typedef App::FeaturePythonT<SketchObject> SketchObjectPython;
Expand Down

0 comments on commit 70f8550

Please sign in to comment.