## Sketcher: Bezier curves

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
microelly2
Posts: 2450
Joined: Tue Nov 12, 2013 4:06 pm
Contact:

### Re: Sketcher: Bezier curves

abdullah wrote:
saso wrote:Since 8 is a nice number how about adding support for bezier curves to draft -> draft to sketch tool?

Draft is Python. I do not have the competence to do any decent Python. Sorry!

I have already played with some convertings
at that time the sketcher interface was easy to use: create the sketcher splines from point clouds, so Draft BSplines <-> Sketcher BSplines will come.
At the moment its too much dynamic in the sketcher project. Let's wait until it has finished
microelly2
Posts: 2450
Joined: Tue Nov 12, 2013 4:06 pm
Contact:

### Re: Sketcher: Bezier curves

bp_406.png (37.42 KiB) Viewed 333 times

Here is a method to convert a Draft BSpline into a Sketcher Bspline

So the way is open from a hand drawn picture to a parametric bspline curve.
abdullah
Posts: 1610
Joined: Sun May 04, 2014 3:16 pm

### Re: Sketcher: Bezier curves

microelly2 wrote:Here is a method to convert a Draft BSpline into a Sketcher Bspline

So the way is open from a hand drawn picture to a parametric bspline curve.

Beautiful. You do have a gift for giving new uses to existing tools
abdullah
Posts: 1610
Joined: Sun May 04, 2014 3:16 pm

### Re: Sketcher: Bezier curves

wmayer wrote:Attached is a sketch to demonstrate the behaviour.

The problem is caused by this line in ViewProviderSketch.cpp:

Code: Select all

`repscale = ( 0.5 * maxdisttocenterofmass ) / maxcurv; `

because it computes an individual scaling factor for each curve. But what we need is a fix scaling factor for all curves.

I find very interesting this geometric construction of C1 and C2 continuities.

While I do understand what you are saying, I am not sure how a curvature comb should look in the intersection. So I just fixed the problem you identified. Now the scale is general for all bsplines in a sketch.

The last commit in this branch should fix the problem:

https://github.com/abdullahtahiriyo/Fre ... eliverable

Let me know if it is not ok.
abdullah
Posts: 1610
Joined: Sun May 04, 2014 3:16 pm

### Re: Sketcher: Bezier curves

1. Fix curvature comb as indicated by Werner
2. Implement decrease knot multiplicity
3. Review return types in functions (I have some boolean returning functions that should probably better off by returning nothing and raising an exception if something happens)
4. Ask for icons and integrate icons.
5. Fix annoying bug that crashes FC when undo is effected after a multiplicity change.
6. Do something so that FC compiled against OCC<6.9.0 does not crash.
7. Check Werner's solver test case issue.
microelly2
Posts: 2450
Joined: Tue Nov 12, 2013 4:06 pm
Contact:

### Re: Sketcher: Bezier curves

abdullah wrote:1. Fix curvature comb as indicated by Werner
2. Implement decrease knot multiplicity

Nice to see knot reduction on top of your list.
I have played yesterday on this problem to simplify my scan-based layouts.

one other big step for me would be a constraint "pole is on the curve"
abdullah
Posts: 1610
Joined: Sun May 04, 2014 3:16 pm

### Re: Sketcher: Bezier curves

wmayer wrote:Very often the travis or AppVeyor builds fail because of this error:
======================================================================
ERROR: testSlotCase (TestSketcherApp.SketcherSolverTestCases)
----------------------------------------------------------------------
Traceback (most recent call last):
File "C:\projects\freecad\build\Mod\Sketcher\TestSketcherApp.py", line 113, in testSlotCase
CreateSlotPlateSet(self.Slot)
File "C:\projects\freecad\build\Mod\Sketcher\TestSketcherApp.py", line 61, in CreateSlotPlateSet
SketchFeature.setDatum(9,200.000000)
ValueError: Cannot set the datum because the sketch contains conflicting constraints
----------------------------------------------------------------------

If wonder why this happens and how it can be fixed.

I would say the reason is this:

The proposed fix is this:
https://github.com/abdullahtahiriyo/Fre ... 3e22e61b76

I have not removed the coincidents. It should not be needed according to my tests. If it fails after the merge, then probably we should just remove them and rewrite the test with the new constraint indexes.

abdullah
Posts: 1610
Joined: Sun May 04, 2014 3:16 pm

### Re: Sketcher: Bezier curves

microelly2 wrote:
abdullah wrote:1. Fix curvature comb as indicated by Werner
2. Implement decrease knot multiplicity

Nice to see knot reduction on top of your list.
I have played yesterday on this problem to simplify my scan-based layouts.

one other big step for me would be a constraint "pole is on the curve"

Sorry MicroElly, I cheated:

1. Fix curvature comb as indicated by Werner
2. Implement decrease knot multiplicity
3. Review return types in functions (I have some boolean returning functions that should probably better off by returning nothing and raising an exception if something happens)
4. Ask for icons and integrate icons.
5. Fix annoying bug that crashes FC when undo is effected after a multiplicity change.
6. Do something so that FC compiled against OCC<6.9.0 does not crash.
7. Check Werner's solver test case issue.

I probably will continue cheating, as I would like to get rid of 5, because this will replicate when implementing knot reduction. Somehow, because the sketchobject function is modifyrank, sooner or later I will have to do it.

I saw your other topic with the tolerance for rank reduction. I am not sure how to handle this tolerance. I was not planning on asking the user, but iteratively increasing the tolerance. However, now I realize that maybe the user want to smooth (so not using the smallest possible tolerance)... any input is welcome.

EDIT: You mean point on object (pole point on BSpline curve?)
microelly2
Posts: 2450
Joined: Tue Nov 12, 2013 4:06 pm
Contact:

### Re: Sketcher: Bezier curves

abdullah wrote:[
I saw your other topic with the tolerance for rank reduction. I am not sure how to handle this tolerance. I was not planning on asking the user, but iteratively increasing the tolerance. However, now I realize that maybe the user want to smooth (so not using the smallest possible tolerance)... any input is welcome.

when I want to delete a knot, I calculate all possibilities , display them and calculate the tolerance value.
sometimes the least square minimum is not the figure I prefer,

I have the opportunity to select my favourite and delete the others, no idea how a parametric sketch solver can do this.
maybe that this is the horizon from CAD to CAA (computer aided art)
EDIT: You mean point on object (pole point on BSpline curve?)

yes, the pole point is on the curve (a knot with a higher multiplicity)
abdullah
Posts: 1610
Joined: Sun May 04, 2014 3:16 pm

### Re: Sketcher: Bezier curves

microelly2 wrote:yes, the pole point is on the curve (a knot with a higher multiplicity)

A pole will be on the curve naturally, without any constraint when sufficiently increasing the multiplicity of the knot:

knotHigherMult.png (16.12 KiB) Viewed 164 times

This can be done in my development branch (but do not try to undo it afterwards yet )