Sketcher: Solver bypass of knotpoints
Internal geometry knot points, which were added as fixed parameters to the solver according to a previous commit, are tracked in the corresponding bspline as solver level, without being a parameter to the solver, and upon solving, the position thereof is updated by means of OCC functionality. This allows to show the knot points and solidarily move them when moving a bspline.
This commit is contained in:
@@ -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<int>::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<GeomPoint*>(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<GeomLineSegment*>(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<int>::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<GeomPoint*>(Geoms[*it5].geo);
|
||||
|
||||
if(point->Construction) {
|
||||
point->setPoint(bsp->pointAtParameter(knots[index]));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
} catch (Base::Exception e) {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user