Why is FreeCAD so slow in redrawing?
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
Re: Why is FreeCAD so slow in redrawing?
can you try putting your operation commands into a simple python script for simulation without that particular workbench?
So other ones can simulate it just by running the script (on a cube)?
So other ones can simulate it just by running the script (on a cube)?
Re: Why is FreeCAD so slow in redrawing?
Believe me it is difficult to separate the code. Since you need something that the mouse interact with, you need my FR_WIDGETS which is a COIN library to draw the arrows and interact with them. I used that part on many other tools .. it is not the problem
Download my WB and change to devbranch ..
the file is located at ..\Roaming\FreeCAD\Mod\Design456\DirectModeling
called Design456_manipulate.py
The part that is doing the job called :
Code: Select all
def recreateObject(self):
But it is not complete .. I need to disable redrawing faces that didn't change during using the tool. For the cube it is only 2 faces that won't be changed.
Design456 Direct Modeling. Coin3D GUI Toolkit. Objects get simplified.
https://github.com/MariwanJ/Design456 - https://wiki.freecadweb.org/Design456_Workbench
https://www.youtube.com/watch?v=6agcHPd ... utbTDH93m_
https://github.com/MariwanJ/Design456 - https://wiki.freecadweb.org/Design456_Workbench
https://www.youtube.com/watch?v=6agcHPd ... utbTDH93m_
Re: Why is FreeCAD so slow in redrawing?
try to separate the functions.
-- is it the mouse handling that is generating the lag (I don't think so I have just quickly checked your workbench and the values updated quickly)
-- is calling the functions expensive (add some timer / profiling information to it). eg. how much does one resizing object cost how many milliseconds? how many do you try to perform in a second? Break it down to the smallest easy to test example.
-- is it the mouse handling that is generating the lag (I don't think so I have just quickly checked your workbench and the values updated quickly)
-- is calling the functions expensive (add some timer / profiling information to it). eg. how much does one resizing object cost how many milliseconds? how many do you try to perform in a second? Break it down to the smallest easy to test example.
Re: Why is FreeCAD so slow in redrawing?
Thanks for your advice. I will try that.MRx wrote: ↑Wed Nov 24, 2021 12:41 am try to separate the functions.
-- is it the mouse handling that is generating the lag (I don't think so I have just quickly checked your workbench and the values updated quickly)
-- is calling the functions expensive (add some timer / profiling information to it). eg. how much does one resizing object cost how many milliseconds? how many do you try to perform in a second? Break it down to the smallest easy to test example.
Design456 Direct Modeling. Coin3D GUI Toolkit. Objects get simplified.
https://github.com/MariwanJ/Design456 - https://wiki.freecadweb.org/Design456_Workbench
https://www.youtube.com/watch?v=6agcHPd ... utbTDH93m_
https://github.com/MariwanJ/Design456 - https://wiki.freecadweb.org/Design456_Workbench
https://www.youtube.com/watch?v=6agcHPd ... utbTDH93m_
Re: Why is FreeCAD so slow in redrawing?
It is clear that the recreate is costing too much.
I must dig into the function and find out exactly which part.
but the time is in ns not ms .. I will fix that
I must dig into the function and find out exactly which part.
but the time is in ns not ms .. I will fix that
- Attachments
-
- test.JPG (64.18 KiB) Viewed 1377 times
Design456 Direct Modeling. Coin3D GUI Toolkit. Objects get simplified.
https://github.com/MariwanJ/Design456 - https://wiki.freecadweb.org/Design456_Workbench
https://www.youtube.com/watch?v=6agcHPd ... utbTDH93m_
https://github.com/MariwanJ/Design456 - https://wiki.freecadweb.org/Design456_Workbench
https://www.youtube.com/watch?v=6agcHPd ... utbTDH93m_
Re: Why is FreeCAD so slow in redrawing?
I removed all recompute() from my tool. Surprisingly the redrawing is still working .. So there is something else triggering the recompute and redrawing the whole document.
In this video, you see that the 4 faces object is definitely more responsive. So, the recreating of the face is the cause of the issue.
The problem is that you cannot recreate the whole object only one time.. I think each time I add or remove a face a recompute trigger automatically without my intention. So, I have no control over that .. i.e I cannot fix this issue at all.
Definitely, the recreate of the object is the most expensive component in the tool and thinking in direct modeling .. It is about recreating the objects continuously.
I am quite depressed how this issue can make an end of my project. I should try some more things before I give up totally.
In this video, you see that the 4 faces object is definitely more responsive. So, the recreating of the face is the cause of the issue.
The problem is that you cannot recreate the whole object only one time.. I think each time I add or remove a face a recompute trigger automatically without my intention. So, I have no control over that .. i.e I cannot fix this issue at all.
Definitely, the recreate of the object is the most expensive component in the tool and thinking in direct modeling .. It is about recreating the objects continuously.
I am quite depressed how this issue can make an end of my project. I should try some more things before I give up totally.
Design456 Direct Modeling. Coin3D GUI Toolkit. Objects get simplified.
https://github.com/MariwanJ/Design456 - https://wiki.freecadweb.org/Design456_Workbench
https://www.youtube.com/watch?v=6agcHPd ... utbTDH93m_
https://github.com/MariwanJ/Design456 - https://wiki.freecadweb.org/Design456_Workbench
https://www.youtube.com/watch?v=6agcHPd ... utbTDH93m_
- adrianinsaval
- Veteran
- Posts: 5547
- Joined: Thu Apr 05, 2018 5:15 pm
Re: Why is FreeCAD so slow in redrawing?
can you explain maybe in pseudo code how your tool works? not how it's used but how does it work internally, the steps
for example: take an edge -> translate using example_function -> create face using example_function2 -> etc
for example: take an edge -> translate using example_function -> create face using example_function2 -> etc
Re: Why is FreeCAD so slow in redrawing?
Hi,adrianinsaval wrote: ↑Wed Nov 24, 2021 7:01 pm can you explain maybe in pseudo code how your tool works? not how it's used but how does it work internally, the steps
for example: take an edge -> translate using example_function -> create face using example_function2 -> etc
Simply it is like here :
1-Copy the edge -- Make it moving with the mouse.
2-Save the vertexes of the edge in it's origin position.. when the copied edges moves change the Placement.Base to be equal to the Wheel (coin wheel) and keep saving the new vertexes
3-Vertexes were shared with some faces. Keep vertexes of the faces and just change the vertexes of the two points that are moving.
4-Remove the original 3D object.
5-Continously recreate the faces from vertexes as far as the movement of the mouse is >=1 mm
Planned/not implemented yet:
-Recreate the 3D object by the faces created earlier when user presses the OK button.
-Check the object if it is not ok .. make it solid, and fix it so it is correct.
That is how this tool should work or works.
Design456 Direct Modeling. Coin3D GUI Toolkit. Objects get simplified.
https://github.com/MariwanJ/Design456 - https://wiki.freecadweb.org/Design456_Workbench
https://www.youtube.com/watch?v=6agcHPd ... utbTDH93m_
https://github.com/MariwanJ/Design456 - https://wiki.freecadweb.org/Design456_Workbench
https://www.youtube.com/watch?v=6agcHPd ... utbTDH93m_
- adrianinsaval
- Veteran
- Posts: 5547
- Joined: Thu Apr 05, 2018 5:15 pm
Re: Why is FreeCAD so slow in redrawing?
are you creating a shell/solid from the faces with every movement? do you recreate all faces or only the ones that share a vertex with the selected edge?
Re: Why is FreeCAD so slow in redrawing?
adrianinsaval wrote: ↑Wed Nov 24, 2021 7:47 pm are you creating a shell/solid from the faces with every movement? do you recreate all faces or only the ones that share a vertex with the selected edge?
Code: Select all
newPolygon = Part.makePolygon(_Newvertices, True)
newFace = Part.makeFilledFace(newPolygon.Edges)
if newFace.isNull():
raise RuntimeError('Failed to create face')
No the shell should be in the end when user presses the OK
Design456 Direct Modeling. Coin3D GUI Toolkit. Objects get simplified.
https://github.com/MariwanJ/Design456 - https://wiki.freecadweb.org/Design456_Workbench
https://www.youtube.com/watch?v=6agcHPd ... utbTDH93m_
https://github.com/MariwanJ/Design456 - https://wiki.freecadweb.org/Design456_Workbench
https://www.youtube.com/watch?v=6agcHPd ... utbTDH93m_