Unexpected Chamfer behaviour when face selected

About the development of the Part Design module/workbench. PLEASE DO NOT POST HELP REQUESTS HERE!
troyp76
Posts: 32
Joined: Thu May 06, 2021 8:05 am

Unexpected Chamfer behaviour when face selected

Post by troyp76 »

Hi all,

There is an unexpected behaviour when chamfering letter shapes with a inner hole (eg "R" "O") using the Distance and angle type.

When selecting a face the inner edges have the chamfer applied in the opposite direction to the outer edges.
A consistent direction can be achieved by selecting the edges directly and then manually flipping the direction of the inner edges.
(See GIF's below and the attached example)

To apply the chamfer consistently the code around FeatureChamfer.cpp: Line 148 would need to be changed so the chamfer distance is applied along the face that was not originally selected.

Before attempting to make this change does anyone see an issue with this approach?

Cheers,

Troy

PartDesign Chamfer Face Selected.gif
PartDesign Chamfer Face Selected.gif (482.12 KiB) Viewed 1698 times
Chamfer Face Selected

PartDesign Chamfer Edge Selected.gif
PartDesign Chamfer Edge Selected.gif (429.07 KiB) Viewed 1698 times
Chamfer Edges Selected

Note: 0.19.2 behaves the same

OS: Windows 10 Version 1909
Word size of FreeCAD: 64-bit
Version: 0.20.25644 (Git)
Build type: Release
Branch: master
Hash: 12d0974525afe812e81ad623f7d915cb1784118e
Python version: 3.8.6+
Qt version: 5.15.1
Coin version: 4.0.1
OCC version: 7.5.0
Locale: English/Australia (en_AU)
Attachments
letter_chamfer.FCStd
(288.76 KiB) Downloaded 23 times
Last edited by troyp76 on Fri Sep 10, 2021 11:00 am, edited 1 time in total.
openBrain
Posts: 6520
Joined: Fri Nov 09, 2018 5:38 pm

Re: Inconsistent Chamfer behaviour when face selected

Post by openBrain »

This explains well from 3D geometry point-of-view as inner and outer edges have inverse orientations. But indeed probably not what the user expects... :|
GeneFC
Posts: 2839
Joined: Sat Mar 19, 2016 3:36 pm
Location: Punta Gorda, FL

Re: Inconsistent Chamfer behaviour when face selected

Post by GeneFC »

troyp76 wrote: Thu Sep 09, 2021 2:11 pm To apply the chamfer consistently the code around FeatureChamfer.cpp: Line 148 would need to be changed so the chamfer distance is applied along the face that was not originally selected.

Before attempting to make this change does anyone see an issue with this approach?
If you are proposing a PR then it is important to thoroughly test this on various cases. Operating on a face that was not selected could have unintended consequences in some cases.

Gene
openBrain
Posts: 6520
Joined: Fri Nov 09, 2018 5:38 pm

Re: Inconsistent Chamfer behaviour when face selected

Post by openBrain »

GeneFC wrote: Thu Sep 09, 2021 3:34 pm If you are proposing a PR then it is important to thoroughly test this on various cases. Operating on a face that was not selected could have unintended consequences in some cases.

Gene
Not sure you caught well the issue. The fact is that if you select a face that has an "hole" and chamfer it, the outer edge is chamfered with 'alpha' angle, while the inner edge is chamfered with complementary angle '90°-alpha'. Of course if you use 45° as a chamfer angle, it's not visible. :)
troyp76
Posts: 32
Joined: Thu May 06, 2021 8:05 am

Re: Unexpected Chamfer behaviour when face selected

Post by troyp76 »

openBrain wrote: Thu Sep 09, 2021 2:37 pm This explains well from 3D geometry point-of-view as inner and outer edges have inverse orientations. But indeed probably not what the user expects... :|
Yes I agree from a programmatic perspective it is being applied consistently but from user perspective it is unexpected.
(title changed to reflect this)

I created another quick test that shows the issue also happens on vertical faces so it seems like a broader issue.

For comparison I tried the same operation in two other CAD systems. (FreeCAD is on the left)
chamfer_test.png
chamfer_test.png (292.63 KiB) Viewed 1519 times

The two other systems applied the distance along the same face. (either the selected face or the other face.)

FreeCAD applies the distance along both faces which I would argue is not useful and the user would need to fall back to manually clicking all edges to control the flip direction.
(Sorry not sure of the correct terminology. :) )
openBrain
Posts: 6520
Joined: Fri Nov 09, 2018 5:38 pm

Re: Unexpected Chamfer behaviour when face selected

Post by openBrain »

We are aligned. No doubt that there is room for improvement there. ;)
Let's wait a bit if someone with some spare time dives in. If not, we can open a tracker ticket in a few days to keep trace of this.
User avatar
-alex-
Posts: 1015
Joined: Wed Feb 13, 2019 9:42 pm
Location: France

Re: Unexpected Chamfer behaviour when face selected

Post by -alex- »

troyp76 wrote: Fri Sep 10, 2021 11:26 am For comparison I tried the same operation in two other CAD systems. (FreeCAD is on the left)
Just my 2 cts, I know a big CAD system where the behaviour is similar with FreeCAD, same issue, since more than 20 years. That make me think the fix is not trivial.
BTW you mention that others CAD systems have a better behaviour and that's interesting.
I fully agree with you, any fix would be a great improvment. I hope some developper will be inspired :)
GeneFC
Posts: 2839
Joined: Sat Mar 19, 2016 3:36 pm
Location: Punta Gorda, FL

Re: Inconsistent Chamfer behaviour when face selected

Post by GeneFC »

openBrain wrote: Fri Sep 10, 2021 7:21 am Not sure you caught well the issue. The fact is that if you select a face that has an "hole" and chamfer it, the outer edge is chamfered with 'alpha' angle, while the inner edge is chamfered with complementary angle '90°-alpha'. Of course if you use 45° as a chamfer angle, it's not visible. :)
I think I caught the issue correctly. My concern is for related shapes that are not donuts. For example, a U-shaped cutout may have similar behavior. I am not the least bit opposed to a proper fix; just a quick fix that breaks something else. :shock:

Proposing to operate on the unselected face may work out fine, but the wording sounds scary.

Gene
troyp76
Posts: 32
Joined: Thu May 06, 2021 8:05 am

Re: Inconsistent Chamfer behaviour when face selected

Post by troyp76 »

GeneFC wrote: Fri Sep 10, 2021 7:16 pm
I think I caught the issue correctly. My concern is for related shapes that are not donuts. For example, a U-shaped cutout may have similar behavior. I am not the least bit opposed to a proper fix; just a quick fix that breaks something else. :shock:

Proposing to operate on the unselected face may work out fine, but the wording sounds scary.
Please don't be scared, my wording was only intended to start the discussion before attempting any development effort which of course would need to be tested and reviewed. :)

Also the suggestion was based on the existing code where it already operates on the unselected face if the orientation is flipped by the user. eg the second GIF showing the manually selected edges and the orientation being flipped.

Will wait a couple of days as openBrain suggested to see if others chime in, otherwise from the feedback and further investigation it seems worthwhile having a go at fixing it.

I anticipate the fix will involve selecting the correct flip orientation for the discovered edges (from the selected face) rather than fundamentally changing how the chamfer operation works.

Gives me an excuse to learn more about FreeCAD C++ development ...
troyp76
Posts: 32
Joined: Thu May 06, 2021 8:05 am

Re: Unexpected Chamfer behaviour when face selected

Post by troyp76 »

Finding my way around the code and now have an initial concept working. :D

Still a lot to do but it's a start.

PartDesign Chamfer Face Prototype fix.gif
PartDesign Chamfer Face Prototype fix.gif (718.55 KiB) Viewed 1123 times
Post Reply