Compare commits

...
4 Commits
Author SHA1 Message Date
Chun Kit LAM bb6acf1f6e V2.2.1 (#589)
* added notes about twistDegree and nDivisions

* update version

* removed perf comparison figure

it is pretty outdated considering we don't have the GPU backend anymore
and performance is different now.
2023-11-02 22:00:27 -07:00
Emmett Lalish 5930b5c09d Fix NaN halfedgeTangents (#588)
fixed CreateTangents
2023-11-02 12:35:44 -07:00
Emmett Lalish a842de97c6 Fix properties (#587)
* fix testing

* added test

* add comments

* tests pass

* cleanup
2023-11-02 12:07:58 -07:00
Chun Kit LAM 2942229b49 push to pypi (#583)
* push to pypi

* update action name
2023-10-31 11:13:02 +08:00
14 changed files with 540 additions and 50 deletions
+32
View File
@@ -22,3 +22,35 @@ jobs:
with:
path: ./wheelhouse/*.whl
make_sdist:
name: Make SDist
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Optional, use if you use setuptools_scm
submodules: true # Optional, use if you have submodules
- name: Build SDist
run: pipx run build --sdist
- uses: actions/upload-artifact@v3
with:
path: dist/*.tar.gz
pypi-publish:
name: Upload release to PyPI
needs: [build_wheels, make_sdist]
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/manifold3d
permissions:
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
steps:
- uses: actions/download-artifact@v3
with:
name: artifact
path: dist
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
+3 -5
View File
@@ -1,14 +1,12 @@
[![codecov](https://codecov.io/github/elalish/manifold/branch/master/graph/badge.svg?token=IIA8G5HVS7)](https://codecov.io/github/elalish/manifold)
[![PyPI version](https://badge.fury.io/py/manifold3d.svg)](https://badge.fury.io/py/manifold3d)
[![npm version](https://badge.fury.io/js/manifold-3d.svg)](https://badge.fury.io/js/manifold-3d)
[![twitter](https://img.shields.io/twitter/follow/manifoldcad?style=social&logo=twitter)](https://twitter.com/intent/follow?screen_name=manifoldcad)
## Users
[OpenSCAD](https://openscad.org/), [IFCjs](https://ifcjs.github.io/info/), [Grid.Space](https://grid.space/), and [OCADml](https://github.com/OCADml/OManifold) have all integrated our Manifold geometry kernel! Why? Because its reliability is guaranteed and it's 1,000 times faster than other libraries. See our [usage](https://github.com/elalish/manifold/discussions/340) and [performance](https://github.com/elalish/manifold/discussions/383) discussions for all the latest and to add your own projects & analyses.
For example, here is a log-log plot of Manifold's performance vs. earlier OpenSCAD geometry backends:
<img src="https://elalish.github.io/manifold/samples/models/perfSpheres.png" width="350px"/>
## [ManifoldCAD.org](https://manifoldcad.org)
If you like OpenSCAD / JSCAD, you might also like ManifoldCAD - our own solid modelling web app. Our WASM is not multithreaded yet, but it's still quite fast and a good way to test out our Manifold library.
@@ -29,7 +27,7 @@ of this repository may solve the problem.
[Manifold](https://github.com/elalish/manifold) is a geometry library dedicated to creating and operating on manifold triangle meshes. A [manifold mesh](https://github.com/elalish/manifold/wiki/Manifold-Library#manifoldness) is a mesh that represents a solid object, and so is very important in manufacturing, CAD, structural analysis, etc. Further information can be found on the [wiki](https://github.com/elalish/manifold/wiki/Manifold-Library).
This is a modern C++ library that Github's CI verifies builds and runs on a variety of platforms. Additionally, we build bindings for JavaScript ([manifold-3d](https://www.npmjs.com/package/manifold-3d) on npm), Python, and C to make this library more portable and easy to use.
This is a modern C++ library that Github's CI verifies builds and runs on a variety of platforms. Additionally, we build bindings for JavaScript ([manifold-3d](https://www.npmjs.com/package/manifold-3d) on npm), Python ([manifold3d](https://pypi.org/project/manifold3d/)), and C to make this library more portable and easy to use.
System Dependencies (note that we will automatically download the dependency if there is no such package on the system):
- [`GLM`](https://github.com/g-truc/glm/): A compact header-only vector library.
+2 -2
View File
@@ -1,6 +1,6 @@
{
"name": "manifold-3d",
"version": "2.1.0",
"version": "2.2.1",
"description": "Geometry library for topological robustness",
"main": "manifold.js",
"files": [
@@ -36,4 +36,4 @@
"url": "https://github.com/elalish/manifold/issues"
},
"homepage": "https://github.com/elalish/manifold#readme"
}
}
+3 -3
View File
@@ -52,7 +52,7 @@
}: pkgs.stdenv.mkDerivation {
inherit doCheck;
pname = "manifold-${parallel-backend}";
version = "2.2.0";
version = "2.2.1";
src = self;
nativeBuildInputs = (with pkgs; [
cmake
@@ -103,7 +103,7 @@
parallelBackends)) // {
manifold-js = pkgs.buildEmscriptenPackage {
name = "manifold-js";
version = "beta";
version = "2.2.1";
src = self;
nativeBuildInputs = (with pkgs; [ cmake python39 ]);
buildInputs = [ pkgs.nodejs ];
@@ -134,7 +134,7 @@
# but how should we make it work with other python versions?
manifold3d = with pkgs.python3Packages; buildPythonPackage {
pname = "manifold3d";
version = "2.2.0";
version = "2.2.1";
src = self;
propagatedBuildInputs = [
numpy
+1
View File
@@ -234,6 +234,7 @@ void ExportMesh(const std::string& filename, const MeshGL& mesh,
? 1
: mesh.vertProperties[i * mesh.numProp +
options.mat.colorChannels[j]];
c = glm::saturate(c);
mesh_out->mColors[0][i] = aiColor4D(c.r, c.g, c.b, c.a);
}
}
+2 -2
View File
@@ -1,13 +1,13 @@
[project]
name = "manifold3d"
version = "2.2.0"
version = "2.2.1"
authors = [
{ name="Emmett Lalish", email="elalish@gmail.com" },
]
description = "Library for geometric robustness"
readme = "README.md"
classifiers = [
"Development Status :: 4 - Beta",
"Development Status :: 5 - Production/Stable",
"License :: OSI Approved :: Apache Software License",
"Operating System :: OS Independent",
"Programming Language :: C++",
Binary file not shown.

Before

Width:  |  Height:  |  Size: 106 KiB

+17 -16
View File
@@ -463,9 +463,8 @@ struct MapTriRef {
}
};
Vec<TriRef> UpdateReference(Manifold::Impl &outR, const Manifold::Impl &inP,
const Manifold::Impl &inQ, bool invertQ) {
Vec<TriRef> refPQ = outR.meshRelation_.triRef;
void UpdateReference(Manifold::Impl &outR, const Manifold::Impl &inP,
const Manifold::Impl &inQ, bool invertQ) {
const int offsetQ = Manifold::Impl::meshIDCounter_;
for_each_n(
autoPolicy(outR.NumTri()), outR.meshRelation_.triRef.begin(),
@@ -480,7 +479,6 @@ Vec<TriRef> UpdateReference(Manifold::Impl &outR, const Manifold::Impl &inP,
outR.meshRelation_.meshIDtransform[pair.first + offsetQ].backSide ^=
invertQ;
}
return refPQ;
}
struct Barycentric {
@@ -514,8 +512,8 @@ struct Barycentric {
}
};
void CreateProperties(Manifold::Impl &outR, const Vec<TriRef> &refPQ,
const Manifold::Impl &inP, const Manifold::Impl &inQ) {
void CreateProperties(Manifold::Impl &outR, const Manifold::Impl &inP,
const Manifold::Impl &inQ) {
const int numPropP = inP.NumProp();
const int numPropQ = inQ.NumProp();
const int numProp = glm::max(numPropP, numPropQ);
@@ -526,7 +524,8 @@ void CreateProperties(Manifold::Impl &outR, const Vec<TriRef> &refPQ,
outR.meshRelation_.triProperties.resize(numTri);
Vec<glm::vec3> bary(outR.halfedge_.size());
for_each_n(autoPolicy(numTri), zip(countAt(0), refPQ.cbegin()), numTri,
for_each_n(autoPolicy(numTri),
zip(countAt(0), outR.meshRelation_.triRef.cbegin()), numTri,
Barycentric({bary, inP.vertPos_, inQ.vertPos_, outR.vertPos_,
inP.halfedge_, inQ.halfedge_, outR.halfedge_,
outR.precision_}));
@@ -541,14 +540,14 @@ void CreateProperties(Manifold::Impl &outR, const Vec<TriRef> &refPQ,
// Skip collapsed triangles
if (outR.halfedge_[3 * tri].startVert < 0) continue;
const int triPQ = refPQ[tri].tri;
const bool PQ = refPQ[tri].meshID == 0;
const TriRef ref = outR.meshRelation_.triRef[tri];
const bool PQ = ref.meshID == 0;
const int oldNumProp = PQ ? numPropP : numPropQ;
const auto &properties =
PQ ? inP.meshRelation_.properties : inQ.meshRelation_.properties;
const glm::ivec3 &triProp = oldNumProp == 0 ? glm::ivec3(-1)
: PQ ? inP.meshRelation_.triProperties[triPQ]
: inQ.meshRelation_.triProperties[triPQ];
: PQ ? inP.meshRelation_.triProperties[ref.tri]
: inQ.meshRelation_.triProperties[ref.tri];
for (const int i : {0, 1, 2}) {
const int vert = outR.halfedge_[3 * tri + i].startVert;
@@ -556,8 +555,7 @@ void CreateProperties(Manifold::Impl &outR, const Vec<TriRef> &refPQ,
glm::ivec4 key(PQ, idMissProp, -1, -1);
if (oldNumProp > 0) {
key[1] = vert;
int edge = -1;
int edge = -2;
for (const int j : {0, 1, 2}) {
if (uvw[j] == 1) {
// On a retained vert, the propVert must also match
@@ -571,8 +569,11 @@ void CreateProperties(Manifold::Impl &outR, const Vec<TriRef> &refPQ,
// On an edge, both propVerts must match
const int p0 = triProp[Next3(edge)];
const int p1 = triProp[Prev3(edge)];
key[1] = vert;
key[2] = glm::min(p0, p1);
key[3] = glm::max(p0, p1);
} else if (edge == -2) {
key[1] = vert;
}
}
@@ -770,12 +771,12 @@ Manifold::Impl Boolean3::Result(OpType op) const {
if (ManifoldParams().intermediateChecks)
ASSERT(outR.IsManifold(), logicErr, "triangulated mesh is not manifold!");
Vec<TriRef> refPQ = UpdateReference(outR, inP_, inQ_, invertQ);
CreateProperties(outR, inP_, inQ_);
UpdateReference(outR, inP_, inQ_, invertQ);
outR.SimplifyTopology();
CreateProperties(outR, refPQ, inP_, inQ_);
if (ManifoldParams().intermediateChecks)
ASSERT(outR.Is2Manifold(), logicErr, "simplified mesh is not 2-manifold!");
+3
View File
@@ -220,6 +220,9 @@ Manifold Manifold::Sphere(float radius, int circularSegments) {
/**
* Constructs a manifold from a set of polygons by extruding them along the
* Z-axis.
* Note that high twistDegrees with small nDivisions may cause
* self-intersection. This is not checked here and it is up to the user to
* choose the correct parameters.
*
* @param crossSection A set of non-overlapping polygons to extrude.
* @param height Z-extent of extrusion.
+10 -15
View File
@@ -501,25 +501,20 @@ void Manifold::Impl::CollapseEdge(const int edge, std::vector<int>& edges) {
const int tri1 = toRemove.pairedHalfedge / 3;
const int triVert0 = (edge + 1) % 3;
const int triVert1 = toRemove.pairedHalfedge % 3;
const int prop0 = triProp.size() > 0 ? triProp[tri0][edge % 3] : -1;
const int prop1 = triProp.size() > 0
? triProp[tri1][(toRemove.pairedHalfedge + 1) % 3]
: -1;
current = start;
while (current != tri0edge[2]) {
current = NextHalfedge(current);
// Update the shifted triangles to the vertBary of endVert
const int tri = current / 3;
const int vIdx = current - 3 * tri;
if (!shortEdge) {
if (triProp.size() > 0) {
if (triProp[tri][vIdx] == prop0) {
triProp[tri][vIdx] = triProp[tri0][triVert0];
} else if (triProp[tri][vIdx] == prop1) {
triProp[tri][vIdx] = triProp[tri1][triVert1];
}
if (triProp.size() > 0) {
// Update the shifted triangles to the vertBary of endVert
const int tri = current / 3;
const int vIdx = current - 3 * tri;
if (triRef[tri].meshID == triRef[tri0].meshID &&
triRef[tri].tri == triRef[tri0].tri) {
triProp[tri][vIdx] = triProp[tri0][triVert0];
} else if (triRef[tri].meshID == triRef[tri1].meshID &&
triRef[tri].tri == triRef[tri1].tri) {
triProp[tri][vIdx] = triProp[tri1][triVert1];
}
}
+6 -3
View File
@@ -196,10 +196,13 @@ struct SmoothBezier {
const glm::vec3 edgeNormal =
(triNormal[edge.face] + triNormal[halfedge[edge.pairedHalfedge].face]) /
2.0f;
glm::vec3 dir = glm::normalize(glm::cross(glm::cross(edgeNormal, edgeVec),
vertNormal[edge.startVert]));
glm::vec3 dir = SafeNormalize(glm::cross(glm::cross(edgeNormal, edgeVec),
vertNormal[edge.startVert]));
const float weight = glm::abs(glm::dot(dir, glm::normalize(edgeVec)));
float weight = glm::abs(glm::dot(dir, SafeNormalize(edgeVec)));
if (weight == 0) {
weight = 1;
}
// Quadratic weighted bezier for circular interpolation
const glm::vec4 bz2 =
weight *
+441 -2
View File
@@ -163,7 +163,7 @@ TEST(Boolean, Coplanar) {
MeshGL cylinderGL = WithPositionColors(cylinder);
cylinder = Manifold(cylinderGL);
Manifold cylinder2 = cylinder.Scale({0.8f, 0.8f, 1.0f}).Rotate(0, 0, 5);
Manifold cylinder2 = cylinder.Scale({0.8f, 0.8f, 1.0f}).Rotate(0, 0, 185);
Manifold out = cylinder - cylinder2;
ExpectMeshes(out, {{32, 64, 3, 48}});
EXPECT_EQ(out.NumDegenerateTris(), 0);
@@ -187,7 +187,7 @@ TEST(Boolean, CoplanarProp) {
MeshGL cylinderGL = WithIndexColors(cylinder.GetMesh());
cylinder = Manifold(cylinderGL);
Manifold cylinder2 = cylinder.Scale({0.8f, 0.8f, 1.0f}).Rotate(0, 0, 5);
Manifold cylinder2 = cylinder.Scale({0.8f, 0.8f, 1.0f}).Rotate(0, 0, 185);
Manifold out = cylinder - cylinder2;
ExpectMeshes(out, {{52, 104, 3, 88}});
EXPECT_EQ(out.NumDegenerateTris(), 0);
@@ -902,3 +902,442 @@ TEST(Boolean, Sweep) {
PolygonParams().processOverlaps = false;
}
TEST(Boolean, InterpolatedNormals) {
MeshGL a;
a.numProp = 8;
a.vertProperties = {
// 0
-409.0570983886719, -300, -198.83624267578125, 0, -1, 0,
590.9429321289062, 301.1637268066406,
// 1
-1000, -300, 500, 0, -1, 0, 0, 1000,
// 2
-1000, -300, -500, 0, -1, 0, 0, 0,
// 3
-1000, -300, -500, -1, 0, 0, 600, 0,
// 4
-1000, -300, 500, -1, 0, 0, 600, 1000,
// 5
-1000, 300, -500, -1, 0, 0, 0, 0,
// 6
7.179656982421875, -300, -330.03717041015625, 0, -1, 0,
1007.1796264648438, 169.9628448486328,
// 7
1000, 300, 500, 0, 0, 1, 2000, 600,
// 8
403.5837097167969, 300, 500, 0, 0, 1, 1403.583740234375, 600,
// 9
564.2904052734375, 21.64801025390625, 500, 0, 0, 1, 1564.29052734375,
321.64801025390625,
// 10
1000, -300, -500, 0, 0, -1, 2000, 600,
// 11
-1000, -300, -500, 0, 0, -1, 0, 600,
// 12
-1000, 300, -500, 0, 0, -1, 0, 0,
// 13
1000, 300, 500, 0, 1, 0, 0, 1000,
// 14
1000, 300, -500, 0, 1, 0, 0, 0,
// 15
724.5271606445312, 300, 398.83624267578125, 0, 1, 0, 275.47283935546875,
898.8362426757812,
// 16
-115.35255432128906, -300, 500, 0, -1, 0, 884.6475219726562,
1000.0001220703125,
// 17
-384.7195129394531, 166.55722045898438, 500, 0, 0, 1, 615.280517578125,
466.5572509765625,
// 18
-1000, -300, 500, 0, 0, 1, 0, 0,
// 19
-161.6136932373047, -219.87335205078125, 500, 0, 0, 1, 838.3862915039062,
80.12664794921875,
// 20
1000, -300, 500, 0, 0, 1, 2000, 0,
// 21
-115.35255432128906, -300, 500, 0, 0, 1, 884.6475219726562, 0,
// 22
1000, 300, 500, 1, 0, 0, 600, 1000,
// 23
1000, -300, 500, 1, 0, 0, 0, 1000,
// 24
1000, 300, -500, 1, 0, 0, 600, 0,
// 25
566.6257934570312, 300, 23.1280517578125, 0, 1, 0, 433.3742370605469,
523.1281127929688,
// 26
411.5867004394531, -66.51548767089844, -500, 0, 0, -1, 1411.586669921875,
366.5155029296875,
// 27
375.7498779296875, -4.444300651550293, -500, 0, 0, -1, 1375.7498779296875,
304.4443054199219,
// 28
346.7673034667969, 300, -500, 0, 1, 0, 653.2326049804688, 0,
// 29
-153.58984375, 300, -388.552490234375, 0, 1, 0, 1153.58984375,
111.447509765625,
// 30
199.9788818359375, 300, -500, 0, 1, 0, 800.0211791992188, 0,
// 31
-1000, 300, -500, 0, 1, 0, 2000, 0,
// 32
-153.58987426757812, 300, 44.22247314453125, 0, 1, 0, 1153.58984375,
544.2224731445312,
// 33
199.9788818359375, 300, -500, 0, 0, -1, 1199.9791259765625, 0,
// 34
521.6780395507812, -2.9542479515075684, -500, 0, 0, -1, 1521.677978515625,
302.9542541503906,
// 35
346.7673034667969, 300, -500, 0, 0, -1, 1346.767333984375, 0,
// 36
1000, 300, -500, 0, 0, -1, 2000, 0,
// 37
-1000, 300, 500, -1, 0, 0, 0, 1000,
// 38
-1000, 300, 500, 0, 0, 1, 0, 600,
// 39
-1000, 300, 500, 0, 1, 0, 2000, 1000,
// 40
-153.58985900878906, 300, 500, 0, 0, 1, 846.4102172851562, 600,
// 41
88.46627807617188, -253.06915283203125, 500, 0, 0, 1, 1088.4664306640625,
46.93084716796875,
// 42
-153.58985900878906, 300, 500, 0, 1, 0, 1153.58984375, 1000,
// 43
7.1796698570251465, -300, 500, 0, 0, 1, 1007.1797485351562, 0,
// 44
1000, -300, -500, 0, -1, 0, 2000, 0,
// 45
1000, -300, 500, 0, -1, 0, 2000, 1000,
// 46
7.1796698570251465, -300, 500, 0, -1, 0, 1007.1796264648438, 1000,
// 47
403.5837097167969, 300, 500, 0, 1, 0, 596.4163208007812, 1000,
// 48
1000, -300, -500, 1, 0, 0, 0, 0,
// 49
492.3005676269531, -19.915321350097656, -500, 0, 0, -1, 1492.300537109375,
319.91534423828125,
// 50
411.5867004394531, -66.51548767089844, -500, -0.5, 0.8660253882408142, 0,
880.5439453125, 0,
// 51
7.179656982421875, -300, -330.03717041015625, -0.5000000596046448,
0.866025447845459, 0, 383.6058654785156, 0,
// 52
492.3005676269531, -19.915321350097656, -500, -0.5, 0.8660253882408142, 0,
968.1235961914062, 31.876384735107422,
// 53
7.1796698570251465, -300, 500, -0.5000000596046448, 0.866025447845459, 0,
99.71644592285156, 779.979736328125,
// 54
88.46627807617188, -253.06915283203125, 500, -0.5, 0.8660253882408142, 0,
187.91758728027344, 812.0823974609375,
// 55
-153.58985900878906, 300, 500, 0.5, -0.866025447845459, 0,
749.2095947265625, 834.9661865234375,
// 56
-384.7195129394531, 166.55722045898438, 500, 0.5000000596046448,
-0.866025447845459, 0, 1000, 743.6859741210938,
// 57
-153.58987426757812, 300, 44.22247314453125, 0.5, -0.8660253882408142, 0,
593.3245239257812, 406.6754455566406,
// 58
564.2904052734375, 21.64801025390625, 500, -0.5, 0.866025447845459, 0,
704.217041015625, 1000.0000610351562,
// 59
-604.9979248046875, 39.37942886352539, -198.83624267578125, 0.5,
-0.8660253882408142, 0, 1000, 0,
// 60
199.9788818359375, 300, -500, 0.29619815945625305, 0.1710100919008255,
0.9396927356719971, 880.5438842773438, 176.7843475341797,
// 61
-153.58984375, 300, -388.552490234375, 0.29619815945625305,
0.1710100919008255, 0.9396927356719971, 554.6932373046875, 0,
// 62
375.7498779296875, -4.444300651550293, -500, 0.29619812965393066,
0.1710100919008255, 0.9396926760673523, 880.5438842773438,
528.3263549804688,
// 63
566.6257934570312, 300, 23.1280517578125, -0.8137977123260498,
-0.46984636783599854, 0.342020183801651, 239.89218139648438, 600.1796875,
// 64
346.7673034667969, 300, -500, -0.8137977719306946, -0.46984633803367615,
0.342020183801651, 349.8214111328125, 43.478458404541016,
// 65
521.6780395507812, -2.9542479515075684, -500, -0.8137977719306946,
-0.46984633803367615, 0.342020183801651, 0, 43.478458404541016,
// 66
804.9979248046875, 160.62057495117188, 398.83624267578125, -0.5,
0.8660253882408142, 0, 1000, 1000,
// 67
521.6780395507812, -2.9542479515075684, -500, -0.5, 0.8660253882408142, 0,
1000, 43.47837829589844,
// 68
-153.58984375, 300, -388.552490234375, 0.5, -0.8660253882408142, 0,
445.3067626953125, 0,
// 69
-604.9979248046875, 39.37942886352539, -198.83624267578125,
0.29619815945625305, 0.1710100919008255, 0.9396927356719971, 0, 0,
// 70
804.9979248046875, 160.62057495117188, 398.83624267578125,
-0.813797652721405, -0.46984630823135376, 0.3420201539993286, 0, 1000,
// 71
-161.6136932373047, -219.87335205078125, 500, 0.8137977123260498,
0.46984630823135376, -0.3420201539993286, 446.21160888671875,
743.68603515625,
// 72
-604.9979248046875, 39.37942886352539, -198.83624267578125,
0.813797652721405, 0.46984630823135376, -0.3420201539993286, 0, 0,
// 73
-384.7195129394531, 166.55722045898438, 500, 0.8137977123260498,
0.46984636783599854, -0.342020183801651, 0, 743.6859741210938,
// 74
-115.35255432128906, -300, 500, 0.813797652721405, 0.46984633803367615,
-0.3420201539993286, 538.73388671875, 743.68603515625,
// 75
-409.0570983886719, -300, -198.83624267578125, 0.813797652721405,
0.46984630823135376, -0.3420201539993286, 391.8816223144531, 0,
// 76
7.179656982421875, -300, -330.03717041015625, 0.29619815945625305,
0.1710100919008255, 0.9396927356719971, 383.6058654785156, 600,
// 77
564.2904052734375, 21.64801025390625, 500, -0.29619812965393066,
-0.1710100919008255, -0.9396926164627075, 704.2169189453125,
-0.000030517578125,
// 78
403.5837097167969, 300, 500, -0.29619812965393066, -0.1710100919008255,
-0.9396926164627075, 704.2169799804688, 321.4132385253906,
// 79
724.5271606445312, 300, 398.83624267578125, -0.29619815945625305,
-0.1710100919008255, -0.9396926760673523, 1000, 160.94149780273438,
// 80
804.9979248046875, 160.62057495117188, 398.83624267578125,
-0.29619815945625305, -0.1710100919008255, -0.9396927356719971, 1000, 0,
// 81
-409.0570983886719, -300, -198.83624267578125, 0.29619815945625305,
0.1710100919008255, 0.9396927356719971, 0, 391.88165283203125,
// 82
724.5271606445312, 300, 398.83624267578125, -0.813797652721405,
-0.46984630823135376, 0.342020183801651, 160.94149780273438,
1000.0000610351562,
// 83
411.5867004394531, -66.51548767089844, -500, 0.29619815945625305,
0.1710100769996643, 0.9396926164627075, 880.5440063476562,
600.0000610351562};
a.triVerts = {// 0
0, 1, 2,
// 1
3, 4, 5,
// 2
6, 0, 2,
// 3
7, 8, 9,
// 4
10, 11, 12,
// 5
13, 14, 15,
// 6
0, 16, 1,
// 7
17, 18, 19,
// 8
9, 20, 7,
// 9
18, 21, 19,
// 10
22, 23, 24,
// 11
14, 25, 15,
// 12
26, 12, 27,
// 13
14, 28, 25,
// 14
29, 30, 31,
// 15
29, 31, 32,
// 16
12, 33, 27,
// 17
34, 35, 36,
// 18
5, 4, 37,
// 19
17, 38, 18,
// 20
31, 39, 32,
// 21
40, 38, 17,
// 22
9, 41, 20,
// 23
39, 42, 32,
// 24
41, 43, 20,
// 25
6, 2, 44,
// 26
6, 45, 46,
// 27
26, 10, 12,
// 28
47, 13, 15,
// 29
48, 24, 23,
// 30
6, 44, 45,
// 31
26, 49, 10,
// 32
49, 34, 10,
// 33
34, 36, 10,
// 34
50, 51, 52,
// 35
51, 53, 54,
// 36
51, 54, 52,
// 37
55, 56, 57,
// 38
52, 54, 58,
// 39
59, 57, 56,
// 40
60, 61, 62,
// 41
63, 64, 65,
// 42
52, 66, 67,
// 43
59, 68, 57,
// 44
69, 62, 61,
// 45
65, 70, 63,
// 46
71, 72, 73,
// 47
52, 58, 66,
// 48
74, 72, 71,
// 49
74, 75, 72,
// 50
62, 69, 76,
// 51
77, 78, 79,
// 52
79, 80, 77,
// 53
69, 81, 76,
// 54
63, 70, 82,
// 55
76, 83, 62};
a.mergeFromVert = {3, 4, 11, 12, 13, 18, 21, 22, 23, 24, 31, 33, 35, 36,
38, 39, 42, 44, 45, 46, 47, 48, 50, 51, 52, 53, 54, 55,
56, 57, 58, 60, 61, 62, 63, 64, 65, 67, 68, 69, 70, 71,
72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83};
a.mergeToVert = {2, 1, 2, 5, 7, 1, 16, 7, 20, 14, 5, 30, 28, 14,
37, 37, 40, 10, 20, 43, 8, 10, 26, 6, 49, 43, 41, 40,
17, 32, 9, 30, 29, 27, 25, 28, 34, 34, 29, 59, 66, 19,
59, 17, 16, 0, 6, 9, 8, 15, 66, 0, 15, 26};
MeshGL b;
b.numProp = 8;
b.vertProperties = {// 0
-1700, -600, -1000, -1, 0, 0, 1200, 0,
// 1
-1700, -600, 1000, -1, 0, 0, 1200, 2000,
// 2
-1700, 600, -1000, -1, 0, 0, 0, 0,
// 3
-1700, -600, -1000, 0, -1, 0, 0, 0,
// 4
300, -600, -1000, 0, -1, 0, 2000, 0,
// 5
-1700, -600, 1000, 0, -1, 0, 0, 2000,
// 6
-1700, -600, -1000, 0, 0, -1, 0, 1200,
// 7
-1700, 600, -1000, 0, 0, -1, 0, 0,
// 8
300, -600, -1000, 0, 0, -1, 2000, 1200,
// 9
-1700, -600, 1000, 0, 0, 1, 0, 0,
// 10
300, -600, 1000, 0, 0, 1, 2000, 0,
// 11
-1700, 600, 1000, 0, 0, 1, 0, 1200,
// 12
-1700, 600, 1000, -1, 0, 0, 0, 2000,
// 13
-1700, 600, -1000, 0, 1, 0, 2000, 0,
// 14
-1700, 600, 1000, 0, 1, 0, 2000, 2000,
// 15
300, 600, 1000, 0, 1, 0, 0, 2000,
// 16
300, -600, -1000, 1, 0, 0, 0, 0,
// 17
300, 600, -1000, 1, 0, 0, 1200, 0,
// 18
300, -600, 1000, 1, 0, 0, 0, 2000,
// 19
300, -600, 1000, 0, -1, 0, 2000, 2000,
// 20
300, 600, -1000, 0, 0, -1, 2000, 0,
// 21
300, 600, -1000, 0, 1, 0, 0, 0,
// 22
300, 600, 1000, 0, 0, 1, 2000, 1200,
// 23
300, 600, 1000, 1, 0, 0, 1200, 2000};
b.triVerts = {// 0
0, 1, 2,
// 1
3, 4, 5,
// 2
6, 7, 8,
// 3
9, 10, 11,
// 4
1, 12, 2,
// 5
13, 14, 15,
// 6
16, 17, 18,
// 7
4, 19, 5,
// 8
7, 20, 8,
// 9
21, 13, 15,
// 10
10, 22, 11,
// 11
17, 23, 18};
b.mergeFromVert = {3, 5, 6, 7, 8, 9, 12, 13, 14, 16, 18, 19, 20, 21, 22, 23};
b.mergeToVert = {0, 1, 0, 2, 4, 1, 11, 2, 11, 4, 10, 10, 17, 17, 15, 15};
a.runOriginalID = {Manifold::ReserveIDs(1)};
b.runOriginalID = {Manifold::ReserveIDs(1)};
Manifold aManifold(a);
Manifold bManifold(b);
auto aMinusB = aManifold - bManifold;
std::vector<MeshGL> meshList;
meshList.emplace_back(a);
meshList.emplace_back(b);
RelatedGL(aMinusB, meshList, false, false);
}
+18
View File
@@ -115,3 +115,21 @@ TEST(SDF, Resize) {
EXPECT_EQ(layers.Status(), Manifold::Error::NoError);
EXPECT_EQ(layers.Genus(), -8);
}
TEST(SDF, SineSurface) {
Mesh surface(LevelSet(
[](glm::vec3 p) {
float mid = glm::sin(p.x) + glm::sin(p.y);
return (p.z > mid - 0.5 && p.z < mid + 0.5) ? 1 : 0;
},
{glm::vec3(-4 * glm::pi<float>()), glm::vec3(4 * glm::pi<float>())}, 1));
Manifold smoothed = Manifold::Smooth(surface).Refine(2);
EXPECT_EQ(smoothed.Status(), Manifold::Error::NoError);
EXPECT_EQ(smoothed.Genus(), -2);
#ifdef MANIFOLD_EXPORT
if (options.exportModels)
ExportMesh("sinesurface.glb", smoothed.GetMeshGL(), {});
#endif
}
+2 -2
View File
@@ -373,7 +373,7 @@ void RelatedGL(const Manifold& out, const std::vector<MeshGL>& originals,
glm::vec3 edges[3];
for (int k : {0, 1, 2}) edges[k] = inTriPos[k] - outTriPos[j];
const float volume = glm::dot(edges[0], glm::cross(edges[1], edges[2]));
ASSERT_LE(volume, area * 100 * out.Precision());
ASSERT_LE(volume, area * out.Precision());
if (checkNormals) {
glm::vec3 normal;
@@ -396,7 +396,7 @@ void RelatedGL(const Manifold& out, const std::vector<MeshGL>& originals,
const float volumeP =
glm::dot(edgesP[0], glm::cross(edgesP[1], edgesP[2]));
ASSERT_LE(volumeP, area * 100 * out.Precision());
ASSERT_LE(volumeP, area * out.Precision());
}
}
}