Skip to content
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

Double precision #895

Merged
merged 32 commits into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
8a7ca7f
added configuration summary
pca006132 Jul 30, 2024
a5de6a5
use custom math type
pca006132 Jul 30, 2024
bee9570
use std function if possible
pca006132 Jul 30, 2024
38077f0
build success
pca006132 Aug 11, 2024
1511564
fix js binding
pca006132 Aug 11, 2024
39bcd2a
Merge remote-tracking branch 'upstream/master' into double-precision
pca006132 Aug 11, 2024
4014641
format
pca006132 Aug 11, 2024
6083019
use better primitives
pca006132 Aug 11, 2024
4d48102
use old precision for polygon tests
pca006132 Aug 12, 2024
36f9ef9
merging master
elalish Aug 13, 2024
35967ea
merging master, cleanup hull
elalish Aug 20, 2024
85c1bf7
fix polygon CCW check
elalish Aug 21, 2024
aab9606
temp-fix tests
elalish Aug 22, 2024
0939e30
add simpler failing test case
elalish Aug 22, 2024
f014e1d
refactored CutKeyhole
elalish Aug 23, 2024
900bd85
fixed tests
elalish Aug 23, 2024
fb4a81f
more keyholing fixes
elalish Aug 24, 2024
25aabc3
truncate long debug output
elalish Aug 24, 2024
fbec45c
shrink SDF blobs test
elalish Aug 24, 2024
2bf9405
fixed WASM and disabled zebra
elalish Aug 24, 2024
cf26a37
merging master
elalish Aug 27, 2024
dc6de0f
fix hull
elalish Aug 29, 2024
e0c8048
cleanup a bit
pca006132 Sep 1, 2024
9301363
merging master
elalish Sep 1, 2024
db46659
Merge branch 'double-precision' of github.com:pca006132/manifold into…
elalish Sep 1, 2024
460a267
fix wasm
elalish Sep 1, 2024
d18d71d
CI cleanuo
elalish Sep 1, 2024
536cfea
reenable zebra
elalish Sep 2, 2024
9dcf037
upped precision and fixed tests
elalish Sep 2, 2024
3ffc865
fix format
elalish Sep 2, 2024
d2b55ba
merging master
elalish Sep 3, 2024
6fbd851
disable zebra test on windows
elalish Sep 3, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -172,3 +172,53 @@ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/manifold.pc
DESTINATION lib/pkgconfig)

endif()

# configuration summary, idea from openscad
# https://github.com/openscad/openscad/blob/master/cmake/Modules/info.cmake
message(STATUS "====================================")
message(STATUS "Manifold Build Configuration Summary")
message(STATUS "====================================")
message(STATUS " ")
if (MXECROSS)
message(STATUS "Environment: MXE")
elseif (APPLE)
message(STATUS "Environment: macOS")
elseif (WIN32)
if (MINGW)
message(STATUS "Environment: msys2")
else()
message(STATUS "Environment: Windows")
endif()
elseif (LINUX)
message(STATUS "Environment: Linux")
elseif(UNIX)
message(STATUS "Environment: Unknown Unix")
else()
message(STATUS "Environment: Unknown")
endif()
message(STATUS " ")
message(STATUS "CMAKE_VERSION: ${CMAKE_VERSION}")
message(STATUS "CMAKE_TOOLCHAIN_FILE: ${CMAKE_TOOLCHAIN_FILE}")
message(STATUS "CMAKE_GENERATOR: ${CMAKE_GENERATOR}")
message(STATUS "CPACK_CMAKE_GENERATOR: ${CPACK_CMAKE_GENERATOR}")
message(STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}")
message(STATUS "CMAKE_PREFIX_PATH: ${CMAKE_PREFIX_PATH}")
message(STATUS "CMAKE_CXX_COMPILER_ID: ${CMAKE_CXX_COMPILER_ID}")
message(STATUS "CMAKE_CXX_COMPILER_VERSION: ${CMAKE_CXX_COMPILER_VERSION}")
if (APPLE)
message(STATUS "CMAKE_OSX_DEPLOYMENT_TARGET: ${CMAKE_OSX_DEPLOYMENT_TARGET}")
message(STATUS "CMAKE_OSX_ARCHITECTURES: ${CMAKE_OSX_ARCHITECTURES}")
endif()
message(STATUS "BUILD_SHARED_LIBS: ${BUILD_SHARED_LIBS}")
message(STATUS " ")
message(STATUS "MANIFOLD_PAR: ${MANIFOLD_PAR}")
message(STATUS "MANIFOLD_FLAGS: ${MANIFOLD_FLAGS}")
message(STATUS "MANIFOLD_EXPORT: ${MANIFOLD_EXPORT}")
message(STATUS "MANIFOLD_TEST: ${MANIFOLD_TEST}")
message(STATUS "MANIFOLD_FUZZ: ${MANIFOLD_FUZZ}")
message(STATUS "MANIFOLD_DEBUG: ${MANIFOLD_DEBUG}")
message(STATUS "MANIFOLD_PYBIND: ${MANIFOLD_PYBIND}")
message(STATUS "MANIFOLD_CBIND: ${MANIFOLD_CBIND}")
message(STATUS "MANIFOLD_JSBIND: ${MANIFOLD_JSBIND}")
message(STATUS "MANIFOLD_EXCEPTIONS: ${MANIFOLD_EXCEPTIONS}")
message(STATUS " ")
44 changes: 22 additions & 22 deletions bindings/c/box.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
#include "public.h"
#include "types.h"

ManifoldBox *manifold_box(void *mem, float x1, float y1, float z1, float x2,
float y2, float z2) {
auto p1 = glm::vec3(x1, y1, z1);
auto p2 = glm::vec3(x2, y2, z2);
ManifoldBox *manifold_box(void *mem, double x1, double y1, double z1, double x2,
double y2, double z2) {
auto p1 = vec3(x1, y1, z1);
auto p2 = vec3(x2, y2, z2);
auto box = new (mem) Box(p1, p2);
return to_c(box);
}
Expand All @@ -39,10 +39,10 @@ ManifoldVec3 manifold_box_center(ManifoldBox *b) {
return {v.x, v.y, v.z};
}

float manifold_box_scale(ManifoldBox *b) { return from_c(b)->Scale(); }
double manifold_box_scale(ManifoldBox *b) { return from_c(b)->Scale(); }

int manifold_box_contains_pt(ManifoldBox *b, float x, float y, float z) {
auto p = glm::vec3(x, y, z);
int manifold_box_contains_pt(ManifoldBox *b, double x, double y, double z) {
auto p = vec3(x, y, z);
return from_c(b)->Contains(p);
}

Expand All @@ -52,9 +52,9 @@ int manifold_box_contains_box(ManifoldBox *a, ManifoldBox *b) {
return outer.Contains(inner);
}

void manifold_box_include_pt(ManifoldBox *b, float x, float y, float z) {
void manifold_box_include_pt(ManifoldBox *b, double x, double y, double z) {
auto box = *from_c(b);
auto p = glm::vec3(x, y, z);
auto p = vec3(x, y, z);
box.Union(p);
}

Expand All @@ -63,31 +63,31 @@ ManifoldBox *manifold_box_union(void *mem, ManifoldBox *a, ManifoldBox *b) {
return to_c(new (mem) Box(box));
}

ManifoldBox *manifold_box_transform(void *mem, ManifoldBox *b, float x1,
float y1, float z1, float x2, float y2,
float z2, float x3, float y3, float z3,
float x4, float y4, float z4) {
auto mat = glm::mat4x3(x1, y1, z1, x2, y2, z2, x3, y3, z3, x4, y4, z4);
ManifoldBox *manifold_box_transform(void *mem, ManifoldBox *b, double x1,
double y1, double z1, double x2, double y2,
double z2, double x3, double y3, double z3,
double x4, double y4, double z4) {
auto mat = mat4x3(x1, y1, z1, x2, y2, z2, x3, y3, z3, x4, y4, z4);
auto transformed = from_c(b)->Transform(mat);
return to_c(new (mem) Box(transformed));
}

ManifoldBox *manifold_box_translate(void *mem, ManifoldBox *b, float x, float y,
float z) {
auto p = glm::vec3(x, y, z);
ManifoldBox *manifold_box_translate(void *mem, ManifoldBox *b, double x,
double y, double z) {
auto p = vec3(x, y, z);
auto translated = (*from_c(b)) + p;
return to_c(new (mem) Box(translated));
}

ManifoldBox *manifold_box_mul(void *mem, ManifoldBox *b, float x, float y,
float z) {
auto p = glm::vec3(x, y, z);
ManifoldBox *manifold_box_mul(void *mem, ManifoldBox *b, double x, double y,
double z) {
auto p = vec3(x, y, z);
auto scaled = (*from_c(b)) * p;
return to_c(new (mem) Box(scaled));
}

int manifold_box_does_overlap_pt(ManifoldBox *b, float x, float y, float z) {
auto p = glm::vec3(x, y, z);
int manifold_box_does_overlap_pt(ManifoldBox *b, double x, double y, double z) {
auto p = vec3(x, y, z);
return from_c(b)->DoesOverlap(p);
}

Expand Down
26 changes: 13 additions & 13 deletions bindings/c/conv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,11 @@ ManifoldRect *to_c(manifold::Rect *m) {
return reinterpret_cast<ManifoldRect *>(m);
}

ManifoldVec2 to_c(glm::vec2 v) { return {v.x, v.y}; }
ManifoldVec2 to_c(vec2 v) { return {v.x, v.y}; }

ManifoldVec3 to_c(glm::vec3 v) { return {v.x, v.y, v.z}; }
ManifoldVec3 to_c(vec3 v) { return {v.x, v.y, v.z}; }

ManifoldIVec3 to_c(glm::ivec3 v) { return {v.x, v.y, v.z}; }
ManifoldIVec3 to_c(ivec3 v) { return {v.x, v.y, v.z}; }

ManifoldProperties to_c(manifold::Properties p) {
return {p.surfaceArea, p.volume};
Expand Down Expand Up @@ -216,32 +216,32 @@ const manifold::Rect *from_c(ManifoldRect *m) {
return reinterpret_cast<manifold::Rect const *>(m);
}

glm::vec2 from_c(ManifoldVec2 v) { return glm::vec2(v.x, v.y); }
vec2 from_c(ManifoldVec2 v) { return vec2(v.x, v.y); }

glm::vec3 from_c(ManifoldVec3 v) { return glm::vec3(v.x, v.y, v.z); }
vec3 from_c(ManifoldVec3 v) { return vec3(v.x, v.y, v.z); }

glm::ivec3 from_c(ManifoldIVec3 v) { return glm::ivec3(v.x, v.y, v.z); }
ivec3 from_c(ManifoldIVec3 v) { return ivec3(v.x, v.y, v.z); }

glm::vec4 from_c(ManifoldVec4 v) { return glm::vec4(v.x, v.y, v.z, v.w); }
vec4 from_c(ManifoldVec4 v) { return vec4(v.x, v.y, v.z, v.w); }

std::vector<glm::vec3> vector_of_vec_array(ManifoldVec3 *vs, size_t length) {
auto vec = std::vector<glm::vec3>();
std::vector<vec3> vector_of_vec_array(ManifoldVec3 *vs, size_t length) {
auto vec = std::vector<vec3>();
for (size_t i = 0; i < length; ++i) {
vec.push_back(from_c(vs[i]));
}
return vec;
}

std::vector<glm::ivec3> vector_of_vec_array(ManifoldIVec3 *vs, size_t length) {
auto vec = std::vector<glm::ivec3>();
std::vector<ivec3> vector_of_vec_array(ManifoldIVec3 *vs, size_t length) {
auto vec = std::vector<ivec3>();
for (size_t i = 0; i < length; ++i) {
vec.push_back(from_c(vs[i]));
}
return vec;
}

std::vector<glm::vec4> vector_of_vec_array(ManifoldVec4 *vs, size_t length) {
auto vec = std::vector<glm::vec4>();
std::vector<vec4> vector_of_vec_array(ManifoldVec4 *vs, size_t length) {
auto vec = std::vector<vec4>();
for (size_t i = 0; i < length; ++i) {
vec.push_back(from_c(vs[i]));
}
Expand Down
36 changes: 18 additions & 18 deletions bindings/c/cross.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,13 @@ void manifold_cross_section_vec_push_back(ManifoldCrossSectionVec *csv,
return from_c(csv)->push_back(*from_c(cs));
}

ManifoldCrossSection *manifold_cross_section_square(void *mem, float x, float y,
int center) {
auto cs = CrossSection::Square(glm::vec2(x, y), center);
ManifoldCrossSection *manifold_cross_section_square(void *mem, double x,
double y, int center) {
auto cs = CrossSection::Square(vec2(x, y), center);
return to_c(new (mem) CrossSection(cs));
}

ManifoldCrossSection *manifold_cross_section_circle(void *mem, float radius,
ManifoldCrossSection *manifold_cross_section_circle(void *mem, double radius,
int circular_segments) {
auto cs = CrossSection::Circle(radius, circular_segments);
return to_c(new (mem) CrossSection(cs));
Expand Down Expand Up @@ -145,49 +145,49 @@ ManifoldCrossSection *manifold_cross_section_hull_polygons(

ManifoldCrossSection *manifold_cross_section_translate(void *mem,
ManifoldCrossSection *cs,
float x, float y) {
auto translated = from_c(cs)->Translate(glm::vec2(x, y));
double x, double y) {
auto translated = from_c(cs)->Translate(vec2(x, y));
return to_c(new (mem) CrossSection(translated));
}

ManifoldCrossSection *manifold_cross_section_rotate(void *mem,
ManifoldCrossSection *cs,
float deg) {
double deg) {
auto rotated = from_c(cs)->Rotate(deg);
return to_c(new (mem) CrossSection(rotated));
}

ManifoldCrossSection *manifold_cross_section_scale(void *mem,
ManifoldCrossSection *cs,
float x, float y) {
auto scaled = from_c(cs)->Scale(glm::vec2(x, y));
double x, double y) {
auto scaled = from_c(cs)->Scale(vec2(x, y));
return to_c(new (mem) CrossSection(scaled));
}

ManifoldCrossSection *manifold_cross_section_mirror(void *mem,
ManifoldCrossSection *cs,
float ax_x, float ax_y) {
auto mirrored = from_c(cs)->Mirror(glm::vec2(ax_x, ax_y));
double ax_x, double ax_y) {
auto mirrored = from_c(cs)->Mirror(vec2(ax_x, ax_y));
return to_c(new (mem) CrossSection(mirrored));
}

ManifoldCrossSection *manifold_cross_section_transform(void *mem,
ManifoldCrossSection *cs,
float x1, float y1,
float x2, float y2,
float x3, float y3) {
auto mat = glm::mat3x2(x1, y1, x2, y2, x3, y3);
double x1, double y1,
double x2, double y2,
double x3, double y3) {
auto mat = mat3x2(x1, y1, x2, y2, x3, y3);
auto transformed = from_c(cs)->Transform(mat);
return to_c(new (mem) CrossSection(transformed));
}

ManifoldCrossSection *manifold_cross_section_warp(
void *mem, ManifoldCrossSection *cs,
ManifoldVec2 (*fun)(float, float, void *), void *ctx) {
ManifoldVec2 (*fun)(double, double, void *), void *ctx) {
// Bind function with context argument to one without
using namespace std::placeholders;
std::function<ManifoldVec2(float, float)> f2 = std::bind(fun, _1, _2, ctx);
std::function<void(glm::vec2 & v)> warp = [f2](glm::vec2 &v) {
std::function<ManifoldVec2(double, double)> f2 = std::bind(fun, _1, _2, ctx);
std::function<void(vec2 & v)> warp = [f2](vec2 &v) {
v = from_c(f2(v.x, v.y));
};
auto warped = from_c(cs)->Warp(warp);
Expand Down
20 changes: 10 additions & 10 deletions bindings/c/include/conv.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ ManifoldMeshGL *to_c(manifold::MeshGL *m);
ManifoldBox *to_c(manifold::Box *m);
ManifoldRect *to_c(manifold::Rect *m);
ManifoldError to_c(manifold::Manifold::Error error);
ManifoldVec2 to_c(glm::vec2 v);
ManifoldVec3 to_c(glm::vec3 v);
ManifoldIVec3 to_c(glm::ivec3 v);
ManifoldVec2 to_c(vec2 v);
ManifoldVec3 to_c(vec3 v);
ManifoldIVec3 to_c(ivec3 v);
ManifoldProperties to_c(manifold::Properties p);

const manifold::Manifold *from_c(ManifoldManifold *m);
Expand All @@ -54,14 +54,14 @@ CrossSection::FillRule from_c(ManifoldFillRule fillrule);
CrossSection::JoinType from_c(ManifoldJoinType jt);
const manifold::Box *from_c(ManifoldBox *m);
const manifold::Rect *from_c(ManifoldRect *r);
glm::vec2 from_c(ManifoldVec2 v);
glm::vec3 from_c(ManifoldVec3 v);
glm::ivec3 from_c(ManifoldIVec3 v);
glm::vec4 from_c(ManifoldVec4 v);
vec2 from_c(ManifoldVec2 v);
vec3 from_c(ManifoldVec3 v);
ivec3 from_c(ManifoldIVec3 v);
vec4 from_c(ManifoldVec4 v);

std::vector<glm::vec3> vector_of_vec_array(ManifoldVec3 *vs, size_t length);
std::vector<glm::ivec3> vector_of_vec_array(ManifoldIVec3 *vs, size_t length);
std::vector<glm::vec4> vector_of_vec_array(ManifoldVec4 *vs, size_t length);
std::vector<vec3> vector_of_vec_array(ManifoldVec3 *vs, size_t length);
std::vector<ivec3> vector_of_vec_array(ManifoldIVec3 *vs, size_t length);
std::vector<vec4> vector_of_vec_array(ManifoldVec4 *vs, size_t length);

template <typename T>
std::vector<T> vector_of_array(T *ts, size_t length) {
Expand Down
Loading