Part: Part2DObject::seekTrimPoints rename parameters

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

This function takes parameters named GeoId, which evoke the Sketcher GeoId and which
indeed are used by the sketcher. However, these indices are just indices of the provided
geometry list. Therefore:
1. The are never negative (no matter if a corresponding Sketcher GeoId is external or not).
2. They do not have reserved indices for axes.
3. Most importantly, not found GeoId1 and GeoId2 are coded as -1, which for the Sketcher has
a well defined meaning (axis), whereas the Sketcher uses Constraint::GeoUndef as undefined or
not present/ not found index, which currently is -2000.

For these reasons, it was judged appropriate to rename the parameters and documentation to
emphasise that this function is unrelated and dettached from any Sketcher knowledge, and that
indices are just normal indices of a vector.
This commit is contained in:
Abdullah Tahiri
2021-01-14 07:15:37 +01:00
committed by abdullahtahiriyo
parent f4e3e8abd6
commit 595fc118e3
2 changed files with 25 additions and 23 deletions

View File

@@ -108,11 +108,11 @@ Base::Axis Part2DObject::getAxis(int axId) const
}
bool Part2DObject::seekTrimPoints(const std::vector<Geometry *> &geomlist,
int GeoId, const Base::Vector3d &point,
int &GeoId1, Base::Vector3d &intersect1,
int &GeoId2, Base::Vector3d &intersect2)
int geometryIndex, const Base::Vector3d &point,
int &geometryIndex1, Base::Vector3d &intersect1,
int &geometryIndex2, Base::Vector3d &intersect2)
{
if (GeoId >= int(geomlist.size()))
if ( geometryIndex >= int(geomlist.size()))
return false;
gp_Pln plane(gp_Pnt(0,0,0),gp_Dir(0,0,1));
@@ -120,7 +120,7 @@ bool Part2DObject::seekTrimPoints(const std::vector<Geometry *> &geomlist,
Standard_Boolean periodic=Standard_False;
double period = 0;
Handle(Geom2d_Curve) primaryCurve;
Handle(Geom_Geometry) geom = (geomlist[GeoId])->handle();
Handle(Geom_Geometry) geom = (geomlist[geometryIndex])->handle();
Handle(Geom_Curve) curve3d = Handle(Geom_Curve)::DownCast(geom);
if (curve3d.IsNull())
@@ -141,14 +141,14 @@ bool Part2DObject::seekTrimPoints(const std::vector<Geometry *> &geomlist,
double pickedParam = Projector.LowerDistanceParameter();
// find intersection points
GeoId1 = -1;
GeoId2 = -1;
geometryIndex1 = -1;
geometryIndex2 = -1;
double param1=-1e10,param2=1e10;
gp_Pnt2d p1,p2;
Handle(Geom2d_Curve) secondaryCurve;
for (int id=0; id < int(geomlist.size()); id++) {
// #0000624: Trim tool doesn't work with construction lines
if (id != GeoId/* && !geomlist[id]->Construction*/) {
if (id != geometryIndex/* && !geomlist[id]->Construction*/) {
geom = (geomlist[id])->handle();
curve3d = Handle(Geom_Curve)::DownCast(geom);
if (!curve3d.IsNull()) {
@@ -205,24 +205,24 @@ bool Part2DObject::seekTrimPoints(const std::vector<Geometry *> &geomlist,
if (param > param1) {
param1 = param;
p1 = p;
GeoId1 = id;
geometryIndex1 = id;
}
param -= period; // transfer param into the interval (pickedParam pickedParam+period]
if (param < param2) {
param2 = param;
p2 = p;
GeoId2 = id;
geometryIndex2 = id;
}
}
else if (param < pickedParam && param > param1) {
param1 = param;
p1 = p;
GeoId1 = id;
geometryIndex1 = id;
}
else if (param > pickedParam && param < param2) {
param2 = param;
p2 = p;
GeoId2 = id;
geometryIndex2 = id;
}
}
}
@@ -233,18 +233,18 @@ bool Part2DObject::seekTrimPoints(const std::vector<Geometry *> &geomlist,
// in case both points coincide, cancel the selection of one of both
if (fabs(param2-param1-period) < 1e-10) {
if (param2 - pickedParam >= pickedParam - param1)
GeoId2 = -1;
geometryIndex2 = -1;
else
GeoId1 = -1;
geometryIndex1 = -1;
}
}
if (GeoId1 < 0 && GeoId2 < 0)
if ( geometryIndex1 < 0 && geometryIndex2 < 0)
return false;
if (GeoId1 >= 0)
if ( geometryIndex1 >= 0)
intersect1 = Base::Vector3d(p1.X(),p1.Y(),0.f);
if (GeoId2 >= 0)
if ( geometryIndex2 >= 0)
intersect2 = Base::Vector3d(p2.X(),p2.Y(),0.f);
return true;
}

View File

@@ -66,17 +66,19 @@ public:
/// verify and accept the assigned geometry
virtual void acceptGeometry();
/** calculate the points where a curve with index GeoId should be trimmed
/** calculate the points where a curve with index geometryIndex should be trimmed
* with respect to the rest of the curves contained in the list geomlist
* and a picked point. The outputs intersect1 and intersect2 specify the
* tightest boundaries for trimming around the picked point and the
* indexes GeoId1 and GeoId2 specify the corresponding curves that intersect
* the curve GeoId.
* indexes geometryIndex1 and geometryIndex2 specify the corresponding curves that intersect
* the curve geometryIndex.
*
* If intersection is found, the associated geometryIndex1 or geometryIndex2 retuns -1.
*/
static bool seekTrimPoints(const std::vector<Geometry *> &geomlist,
int GeoId, const Base::Vector3d &point,
int &GeoId1, Base::Vector3d &intersect1,
int &GeoId2, Base::Vector3d &intersect2);
int geometryIndex, const Base::Vector3d &point,
int &geometryIndex1, Base::Vector3d &intersect1,
int &geometryIndex2, Base::Vector3d &intersect2);
static const int H_Axis;
static const int V_Axis;