Page 3 of 5

Re: FC#3006: PartDesign Mirrored bugs

Posted: Mon Jun 05, 2017 4:31 am
by abdullah
For a couple of days I will be working on DAG cyclic detection and recomputes.

This is post for self about checkIntersection to save the context.

The problem:
1. https://www.freecadweb.org/tracker/view.php?id=3065
2. CheckIntersection is not called for the output of the previous transformation, so in some cases it can not detect an intersection between successive transformations not even if it would work perfectly.
3. If we can not fix extrema and boolean fails on edge, sgrogan's Glitter idea of using fuzzy boolean may be worth a try (where the linked OCC supports it).

Re: FC#3006: PartDesign Mirrored bugs

Posted: Wed Jun 07, 2017 5:40 pm
by abdullah
kkremitzki wrote: Thu Jun 01, 2017 10:23 pm Yup, Abdullah and I came to this conclusion as well and divided up the investigation, with me taking the first and him taking the second.
Those two commits:
https://github.com/abdullahtahiriyo/Fre ... on_failure

fix the problem with the intersection.

The first commit reverts the intersection detection method to boolean, as the extrema method fails sometimes on touching.

The second commit modifies the way the transformation feature operates and fuses each individual transformation after a successful "checkintersection". This enables to extend the support to the result of this individual transformation, as it may be this extension what actually intersects with the next individual transformation.

In the way, I have dropped the creation of the compound and that second optional fuse that I think it is a consequence of the creation of the compound. I am not certain of it. I would be grateful if anybody with a better understanding of OCC gives it a look to ensure it is ok.

In my tests it works a treat, but I have not extensively tested it. If somebody feels energetic enough to do some more/extensive testing FC will be grateful.

Kurt, you can cherry-pick those two commits into your branch and I think this should enable you now to fix that annoying mesh bug. It is not only inversion also misses some kind of translation, see:
mesh1.png
mesh1.png (10.44 KiB) Viewed 2301 times
mesh2.png
mesh2.png (2.9 KiB) Viewed 2301 times
This is a transformation about the Horizontal sketch axis that should appear at the other side of the X axis, so the red mesh should not touch the original block, not even one edge, it should be totally apart, which is not...

The transformation about the Vertical axis, of course, succeeds:
mesh3.png
mesh3.png (2.63 KiB) Viewed 2301 times
A double mirror transformation gives a weird result with the red mesh, with one displaced and the other not:
mesh4.png
mesh4.png (2.41 KiB) Viewed 2301 times

Re: FC#3006: PartDesign Mirrored bugs

Posted: Wed Jun 07, 2017 8:38 pm
by kkremitzki
abdullah wrote: Wed Jun 07, 2017 5:40 pm
kkremitzki wrote: Thu Jun 01, 2017 10:23 pm Yup, Abdullah and I came to this conclusion as well and divided up the investigation, with me taking the first and him taking the second.
Those two commits:
https://github.com/abdullahtahiriyo/Fre ... on_failure

fix the problem with the intersection.
Looks good! Here's the commit that fixes the failure mesh: https://github.com/FreeCAD/FreeCAD/comp ... zki:pd3006

It turns out that gp_Trsf::VectorialPart is already including the scale factor, so the multiplication was happening twice.

Now there is some strange behavior with the failure mesh not being colored red in all cases:
mirror.png
mirror.png (151.68 KiB) Viewed 2283 times

Previously, even when there was a failure, the messages box in the task window would say "... shapes do not intersect support. Transformation succeeded."

So I think there is actually a 3rd bug in here, and we're seeing new behavior from it now that the first two have been fixed!

Re: FC#3006: PartDesign Mirrored bugs

Posted: Wed Jun 07, 2017 8:54 pm
by kkremitzki
I should note that previous to cherry-picking your commits, the failure mesh was always showing up in black and not red. Time to dig further...

Re: FC#3006: PartDesign Mirrored bugs

Posted: Thu Jun 08, 2017 3:45 am
by kkremitzki
https://github.com/kkremitzki/FreeCAD/tree/pd3006 now has your commits plus one that fixes the failure mesh being in the wrong location, as well as a commit that fixes the "shapes do not intersect... transformation succeeded" message issue. Now all that's left for PartDesign Mirror to be fixed is getting the red error coloring back!

Re: FC#3006: PartDesign Mirrored bugs

Posted: Thu Jun 08, 2017 4:33 am
by abdullah
kkremitzki wrote: Thu Jun 08, 2017 3:45 am https://github.com/kkremitzki/FreeCAD/tree/pd3006 now has your commits plus one that fixes the failure mesh being in the wrong location, as well as a commit that fixes the "shapes do not intersect... transformation succeeded" message issue. Now all that's left for PartDesign Mirror to be fixed is getting the red error coloring back!
There is another one at least, that when after having entered some transformations, if you click "close" FC segfaults. It has happened to me a couple of times. Not sure what exactly has to be done before pressing close.
kkremitzki wrote: Wed Jun 07, 2017 8:38 pm Here's the commit that fixes the failure mesh: https://github.com/FreeCAD/FreeCAD/comp ... zki:pd3006

It turns out that gp_Trsf::VectorialPart is already including the scale factor, so the multiplication was happening twice.
LGTM.
kkremitzki wrote: Wed Jun 07, 2017 8:38 pm Now there is some strange behavior with the failure mesh not being colored red in all cases:
This one is really funny. Without your commit it is out of place but red, with your commit it is in place but black. And it gets better:
multi_transform_no_checkintersection3.png
multi_transform_no_checkintersection3.png (3.41 KiB) Viewed 2246 times
multi-transform-multifeature.fcstd
(79.72 KiB) Downloaded 70 times
Now with 3 transformation Vertical axis, bottom face, Horizontal axis, I get two red and two black... time to go to the casino :lol:

Re: FC#3006: PartDesign Mirrored bugs

Posted: Thu Jun 08, 2017 4:43 am
by abdullah
kkremitzki wrote: Thu Jun 08, 2017 3:45 am https://github.com/kkremitzki/FreeCAD/tree/pd3006 now has your commits plus one that fixes the failure mesh being in the wrong location, as well as a commit that fixes the "shapes do not intersect... transformation succeeded" message issue. Now all that's left for PartDesign Mirror to be fixed is getting the red error coloring back!
If the last transformation fails, and the user nevertheless hits ok, he sees the effect of the n-1 transformations before (there is not even a red exclamation mark on the feature). So the full transformation is failing, indeed, but a partial result is shown. I am unsure what is best. Maybe the current behaviour is the best and we should arrange so that the red exclamation mark appears when not all the transformations succeeded.


I have changed one of my commits to clean up (remove unused variables). The new branch with all your commits on top of this here:
https://github.com/abdullahtahiriyo/Fre ... r_issues_1

Re: FC#3006: PartDesign Mirrored bugs

Posted: Thu Jun 08, 2017 5:31 am
by kkremitzki
abdullah wrote: Thu Jun 08, 2017 4:43 am
kkremitzki wrote: Thu Jun 08, 2017 3:45 am https://github.com/kkremitzki/FreeCAD/tree/pd3006 now has your commits plus one that fixes the failure mesh being in the wrong location, as well as a commit that fixes the "shapes do not intersect... transformation succeeded" message issue. Now all that's left for PartDesign Mirror to be fixed is getting the red error coloring back!
If the last transformation fails, and the user nevertheless hits ok, he sees the effect of the n-1 transformations before (there is not even a red exclamation mark on the feature). So the full transformation is failing, indeed, but a partial result is shown. I am unsure what is best. Maybe the current behaviour is the best and we should arrange so that the red exclamation mark appears when not all the transformations succeeded.


I have changed one of my commits to clean up (remove unused variables). The new branch with all your commits on top of this here:
https://github.com/abdullahtahiriyo/Fre ... r_issues_1
Hmm, you should check in the case of a single Mirrored command on your example with the cube offset by 30mm in the Y direction. If you try to mirror it about the horizontal sketch axis, you'll get the not-red failed mesh, and if you try to click ok, you'll be prevented:
pdmirror.png
pdmirror.png (97.93 KiB) Viewed 2240 times

Re: FC#3006: PartDesign Mirrored bugs

Posted: Thu Jun 08, 2017 11:24 am
by abdullah
kkremitzki wrote: Thu Jun 08, 2017 5:31 am Hmm, you should check in the case of a single Mirrored command on your example with the cube offset by 30mm in the Y direction. If you try to mirror it about the horizontal sketch axis, you'll get the not-red failed mesh, and if you try to click ok, you'll be prevented:
Yup. You are right. I complained about the exclamation mark because it was late at night and I forgot to compile after cherry-picking. But your code does also indirectly set the exclamation mark, because it returns a non StdReturn DocumentObjectExecReturn. :)

Re: FC#3006: PartDesign Mirrored bugs

Posted: Thu Jun 08, 2017 4:51 pm
by abdullah
I just tested the branch with OCE:

OS: Ubuntu 16.04.2 LTS
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.17.11211 +4 (Git)
Build type: Debug
Branch: mirror_issues_1
Hash: d164c4a53f91530584a1b9ac8a88e1d2b8ce14bb
Python version: 2.7.12
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 6.8.0.oce-0.17

The bug fixes work as good as with OCC 7.1.