Sketcher: make Sketch::calculateNormalAtPoint const

This commit is contained in:
Abdullah Tahiri
2020-12-25 07:51:36 +01:00
committed by abdullahtahiriyo
parent a790e32605
commit 18ecd174a8
2 changed files with 11 additions and 3 deletions

View File

@@ -1427,6 +1427,13 @@ GCS::Curve* Sketch::getGCSCurveByGeoId(int geoId)
};
}
const GCS::Curve* Sketch::getGCSCurveByGeoId(int geoId) const
{
// I hereby guarantee that if I modify the non-const version, I will still
// never modify (this). I return const copy to enforce on my users.
return const_cast<Sketch *>(this)->getGCSCurveByGeoId(geoId);
}
// constraint adding ==========================================================
int Sketch::addConstraint(const Constraint *constraint)
@@ -3177,7 +3184,7 @@ double Sketch::calculateAngleViaPoint(int geoId1, int geoId2, double px, double
return GCSsys.calculateAngleViaPoint(*crv1, *crv2, p);
}
Base::Vector3d Sketch::calculateNormalAtPoint(int geoIdCurve, double px, double py)
Base::Vector3d Sketch::calculateNormalAtPoint(int geoIdCurve, double px, double py) const
{
geoIdCurve = checkGeoId(geoIdCurve);
@@ -3186,7 +3193,7 @@ Base::Vector3d Sketch::calculateNormalAtPoint(int geoIdCurve, double px, double
p.y = &py;
//check pointers
GCS::Curve* crv = getGCSCurveByGeoId(geoIdCurve);
const GCS::Curve* crv = getGCSCurveByGeoId(geoIdCurve);
if (!crv) {
throw Base::ValueError("calculateNormalAtPoint: getGCSCurveByGeoId returned NULL!\n");
}

View File

@@ -356,7 +356,7 @@ public:
double calculateAngleViaPoint(int geoId1, int geoId2, double px, double py );
//This is to be used for rendering of angle-via-point constraint.
Base::Vector3d calculateNormalAtPoint(int geoIdCurve, double px, double py);
Base::Vector3d calculateNormalAtPoint(int geoIdCurve, double px, double py) const;
//icstr should be the value returned by addXXXXConstraint
//see more info in respective function in GCS.
@@ -485,6 +485,7 @@ private:
/// checks if the index bounds and converts negative indices to positive
int checkGeoId(int geoId) const;
GCS::Curve* getGCSCurveByGeoId(int geoId);
const GCS::Curve* getGCSCurveByGeoId(int geoId) const;
};
} //namespace Part