Geom2d_BSplineCurve edit points

Hello everybody, I'm new to this forum. I recently started to use the powerful functionalities of the OCCT kernel in my CAD-CAM  application. In particular I will use it for the 2D bspline modeling.

I want to reproduce in my software some basic functionalities offered by other common cad systems like Rhinoceros. Usually CAD software allow to create and edit a nurbs by control points and by "edit points". I'm ok with control points as they are part of the curve definition, but I'm really struggling to give a meaning to the "edit points" which are used as interpolating points. In Rhino for example is it possible to enable the "edit points" of a curve and move them to change the shape of the curve. I found out that these points are simply the evaluation of the curve at each knot, plus two additional points at 1/3 of the first span and 2/3 of the last span.

I want to be able to move one of these points and change the shape of the curve locally while keeping the passage of the curve through all the other points. Is there a function to do this? How could it be accomplished?

Forum supervisor's picture

Hello Alessandro,

When you say “usually CAD software allow to create and edit a nurbs” you likely mean some end-user CAD applications.

Behind the function to “edit a nurbs” in an end-user CAD application, you may find some data structure that allows storing NURBS representation, algorithms that allow its modification, algorithms that convert such “mathematical” representation to a representation suitable for visualization in a 2D or a 3D viewer, algorithms that implement specific selection logic etc.

If you already started using OCCT, you should know that OCCT is not an end-user application but a library. And this library actually provides all that needed elements that can be used to implement the required functionality in your end-user application.

So you just need to implement some specific code in your application that will put all the listed things from OCCT together, to implement the kind of logic you want.

If you require our assistance in implementing that, please, contact us for more information about available services.

Best regards,

Forum supervisor

alessandro ordan's picture

Hello, thanks for your answer. Yes, I know what you mean and that's actually what I'm trying to do. My CAD-CAM software is a fully featured 2D design application that uses cubic beziers, arcs and segments as geometrical elements to compose polycurves. I'm adding support to nurbs curve and I'm trying do to so by using OCCT (only the kernel part, not the application framework).

While I have no problem in visualizing, selecting, transforming the curve, and editing it with control points, I want to add a functionality like Rhinos "Edit points".

I tried the Geom2d_BSplineCurve::MovePoint method but it doesn't accept constraints on other points.

I also tried Geom2dAPI_Interpolate but it has less constraints of the degrees of freedom so it is not useful for this purpose.

I think I will have to solve some system of equations to obtain a new curve and impose the required constraints

lukas alberts's picture

have a look at FreeCAD
freecadweb.org
lukas

alessandro ordan's picture

I've found a solution, maybe not the best but makes what I need by using the function BSplCLib::Interpolate.

With a non periodic curve having n control points I choose n "Edit Points" on the curve evaluating it at knot averages (http://docs.mcneel.com/rhino/5/help/en-us/commands/pointson.htm#EditPtOn). The fist and last edit point will coincide with the first and last point (and control point) of the curve.

Given the new position of the edit points (usually the user will move one edit point a time) the control points of the curve are recomputed by calling BSplCLib::Interpolate with these parameters:

  • [IN] The degree of the original curve
  • [IN] The expanded (flat) knots vector of the original curve
  • [IN] The vector of parameter of the points to interpolate (the knot averages)
  • [IN] A vector of same size with all 0s
  • [IN-OUT] The vector of points to interpolate (evaluated at knot averages), returns the new control points vector