From 18fd4bd9f48112fae9f7d29ee88d39cdf5d3a95f Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 25 Feb 2013 10:02:43 +0000 Subject: Update Carve to newest upstream version with some assorted fixes Perhaps some warnings could be silenced, but not in mood of writing local patches at this moment. They're all harmless anyway. --- extern/carve/bundle.sh | 2 +- extern/carve/files.txt | 174 ++++++++++++------------ extern/carve/include/carve/csg_triangulator.hpp | 2 +- extern/carve/include/carve/geom3d.hpp | 19 ++- extern/carve/include/carve/geom_impl.hpp | 2 +- extern/carve/include/carve/input.hpp | 81 +++++++++-- extern/carve/include/carve/mesh.hpp | 38 +++++- extern/carve/include/carve/mesh_impl.hpp | 59 ++++++-- extern/carve/lib/intersect.cpp | 4 +- extern/carve/lib/intersect_face_division.cpp | 3 +- extern/carve/lib/mesh.cpp | 36 +++-- extern/carve/lib/polyhedron.cpp | 2 +- extern/carve/patches/series | 1 - extern/carve/patches/strict_flags.patch | 22 --- 14 files changed, 284 insertions(+), 161 deletions(-) delete mode 100644 extern/carve/patches/strict_flags.patch (limited to 'extern') diff --git a/extern/carve/bundle.sh b/extern/carve/bundle.sh index 63d32a5993d..c80bf645077 100755 --- a/extern/carve/bundle.sh +++ b/extern/carve/bundle.sh @@ -91,7 +91,7 @@ if(WITH_BOOST) -DCARVE_SYSTEM_BOOST ) - list(APPEND INC + list(APPEND INC_SYS \${BOOST_INCLUDE_DIR} ) endif() diff --git a/extern/carve/files.txt b/extern/carve/files.txt index c3cb9275950..1084c7f5c41 100644 --- a/extern/carve/files.txt +++ b/extern/carve/files.txt @@ -1,107 +1,109 @@ -include/carve/polyhedron_decl.hpp -include/carve/geom2d.hpp -include/carve/exact.hpp -include/carve/triangulator_impl.hpp -include/carve/collection.hpp -include/carve/pointset.hpp -include/carve/djset.hpp -include/carve/kd_node.hpp -include/carve/polyline.hpp -include/carve/polyline_iter.hpp -include/carve/geom3d.hpp -include/carve/edge_decl.hpp -include/carve/face_decl.hpp +include/carve/vertex_impl.hpp include/carve/aabb_impl.hpp -include/carve/colour.hpp +include/carve/csg.hpp include/carve/pointset_iter.hpp -include/carve/polyline_decl.hpp -include/carve/rescale.hpp -include/carve/mesh_impl.hpp -include/carve/classification.hpp -include/carve/util.hpp -include/carve/triangulator.hpp -include/carve/polyhedron_base.hpp -include/carve/rtree.hpp -include/carve/math.hpp -include/carve/math_constants.hpp -include/carve/octree_decl.hpp -include/carve/input.hpp -include/carve/mesh_ops.hpp include/carve/debug_hooks.hpp -include/carve/mesh_simplify.hpp -include/carve/interpolator.hpp -include/carve/poly_decl.hpp -include/carve/csg.hpp include/carve/mesh.hpp -include/carve/carve.hpp -include/carve/gnu_cxx.h -include/carve/polyhedron_impl.hpp -include/carve/poly_impl.hpp -include/carve/aabb.hpp +include/carve/triangulator_impl.hpp +include/carve/edge_decl.hpp +include/carve/collection/unordered.hpp +include/carve/collection/unordered/tr1_impl.hpp +include/carve/collection/unordered/fallback_impl.hpp +include/carve/collection/unordered/std_impl.hpp +include/carve/collection/unordered/vcpp_impl.hpp +include/carve/collection/unordered/libstdcpp_impl.hpp +include/carve/collection/unordered/boost_impl.hpp include/carve/convex_hull.hpp -include/carve/vertex_decl.hpp +include/carve/geom.hpp +include/carve/collection_types.hpp +include/carve/cbrt.h +include/carve/util.hpp +include/carve/iobj.hpp +include/carve/polyline_decl.hpp +include/carve/polyline_impl.hpp include/carve/win32.h include/carve/edge_impl.hpp -include/carve/tag.hpp -include/carve/tree.hpp -include/carve/heap.hpp +include/carve/carve.hpp +include/carve/polyline.hpp +include/carve/config.h +include/carve/face_decl.hpp include/carve/matrix.hpp -include/carve/poly.hpp -include/carve/vector.hpp -include/carve/intersection.hpp -include/carve/faceloop.hpp +include/carve/classification.hpp include/carve/geom_impl.hpp -include/carve/octree_impl.hpp -include/carve/spacetree.hpp -include/carve/collection/unordered/std_impl.hpp -include/carve/collection/unordered/tr1_impl.hpp -include/carve/collection/unordered/libstdcpp_impl.hpp -include/carve/collection/unordered/boost_impl.hpp -include/carve/collection/unordered/vcpp_impl.hpp -include/carve/collection/unordered/fallback_impl.hpp -include/carve/collection/unordered.hpp +include/carve/faceloop.hpp +include/carve/mesh_ops.hpp +include/carve/tree.hpp +include/carve/geom2d.hpp include/carve/face_impl.hpp +include/carve/polyhedron_decl.hpp +include/carve/interpolator.hpp +include/carve/poly_decl.hpp +include/carve/mesh_impl.hpp +include/carve/gnu_cxx.h +include/carve/mesh_simplify.hpp +include/carve/triangulator.hpp include/carve/pointset_impl.hpp -include/carve/cbrt.h +include/carve/rtree.hpp +include/carve/math_constants.hpp +include/carve/vector.hpp +include/carve/octree_impl.hpp +include/carve/pointset.hpp +include/carve/math.hpp +include/carve/intersection.hpp +include/carve/colour.hpp +include/carve/kd_node.hpp +include/carve/input.hpp +include/carve/geom3d.hpp +include/carve/exact.hpp +include/carve/rescale.hpp +include/carve/polyhedron_base.hpp +include/carve/heap.hpp +include/carve/spacetree.hpp +include/carve/polyhedron_impl.hpp include/carve/vcpp_config.h -include/carve/geom.hpp -include/carve/vertex_impl.hpp -include/carve/polyline_impl.hpp -include/carve/pointset_decl.hpp -include/carve/timing.hpp +include/carve/aabb.hpp +include/carve/polyline_iter.hpp +include/carve/djset.hpp +include/carve/vertex_decl.hpp include/carve/csg_triangulator.hpp -include/carve/iobj.hpp -include/carve/collection_types.hpp -lib/carve.cpp -lib/mesh.cpp -lib/intersect_group.cpp -lib/intersect_classify_common.hpp -lib/intersect_classify_edge.cpp -lib/intersect_classify_group.cpp +include/carve/poly.hpp +include/carve/external/boost/random.hpp +include/carve/timing.hpp +include/carve/octree_decl.hpp +include/carve/pointset_decl.hpp +include/carve/tag.hpp +include/carve/collection.hpp +include/carve/poly_impl.hpp +lib/intersection.cpp +lib/intersect.cpp +lib/triangulator.cpp +lib/intersect_debug.hpp +lib/csg_collector.hpp lib/csg_data.hpp +lib/convex_hull.cpp +lib/intersect_classify_common.hpp +lib/intersect_common.hpp lib/polyhedron.cpp -lib/csg_collector.hpp -lib/geom3d.cpp lib/polyline.cpp -lib/csg_collector.cpp -lib/triangulator.cpp -lib/intersect_face_division.cpp -lib/intersect_half_classify_group.cpp -lib/edge.cpp -lib/math.cpp +lib/pointset.cpp lib/geom2d.cpp +lib/math.cpp +lib/intersect_half_classify_group.cpp +lib/intersect_face_division.cpp lib/tag.cpp -lib/intersection.cpp -lib/convex_hull.cpp -lib/intersect_common.hpp -lib/intersect_classify_common_impl.hpp -lib/csg.cpp -lib/intersect.cpp +lib/aabb.cpp +lib/intersect_classify_group.cpp lib/csg_detail.hpp -lib/face.cpp -lib/pointset.cpp +lib/mesh.cpp lib/timing.cpp -lib/octree.cpp -lib/aabb.cpp -lib/intersect_debug.hpp +lib/geom3d.cpp +lib/intersect_group.cpp +lib/carve.cpp +lib/intersect_classify_edge.cpp +lib/csg.cpp +lib/face.cpp +lib/csg_collector.cpp lib/intersect_debug.cpp +lib/edge.cpp +lib/intersect_classify_common_impl.hpp +lib/octree.cpp diff --git a/extern/carve/include/carve/csg_triangulator.hpp b/extern/carve/include/carve/csg_triangulator.hpp index 740585571bf..5a40439271e 100644 --- a/extern/carve/include/carve/csg_triangulator.hpp +++ b/extern/carve/include/carve/csg_triangulator.hpp @@ -174,7 +174,7 @@ namespace carve { double scoreQuad(edge_map_t::iterator i, edge_map_t &edge_map) { if (!(*i).second.first || !(*i).second.second) return -1; - return 0; + return -1; } carve::mesh::MeshSet<3>::face_t *mergeQuad(edge_map_t::iterator i, edge_map_t &edge_map) { diff --git a/extern/carve/include/carve/geom3d.hpp b/extern/carve/include/carve/geom3d.hpp index 90d0672b81e..faeb565b922 100644 --- a/extern/carve/include/carve/geom3d.hpp +++ b/extern/carve/include/carve/geom3d.hpp @@ -206,9 +206,22 @@ namespace carve { * * +1, if a is ordered after b around, rotating about direction. */ inline int compareAngles(const Vector &direction, const Vector &base, const Vector &a, const Vector &b) { - const double d1 = carve::geom3d::orient3d(carve::geom::VECTOR(0,0,0), direction, a, b); - const double d2 = carve::geom3d::orient3d(carve::geom::VECTOR(0,0,0), direction, base, a); - const double d3 = carve::geom3d::orient3d(carve::geom::VECTOR(0,0,0), direction, base, b); + // double d1 = carve::geom3d::orient3d(carve::geom::VECTOR(0,0,0), direction, a, b); + // double d2 = carve::geom3d::orient3d(carve::geom::VECTOR(0,0,0), direction, base, a); + // double d3 = carve::geom3d::orient3d(carve::geom::VECTOR(0,0,0), direction, base, b); + +#if defined(CARVE_USE_EXACT_PREDICATES) + // which is equivalent to the following (which eliminates a + // vector subtraction): + double d1 = carve::geom3d::orient3d(direction, b, a, carve::geom::VECTOR(0,0,0)); + double d2 = carve::geom3d::orient3d(direction, a, base, carve::geom::VECTOR(0,0,0)); + double d3 = carve::geom3d::orient3d(direction, b, base, carve::geom::VECTOR(0,0,0)); +#else + // dotcross = a . (b x c) + double d1 = carve::geom::dotcross(direction, b, a ); + double d2 = carve::geom::dotcross(direction, a, base); + double d3 = carve::geom::dotcross(direction, b, base); +#endif // CASE: a and b are coplanar wrt. direction. if (d1 == 0.0) { diff --git a/extern/carve/include/carve/geom_impl.hpp b/extern/carve/include/carve/geom_impl.hpp index 4463ba2bd88..044655b6c07 100644 --- a/extern/carve/include/carve/geom_impl.hpp +++ b/extern/carve/include/carve/geom_impl.hpp @@ -396,7 +396,7 @@ namespace carve { // Compute a . (b x c) return (a.x * b.y * c.z + a.y * b.z * c.x + a.z * b.x * c.y) - - (a.x * b.z * c.y + a.y * b.x * c.z + a.z * b.y * c.x); + (a.x * c.y * b.z + a.y * c.z * b.x + a.z * c.x * b.y); } diff --git a/extern/carve/include/carve/input.hpp b/extern/carve/include/carve/input.hpp index a8bc8137d6c..4223955c0fd 100644 --- a/extern/carve/include/carve/input.hpp +++ b/extern/carve/include/carve/input.hpp @@ -17,6 +17,9 @@ #pragma once +#include +#include + #include #include #include @@ -28,6 +31,50 @@ namespace carve { namespace input { + typedef std::map Options; + + static inline Options opts() { + return Options(); + } + + static inline Options opts(const char **kv) { + Options r; + for (size_t i = 0; kv[i] != NULL; i += 2) { + r[kv[i]] = kv[i+1]; + } + return r; + } + + static inline Options opts(const std::string &k1, const std::string &v1) { + Options r; + r[k1] = v1; + return r; + } + + static inline Options opts(const std::string &k1, const std::string &v1, + const std::string &k2, const std::string &v2) { + Options r; + r[k1] = v1; + r[k2] = v2; + return r; + } + + static inline Options opts(const std::string &k1, const std::string &v1, + const std::string &k2, const std::string &v2, + const std::string &k3, const std::string &v3) { + Options r; + r[k1] = v1; + r[k2] = v2; + r[k3] = v3; + return r; + } + + static inline bool _bool(const std::string &str, bool _default = false) { + if (str == "true") return true; + if (str == "false") return false; + return _default; + } + struct Data { Data() { } @@ -126,12 +173,18 @@ namespace carve { faceCount = 0; } - carve::poly::Polyhedron *create() const { + carve::poly::Polyhedron *create(const Options &options) const { return new carve::poly::Polyhedron(points, faceCount, faceIndices); } - carve::mesh::MeshSet<3> *createMesh() const { - return new carve::mesh::MeshSet<3>(points, faceCount, faceIndices); + carve::mesh::MeshSet<3> *createMesh(const Options &options) const { + Options::const_iterator i; + carve::mesh::MeshOptions opts; + i = options.find("avoid_cavities"); + if (i != options.end()) { + opts.avoid_cavities(_bool((*i).second)); + } + return new carve::mesh::MeshSet<3>(points, faceCount, faceIndices, opts); } }; @@ -159,7 +212,7 @@ namespace carve { polylines.back().second.push_back(idx); } - carve::line::PolylineSet *create() const { + carve::line::PolylineSet *create(const Options &options) const { carve::line::PolylineSet *p = new carve::line::PolylineSet(points); for (std::list::const_iterator i = polylines.begin(); @@ -181,7 +234,7 @@ namespace carve { virtual ~PointSetData() { } - carve::point::PointSet *create() const { + carve::point::PointSet *create(const Options &options) const { carve::point::PointSet *p = new carve::point::PointSet(points); return p; } @@ -214,37 +267,37 @@ namespace carve { } template - static inline T *create(Data *d) { + static inline T *create(Data *d, const Options &options = Options()) { return NULL; } }; template<> - inline carve::mesh::MeshSet<3> *Input::create(Data *d) { + inline carve::mesh::MeshSet<3> *Input::create(Data *d, const Options &options) { PolyhedronData *p = dynamic_cast(d); if (p == NULL) return NULL; - return p->createMesh(); + return p->createMesh(options); } template<> - inline carve::poly::Polyhedron *Input::create(Data *d) { + inline carve::poly::Polyhedron *Input::create(Data *d, const Options &options) { PolyhedronData *p = dynamic_cast(d); if (p == NULL) return NULL; - return p->create(); + return p->create(options); } template<> - inline carve::line::PolylineSet *Input::create(Data *d) { + inline carve::line::PolylineSet *Input::create(Data *d, const Options &options) { PolylineSetData *p = dynamic_cast(d); if (p == NULL) return NULL; - return p->create(); + return p->create(options); } template<> - inline carve::point::PointSet *Input::create(Data *d) { + inline carve::point::PointSet *Input::create(Data *d, const Options &options) { PointSetData *p = dynamic_cast(d); if (p == NULL) return NULL; - return p->create(); + return p->create(options); } } diff --git a/extern/carve/include/carve/mesh.hpp b/extern/carve/include/carve/mesh.hpp index d4170e55133..202337b64d3 100644 --- a/extern/carve/include/carve/mesh.hpp +++ b/extern/carve/include/carve/mesh.hpp @@ -464,8 +464,27 @@ namespace carve { + struct MeshOptions { + bool opt_avoid_cavities; + + MeshOptions() : + opt_avoid_cavities(false) { + } + + MeshOptions &avoid_cavities(bool val) { + opt_avoid_cavities = val; + return *this; + } + }; + + + namespace detail { class FaceStitcher { + FaceStitcher(); + FaceStitcher(const FaceStitcher &); + FaceStitcher &operator=(const FaceStitcher &); + typedef Vertex<3> vertex_t; typedef Edge<3> edge_t; typedef Face<3> face_t; @@ -475,6 +494,8 @@ namespace carve { typedef std::unordered_map edge_map_t; typedef std::unordered_map > edge_graph_t; + MeshOptions opts; + edge_map_t edges; edge_map_t complex_edges; @@ -570,6 +591,8 @@ namespace carve { void build(iter_t begin, iter_t end, std::vector *> &meshes); public: + FaceStitcher(const MeshOptions &_opts); + template void create(iter_t begin, iter_t end, std::vector *> &meshes); }; @@ -623,7 +646,7 @@ namespace carve { ~Mesh(); template - static void create(iter_t begin, iter_t end, std::vector *> &meshes); + static void create(iter_t begin, iter_t end, std::vector *> &meshes, const MeshOptions &opts); aabb_t getAABB() const { return aabb_t(faces.begin(), faces.end()); @@ -692,7 +715,7 @@ namespace carve { MeshSet &operator=(const MeshSet &); template - void _init_from_faces(iter_t begin, iter_t end); + void _init_from_faces(iter_t begin, iter_t end, const MeshOptions &opts); public: typedef Vertex vertex_t; @@ -781,13 +804,16 @@ namespace carve { MeshSet(const std::vector &points, size_t n_faces, - const std::vector &face_indices); + const std::vector &face_indices, + const MeshOptions &opts = MeshOptions()); // Construct a mesh set from a set of disconnected faces. Takes // posession of the face pointers. - MeshSet(std::vector &faces); + MeshSet(std::vector &faces, + const MeshOptions &opts = MeshOptions()); - MeshSet(std::list &faces); + MeshSet(std::list &faces, + const MeshOptions &opts = MeshOptions()); MeshSet(std::vector &_vertex_storage, std::vector &_meshes); @@ -817,6 +843,8 @@ namespace carve { void collectVertices(); void canonicalize(); + + void separateMeshes(); }; diff --git a/extern/carve/include/carve/mesh_impl.hpp b/extern/carve/include/carve/mesh_impl.hpp index d55df8c8130..56fb6788b62 100644 --- a/extern/carve/include/carve/mesh_impl.hpp +++ b/extern/carve/include/carve/mesh_impl.hpp @@ -676,7 +676,7 @@ namespace carve { template template - void Mesh::create(iter_t begin, iter_t end, std::vector *> &meshes) { + void Mesh::create(iter_t begin, iter_t end, std::vector *> &meshes, const MeshOptions &opts) { meshes.clear(); } @@ -684,15 +684,15 @@ namespace carve { template<> template - void Mesh<3>::create(iter_t begin, iter_t end, std::vector *> &meshes) { - detail::FaceStitcher().create(begin, end, meshes); + void Mesh<3>::create(iter_t begin, iter_t end, std::vector *> &meshes, const MeshOptions &opts) { + detail::FaceStitcher(opts).create(begin, end, meshes); } template template - void MeshSet::_init_from_faces(iter_t begin, iter_t end) { + void MeshSet::_init_from_faces(iter_t begin, iter_t end, const MeshOptions &opts) { typedef std::unordered_map map_t; map_t vmap; @@ -723,7 +723,7 @@ namespace carve { } while (e != f->edge); } - mesh_t::create(begin, end, meshes); + mesh_t::create(begin, end, meshes, opts); for (size_t i = 0; i < meshes.size(); ++i) { meshes[i]->meshset = this; @@ -735,7 +735,8 @@ namespace carve { template MeshSet::MeshSet(const std::vector::vertex_t::vector_t> &points, size_t n_faces, - const std::vector &face_indices) { + const std::vector &face_indices, + const MeshOptions &opts) { vertex_storage.reserve(points.size()); std::vector faces; faces.reserve(n_faces); @@ -755,7 +756,7 @@ namespace carve { faces.push_back(new face_t(v.begin(), v.end())); } CARVE_ASSERT(p == face_indices.size()); - mesh_t::create(faces.begin(), faces.end(), meshes); + mesh_t::create(faces.begin(), faces.end(), meshes, opts); for (size_t i = 0; i < meshes.size(); ++i) { meshes[i]->meshset = this; @@ -765,15 +766,15 @@ namespace carve { template - MeshSet::MeshSet(std::vector &faces) { - _init_from_faces(faces.begin(), faces.end()); + MeshSet::MeshSet(std::vector &faces, const MeshOptions &opts) { + _init_from_faces(faces.begin(), faces.end(), opts); } template - MeshSet::MeshSet(std::list &faces) { - _init_from_faces(faces.begin(), faces.end()); + MeshSet::MeshSet(std::list &faces, const MeshOptions &opts) { + _init_from_faces(faces.begin(), faces.end(), opts); } @@ -1010,5 +1011,41 @@ namespace carve { vertex_storage.swap(vout); } + + + template + void MeshSet::separateMeshes() { + size_t n; + typedef std::unordered_map, vertex_t *> vmap_t; + vmap_t vmap; + typename vmap_t::iterator vmap_iter; + + for (face_iter i = faceBegin(); i != faceEnd(); ++i) { + face_t *f = *i; + for (typename face_t::edge_iter_t j = f->begin(); j != f->end(); ++j) { + edge_t &e = *j; + vmap[std::make_pair(f->mesh, e.vert)] = e.vert; + } + } + + std::vector vout; + vout.reserve(vmap.size()); + + for (n = 0, vmap_iter = vmap.begin(); vmap_iter != vmap.end(); ++vmap_iter, ++n) { + vout.push_back(*(*vmap_iter).second); + (*vmap_iter).second = & vout.back(); + } + + for (face_iter i = faceBegin(); i != faceEnd(); ++i) { + face_t *f = *i; + for (typename face_t::edge_iter_t j = f->begin(); j != f->end(); ++j) { + edge_t &e = *j; + e.vert = vmap[std::make_pair(f->mesh, e.vert)]; + } + } + + vertex_storage.swap(vout); + } + } } diff --git a/extern/carve/lib/intersect.cpp b/extern/carve/lib/intersect.cpp index b92dbcfe24c..b468e4addc7 100644 --- a/extern/carve/lib/intersect.cpp +++ b/extern/carve/lib/intersect.cpp @@ -1320,8 +1320,8 @@ void carve::csg::CSG::calc(meshset_t *a, } #endif - checkFaceLoopIntegrity(a_face_loops); - checkFaceLoopIntegrity(b_face_loops); + // checkFaceLoopIntegrity(a_face_loops); + // checkFaceLoopIntegrity(b_face_loops); #if defined(CARVE_DEBUG) std::cerr << "classify" << std::endl; diff --git a/extern/carve/lib/intersect_face_division.cpp b/extern/carve/lib/intersect_face_division.cpp index c5d5d8c5152..3b771bc8f3e 100644 --- a/extern/carve/lib/intersect_face_division.cpp +++ b/extern/carve/lib/intersect_face_division.cpp @@ -1110,8 +1110,7 @@ namespace { } // copy up to the end of the path. - if (pos < e1_1) - std::copy(base_loop.begin() + pos, base_loop.begin() + e1_1, std::back_inserter(out)); + std::copy(base_loop.begin() + pos, base_loop.begin() + e1_1, std::back_inserter(out)); CARVE_ASSERT(base_loop[e1_1] == p1.back()); std::copy(p1.rbegin(), p1.rend() - 1, std::back_inserter(out)); diff --git a/extern/carve/lib/mesh.cpp b/extern/carve/lib/mesh.cpp index 55ab893c10a..ae91b385d44 100644 --- a/extern/carve/lib/mesh.cpp +++ b/extern/carve/lib/mesh.cpp @@ -243,15 +243,20 @@ namespace carve { bool FaceStitcher::EdgeOrderData::Cmp::operator()(const EdgeOrderData &a, const EdgeOrderData &b) const { int v = carve::geom3d::compareAngles(edge_dir, base_dir, a.face_dir, b.face_dir); - double da = carve::geom3d::antiClockwiseAngle(base_dir, a.face_dir, edge_dir); - double db = carve::geom3d::antiClockwiseAngle(base_dir, b.face_dir, edge_dir); - int v0 = v; - v = 0; - if (da < db) v = -1; - if (db < da) v = +1; - if (v0 != v) { - std::cerr << "v0= " << v0 << " v= " << v << " da= " << da << " db= " << db << " " << edge_dir << " " << base_dir << " " << a.face_dir << b.face_dir << std::endl; + +#if defined(CARVE_DEBUG) + { + double da = carve::geom3d::antiClockwiseAngle(base_dir, a.face_dir, edge_dir); + double db = carve::geom3d::antiClockwiseAngle(base_dir, b.face_dir, edge_dir); + int v_cmp = 0; + if (da < db) v_cmp = -1; + if (db < da) v_cmp = +1; + if (v_cmp != v) { + std::cerr << "v= " << v << " v_cmp= " << v_cmp << " da= " << da << " db= " << db << " edge_dir=" << edge_dir << " base_dir=" << base_dir << " a=" << a.face_dir << " b=" << b.face_dir << std::endl; + } } +#endif + if (v < 0) return true; if (v == 0) { if (a.is_reversed && !b.is_reversed) return true; @@ -327,9 +332,14 @@ namespace carve { CARVE_ASSERT(erev[0][i]->v2() == erev[j][i]->v2()); } - std::sort(result[i].begin(), - result[i].end(), - EdgeOrderData::Cmp(base->v2()->v - base->v1()->v, result[i][0].face_dir)); + geom::vector<3> sort_dir; + if (opts.opt_avoid_cavities) { + sort_dir = base->v1()->v - base->v2()->v; + } else { + sort_dir = base->v2()->v - base->v1()->v; + } + + std::sort(result[i].begin(), result[i].end(), EdgeOrderData::Cmp(sort_dir, result[i][0].face_dir)); } } @@ -751,11 +761,15 @@ namespace carve { } } } + + FaceStitcher::FaceStitcher(const MeshOptions &_opts) : opts(_opts) { + } } } + // construct a MeshSet from a Polyhedron, maintaining on the // connectivity information in the Polyhedron. mesh::MeshSet<3> *meshFromPolyhedron(const poly::Polyhedron *poly, int manifold_id) { diff --git a/extern/carve/lib/polyhedron.cpp b/extern/carve/lib/polyhedron.cpp index 93e667ffaf7..43d08b81bfd 100644 --- a/extern/carve/lib/polyhedron.cpp +++ b/extern/carve/lib/polyhedron.cpp @@ -233,7 +233,7 @@ namespace carve { } std::vector *> meshes; - mesh::Mesh<3>::create(mesh_faces.begin(), mesh_faces.end(), meshes); + mesh::Mesh<3>::create(mesh_faces.begin(), mesh_faces.end(), meshes, mesh::MeshOptions()); mesh::MeshSet<3> *meshset = new mesh::MeshSet<3>(vertex_storage, meshes); manifold_is_closed.resize(meshset->meshes.size()); diff --git a/extern/carve/patches/series b/extern/carve/patches/series index 585d90659bd..0b1f731805e 100644 --- a/extern/carve/patches/series +++ b/extern/carve/patches/series @@ -1,4 +1,3 @@ -strict_flags.patch includes.patch win32.patch mesh_iterator.patch diff --git a/extern/carve/patches/strict_flags.patch b/extern/carve/patches/strict_flags.patch deleted file mode 100644 index c1046b78c5f..00000000000 --- a/extern/carve/patches/strict_flags.patch +++ /dev/null @@ -1,22 +0,0 @@ -diff -r 47dfdaff1dd5 include/carve/csg_triangulator.hpp ---- a/include/carve/csg_triangulator.hpp Thu Jan 12 15:49:04 2012 -0500 -+++ b/include/carve/csg_triangulator.hpp Fri Jan 13 03:13:32 2012 +0600 -@@ -174,6 +174,7 @@ - - double scoreQuad(edge_map_t::iterator i, edge_map_t &edge_map) { - if (!(*i).second.first || !(*i).second.second) return -1; -+ return 0; - } - - carve::mesh::MeshSet<3>::face_t *mergeQuad(edge_map_t::iterator i, edge_map_t &edge_map) { -diff -r 47dfdaff1dd5 lib/selfintersect.cpp ---- a/lib/selfintersect.cpp Thu Jan 12 15:49:04 2012 -0500 -+++ b/lib/selfintersect.cpp Fri Jan 13 03:13:32 2012 +0600 -@@ -465,6 +465,7 @@ - - // 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) { -+ return false; - } - - -- cgit v1.2.3