Bug fix: deletion of groups of external geometry
================================================ Issue reported inter alia here: http://forum.freecadweb.org/viewtopic.php?f=10&t=12380#p99456 How to reproduce: 1. Make an external geometry hexagon (make a hexagon, pad it, make a sketch on a hexagonal face and make all the lines external geometry) 2. Box select the external lines and press "del" On the first pressing of "del" 3 lines were deleted and 3 remained, select again, on the second press 1 remains, select again, on the last press all are deleted. Why? Internal and External geometry were handled together in a single set. Group deletion of geometry is effected starting from the highest index, so that upon deleting an element, the index of the remaining elements does not change. Handling both groups together caused that the external geometry was actually deleted on the inversed order (as they are (decreasing) negative values for representation, but increasing positive indexes in the external geometry array). Solution: Internal and External geometries are handled separatedly
This commit is contained in:
parent
e9594501dd
commit
01ba165d9a
|
@ -4756,24 +4756,30 @@ bool ViewProviderSketch::onDelete(const std::vector<std::string> &subList)
|
|||
edit->PreselectCross = -1;
|
||||
edit->PreselectConstraintSet.clear();
|
||||
|
||||
std::set<int> delGeometries, delCoincidents, delConstraints;
|
||||
std::set<int> delInternalGeometries, delExternalGeometries, delCoincidents, delConstraints;
|
||||
// go through the selected subelements
|
||||
for (std::vector<std::string>::const_iterator it=SubNames.begin(); it != SubNames.end(); ++it) {
|
||||
if (it->size() > 4 && it->substr(0,4) == "Edge") {
|
||||
int GeoId = std::atoi(it->substr(4,4000).c_str()) - 1;
|
||||
delGeometries.insert(GeoId);
|
||||
if( GeoId >= 0 )
|
||||
delInternalGeometries.insert(GeoId);
|
||||
else
|
||||
delExternalGeometries.insert(-3-GeoId);
|
||||
} else if (it->size() > 12 && it->substr(0,12) == "ExternalEdge") {
|
||||
int GeoId = std::atoi(it->substr(12,4000).c_str()) - 1;
|
||||
GeoId = -GeoId - 3;
|
||||
delGeometries.insert(GeoId);
|
||||
delExternalGeometries.insert(GeoId);
|
||||
} else if (it->size() > 6 && it->substr(0,6) == "Vertex") {
|
||||
int VtId = std::atoi(it->substr(6,4000).c_str()) - 1;
|
||||
int GeoId;
|
||||
Sketcher::PointPos PosId;
|
||||
getSketchObject()->getGeoVertexIndex(VtId, GeoId, PosId);
|
||||
if (getSketchObject()->getGeometry(GeoId)->getTypeId()
|
||||
== Part::GeomPoint::getClassTypeId())
|
||||
delGeometries.insert(GeoId);
|
||||
== Part::GeomPoint::getClassTypeId()) {
|
||||
if(GeoId>=0)
|
||||
delInternalGeometries.insert(GeoId);
|
||||
else
|
||||
delExternalGeometries.insert(-3-GeoId);
|
||||
}
|
||||
else
|
||||
delCoincidents.insert(VtId);
|
||||
} else if (*it == "RootPoint") {
|
||||
|
@ -4805,14 +4811,20 @@ bool ViewProviderSketch::onDelete(const std::vector<std::string> &subList)
|
|||
}
|
||||
}
|
||||
|
||||
for (rit = delGeometries.rbegin(); rit != delGeometries.rend(); rit++) {
|
||||
for (rit = delInternalGeometries.rbegin(); rit != delInternalGeometries.rend(); rit++) {
|
||||
try {
|
||||
if (*rit >= 0)
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.delGeometry(%i)"
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.delGeometry(%i)"
|
||||
,getObject()->getNameInDocument(), *rit);
|
||||
else if (*rit < -2) // external geometry
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.delExternal(%i)"
|
||||
,getObject()->getNameInDocument(), -3-*rit);
|
||||
}
|
||||
catch (const Base::Exception& e) {
|
||||
Base::Console().Error("%s\n", e.what());
|
||||
}
|
||||
}
|
||||
|
||||
for (rit = delExternalGeometries.rbegin(); rit != delExternalGeometries.rend(); rit++) {
|
||||
try {
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.delExternal(%i)"
|
||||
,getObject()->getNameInDocument(), *rit);
|
||||
}
|
||||
catch (const Base::Exception& e) {
|
||||
Base::Console().Error("%s\n", e.what());
|
||||
|
|
Loading…
Reference in New Issue
Block a user