chbergmann / OpticsWorkbench

GNU Lesser General Public License v3.0
69 stars 23 forks source link

FreeCAD freezes when adding a row of rays inside mirror #7

Closed wohltat closed 2 years ago

wohltat commented 2 years ago

When adding a row of rays it can happen that it is created inside of a mirror which causes FreeCAD not to respond for quite a while. On the console there are many of theses lines: maximum recursion depth exceeded while calling a Python object

This can happen pretty easily when just adding a box, making it a mirror and then adding the rays. Also if one accidentally moves the rays inside a mirror, this can happen.

chbergmann commented 2 years ago

The Optics Workbench creates as many reflections as possible for every ray. Infinite loops are prevented by the exceptions you see in the console. I could implement a lower level for maximum number of reflections, but is this something we want to have ?

wohltat commented 2 years ago

What is the number of reflections right now? Does lowering it really risk functionality?

I think i would rather have a lower number of reflections than have FreeCAD not respond for some minutes, but ppl with different use cases may think otherwise. What about make a low default and add an option to set the value for max reflections?

chbergmann commented 2 years ago

A parameter MaxNrReflections has been added. The default value is 200. This should prevent freezing unless you have a beam with thousands of rays.