[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [41086] branches/carve_booleans: Carve:
Sergey Sharybin
g.ulairi at gmail.com
Mon Oct 17 13:47:54 CEST 2011
Revision: 41086
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=41086
Author: nazgul
Date: 2011-10-17 11:47:54 +0000 (Mon, 17 Oct 2011)
Log Message:
-----------
Carve:
- Bundle the very recent version of carve library
- Set carve epsilon to 1e-3 when performing boolean operator.
Seems to solve mesh flickering in special cases without visible
harm to shape. But need to be investigated further.
Modified Paths:
--------------
branches/carve_booleans/extern/carve/include/carve/collection/unordered/boost_impl.hpp
branches/carve_booleans/extern/carve/include/carve/face_decl.hpp
branches/carve_booleans/extern/carve/include/carve/geom.hpp
branches/carve_booleans/extern/carve/include/carve/geom_impl.hpp
branches/carve_booleans/extern/carve/include/carve/math.hpp
branches/carve_booleans/extern/carve/include/carve/mesh.hpp
branches/carve_booleans/extern/carve/include/carve/mesh_impl.hpp
branches/carve_booleans/extern/carve/include/carve/mesh_ops.hpp
branches/carve_booleans/extern/carve/include/carve/mesh_simplify.hpp
branches/carve_booleans/extern/carve/include/carve/rtree.hpp
branches/carve_booleans/extern/carve/include/carve/vcpp_config.h
branches/carve_booleans/extern/carve/lib/polyhedron.cpp
branches/carve_booleans/intern/boolop/intern/BOP_CarveInterface.cpp
Modified: branches/carve_booleans/extern/carve/include/carve/collection/unordered/boost_impl.hpp
===================================================================
--- branches/carve_booleans/extern/carve/include/carve/collection/unordered/boost_impl.hpp 2011-10-17 11:24:20 UTC (rev 41085)
+++ branches/carve_booleans/extern/carve/include/carve/collection/unordered/boost_impl.hpp 2011-10-17 11:47:54 UTC (rev 41086)
@@ -23,21 +23,23 @@
#include <functional>
namespace std {
-
template <typename Key, typename T, typename Hash = boost::hash<Key>,
typename Pred = std::equal_to<Key> >
class unordered_map : public boost::unordered_map<Key, T, Hash, Pred> {
public:
typedef T data_type;
+ };
+ template <typename Key, typename T, typename Hash = boost::hash<Key>,
+ typename Pred = std::equal_to<Key> >
+ class unordered_multimap : public boost::unordered_multimap<Key, T, Hash, Pred> {
};
template <typename Value, typename Hash = boost::hash<Value>,
typename Pred = std::equal_to<Value> >
class unordered_set : public boost::unordered_set<Value, Hash, Pred> {
};
-
}
#undef UNORDERED_COLLECTIONS_SUPPORT_RESIZE
Modified: branches/carve_booleans/extern/carve/include/carve/face_decl.hpp
===================================================================
--- branches/carve_booleans/extern/carve/include/carve/face_decl.hpp 2011-10-17 11:24:20 UTC (rev 41085)
+++ branches/carve_booleans/extern/carve/include/carve/face_decl.hpp 2011-10-17 11:47:54 UTC (rev 41086)
@@ -95,6 +95,11 @@
Face(const vertex_t *v1, const vertex_t *v2, const vertex_t *v3, bool delay_recalc = false);
Face(const vertex_t *v1, const vertex_t *v2, const vertex_t *v3, const vertex_t *v4, bool delay_recalc = false);
+ template <typename iter_t>
+ Face(const Face *base, iter_t vbegin, iter_t vend, bool flipped) {
+ init(base, vbegin, vend, flipped);
+ }
+
Face(const Face *base, const std::vector<const vertex_t *> &_vertices, bool flipped) {
init(base, _vertices, flipped);
}
Modified: branches/carve_booleans/extern/carve/include/carve/geom.hpp
===================================================================
--- branches/carve_booleans/extern/carve/include/carve/geom.hpp 2011-10-17 11:24:20 UTC (rev 41085)
+++ branches/carve_booleans/extern/carve/include/carve/geom.hpp 2011-10-17 11:47:54 UTC (rev 41086)
@@ -201,9 +201,9 @@
static inline double distance(const ray<3> &r, const vector<3> &v);
- inline double distance2(const ray<2> &r, const vector<2> &v);
+ static inline double distance2(const ray<2> &r, const vector<2> &v);
- inline double distance(const ray<2> &r, const vector<2> &v);
+ static inline double distance(const ray<2> &r, const vector<2> &v);
@@ -298,6 +298,10 @@
tri(vector_t _v[3]);
tri(const vector_t &a, const vector_t &b, const vector_t &c);
+
+ vector_t normal() const {
+ return cross(v[1] - v[0], v[2] - v[1]).normalized();
+ }
};
@@ -309,6 +313,12 @@
+ template<unsigned ndim> vector<ndim> closestPoint(const tri<ndim> &tri, const vector<ndim> &pt);
+ template<unsigned ndim> double distance(const tri<ndim> &tri, const vector<ndim> &pt);
+ template<unsigned ndim> double distance2(const tri<ndim> &tri, const vector<ndim> &pt);
+
+
+
// ========================================================================
template<int base, int power> struct __pow__ { enum { val = __pow__<base, (power >> 1)>::val * __pow__<base, power - (power >> 1)>::val }; };
template<int base> struct __pow__<base, 1> { enum { val = base }; };
Modified: branches/carve_booleans/extern/carve/include/carve/geom_impl.hpp
===================================================================
--- branches/carve_booleans/extern/carve/include/carve/geom_impl.hpp 2011-10-17 11:24:20 UTC (rev 41085)
+++ branches/carve_booleans/extern/carve/include/carve/geom_impl.hpp 2011-10-17 11:47:54 UTC (rev 41086)
@@ -17,6 +17,8 @@
#pragma once
+#include <carve/math.hpp>
+
namespace carve {
namespace geom {
@@ -448,12 +450,12 @@
return sqrt(distance2(r, v));
}
- inline double distance2(const ray<2> &r, const vector<2> &v) {
+ static inline double distance2(const ray<2> &r, const vector<2> &v) {
double t = cross(r.D, v - r.v);
return (t * t) / r.D.length2();
}
- inline double distance(const ray<2> &r, const vector<2> &v) {
+ static inline double distance(const ray<2> &r, const vector<2> &v) {
return sqrt(distance2(r, v));
}
@@ -508,7 +510,8 @@
template<unsigned ndim>
void plane<ndim>::negate() {
- N.negate(); d = -d;
+ N.negate();
+ d = -d;
}
template<unsigned ndim>
@@ -529,7 +532,7 @@
template<unsigned ndim>
- inline plane<ndim> operator-(const plane<ndim> &p) {
+ plane<ndim> operator-(const plane<ndim> &p) {
return plane<ndim>(-p.N, -p.d);
}
@@ -545,7 +548,7 @@
}
template<unsigned ndim>
- static inline vector<ndim> closestPoint(const plane<ndim> &p, const vector<ndim> &v) {
+ vector<ndim> closestPoint(const plane<ndim> &p, const vector<ndim> &v) {
return v - p.N * (p.d + dot(p.N, v)) / dot(p.N, p.N);
}
@@ -580,7 +583,7 @@
}
template<unsigned ndim>
- static inline vector<ndim> closestPoint(const sphere<ndim> &sphere, const vector<ndim> &point) {
+ vector<ndim> closestPoint(const sphere<ndim> &sphere, const vector<ndim> &point) {
return (point - sphere.C).normalized() * sphere.r;
}
@@ -608,13 +611,13 @@
template<unsigned ndim>
- inline std::ostream &operator<<(std::ostream &o, const vector<ndim> &v) {
+ std::ostream &operator<<(std::ostream &o, const vector<ndim> &v) {
o << v.asStr();
return o;
}
template<unsigned ndim>
- inline std::ostream &operator<<(std::ostream &o, const carve::geom::plane<ndim> &p) {
+ std::ostream &operator<<(std::ostream &o, const carve::geom::plane<ndim> &p) {
o << p.N << ";" << p.d;
return o;
}
@@ -633,5 +636,16 @@
+ template<unsigned ndim>
+ double distance(const tri<ndim> &tri, const vector<ndim> &pt) {
+ return distance(closestPoint(tri, pt), pt);
+ }
+
+
+
+ template<unsigned ndim>
+ double distance2(const tri<ndim> &tri, const vector<ndim> &pt) {
+ return distance2(closestPoint(tri, pt), pt);
+ }
}
}
Modified: branches/carve_booleans/extern/carve/include/carve/math.hpp
===================================================================
--- branches/carve_booleans/extern/carve/include/carve/math.hpp 2011-10-17 11:24:20 UTC (rev 41085)
+++ branches/carve_booleans/extern/carve/include/carve/math.hpp 2011-10-17 11:47:54 UTC (rev 41086)
@@ -19,22 +19,25 @@
#include <carve/carve.hpp>
-#include <carve/geom3d.hpp>
#include <carve/math_constants.hpp>
#include <math.h>
namespace carve {
+ namespace geom {
+ template<unsigned ndim> class vector;
+ }
+}
+
+namespace carve {
namespace math {
struct Matrix3;
- using carve::geom3d::Vector;
-
int cubic_roots(double c3, double c2, double c1, double c0, double *roots);
void eigSolveSymmetric(const Matrix3 &m,
- double &l1, Vector &e1,
- double &l2, Vector &e2,
- double &l3, Vector &e3);
+ double &l1, carve::geom::vector<3> &e1,
+ double &l2, carve::geom::vector<3> &e2,
+ double &l3, carve::geom::vector<3> &e3);
void eigSolve(const Matrix3 &m, double &l1, double &l2, double &l3);
@@ -47,5 +50,11 @@
return (x < 0) ? x + M_TWOPI : x;
}
+ template<typename T>
+ static inline const T &clamp(const T &val, const T &min, const T &max) {
+ if (val < min) return min;
+ if (val > max) return max;
+ return val;
+ }
}
}
Modified: branches/carve_booleans/extern/carve/include/carve/mesh.hpp
===================================================================
--- branches/carve_booleans/extern/carve/include/carve/mesh.hpp 2011-10-17 11:24:20 UTC (rev 41085)
+++ branches/carve_booleans/extern/carve/include/carve/mesh.hpp 2011-10-17 11:47:54 UTC (rev 41086)
@@ -186,8 +186,11 @@
size_t c = 0;
do {
++c;
- CARVE_ASSERT(e->rev->rev == e);
+ CARVE_ASSERT(e->rev == NULL || e->rev->rev == e);
+ CARVE_ASSERT(e->next == e || e->next->vert != e->vert);
+ CARVE_ASSERT(e->prev == e || e->prev->vert != e->vert);
CARVE_ASSERT(e->next->prev == e);
+ CARVE_ASSERT(e->prev->next == e);
CARVE_ASSERT(e->face == f);
e = e->next;
} while (e != this);
@@ -563,6 +566,22 @@
return is_negative;
}
+ double volume() const {
+ if (is_negative || !faces.size()) return 0.0;
+
+ double vol = 0.0;
+ typename vertex_t::vector_t origin = faces[0]->edge->vert->v;
+
+ for (size_t f = 0; f < faces.size(); ++f) {
+ face_t *face = faces[f];
+ edge_t *e1 = face->edge;
+ for (edge_t *e2 = e1->next ;e2->next != e1; e2 = e2->next) {
+ vol += carve::geom3d::tetrahedronVolume(e1->vert->v, e2->vert->v, e2->next->vert->v, origin);
+ }
+ }
+ return vol;
+ }
+
struct IsClosed {
bool operator()(const Mesh &mesh) const { return mesh.isClosed(); }
bool operator()(const Mesh *mesh) const { return mesh->isClosed(); }
Modified: branches/carve_booleans/extern/carve/include/carve/mesh_impl.hpp
===================================================================
--- branches/carve_booleans/extern/carve/include/carve/mesh_impl.hpp 2011-10-17 11:24:20 UTC (rev 41085)
+++ branches/carve_booleans/extern/carve/include/carve/mesh_impl.hpp 2011-10-17 11:47:54 UTC (rev 41086)
@@ -646,8 +646,8 @@
edge_t *emin = closed_edges[0];
if (emin->rev->v1()->v < emin->v1()->v) emin = emin->rev;
for (size_t i = 1; i < closed_edges.size(); ++i) {
- if (emin->v1()->v < closed_edges[i]->v1()->v) emin = closed_edges[i];
- if (emin->v1()->v < closed_edges[i]->rev->v1()->v) emin = closed_edges[i]->rev;
+ if (closed_edges[i]->v1()->v < emin->v1()->v) emin = closed_edges[i];
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list