0.20 bug/regression Array Pattern issue #6641

About the development of the Part Design module/workbench. PLEASE DO NOT POST HELP REQUESTS HERE!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
wmayer
Founder
Posts: 20243
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: 0.20 bug/regression Array Pattern

Post by wmayer »

jnxd wrote: Fri Mar 25, 2022 5:08 am I have a question: what exactly does "overlap mode" do?

For example, with the example from the bug report, unless "Occurrences" is set to 60, there is no intersection between the occurrences. With "Overlap Mode", this makes a multi-solid compound out of the transformed "tool shapes". OCC's fuse algorithm doesn't seem to like fusing (at least solids) with compounds. Comp-solids behave correctly, but the fuse somehow always creates a compound.

Right now there are a couple options:
1. Run through each of the solids of the compound: can make everything slow as the last one.
2. Make the fuzzy fuse/cut on the original object itself, but this sounds like doing things exactly as with "Overlap" property set to "No overlap mode" without making a compound. As such the fuzzy operations can be done in parallel, as opposed to serially adding individual transformed tools to compound (though it can be parallelized as well in some way).

Sorry if I'm getting too technical here. Please point out where I'm being too opaque.
I had a look at this issue now:

The main purpose of the overlap mode is to avoid to run boolean operations inside the for loop when transforming the add/sub shapes. There are the three modes that either force a boolean operation, always add the transformed shape to the compound or automatically detect if a boolean operation is needed or not.

After the for loop the tool shape for the final boolean operation is computed. If overlapping mode is on then the tool shape is performed by a fusion of all transformed shapes and otherwise the compound is kept.

When using the new API (it's not so new any more) of BRepAlgoAPI_BooleanOperation to pass a list of shapes we actually don't need this workaround with the compound any more and could always use just that API.

When doing this with the test file of the first posting of this thread then the issue is fixed. I haven't tested the other projects file so far.

I have uploaded a branch to https://github.com/wwmayer/FreeCAD/tree/issue_6641 that at the moment uses your idea with the compound solid for testing purposes. But because at the end always a boolean operation is performed I think we can remove the if-else check and use the if-branch.

This has also the advantage that the boolean operation that is done to check if the result has two or more solids can be dropped.
User avatar
adrianinsaval
Veteran
Posts: 5541
Joined: Thu Apr 05, 2018 5:15 pm

Re: 0.20 bug/regression Array Pattern issue #6641

Post by adrianinsaval »

great work as always werner, are there any performance difference between your fix and current implementation?
User avatar
jnxd
Posts: 951
Joined: Mon Mar 30, 2015 2:30 pm
Contact:

Re: 0.20 bug/regression Array Pattern

Post by jnxd »

wmayer wrote: Thu Apr 07, 2022 3:31 pm The main purpose of the overlap mode is to avoid to run boolean operations inside the for loop when transforming the add/sub shapes. ...

After the for loop the tool shape for the final boolean operation is computed. If overlapping mode is on then the tool shape is performed by a fusion of all transformed shapes and otherwise the compound is kept.

When using the new API (it's not so new any more) of BRepAlgoAPI_BooleanOperation to pass a list of shapes we actually don't need this workaround with the compound any more and could always use just that API.
Thank you for the explanation. I do believe I was faffing around and did try the "list of shapes" approach, albeit without this context.
wmayer wrote: Thu Apr 07, 2022 3:31 pm When doing this with the test file of the first posting of this thread then the issue is fixed. I haven't tested the other projects file so far.
If the experiments I was doing (will explain shortly) were effectively resulting in the same changes, I don't expect the fillet issues to be solved with this.
wmayer wrote: Thu Apr 07, 2022 3:31 pm I have uploaded a branch to https://github.com/wwmayer/FreeCAD/tree/issue_6641 that at the moment uses your idea with the compound solid for testing purposes. But because at the end always a boolean operation is performed I think we can remove the if-else check and use the if-branch.
So would you say the if-branch is equivalent to the following?

Code: Select all

       if (!fuseShape.isNull()) {
           current = TopoShape(current).fuse(shapes, Precision::Confusion());
            if (current.IsNull()) {
                std::stringstream error;
                error << "Boolean operation failed";
                return new App::DocumentObjectExecReturn(error.str());
            }
        } else {...}
I tried this, since there was some issue while trying to put the fillet's shape to the compound. It would work with the original test cases (AFAICT), but failed for some fillet cases still.

That said this solution does appear to resolve our main gripe with CompSolids that we don't know what side effect(s) their use might have.
My latest (or last) project: B-spline Construction Project.
User avatar
adrianinsaval
Veteran
Posts: 5541
Joined: Thu Apr 05, 2018 5:15 pm

Re: 0.20 bug/regression Array Pattern issue #6641

Post by adrianinsaval »

Can you remind me what are the issues with fillets? if it's not a regression they aren't very important right now IMO. Also it might be a completely independent issue from this one. Fillet patterns are a relatively new feature that isn't fully supported.
User avatar
jnxd
Posts: 951
Joined: Mon Mar 30, 2015 2:30 pm
Contact:

Re: 0.20 bug/regression Array Pattern issue #6641

Post by jnxd »

adrianinsaval wrote: Thu Apr 07, 2022 8:14 pm Can you remind me what are the issues with fillets? if it's not a regression they aren't very important right now IMO. Also it might be a completely independent issue from this one. Fillet patterns are a relatively new feature that isn't fully supported.
I'll have to go through the posts again myself to recall what exactly is the issue, but in rough strokes:
1. Sometimes a pattern with fillets causes some unknown "instability" in OCC, leading to garbage output.
2. Even if it works exactly as designed, the outcome is probably not what you want.

If it is indeed new, these issues can be dealt in the future, but we should at least put a warning that fillet patterns aren't a good idea.
My latest (or last) project: B-spline Construction Project.
User avatar
adrianinsaval
Veteran
Posts: 5541
Joined: Thu Apr 05, 2018 5:15 pm

Re: 0.20 bug/regression Array Pattern issue #6641

Post by adrianinsaval »

probably best to open a separate topic/issue for dressup feature transforms
user1234
Veteran
Posts: 3332
Joined: Mon Jul 11, 2016 5:08 pm

Re: 0.20 bug/regression Array Pattern issue #6641

Post by user1234 »

jnxd wrote: Thu Apr 07, 2022 8:24 pm If it is indeed new, these issues can be dealt in the future, but we should at least put a warning that fillet patterns aren't a good idea.
No, it is a regression. The example this thread here works with 0.19. Also on an other thread, https://forum.freecad.org/viewtopic.php?t=67716, it works with 0.19 and do not work with 0.20 master.
0.19.3.png
0.19.3.png (180.79 KiB) Viewed 1462 times
0.20master.png
0.20master.png (164.81 KiB) Viewed 1462 times


Greetings
user1234

edit: typo, i should sleep more
User avatar
jnxd
Posts: 951
Joined: Mon Mar 30, 2015 2:30 pm
Contact:

Re: 0.20 bug/regression Array Pattern issue #6641

Post by jnxd »

user1234 wrote: Thu Apr 07, 2022 9:56 pm
jnxd wrote: Thu Apr 07, 2022 8:24 pm If it is indeed new, these issues can be dealt in the future, but we should at least put a warning that fillet patterns aren't a good idea.
No, it is a regression. The example this thread here works with 0.19. Also on an other thread, https://forum.freecad.org/viewtopic.php?t=67716, it works with 0.19 and do not work with 0.20 master.
Oh right this is still there, and I believe i know a solution to it (it's the fuse/cut tool idea).

I still doubt all the examples in this thread work with 0.19 though, but the only thing I have to check it is reverting the changes.
My latest (or last) project: B-spline Construction Project.
User avatar
jnxd
Posts: 951
Joined: Mon Mar 30, 2015 2:30 pm
Contact:

Re: 0.20 bug/regression Array Pattern

Post by jnxd »

wmayer wrote: Thu Apr 07, 2022 3:31 pm I have uploaded a branch to https://github.com/wwmayer/FreeCAD/tree/issue_6641 that at the moment uses your idea with the compound solid for testing purposes. But because at the end always a boolean operation is performed I think we can remove the if-else check and use the if-branch.
Forgot to mention fillet/dressup has issues with simply using comp-solids for pattern/transform, and that is a regression from 0.19. We should either choose the if-branch, or also make sure dressup gives compsolids for add/sub shapes.
My latest (or last) project: B-spline Construction Project.
User avatar
jnxd
Posts: 951
Joined: Mon Mar 30, 2015 2:30 pm
Contact:

Re: 0.20 bug/regression Array Pattern issue #6641

Post by jnxd »

user1234 wrote: Thu Apr 07, 2022 9:56 pm No, it is a regression. The example this thread here works with 0.19. Also on an other thread, https://forum.freecad.org/viewtopic.php?t=67716, it works with 0.19 and do not work with 0.20 master.
See https://forum.freecadweb.org/viewtopic. ... 71#p587071.
My latest (or last) project: B-spline Construction Project.
Post Reply