From 01472ed4d7a4aa08a8d7dec6f2e77c182ae31e5e Mon Sep 17 00:00:00 2001 From: Carsten Arnholm Date: Sat, 6 Apr 2019 20:50:16 +0200 Subject: [PATCH 01/12] Correct sign warnings & make MSVC2013 compatible --- include/carve/aabb_impl.hpp | 1 + include/carve/csg_triangulator.hpp | 2 +- include/carve/exact.hpp | 8 ++-- include/carve/geom2d.hpp | 2 +- include/carve/input.hpp | 2 +- include/carve/mesh.hpp | 7 ++-- include/carve/mesh_impl.hpp | 2 +- include/carve/mesh_simplify.hpp | 19 +++++----- include/carve/polyhedron_impl.hpp | 2 +- include/carve/polyline_iter.hpp | 8 ++-- include/carve/rtree.hpp | 6 +-- include/carve/vector.hpp | 2 +- include/carve/win32.h | 5 +++ lib/intersect_face_division.cpp | 4 +- lib/mesh.cpp | 3 +- lib/polyhedron.cpp | 8 ++-- lib/polyline.cpp | 2 +- lib/shewchuk_predicates.cpp | 17 ++++----- lib/triangle_intersection.cpp | 60 +++++++++++++++++++----------- lib/triangulator.cpp | 14 ++++--- src/close_manifold.cpp | 2 +- src/convert.cpp | 2 +- src/cut.cpp | 2 +- src/extrude.cpp | 10 ++--- src/face_merge.cpp | 1 - src/intersect.cpp | 2 +- src/selfintersect.cpp | 20 +++++----- src/triangulate.cpp | 2 +- 28 files changed, 122 insertions(+), 93 deletions(-) diff --git a/include/carve/aabb_impl.hpp b/include/carve/aabb_impl.hpp index f43270a..a9e63e2 100644 --- a/include/carve/aabb_impl.hpp +++ b/include/carve/aabb_impl.hpp @@ -32,6 +32,7 @@ #include #include +#include namespace carve { namespace geom { diff --git a/include/carve/csg_triangulator.hpp b/include/carve/csg_triangulator.hpp index 41d56b9..286fc84 100644 --- a/include/carve/csg_triangulator.hpp +++ b/include/carve/csg_triangulator.hpp @@ -136,7 +136,7 @@ class CarveTriangulationImprover : public csg::CSG::Hook { } else { v = (*j).second; } - tri.v[i.idx()] = v; + tri.v[i.idx()] = static_cast(v); } result.push_back(tri); delete face; diff --git a/include/carve/exact.hpp b/include/carve/exact.hpp index 4efe91e..5d3e15e 100644 --- a/include/carve/exact.hpp +++ b/include/carve/exact.hpp @@ -382,7 +382,7 @@ static inline void prod_2_1(const double* a, const double* b, double* r) { double t3[2]; op<1, 1>::add(t1 + 1, t2, t3); r[1] = t3[0]; - double t4[2]; +// double t4[2]; op<1, 1>::add_fast(t2 + 1, t3 + 1, r + 2); } @@ -510,7 +510,7 @@ static inline void square_2(const double* a, double* r) { r[1] = t4[0]; double t5[2]; square(a[1], t5); - double t6[4]; +// double t6[4]; op<2, 2>::add(t5, t4 + 1, r + 2); } } // namespace detail @@ -518,7 +518,7 @@ static inline void square_2(const double* a, double* r) { void exact_t::compress() { double sum[2]; - int j = size() - 1; + size_t j = size() - 1; double Q = (*this)[j]; for (int i = (int)size() - 2; i >= 0; --i) { detail::op<1, 1>::add_fast(&Q, &(*this)[i], sum); @@ -530,7 +530,7 @@ void exact_t::compress() { } } int j2 = 0; - for (int i = j + 1; i < (int)size(); ++i) { + for (size_t i = j + 1; i < size(); ++i) { detail::op<1, 1>::add_fast(&(*this)[i], &Q, sum); if (sum[0] != 0) { (*this)[j2++] = sum[0]; diff --git a/include/carve/geom2d.hpp b/include/carve/geom2d.hpp index 8145730..d8d84e6 100644 --- a/include/carve/geom2d.hpp +++ b/include/carve/geom2d.hpp @@ -32,7 +32,7 @@ #include #include - +#include #include #if defined(CARVE_DEBUG) diff --git a/include/carve/input.hpp b/include/carve/input.hpp index adae650..85a2008 100644 --- a/include/carve/input.hpp +++ b/include/carve/input.hpp @@ -138,7 +138,7 @@ struct PolyhedronData : public VertexData { void addFace(Iter begin, Iter end) { size_t n = std::distance(begin, end); faceIndices.reserve(faceIndices.size() + n + 1); - faceIndices.push_back(n); + faceIndices.push_back(static_cast(n)); std::copy(begin, end, std::back_inserter(faceIndices)); ++faceCount; } diff --git a/include/carve/mesh.hpp b/include/carve/mesh.hpp index 117ba30..3bd0095 100644 --- a/include/carve/mesh.hpp +++ b/include/carve/mesh.hpp @@ -310,7 +310,8 @@ class Face : public tagable { unproject(nullptr) {} Face(const Face& other) - : edge(nullptr), + : tagable(other), + edge(nullptr), n_edges(other.n_edges), mesh(nullptr), id(other.id), @@ -326,10 +327,10 @@ class Face : public tagable { typedef detail::list_iter_t > const_edge_iter_t; edge_iter_t begin() { return edge_iter_t(edge, 0); } - edge_iter_t end() { return edge_iter_t(edge, n_edges); } + edge_iter_t end() { return edge_iter_t(edge, static_cast(n_edges)); } const_edge_iter_t begin() const { return const_edge_iter_t(edge, 0); } - const_edge_iter_t end() const { return const_edge_iter_t(edge, n_edges); } + const_edge_iter_t end() const { return const_edge_iter_t(edge, static_cast(n_edges)); } bool containsPoint(const vector_t& p) const; bool containsPointInProjection(const vector_t& p) const; diff --git a/include/carve/mesh_impl.hpp b/include/carve/mesh_impl.hpp index b911798..8c2844c 100644 --- a/include/carve/mesh_impl.hpp +++ b/include/carve/mesh_impl.hpp @@ -438,7 +438,7 @@ typename Face::vector_t Face::centroid() const { v += e->vert->v; e = e->next; } while (e != edge); - v /= n_edges; + v /= static_cast(n_edges); return v; } diff --git a/include/carve/mesh_simplify.hpp b/include/carve/mesh_simplify.hpp index c69df58..5472f19 100644 --- a/include/carve/mesh_simplify.hpp +++ b/include/carve/mesh_simplify.hpp @@ -38,8 +38,7 @@ #include #include #include - -#include "write_ply.hpp" +#include namespace carve { namespace mesh { @@ -388,7 +387,7 @@ class MeshSimplifier { } } - return ints.size(); + return static_cast(ints.size()); } int countIntersections(const vertex_t* v1, const vertex_t* v2, @@ -1049,11 +1048,11 @@ class MeshSimplifier { } double minimize(carve::geom::vector<3>& vert, - const std::list >& planes, int axis) { + const std::list >& planes, unsigned axis) { double num = 0.0; double den = 0.0; - int a1 = (axis + 1) % 3; - int a2 = (axis + 2) % 3; + unsigned a1 = (axis + 1) % 3; + unsigned a2 = (axis + 2) % 3; for (std::list >::const_iterator i = planes.begin(); i != planes.end(); ++i) { const carve::geom::vector<3>& N = (*i).N; @@ -1311,7 +1310,7 @@ class MeshSimplifier { } double d = summedError(vert->v, planes); - for (size_t N = 0;; N = (N + 1) % 3) { + for (unsigned N = 0;; N = (N + 1) % 3) { if (constraint & (1 << N)) { continue; } @@ -1333,7 +1332,7 @@ class MeshSimplifier { if (constraint & (1 << N)) { continue; } - if (axes & (1 << N)) { + if (axes & (1ULL << N)) { v.v[N] = ceil(v.v[N] / grid) * grid; } else { v.v[N] = floor(v.v[N] / grid) * grid; @@ -1462,8 +1461,8 @@ class MeshSimplifier { heap() { for (size_t i = 0; i < (1 << 3); ++i) { vector_t t = origin; - for (size_t j = 0; j < 3; ++j) { - if (i & (1U << j)) { + for (unsigned j = 0; j < 3; ++j) { + if (i & (1ULL << j)) { t[j] = ceil(t[j] * rounding_fac) / rounding_fac; } else { t[j] = floor(t[j] * rounding_fac) / rounding_fac; diff --git a/include/carve/polyhedron_impl.hpp b/include/carve/polyhedron_impl.hpp index 3d0b2cd..c0e6085 100644 --- a/include/carve/polyhedron_impl.hpp +++ b/include/carve/polyhedron_impl.hpp @@ -256,7 +256,7 @@ int Polyhedron::vertexManifolds(const vertex_t* v, T result) const { } std::copy(em.begin(), em.end(), result); - return em.size(); + return static_cast(em.size()); } template diff --git a/include/carve/polyline_iter.hpp b/include/carve/polyline_iter.hpp index 0ec6783..ddecc52 100644 --- a/include/carve/polyline_iter.hpp +++ b/include/carve/polyline_iter.hpp @@ -69,7 +69,7 @@ struct polyline_vertex_iter } Vertex* operator*() const { - CARVE_ASSERT(idx >= 0 && idx < base->vertexCount()); + CARVE_ASSERT(idx >= 0 && idx < static_cast(base->vertexCount())); return base->vertex((size_t)idx); } }; @@ -139,7 +139,7 @@ struct polyline_vertex_const_iter } const Vertex* operator*() const { - CARVE_ASSERT(idx >= 0 && idx < base->vertexCount()); + CARVE_ASSERT(idx >= 0 && idx < static_cast(base->vertexCount())); return base->vertex((size_t)idx); } }; @@ -217,7 +217,7 @@ struct polyline_edge_iter } PolylineEdge* operator*() const { - CARVE_ASSERT(idx >= 0 && idx < base->edgeCount()); + CARVE_ASSERT(idx >= 0 && idx < static_cast(base->edgeCount())); return base->edge((size_t)idx); } }; @@ -287,7 +287,7 @@ struct polyline_edge_const_iter } const PolylineEdge* operator*() const { - CARVE_ASSERT(idx >= 0 && idx < base->edgeCount()); + CARVE_ASSERT(idx >= 0 && idx < static_cast(base->edgeCount())); return base->edge((size_t)idx); } }; diff --git a/include/carve/rtree.hpp b/include/carve/rtree.hpp index c8256d7..eb79fd4 100644 --- a/include/carve/rtree.hpp +++ b/include/carve/rtree.hpp @@ -194,10 +194,10 @@ struct RTreeNode { aabb_cmp_mid(size_t _dim) : dim(_dim) {} bool operator()(const node_t* a, const node_t* b) { - return a->bbox.mid(dim) < b->bbox.mid(dim); + return a->bbox.mid(static_cast(dim)) < b->bbox.mid(static_cast(dim)); } bool operator()(const data_aabb_t& a, const data_aabb_t& b) { - return a.bbox.mid(dim) < b.bbox.mid(dim); + return a.bbox.mid(static_cast(dim)) < b.bbox.mid(static_cast(dim)); } }; @@ -257,7 +257,7 @@ struct RTreeNode { const size_t N = std::distance(begin, end); size_t dim = ndim; - double r_best = N + 1; + double r_best = static_cast(N + 1); // find the sparsest remaining dimension to partition by. for (size_t i = 0; i < ndim; ++i) { diff --git a/include/carve/vector.hpp b/include/carve/vector.hpp index 79133c8..0f31de5 100644 --- a/include/carve/vector.hpp +++ b/include/carve/vector.hpp @@ -31,7 +31,7 @@ #include #include - +#include #include namespace carve { diff --git a/include/carve/win32.h b/include/carve/win32.h index 82cdcf5..1649481 100755 --- a/include/carve/win32.h +++ b/include/carve/win32.h @@ -21,7 +21,12 @@ inline long random() { } #if defined(_MSC_VER) +#if _MSC_VER < 1800 # include +#else +# include +typedef SSIZE_T ssize_t; +#endif #if _MSC_VER < 1300 // intptr_t is an integer type that is big enough to hold a pointer diff --git a/lib/intersect_face_division.cpp b/lib/intersect_face_division.cpp index ca87ebb..d12657b 100644 --- a/lib/intersect_face_division.cpp +++ b/lib/intersect_face_division.cpp @@ -499,7 +499,7 @@ static void computeContainment( face_loops_sorted[m].reserve(f_loop.size()); for (size_t n = 0; n < f_loop.size(); ++n) { face_loops_projected[m].push_back(face->project(f_loop[n]->v)); - face_loops_sorted[m].push_back(n); + face_loops_sorted[m].push_back(static_cast(n)); } face_loop_areas.push_back( carve::geom2d::signedArea(face_loops_projected[m])); @@ -519,7 +519,7 @@ static void computeContainment( hole_loops_projected[m].reserve(h_loop.size()); for (size_t n = 0; n < h_loop.size(); ++n) { hole_loops_projected[m].push_back(face->project(h_loop[n]->v)); - hole_loops_sorted[m].push_back(n); + hole_loops_sorted[m].push_back(static_cast(n)); } hole_loop_areas.push_back( carve::geom2d::signedArea(hole_loops_projected[m])); diff --git a/lib/mesh.cpp b/lib/mesh.cpp index cd3dab3..77b50b8 100644 --- a/lib/mesh.cpp +++ b/lib/mesh.cpp @@ -31,6 +31,7 @@ #include #include +#include namespace { inline double CALC_X(const carve::geom::plane<3>& p, double y, double z) { @@ -932,7 +933,7 @@ static void copyMeshFaces( ; poly->faces.push_back(poly::Polyhedron::face_t(vert_ptr)); - poly->faces.back().manifold_id = manifold_id; + poly->faces.back().manifold_id = static_cast(manifold_id); poly->faces.back().owner = poly; } } diff --git a/lib/polyhedron.cpp b/lib/polyhedron.cpp index 99660da..c9b8a96 100644 --- a/lib/polyhedron.cpp +++ b/lib/polyhedron.cpp @@ -251,7 +251,7 @@ bool Polyhedron::initConnectivity() { for (size_t f = 0; f < mesh->faces.size(); ++f) { mesh::Face<3>* src = mesh->faces[f]; mesh::Edge<3>* e = src->edge; - faces[face_map[src]].manifold_id = m; + faces[face_map[src]].manifold_id = static_cast(m); do { edge_map[std::make_pair(e->v1() - Vbase, e->v2() - Vbase)].push_back( e); @@ -360,7 +360,7 @@ bool Polyhedron::calcManifoldEmbedding() { carve::TimingBlock block(FUNC_NAME); - const unsigned MCOUNT = manifoldCount(); + const size_t MCOUNT = manifoldCount(); if (MCOUNT < 2) { return true; } @@ -784,14 +784,14 @@ void Polyhedron::testVertexAgainstClosedManifolds( if (!manifold_is_closed[i]) { continue; } - if (result.find(i) != result.end()) { + if (result.find(static_cast(i)) != result.end()) { continue; } PointClass pc = (crossings[i] & 1) ? POINT_IN : POINT_OUT; if (!ignore_orientation && manifold_is_negative[i]) { pc = (PointClass)-pc; } - result[i] = pc; + result[static_cast(i)] = pc; } } diff --git a/lib/polyline.cpp b/lib/polyline.cpp index 2b3664f..5a927a6 100644 --- a/lib/polyline.cpp +++ b/lib/polyline.cpp @@ -58,7 +58,7 @@ void PolylineSet::sortVertices(const carve::geom3d::Vector& axis) { for (size_t i = 0; i < vertices.size(); ++i) { vnew.push_back(vertices[temp[i].second]); - revmap[temp[i].second] = i; + revmap[temp[i].second] = static_cast(i); } for (line_iter i = lines.begin(); i != lines.end(); ++i) { diff --git a/lib/shewchuk_predicates.cpp b/lib/shewchuk_predicates.cpp index ae09b66..9b8ff08 100644 --- a/lib/shewchuk_predicates.cpp +++ b/lib/shewchuk_predicates.cpp @@ -116,7 +116,6 @@ #include #include #include -#include /* On some machines, the exact arithmetic routines might be defeated by the */ /* use of internal extended precision floating-point registers. Sometimes */ @@ -519,9 +518,9 @@ double doublerand() { long a, b, c; long i; - a = random(); - b = random(); - c = random(); + a = rand(); + b = rand(); + c = rand(); result = (double)(a - 1073741824) * 8388608.0 + (double)(b >> 8); for (i = 512, expo = 2; i <= 131072; i *= 2, expo = expo * expo) { if (c & i) { @@ -544,9 +543,9 @@ double narrowdoublerand() { long a, b, c; long i; - a = random(); - b = random(); - c = random(); + a = rand(); + b = rand(); + c = rand(); result = (double)(a - 1073741824) * 8388608.0 + (double)(b >> 8); for (i = 512, expo = 2; i <= 2048; i *= 2, expo = expo * expo) { if (c & i) { @@ -566,8 +565,8 @@ double uniformdoublerand() { double result; long a, b; - a = random(); - b = random(); + a = rand(); + b = rand(); result = (double)(a - 1073741824) * 8388608.0 + (double)(b >> 8); return result; } diff --git a/lib/triangle_intersection.cpp b/lib/triangle_intersection.cpp index f5e6034..d643b1c 100644 --- a/lib/triangle_intersection.cpp +++ b/lib/triangle_intersection.cpp @@ -35,6 +35,7 @@ #include #include +#include typedef carve::geom::vector<3> vec3; typedef carve::geom::vector<2> vec2; @@ -139,6 +140,10 @@ bool sat_plane(const vec3 tri_a[3], const vec3 tri_b[3], unsigned i, unsigned j, return false; } +inline bool sat_plane_size_t(const vec3 tri_a[3], const vec3 tri_b[3], size_t i, size_t j, size_t k) { + return sat_plane(tri_a, tri_b, static_cast(i), static_cast(j), static_cast(k)); +} + // returns true if no intersection, based upon edge^a_i and vertex^b_j // separating plane. bool sat_plane(const vec3 tri_a[3], const vec3 tri_b[3], unsigned i, @@ -165,6 +170,10 @@ bool sat_plane(const vec3 tri_a[3], const vec3 tri_b[3], unsigned i, return false; } +inline bool sat_plane_size_t(const vec3 tri_a[3], const vec3 tri_b[3], size_t i, size_t j) { + return sat_plane(tri_a, tri_b, static_cast(i), static_cast(j)); +} + // returns: -1 - no intersection // 0 - touching // +1 - intersection @@ -174,10 +183,15 @@ int sat_edge(const vec2 tri_a[3], const vec2 tri_b[3], unsigned i) { dbl_sign(orient2d_exact(tri_a[i], tri_a[(i + 1) % 3], tri_b[2]))); } +inline int sat_edge_size_t(const vec2 tri_a[3], const vec2 tri_b[3], size_t i) { + return sat_edge(tri_a, tri_b, static_cast(i)); +} + + // returns: -1 - no intersection // 0 - touching // +1 - intersection -bool sat_edge(const vec2 tri_a[3], const vec2 tri_b[3], unsigned i, +int sat_edge(const vec2 tri_a[3], const vec2 tri_b[3], unsigned i, unsigned j) { return std::max(dbl_sign(orient2d_exact(tri_a[i], tri_a[(i + 1) % 3], tri_b[(j + 1) % 3])), @@ -185,6 +199,10 @@ bool sat_edge(const vec2 tri_a[3], const vec2 tri_b[3], unsigned i, tri_b[(j + 2) % 3]))); } +inline int sat_edge_size_t(const vec2 tri_a[3], const vec2 tri_b[3], size_t i, size_t j) { + return sat_edge(tri_a, tri_b, static_cast(i), static_cast(j)); +} + // test for vertex sharing. between a triangle pair. // returns: // +3 all vertices are shared, same orientation @@ -445,16 +463,16 @@ TriangleInt triangle_intersection(const vec2 tri_a[3], const vec2 tri_b[3]) { } case 1: { // shared vertex (ia, ib) [but not shared edge] - if (sat_edge(tri_a, tri_b, (ia + 2) % 3, ib) < 0) { + if (sat_edge_size_t(tri_a, tri_b, (ia + 2) % 3, ib) < 0) { return TR_INT_VERT; } - if (sat_edge(tri_a, tri_b, ia, ib) < 0) { + if (sat_edge_size_t(tri_a, tri_b, ia, ib) < 0) { return TR_INT_VERT; } - if (sat_edge(tri_b, tri_a, (ib + 2) % 3, ia) < 0) { + if (sat_edge_size_t(tri_b, tri_a, (ib + 2) % 3, ia) < 0) { return TR_INT_VERT; } - if (sat_edge(tri_b, tri_a, ib, ia) < 0) { + if (sat_edge_size_t(tri_b, tri_a, ib, ia) < 0) { return TR_INT_VERT; } @@ -513,10 +531,10 @@ TriangleInt triangle_intersection(const vec3 tri_a[3], const vec3 tri_b[3]) { // no shared vertices. for (size_t i = 0; i < 3; ++i) { for (size_t j = 0; j < 3; ++j) { - if (sat_plane(tri_a, tri_b, i, j)) { + if (sat_plane_size_t(tri_a, tri_b, i, j)) { return TR_INT_NONE; } - if (sat_plane(tri_b, tri_a, i, j)) { + if (sat_plane_size_t(tri_b, tri_a, i, j)) { return TR_INT_NONE; } } @@ -529,28 +547,28 @@ TriangleInt triangle_intersection(const vec3 tri_a[3], const vec3 tri_b[3]) { size_t ia0 = ia, ia1 = (ia + 1) % 3, ia2 = (ia + 2) % 3; size_t ib0 = ib, ib1 = (ib + 1) % 3, ib2 = (ib + 2) % 3; - if (sat_plane(tri_a, tri_b, ia2, ib1, ib2)) { + if (sat_plane_size_t(tri_a, tri_b, ia2, ib1, ib2)) { return TR_INT_VERT; } - if (sat_plane(tri_a, tri_b, ia2, ib2, ib1)) { + if (sat_plane_size_t(tri_a, tri_b, ia2, ib2, ib1)) { return TR_INT_VERT; } - if (sat_plane(tri_a, tri_b, ia0, ib1, ib2)) { + if (sat_plane_size_t(tri_a, tri_b, ia0, ib1, ib2)) { return TR_INT_VERT; } - if (sat_plane(tri_a, tri_b, ia0, ib2, ib1)) { + if (sat_plane_size_t(tri_a, tri_b, ia0, ib2, ib1)) { return TR_INT_VERT; } - if (sat_plane(tri_b, tri_b, ib2, ia1, ia2)) { + if (sat_plane_size_t(tri_b, tri_b, ib2, ia1, ia2)) { return TR_INT_VERT; } - if (sat_plane(tri_b, tri_b, ib2, ia2, ia1)) { + if (sat_plane_size_t(tri_b, tri_b, ib2, ia2, ia1)) { return TR_INT_VERT; } - if (sat_plane(tri_b, tri_b, ib0, ia1, ia2)) { + if (sat_plane_size_t(tri_b, tri_b, ib0, ia1, ia2)) { return TR_INT_VERT; } - if (sat_plane(tri_b, tri_b, ib0, ia2, ia1)) { + if (sat_plane_size_t(tri_b, tri_b, ib0, ia2, ia1)) { return TR_INT_VERT; } @@ -573,12 +591,12 @@ bool triangle_intersection_simple(const vec2 tri_a[3], const vec2 tri_b[3]) { CARVE_ASSERT(orient2d_exact(tri_b[0], tri_b[1], tri_b[2]) >= 0.0); for (size_t i = 0; i < 3; ++i) { - if (sat_edge(tri_a, tri_b, i) < 0) { + if (sat_edge_size_t(tri_a, tri_b, i) < 0) { return false; } } for (size_t i = 0; i < 3; ++i) { - if (sat_edge(tri_b, tri_a, i) < 0) { + if (sat_edge_size_t(tri_b, tri_a, i) < 0) { return false; } } @@ -605,10 +623,10 @@ bool triangle_intersection_simple(const vec3 tri_a[3], const vec3 tri_b[3]) { for (size_t i = 0; i < 3; ++i) { for (size_t j = 0; j < 3; ++j) { - if (sat_plane(tri_a, tri_b, i, j)) { + if (sat_plane_size_t(tri_a, tri_b, i, j)) { return false; } - if (sat_plane(tri_b, tri_a, i, j)) { + if (sat_plane_size_t(tri_b, tri_a, i, j)) { return false; } } @@ -675,10 +693,10 @@ TriangleIntType triangle_intersection_exact(const vec2 tri_a[3], int curr = +1; for (size_t i = 0; curr != -1 && i < 3; ++i) { - curr = std::min(curr, sat_edge(tri_a, tri_b, i)); + curr = std::min(curr, sat_edge_size_t(tri_a, tri_b, i)); } for (size_t i = 0; curr != -1 && i < 3; ++i) { - curr = std::min(curr, sat_edge(tri_b, tri_a, i)); + curr = std::min(curr, sat_edge_size_t(tri_b, tri_a, i)); } switch (curr) { case -1: diff --git a/lib/triangulator.cpp b/lib/triangulator.cpp index 44c827e..6b68545 100644 --- a/lib/triangulator.cpp +++ b/lib/triangulator.cpp @@ -556,8 +556,9 @@ size_t carve::triangulate::detail::removeDegeneracies( } if (remove) { - result.push_back(carve::triangulate::tri_idx(v->idx, v->next->idx, - v->next->next->idx)); + result.push_back(carve::triangulate::tri_idx(static_cast(v->idx), + static_cast(v->next->idx), + static_cast(v->next->next->idx))); n = v->next; if (n == begin) { begin = n->next; @@ -659,7 +660,9 @@ bool carve::triangulate::detail::doTriangulate( vertex_info* p = v->prev; result.push_back( - carve::triangulate::tri_idx(v->prev->idx, v->idx, v->next->idx)); + carve::triangulate::tri_idx(static_cast(v->prev->idx), + static_cast(v->idx), + static_cast(v->next->idx))); #if defined(CARVE_DEBUG) { @@ -734,8 +737,9 @@ bool carve::triangulate::detail::doTriangulate( } if (remain == 3) { - result.push_back(carve::triangulate::tri_idx(begin->idx, begin->next->idx, - begin->next->next->idx)); + result.push_back(carve::triangulate::tri_idx(static_cast(begin->idx), + static_cast(begin->next->idx), + static_cast(begin->next->next->idx))); } vertex_info* d = begin; diff --git a/src/close_manifold.cpp b/src/close_manifold.cpp index 321b90b..939bb95 100644 --- a/src/close_manifold.cpp +++ b/src/close_manifold.cpp @@ -129,7 +129,7 @@ static bool endswith(const std::string& a, const std::string& b) { return false; } - for (unsigned i = a.size(), j = b.size(); j;) { + for (size_t i = a.size(), j = b.size(); j;) { if (tolower(a[--i]) != tolower(b[--j])) { return false; } diff --git a/src/convert.cpp b/src/convert.cpp index e6efe10..2140103 100644 --- a/src/convert.cpp +++ b/src/convert.cpp @@ -120,7 +120,7 @@ static bool endswith(const std::string& a, const std::string& b) { return false; } - for (unsigned i = a.size(), j = b.size(); j;) { + for (size_t i = a.size(), j = b.size(); j;) { if (tolower(a[--i]) != tolower(b[--j])) { return false; } diff --git a/src/cut.cpp b/src/cut.cpp index 4241ed7..b017e64 100644 --- a/src/cut.cpp +++ b/src/cut.cpp @@ -106,7 +106,7 @@ static bool endswith(const std::string& a, const std::string& b) { return false; } - for (unsigned i = a.size(), j = b.size(); j;) { + for (size_t i = a.size(), j = b.size(); j;) { if (tolower(a[--i]) != tolower(b[--j])) { return false; } diff --git a/src/extrude.cpp b/src/extrude.cpp index 4dc93e0..eacb77c 100644 --- a/src/extrude.cpp +++ b/src/extrude.cpp @@ -397,7 +397,7 @@ carve::poly::Polyhedron* extrude( for (size_t p = 0; p < paths.size(); ++p) { const std::vector& path = paths[p]; - const unsigned N = path.size(); + const size_t N = path.size(); std::cerr << "N=" << N << std::endl; std::vector fwd, rev; @@ -415,18 +415,18 @@ carve::poly::Polyhedron* extrude( j = vert_idx.find(v); if (j == vert_idx.end()) { data.addVertex(v); - fwd.push_back(vert_idx[v] = data.getVertexCount() - 1); + fwd.push_back(static_cast(vert_idx[v] = data.getVertexCount() - 1)); } else { - fwd.push_back((*j).second); + fwd.push_back(static_cast((*j).second)); } v = carve::geom::VECTOR(path[i].x, -path[i].y, 0.0) + dir; j = vert_idx.find(v); if (j == vert_idx.end()) { data.addVertex(v); - rev.push_back(vert_idx[v] = data.getVertexCount() - 1); + rev.push_back(static_cast(vert_idx[v] = data.getVertexCount() - 1)); } else { - rev.push_back((*j).second); + rev.push_back(static_cast((*j).second)); } } diff --git a/src/face_merge.cpp b/src/face_merge.cpp index 23c6a81..f383858 100644 --- a/src/face_merge.cpp +++ b/src/face_merge.cpp @@ -47,7 +47,6 @@ #include #include -#include #include typedef carve::mesh::MeshSet<3> meshset_t; diff --git a/src/intersect.cpp b/src/intersect.cpp index 1b3ae2e..c404101 100644 --- a/src/intersect.cpp +++ b/src/intersect.cpp @@ -267,7 +267,7 @@ static bool endswith(const std::string& a, const std::string& b) { return false; } - for (unsigned i = a.size(), j = b.size(); j;) { + for (size_t i = a.size(), j = b.size(); j;) { if (tolower(a[--i]) != tolower(b[--j])) { return false; } diff --git a/src/selfintersect.cpp b/src/selfintersect.cpp index 9503c73..bf6174f 100644 --- a/src/selfintersect.cpp +++ b/src/selfintersect.cpp @@ -109,7 +109,7 @@ static bool endswith(const std::string& a, const std::string& b) { return false; } - for (unsigned i = a.size(), j = b.size(); j;) { + for (size_t i = a.size(), j = b.size(); j;) { if (tolower(a[--i]) != tolower(b[--j])) { return false; } @@ -259,8 +259,8 @@ int triangle_line_intersection_2d(const vec3 tri[3], const vec3& p1, pp1 = carve::geom::select(p1, a1, a2); pp2 = carve::geom::select(p2, a1, a2); - int ia = std::find(ptri, ptri + 3, pp1) - ptri; - int ib = std::find(ptri, ptri + 3, pp2) - ptri; + int ia = static_cast(std::find(ptri, ptri + 3, pp1) - ptri); + int ib = static_cast(std::find(ptri, ptri + 3, pp2) - ptri); if (ia == 3 && ib == 3) { // no shared vertices @@ -350,9 +350,9 @@ int triangle_triangle_intersection_2d(const vec3 tri_a[3], std::swap(ptri_b[0], ptri_b[2]); } - int ia = std::find(ptri_b, ptri_b + 3, ptri_a[0]) - ptri_b; - int ib = std::find(ptri_b, ptri_b + 3, ptri_a[1]) - ptri_b; - int ic = std::find(ptri_b, ptri_b + 3, ptri_a[2]) - ptri_b; + int ia = static_cast(std::find(ptri_b, ptri_b + 3, ptri_a[0]) - ptri_b); + int ib = static_cast(std::find(ptri_b, ptri_b + 3, ptri_a[1]) - ptri_b); + int ic = static_cast(std::find(ptri_b, ptri_b + 3, ptri_a[2]) - ptri_b); if (ia == 3 && ib == 3 && ic == 3) { // no shared vertices @@ -569,10 +569,10 @@ int orient3d_inexact(const vec3& a, const vec3& b, const vec3& c, double errbound = 0.0; // shewchuk::robust.o3derrboundA * permanent; if ((det > errbound) || (-det > errbound)) { - return det; + return static_cast(det); } - return 0.0; + return 0; } // returns true if no intersection, based upon normal testing. @@ -591,7 +591,9 @@ bool sat_normal(const vec3 tri_a[3], const vec3 tri_b[3]) { // returns true if no intersection, based upon edge^a_i and edge^b_j separating // axis. bool sat_edge(const vec3 tri_a[3], const vec3 tri_b[3], unsigned i, - unsigned j) {} + unsigned j) { + return false; +} // 0 = not intersecting // 1 = shared vertex diff --git a/src/triangulate.cpp b/src/triangulate.cpp index 3ca4b7a..6527748 100644 --- a/src/triangulate.cpp +++ b/src/triangulate.cpp @@ -122,7 +122,7 @@ static bool endswith(const std::string& a, const std::string& b) { return false; } - for (unsigned i = a.size(), j = b.size(); j;) { + for (size_t i = a.size(), j = b.size(); j;) { if (tolower(a[--i]) != tolower(b[--j])) { return false; } From 0367a0e3c98ec310e1c320764344c09576a503d5 Mon Sep 17 00:00:00 2001 From: Carsten Arnholm Date: Sat, 6 Apr 2019 21:26:15 +0200 Subject: [PATCH 02/12] Replace deprecated auto_ptr with unique_ptr --- lib/intersect.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/intersect.cpp b/lib/intersect.cpp index ea58eae..359cc5c 100644 --- a/lib/intersect.cpp +++ b/lib/intersect.cpp @@ -1385,12 +1385,12 @@ void carve::csg::CSG::calc(meshset_t* a, const face_rtree_t* a_rtree, #if defined(CARVE_DEBUG_WRITE_PLY_DATA) { - std::auto_ptr > poly( + std::unique_ptr > poly( faceLoopsToPolyhedron(a_face_loops)); writePLY("/tmp/a_split.ply", poly.get(), false); } { - std::auto_ptr > poly( + std::unique_ptr > poly( faceLoopsToPolyhedron(b_face_loops)); writePLY("/tmp/b_split.ply", poly.get(), false); } @@ -1499,9 +1499,9 @@ carve::mesh::MeshSet<3>* carve::csg::CSG::compute( size_t a_edge_count; size_t b_edge_count; - std::auto_ptr a_rtree( + std::unique_ptr a_rtree( face_rtree_t::construct_STR(a->faceBegin(), a->faceEnd(), 4, 4)); - std::auto_ptr b_rtree( + std::unique_ptr b_rtree( face_rtree_t::construct_STR(b->faceBegin(), b->faceEnd(), 4, 4)); { @@ -1660,9 +1660,9 @@ bool carve::csg::CSG::sliceAndClassify( size_t a_edge_count; size_t b_edge_count; - std::auto_ptr closed_rtree(face_rtree_t::construct_STR( + std::unique_ptr closed_rtree(face_rtree_t::construct_STR( closed->faceBegin(), closed->faceEnd(), 4, 4)); - std::auto_ptr open_rtree( + std::unique_ptr open_rtree( face_rtree_t::construct_STR(open->faceBegin(), open->faceEnd(), 4, 4)); calc(closed, closed_rtree.get(), open, open_rtree.get(), vclass, eclass, @@ -1724,9 +1724,9 @@ void carve::csg::CSG::slice(meshset_t* a, meshset_t* b, size_t a_edge_count; size_t b_edge_count; - std::auto_ptr a_rtree( + std::unique_ptr a_rtree( face_rtree_t::construct_STR(a->faceBegin(), a->faceEnd(), 4, 4)); - std::auto_ptr b_rtree( + std::unique_ptr b_rtree( face_rtree_t::construct_STR(b->faceBegin(), b->faceEnd(), 4, 4)); calc(a, a_rtree.get(), b, b_rtree.get(), vclass, eclass, a_face_loops, From ee5bc6e38006c5d4bb5dee5ca1f350a2e2503fc5 Mon Sep 17 00:00:00 2001 From: Carsten Arnholm Date: Sat, 6 Apr 2019 21:31:37 +0200 Subject: [PATCH 03/12] Fix additional sign warnings for non-core code --- common/write_ply.cpp | 26 +++++++++---------- external/GLOOP/include/gloop/model/stream.hpp | 4 +-- external/GLOOP/src/model/obj_format.cpp | 10 +++---- external/GLOOP/src/model/ply_format.cpp | 8 +++--- external/GLOOP/src/model/vtk_format.cpp | 6 ++--- tests/mersenne_twister.h | 16 +++++++++--- 6 files changed, 40 insertions(+), 30 deletions(-) diff --git a/common/write_ply.cpp b/common/write_ply.cpp index e7bdeb8..7576037 100644 --- a/common/write_ply.cpp +++ b/common/write_ply.cpp @@ -51,7 +51,7 @@ struct vertex : public vertex_base { int i; vertex(const container_t& _cnt) : cnt(_cnt), i(-1) {} void next() override { ++i; } - int length() override { return cnt.size(); } + int length() override { return static_cast(cnt.size()); } const carve::geom3d::Vector& curr() const override { return cnt[i].v; } }; @@ -74,7 +74,7 @@ struct mesh_face : public gloop::stream::null_writer { std::copy(poly->faceBegin(), poly->faceEnd(), std::back_inserter(faces)); } void next() override { ++i; } - int length() override { return faces.size(); } + int length() override { return static_cast(faces.size()); } const carve::mesh::MeshSet<3>::face_t* curr() const { return faces[i]; } }; @@ -91,7 +91,7 @@ struct mesh_face_idx : public gloop::stream::writer { f = r.curr(); i = f->begin(); } - int length() override { return f->nVertices(); } + int length() override { return static_cast(f->nVertices()); } bool isList() override { return true; } gloop::stream::Type dataType() override { return data_type; } @@ -108,7 +108,7 @@ struct face : public gloop::stream::null_writer { int i; face(const carve::poly::Polyhedron* _poly) : poly(_poly), i(-1) {} void next() override { ++i; } - int length() override { return poly->faces.size(); } + int length() override { return static_cast(poly->faces.size()); } const carve::poly::Face<3>* curr() const { return &poly->faces[i]; } }; @@ -129,7 +129,7 @@ struct face_idx : public gloop::stream::writer { f = r.curr(); i = 0; } - int length() override { return f->nVertices(); } + int length() override { return static_cast(f->nVertices()); } bool isList() override { return true; } gloop::stream::Type dataType() override { return data_type; } @@ -152,7 +152,7 @@ struct lineset : public gloop::stream::null_writer { c = n; ++n; } - int length() override { return polyline->lines.size(); } + int length() override { return static_cast(polyline->lines.size()); } const carve::line::Polyline* curr() const { return *c; } }; @@ -183,7 +183,7 @@ struct line_vi : public gloop::stream::writer { l = ls.curr(); i = 0; } - int length() override { return l->vertexCount(); } + int length() override { return static_cast(l->vertexCount()); } size_t value() override { return ls.polyline->vertexToIndex_fast(l->vertex(i++)); } @@ -208,8 +208,8 @@ void setup(gloop::stream::model_writer& file, file.addWriter("polyhedron.face", fi); file.addWriter("polyhedron.face.vertex_indices", new mesh_face_idx(*fi, gloop::stream::smallest_type( - poly->vertex_storage.size()), - face_max)); + static_cast(poly->vertex_storage.size())), + static_cast(face_max))); } void setup(gloop::stream::model_writer& file, @@ -230,8 +230,8 @@ void setup(gloop::stream::model_writer& file, file.addWriter("polyhedron.face", fi); file.addWriter( "polyhedron.face.vertex_indices", - new face_idx(*fi, gloop::stream::smallest_type(poly->vertices.size()), - face_max)); + new face_idx(*fi, gloop::stream::smallest_type(static_cast(poly->vertices.size())), + static_cast(face_max))); } void setup(gloop::stream::model_writer& file, @@ -256,8 +256,8 @@ void setup(gloop::stream::model_writer& file, file.addWriter("polyline.polyline.closed", new line_closed(*pi)); file.addWriter( "polyline.polyline.vertex_indices", - new line_vi(*pi, gloop::stream::smallest_type(lines->vertices.size()), - line_max)); + new line_vi(*pi, gloop::stream::smallest_type(static_cast(lines->vertices.size())), + static_cast(line_max))); } void setup(gloop::stream::model_writer& file, diff --git a/external/GLOOP/include/gloop/model/stream.hpp b/external/GLOOP/include/gloop/model/stream.hpp index 723dc60..2aa76d1 100644 --- a/external/GLOOP/include/gloop/model/stream.hpp +++ b/external/GLOOP/include/gloop/model/stream.hpp @@ -32,7 +32,7 @@ #include #include -#ifdef WIN32 +#if defined(WIN32) && defined(_MSC_VER) && _MSC_VER < 1800 typedef char int8_t; typedef short int16_t; @@ -153,7 +153,7 @@ namespace gloop { void send_sequence(reader_base *rd, size_t n, iter_t begin, iter_t end) { if (rd) { rd->begin(); - rd->length(n); + rd->length(static_cast(n)); while (begin != end) { rd->next(); rd->_val(*begin++); diff --git a/external/GLOOP/src/model/obj_format.cpp b/external/GLOOP/src/model/obj_format.cpp index cd76bc4..93964f0 100644 --- a/external/GLOOP/src/model/obj_format.cpp +++ b/external/GLOOP/src/model/obj_format.cpp @@ -33,7 +33,7 @@ #include #include #include - +#include namespace gloop { namespace obj { @@ -101,7 +101,7 @@ namespace gloop { for (size_t i = 0; i < std::min(rd_count, r1.size()); ++i) { if (v_rd[i] && r1[i].size()) { v_rd[i]->begin(); - v_rd[i]->length(blocks.size()); + v_rd[i]->length(static_cast(blocks.size())); } } @@ -317,19 +317,19 @@ namespace { uint32_t idx; v_prop->wt->next(); v_prop->wt->_val(idx); - idx += v_base; + idx += static_cast(v_base); s << idx; if (vt_prop || vn_prop) s << "/"; if (vt_prop) { vt_prop->wt->next(); vt_prop->wt->_val(idx); - idx += vt_base; + idx += static_cast(vt_base); s << idx; } if (vn_prop) { vn_prop->wt->next(); vn_prop->wt->_val(idx); - idx += vn_base; + idx += static_cast(vn_base); s << "/" << idx; } } diff --git a/external/GLOOP/src/model/ply_format.cpp b/external/GLOOP/src/model/ply_format.cpp index 178ed31..b2161bf 100644 --- a/external/GLOOP/src/model/ply_format.cpp +++ b/external/GLOOP/src/model/ply_format.cpp @@ -34,7 +34,7 @@ #include #include -#ifdef WIN32 +#if defined(WIN32) && defined(_MSC_VER) && _MSC_VER < 1800 typedef char int8_t; typedef short int16_t; @@ -403,7 +403,7 @@ namespace { in.seekg(len * sz, std::ios_base::cur); } else { rd->begin(); - rd->length(len); + rd->length(static_cast(len)); for (size_t i = 0; i < len; ++i) { rd->next(); in.read(buf, sz); @@ -426,7 +426,7 @@ namespace { } if (rd != NULL) { rd->begin(); - rd->length(len); + rd->length(static_cast(len)); for (size_t i = 0; i < len; ++i) { rd->next(); if (!prop_read(in, type, rd)) { @@ -503,7 +503,7 @@ namespace { in >> s_count; if (!in.fail()) { name = s_name; - count = s_count; + count = static_cast(s_count); } } } diff --git a/external/GLOOP/src/model/vtk_format.cpp b/external/GLOOP/src/model/vtk_format.cpp index a5d3ce2..c903210 100644 --- a/external/GLOOP/src/model/vtk_format.cpp +++ b/external/GLOOP/src/model/vtk_format.cpp @@ -86,7 +86,7 @@ namespace gloop { stream::reader_base *z_rd = findReader(base, "vertex", "z"); if (e_rd) { e_rd->begin(); - e_rd->length(point_data.size()); + e_rd->length(static_cast(point_data.size())); } // std::cerr << "emitting " << point_data.size() << " points" << std::endl; for (size_t i = 0; i < point_data.size(); ++i) { @@ -184,7 +184,7 @@ namespace gloop { if (e_rd) { e_rd->begin(); - e_rd->length(num); + e_rd->length(static_cast(num)); } size_t x = 0; @@ -226,7 +226,7 @@ namespace gloop { if (e_rd) { e_rd->begin(); - e_rd->length(num); + e_rd->length(static_cast(num)); } size_t x = 0; diff --git a/tests/mersenne_twister.h b/tests/mersenne_twister.h index a6d63e5..b374da0 100644 --- a/tests/mersenne_twister.h +++ b/tests/mersenne_twister.h @@ -65,10 +65,20 @@ #include #include -#if !defined(_WIN32) -#include -#else +#if defined(WIN32) && defined(_MSC_VER) && _MSC_VER < 1800 + +typedef char int8_t; +typedef short int16_t; +typedef long int32_t; + +typedef unsigned char uint8_t; +typedef unsigned short uint16_t; typedef unsigned long uint32_t; + +#else + +#include + #endif class MTRand { From d844a9b9d5d2dcf34bf8b6b07a0cba84c9820f69 Mon Sep 17 00:00:00 2001 From: Carsten Arnholm Date: Sat, 6 Apr 2019 21:33:52 +0200 Subject: [PATCH 04/12] Revert to using /MD (Multithreaded DLL) for MSVC --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3f5604b..fd19019 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -33,10 +33,10 @@ if (MSVC) # In hermetic build environments, tests may not have access to MS runtime # DLLs, so this replaces /MD (CRT libraries in DLLs) with /MT (static CRT # libraries). - string(REPLACE "/MD" "-MT" ${flag_var} "${${flag_var}}") + # string(REPLACE "/MD" "-MT" ${flag_var} "${${flag_var}}") # We prefer more strict warning checking for building Google Test. # Replaces /W3 with /W4 in defaults. - string(REPLACE "/W3" "-W4" ${flag_var} "${${flag_var}}") + # string(REPLACE "/W3" "-W4" ${flag_var} "${${flag_var}}") endforeach() endif() From 605f1a9a95dadffe5df98f07df7009e87f6f1080 Mon Sep 17 00:00:00 2001 From: Carsten Arnholm Date: Sat, 6 Apr 2019 22:17:19 +0200 Subject: [PATCH 05/12] Added .gitignore and README.md --- .gitignore | 1 + README.md | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 .gitignore create mode 100644 README.md diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e013b8d --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +cmake_build diff --git a/README.md b/README.md new file mode 100644 index 0000000..d037805 --- /dev/null +++ b/README.md @@ -0,0 +1,16 @@ + +This fork of carve contains fixes to allow static compilation for +* Windows MSVC2013 Express compiler x64 +* Linux Ubuntu GNU g++ 7.3.0 with boost x64 + +## Basic build instructions + +* Use CMake Gui on both platforms, disable dev warning (Options menu) +* Enable only CARVE_USE_EXACT_PREDICATES +* Set "Where to build" ../carve/cmake_build +* Windows MSVC2013: Build using carve/cmake_build/carve.sln + * Static libs under cmake_build/lib/Release and cmake_build/lib/Debug +* Linux: Build with makefile under carve/cmake_build + * Static lib under cmake_build/lib + + From 56508f8fb33612f17a2bd14df893b33934dab639 Mon Sep 17 00:00:00 2001 From: Carsten Arnholm Date: Sat, 27 Jun 2020 09:35:28 +0200 Subject: [PATCH 06/12] Update README.md Add note that MSVC2019 works --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index d037805..f161dfa 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ -This fork of carve contains fixes to allow static compilation for -* Windows MSVC2013 Express compiler x64 -* Linux Ubuntu GNU g++ 7.3.0 with boost x64 +This fork of carve contains fixes to allow static library compilation for +* Windows MSVC2013 (express) & MSVC2019 (community) x64 compilers +* Linux Ubuntu GNU g++ x64 ## Basic build instructions From f8111a2c9d06d5a47424608b3f688726edd43d45 Mon Sep 17 00:00:00 2001 From: Reini Urban Date: Sat, 22 Aug 2020 16:03:34 +0200 Subject: [PATCH 07/12] prefer modern cmake GLVND OpenGL PREFERENCE --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index fd19019..39bf7aa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -66,6 +66,7 @@ if(OPENMP_FOUND) endif() if(CARVE_WITH_GUI) + set(OpenGL_GL_PREFERENCE GLVND) find_package(OpenGL) find_package(GLUT) find_package(GLEW) From 793f7a0210e678dc7a9f0cf6d586b79e6cf04443 Mon Sep 17 00:00:00 2001 From: Reini Urban Date: Sat, 22 Aug 2020 20:10:18 +0200 Subject: [PATCH 08/12] CMakeLists typo --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 39bf7aa..d196c10 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,7 +21,7 @@ option(CARVE_DEBUG "Compile in debug code" option(CARVE_DEBUG_WRITE_PLY_DATA "Write geometry output during debug" OFF) option(CARVE_USE_EXACT_PREDICATES "Use Shewchuk's exact predicates, where possible" OFF) option(CARVE_INTERSECT_GLU_TRIANGULATOR "Include support for GLU triangulator in intersect" OFF) -option(CARVE_GTEST_TESTS "Complie gtest, and dependent tests" ON) +option(CARVE_GTEST_TESTS "Compile gtest, and dependent tests" ON) if (MSVC) # For MSVC, CMake sets certain flags to defaults we want to override. From 05b85b8c9ca015e74d925479a515a6e3dac061b8 Mon Sep 17 00:00:00 2001 From: Carsten Arnholm Date: Wed, 9 Dec 2020 17:14:43 +0100 Subject: [PATCH 09/12] command line build --- README.md | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index d037805..928bc74 100644 --- a/README.md +++ b/README.md @@ -7,10 +7,15 @@ This fork of carve contains fixes to allow static compilation for * Use CMake Gui on both platforms, disable dev warning (Options menu) * Enable only CARVE_USE_EXACT_PREDICATES -* Set "Where to build" ../carve/cmake_build -* Windows MSVC2013: Build using carve/cmake_build/carve.sln - * Static libs under cmake_build/lib/Release and cmake_build/lib/Debug -* Linux: Build with makefile under carve/cmake_build - * Static lib under cmake_build/lib +* Set "Where to build" ../carve/build +* Windows MSVC2013: Build using carve/build/carve.sln + * Static libs under build/lib/Release and build/lib/Debug +* Linux: Build with makefile under carve/build + * Static lib under build/lib +## Linux command line build with cmake +$ cd carve +$ cmake -B build -DBUILD_TESTING:BOOL="0" -DCARVE_USE_EXACT_PREDICATES:BOOL="1" -DCARVE_GTEST_TESTS:BOOL="0" -DCARVE_WITH_GUI:BOOL="0" -DBUILD_SHARED_LIBS:BOOL="0" +$ cd build +$ make \ No newline at end of file From ea9f4b170b8e79ff3b4596ef4e73d761abc708dc Mon Sep 17 00:00:00 2001 From: Carsten Arnholm Date: Wed, 9 Dec 2020 17:18:22 +0100 Subject: [PATCH 10/12] Update README.md --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 74505d0..6322f3f 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,9 @@ This fork of carve contains fixes to allow static library compilation for ## Linux command line build with cmake $ cd carve + $ cmake -B build -DBUILD_TESTING:BOOL="0" -DCARVE_USE_EXACT_PREDICATES:BOOL="1" -DCARVE_GTEST_TESTS:BOOL="0" -DCARVE_WITH_GUI:BOOL="0" -DBUILD_SHARED_LIBS:BOOL="0" + $ cd build -$ make \ No newline at end of file + +$ make From 312cf524420fc7e7af22e99505b106abda12e9d0 Mon Sep 17 00:00:00 2001 From: Carsten Arnholm Date: Wed, 9 Dec 2020 21:06:29 +0100 Subject: [PATCH 11/12] Windows msvc build script --- .gitignore | 2 +- build_windows_msvc.cmd | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 build_windows_msvc.cmd diff --git a/.gitignore b/.gitignore index e013b8d..378eac2 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1 @@ -cmake_build +build diff --git a/build_windows_msvc.cmd b/build_windows_msvc.cmd new file mode 100644 index 0000000..d1000a0 --- /dev/null +++ b/build_windows_msvc.cmd @@ -0,0 +1,32 @@ +@echo off +echo building the carve library for MSVC... +REM by Carsten Arnholm, December 2020 +REM +REM Requirements +REM 1) Must be executed from "MSVC Developer Command Prompt" +REM 2) cmake must be installed and defined in system PATH +REM +REM Output is found in "build" folder +REM only carve static library is built +REM +REM Using the library +REM include paths: +REM carve/include +REM +REM lib path: +REM carve/build/lib/Release (for release builds) +REM carve/build/lib/Debug (for debug builds) +REM +cmake -B build ^ + -DBUILD_TESTING:BOOL="0" ^ + -DCARVE_USE_EXACT_PREDICATES:BOOL="1" ^ + -DBUILD_SHARED_LIBS:BOOL="0" ^ + -DCARVE_GTEST_TESTS:BOOL="0" ^ + -DCARVE_WITH_GUI:BOOL="0" ^ + -DBUILD_SHARED_LIBS:BOOL="0" +REM +cd build +msbuild carve.sln -target:carve /p:Platform="x64" /p:Configuration=Release /m +msbuild carve.sln -target:carve /p:Platform="x64" /p:Configuration=Debug /m +dir .\lib\Debug,.\lib\release +echo Carve build script ended \ No newline at end of file From ca82d4c52311b3b56bacb7523c1b2ff314a9ccca Mon Sep 17 00:00:00 2001 From: Carsten Arnholm Date: Wed, 9 Dec 2020 21:23:47 +0100 Subject: [PATCH 12/12] Linux build script --- build_linux.sh | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100755 build_linux.sh diff --git a/build_linux.sh b/build_linux.sh new file mode 100755 index 0000000..6940a73 --- /dev/null +++ b/build_linux.sh @@ -0,0 +1,30 @@ +#!/bin/bash +echo building the carve library for Linux... +# by Carsten Arnholm, December 2020 +# +# Requirements +# 1) cmake must be installed and defined in system PATH +# +# Output is found in "build" folder +# only carve static library is built +# +# Using the library: +# include paths: +# carve/include +# carve/build/include +# +# lib path: +# carve/build/lib +# +cmake -B build \ + -DBUILD_TESTING:BOOL="0" \ + -DCARVE_USE_EXACT_PREDICATES:BOOL="1" \ + -DBUILD_SHARED_LIBS:BOOL="0" \ + -DCARVE_GTEST_TESTS:BOOL="0" \ + -DCARVE_WITH_GUI:BOOL="0" \ + -DBUILD_SHARED_LIBS:BOOL="0" +# +cd build +make carve +ls -l ./lib/*.a +echo Carve build script ended \ No newline at end of file