New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[manifold] Difference of Cube and Complex SVG Results in Incomplete Render #4679
Comments
It would be awesome to have an "scad-to-manifold" converter which spits out a pure manifold test case, to make it easier to report such issues upstream. |
I am seeing the same behavior when differencing using the same specs/version and manifold. It also occurs with DXFs not just SVGs. Environment and Version info: |
There are several bug fixes for manifold, wondering if this issue will still occur with the latest master (manifold). It is also possible that the issue is caused by the mesh extruded from svg, not sure about that. For submitting an issue to upstream, you can just export the model for the svg extruded part (in gltf for example, as it preserves manifoldness), it should be enough for us to reproduce it. |
Just tried it with OpenSCAD version 2023.07.09 (git 44fdb2c), and am getting similar results. Not sure how to export to gltf, but here's an STL file of the extruded SVG, which gives basically the same results when subtracted from a 145x100x1 cube. |
Reproduced now, thanks! |
I've had the same behaviour since manifold was introduced but note that it has also happened with text, albeit a lot less frequently. It affects complicated svg images the most, i.e. lots of small detail or islands (disconnected regions) and the un-rendered region is typically a large geometrically uniform area. It still rocks though. I can't complain with a render time in milliseconds compared to 20+ minutes, when it works! |
I think we might be able to get around this issue (before upstream has a fix) if we do Delaunay refinement to make the svg extruded mesh better. I think the sliver triangles are making the triangulator mad. Alternatively, you can perform simplify to simplify the 2d polygon. |
I use a small offset() to mitigate the creation of open meshes with small features when using the standard solver already. It has limited effect with Manifold but then the radius (typically 0.1) needs to be quite small to maintain as much definition as possible. I'm dealing with logos and text that need the detail to be preserved. |
There is a
I checked the woodgrain mesh, and indeed there are triangles where the distance between a point and the edge is very small: |
Btw, offset is orthogonal to simplifyPath, I think it should not remove the number of edges in general. |
Ah, ok. I'm not using the woodgrain mesh in any case. My images are far less detailed. OP should have precedence on this but I have attached an stl of one of my example images extruded if it helps. |
I experience the same issue on nightly(build from source commit: 2835e35 latest as of 12.08.2023) Time: ~12 minutes Time: ~5 seconds Script: $fn=350; // ignore this since it is just for testing purposes
module hole_plate(size, hole_dm, hole_margin, hole_count = [ 2, 2 ])
{
difference()
{
cube(size);
abs_margin = hole_margin + hole_dm / 2;
x_hole_dist = (size.x - 2 * abs_margin) / (hole_count.x - 1);
y_hole_dist = (size.y - 2 * abs_margin) / (hole_count.y - 1);
x_values = [abs_margin:x_hole_dist:size.x - abs_margin + 0.1];
y_values = [abs_margin:y_hole_dist:size.y - abs_margin + 0.1];
// holes
for (x = x_values, y = y_values)
translate([ x, y, -1 ]) cylinder(d = hole_dm, h = size.z + 2);
}
}
hole_plate([ 100, 50, 5 ], 6, 4);
translate([ 0, 60, 0 ]) hole_plate(size = [ 50, 50, 5 ], hole_dm = 3, hole_margin = 2);
translate([ 60, 60, 0 ]) hole_plate([ 50, 50, 5 ], hole_dm = 5, hole_margin = 5);
translate([ 110, 0, 0 ]) hole_plate([ 100, 50, 5 ], 6, 4);
translate([ 0, -60, 0 ]) hole_plate(size = [ 50, 50, 5 ], hole_dm = 3, hole_margin = 2, hole_count = [ 10, 10 ]); Files:
Reducing |
@astrolemonade It is a problem with manifold's triangulator, more specifically about how we handle small line segments. We are now tracking this issue in elalish/manifold#502. Btw, thanks for the simple repro! |
should be fixed in the upstream note that we may need to wait a bit to update the submodule, see elalish/manifold#529 |
Updating turns out to be a bit difficult. Looks like none of the build environments have a TBB new enough to compile latest Manifold code. |
What is the compilation error exactly? Is it missing the concurrent containers? |
Link to build logs: https://github.com/openscad/openscad/runs/16230648150 Looks like it's not always the same error as I assumed first. MXE (windows builds on Linux) does have an old TBB version:
I can have a look if the compile from source works here. There's already an issue asking for an upstream TBB update too mxe/mxe#2984. The AppImage build actually fails due to Manifold injecting
|
|
Thanks @pca006132, compilation is now green on all platforms. We still need to solve an issue with a test case generating STL output in a different order. See #4728. |
Should be fixed via #4728. |
Hey, I still experience this after the fix: 5f8f6e4 . Can you have another look, please?
|
Thanks for testing, I'll reopen for investigation... |
@astrolemonade are you sure you updated the submodule after pulling the changes? |
It turns out I did the The viewport became terrible slow. output.mp4 |
Closing as fix is confirmed. The preview is unrelated to ManifoldT here were some changes in that area, please check Preferences -> Features and maybe enable the changed display options there. |
I don't have any display options changed in the Preferences -> Features, I don't even see a display settings there. |
@astrolemonade there were some recent changes in rendering code, maybe you can open another issue for it |
Hmm, looks like the change is not merged yet. So let me rephrase: Please check that all of the vertex-object-* options are enabled. |
@astrolemonade How much time does rendering take now? |
I got 8.5s for this particular example. It is slow because the triangulator is now using ear clipping and is O(n^2), which can get pretty slow when there are 300k vertices. We can potentially use collider to reduce the complexity, do parallelization, or try to optimize the memory access. Btw not sure if the rendering being slow means manifold or OpenGL rendering. |
That said, the updated manifold version should be much faster in general. For example comparing with the older version (in #4533), |
49 seconds compared to the old 6 seconds before the manifold upgrade.
I enabled them and the viewport behaves faster again. I have all the |
49 seconds feels like you're running a debug build. If you build yourself: |
Oh, and you should disable the two |
That was it, it was a debug build and I had those 2 options (fast-csg) enabled. After rebuilding it in release mode and disable those 2 I got 9 seconds which is pretty great. |
The Windows 2023.11.08 nightly build appears to crash or hang with manifold enabled on render/preview (dependent on file). 2023.11.05 build does not — so it appears to be related to this push? The 2023.11.08 Linux AppImage appears to work and fix the original issue. The exception codes I've noted in Event Viewer "Application Error" and ".NET Runtime" entries have been:
I've tried:
You should be able to replicate with even a simple basic model like the included |
@donovansmith This probably deserves a new issue, as the fix in question (#4728) relates to a number of other issues. |
Using Manifold, a difference() between a cube and a linear_extrude()-ed complex SVG results in an incomplete render. Preview is correct but render results in incomplete model.
To Reproduce
Expected behavior
Render should look like preview
Code reproducing the issue
SCAD code and SVG file included
manifold-issue.zip
Screenshots
If applicable, add screenshots to help explain your problem.
Environment and Version info:
Additional context
I realize this is a bit of a torture test for the rendering engine. Submitting this mostly in the event that it reveals an issue with the Manifold library.
The text was updated successfully, but these errors were encountered: