Sketcher: Renaming old get Coincident functions and introducing a extended one

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

What is this?

method

getCoincidentPoints

actually only included (as indicated in the documentation comment) those points coincident by a single constraint.

That is not "all the coincident points".

However some methods currently using it are expecting exactly that (coincident points linked by a single constraint).

A new method is introduced:
const std::map<int, Sketcher::PointPos> getAllCoincidentPoints(int GeoId, PointPos PosId);

that provides all the points coincident with the given one, directly (via a single constraint) or indirectly (via multiple coincident constraints).

The old method is renamed to:
getDirectlyCoincidentPoints

So as to have a more meaningful name to differentiate between both methods.
This commit is contained in:
Abdullah Tahiri 2015-09-07 15:28:33 +02:00 committed by wmayer
parent 82e41125da
commit 53320b260e
3 changed files with 37 additions and 10 deletions

View File

@ -535,7 +535,7 @@ int SketchObject::delGeometry(int GeoId)
std::vector<int> GeoIdList;
std::vector<PointPos> PosIdList;
for (PointPos PosId = start; PosId != mid; ) {
getCoincidentPoints(GeoId, PosId, GeoIdList, PosIdList);
getDirectlyCoincidentPoints(GeoId, PosId, GeoIdList, PosIdList);
if (GeoIdList.size() > 1) {
delConstraintOnPoint(GeoId, PosId, true /* only coincidence */);
transferConstraints(GeoIdList[0], PosIdList[0], GeoIdList[1], PosIdList[1]);
@ -820,7 +820,7 @@ int SketchObject::fillet(int GeoId, PointPos PosId, double radius, bool trim)
// Find the other geometry Id associated with the coincident point
std::vector<int> GeoIdList;
std::vector<PointPos> PosIdList;
getCoincidentPoints(GeoId, PosId, GeoIdList, PosIdList);
getDirectlyCoincidentPoints(GeoId, PosId, GeoIdList, PosIdList);
// only coincident points between two (non-external) edges can be filleted
if (GeoIdList.size() == 2 && GeoIdList[0] >= 0 && GeoIdList[1] >= 0) {
@ -3163,7 +3163,31 @@ void SketchObject::isCoincidentWithExternalGeometry(int GeoId, bool &start_exter
}
}
void SketchObject::getCoincidentPoints(int GeoId, PointPos PosId, std::vector<int> &GeoIdList,
const std::map<int, Sketcher::PointPos> SketchObject::getAllCoincidentPoints(int GeoId, PointPos PosId) {
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(GeoId);
if( geoId1iterator != (*it).end()) {
// If GeoId is in this set
if ((*geoId1iterator).second == PosId) // and posId matches
return (*it);
}
}
std::map<int, Sketcher::PointPos> empty;
return empty;
}
void SketchObject::getDirectlyCoincidentPoints(int GeoId, PointPos PosId, std::vector<int> &GeoIdList,
std::vector<PointPos> &PosIdList)
{
const std::vector<Constraint *> &constraints = this->Constraints.getValues();
@ -3191,13 +3215,13 @@ void SketchObject::getCoincidentPoints(int GeoId, PointPos PosId, std::vector<in
}
}
void SketchObject::getCoincidentPoints(int VertexId, std::vector<int> &GeoIdList,
void SketchObject::getDirectlyCoincidentPoints(int VertexId, std::vector<int> &GeoIdList,
std::vector<PointPos> &PosIdList)
{
int GeoId;
PointPos PosId;
getGeoVertexIndex(VertexId, GeoId, PosId);
getCoincidentPoints(GeoId, PosId, GeoIdList, PosIdList);
getDirectlyCoincidentPoints(GeoId, PosId, GeoIdList, PosIdList);
}
bool SketchObject::arePointsCoincident(int GeoId1, PointPos PosId1,

View File

@ -181,11 +181,14 @@ public:
const std::vector< std::map<int, Sketcher::PointPos> > getCoincidenceGroups();
// returns if the given geoId is fixed (coincident) with external geometry on any of the possible relevant points
void isCoincidentWithExternalGeometry(int GeoId, bool &start_external, bool &mid_external, bool &end_external);
// returns a map containing all the GeoIds that are coincident with the given point as keys, and the PosIds as values associated
// with the keys.
const std::map<int, Sketcher::PointPos> getAllCoincidentPoints(int GeoId, PointPos PosId);
/// retrieves for a Vertex number a list with all coincident points (sharing a single coincidence constraint)
void getCoincidentPoints(int GeoId, PointPos PosId, std::vector<int> &GeoIdList,
void getDirectlyCoincidentPoints(int GeoId, PointPos PosId, std::vector<int> &GeoIdList,
std::vector<PointPos> &PosIdList);
void getCoincidentPoints(int VertexId, std::vector<int> &GeoIdList, std::vector<PointPos> &PosIdList);
void getDirectlyCoincidentPoints(int VertexId, std::vector<int> &GeoIdList, std::vector<PointPos> &PosIdList);
bool arePointsCoincident(int GeoId1, PointPos PosId1, int GeoId2, PointPos PosId2);
/// generates a warning message about constraint conflicts and appends it to the given message

View File

@ -3981,7 +3981,7 @@ namespace SketcherGui {
Sketcher::SketchObject *Sketch = static_cast<Sketcher::SketchObject*>(object);
std::vector<int> GeoIdList;
std::vector<Sketcher::PointPos> PosIdList;
Sketch->getCoincidentPoints(VtId, GeoIdList, PosIdList);
Sketch->getDirectlyCoincidentPoints(VtId, GeoIdList, PosIdList);
if (GeoIdList.size() == 2 && GeoIdList[0] >= 0 && GeoIdList[1] >= 0) {
const Part::Geometry *geom1 = Sketch->getGeometry(GeoIdList[0]);
const Part::Geometry *geom2 = Sketch->getGeometry(GeoIdList[1]);
@ -4080,7 +4080,7 @@ public:
double radius=-1;
std::vector<int> GeoIdList;
std::vector<Sketcher::PointPos> PosIdList;
sketchgui->getSketchObject()->getCoincidentPoints(GeoId, PosId, GeoIdList, PosIdList);
sketchgui->getSketchObject()->getDirectlyCoincidentPoints(GeoId, PosId, GeoIdList, PosIdList);
if (GeoIdList.size() == 2 && GeoIdList[0] >= 0 && GeoIdList[1] >= 0) {
const Part::Geometry *geom1 = sketchgui->getSketchObject()->getGeometry(GeoIdList[0]);
const Part::Geometry *geom2 = sketchgui->getSketchObject()->getGeometry(GeoIdList[1]);