Shape binder not at expected place

Post here for help on using FreeCAD's graphical user interface (GUI).
Forum rules
and Helpful information
IMPORTANT: Please click here and read this first, before asking for help

Also, be nice to others! Read the FreeCAD code of conduct!
Dekonstruierer
Posts: 45
Joined: Sat Jun 24, 2017 8:12 am

Shape binder not at expected place

Postby Dekonstruierer » Mon Aug 14, 2017 6:38 pm

Hello,
in this thread I asked something similar. But now I think it is another situation:

https://forum.freecadweb.org/viewtopic.php?t=23495

In the attached file, I have two bodies.
  • In Body1 I create a pad.
  • In body2 I create a shape binder of face6.
But the shape binder is positioned at the bottom. Selecting any other face, the shape binder lies perfectly on the selected face.

Is this a known bug? Or am I using it wrong?
Attachments
ShapeBinder not at expected place.PNG
ShapeBinder not at expected place.PNG (11.27 KiB) Viewed 761 times
ShapeBinder not at expected place.FCStd
(11.38 KiB) Downloaded 7 times
Dekonstruierer
Posts: 45
Joined: Sat Jun 24, 2017 8:12 am

Re: Shape binder not at expected place

Postby Dekonstruierer » Mon Aug 14, 2017 7:55 pm

When I add a new pad on the exisiting one in Body, the shape binder in Body001 is then on the bottom of that pad, not at global Z Position 0.
In ShapeBinder.cpp I cannot find, where the position of the ShapeBinder is set. As it does not have a position property, what could be wrong there.

Could anyone give me a small hint at which place in code I should have a look. I really would like to fix it.

Best regards
Attachments
ShapeBinder not at expected place2b.PNG
ShapeBinder not at expected place2b.PNG (1.11 KiB) Viewed 754 times
ShapeBinder not at expected place2a.PNG
ShapeBinder not at expected place2a.PNG (4.83 KiB) Viewed 754 times
ShapeBinder not at expected place.FCStd
(17.54 KiB) Downloaded 6 times
Dekonstruierer
Posts: 45
Joined: Sat Jun 24, 2017 8:12 am

Re: Shape binder not at expected place

Postby Dekonstruierer » Tue Aug 15, 2017 9:47 am

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()));
    }
Could this be an interesting place? "sub" is the face I build the Shape Binder on. But it is very difficult for me to find where the placement of the ShapeBinder is set. It must be relative to the pad where the shape binder is create of, because if I use Top Face of the Pad as Shape Binder, the Shape Binder is create at the bottom of the current pad.
Dekonstruierer
Posts: 45
Joined: Sat Jun 24, 2017 8:12 am

Re: Shape binder not at expected place

Postby Dekonstruierer » Tue Aug 15, 2017 10:28 am

If the face is not parallel to the XY-Plane, it works well:
Attachments
ShapeBinder not at expected place.FCStd
(29.09 KiB) Downloaded 6 times
ShapeBinder not at expected place3.PNG
ShapeBinder not at expected place3.PNG (15.68 KiB) Viewed 723 times
ickby
Posts: 2922
Joined: Wed Oct 05, 2011 7:36 am

Re: Shape binder not at expected place

Postby ickby » Tue Aug 15, 2017 10:56 am

you found the correct code place to look at. The Placement of the shapebinder should actually be Zero, it mustnot move. It takes all subshapes and simply adds them to itself, as the subshapes should be transformed themself. So the question is, why are some subshapes not where they are in the parent shape. Don't know exactly, could have something to do with OCC shape sharing mechanism...
Dekonstruierer
Posts: 45
Joined: Sat Jun 24, 2017 8:12 am

Re: Shape binder not at expected place

Postby Dekonstruierer » Tue Aug 15, 2017 11:08 am

Ok. Do you know where the placement in 'Part::TopoShape base;' is stored?

I guess this object should hold the neccessary information. The "_pos" field (dont know the actual class) is always X=0,Y=0,Z=0, so that seems correct.
ickby
Posts: 2922
Joined: Wed Oct 05, 2011 7:36 am

Re: Shape binder not at expected place

Postby ickby » Tue Aug 15, 2017 11:45 am

Code: Select all

Do you know where the placement in 'Part::TopoShape base;' is stored? 
It is not stored, but added directly to the geometrie in the OCC shapes. You can set and extract it with the functions given from here on: https://github.com/FreeCAD/FreeCAD/blob ... hape.h#L76

So if you extract a vertex, it will be added the location "vertex_nominal + placement". At least in theorie, there seems to be a certain problem for some subshapes. I can't guide you further as I'm currently not at my machine, but hopefully this gives you a first starting point.
Dekonstruierer
Posts: 45
Joined: Sat Jun 24, 2017 8:12 am

Re: Shape binder not at expected place

Postby Dekonstruierer » Tue Aug 15, 2017 11:50 am

Ok, thank you so far ickby.

I will try my best. I have to solve this problem, or the one I reported in issue #0003159, where, if I do not select a single face, but the complete pad, the whole shape binder is added to the pad, that was create based on the shape binder.

With these two bugs, it is not possible for me to work with shape binders :(.
Dekonstruierer
Posts: 45
Joined: Sat Jun 24, 2017 8:12 am

Re: Shape binder not at expected place

Postby Dekonstruierer » Tue Aug 15, 2017 1:11 pm

I could refine the error.
  • If I create a sketch on YZ-Plane, make a pad from it and create a shape binder on the face parallel to the sketch, the Shap Binder lies on XZ-Plane.
  • If I create a sketch on XZ-Plane, make a pad from it and create a shape binder on the face parallel to the sketch, the Shap Binder lies on XY-Plane.
  • If I create a sketch on XY-Plane, make a pad from it and create a shape binder on the face parallel to the sketch, the Shap Binder lies on XY-Plane.
This looks for me, as if there would be some matrix calculations be wrong, but I am still searching in the code. Perheps someone can give a hint based on these new information.
Attachments
ShapeBinder not expected place YZ-XZ.FCStd
(11.1 KiB) Downloaded 9 times
Dekonstruierer
Posts: 45
Joined: Sat Jun 24, 2017 8:12 am

Re: Shape binder not at expected place

Postby Dekonstruierer » Wed Aug 16, 2017 10:41 am

I added this issue in mantis:
issue #0003161