tomate44 / CurvesWB

Experiments for a FreeCAD Surface workbench
GNU Lesser General Public License v2.1
112 stars 24 forks source link

Trying to create a gordon surface from 2 or more gordon surfaces gives error #102

Closed Anthony-Gaudino closed 10 months ago

Anthony-Gaudino commented 10 months ago

If a user selects two gordon surfaces and click on the create gordon surface tool an error will occur and it will appear as FreeCAD is running an infinite computation.

Screenshot 2023-12-11 at 09 58 48

An error also appears if the user only selects a single gordon surface and tries to create a gordon surface. An invalid gordon surface will appear on tree view.

09:57:23  Not enough guides or profiles
09:57:23  Traceback (most recent call last):
  File "/Users/anthonygaudino/Library/Application Support/FreeCAD/Mod/Curves/./freecad/Curves/gordonFP.py", line 144, in execute
    s = gordon_surf.surface()
  File "/Users/anthonygaudino/Library/Application Support/FreeCAD/Mod/Curves/./freecad/Curves/gordon.py", line 358, in surface
    self.perform()
  File "/Users/anthonygaudino/Library/Application Support/FreeCAD/Mod/Curves/./freecad/Curves/gordon.py", line 319, in perform
    self.make_curves_compatible()
  File "/Users/anthonygaudino/Library/Application Support/FreeCAD/Mod/Curves/./freecad/Curves/gordon.py", line 456, in make_curves_compatible
    intersection_params_u, intersection_params_v = self.sort_curves(intersection_params_u, intersection_params_v)
  File "/Users/anthonygaudino/Library/Application Support/FreeCAD/Mod/Curves/./freecad/Curves/gordon.py", line 416, in sort_curves
    sorterObj = curve_network_sorter.CurveNetworkSorter(self.profiles, self.guides, intersection_params_u, intersection_params_v)
  File "/Users/anthonygaudino/Library/Application Support/FreeCAD/Mod/Curves/./freecad/Curves/curve_network_sorter.py", line 79, in __init__
    raise ValueError("Not enough guides or profiles")
<class 'ValueError'>: Not enough guides or profiles
09:57:23  Recompute failed!

Example file: gordon_squares_2.FCStd.zip


I think Curves WB should disable the tool buttons if the selected geometry is incorrect or the number of items is not correct. For example, right now to create a gordon surface the user needs 4 edges / curves so the button should only be enabled if the user selects 4 edges / curves.

Also, since users can call the tool by Python script, it should handle the case the user tries to use it with incorrect inputs in code too.

Another option is to allow using gordon surfaces for creation of other gordon surfaces valid by implementing, for example, that if the user tries to create a gordon surface using other gordon surfaces a new valid surface is created using the other surfaces edges.

tomate44 commented 10 months ago

Handling all possible selection schemes would be a pain. It's up to the user to make the right selection. I emphasize that Curves WB is experimental. It is mainly my personal sandbox workbench, and should only be used at your own risks.