COIN3D get Boundary box or length (size) of COIN object ?

Have some feature requests, feedback, cool stuff to share, or want to know where FreeCAD is going? This is the place.
Forum rules
Be nice to others! Read the FreeCAD code of conduct!
Post Reply
User avatar
mariwan
Posts: 469
Joined: Wed Jan 06, 2021 2:00 pm

COIN3D get Boundary box or length (size) of COIN object ?

Post by mariwan »

For the rotation wheel, I need to get the size of the wheel in the scene graph.
Is there any function that can retrieve that info like we have in FreeCAD?
This is not related to a mouse-click .. So no action should be required for getting that info.. Giving the SoSeparator to that function should return the size-dimensions.


XMax , YMax and ZMax ?

I need to know these dimension to calculate the center and later use that to calculate the angle of rotation with the movement of the mouse pointer. I made a similar wheel before but is not accurate.

Thanks
User avatar
mariwan
Posts: 469
Joined: Wed Jan 06, 2021 2:00 pm

Re: COIN3D get Boundary box or length (size) of COIN object ?

Post by mariwan »

seems to be difficult to answer :cry:
User avatar
mariwan
Posts: 469
Joined: Wed Jan 06, 2021 2:00 pm

Re: COIN3D get Boundary box or length (size) of COIN object ?

Post by mariwan »

Thank you very much .. I think you saved my evening :)
I was planning to search and read lot of api.
Yesterday, I tried to understand how I use those functions but I failed. The examples given in the pages you told me helps to understand.
Look at my code for both center and boundary box max, min .. I hope it is correct.

Code: Select all

 
    def getWidgetsCentor(self):
        """[Get Center of the Widget]

        Returns:
            [App.Vector]: [Return a vector represents the centor of the widget]
        """
        viewPort = coin.SbViewportRegion()
        BoundaryAction = coin.SoGetBoundingBoxAction(viewPort)
        BoundaryAction.apply(self.w_wdgsoSwitch)
        center = BoundaryAction.getCenter()
        return App.Vector(center[0], center[1], center[2])

    def getWidgetsBoundary(self):
        """[Retrive the Min/Max size of the 3D coin object, by returning the Min vector and Max vector]

        Returns:
            [Tuple]: [Two vectors first is for the Min Boundary, second is for the Max Boundary]
        """
        viewPort = coin.SbViewportRegion()
        BoundaryAction = coin.SoGetBoundingBoxAction(viewPort)
        BoundaryAction.apply(self.w_wdgsoSwitch)
        Boundary = BoundaryAction.getBoundingBox()
        BoundMax = coin.SbVec3f()
        BoundMin = coin.SbVec3f()
        Boundary.getMax(BoundMax)
        Boundary.getMin(BoundMin)
        return ([App.Vector(BoundMin[0], BoundMin[3], BoundMin[2]),
                App.Vector(BoundMax[0], BoundMax[1], BoundMax[2])])
The switch which holdes the SoSeparator is (self.w_wdgsoSwitch). These functions will be as a part of my FR_Widget .. i.e FreeCAD COIN3D Widget toolkit.
If you are able to confirm the functions are correct, I will mark this thread as SOLVED .. please let me know.
Thanks .
User avatar
mariwan
Posts: 469
Joined: Wed Jan 06, 2021 2:00 pm

Re: COIN3D get Boundary box or length (size) of COIN object ?

Post by mariwan »

np :mrgreen:
You helped me much .. thank you
I will be using it so I will know ..
User avatar
mariwan
Posts: 469
Joined: Wed Jan 06, 2021 2:00 pm

Re: COIN3D get Boundary box or length (size) of COIN object ?

Post by mariwan »

First day working on the Face manipulator :mrgreen:

phpBB [video]
Post Reply