[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)
|
||||
{
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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<SelIdPair> &
|
||||
|
||||
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."));
|
||||
|
||||
Reference in New Issue
Block a user