elalish / manifold

Geometry library for topological robustness
Apache License 2.0
881 stars 97 forks source link

Triangulation failure with TBB enabled in SimpleOffset test #1006

Open starseeker opened 2 hours ago

starseeker commented 2 hours ago

When working on #998, a failure (see below) was observed in triangulation when moving the Status() checks of the test up out of the processing loops: https://github.com/elalish/manifold/pull/998/commits/1f47f80305267429e91843d7819c2f65d14a61a1

Subsequent testing indicated that the issue was only observed (at least, on Ubuntu Linux) when tbb was enabled.

Needs additional debugging setup to capture the precise problematic inputs - just setting up this issue here to capture the info buried in the #998 discussion.

-----------------------------------
Triangulation failed! Precision = 2.01703e-08
Error in file: /home/runner/work/manifold/manifold/src/polygon.cpp (118): 'std::all_of(triangles.begin(), triangles.end(), [&vertPos, precision](const ivec3 &tri) { return CCW(vertPos[tri[0]], vertPos[tri[1]], vertPos[tri[2]], precision) >= 0; })' is false: triangulation is not entirely CCW!
Polygon 0 2.01703e-08 1
17
4970.57 -19594.7
5039.82 -19373.5
5039.82 -19373.5
5039.82 -19373.5
5038.85 -19373.3
5038.85 -19373.3
5037.88 -19373.2
5037.88 -19373.2
5037.88 -19373.2
5038.85 -19373.3
5038.85 -19373.3
5039.82 -19373.5
5039.82 -19373.5
5038.85 -19373.3
5037.88 -19373.2
5037.88 -19373.2
5037.88 -19373.2
# ... 
show(array([
  [4970.57, -19594.7],
  [5039.82, -19373.5],
  [5039.82, -19373.5],
  [5039.82, -19373.5],
  [5038.85, -19373.3],
  [5038.85, -19373.3],
  [5037.88, -19373.2],
  [5037.88, -19373.2],
  [5037.88, -19373.2],
  [5038.85, -19373.3],
  [5038.85, -19373.3],
  [5039.82, -19373.5],
  [5039.82, -19373.5],
  [5038.85, -19373.3],
  [5037.88, -19373.2],
  [5037.88, -19373.2],
  [5037.88, -19373.2],
]))
produced this triangulation:
214, 159, 176
176, 174, 224
170, 220, 229
124, 221, 170
168, 218, 121
121, 214, 176
229, 230, 125
180, 168, 121
180, 121, 176
225, 180, 176
224, 124, 170
176, 224, 170
125, 225, 176
125, 176, 170
125, 170, 229
unknown file: Failure
C++ exception with description "Error in file: /home/runner/work/manifold/manifold/src/polygon.cpp (118): 'std::all_of(triangles.begin(), triangles.end(), [&vertPos, precision](const ivec3 &tri) { return CCW(vertPos[tri[0]], vertPos[tri[1]], vertPos[tri[2]], precision) >= 0; })' is false: triangulation is not entirely CCW!" thrown in the test body.

[  FAILED  ] BooleanComplex.SimpleOffset (499 ms)
[----------] 15 tests from BooleanComplex (23044 ms total)
pca006132 commented 2 hours ago

I suspect that this is related to #970, as that is also with offset and has similar behavior as this one.

starseeker commented 1 minute ago

No idea if this info is significant (may just be a quirk of the local machine and/or specifics of the test) but just in case I'll add it here:

When I checked Status() after processing N triangle generated solids in the last loop of the test, at N<15 things passed, N==15 it sometimes passed and sometimes failed, and N>15 seemed to reliably fail.