Skip to content

Commit 24140de

Browse files
authored
mcpplibs.mwrap.manifold 3.5.5.1: manifold-m (Manifold, booleans of solids that stay solid, as a C++23 module) (#779)
* mcpplibs.mwrap.manifold 3.5.5: manifold-m (Manifold, booleans of solids that stay solid, as a C++23 module) * mcpplibs.mwrap.manifold: index wrapper revision 3.5.5.1 (floating-point contraction off, as upstream builds it) instead of 3.5.5
1 parent c8e06cc commit 24140de

8 files changed

Lines changed: 177 additions & 0 deletions

File tree

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Add mcpplibs.mwrap.manifold (manifold-m 3.5.5.1)
2+
3+
## Form
4+
5+
- Third-party upstream [elalish/manifold](https://github.com/elalish/manifold), release v3.5.5, Apache-2.0 (its
6+
`linalg.h` derives from Sterling Orsten's public-domain library).
7+
- Form A external mwrap module repository [mcpplibs/manifold-m](https://github.com/mcpplibs/manifold-m), package
8+
`mcpplibs.mwrap.manifold`, version 3.5.5.1 (wrapper revision 1 of upstream 3.5.5; the first indexed release of the
9+
identity), tag `mwrap-3.5.5.1`; release asset `manifold-m-3.5.5.1.tar.gz` (`d80aa82f…7d3a`), CN mirror
10+
`gitcode.com/mcpp-res/mwrap-manifold` with identical bytes. The repository's `mwrap-3.5.5` release is not indexed:
11+
it was built without `-ffp-contract=off`, which upstream's own build sets (a fused multiply-add changes results).
12+
- Implementation ownership: the library has no compat package in this index, so the wrapper vendors `src/*.cpp`,
13+
`src/*.h` and `include/manifold/` from the release archive (checksums in `upstream/documents.json`) and builds them
14+
as upstream's default build does (floating-point contraction off), save two choices: one thread (`MANIFOLD_PAR=-1`, no oneTBB) and no `CrossSection`
15+
(`MANIFOLD_CROSS_SECTION` off: upstream's class needs Clipper2, and the backend without it,
16+
`cross_section_boolean2.cpp`, is a stub in 3.5.5 — every operation gives nothing — so it is not vendored and
17+
`<manifold/cross_section.h>` is not exported). It deploys upstream's README, LICENSE and AUTHORS with its own
18+
LICENSE/NOTICE (`runtime.deploy`).
19+
20+
## Module
21+
22+
- `mcpplibs.mwrap.manifold`: every public name of `<manifold/manifold.h>` and `<manifold/polygon.h>` by `using` in the
23+
namespace upstream declares it in — `manifold` (36 types, 10 functions, the alias `la`), `manifold::math` (16
24+
functions), `linalg` (10 types, 116 functions and operators).
25+
- Internal-linkage adaptation: seven `constexpr` objects at namespace scope are not `inline` (`kPi`, `kTwoPi`,
26+
`kHalfPi`, `DEFAULT_SEGMENTS`, `DEFAULT_ANGLE`, `DEFAULT_LENGTH`, `linalg::identity`); a module cannot export
27+
them, so they are declared again under their names, with their types and values, in `mcpplibs::mwrap::manifold`.
28+
- No `.macros` module: the public headers define no object-like constant; `DEBUG_ASSERT` and `ASSERT` are upstream's
29+
own control-flow macros, empty in this configuration. `<manifold/mesh.h>` names `std::istream` and `std::ostream`
30+
without their header; the module's global fragment includes `<istream>` and `<ostream>` first.
31+
- The export list is derived by `tools/surface.py` from the headers as clang reads them (its JSON AST), recorded in
32+
`tools/surface.json`, and audited in CI: the module is the record on every row, and on the Linux LLVM row the
33+
record is derived again and compared.
34+
35+
## Verification
36+
37+
- Wrapper CI (Linux x86_64 GCC 16.1 and LLVM 23.1.3, macOS LLVM, Windows LLVM): the module tests (solids, booleans
38+
and their volumes, the same input giving the same mesh, the same triangles on every row — every corner bit for bit,
39+
by a pinned hash; the order they come in follows the standard library's sort and differs between libstdc++ and
40+
libc++ — meshes in and out, hull, decomposition and splitting,
41+
linalg, outlines extruded, revolved, sliced and projected, header mixing), the export audit, and the default
42+
template from an installed copy with a strict build.
43+
- This index: consumer `tests/mwrap/manifold-boolean`; the installed-template check with `--deploy`
44+
(`STATIC_NOTICES`).

‎.github/workflows/validate.yml‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1728,6 +1728,11 @@ jobs:
17281728
shell: bash
17291729
run: python3 tests/mwrap/check_installed_template.py --mcpp "$MCPP" --package mcpplibs.mwrap.cgltf@1.15 --deploy
17301730

1731+
- name: Installed manifold wrapper archive, actual default boolean template and its relocated notices
1732+
if: contains(format(' {0} ', env.MEMBERS), ' manifold-boolean ') && matrix.toolchain == 'default'
1733+
shell: bash
1734+
run: python3 tests/mwrap/check_installed_template.py --mcpp "$MCPP" --package mcpplibs.mwrap.manifold@3.5.5.1 --deploy
1735+
17311736
- name: Installed libarchive wrapper archive, actual default archive template and its relocated notices
17321737
if: contains(format(' {0} ', env.MEMBERS), ' libarchive-bundle ') && matrix.toolchain == 'default'
17331738
shell: bash

‎CHANGELOG.md‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,14 @@
3838

3939
### Added
4040

41+
- **mcpplibs.mwrap.manifold 3.5.5.1(新包)。** manifold-m:Manifold(始终保持流形的实体几何库)的 C++23 模块,以 `export using`
42+
在上游的命名空间里导出 `<manifold/manifold.h>` 与 `<manifold/polygon.h>` 的全部公开名字(`manifold` 36 个类型、10 个函数,
43+
`manifold::math` 16 个函数,`linalg` 10 个类型、116 个函数与运算符);7 个内部链接的 `constexpr` 常量(`kPi`、
44+
`DEFAULT_SEGMENTS`、`linalg::identity` 等)以原名位于 `mcpplibs::mwrap::manifold`。导出清单由 clang 读头文件推出并在 CI 中审计。
45+
封装仓库从上游 3.5.5 发布包取源码并自行构建:与上游一样关闭浮点收缩(封装修订 3.5.5.1 补上,3.5.5 未入索引),
46+
单线程(`MANIFOLD_PAR=-1`,不依赖 oneTBB),同样的输入在各平台给出逐位相同的三角形(次序随标准库的排序而不同),不含 `CrossSection`(上游实现依赖
47+
Clipper2,3.5.5 中不依赖它的后端只是占位)。消费者测试 `tests/mwrap/manifold-boolean`,安装后模板检查带 `--deploy`。
48+
GLOBAL 为 GitHub 发布资产,CN 为 GitCode `mcpp-res/mwrap-manifold` 镜像,sha256 相同。
4149
- **mcpplibs.mwrap.meshoptimizer 1.3、mcpplibs.mwrap.cgltf 1.15(新包)。** 两个 mwrap 包:meshoptimizer-m 以 `export using`
4250
导出 `<meshoptimizer.h>` 的全部公开名字(9 个类型、20 个枚举值、89 个函数),`MESHOPTIMIZER_VERSION` 在 `.macros` 中为同名常量;
4351
cgltf-m 导出 `<cgltf.h>` 的全部公开名字(72 个类型、102 个枚举值、37 个函数),并再导出 `.write`(`<cgltf_write.h>`)。

‎mcpp.toml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ members = [
3737
"tests/mwrap/xxhash-digest",
3838
"tests/mwrap/meshoptimizer-simplify",
3939
"tests/mwrap/cgltf-inspect",
40+
"tests/mwrap/manifold-boolean",
4041
"tests/mwrap/libarchive-bundle",
4142
"tests/mwrap/libc-stdio",
4243
"tests/mwrap/miniaudio-engine",

‎pkgs/mwrap/manifold.lua‎

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
-- Immutable upstream-aligned mwrap source release (manifold-m mwrap-3.5.5.1, wrapper revision 1 of upstream 3.5.5);
2+
-- GLOBAL and CN bytes are identical.
3+
--
4+
-- The wrapper is Apache-2.0; the library it vendors and links statically,
5+
-- Manifold 3.5.5, is Apache-2.0: the package deploys its README, LICENSE and
6+
-- AUTHORS beside programs (runtime.deploy).
7+
package = {
8+
spec = "1",
9+
namespace = "mcpplibs.mwrap",
10+
name = "manifold",
11+
description = "manifold-m: Manifold 3.5.5 (booleans, hulls, level sets, slices and extrusions of solids that stay solid) as a C++23 module",
12+
licenses = { "Apache-2.0" },
13+
repo = "https://github.com/mcpplibs/manifold-m",
14+
type = "package",
15+
extensions = {
16+
autoupdate = {
17+
tag = "mwrap-${version}",
18+
url = "https://github.com/mcpplibs/manifold-m/releases/download/${tag}/manifold-m-${version}.tar.gz",
19+
},
20+
},
21+
xpm = {
22+
linux = {
23+
["3.5.5.1"] = {
24+
url = {
25+
GLOBAL = "https://github.com/mcpplibs/manifold-m/releases/download/mwrap-3.5.5.1/manifold-m-3.5.5.1.tar.gz",
26+
CN = "https://gitcode.com/mcpp-res/mwrap-manifold/releases/download/3.5.5.1/manifold-m-3.5.5.1.tar.gz",
27+
},
28+
sha256 = "d80aa82f45a6aa10cf4d8611ad5c2140fb837015630f7710ee6ee4e078fd7d3a",
29+
},
30+
},
31+
macosx = {
32+
["3.5.5.1"] = {
33+
url = {
34+
GLOBAL = "https://github.com/mcpplibs/manifold-m/releases/download/mwrap-3.5.5.1/manifold-m-3.5.5.1.tar.gz",
35+
CN = "https://gitcode.com/mcpp-res/mwrap-manifold/releases/download/3.5.5.1/manifold-m-3.5.5.1.tar.gz",
36+
},
37+
sha256 = "d80aa82f45a6aa10cf4d8611ad5c2140fb837015630f7710ee6ee4e078fd7d3a",
38+
},
39+
},
40+
windows = {
41+
["3.5.5.1"] = {
42+
url = {
43+
GLOBAL = "https://github.com/mcpplibs/manifold-m/releases/download/mwrap-3.5.5.1/manifold-m-3.5.5.1.tar.gz",
44+
CN = "https://gitcode.com/mcpp-res/mwrap-manifold/releases/download/3.5.5.1/manifold-m-3.5.5.1.tar.gz",
45+
},
46+
sha256 = "d80aa82f45a6aa10cf4d8611ad5c2140fb837015630f7710ee6ee4e078fd7d3a",
47+
},
48+
},
49+
},
50+
}

‎tests/mwrap/check_installed_template.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"mcpplibs.mwrap.libarchive": ("libarchive.cppm", "upstream/libarchive/COPYING", b"Tim Kientzle", b"Tim Kientzle"),
2323
"mcpplibs.mwrap.meshoptimizer": ("meshoptimizer.cppm", "upstream/meshoptimizer/LICENSE.md", b"MIT License", b"Arseny Kapoulkine"),
2424
"mcpplibs.mwrap.cgltf": ("cgltf.cppm", "upstream/cgltf/LICENSE", b"Permission is hereby granted", b"Kuhlmann"),
25+
"mcpplibs.mwrap.manifold": ("manifold.cppm", "upstream/manifold/LICENSE", b"Apache License", b"The Manifold Authors"),
2526
"mcpplibs.mwrap.libc": ("libc.cppm", None, b"", b"ISO/IEC 9899:2018"),
2627
}
2728

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[package]
2+
name = "manifold-boolean"
3+
version = "3.5.5.1"
4+
description = "Consume the immutable Manifold wrapper: booleans of solids and their volumes, a mesh in and out, the same mesh twice, an outline extruded and sliced"
5+
6+
[indices]
7+
# Use the complete candidate built-in index prepared by tests/run_members.sh.
8+
# An explicit empty table overrides the legacy workspace redirect.
9+
10+
[dependencies]
11+
mcpplibs.mwrap.manifold = "3.5.5.1"
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
// The installed Manifold wrapper: booleans of solids and their volumes, a
2+
// mesh in and out, the same input giving the same mesh, an outline extruded
3+
// and sliced, linalg's operators, the adapted constants.
4+
import std;
5+
import mcpplibs.mwrap.manifold;
6+
7+
using manifold::Manifold;
8+
using manifold::vec3;
9+
10+
namespace {
11+
12+
bool near(double one, double other, double within = 1e-9) { return std::abs(one - other) <= within; }
13+
14+
} // namespace
15+
16+
int main() {
17+
const Manifold one = Manifold::Cube(vec3(2.0));
18+
const Manifold other = one.Translate(vec3(1.0, 0.0, 0.0));
19+
if (one.NumVert() != 8 || one.NumTri() != 12 || !near(one.Volume(), 8.0)) return 1;
20+
if (!near((one + other).Volume(), 12.0) || !near((one - other).Volume(), 4.0) || !near((one ^ other).Volume(), 4.0)) return 2;
21+
if (!near(one.Boolean(other, manifold::OpType::Intersect).Volume(), 4.0)) return 3;
22+
23+
// A cube with a round hole through it has a handle.
24+
const Manifold drilled = Manifold::Cube(vec3(2.0), true) - Manifold::Cylinder(4.0, 0.5, 0.5, 32, true);
25+
if (drilled.Status() != Manifold::Error::NoError || drilled.Genus() != 1 || !(drilled.Volume() < 8.0)) return 4;
26+
27+
// The same input, the same mesh.
28+
const auto made = [] { return (Manifold::Sphere(1.0, 24) - Manifold::Cube(vec3(1.0))).GetMeshGL(); };
29+
const manifold::MeshGL first = made(), second = made();
30+
if (first.vertProperties.empty() || first.vertProperties != second.vertProperties || first.triVerts != second.triVerts) return 5;
31+
32+
// A tetrahedron in, a solid out; one triangle short is refused with its reason.
33+
manifold::MeshGL mesh;
34+
mesh.numProp = 3;
35+
mesh.vertProperties = {0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1};
36+
mesh.triVerts = {0, 2, 1, 0, 1, 3, 1, 2, 3, 0, 3, 2};
37+
if (!near(Manifold(mesh).Volume(), 1.0 / 6.0, 1e-12)) return 6;
38+
mesh.triVerts.resize(9);
39+
if (Manifold(mesh).Status() != Manifold::Error::NotManifold) return 7;
40+
41+
// An outline raised and cut again.
42+
const manifold::Polygons square{{{-1, -1}, {1, -1}, {1, 1}, {-1, 1}}};
43+
const Manifold raised = Manifold::Extrude(square, 3.0);
44+
double area = 0;
45+
for (const manifold::SimplePolygon& loop : raised.Slice(1.5))
46+
for (std::size_t at = 0; at < loop.size(); ++at) area += linalg::cross(loop[at], loop[(at + 1) % loop.size()]) / 2;
47+
if (!near(raised.Volume(), 12.0) || !near(area, 4.0)) return 8;
48+
49+
// linalg's operators and the constants of internal linkage, adapted.
50+
const vec3 along(1.0, 2.0, 2.0);
51+
if (linalg::length(along) != 3.0 || along * 2.0 - along != along) return 9;
52+
if (manifold::degrees(mcpplibs::mwrap::manifold::kPi) != 180.0 || mcpplibs::mwrap::manifold::DEFAULT_SEGMENTS != 0) return 10;
53+
54+
std::println("Manifold 3.5.5 through import mcpplibs.mwrap.manifold: a drilled cube of volume {:.4f} and genus {}, {} triangles the same twice", drilled.Volume(), drilled.Genus(),
55+
first.NumTri());
56+
return 0;
57+
}

0 commit comments

Comments
 (0)