[Sketcher] Enable point-on-B-spline in Sketcher and GUI
Also squashes: [Sketcher] Allow point on external B-spline
This commit is contained in:
committed by
abdullahtahiriyo
parent
4f3f566423
commit
d5793dc0e4
@@ -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<GeomBSplineCurve*>(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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user