Sketcher bug/feature request: arePointsCoincident/coincidence creation

======================================================================

1. SketchObject::arePointsCoincident upgraded to check for indirect coincidence.
2. Coincidence constraint creation now checks for indirect coincidences and avoids
creating redundant coincidence constraints (for example during box selection).
This commit is contained in:
Abdullah Tahiri
2015-09-07 14:20:47 +02:00
committed by wmayer
parent 6035dc3336
commit 4b9a379b90
2 changed files with 25 additions and 24 deletions

View File

@@ -3205,17 +3205,30 @@ bool SketchObject::arePointsCoincident(int GeoId1, PointPos PosId1,
{
if (GeoId1 == GeoId2 && PosId1 == PosId2)
return true;
const std::vector<Constraint *> &constraints = this->Constraints.getValues();
for (std::vector<Constraint *>::const_iterator it=constraints.begin();
it != constraints.end(); ++it) {
if ((*it)->Type == Sketcher::Coincident)
if (((*it)->First == GeoId1 && (*it)->FirstPos == PosId1 &&
(*it)->Second == GeoId2 && (*it)->SecondPos == PosId2) ||
((*it)->First == GeoId2 && (*it)->FirstPos == PosId2 &&
(*it)->Second == GeoId1 && (*it)->SecondPos == PosId1))
return true;
const std::vector< std::map<int, Sketcher::PointPos> > coincidenttree = getCoincidenceGroups();
for(std::vector< std::map<int, Sketcher::PointPos> >::const_iterator it = coincidenttree.begin(); it != coincidenttree.end(); ++it) {
std::map<int, Sketcher::PointPos>::const_iterator geoId1iterator;
geoId1iterator = (*it).find(GeoId1);
if( geoId1iterator != (*it).end()) {
// If First is in this set
std::map<int, Sketcher::PointPos>::const_iterator geoId2iterator;
geoId2iterator = (*it).find(GeoId2);
if( geoId2iterator != (*it).end()) {
// If Second is in this set
if ((*geoId1iterator).second == PosId1 &&
(*geoId2iterator).second == PosId2)
return true;
}
}
}
return false;
}