CurvedShapesWorkbench
CurvedShapesWorkbench copied to clipboard
Tessellation independence
Shape.BoundBox depends on the Shapes tessellation.
The tessellation has 2 properties
- It only exists if the shape has been tessellated in the first place (if not, the valus can be very wrong, for example if the file is being edited in FreeCADCmd without GUI, parts are not tessellated at all and BoundBox can be off by up to 50% in any dimension in case of curved shapes)
- IF the part is tessellated, the exact dimensions depend on the Tessellation accuracy, which in turn depends on
Preferences->Part->Shape_view->Maximum deviation
andPreferences->Part->Shape_view->Maximum angualar deviation
The effect of this is that the users GUI settings for display-accuracy (and freecad rendering speed) affect the exact dimensions of the bounding boxes computed by CurvedShapes - and that in turn can lead to errors in the shape -- > i.e. parts that work fine on one users computer generate Geometry errors and fail in subsequent boolean operations on another users computer because they have the display accuracy set lower for performance reasons.
This is technically a flaw in FreeCAD itself -- Shape.BoundBox is a property that should NOT be calculated based on tessellation. There is an existing bug report for this:
https://github.com/FreeCAD/FreeCAD/issues/17340
however CurvedShapes is affected by this to a much larger dergree, since it uses BoundBox everywhere.
fix #52
Note: this is a draft. Right now the "fix" has too many side effects. Using "optimalBoundingBox()" is more tricky than BoundBox because of several issues:
- the default call to optrimalBoundBox is optimalBoundBox(True,False) - which uses a triangualted approximation - this yields to flat 2d shapes having a bounding box that can be several millimeters thick for some reason
- Even if optimalBoundBox is called explicitly with optimalBoundBox(False,False) I have seen "thickness" of 2d parts of 2 times epsilon (2e-7)
even with "epsion" increased to 1e-6 some curvedarrays end up weird with broken 1.dimensional ribs created at the beginning or the end sometimes. so a lot more "sanitation" needs to be done with optimalBoundingBox than with BoundBox
Also: on 0.21.2 with OCCT 7.3.0 a call to Shape.optimalBoundBox(False,False) on a standard Part Cube caused FreeCAD to segfault. on 1.0RC4 with OCCT with 7.6.3 there is no segfault