Skip to content

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

@wjvandersluis

Description

@wjvandersluis

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):

  • OS: Windows 11 Home
  • Python Version: 3.12
  • Fullcontrol Version: 0.1.1
  • Lab Version: 8.3

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingready to closeIssue will be closed imminently

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions