FullControlXYZ / fullcontrol

Python version of FullControl for toolpath design (and more) - the readme below is best source of information
GNU General Public License v3.0
672 stars 78 forks source link

[BUG] generate_mesh fails when optional argument colors_now takes default value (None) #109

Open wjvandersluis opened 1 week ago

wjvandersluis commented 1 week ago

Describe the bug The generate_mesh() function in fullcontrol/visualize/plotly.py fails when colors_now is None. The code attempts to modify colors_now without first checking if it is set, causing a runtime error on the line colors_now[:] = np.array(colors_now, dtype=object)[good_points].

The error is triggered when generate_stl() in lab/fullcontrol/geometry_model/steps2geometry.py calls generate_mesh(), since it does not specify colors_now.

To Reproduce Steps to reproduce the behavior:

  1. Call the generate_mesh() function with colors_now=None or simply omit the colors_now argument.
  2. Observe the error thrown when generate_mesh() tries to modify colors_now.

Expected behavior The generate_mesh() function should handle the case where the optional argument colors_now takes it default value None gracefully and proceed without modification to colors_now if it is not provided. Adding an if colors_now is not None: check before modifying colors_now resolves this issue.

Screenshots N/A

Desktop (please complete the following information):

Smartphone (please complete the following information): N/A

Additional context Bug occurs in fullcontrol/visualize/plotly.py within generate_mesh()

Suggested solution:

if colors_now is not None:
    colors_now[:] = np.array(colors_now, dtype=object)[good_points]

Or force the user to provide colors_now