Skip to content

About

Manifold (booleans of solids that stay solid) as a C++23 module — mcpplibs.mwrap.manifold

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

manifold

Manifold, the geometry library for solids that stay solid (booleans, hulls, level sets, slices and extrusions), through C++23 modules.

English · 简体中文 · Upstream · Releases · mcpp · Index

C++23 License mcpp-community CI

The upstream C++ API is unchanged: manifold::Manifold, manifold::MeshGL, manifold::vec3 and linalg's vectors, matrices and operators are the upstream entities, in the namespaces upstream declares them in. The library's sources are vendored byte for byte from the 3.5.5 release and built by this package as upstream's default build does (floating-point contraction off), save two choices: one thread (MANIFOLD_PAR=-1, no oneTBB) and no CrossSection (see "What is and is not wrapped"). The same input gives the same triangles, every corner bit for bit, on every platform CI builds (a pinned hash in the tests); the order they come in follows the standard library's sort, and differs between libstdc++ and libc++. Wrapper revision 3.5.5.1 adds -ffp-contract=off, which 3.5.5 lacked.

Modules

  • import mcpplibs.mwrap.manifold;: every public name of <manifold/manifold.h> and <manifold/polygon.h> — 36 types and 10 functions of manifold, 16 functions of manifold::math, 10 types and 116 functions and operators of linalg, and the namespace alias manifold::la

More Modules API -> upstream's README

Getting started

mcpp new part --template mcpplibs.mwrap.manifold@3.5.5.1
cd part
mcpp run

The default template cuts a round hole through a cube, adds a ball, and prints the result's volume, surface, genus, mesh size and the loops of its middle cut.

[dependencies]
mcpplibs.mwrap.manifold = "3.5.5.1"
import std;
import mcpplibs.mwrap.manifold;

int main() {
    using manifold::Manifold;
    const Manifold part = Manifold::Cube(manifold::vec3(2.0), true) - Manifold::Cylinder(4.0, 0.5, 0.5, 48, true);
    const manifold::MeshGL mesh = part.GetMeshGL();
    std::println("volume {:.3f}, genus {}, {} triangles", part.Volume(), part.Genus(), mesh.NumTri());
}

Constants and macros

Seven constexpr objects at namespace scope in the headers are not inline: they have internal linkage (each includer has its own) and a module cannot export them. They are in mcpplibs::mwrap::manifold under their names, with their types and values: kPi, kTwoPi, kHalfPi, DEFAULT_SEGMENTS, DEFAULT_ANGLE, DEFAULT_LENGTH, and identity (linalg::identity). The public headers define no object-like constant macro, so there is no .macros module; DEBUG_ASSERT and ASSERT are upstream's own control-flow macros, empty as this package builds it.

What is and is not wrapped

  • Wrapped: every name of the two headers in manifold, manifold::math and linalg (196 in all, the seven constants above among them).
  • A translation unit that also includes <manifold/manifold.h> (add upstream/manifold/include to its include path, and include <istream> and <ostream> first) sees the same entities (tests/header_mix_test.cpp).
  • Not here: CrossSection (<manifold/cross_section.h>). Upstream's class needs Clipper2, and the backend without it is a stub in 3.5.5 (every operation gives nothing). Outlines are manifold::Polygons; Extrude, Revolve, Slice, Project and Triangulate are all here.
  • Not here: oneTBB parallelism, the debug and timing builds (MANIFOLD_DEBUG, MANIFOLD_TIMING), the C, Python and WebAssembly bindings, extras and samples.
  • linalg::detail is not exported; the specialisations the header adds to std come with their types.

Verification

  • mcpp test: a cube's corners, faces, volume and box; the volumes of union, difference and intersection and the genus of a drilled solid; the same input twice gives the same mesh byte for byte, and the same triangles on every platform (pinned); a MeshGL in and out, and why what is not manifold is refused; hull, decomposition, a split by a plane; linalg's vectors, matrices and operators; an outline extruded, revolved, sliced and projected; header mixing.
  • python3 tools/check_exports.py: the module is exactly tools/surface.json; given a clang++ (required on CI's LLVM row) the record is derived again from the headers as the compiler reads them, and compared.
  • python3 tools/test_template.py: mcpp new from an installed copy, a strict build, and a run of the generated project.
  • CI: Linux (GCC 16, LLVM 23), macOS and Windows (LLVM 23).

License

The wrapper is Apache-2.0 (mcpp-community). Manifold is Apache-2.0, © The Manifold Authors; its linalg.h derives from Sterling Orsten's public-domain library of that name. Upstream's README, LICENSE and AUTHORS are kept in upstream/manifold/ and deployed with a program's licenses. Provenance: upstream/documents.json.

About

Manifold (booleans of solids that stay solid) as a C++23 module — mcpplibs.mwrap.manifold

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages