Design456: Best practice to minimize CPU demand while redrawing the 3D object?

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
User avatar
mariwan
Posts: 469
Joined: Wed Jan 06, 2021 2:00 pm

Design456: Best practice to minimize CPU demand while redrawing the 3D object?

Post by mariwan »

I noticed that the redrawing takes too much time when I continuously do resizing(scaling) of the 3D object.

The desired 3D drawing is slow in FreeCAD or I don't know how to make it optimized.
Thinking about drawing the TopoShape object in the Coin3D is not possible. Think about all possible situations. I cannot recreate the 3D object in COIN3D.
The implementation of DirectScale is at
https://github.com/MariwanJ/Design456/b ... tScale.py
I would like to know how you would think about this matter. To understand the problem, please use the DirectScale I have in my Workbench.
For primitive simple object, you don't notice the problem.. But as soon as you use it on a complex object, it lags and take too much time.. FreeCAD might freezes for some seconds.

As the whole project is based on that, I need to find a solution. Please let me know how I do minimize CPU demand.

Why for example redrawing in Autodesk 123D Design is so smooth, you don't notice any redrawing problem? How do other CAD programs redraw the object so quickly?

Your help is appreciated.
Thanks.

https://github.com/MariwanJ/Design456
Last edited by mariwan on Sun Jul 11, 2021 4:19 pm, edited 1 time in total.
carlopav
Veteran
Posts: 2062
Joined: Mon Dec 31, 2018 1:49 pm
Location: Venice, Italy

Re: Design456: Best practice to minimize CPU demand while redrawing the 3D object?

Post by carlopav »

I suggest to take a look at Draft WB.
Almost every command do not directly modify the shape, but preview the changes using coin, and then compute the changed shape only once at the end of the transformation. This is done for Draft.Move and Draft.Rotate.
Usually the preview object is called ghost in the code.

Also Draft Scale command do it :)
https://github.com/FreeCAD/FreeCAD/blob ... le.py#L364
https://github.com/FreeCAD/FreeCAD/blob ... rs.py#L721
Last edited by carlopav on Sun Jul 11, 2021 12:27 pm, edited 1 time in total.
follow my experiments on BIM modelling for architecture design
Post Reply