Shapebinder fusion: remove it?

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!
User avatar
DeepSOIC
Veteran
Posts: 7896
Joined: Fri Aug 29, 2014 12:45 am
Location: used to be Saint-Petersburg, Russia

Shapebinder fusion: remove it?

Post by DeepSOIC »

Hi
I want to attempt fixing shapebinder placement bug, reported here: https://forum.freecadweb.org/viewtopic.php?f=20&t=33794

I noticed, there is fusion going on under the hood, and it doesn't seem right to me. Shapebinder is only used for linking, and fusion is a great way to mess up the indexing. So I'd like to change it to a compound, but that might break some older projects (probably, very few).

The code:
https://github.com/FreeCAD/FreeCAD/blob ... r.cpp#L160

Code: Select all

Part::TopoShape ShapeBinder::buildShapeFromReferences( Part::Feature* obj, std::vector< std::string > subs) {

    if (!obj)
        return TopoDS_Shape();

    if (subs.empty())
        return obj->Shape.getShape();

    //if we use multiple subshapes we build a shape from them by fusing them together
    Part::TopoShape base;
    std::vector<TopoDS_Shape> operators;
    for (std::string sub : subs) {
        if (base.isNull())
            base = obj->Shape.getShape().getSubShape(sub.c_str());
        else
            operators.push_back(obj->Shape.getShape().getSubShape(sub.c_str()));
    }

    try {
        if (!operators.empty() && !base.isNull())
            return base.fuse(operators); //                <----    !!!!!!!!!!
    }
    catch (...) {
        return base;
    }
    return base;
}
Fusion might be not that bad if shapes share topology - I think, OCC detects that, and doesn't search for intersections. But if they don't, fusion will probably do nothing except wasting cpu cycles (and if the subs actually intersect, which is pretty unlikely but is still possible, new edges are not at all helpful IMO).

Any objections for changing fusion to compounding?
User avatar
NormandC
Veteran
Posts: 18589
Joined: Sat Feb 06, 2010 9:52 pm
Location: Québec, Canada

Re: Shapebinder fusion: remove it?

Post by NormandC »

Something to take into consideration, before doing this change. At one point, ickby and I discussed of expanding the ShapeBinder functionality to transform it into a base feature through a parameter. My lunch break is nearly over so I don't have time to locate the discussion or Mantis ticket.
RatonLaveur
Posts: 991
Joined: Wed Mar 27, 2019 10:45 am

Re: Shapebinder fusion: remove it?

Post by RatonLaveur »

I'm reviving an old post here, we were having a discussion with some people including abdullah
https://forum.freecadweb.org/viewtopic.php?f=3&t=36993

regarding the possibility of extracting direct usable geometry from a shapebinder. Either construction (not just reference) or real geometry.

I think your last statement NormandC actually taps into this idea, making the shapebinder as a basefeature so I wanted to leave a connection between the two discussions here.
User avatar
OficineRobotica
Posts: 433
Joined: Thu Feb 21, 2019 8:17 am
Contact:

Re: Shapebinder fusion: remove it?

Post by OficineRobotica »

NormandC wrote: Thu Jan 31, 2019 6:00 pm Something to take into consideration, before doing this change. At one point, ickby and I discussed of expanding the ShapeBinder functionality to transform it into a base feature through a parameter. My lunch break is nearly over so I don't have time to locate the discussion or Mantis ticket.
I'm not a coder so sorry if I jump in but this would be such an awesome feature. I hit a similar problem http://forum.freecadweb.org/viewtopic.php?t=39551 and having shape binders as base features or transformable in to real geometry could come so handy when working with assemblies and the need arises to reference , for example , position of holes on other bodies. This way the newly created body can be saved into it's own file witought external dependencies . Handy for later import into a assembly file.

Thank you devs for all your efforts.
Check out my Youtube channel at: https://www.youtube.com/@OficineRobotica
User avatar
DeepSOIC
Veteran
Posts: 7896
Joined: Fri Aug 29, 2014 12:45 am
Location: used to be Saint-Petersburg, Russia

Re: Shapebinder fusion: remove it?

Post by DeepSOIC »

OficineRobotica wrote: Mon Sep 23, 2019 5:10 pm ShapeBinder functionality to transform it into a base feature...
and having shape binders as base features or transformable in to real geometry could come so handy
Most of it is possible with Part-o-magic addon. However, with some hacks, you can achieve something it without PoM.
For example, say you want to create a body in the root of project, that starts off a body buried in some placed Parts. So you:
1. create a temporary Body to place the shapebinder there
2. create the shapebinder, set TraceSupport to True
3. drag the shapebinder out of Body, delete Body.
4. select the shapebinder, and create a new body
-> the new body will be based on the geometry of shapebinder.

If you want to use a shapebinder as a feature shape, you go through all the above steps to convert a shapebinder into a body, and then use the body in PD Boolean.

With Part-o-magic, the above 3 steps are replaced with just one command (it simply allows to create a shapebinder/ghost anywhere). And if you want to use it as feature geometry, you create a PoM AdditiveFeature, put a shapebinder/ghost of the thing you need in there, and done.

I think it's a good idea to lift a LOT of partdesign's artificial restrictions. Hopefully, some day someone just does it. As far as I remember, realthunder has already removed single solid limitation in his branch.
User avatar
OficineRobotica
Posts: 433
Joined: Thu Feb 21, 2019 8:17 am
Contact:

Re: Shapebinder fusion: remove it?

Post by OficineRobotica »

Thank you @DeepSOIC . I'm giving PoM a try right now....very useful tool to have.
Check out my Youtube channel at: https://www.youtube.com/@OficineRobotica
vocx
Veteran
Posts: 5197
Joined: Thu Oct 18, 2018 9:18 pm

Re: Shapebinder fusion: remove it?

Post by vocx »

DeepSOIC wrote: Mon Sep 23, 2019 5:38 pm Most of it is possible with Part-o-magic addon. ...
Honestly, you should put a link to Part-o-magic and other tools that you maintain in your signature. I think developers of External workbenches who do this make it easier for anybody to try things. Like Joel Graff and his Trails, Klaus with A2plus, microelly with his stuff, and so on.

"Try Part-o-magic, it has tools to work with objects and do assemblies."
Always add the important information to your posts if you need help. Also see Tutorials and Video tutorials.
To support the documentation effort, and code development, your donation is appreciated: liberapay.com/FreeCAD.
User avatar
DeepSOIC
Veteran
Posts: 7896
Joined: Fri Aug 29, 2014 12:45 am
Location: used to be Saint-Petersburg, Russia

Re: Shapebinder fusion: remove it?

Post by DeepSOIC »

vocx wrote: Mon Sep 23, 2019 11:51 pm Honestly, you should put a link to Part-o-magic and other tools that you maintain in your signature
:? maybe I'm too sick seeing ads everywhere, to do it....
vocx
Veteran
Posts: 5197
Joined: Thu Oct 18, 2018 9:18 pm

Re: Shapebinder fusion: remove it?

Post by vocx »

DeepSOIC wrote: Tue Sep 24, 2019 12:29 am :? maybe I'm too sick seeing ads everywhere, to do it....
But this isn't an annoying pop-up for something commercial; it's more about getting people to try an interesting thing that isn't part of the base system. Besides, if you are going to mention the workbench in many posts, why not just give a link to the workbench already?
Always add the important information to your posts if you need help. Also see Tutorials and Video tutorials.
To support the documentation effort, and code development, your donation is appreciated: liberapay.com/FreeCAD.
chrisb
Veteran
Posts: 54166
Joined: Tue Mar 17, 2015 9:14 am

Re: Shapebinder fusion: remove it?

Post by chrisb »

From what they do your workbenches could well be added to the base system (if they wouldn't do some messing with the PartDesign tip).
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
Post Reply