Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing long splines rendering #367

Open
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

renato-grottesi
Copy link

The change allows correct rendering of quadratic and cubic splines
with more than 4 control points by splitting the spline into
segments and evaluating each segment as a quadratic or cubic
spline, one at a time.

The change allows correct rendering of quadratic and cubic splines
with more than 4 control points by splitting the spline into
segments and evaluating each segment as a quadratic or cubic
spline, one at a time.
@jcoffland
Copy link
Member

This is looking good. DXFModule::define should also have this code:

  exports.insert("SPLINE_CLOSED",   1 << 0);
  exports.insert("SPLINE_PERIODIC", 1 << 1);
  exports.insert("SPLINE_RATIONAL", 1 << 2);
  exports.insert("SPLINE_PLANAR",   1 << 3);
  exports.insert("SPLINE_LINEAR",   1 << 4);

var degree = spl.degree;
var points = spl.ctrlPts;
var knots = spl.knots;
var weights = []; /* spl.weights; */ for(i=0; i<points.length; i++) { weights.push(1.0); } /* TODO */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The weights are in the DL_ControlPointData structure. The function Reader::addControlPoint()should passctrlPt.wto theaddControlPoint()callback. The weights could then be added tostd::vector DXF::Spline::weightsand then later passed viaDXFModule`` to TPL.

}
var steps = Math.ceil(nurbs_length(s) / res);
//var delta = 1.0 / steps;
var delta = 0.01;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use the value from nurbs_length() here?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because of the bug you found at line 238 :-D
sorry for pushing in a rush, but that was it for my 30 minutes of coding.
I have one free hour now, I'll address all comments and try to implement closed curves at least.


for (var i = 1; i <= 100; i++) {
var u = cubic_bezier(p, 0.01 * i);
var u = nurbs_interpolate(0.0*i, spl);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i*0.0 is always 0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants