diff --git a/src/Mod/Sketcher/App/Sketch.cpp b/src/Mod/Sketcher/App/Sketch.cpp index 70c251d173..fab57754e0 100644 --- a/src/Mod/Sketcher/App/Sketch.cpp +++ b/src/Mod/Sketcher/App/Sketch.cpp @@ -1686,6 +1686,14 @@ int Sketch::addConstraint(const Constraint *constraint) rtn = addPointCoincidentConstraint(constraint->First,constraint->FirstPos,constraint->Second,constraint->SecondPos); break; case PointOnObject: + if (Geoms[checkGeoId(constraint->Second)].type == BSpline) { + c.value = new double(constraint->getValue()); + // Driving doesn't make sense here + Parameters.push_back(c.value); + + rtn = addPointOnObjectConstraint(constraint->First,constraint->FirstPos, constraint->Second, c.value); + } + else rtn = addPointOnObjectConstraint(constraint->First,constraint->FirstPos, constraint->Second); break; case Parallel: @@ -3009,6 +3017,31 @@ int Sketch::addPointOnObjectConstraint(int geoId1, PointPos pos1, int geoId2, bo return -1; } +int Sketch::addPointOnObjectConstraint(int geoId1, PointPos pos1, int geoId2, double* pointparam, bool driving) +{ + geoId1 = checkGeoId(geoId1); + geoId2 = checkGeoId(geoId2); + + int pointId1 = getPointId(geoId1, pos1); + + if (pointId1 >= 0 && pointId1 < int(Points.size())) { + GCS::Point &p1 = Points[pointId1]; + + if (Geoms[geoId2].type == BSpline) { + GCS::BSpline &b = BSplines[Geoms[geoId2].index]; + int tag = ++ConstraintsCounter; + auto partBsp = static_cast(Geoms[geoId2].geo); + double uNear; + partBsp->closestParameter(Base::Vector3d(*p1.x, *p1.y, 0.0), uNear); + *pointparam = uNear; + GCSsys.addConstraintPointOnBSpline(p1, b, pointparam, tag, driving); + + return ConstraintsCounter; + } + } + return -1; +} + // symmetric points constraint int Sketch::addSymmetricConstraint(int geoId1, PointPos pos1, int geoId2, PointPos pos2, int geoId3) { diff --git a/src/Mod/Sketcher/App/Sketch.h b/src/Mod/Sketcher/App/Sketch.h index b161fa676a..6987e55dd2 100644 --- a/src/Mod/Sketcher/App/Sketch.h +++ b/src/Mod/Sketcher/App/Sketch.h @@ -342,6 +342,8 @@ public: int addEqualConstraint(int geoId1, int geoId2); /// add a point on line constraint int addPointOnObjectConstraint(int geoId1, PointPos pos1, int geoId2, bool driving = true); + /// add a point on B-spline constraint: needs a parameter + int addPointOnObjectConstraint(int geoId1, PointPos pos1, int geoId2,double* pointparam, bool driving = true); /// add a symmetric constraint between two points with respect to a line int addSymmetricConstraint(int geoId1, PointPos pos1, int geoId2, PointPos pos2, int geoId3); /// add a symmetric constraint between three points, the last point is in the middle of the first two diff --git a/src/Mod/Sketcher/Gui/CommandConstraints.cpp b/src/Mod/Sketcher/Gui/CommandConstraints.cpp index ffde840d65..902c45f38d 100644 --- a/src/Mod/Sketcher/Gui/CommandConstraints.cpp +++ b/src/Mod/Sketcher/Gui/CommandConstraints.cpp @@ -2571,13 +2571,6 @@ void CmdSketcherConstrainPointOnObject::activated(int iMsg) const Part::Geometry *geom = Obj->getGeometry(curves[iCrv].GeoId); - if( geom && geom->getTypeId() == Part::GeomBSplineCurve::getClassTypeId() ){ - // unsupported until normal to B-spline at any point implemented. - QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"), - QObject::tr("Point on B-spline edge currently unsupported.")); - continue; - } - if( geom && isBsplinePole(geom)) { QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"), QObject::tr("Select an edge that is not a B-spline weight.")); @@ -2658,15 +2651,6 @@ void CmdSketcherConstrainPointOnObject::applyConstraint(std::vector & const Part::Geometry *geom = Obj->getGeometry(GeoIdCrv); - if( geom && geom->getTypeId() == Part::GeomBSplineCurve::getClassTypeId() ){ - // unsupported until normal to B-spline at any point implemented. - QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"), - QObject::tr("Point on B-spline edge currently unsupported.")); - abortCommand(); - - return; - } - if( geom && isBsplinePole(geom)) { QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"), QObject::tr("Select an edge that is not a B-spline weight."));