Skip to content

Lazy union (aka. no implicit union) #350

@kintel

Description

@kintel

Don't perform a union in the following cases:

  • Separate root objects
  • for loops: A for loop will create a list of separate object passed on to the parent node (or the root)
  • children(). A children() statement will pass on the list of children to the parent node

See also https://github.com/openscad/openscad/wiki/OEP2:-Implicit-Unions.

The code lives in https://github.com/openscad/openscad/tree/issue350

This feature is currently experimental. To enabled it, lazy unions must be enabled in Preferences or the cmd-line (--enable=lazy-union).

Exporting top-level object to STL/OFF/AMF/DXF/SVG will attempt to keep the objects separate as far as the used file format supports it.

TODO:

This has been discussed a bit, and is interesting for a number of reasons:

  • Speed: In many cases, most (half?) of the time and memory used for compiling an OpenSCAD design is consumed by the final union of the top-level objects (see e.g. Compile and Render doesn't ever get past 99% #261 and OpenSCAD crashes with high memory usage. #342)
  • Necessity: Slicer software (Slic3r in particular, others unknown) supports slicing overlapping objects as it performs an implicit union of all submeshes.
  • Multi-material 3D printing: We could, at the top-level, specify different colors for different top-level objects. When exporting as separate meshes, these colors could be mapped to materials by the slicer software. Combined with amf or obj export, this could make multi-material prints a lot more convenient.
  • Manifoldness: This will partially let users export more complex models where the final manifold test done today fails (see export directly to stl from nef polyhedron w/o manifold check [$10] #337).

Further work past this issue:

  • Don't need to perform any unions which are not influenced by subsequent operations, independent on top-level or not. This will allow modules to create on non-unioned objects.
  • Do lazy evaluation of CGAL Nef polyhedrons. This will make it possible to defer calculation of transformations until the last minute, which perhaps makes it possible to avoid caching more than one instance of geometries which only differ in transformation.


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions