diff --git a/src/Mod/Sketcher/App/Sketch.cpp b/src/Mod/Sketcher/App/Sketch.cpp index 8142add219..44598f4f14 100644 --- a/src/Mod/Sketcher/App/Sketch.cpp +++ b/src/Mod/Sketcher/App/Sketch.cpp @@ -774,6 +774,14 @@ int Sketch::addBSpline(const Part::GeomBSplineCurve &bspline, bool fixed) bs.degree = degree; bs.periodic = periodic; def.index = BSplines.size(); + + // non-solver related, just to enable initialization of knotspoints which is not a parameter of the solver + bs.knotpointGeoids.resize(knots.size()); + + for(std::vector::iterator it = bs.knotpointGeoids.begin(); it != bs.knotpointGeoids.end(); ++it) { + (*it) = Constraint::GeoUndef; + } + BSplines.push_back(bs); // store complete set @@ -2489,12 +2497,15 @@ int Sketch::addInternalAlignmentKnotPoint(int geoId1, int geoId2, int knotindex) int pointId1 = getPointId(geoId2, start); if (pointId1 >= 0 && pointId1 < int(Points.size())) { - GCS::Point &p = Points[pointId1]; + // GCS::Point &p = Points[pointId1]; GCS::BSpline &b = BSplines[Geoms[geoId1].index]; - int tag = ++ConstraintsCounter; - GCSsys.addConstraintInternalAlignmentBSplineKnot(b, p, knotindex, tag); + // no constraint is actually added, as knots are fixed geometry in this implementation + // indexing is added here. + + b.knotpointGeoids[knotindex] = geoId2; + return ConstraintsCounter; } return -1; @@ -2545,10 +2556,13 @@ bool Sketch::updateGeometry() try { if (it->type == Point) { GeomPoint *point = static_cast(it->geo); - point->setPoint(Vector3d(*Points[it->startPointId].x, + + if(!point->Construction) { + point->setPoint(Vector3d(*Points[it->startPointId].x, *Points[it->startPointId].y, 0.0) ); + } } else if (it->type == Line) { GeomLineSegment *lineSeg = static_cast(it->geo); lineSeg->setPoints(Vector3d(*Lines[it->index].p1.x, @@ -2687,6 +2701,19 @@ bool Sketch::updateGeometry() } bsp->setKnots(knots,mult); + + int index = 0; + for(std::vector::const_iterator it5 = mybsp.knotpointGeoids.begin(); it5 != mybsp.knotpointGeoids.end(); ++it5, index++) { + if( *it5 != Constraint::GeoUndef) { + if (Geoms[*it5].type == Point) { + GeomPoint *point = static_cast(Geoms[*it5].geo); + + if(point->Construction) { + point->setPoint(bsp->pointAtParameter(knots[index])); + } + } + } + } } } catch (Base::Exception e) { diff --git a/src/Mod/Sketcher/App/planegcs/GCS.cpp b/src/Mod/Sketcher/App/planegcs/GCS.cpp index 6889b0a7ac..5c81261811 100644 --- a/src/Mod/Sketcher/App/planegcs/GCS.cpp +++ b/src/Mod/Sketcher/App/planegcs/GCS.cpp @@ -1014,13 +1014,6 @@ int System::addConstraintInternalAlignmentBSplineControlPoint(BSpline &b, Circle return addConstraintEqual(b.weights[poleindex], c.rad, tagId); } -int System::addConstraintInternalAlignmentBSplineKnot(BSpline &b, Point &p, int knotindex, int tagId) -{ - // not yet implemented - return 0; - -} - //calculates angle between two curves at point of their intersection p. If two //points are supplied, p is used for first curve and p2 for second, yielding a //remote angle computation (this is useful when the endpoints haven't) been diff --git a/src/Mod/Sketcher/App/planegcs/GCS.h b/src/Mod/Sketcher/App/planegcs/GCS.h index 8ed134161c..193cfb08ee 100644 --- a/src/Mod/Sketcher/App/planegcs/GCS.h +++ b/src/Mod/Sketcher/App/planegcs/GCS.h @@ -234,7 +234,6 @@ namespace GCS int addConstraintInternalAlignmentHyperbolaFocus(Hyperbola &e, Point &p1, int tagId=0); int addConstraintInternalAlignmentParabolaFocus(Parabola &e, Point &p1, int tagId=0); int addConstraintInternalAlignmentBSplineControlPoint(BSpline &b, Circle &c, int poleindex, int tag=0); - int addConstraintInternalAlignmentBSplineKnot(BSpline &b, Point &p, int knotindex, int tagId=0); double calculateAngleViaPoint(Curve &crv1, Curve &crv2, Point &p); double calculateAngleViaPoint(Curve &crv1, Curve &crv2, Point &p1, Point &p2); diff --git a/src/Mod/Sketcher/App/planegcs/Geo.h b/src/Mod/Sketcher/App/planegcs/Geo.h index dba2344b26..44664c7d08 100644 --- a/src/Mod/Sketcher/App/planegcs/Geo.h +++ b/src/Mod/Sketcher/App/planegcs/Geo.h @@ -290,6 +290,7 @@ namespace GCS VEC_I mult; int degree; bool periodic; + VEC_I knotpointGeoids; // geoids of knotpoints as to index Geom array // interface helpers DeriVector2 CalculateNormal(Point &p, double* derivparam = 0); virtual DeriVector2 Value(double u, double du, double* derivparam = 0);