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.
This commit is contained in:
2
extern/carve/bundle.sh
vendored
2
extern/carve/bundle.sh
vendored
@@ -91,7 +91,7 @@ if(WITH_BOOST)
|
|||||||
-DCARVE_SYSTEM_BOOST
|
-DCARVE_SYSTEM_BOOST
|
||||||
)
|
)
|
||||||
|
|
||||||
list(APPEND INC
|
list(APPEND INC_SYS
|
||||||
\${BOOST_INCLUDE_DIR}
|
\${BOOST_INCLUDE_DIR}
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
192
extern/carve/files.txt
vendored
192
extern/carve/files.txt
vendored
@@ -1,107 +1,109 @@
|
|||||||
include/carve/polyhedron_decl.hpp
|
include/carve/vertex_impl.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/aabb_impl.hpp
|
include/carve/aabb_impl.hpp
|
||||||
include/carve/colour.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/csg.hpp
|
||||||
|
include/carve/pointset_iter.hpp
|
||||||
|
include/carve/debug_hooks.hpp
|
||||||
include/carve/mesh.hpp
|
include/carve/mesh.hpp
|
||||||
include/carve/carve.hpp
|
include/carve/triangulator_impl.hpp
|
||||||
include/carve/gnu_cxx.h
|
include/carve/edge_decl.hpp
|
||||||
include/carve/polyhedron_impl.hpp
|
include/carve/collection/unordered.hpp
|
||||||
include/carve/poly_impl.hpp
|
|
||||||
include/carve/aabb.hpp
|
|
||||||
include/carve/convex_hull.hpp
|
|
||||||
include/carve/vertex_decl.hpp
|
|
||||||
include/carve/win32.h
|
|
||||||
include/carve/edge_impl.hpp
|
|
||||||
include/carve/tag.hpp
|
|
||||||
include/carve/tree.hpp
|
|
||||||
include/carve/heap.hpp
|
|
||||||
include/carve/matrix.hpp
|
|
||||||
include/carve/poly.hpp
|
|
||||||
include/carve/vector.hpp
|
|
||||||
include/carve/intersection.hpp
|
|
||||||
include/carve/faceloop.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/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/libstdcpp_impl.hpp
|
||||||
include/carve/collection/unordered/boost_impl.hpp
|
include/carve/collection/unordered/boost_impl.hpp
|
||||||
include/carve/collection/unordered/vcpp_impl.hpp
|
include/carve/convex_hull.hpp
|
||||||
include/carve/collection/unordered/fallback_impl.hpp
|
|
||||||
include/carve/collection/unordered.hpp
|
|
||||||
include/carve/face_impl.hpp
|
|
||||||
include/carve/pointset_impl.hpp
|
|
||||||
include/carve/cbrt.h
|
|
||||||
include/carve/vcpp_config.h
|
|
||||||
include/carve/geom.hpp
|
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/csg_triangulator.hpp
|
|
||||||
include/carve/iobj.hpp
|
|
||||||
include/carve/collection_types.hpp
|
include/carve/collection_types.hpp
|
||||||
lib/carve.cpp
|
include/carve/cbrt.h
|
||||||
lib/mesh.cpp
|
include/carve/util.hpp
|
||||||
lib/intersect_group.cpp
|
include/carve/iobj.hpp
|
||||||
lib/intersect_classify_common.hpp
|
include/carve/polyline_decl.hpp
|
||||||
lib/intersect_classify_edge.cpp
|
include/carve/polyline_impl.hpp
|
||||||
lib/intersect_classify_group.cpp
|
include/carve/win32.h
|
||||||
lib/csg_data.hpp
|
include/carve/edge_impl.hpp
|
||||||
lib/polyhedron.cpp
|
include/carve/carve.hpp
|
||||||
lib/csg_collector.hpp
|
include/carve/polyline.hpp
|
||||||
lib/geom3d.cpp
|
include/carve/config.h
|
||||||
lib/polyline.cpp
|
include/carve/face_decl.hpp
|
||||||
lib/csg_collector.cpp
|
include/carve/matrix.hpp
|
||||||
lib/triangulator.cpp
|
include/carve/classification.hpp
|
||||||
lib/intersect_face_division.cpp
|
include/carve/geom_impl.hpp
|
||||||
lib/intersect_half_classify_group.cpp
|
include/carve/faceloop.hpp
|
||||||
lib/edge.cpp
|
include/carve/mesh_ops.hpp
|
||||||
lib/math.cpp
|
include/carve/tree.hpp
|
||||||
lib/geom2d.cpp
|
include/carve/geom2d.hpp
|
||||||
lib/tag.cpp
|
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/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/aabb.hpp
|
||||||
|
include/carve/polyline_iter.hpp
|
||||||
|
include/carve/djset.hpp
|
||||||
|
include/carve/vertex_decl.hpp
|
||||||
|
include/carve/csg_triangulator.hpp
|
||||||
|
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/intersection.cpp
|
||||||
lib/convex_hull.cpp
|
|
||||||
lib/intersect_common.hpp
|
|
||||||
lib/intersect_classify_common_impl.hpp
|
|
||||||
lib/csg.cpp
|
|
||||||
lib/intersect.cpp
|
lib/intersect.cpp
|
||||||
lib/csg_detail.hpp
|
lib/triangulator.cpp
|
||||||
lib/face.cpp
|
|
||||||
lib/pointset.cpp
|
|
||||||
lib/timing.cpp
|
|
||||||
lib/octree.cpp
|
|
||||||
lib/aabb.cpp
|
|
||||||
lib/intersect_debug.hpp
|
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/polyline.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/aabb.cpp
|
||||||
|
lib/intersect_classify_group.cpp
|
||||||
|
lib/csg_detail.hpp
|
||||||
|
lib/mesh.cpp
|
||||||
|
lib/timing.cpp
|
||||||
|
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/intersect_debug.cpp
|
||||||
|
lib/edge.cpp
|
||||||
|
lib/intersect_classify_common_impl.hpp
|
||||||
|
lib/octree.cpp
|
||||||
|
@@ -174,7 +174,7 @@ namespace carve {
|
|||||||
|
|
||||||
double scoreQuad(edge_map_t::iterator i, edge_map_t &edge_map) {
|
double scoreQuad(edge_map_t::iterator i, edge_map_t &edge_map) {
|
||||||
if (!(*i).second.first || !(*i).second.second) return -1;
|
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) {
|
carve::mesh::MeshSet<3>::face_t *mergeQuad(edge_map_t::iterator i, edge_map_t &edge_map) {
|
||||||
|
19
extern/carve/include/carve/geom3d.hpp
vendored
19
extern/carve/include/carve/geom3d.hpp
vendored
@@ -206,9 +206,22 @@ namespace carve {
|
|||||||
* * +1, if a is ordered after b around, rotating about direction.
|
* * +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) {
|
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);
|
// 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);
|
// 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 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.
|
// CASE: a and b are coplanar wrt. direction.
|
||||||
if (d1 == 0.0) {
|
if (d1 == 0.0) {
|
||||||
|
2
extern/carve/include/carve/geom_impl.hpp
vendored
2
extern/carve/include/carve/geom_impl.hpp
vendored
@@ -396,7 +396,7 @@ namespace carve {
|
|||||||
// Compute a . (b x c)
|
// Compute a . (b x c)
|
||||||
return
|
return
|
||||||
(a.x * b.y * c.z + a.y * b.z * c.x + a.z * b.x * c.y) -
|
(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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
81
extern/carve/include/carve/input.hpp
vendored
81
extern/carve/include/carve/input.hpp
vendored
@@ -17,6 +17,9 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <map>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
#include <carve/carve.hpp>
|
#include <carve/carve.hpp>
|
||||||
#include <carve/poly.hpp>
|
#include <carve/poly.hpp>
|
||||||
#include <carve/mesh.hpp>
|
#include <carve/mesh.hpp>
|
||||||
@@ -28,6 +31,50 @@
|
|||||||
namespace carve {
|
namespace carve {
|
||||||
namespace input {
|
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 {
|
struct Data {
|
||||||
Data() {
|
Data() {
|
||||||
}
|
}
|
||||||
@@ -126,12 +173,18 @@ namespace carve {
|
|||||||
faceCount = 0;
|
faceCount = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
carve::poly::Polyhedron *create() const {
|
carve::poly::Polyhedron *create(const Options &options) const {
|
||||||
return new carve::poly::Polyhedron(points, faceCount, faceIndices);
|
return new carve::poly::Polyhedron(points, faceCount, faceIndices);
|
||||||
}
|
}
|
||||||
|
|
||||||
carve::mesh::MeshSet<3> *createMesh() const {
|
carve::mesh::MeshSet<3> *createMesh(const Options &options) const {
|
||||||
return new carve::mesh::MeshSet<3>(points, faceCount, faceIndices);
|
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);
|
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);
|
carve::line::PolylineSet *p = new carve::line::PolylineSet(points);
|
||||||
|
|
||||||
for (std::list<polyline_data_t>::const_iterator i = polylines.begin();
|
for (std::list<polyline_data_t>::const_iterator i = polylines.begin();
|
||||||
@@ -181,7 +234,7 @@ namespace carve {
|
|||||||
virtual ~PointSetData() {
|
virtual ~PointSetData() {
|
||||||
}
|
}
|
||||||
|
|
||||||
carve::point::PointSet *create() const {
|
carve::point::PointSet *create(const Options &options) const {
|
||||||
carve::point::PointSet *p = new carve::point::PointSet(points);
|
carve::point::PointSet *p = new carve::point::PointSet(points);
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
@@ -214,37 +267,37 @@ namespace carve {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
static inline T *create(Data *d) {
|
static inline T *create(Data *d, const Options &options = Options()) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template<>
|
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);
|
PolyhedronData *p = dynamic_cast<PolyhedronData *>(d);
|
||||||
if (p == NULL) return NULL;
|
if (p == NULL) return NULL;
|
||||||
return p->createMesh();
|
return p->createMesh(options);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
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);
|
PolyhedronData *p = dynamic_cast<PolyhedronData *>(d);
|
||||||
if (p == NULL) return NULL;
|
if (p == NULL) return NULL;
|
||||||
return p->create();
|
return p->create(options);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
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);
|
PolylineSetData *p = dynamic_cast<PolylineSetData *>(d);
|
||||||
if (p == NULL) return NULL;
|
if (p == NULL) return NULL;
|
||||||
return p->create();
|
return p->create(options);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
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);
|
PointSetData *p = dynamic_cast<PointSetData *>(d);
|
||||||
if (p == NULL) return NULL;
|
if (p == NULL) return NULL;
|
||||||
return p->create();
|
return p->create(options);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
38
extern/carve/include/carve/mesh.hpp
vendored
38
extern/carve/include/carve/mesh.hpp
vendored
@@ -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 {
|
namespace detail {
|
||||||
class FaceStitcher {
|
class FaceStitcher {
|
||||||
|
FaceStitcher();
|
||||||
|
FaceStitcher(const FaceStitcher &);
|
||||||
|
FaceStitcher &operator=(const FaceStitcher &);
|
||||||
|
|
||||||
typedef Vertex<3> vertex_t;
|
typedef Vertex<3> vertex_t;
|
||||||
typedef Edge<3> edge_t;
|
typedef Edge<3> edge_t;
|
||||||
typedef Face<3> face_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<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;
|
typedef std::unordered_map<const vertex_t *, std::set<const vertex_t *> > edge_graph_t;
|
||||||
|
|
||||||
|
MeshOptions opts;
|
||||||
|
|
||||||
edge_map_t edges;
|
edge_map_t edges;
|
||||||
edge_map_t complex_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);
|
void build(iter_t begin, iter_t end, std::vector<Mesh<3> *> &meshes);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
FaceStitcher(const MeshOptions &_opts);
|
||||||
|
|
||||||
template<typename iter_t>
|
template<typename iter_t>
|
||||||
void create(iter_t begin, iter_t end, std::vector<Mesh<3> *> &meshes);
|
void create(iter_t begin, iter_t end, std::vector<Mesh<3> *> &meshes);
|
||||||
};
|
};
|
||||||
@@ -623,7 +646,7 @@ namespace carve {
|
|||||||
~Mesh();
|
~Mesh();
|
||||||
|
|
||||||
template<typename iter_t>
|
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 {
|
aabb_t getAABB() const {
|
||||||
return aabb_t(faces.begin(), faces.end());
|
return aabb_t(faces.begin(), faces.end());
|
||||||
@@ -692,7 +715,7 @@ namespace carve {
|
|||||||
MeshSet &operator=(const MeshSet &);
|
MeshSet &operator=(const MeshSet &);
|
||||||
|
|
||||||
template<typename iter_t>
|
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:
|
public:
|
||||||
typedef Vertex<ndim> vertex_t;
|
typedef Vertex<ndim> vertex_t;
|
||||||
@@ -781,13 +804,16 @@ namespace carve {
|
|||||||
|
|
||||||
MeshSet(const std::vector<typename vertex_t::vector_t> &points,
|
MeshSet(const std::vector<typename vertex_t::vector_t> &points,
|
||||||
size_t n_faces,
|
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
|
// Construct a mesh set from a set of disconnected faces. Takes
|
||||||
// posession of the face pointers.
|
// 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,
|
MeshSet(std::vector<vertex_t> &_vertex_storage,
|
||||||
std::vector<mesh_t *> &_meshes);
|
std::vector<mesh_t *> &_meshes);
|
||||||
@@ -817,6 +843,8 @@ namespace carve {
|
|||||||
void collectVertices();
|
void collectVertices();
|
||||||
|
|
||||||
void canonicalize();
|
void canonicalize();
|
||||||
|
|
||||||
|
void separateMeshes();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
59
extern/carve/include/carve/mesh_impl.hpp
vendored
59
extern/carve/include/carve/mesh_impl.hpp
vendored
@@ -676,7 +676,7 @@ namespace carve {
|
|||||||
|
|
||||||
template<unsigned ndim>
|
template<unsigned ndim>
|
||||||
template<typename iter_t>
|
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();
|
meshes.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -684,15 +684,15 @@ namespace carve {
|
|||||||
|
|
||||||
template<>
|
template<>
|
||||||
template<typename iter_t>
|
template<typename iter_t>
|
||||||
void Mesh<3>::create(iter_t begin, iter_t end, std::vector<Mesh<3> *> &meshes) {
|
void Mesh<3>::create(iter_t begin, iter_t end, std::vector<Mesh<3> *> &meshes, const MeshOptions &opts) {
|
||||||
detail::FaceStitcher().create(begin, end, meshes);
|
detail::FaceStitcher(opts).create(begin, end, meshes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
template<unsigned ndim>
|
template<unsigned ndim>
|
||||||
template<typename iter_t>
|
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;
|
typedef std::unordered_map<const vertex_t *, size_t> map_t;
|
||||||
map_t vmap;
|
map_t vmap;
|
||||||
|
|
||||||
@@ -723,7 +723,7 @@ namespace carve {
|
|||||||
} while (e != f->edge);
|
} 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) {
|
for (size_t i = 0; i < meshes.size(); ++i) {
|
||||||
meshes[i]->meshset = this;
|
meshes[i]->meshset = this;
|
||||||
@@ -735,7 +735,8 @@ namespace carve {
|
|||||||
template<unsigned ndim>
|
template<unsigned ndim>
|
||||||
MeshSet<ndim>::MeshSet(const std::vector<typename MeshSet<ndim>::vertex_t::vector_t> &points,
|
MeshSet<ndim>::MeshSet(const std::vector<typename MeshSet<ndim>::vertex_t::vector_t> &points,
|
||||||
size_t n_faces,
|
size_t n_faces,
|
||||||
const std::vector<int> &face_indices) {
|
const std::vector<int> &face_indices,
|
||||||
|
const MeshOptions &opts) {
|
||||||
vertex_storage.reserve(points.size());
|
vertex_storage.reserve(points.size());
|
||||||
std::vector<face_t *> faces;
|
std::vector<face_t *> faces;
|
||||||
faces.reserve(n_faces);
|
faces.reserve(n_faces);
|
||||||
@@ -755,7 +756,7 @@ namespace carve {
|
|||||||
faces.push_back(new face_t(v.begin(), v.end()));
|
faces.push_back(new face_t(v.begin(), v.end()));
|
||||||
}
|
}
|
||||||
CARVE_ASSERT(p == face_indices.size());
|
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) {
|
for (size_t i = 0; i < meshes.size(); ++i) {
|
||||||
meshes[i]->meshset = this;
|
meshes[i]->meshset = this;
|
||||||
@@ -765,15 +766,15 @@ namespace carve {
|
|||||||
|
|
||||||
|
|
||||||
template<unsigned ndim>
|
template<unsigned ndim>
|
||||||
MeshSet<ndim>::MeshSet(std::vector<face_t *> &faces) {
|
MeshSet<ndim>::MeshSet(std::vector<face_t *> &faces, const MeshOptions &opts) {
|
||||||
_init_from_faces(faces.begin(), faces.end());
|
_init_from_faces(faces.begin(), faces.end(), opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
template<unsigned ndim>
|
template<unsigned ndim>
|
||||||
MeshSet<ndim>::MeshSet(std::list<face_t *> &faces) {
|
MeshSet<ndim>::MeshSet(std::list<face_t *> &faces, const MeshOptions &opts) {
|
||||||
_init_from_faces(faces.begin(), faces.end());
|
_init_from_faces(faces.begin(), faces.end(), opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1010,5 +1011,41 @@ namespace carve {
|
|||||||
vertex_storage.swap(vout);
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
4
extern/carve/lib/intersect.cpp
vendored
4
extern/carve/lib/intersect.cpp
vendored
@@ -1320,8 +1320,8 @@ void carve::csg::CSG::calc(meshset_t *a,
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
checkFaceLoopIntegrity(a_face_loops);
|
// checkFaceLoopIntegrity(a_face_loops);
|
||||||
checkFaceLoopIntegrity(b_face_loops);
|
// checkFaceLoopIntegrity(b_face_loops);
|
||||||
|
|
||||||
#if defined(CARVE_DEBUG)
|
#if defined(CARVE_DEBUG)
|
||||||
std::cerr << "classify" << std::endl;
|
std::cerr << "classify" << std::endl;
|
||||||
|
3
extern/carve/lib/intersect_face_division.cpp
vendored
3
extern/carve/lib/intersect_face_division.cpp
vendored
@@ -1110,8 +1110,7 @@ namespace {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// copy up to the end of the path.
|
// 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());
|
CARVE_ASSERT(base_loop[e1_1] == p1.back());
|
||||||
std::copy(p1.rbegin(), p1.rend() - 1, std::back_inserter(out));
|
std::copy(p1.rbegin(), p1.rend() - 1, std::back_inserter(out));
|
||||||
|
36
extern/carve/lib/mesh.cpp
vendored
36
extern/carve/lib/mesh.cpp
vendored
@@ -243,15 +243,20 @@ namespace carve {
|
|||||||
|
|
||||||
bool FaceStitcher::EdgeOrderData::Cmp::operator()(const EdgeOrderData &a, const EdgeOrderData &b) const {
|
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);
|
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);
|
#if defined(CARVE_DEBUG)
|
||||||
int v0 = v;
|
{
|
||||||
v = 0;
|
double da = carve::geom3d::antiClockwiseAngle(base_dir, a.face_dir, edge_dir);
|
||||||
if (da < db) v = -1;
|
double db = carve::geom3d::antiClockwiseAngle(base_dir, b.face_dir, edge_dir);
|
||||||
if (db < da) v = +1;
|
int v_cmp = 0;
|
||||||
if (v0 != v) {
|
if (da < db) v_cmp = -1;
|
||||||
std::cerr << "v0= " << v0 << " v= " << v << " da= " << da << " db= " << db << " " << edge_dir << " " << base_dir << " " << a.face_dir << b.face_dir << std::endl;
|
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) return true;
|
||||||
if (v == 0) {
|
if (v == 0) {
|
||||||
if (a.is_reversed && !b.is_reversed) return true;
|
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());
|
CARVE_ASSERT(erev[0][i]->v2() == erev[j][i]->v2());
|
||||||
}
|
}
|
||||||
|
|
||||||
std::sort(result[i].begin(),
|
geom::vector<3> sort_dir;
|
||||||
result[i].end(),
|
if (opts.opt_avoid_cavities) {
|
||||||
EdgeOrderData::Cmp(base->v2()->v - base->v1()->v, result[i][0].face_dir));
|
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
|
// construct a MeshSet from a Polyhedron, maintaining on the
|
||||||
// connectivity information in the Polyhedron.
|
// connectivity information in the Polyhedron.
|
||||||
mesh::MeshSet<3> *meshFromPolyhedron(const poly::Polyhedron *poly, int manifold_id) {
|
mesh::MeshSet<3> *meshFromPolyhedron(const poly::Polyhedron *poly, int manifold_id) {
|
||||||
|
2
extern/carve/lib/polyhedron.cpp
vendored
2
extern/carve/lib/polyhedron.cpp
vendored
@@ -233,7 +233,7 @@ namespace carve {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::vector<mesh::Mesh<3> *> meshes;
|
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);
|
mesh::MeshSet<3> *meshset = new mesh::MeshSet<3>(vertex_storage, meshes);
|
||||||
|
|
||||||
manifold_is_closed.resize(meshset->meshes.size());
|
manifold_is_closed.resize(meshset->meshes.size());
|
||||||
|
1
extern/carve/patches/series
vendored
1
extern/carve/patches/series
vendored
@@ -1,4 +1,3 @@
|
|||||||
strict_flags.patch
|
|
||||||
includes.patch
|
includes.patch
|
||||||
win32.patch
|
win32.patch
|
||||||
mesh_iterator.patch
|
mesh_iterator.patch
|
||||||
|
22
extern/carve/patches/strict_flags.patch
vendored
22
extern/carve/patches/strict_flags.patch
vendored
@@ -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;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
Reference in New Issue
Block a user