Sketcher: Bezier curves

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
abdullah
Posts: 1502
Joined: Sun May 04, 2014 3:16 pm

Re: Sketcher: Bezier curves

Postby abdullah » Thu Feb 16, 2017 4:43 pm

Alex, Agryson, has delivered those beautiful icons for the BSpline bar. I had some unpublished code and decided to cherry pick the commits and rebase in order not to break the unpublished code and the developments thereof to come into meaningless commits, so I cherry picked his commits. This is how it looks like:

bspline_toolbar.png
bspline_toolbar.png (15.71 KiB) Viewed 369 times


Thanks Alex!!! :)
abdullah
Posts: 1502
Joined: Sun May 04, 2014 3:16 pm

Re: Sketcher: Bezier curves

Postby abdullah » Thu Feb 16, 2017 10:57 pm

Several improvements today. I created python counterparts of the ConverttoNurbs and IncreaseDegree SketchObject functions and made use of them to execute the commands, so now we have redo/undo functionality on these commands.

Missing parts for this deliverable:
The Convert to NURBS fails miserably by crashing when constraints where applied on the geometry to convert (slot). I have to take a look on what exactly happens, and maybe remove the constraints, if existing, before effecting the conversion...

The branch is updated for those who like to play:
https://github.com/abdullahtahiriyo/Fre ... iverable_2
triplus
Posts: 4860
Joined: Mon Dec 12, 2011 4:45 pm

Re: Sketcher: Bezier curves

Postby triplus » Thu Feb 16, 2017 11:59 pm

abdullah wrote:Thanks! Good to know. You may want to report the issue to the one doing the python3 integration...


That would be @looo. ;)

P.S. I'll compile and do some tests tomorrow. Especially as i haven't tested the curvature combs functionality just yet. But to be honest i thought you would merge the spline curvature combs functionality as is. As it looks finished.
abdullah
Posts: 1502
Joined: Sun May 04, 2014 3:16 pm

Re: Sketcher: Bezier curves

Postby abdullah » Fri Feb 17, 2017 3:50 pm

triplus wrote:That would be @looo. ;)


I did not know :lol:

triplus wrote:P.S. I'll compile and do some tests tomorrow. Especially as i haven't tested the curvature combs functionality just yet. But to be honest i thought you would merge the spline curvature combs functionality as is. As it looks finished.


I intended to do the pull request, but I keep finding new use cases and small bugs.

For example, now I thought I would like to have a NURB-izer that works differently, i.e. not substituting the shape with the new one, which is handy in other situations, but just by adding the approximation. The latter should work with external geometry...
wmayer
Site Admin
Posts: 11234
Joined: Thu Feb 19, 2009 10:32 am

Re: Sketcher: Bezier curves

Postby wmayer » Fri Feb 17, 2017 5:49 pm

I intended to do the pull request, but I keep finding new use cases and small bugs

When creating the internal geometries of a rational B-spline then due to the equality constraint all radii are equal.
triplus
Posts: 4860
Joined: Mon Dec 12, 2011 4:45 pm

Re: Sketcher: Bezier curves

Postby triplus » Fri Feb 17, 2017 7:05 pm

abdullah wrote:I intended to do the pull request, but I keep finding new use cases and small bugs.

For example, now I thought I would like to have a NURB-izer that works differently, i.e. not substituting the shape with the new one, which is handy in other situations, but just by adding the approximation. The latter should work with external geometry...


The main reason i asked is i have FreeCAD 0.17 build against OCC 7+ and i want to test 2 things when it comes to curvature combs. And i have your branch build against OCE 0.17 and i could test only 1 thing. Therefore this time i decided i will wait for the curvature combs functionality to be upstreamed and do both test after! :)
abdullah
Posts: 1502
Joined: Sun May 04, 2014 3:16 pm

Re: Sketcher: Bezier curves

Postby abdullah » Sun Feb 19, 2017 11:20 pm

Well, I think it is ready:
https://github.com/FreeCAD/FreeCAD/pull/538

Lately I have been working on small details and some functionality has changed:
- No constraint is enforce on restoring internal geometry (same functionality as for other complex geometries like ellipse).
- to NURBS works also on external geometry now (a new regular geometry with the approximation is added)

bspline_ConvertToNURBS_External.png
bspline_ConvertToNURBS_External.png (22.34 KiB) Viewed 210 times


Let me hear your feedback :)
abdullah
Posts: 1502
Joined: Sun May 04, 2014 3:16 pm

Re: Sketcher: Bezier curves

Postby abdullah » Tue Feb 21, 2017 12:50 am

While this deliverable gets merged, I am looking for ideas to define the functionalities of the third deliverable. So here I look for some user input.

I have been doing a design with BSplines. I have identified some problems and I am looking for solutions:

1. When working you add a number of poles, it is not strange that this number happens to be too small or too high. Then you have to delete your B-Spline and make a new one with an appropriate number.

Possible solutions:
a) A tool to delete one pole.
b) A tool to split a bspline in two at a given pole
c) A tool to join bsplines (how? what if different degrees)
d) A tool that given a bspline approximates the Bspline using a "lower degree" or "lower amount of poles".

2. It is a nightmare to lock these beasts.

Any idea?


Separately:

3. What are you missing? (other than knots, knots are the next stage)
User avatar
NormandC
Posts: 12077
Joined: Sat Feb 06, 2010 9:52 pm
Location: Québec, Canada

Re: Sketcher: Bezier curves

Postby NormandC » Tue Feb 21, 2017 1:58 am

Hello Abdullah,

abdullah wrote:Possible solutions:
a) A tool to delete one pole.

Have you looked at the Draft BSpline? The Draft Modifying toolbar includes Image add point and Image delete point tools. Their use is pretty user-friendly. In this case since the Draft BSpline is created from knots on the curve, you click on an existing knot to delete it, or you click somewhere along the curve to add a knot there.

Your option a) is what I would expect as an end user.

But IMHO your list is missing an option: adding a pole to an existing B-spline. I'm not sure if it would be possible to insert a pole between two existing ones? Either
  • with the tool active, the user clicks on the B-spline and a pole is added in the area (trying to keep the resulting curve as close to the original as possible?), or
  • the user selects two poles and a new pole is added between them. (might be more in line with the traditional Sketcher work flow)

Add/remove poles are tools commonly available in other CAD software that provide B-spline creation.

I don't see b) c) and d) as alternatives, but as additional tools that could each have their purpose. But IMO they would be lower priority than add/remove pole tools. :)

abdullah wrote:d) A tool that given a bspline approximates the Bspline using a "lower degree" or "lower amount of poles".

Might this tool also allow the reverse, that is raise the degree/raise amount of poles?

abdullah wrote:2. It is a nightmare to lock these beasts.

I think the nature of a sketch solver makes this unavoidable. It is the same problem I've seen in the commercial CAD software I use at work. Which is why most of the time, I don't follow my own advice where B-splines are concerned, and I leave them unconstrained. :oops:

Talking about the nameless commercial CAD program I always mention, in its Sketcher the lock constraint acts differently than in FreeCAD. Rather than adding vertical and horizontal distance constraints from a vertex to the sketch origin, it literally locks/freezes the geometry in place. If a vertex is selected, then this point is locked in place and cannot be moved; if a segment (line, arc, circle, segment of a rectangle) is selected when creating the lock constraint, then the segment itself is locked/frozen. I wonder if the latter behaviour could be added to the existing lock constraint as an alternative to locking a vertex. It could apply to any type of segment... But maybe that would be opening a whole can of worms? :?
User avatar
NormandC
Posts: 12077
Joined: Sat Feb 06, 2010 9:52 pm
Location: Québec, Canada

Re: Sketcher: Bezier curves

Postby NormandC » Tue Feb 21, 2017 2:02 am

abdullah wrote:3. What are you missing? (other than knots, knots are the next stage)

Sorry for asking, keep in mind I have no knowledge of the math behind B-splines, and no amount of links to technical papers will make me understand it. :oops:

To my question: what would knots bring to the B-spline? What can knots do that control poles can't?