[in master] Test request: updated JoinFeatures,new tools BoolFragments, Slice, XOR

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
User avatar
DeepSOIC
Posts: 6852
Joined: Fri Aug 29, 2014 12:45 am
Location: Saint-Petersburg, Russia

[in master] Test request: updated JoinFeatures,new tools BoolFragments, Slice, XOR

Postby DeepSOIC » Mon Jul 18, 2016 11:46 pm

Hi!
I've been working on these for a few weeks already. The main goal was to port Connect to use generalFuse method, to make it faster. In the process, It became clear it's relatively easy to add a few more tools (which proved to be much more involved than I anticipated, but I did it :D .

Code:
https://github.com/DeepSOIC/FreeCAD-ell ... nFeatures4

I ask for some testing before I make a pull request.

Here's a brief list of what has happened:
* old JoinFeatures was changed to a deprecated state, where it is only capable of recomputing existing objects (using legacy algorithm).

* New JoinFeatures (Connect, Embed, Cutout) were implemented. They use the new generalFuse if OCC6.9.0, or fall back to legacy algorithm (less capable) if OCC is lower.
** Connect now supports multiple arguments
** Connect can take a (single) compound to act as a set of arguments (thus you can now connect self-intersecting Draft Arrays)
** Connect now works with shells/faces, and wires/edges. It might work with compsolids, too (I didn't test, it'll probably treat them as single solids).
** Connect now has Tolerance property (appears to break input shapes, so it probably should be avoided).
** Embed and Cutout are essentially unchanged. But try them on shells/faces and wires, and tell me if they work or not.

* new Split Tools: Boolean Fragments, Slice and XOR. These output compounds, and they need to be exploded to get the actual splitting. They work only if OCC is 6.9.0 and up.
** New tool: Boolean Fragments. This one is essentially generalFuse method exposed to Gui. BUT. It has Mode property, which alters its behavior. The most interesting mode is "CompSolid", which makes compsolids!
** New tool: Slice. It can split solids apart with a plane (for example). It can also "engrave" sketches onto faces of solids/whatever. It should accept a wide variety of inputs, from compsolids to vertices. Just try it, and tell me if it doesn't do what you expected.
It also has Mode property, which has "CompSolid" entry.
** New tool: Boolean XOR. That pretty much says it all. Although I doubt it will be very useful, I made it because it was easy (and it helped reveal a serious problem with the code)

API:
* the new JoinFeatures now have API to work on shapes. This API, as well as all the machinery that makes it work, is exposed as Part.BOPTools,* I hope this machinery will help create more BOP-like tools in the future!
User avatar
NormandC
Posts: 18534
Joined: Sat Feb 06, 2010 9:52 pm
Location: Québec, Canada

Re: Test request: updated JoinFeatures,new tools BoolFragments, Slice, XOR

Postby NormandC » Tue Jul 19, 2016 12:07 am

DeepSOIC wrote:New tool: Boolean XOR. That pretty much says it all.
Nope. Not for me anyway. :D
DeepSOIC wrote:New tool: Slice. It can split solids apart with a plane (for example). It can also "engrave" sketches onto faces of solids/whatever.
Sounds very interesting. Quite a few people have enquired if FreeCAD had this functionality.
User avatar
DeepSOIC
Posts: 6852
Joined: Fri Aug 29, 2014 12:45 am
Location: Saint-Petersburg, Russia

Re: Test request: updated JoinFeatures,new tools BoolFragments, Slice, XOR

Postby DeepSOIC » Tue Jul 19, 2016 5:25 pm

NormandC wrote:
DeepSOIC wrote:New tool: Boolean XOR. That pretty much says it all.
Nope. Not for me anyway. :D
Part_XOR.png
Part_XOR.png (90.67 KiB) Viewed 1425 times
User avatar
NormandC
Posts: 18534
Joined: Sat Feb 06, 2010 9:52 pm
Location: Québec, Canada

Re: Test request: updated JoinFeatures,new tools BoolFragments, Slice, XOR

Postby NormandC » Tue Jul 19, 2016 5:31 pm

Still don't know what XOR stands for.
ezzieyguywuf
Posts: 533
Joined: Tue May 19, 2015 1:11 am

Re: Test request: updated JoinFeatures,new tools BoolFragments, Slice, XOR

Postby ezzieyguywuf » Tue Jul 19, 2016 6:41 pm

https://en.wikipedia.org/wiki/Exclusive_or

Deepsoic: Is that a valid solid? It seems like some of those edges may violate the rule of number of faces per edge (I can't remember the rule specifically).
User avatar
DeepSOIC
Posts: 6852
Joined: Fri Aug 29, 2014 12:45 am
Location: Saint-Petersburg, Russia

Re: Test request: updated JoinFeatures,new tools BoolFragments, Slice, XOR

Postby DeepSOIC » Tue Jul 19, 2016 7:48 pm

ezzieyguywuf wrote:Is that a valid solid? It seems like some of those edges may violate the rule of number of faces per edge (I can't remember the rule specifically).
On the screenshot, there is no solid. It's a compound of faces on XY plane. But if you XOR some cylinders, you'll get a compound of solids. It passes BOPCheck, even though the solids/faces in the compound are touching.

It is usually considered invalid (invalid for BOP, to be specific) to have a compound of touching objects. Boolean fragments, Slice and XOR all create such compounds. Nevertheless, they pass BOPCheck, and can be put through further Boolean operations. I believe this is thanks to that things they touch with are shared.
http://www.opencascade.com/doc/occt-7.0 ... ithms_10_1
OCCT Guide wrote:The argument should not be self-interfered, i.e. all sub-shapes of the argument that have geometrical coincidence through any topological entities (vertices, edges, faces) should share these entities.
ezzieyguywuf
Posts: 533
Joined: Tue May 19, 2015 1:11 am

Re: Test request: updated JoinFeatures,new tools BoolFragments, Slice, XOR

Postby ezzieyguywuf » Tue Jul 19, 2016 8:15 pm

Neat, sounds like you've done your homework. I can't say I have an immediate use for it, but I can definitely see why having these features would be helpful. Well done!
ickby
Posts: 2914
Joined: Wed Oct 05, 2011 7:36 am

Re: Test request: updated JoinFeatures,new tools BoolFragments, Slice, XOR

Postby ickby » Wed Jul 20, 2016 5:50 am

Nicely done DeepSoic! I really love to see that Part Workbench gets all those specialized tools, that makes it ever more powerfull for advanced users! Together with a more streamlined user-friendly PartDesign IMHO this is a very good way for evolving FreeCAD!
triplus
Posts: 8605
Joined: Mon Dec 12, 2011 4:45 pm

Re: Test request: updated JoinFeatures,new tools BoolFragments, Slice, XOR

Postby triplus » Wed Jul 20, 2016 12:09 pm

ickby wrote:Nicely done DeepSoic! I really love to see that Part Workbench gets all those specialized tools, that makes it ever more powerfull for advanced users! Together with a more streamlined user-friendly PartDesign IMHO this is a very good way for evolving FreeCAD!
I am sure this will be ironed out over time but i feel we must not confuse features nobody really understand when reading the description with powerful features. And the use of substandard terminology doesn't really help here. Somebody said in the past if you can't explain it to a child you probably don't know what you are doing. ;)

Therefore this is definitely something that will need additional attention in the future. That is putting the powerful features behind understandable use-cases and short and understandable description. Terminology should be human readable and workflow intuitive.

I do understand ATM things are explored and under heavy development. Therefore they can't be perfect. But as said in the future i would expect additional effort to be made to explain something to average FreeCAD users without loose ends. That is powerful in the end.
User avatar
tanderson69
Posts: 1495
Joined: Thu Feb 18, 2010 1:07 am

Re: Test request: updated JoinFeatures,new tools BoolFragments, Slice, XOR

Postby tanderson69 » Wed Jul 20, 2016 3:14 pm

great work DeepSoic! bernd is going to love this for his FEM compsolids.