0001304: Allow Sketcher to Fillet Arcs, Not Only Lines

Post here for help on using FreeCAD's graphical user interface (GUI).
Forum rules
and Helpful information
IMPORTANT: Please click here and read this first, before asking for help

Also, be nice to others! Read the FreeCAD code of conduct!
RogerK
Posts: 27
Joined: Thu Oct 04, 2018 6:25 pm
Location: Elsau

Re: 0001304: Allow Sketcher to Fillet Arcs, Not Only Lines

Postby RogerK » Fri Nov 02, 2018 3:35 pm

Hi abdullah

To keep you busy during the weekend, I have also something for you :oops:.

When a line and an ellipse segment is fillet this could happend:
SketcherFilletEllipseLineIssue1.gif
SketcherFilletEllipseLineIssue1.gif (154.79 KiB) Viewed 318 times
SketcherFilletEllipseLineIssue2.gif
SketcherFilletEllipseLineIssue2.gif (183.85 KiB) Viewed 318 times

Testfile:
SketcherFilletEllipseLine.FCStd
(9.19 KiB) Downloaded 6 times

Version:
OS: Windows 10
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.18.15113 (Git)
Build type: Release
Branch: master
Hash: e86f7caea866db5b78cfa78e5d3a10b735b205f9
Python version: 3.6.6
Qt version: 5.6.2
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: German/Switzerland (de_CH)


Kind regards

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

Re: 0001304: Allow Sketcher to Fillet Arcs, Not Only Lines

Postby abdullah » Sat Nov 03, 2018 1:10 pm

chrisb wrote:
Fri Nov 02, 2018 7:42 am
Here is the test file. My previous observation lead me to partly wrong conclusions, these should be more precise. Each Sketch contains two lines which I tried to fillet at their joint. I observe the following behaviour

Sketch: Error message in report view, which is ok. other possible behaviour: arc to a side depending on which click is nearer to the joint.

Sketch001: instead of an arc a circle is created and the existing arc turns to a circle as well.

Sketch002: the construction lines serve the only purpose to indicate where above them you have to click to show the described behaviour. Filleting at the position of the right construction line works, at the left line I get an error.
The two first examples I am not sure yet what to do with them.

The last example "is" expected behaviour to me. I am going to try to explain what is happening and most probably you will be able to tell me what would you like to have as result.

1) The algorithm works by constructing offset curves at a "radius" distance from each curve, the intersection being the centre of the fillet.
2) The radius is estimated from the points where the user clicks (currently is the distance between those points, another estimation may be better).
3) For the example:
Screenshot_20181103_140714.png
Screenshot_20181103_140714.png (4.96 KiB) Viewed 301 times
There is a radius value (around 5-6 mm), for which the offset curve of the arc goes under the offset curve of the line segment, so that they do not intersect. In other words, a fillet of 6 mm is too big and can not be done.

If as a user you expect a fillet when clicking there, then we have to come to a better radius estimation.
abdullah
Posts: 3583
Joined: Sun May 04, 2014 3:16 pm

Re: 0001304: Allow Sketcher to Fillet Arcs, Not Only Lines

Postby abdullah » Sat Nov 03, 2018 1:14 pm

RogerK wrote:
Fri Nov 02, 2018 3:35 pm
To keep you busy during the weekend, I have also something for you :oops:.
:D

I enjoyed your example quite a lot.

In the algorithm that is currently in master, if two curves intersect at a point in which there is a coincident constraint, the other points are ignored. If there are several such points, that closest to the points where you click is used. In your sketch, there is a "missing" coincidence between the line and the ellipse.

Your example makes me realise that what looked to me as a good solution is not a good solution, so I will have to come with something better.

In any case, you example has a lot of other issues... I will have to go one at a time...
abdullah
Posts: 3583
Joined: Sun May 04, 2014 3:16 pm

Re: 0001304: Allow Sketcher to Fillet Arcs, Not Only Lines

Postby abdullah » Sat Nov 03, 2018 3:12 pm

Something very weird is happening with the GridSnap of the Sketcher. It may be activated with the checkbox unmarked. I have lost 3 hours trying fillets that were failing because the point actually clicked was "snap to grid" before sending it to the fillet tool. I will try to debug that tomorrow, as it is really annoying. I note it here just in case you helpers start receiving weird situations. You can get the real state of the Gridsnap with:

Code: Select all

>>> ActiveSketch.ViewObject.GridSnap
False
chrisb
Posts: 29076
Joined: Tue Mar 17, 2015 9:14 am

Re: 0001304: Allow Sketcher to Fillet Arcs, Not Only Lines

Postby chrisb » Sat Nov 03, 2018 4:36 pm

abdullah wrote:
Sat Nov 03, 2018 1:10 pm
If as a user you expect a fillet when clicking there, then we have to come to a better radius estimation.
I would have expected one of these two, with one of the fillet starts being where I have clicked, or something in between.
Attachments
Bildschirmfoto 2018-11-03 um 17.29.58.png
Bildschirmfoto 2018-11-03 um 17.29.58.png (15.78 KiB) Viewed 283 times
Bildschirmfoto 2018-11-03 um 17.33.24.png
Bildschirmfoto 2018-11-03 um 17.33.24.png (16.14 KiB) Viewed 283 times
A Sketcher Lecture with in-depth information is available in English, auf deutsch, en français, en español.
abdullah
Posts: 3583
Joined: Sun May 04, 2014 3:16 pm

Re: 0001304: Allow Sketcher to Fillet Arcs, Not Only Lines

Postby abdullah » Sat Nov 03, 2018 6:59 pm

chrisb wrote:
Sat Nov 03, 2018 4:36 pm
abdullah wrote:
Sat Nov 03, 2018 1:10 pm
If as a user you expect a fillet when clicking there, then we have to come to a better radius estimation.
I would have expected one of these two, with one of the fillet starts being where I have clicked, or something in between.
Actually that is a brilliant, easy to implement idea. Better?
FilletRadiusEstimationImprovement.gif
FilletRadiusEstimationImprovement.gif (58.66 KiB) Viewed 268 times
I have added it to the pending:
https://github.com/FreeCAD/FreeCAD/pull/1765
chrisb
Posts: 29076
Joined: Tue Mar 17, 2015 9:14 am

Re: 0001304: Allow Sketcher to Fillet Arcs, Not Only Lines

Postby chrisb » Sat Nov 03, 2018 10:30 pm

Looks wonderful! Am I right, that the last click defines the point where the fillet starts?
A Sketcher Lecture with in-depth information is available in English, auf deutsch, en français, en español.
abdullah
Posts: 3583
Joined: Sun May 04, 2014 3:16 pm

Re: 0001304: Allow Sketcher to Fillet Arcs, Not Only Lines

Postby abdullah » Sun Nov 04, 2018 6:32 am

chrisb wrote:
Sat Nov 03, 2018 10:30 pm
Looks wonderful! Am I right, that the last click defines the point where the fillet starts?
Thanks! :D

Not really, it is a little bit more complicated than that. Defining a fillet for general curves by clicking is not the be best way, but it is user friendly. The reason is that the user may click in places where no tangency is possible (for both clicks, the fillet being an arc of circle). So the "game" is to estimate a fillet radius from those positions.

The thing is kindda egg-chicken type. Before you define the radius of the fillet, you cannot create the offset curves to calculate its center, and without its center, you cannot measure the radius (to the location in the curves where it is tangent).

The previous algorithms used merely the distance between user clicks, or half the distance as radius. But it was not satisfactory.

Taking only one of the clicks generates a problem: with respect to what shall I measure the distance? click to where?

The current algorithm works as follows:
1. It calculates the normals at the clicking points to the respective curves.
2. It calculates the intersection point of the lines going thru the intersection points with normal direction (if it exists).
This intersection point is not the center of the fillet, as the distance to the clicking points is different, so an arc of circle could not be traced being normal to both curves at the click positions.
3. It now calculates the length of the vectors from this intersection to the clicked positions, giving two different lengths.
4. The lengths are averaged, giving an effective length, which is regarded as the closest radius to what the user intends.
5. If anything goes wrong (mostly OCCT exceptions...), the radius defaults to the distance between clicking points.

It is the best I have come with...

git commit df94e8380842be7eba5c764d362255edbaf22165
abdullah
Posts: 3583
Joined: Sun May 04, 2014 3:16 pm

Re: 0001304: Allow Sketcher to Fillet Arcs, Not Only Lines

Postby abdullah » Sun Nov 04, 2018 7:07 am

I am going to work on another bug for a while until all the new improvements get merged.

After the improvements get merged and propagate to the PPA, some additional testing would be nice.

There is one point on my agenda, related to RogerK's case, what exactly to do with filleting and lack of constraints on the endpoints of the curves to fillet, or constraints on the other end, but not where one wants the fillet.

The state of affairs is as follows:
1. Fillet routine can extend certain curves to calculate where the would intersect (certainly not B-Splines, just trimmed curves, conics and line segments). However intersecting code is not always reliable at the moment, waiting for OCCT upstream results on bug reports.

2. The current coding makes an endpoint having a coincidence/endpoint tangency/endpoint perpendicular take priority over an endpoint not having any such constraint regardless of the distance (in fact B-Splines require such constraint, as they cannot be extended). This allows to solve most of the problems under item 1, but introduces the problem observed by RogerK, i.e. when you want the fillet an end not having a coincidence, while the other end does have a coincidence.

3. If both ends have constraints as described above, the one with the shortest distance is taken. So this case should work just fine.

In general, I think that requiring a constraint is not intuitive. However, in most of the use cases I think there is a constraint there, as users then to draw the squarish sketch and then fillet it. I probably need to inspire myself...
RogerK
Posts: 27
Joined: Thu Oct 04, 2018 6:25 pm
Location: Elsau

Re: 0001304: Allow Sketcher to Fillet Arcs, Not Only Lines

Postby RogerK » Sun Nov 04, 2018 7:23 am

abdullah wrote:
Sat Nov 03, 2018 1:14 pm
In your sketch, there is a "missing" coincidence between the line and the ellipse.
Your are perfectely right, the right coincident constraint was missing. I'm sorry, I hadn't seen that.

I have retried the construction several time. When the line is drawn, the fix point on object constraints are set on both ends. When I now trim the ellipse, the first time the fix point on object is converted to a coincident constriant. On the second trim, the fix point on object is just removed, but no coincident constraint is placed.
SketcherTrimConeLineIssue.gif
SketcherTrimConeLineIssue.gif (610.76 KiB) Viewed 241 times
Attachments
SketcherTrimEllipseLine.FCStd
(11.58 KiB) Downloaded 6 times