diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2014-04-09 16:54:13 +0400 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2014-04-10 15:49:49 +0400 |
commit | f93bc7693a530632455d3ec7acc4bce54a1f85bc (patch) | |
tree | d0e067438cbc547875b3cb77e53904c5ea2a537d /extern/carve | |
parent | 19e627cab34a04a3d01b2e3a868b7bf91d56e8f9 (diff) |
Backport revisions for the 2.70a releasev2.70a
d2660a0, 6e99fb0, 58c22d8, 83f2012 + ff21f6a, a7ed1db. cc6b106
7997e38, 9d4b54b, efb48fc, 3fc293c, 29f359c, 77c1d17, 92a539e,
c626462, f48828b, 6452d9f, 765d077, 74518b2, af16d46, 8da4936,
6babbf5, f0106d2, f88776b, ee72cba, 467596d, e21a7b3, eed3974,
71a2ff1, ccf9afd, 44d6c68, 30fdfc3, b69809c, b0a8e4c, bd57ec6,
3b0832d, 2a25676, 3977b76, fb25a86, 9bbb30b, 51abc2b, 0ebade5,
2c0e32f, 3deaf7d, ea01b24, c61eb64, f3db038, a6fb670, eedde31,
b66a954, 7ff123c, f5b79df, 7148c97, 54a8753, fcaa018, 4c73001,
7a21330, 07578be, e9a64e2, fd3de8b, ae792e9, b7712a7 + 3600622,
d9557d0, 6d973b8, 688257d, 4acb57a, 95ac6bc,
Also backported openmp changes to sculpt making it so number
of real CPU cores is used as a number of threads here.
Diffstat (limited to 'extern/carve')
-rw-r--r-- | extern/carve/carve-capi.cc | 45 | ||||
-rw-r--r-- | extern/carve/carve-util.cc | 12 | ||||
-rw-r--r-- | extern/carve/carve-util.h | 39 | ||||
-rw-r--r-- | extern/carve/include/carve/config.h | 18 | ||||
-rw-r--r-- | extern/carve/include/carve/mesh_ops.hpp | 2 | ||||
-rw-r--r-- | extern/carve/lib/triangulator.cpp | 18 | ||||
-rw-r--r-- | extern/carve/patches/clang_is_heap_fix.patch | 42 | ||||
-rw-r--r-- | extern/carve/patches/files/config.h | 18 | ||||
-rw-r--r-- | extern/carve/patches/series | 2 |
9 files changed, 145 insertions, 51 deletions
diff --git a/extern/carve/carve-capi.cc b/extern/carve/carve-capi.cc index a65d1a8d766..af9ecad685d 100644 --- a/extern/carve/carve-capi.cc +++ b/extern/carve/carve-capi.cc @@ -38,7 +38,7 @@ typedef std::pair<int, int> OrigIndex; typedef std::pair<MeshSet<3>::vertex_t *, MeshSet<3>::vertex_t *> VertexPair; typedef carve::interpolate::VertexAttr<OrigIndex> OrigVertMapping; typedef carve::interpolate::FaceAttr<OrigIndex> OrigFaceMapping; -typedef carve::interpolate::FaceEdgeAttr<OrigIndex> OrigFaceEdgeMapping; +typedef carve::interpolate::SwapableFaceEdgeAttr<OrigIndex> OrigFaceEdgeMapping; typedef carve::interpolate::SimpleFaceEdgeAttr<bool> FaceEdgeTriangulatedFlag; typedef struct CarveMeshDescr { @@ -522,6 +522,39 @@ public: } }; +template <typename Interpolator> +void copyFaceEdgeAttrs(const MeshSet<3> *poly, + Interpolator *old_interpolator, + Interpolator *new_interpolator) +{ + for (MeshSet<3>::const_face_iter face_iter = poly->faceBegin(); + face_iter != poly->faceEnd(); + ++face_iter) + { + const MeshSet<3>::face_t *face = *face_iter; + + for (int edge_index = 0; + edge_index < face->nEdges(); + ++edge_index) + { + new_interpolator->copyAttribute(face, + edge_index, + old_interpolator); + } + } +} + +template <typename Interpolator> +void cleanupFaceEdgeAttrs(const MeshSet<3> *left, + const MeshSet<3> *right, + Interpolator *interpolator) +{ + Interpolator new_interpolator; + copyFaceEdgeAttrs(left, interpolator, &new_interpolator); + copyFaceEdgeAttrs(right, interpolator, &new_interpolator); + interpolator->swapAttributes(&new_interpolator); +} + } // namespace CarveMeshDescr *carve_addMesh(struct ImportMeshData *import_data, @@ -698,7 +731,15 @@ bool carve_performBooleanOperation(CarveMeshDescr *left_mesh, // intersecting that meshes tessellation of operation result can't be // done properly. The only way to make such situations working is to // union intersecting meshes of the same operand. - carve_unionIntersections(&csg, &left, &right); + if (carve_unionIntersections(&csg, &left, &right)) { + cleanupFaceEdgeAttrs(left, + right, + &output_descr->face_edge_triangulated_flag); + cleanupFaceEdgeAttrs(left, + right, + &output_descr->orig_face_edge_mapping); + } + left_mesh->poly = left; right_mesh->poly = right; diff --git a/extern/carve/carve-util.cc b/extern/carve/carve-util.cc index ac6dcbc1a94..b268dae9dd6 100644 --- a/extern/carve/carve-util.cc +++ b/extern/carve/carve-util.cc @@ -486,14 +486,15 @@ MeshSet<3> *unionIntersectingMeshes(carve::csg::CSG *csg, // TODO(sergey): This function is to be totally re-implemented to make it // more clear what's going on and hopefully optimize it as well. -void carve_unionIntersections(carve::csg::CSG *csg, +bool carve_unionIntersections(carve::csg::CSG *csg, MeshSet<3> **left_r, MeshSet<3> **right_r) { MeshSet<3> *left = *left_r, *right = *right_r; + bool changed = false; if (left->meshes.size() == 1 && right->meshes.size() == 0) { - return; + return false; } MeshSet<3>::aabb_t leftAABB = left->getAABB(); @@ -503,14 +504,19 @@ void carve_unionIntersections(carve::csg::CSG *csg, right = unionIntersectingMeshes(csg, right, leftAABB); if (left != *left_r) { + changed = true; delete *left_r; } - if (right != *right_r) + if (right != *right_r) { + changed = true; delete *right_r; + } *left_r = left; *right_r = right; + + return changed; } static inline void add_newell_cross_v3_v3v3(const Vector &v_prev, diff --git a/extern/carve/carve-util.h b/extern/carve/carve-util.h index a658b2fea96..f650810e9e3 100644 --- a/extern/carve/carve-util.h +++ b/extern/carve/carve-util.h @@ -70,7 +70,7 @@ void carve_getRescaleMinMax(const carve::mesh::MeshSet<3> *left, carve::geom3d::Vector *min, carve::geom3d::Vector *max); -void carve_unionIntersections(carve::csg::CSG *csg, +bool carve_unionIntersections(carve::csg::CSG *csg, carve::mesh::MeshSet<3> **left_r, carve::mesh::MeshSet<3> **right_r); @@ -115,8 +115,8 @@ namespace carve { attrs.find(new_edge_iter->vert); if (found == attrs.end()) { for (const_edge_iter_t orig_edge_iter = orig_face->begin(); - orig_edge_iter != orig_face->end(); - ++orig_edge_iter) + orig_edge_iter != orig_face->end(); + ++orig_edge_iter) { if ((orig_edge_iter->vert->v - new_edge_iter->vert->v).length2() < 1e-5) { attrs[new_edge_iter->vert] = attrs[orig_edge_iter->vert]; @@ -236,6 +236,20 @@ namespace carve { attrs[std::make_pair(f, e)] = attr; } + void copyAttribute(const meshset_t::face_t *face, + unsigned edge, + SimpleFaceEdgeAttr<attr_t> *interpolator) { + key_t key(face, edge); + typename attrmap_t::const_iterator fv = interpolator->attrs.find(key); + if (fv != interpolator->attrs.end()) { + attrs[key] = (*fv).second; + } + } + + void swapAttributes(SimpleFaceEdgeAttr<attr_t> *interpolator) { + attrs.swap(interpolator->attrs); + } + SimpleFaceEdgeAttr() : Interpolator() { } @@ -243,6 +257,25 @@ namespace carve { } }; + template<typename attr_t> + class SwapableFaceEdgeAttr : public FaceEdgeAttr<attr_t> { + public: + typedef carve::mesh::MeshSet<3> meshset_t; + + void copyAttribute(const meshset_t::face_t *face, + unsigned edge, + SwapableFaceEdgeAttr<attr_t> *interpolator) { + typename FaceEdgeAttr<attr_t>::key_t key(face, edge); + typename FaceEdgeAttr<attr_t>::attrmap_t::const_iterator fv = interpolator->attrs.find(key); + if (fv != interpolator->attrs.end()) { + this->attrs[key] = (*fv).second; + } + } + + void swapAttributes(SwapableFaceEdgeAttr<attr_t> *interpolator) { + this->attrs.swap(interpolator->attrs); + } + }; } // namespace interpolate } // namespace carve diff --git a/extern/carve/include/carve/config.h b/extern/carve/include/carve/config.h index fdae2d2843f..3533c1a6710 100644 --- a/extern/carve/include/carve/config.h +++ b/extern/carve/include/carve/config.h @@ -10,3 +10,21 @@ # define HAVE_STDINT_H #endif + +// Support for latest Clang/LLVM on FreeBSD which does have different libcxx. +// +// TODO(sergey): Move it some some more generic header with platform-specific +// declarations. + +// Indicates whether __is_heap is available +#undef HAVE_IS_HEAP + +#ifdef __GNUC__ +// NeyBSD doesn't have __is_heap +# ifndef __NetBSD__ +# define HAVE_IS_HEAP +# ifdef _LIBCPP_VERSION +# define __is_heap is_heap +# endif // _LIBCPP_VERSION +# endif // !__NetBSD__ +#endif // __GNUC__ diff --git a/extern/carve/include/carve/mesh_ops.hpp b/extern/carve/include/carve/mesh_ops.hpp index 02b1bde4e45..3b71feb0e6c 100644 --- a/extern/carve/include/carve/mesh_ops.hpp +++ b/extern/carve/include/carve/mesh_ops.hpp @@ -580,7 +580,7 @@ namespace carve { std::vector<VertexInfo *> queue; void checkheap() { -#ifdef __GNUC__ +#if defined(HAVE_IS_HEAP) CARVE_ASSERT(std::__is_heap(queue.begin(), queue.end(), order_by_score())); #endif } diff --git a/extern/carve/lib/triangulator.cpp b/extern/carve/lib/triangulator.cpp index 820fed07db7..eb36e86af5d 100644 --- a/extern/carve/lib/triangulator.cpp +++ b/extern/carve/lib/triangulator.cpp @@ -27,24 +27,6 @@ #include <algorithm> -// Support for latest Clang/LLVM on FreeBSD which does have different libcxx. -// -// TODO(sergey): Move it some some more generic header with platform-specific -// declarations. - -// Indicates whether __is_heap is available -#undef HAVE_IS_HEAP - -#ifdef __GNUC__ -// NeyBSD doesn't have __is_heap -# ifndef __NetBSD__ -# define HAVE_IS_HEAP -# ifdef _LIBCPP_VERSION -# define __is_heap is_heap -# endif // _LIBCPP_VERSION -# endif // !__NetBSD__ -#endif // __GNUC__ - namespace { // private code related to hole patching. diff --git a/extern/carve/patches/clang_is_heap_fix.patch b/extern/carve/patches/clang_is_heap_fix.patch index a00710b9540..524a8e0420c 100644 --- a/extern/carve/patches/clang_is_heap_fix.patch +++ b/extern/carve/patches/clang_is_heap_fix.patch @@ -1,31 +1,27 @@ -diff -r 2e6e59022e6e lib/triangulator.cpp ---- a/lib/triangulator.cpp Fri Nov 09 09:35:35 2012 +1100 -+++ b/lib/triangulator.cpp Thu Jan 09 16:13:17 2014 +0600 -@@ -27,6 +27,23 @@ +diff -r e82d852e4fb0 include/carve/mesh_ops.hpp +--- a/include/carve/mesh_ops.hpp Wed Jan 15 13:16:14 2014 +1100 ++++ b/include/carve/mesh_ops.hpp Fri Mar 28 14:34:04 2014 +0600 +@@ -580,7 +580,7 @@ + std::vector<VertexInfo *> queue; - #include <algorithm> + void checkheap() { +-#ifdef __GNUC__ ++#if defined(HAVE_IS_HEAP) + CARVE_ASSERT(std::__is_heap(queue.begin(), queue.end(), order_by_score())); + #endif + } +diff -r e82d852e4fb0 lib/triangulator.cpp +--- a/lib/triangulator.cpp Wed Jan 15 13:16:14 2014 +1100 ++++ b/lib/triangulator.cpp Fri Mar 28 14:34:04 2014 +0600 +@@ -27,7 +27,6 @@ -+// Support for latest Clang/LLVM on FreeBSD which does have different libcxx. -+// -+// TODO(sergey): Move it some some more generic header with platform-specific -+// declarations. -+ -+// Indicates whether __is_heap is available -+#undef HAVE_IS_HEAP -+ -+#ifdef __GNUC__ -+// NeyBSD doesn't have __is_heap -+# ifndef __NetBSD__ -+# define HAVE_IS_HEAP -+# ifdef _LIBCPP_VERSION -+# define __is_heap is_heap -+# endif // _LIBCPP_VERSION -+# endif // !__NetBSD__ -+#endif // __GNUC__ + #include <algorithm> +- namespace { // private code related to hole patching. -@@ -122,7 +139,7 @@ + +@@ -122,7 +121,7 @@ std::vector<vertex_info *> queue; void checkheap() { diff --git a/extern/carve/patches/files/config.h b/extern/carve/patches/files/config.h index fdae2d2843f..3533c1a6710 100644 --- a/extern/carve/patches/files/config.h +++ b/extern/carve/patches/files/config.h @@ -10,3 +10,21 @@ # define HAVE_STDINT_H #endif + +// Support for latest Clang/LLVM on FreeBSD which does have different libcxx. +// +// TODO(sergey): Move it some some more generic header with platform-specific +// declarations. + +// Indicates whether __is_heap is available +#undef HAVE_IS_HEAP + +#ifdef __GNUC__ +// NeyBSD doesn't have __is_heap +# ifndef __NetBSD__ +# define HAVE_IS_HEAP +# ifdef _LIBCPP_VERSION +# define __is_heap is_heap +# endif // _LIBCPP_VERSION +# endif // !__NetBSD__ +#endif // __GNUC__ diff --git a/extern/carve/patches/series b/extern/carve/patches/series index 286d594bbef..529bf43a858 100644 --- a/extern/carve/patches/series +++ b/extern/carve/patches/series @@ -8,5 +8,5 @@ strict_flags.patch interpolator_reorder.patch mesh_simplify_dissolve_edges.patch memory_leak_fix.patch -mavc_fix.patch +msvc_fix.patch face_hole_merge_workaround.patch |