Part: Extension of Geometry::Curve

Part: Extension of Geometry::Curve to wrap more functions of OCC

Apart from:
    bool tangent(double u, gp_Dir&) const;
that was already implemented, now it also implements:
    Base::Vector3d pointAtParameter(double u) const;
    Base::Vector3d firstDerivativeAtParameter(double u) const;
    Base::Vector3d secondDerivativeAtParameter(double u) const;
    bool normal(double u, gp_Dir& dir) const;
    bool closestParameter(Base::Vector3d point, double &u);

i.e. apart from giving the tangent vector for a given curve at parameter value u,
it also gives:
   - The point cartesian coordinates of the curve point at parameter value u
   - The vector of the first derivative at parameter value u
   - The vector of the second derivative at parameter value u
   - The normal vector to the curve at parameter value u
   - The parameter value of a curve closest ot a given point

Code cleanup: Changing Trim functionality of Ellipse to use OCC calculations

Part Curve functions extension: closestParameterToBasicCurve

It provides the parameter of the curve closest to a given point. If the curve is a Trimmed curve, the parameter of the basic underlaying curve closest to the point is provided.
This commit is contained in:
Abdullah Tahiri
2014-11-27 16:15:14 +01:00
committed by wmayer
parent 27cd61f849
commit 948eb8e636
3 changed files with 107 additions and 12 deletions

View File

@@ -969,19 +969,16 @@ int SketchObject::trim(int GeoId, const Base::Vector3d& point)
} else if (geo->getTypeId() == Part::GeomEllipse::getClassTypeId()) {
const Part::GeomEllipse *ellipse = dynamic_cast<const Part::GeomEllipse*>(geo);
Base::Vector3d center = ellipse->getCenter();
double theta0 = Base::fmod(
atan2(-ellipse->getMajorRadius()*((point.x-center.x)*sin(ellipse->getAngleXU())-(point.y-center.y)*cos(ellipse->getAngleXU())),
ellipse->getMinorRadius()*((point.x-center.x)*cos(ellipse->getAngleXU())+(point.y-center.y)*sin(ellipse->getAngleXU()))
), 2.f*M_PI);
double theta0;
ellipse->closestParameter(point,theta0);
theta0 = Base::fmod(theta0, 2.f*M_PI);
if (GeoId1 >= 0 && GeoId2 >= 0) {
double theta1 = Base::fmod(
atan2(-ellipse->getMajorRadius()*((point1.x-center.x)*sin(ellipse->getAngleXU())-(point1.y-center.y)*cos(ellipse->getAngleXU())),
ellipse->getMinorRadius()*((point1.x-center.x)*cos(ellipse->getAngleXU())+(point1.y-center.y)*sin(ellipse->getAngleXU()))
), 2.f*M_PI);
double theta2 = Base::fmod(
atan2(-ellipse->getMajorRadius()*((point2.x-center.x)*sin(ellipse->getAngleXU())-(point2.y-center.y)*cos(ellipse->getAngleXU())),
ellipse->getMinorRadius()*((point2.x-center.x)*cos(ellipse->getAngleXU())+(point2.y-center.y)*sin(ellipse->getAngleXU()))
), 2.f*M_PI);
double theta1;
ellipse->closestParameter(point1,theta1);
theta1 = Base::fmod(theta1, 2.f*M_PI);
double theta2;
ellipse->closestParameter(point2,theta2);
theta2 = Base::fmod(theta2, 2.f*M_PI);
if (Base::fmod(theta1 - theta0, 2.f*M_PI) > Base::fmod(theta2 - theta0, 2.f*M_PI)) {
std::swap(GeoId1,GeoId2);
std::swap(point1,point2);