diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2013-11-28 11:51:17 +0400 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2013-11-28 12:00:10 +0400 |
commit | a628ca9ebe3a5296e197f12adf5988cb37f6050b (patch) | |
tree | 51628098dd155ffc0d8295b98fdd09aaa9d97fe8 /extern/carve/lib | |
parent | 1c14ead46f6aa7cc850033cf77d59127ca257b93 (diff) |
Update Carve to upstream version be054bc7ed86
Diffstat (limited to 'extern/carve/lib')
-rw-r--r-- | extern/carve/lib/geom2d.cpp | 8 | ||||
-rw-r--r-- | extern/carve/lib/intersect.cpp | 11 | ||||
-rw-r--r-- | extern/carve/lib/intersect_face_division.cpp | 30 |
3 files changed, 35 insertions, 14 deletions
diff --git a/extern/carve/lib/geom2d.cpp b/extern/carve/lib/geom2d.cpp index bfa84f5fd24..96527e485a5 100644 --- a/extern/carve/lib/geom2d.cpp +++ b/extern/carve/lib/geom2d.cpp @@ -177,12 +177,12 @@ namespace carve { break; } case INTERSECTION_PP: { - out.push_back(PolyIntersectionInfo(INTERSECT_VERTEX, e.ipoint, i + e.p2 - 2)); + out.push_back(PolyIntersectionInfo(INTERSECT_VERTEX, e.ipoint, i + (size_t)e.p2 - 2)); count++; break; } case INTERSECTION_LP: { - out.push_back(PolyIntersectionInfo(INTERSECT_VERTEX, e.ipoint, i + e.p2 - 2)); + out.push_back(PolyIntersectionInfo(INTERSECT_VERTEX, e.ipoint, i + (size_t)e.p2 - 2)); count++; break; } @@ -192,7 +192,9 @@ namespace carve { break; } case COLINEAR: { - int n1 = (int)i, n2 = (int)j; + size_t n1 = i; + size_t n2 = j; + P2 q1 = points[i], q2 = points[j]; if (q2 < q1) { std::swap(q1, q2); std::swap(n1, n2); } diff --git a/extern/carve/lib/intersect.cpp b/extern/carve/lib/intersect.cpp index b468e4addc7..8e377664748 100644 --- a/extern/carve/lib/intersect.cpp +++ b/extern/carve/lib/intersect.cpp @@ -407,6 +407,17 @@ void carve::csg::CSG::Hooks::resultFace(const meshset_t::face_t *new_face, } } +void carve::csg::CSG::Hooks::edgeDivision(const meshset_t::edge_t *orig_edge, + size_t orig_edge_idx, + const meshset_t::vertex_t *v1, + const meshset_t::vertex_t *v2) { + for (std::list<Hook *>::iterator j = hooks[EDGE_DIVISION_HOOK].begin(); + j != hooks[EDGE_DIVISION_HOOK].end(); + ++j) { + (*j)->edgeDivision(orig_edge, orig_edge_idx, v1, v2); + } +} + void carve::csg::CSG::Hooks::registerHook(Hook *hook, unsigned hook_bits) { for (unsigned i = 0; i < HOOK_MAX; ++i) { if (hook_bits & (1U << i)) { diff --git a/extern/carve/lib/intersect_face_division.cpp b/extern/carve/lib/intersect_face_division.cpp index 75f7f790df6..0fb36c5b89d 100644 --- a/extern/carve/lib/intersect_face_division.cpp +++ b/extern/carve/lib/intersect_face_division.cpp @@ -719,10 +719,6 @@ namespace { unassigned--; } } - - if (!removed.size()) - throw carve::exception("Failed to merge holes"); - for (std::set<int>::iterator f = removed.begin(); f != removed.end(); ++f) { for (unsigned i = 0; i < containing_faces.size(); ++i) { containing_faces[i].erase(std::remove(containing_faces[i].begin(), @@ -811,12 +807,14 @@ namespace { */ static bool assembleBaseLoop(carve::mesh::MeshSet<3>::face_t *face, const carve::csg::detail::Data &data, - std::vector<carve::mesh::MeshSet<3>::vertex_t *> &base_loop) { + std::vector<carve::mesh::MeshSet<3>::vertex_t *> &base_loop, + carve::csg::CSG::Hooks &hooks) { base_loop.clear(); // XXX: assumes that face->edges is in the same order as // face->vertices. (Which it is) carve::mesh::MeshSet<3>::edge_t *e = face->edge; + size_t e_idx = 0; bool face_edge_intersected = false; do { base_loop.push_back(carve::csg::map_vertex(data.vmap, e->vert)); @@ -830,9 +828,22 @@ namespace { base_loop.push_back(ev_vec[k++]); } + if (ev_vec.size() && hooks.hasHook(carve::csg::CSG::Hooks::EDGE_DIVISION_HOOK)) { + carve::mesh::MeshSet<3>::vertex_t *v1 = e->vert; + carve::mesh::MeshSet<3>::vertex_t *v2; + for (size_t k = 0, ke = ev_vec.size(); k < ke;) { + v2 = ev_vec[k++]; + hooks.edgeDivision(e, e_idx, v1, v2); + v1 = v2; + } + v2 = e->v2(); + hooks.edgeDivision(e, e_idx, v1, v2); + } + face_edge_intersected = true; } e = e->next; + ++e_idx; } while (e != face->edge); return face_edge_intersected; @@ -1110,8 +1121,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)); @@ -1445,7 +1455,7 @@ namespace { std::vector<carve::mesh::MeshSet<3>::vertex_t *> base_loop; std::list<std::vector<carve::mesh::MeshSet<3>::vertex_t *> > hole_loops; - bool face_edge_intersected = assembleBaseLoop(face, data, base_loop); + bool face_edge_intersected = assembleBaseLoop(face, data, base_loop, hooks); detail::FV2SMap::const_iterator fse_iter = data.face_split_edges.find(face); @@ -1637,9 +1647,7 @@ namespace { * \brief Build a set of face loops for all (split) faces of a Polyhedron. * * @param[in] poly The polyhedron to process - * @param vmap - * @param face_split_edges - * @param divided_edges + * @param[in] data Internal intersection data * @param[out] face_loops_out The resulting face loops * * @return The number of edges generated. |