Comments (18)
I wonder if we should, generally, write some output sanity checkers for output file formats, and run such checks as part of tests. e.g. like stlsanitytest
(https://github.com/openscad/openscad/blob/dc2a0d1c28e41016abf4f91ffbc4c6c707c4f64a/tests/CMakeLists.txt#L991C18-L991C35) but better.
from openscad.
Did the crash closes scad without warning/error? And what happens with 3mf export?
I have seen some crashes on 2024.02.04 win when rendering or saving but couldn't reproduce.
from openscad.
Did you try the latest version? We fixed some cache related bugs recently.
I tested with the latest master on Linux and cannot reproduce your issue.
from openscad.
Try something after Feb 15 where this is fixed: #4990
from openscad.
Just now I checked it out from scratch (Feb 20 dc2a0d1), re-built, and the bug is still there.
OpenSCAD prints the assertion failure to stderr then quits.
Export to 3mf does not crash, but reports an error in the console:
Rendering finished.
EXPORT-ERROR: Can't add triangle to 3MF model.
3MF export finished: /home/csm/3D_Printing.git/Math_Objects/Reuleaux/bug.3mf
It could be something in my build environment. However, a checkout from 2023 Dec 30 had the problem, while a checkout from 2022 Apr 27 does not. I may try to do a bisect, although it would be painful and manual because of git submodule hell.
from openscad.
- Are your submodules up to date? Try
git submodule update --init --recursive
. - What is your OS version?
I think if you do a bisect, you probably don't have to update the submodules along with the bisect. The API of manifold has been pretty stable.
from openscad.
Also, to eliminate a local issue, you could always try one of the recent dev binaries from https://openscad.org/downloads.html#snapshots
from openscad.
The latest AppImage ran fine on Ubuntu 22.04/Jammy. As yet I have no idea why my build might be different, although I do build with EXPERIMENTAL=1.
@pca006132 Perhaps overkill, but to avoid confounding anything, for every test I started from scratch. Removed everything, cloned from github, checked out specific version, inited submodules, and built.
I ended up doing a full 9-stage manual bisect and found the exact commit where it stops working:
2023-12-03 16:41:36 fe2b635 = ok
2023-12-03 17:29:27 de1e7d8 = crash
My tree is sitting there at de1e7d8 so I can run experiments if needed.
Dependency check
$ ./scripts/check-dependencies.sh
depname minimum found OKness
qt 5.4 5.15.3 OK
qscintilla2 2.9 2.11.6 OK
cgal 5.4 5.4 OK
gmp 5.0 6.2.1 OK
mpfr 3.0 4.1.0 OK
boost 1.56 1.74 OK
opencsg 1.4.2 1.4.2 OK
glew 1.5.4 1.7.0 OK
eigen 3.0 3.4.0 OK
glib2 2.0 2.72.4 OK
fontconfig 2.10 2.13. OK
freetype2 2.4 2.11.1 OK
harfbuzz 0.9.19 2.7.4 OK
libzip 0.10.1 1.7.3 OK
bison 2.4 3.8.2 OK
flex 2.5.35 2.6.4 OK
make 3 4.3 OK
double-conversion 2.0.1 2.0.1 OK
from openscad.
If we have an extremely sliver/small triangle that differs by less than the resolution of float (23 bits) but different when represented as doubles (52 bits), it will become the same when we export to STL (the assertion is checking double, but we eventually outputs float). I think we removed quantization when exporting STL (at least it is not obvious to me where we do it), not sure if we want to add it back.
Also, @curtmcd maybe you can try this:
--- a/src/geometry/PolySetBuilder.cc
+++ b/src/geometry/PolySetBuilder.cc
@@ -148,7 +148,7 @@ std::unique_ptr<PolySet> PolySetBuilder::build()
polyset->setConvexity(convexity_);
polyset->isTriangular = true;
for (const auto& face : polyset->indices) {
- if (face.size() > 3) {
+ if (face.size() != 3) {
polyset->isTriangular = false;
break;
}
I think we forgot the case where there the face can be degenerate...
from openscad.
What about faces with >=3 vertices, but some indices are duplicated, causing degenerate triangles or self-intersections? Perhaps the builder should remove those (at least the degenerate ones) while building?
from openscad.
Perhaps we need to start unit-testing some of the core classes, to establish a more formal contract, as it's easy to introduce bugs which gets magically fixed by some downstream feature, perhaps only in some cases.
from openscad.
True, the builder may get a degenerate triangle, merge vertices together and end up with a triangle with duplicated indices. Manifold can output degenerate triangles, i.e. vertices can have different indices but refers to the same position.
Yeah I think we should write out the assumption of those core classes. Their invariants are pretty unclear now.
from openscad.
I tried the (face.size() != 3)
, but the behavior didn't change.
I tried changing the assert() into a LOG() as follows:
// Tessellation already eliminated these cases.
// assert(p0 != p1 && p0 != p2 && p1 != p2);
if (p0 == p1 || p0 == p2 || p1 == p2)
LOG(message_group::Export_Warning, "Degenerate triangle [%1$.14lg, %2$.14lg, %3$.14lg] [%4\
$.14lg, %5$.14lg, %6$.14lg] [%7$.14lg, %8$.14lg, %9$.14lg]",
p0.x(), p0.y(), p0.z(), p1.x(), p1.y(), p1.z(), p2.x(), p2.y(), p2.z());
It prevented the crash and here's the output of that. This is for rotate_extrude(angle = 90) square([10, 10]);
with Manifold and 32 of 68 triangles are coming out bad. The same set of triangles results with CGAL.
Rendering finished.
EXPORT-WARNING: Degenerate triangle [9.8078528040323, 1.9509032201613, 10] [0, 0, 10] [0, 0, 10]
EXPORT-WARNING: Degenerate triangle [0, 0, 0] [0, 0, 0] [10, 0, 0]
EXPORT-WARNING: Degenerate triangle [0, 0, 10] [0, 0, 10] [0, 0, 0]
EXPORT-WARNING: Degenerate triangle [0, 0, 10] [0, 0, 0] [0, 0, 0]
EXPORT-WARNING: Degenerate triangle [9.2387953251129, 3.8268343236509, 10] [0, 0, 10] [0, 0, 10]
EXPORT-WARNING: Degenerate triangle [0, 0, 0] [0, 0, 0] [9.8078528040323, 1.9509032201613, 0]
EXPORT-WARNING: Degenerate triangle [0, 0, 10] [0, 0, 10] [0, 0, 0]
EXPORT-WARNING: Degenerate triangle [0, 0, 10] [0, 0, 0] [0, 0, 0]
EXPORT-WARNING: Degenerate triangle [8.3146961230255, 5.555702330196, 10] [0, 0, 10] [0, 0, 10]
EXPORT-WARNING: Degenerate triangle [0, 0, 0] [0, 0, 0] [9.2387953251129, 3.8268343236509, 0]
EXPORT-WARNING: Degenerate triangle [0, 0, 10] [0, 0, 10] [0, 0, 0]
EXPORT-WARNING: Degenerate triangle [0, 0, 10] [0, 0, 0] [0, 0, 0]
EXPORT-WARNING: Degenerate triangle [7.0710678118655, 7.0710678118655, 10] [0, 0, 10] [0, 0, 10]
EXPORT-WARNING: Degenerate triangle [0, 0, 0] [0, 0, 0] [8.3146961230255, 5.555702330196, 0]
EXPORT-WARNING: Degenerate triangle [0, 0, 10] [0, 0, 10] [0, 0, 0]
EXPORT-WARNING: Degenerate triangle [0, 0, 10] [0, 0, 0] [0, 0, 0]
EXPORT-WARNING: Degenerate triangle [5.555702330196, 8.3146961230255, 10] [0, 0, 10] [0, 0, 10]
EXPORT-WARNING: Degenerate triangle [0, 0, 0] [0, 0, 0] [7.0710678118655, 7.0710678118655, 0]
EXPORT-WARNING: Degenerate triangle [0, 0, 10] [0, 0, 10] [0, 0, 0]
EXPORT-WARNING: Degenerate triangle [0, 0, 10] [0, 0, 0] [0, 0, 0]
EXPORT-WARNING: Degenerate triangle [3.8268343236509, 9.2387953251129, 10] [0, 0, 10] [0, 0, 10]
EXPORT-WARNING: Degenerate triangle [0, 0, 0] [0, 0, 0] [5.555702330196, 8.3146961230255, 0]
EXPORT-WARNING: Degenerate triangle [0, 0, 10] [0, 0, 10] [0, 0, 0]
EXPORT-WARNING: Degenerate triangle [0, 0, 10] [0, 0, 0] [0, 0, 0]
EXPORT-WARNING: Degenerate triangle [1.9509032201613, 9.8078528040323, 10] [0, 0, 10] [0, 0, 10]
EXPORT-WARNING: Degenerate triangle [0, 0, 0] [0, 0, 0] [3.8268343236509, 9.2387953251129, 0]
EXPORT-WARNING: Degenerate triangle [0, 0, 10] [0, 0, 10] [0, 0, 0]
EXPORT-WARNING: Degenerate triangle [0, 0, 10] [0, 0, 0] [0, 0, 0]
EXPORT-WARNING: Degenerate triangle [0, 10, 10] [0, 0, 10] [0, 0, 10]
EXPORT-WARNING: Degenerate triangle [0, 0, 0] [0, 0, 0] [1.9509032201613, 9.8078528040323, 0]
EXPORT-WARNING: Degenerate triangle [0, 0, 10] [0, 0, 10] [0, 0, 0]
EXPORT-WARNING: Degenerate triangle [0, 0, 10] [0, 0, 0] [0, 0, 0]
STL export finished: /home/csm/3D_Printing.git/Math_Objects/Reuleaux/bug.stl
from openscad.
Ah! Did you build with -DCMAKE_BUILD_TYPE=Release
or RelWithDebInfo
? I think for non-debug builds assertions are disabled. Yeah this is indeed a bug. I see degenerate triangles in my stl output as well (although it seems that other programs handle them just fine). Btw it doesn't matter which backend you are using: rotate_extrude
directly gives you a polyset :).
from openscad.
I only built like this: mkdir build && cd build && cmake .. -DEXPERIMENTAL=1 && make
Let me know if I can help further!
from openscad.
I opted for adding a run-time sanity-check assert of PolySet when in debug mode instead. This is pretty aggressive, but will only crash in debug mode, but will catch such issues much earlier in the pipeline.
from openscad.
@curtmcd It took some time to finalize this, but try with latest master.
from openscad.
@curtmcd It took some time to finalize this, but try with latest master.
I find that the issue is gone in latest master 23d5bb9. Thank you!
from openscad.
Related Issues (20)
- Union of closed shapes fails HOT 13
- Building on Mac OS X Using Homebrew Fails due to Qscintilla2 Versioning HOT 9
- Poor transparency calculation for previewing extruded hollow shapes with holes cut into them HOT 2
- Is this the right place to ask question about OpenSCAD HOT 4
- Chore: renovate python scripts to py>=3.8
- Display colors when rendering using F6 HOT 3
- Customizer: Support vectors with more than 4 elements HOT 1
- Nightly Build Crashes During Render of Complicated Object HOT 15
- Does not see user color schemes (Mac OS 13.6.4) HOT 2
- Intersection not working, creating union instead HOT 5
- preview does not show diffrence() correctly HOT 1
- roof_ss.cc sans me HOT 1
- `$variable` assignment no longer seems to work. HOT 13
- really weird issue that might involve floats HOT 1
- Linear_extrude with 3d vector as height yields inapropriate result HOT 3
- let color() work in rendering mode too and allow to export colored STL files. HOT 1
- Save and restore GUI window state more reliably
- Splat 2D/3D functions HOT 7
- Document vector swizzling HOT 1
- Setting to do full Renders in place of Preview on AutoReload HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from openscad.