Update Carve to newest upstream version with some assorted fixes
authorSergey Sharybin <sergey.vfx@gmail.com>
Mon, 25 Feb 2013 10:02:43 +0000 (10:02 +0000)
committerSergey Sharybin <sergey.vfx@gmail.com>
Mon, 25 Feb 2013 10:02:43 +0000 (10:02 +0000)
Perhaps some warnings could be silenced, but not in mood of writing
local patches at this moment. They're all harmless anyway.

14 files changed:
extern/carve/bundle.sh
extern/carve/files.txt
extern/carve/include/carve/csg_triangulator.hpp
extern/carve/include/carve/geom3d.hpp
extern/carve/include/carve/geom_impl.hpp
extern/carve/include/carve/input.hpp
extern/carve/include/carve/mesh.hpp
extern/carve/include/carve/mesh_impl.hpp
extern/carve/lib/intersect.cpp
extern/carve/lib/intersect_face_division.cpp
extern/carve/lib/mesh.cpp
extern/carve/lib/polyhedron.cpp
extern/carve/patches/series
extern/carve/patches/strict_flags.patch [deleted file]

index 63d32a5993da9b21fb6ccd7527d635d4983f7008..c80bf645077b5174bd7fb1bd2d2e0421e079751d 100755 (executable)
@@ -91,7 +91,7 @@ if(WITH_BOOST)
                -DCARVE_SYSTEM_BOOST
        )
 
-       list(APPEND INC
+       list(APPEND INC_SYS
                \${BOOST_INCLUDE_DIR}
        )
 endif()
index c3cb9275950c564f6b96417f764ae6500d9c3074..1084c7f5c4138d9af27cfc44fa86f371561261fb 100644 (file)
-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
index 740585571bf7cb33f1794312bb2175d8b7fe28f8..5a40439271eb6492f9b9001ad400ef6b476de2b1 100644 (file)
@@ -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) {
index 90d0672b81e5f40d879976696063c44562e59f4b..faeb565b92233ac4d8dcc240c6e037aaa6c3a0e0 100644 (file)
@@ -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) {
index 4463ba2bd88b86c1d0d16fda8ab5e7982ec55b72..044655b6c07a9177095606f26cbcc0621d29eab0 100644 (file)
@@ -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);
     }
 
 
index a8bc8137d6c091ff19266ae8c714a80034d37059..4223955c0fddea95faf6249a4fdad1c2ae05b0a1 100644 (file)
@@ -17,6 +17,9 @@
 
 #pragma once
 
+#include <map>
+#include <string>
+
 #include <carve/carve.hpp>
 #include <carve/poly.hpp>
 #include <carve/mesh.hpp>
 namespace carve {
   namespace input {
 
+    typedef std::map<std::string, std::string> 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<polyline_data_t>::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<typename T>
-      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<PolyhedronData *>(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<PolyhedronData *>(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<PolylineSetData *>(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<PointSetData *>(d);
       if (p == NULL) return NULL;
-      return p->create();
+      return p->create(options);
     }
 
   }
index d4170e551330a6ec3d23ebe44077fc5d64339347..202337b64d3bcadbc333d20c6493ffd0bfd26fde 100644 (file)
@@ -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<vpair_t, edgelist_t, carve::mesh::hash_vertex_pair> edge_map_t;
         typedef std::unordered_map<const vertex_t *, std::set<const vertex_t *> > 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<Mesh<3> *> &meshes);
 
       public:
+        FaceStitcher(const MeshOptions &_opts);
+
         template<typename iter_t>
         void create(iter_t begin, iter_t end, std::vector<Mesh<3> *> &meshes);
       };
@@ -623,7 +646,7 @@ namespace carve {
       ~Mesh();
 
       template<typename iter_t>
-      static void create(iter_t begin, iter_t end, std::vector<Mesh<ndim> *> &meshes);
+      static void create(iter_t begin, iter_t end, std::vector<Mesh<ndim> *> &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<typename iter_t>
-      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<ndim> vertex_t;
@@ -781,13 +804,16 @@ namespace carve {
 
       MeshSet(const std::vector<typename vertex_t::vector_t> &points,
               size_t n_faces,
-              const std::vector<int> &face_indices);
+              const std::vector<int> &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<face_t *> &faces);
+      MeshSet(std::vector<face_t *> &faces,
+              const MeshOptions &opts = MeshOptions());
 
-      MeshSet(std::list<face_t *> &faces);
+      MeshSet(std::list<face_t *> &faces,
+              const MeshOptions &opts = MeshOptions());
 
       MeshSet(std::vector<vertex_t> &_vertex_storage,
               std::vector<mesh_t *> &_meshes);
@@ -817,6 +843,8 @@ namespace carve {
       void collectVertices();
 
       void canonicalize();
+
+      void separateMeshes();
     };
 
 
index d55df8c8130ecc473c237ebfebe9a8aab38bd1c1..56fb6788b622842a0e3a81f019a7f7dc5b3d91bb 100644 (file)
@@ -676,7 +676,7 @@ namespace carve {
 
     template<unsigned ndim>
     template<typename iter_t>
-    void Mesh<ndim>::create(iter_t begin, iter_t end, std::vector<Mesh<ndim> *> &meshes) {
+    void Mesh<ndim>::create(iter_t begin, iter_t end, std::vector<Mesh<ndim> *> &meshes, const MeshOptions &opts) {
       meshes.clear();
     }
 
@@ -684,15 +684,15 @@ namespace carve {
 
     template<>
     template<typename iter_t>
-    void Mesh<3>::create(iter_t begin, iter_t end, std::vector<Mesh<3> *> &meshes) {
-      detail::FaceStitcher().create(begin, end, meshes);
+    void Mesh<3>::create(iter_t begin, iter_t end, std::vector<Mesh<3> *> &meshes, const MeshOptions &opts) {
+      detail::FaceStitcher(opts).create(begin, end, meshes);
     }
 
 
 
     template<unsigned ndim>
     template<typename iter_t>
-    void MeshSet<ndim>::_init_from_faces(iter_t begin, iter_t end) {
+    void MeshSet<ndim>::_init_from_faces(iter_t begin, iter_t end, const MeshOptions &opts) {
       typedef std::unordered_map<const vertex_t *, size_t> 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<unsigned ndim>
     MeshSet<ndim>::MeshSet(const std::vector<typename MeshSet<ndim>::vertex_t::vector_t> &points,
                            size_t n_faces,
-                           const std::vector<int> &face_indices) {
+                           const std::vector<int> &face_indices,
+                           const MeshOptions &opts) {
       vertex_storage.reserve(points.size());
       std::vector<face_t *> 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<unsigned ndim>
-    MeshSet<ndim>::MeshSet(std::vector<face_t *> &faces) {
-      _init_from_faces(faces.begin(), faces.end());
+    MeshSet<ndim>::MeshSet(std::vector<face_t *> &faces, const MeshOptions &opts) {
+      _init_from_faces(faces.begin(), faces.end(), opts);
     }
 
 
 
     template<unsigned ndim>
-    MeshSet<ndim>::MeshSet(std::list<face_t *> &faces) {
-      _init_from_faces(faces.begin(), faces.end());
+    MeshSet<ndim>::MeshSet(std::list<face_t *> &faces, const MeshOptions &opts) {
+      _init_from_faces(faces.begin(), faces.end(), opts);
     }
 
 
@@ -1010,5 +1011,41 @@ namespace carve {
       vertex_storage.swap(vout);
     }
 
+
+
+    template<unsigned ndim>
+    void MeshSet<ndim>::separateMeshes() {
+      size_t n;
+      typedef std::unordered_map<std::pair<mesh_t *, vertex_t *>, 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<vertex_t> 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);
+    }
+
   }
 }
index b92dbcfe24c5e8c1b244d0bf15188a7e018371a3..b468e4addc7763bff822b774a89c430b21462b36 100644 (file)
@@ -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;
index c5d5d8c515284c71389d57a8a6afaf43544d07c5..3b771bc8f3e5f0d4fe78d21f15f63ecb556f7a67 100644 (file)
@@ -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));
index 55ab893c10a8268e7e61cb1e6097a4ffabddccdd..ae91b385d4497c3680b45684faba056b39278921 100644 (file)
@@ -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) {
index 93e667ffaf7839d59ec651dbfcc6ee1566167939..43d08b81bfdcb6f781170e967ed51d318edb7bda 100644 (file)
@@ -233,7 +233,7 @@ namespace carve {
       }
 
       std::vector<mesh::Mesh<3> *> 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());
index 585d90659bd9ebfc74745df3496ed4879a218b3e..0b1f731805e9376b2cf5331780a748d63a6ec243 100644 (file)
@@ -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 (file)
index c1046b7..0000000
+++ /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;
- }