mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-05-16 18:12:10 +00:00
* Update eigen from v3.3.7 to v5.0.1. This updates eigen from v3.3.7 released on December 11, 2018-12-11 to v5.0.1 released on 2025-11-11. There have be a large number of bug-fixes, optimizations, and improvements between these releases. See the details at; https://gitlab.com/libeigen/eigen/-/releases It retains the previous custom minimal `CMakeLists.txt`, and adds a README-OrcaSlicer.md that explains what version and parts of the upstream eigen release have been included, and where the full release can be found. * Update libigl from v2.0.0 (or older) to v2.6.0. This updates libigl from what was probably v2.0.0 released on 2018-10-16 to v2.6.0 released on 2025-05-15. It's possible the old version was even older than that but there is no version indicators in the code and I ran out of patience identifying missing changes and only went back as far as v2.0.0. There have been a large number of bug-fixes, optimizations, and improvements between these versions. See the following for details; https://github.com/libigl/libigl/releases I retained the minimal custom `CMakeLists.txt`, added `README.md` from the libigl distribution which identifies the version, and added a README-OrcaSlicer.md that details the version and parts that have been included. * Update libslic3r for libigl v2.6.0 changes. This updates libslic3r for all changes moving to eigen v5.0.1 and libigl v2.6.0. Despite the large number of updates to both dependencies, no changes were required for the eigen update, and only one change was required for the libigl update. For libigl, `igl::Hit` was changed to a template taking the Scalar type to use. Previously it was hard-coded to `float`, so to minimize possible impact I've updated all places it is used from `igl::Hit` to `igl::Hit<float>`. * Add compiler option `-DNOMINMAX` for libigl with MSVC. MSVC by default defines `min(()` and `max()` macros that break `std::numeric_limits<>::max()`. The upstream cmake that we don't include adds `-DNOMINMAX` for the libigl module when compiling with MSVC, so we need to add the same thing here. * Fix src/libslic3r/TriangleMeshDeal.cpp for the unmodified upstream libigl. This fixes `TriangleMeshDeal.cpp` to work with the unmodified upstream libigl v2.6.0. loop.{h,cpp} implementation. This file and feature was added in PR "BBS Port: Mesh Subdivision" (#12150) which included changes to `loop.{h,cpp}` in the old version of libigl. This PR avoids modifying the included dependencies, and uses the updated upstream versions of those files without any modifications, which requires fixing TriangleMeshDeal.cpp to work with them. In particular, the modifications made to `loop.{h,cpp}` included changing the return type from void to bool, adding additional validation checking of the input meshes, and returning false if they failed validation. These added checks looked unnecessary and would only have caught problems if the input mesh was very corrupt. To make `TriangleMeshDeal.cpp` work without this built-in checking functionality, I removed checking/handling of any `false` return value. There was also a hell of a lot of redundant copying and casting back and forth between float and double, so I cleaned that up. The input and output meshs use floats for the vertexes, and there would be no accuracy benefits from casting to and from doubles for the simple weighted average operations done by igl::loop(). So this just uses `Eigen:Map` to use the original input mesh vertex data directly without requiring any copy or casting. * Move eigen from included `deps_src` to externaly fetched `deps`. This copys what PrusaSlicer did and moved it from an included dependency under `deps_src` to an externaly fetched dependency under `deps`. This requires updating some `CMakeList.txt` configs and removing the old and obsolete `cmake/modules/FindEigen3.cmake`. The details of when this was done in PrusaSlicer and the followup fixes are at; *21116995d7* https://github.com/prusa3d/PrusaSlicer/issues/13608 * https://github.com/prusa3d/PrusaSlicer/pull/13609 *e3c277b9eeFor some reason I don't fully understand this also required fixing `src/slic3r/GUI/GUI_App.cpp` by adding `#include <boost/nowide/cstdio.hpp>` to fix an `error: ‘remove’ is not a member of ‘boost::nowide'`. The main thing I don't understand is how it worked before. Note that this include is in the PrusaSlicer version of this file, but it also significantly deviates from what is currently in OrcaSlicer in many other ways. * Whups... I missed adding the deps/Eigen/Eigen.cmake file... * Tidy some whitespace indenting in CMakeLists.txt. * Ugh... tabs indenting needing fixes. * Change the include order of deps/Eigen. It turns out that although Boost includes some references to Eigen, Eigen also includes some references to Boost for supporting some of it's additional numeric types. I don't think it matters much since we are not using these features, but I think technically its more correct to say Eigen depends on Boost than the other way around, so I've re-ordered them. * Add source for Eigen 5.0.1 download to flatpak yml config. * Add explicit `DEPENDS dep_Boost to deps/Eigen. I missed this before. This ensures we don't rely on include orders to make sure Boost is installed before we configure Eigen. * Add `DEPENDS dep_Boost dep_GMP dep_MPFR` to deps/Eigen. It turns out Eigen can also use GMP and MPFR for multi-precision and multi-precision-rounded numeric types if they are available. Again, I don't think we are using these so it doesn't really matter, but it is technically correct and ensures they are there if we ever do need them. * Fix deps DEPENDENCY ordering for GMP, MPFR, Eigen, and CGAL. I think this is finally correct. Apparently CGAL also optionally depends on Eigen, so the correct dependency order from lowest to highest is GMP, MPFR, Eigen, and CGAL. --------- Co-authored-by: Donovan Baarda <dbaarda@google.com> Co-authored-by: Noisyfox <timemanager.rick@gmail.com>
526 lines
24 KiB
C++
526 lines
24 KiB
C++
// This file is part of libigl, a simple c++ geometry processing library.
|
|
//
|
|
// Copyright (C) 2015 Qingnan Zhou <qnzhou@gmail.com>
|
|
//
|
|
// This Source Code Form is subject to the terms of the Mozilla Public License
|
|
// v. 2.0. If a copy of the MPL was not distributed with this file, You can
|
|
// obtain one at http://mozilla.org/MPL/2.0/.
|
|
//
|
|
#include "closest_facet.h"
|
|
|
|
#include <vector>
|
|
#include <stdexcept>
|
|
#include <unordered_map>
|
|
|
|
#include "order_facets_around_edge.h"
|
|
#include "submesh_aabb_tree.h"
|
|
#include "../../vertex_triangle_adjacency.h"
|
|
#include "../../PlainMatrix.h"
|
|
#include "../../LinSpaced.h"
|
|
//#include "../../writePLY.h"
|
|
|
|
template<
|
|
typename DerivedV,
|
|
typename DerivedF,
|
|
typename DerivedI,
|
|
typename DerivedP,
|
|
typename DerivedEMAP,
|
|
typename DeriveduEC,
|
|
typename DeriveduEE,
|
|
typename Kernel,
|
|
typename DerivedR,
|
|
typename DerivedS >
|
|
IGL_INLINE void igl::copyleft::cgal::closest_facet(
|
|
const Eigen::MatrixBase<DerivedV>& V,
|
|
const Eigen::MatrixBase<DerivedF>& F,
|
|
const Eigen::MatrixBase<DerivedI>& I,
|
|
const Eigen::MatrixBase<DerivedP>& P,
|
|
const Eigen::MatrixBase<DerivedEMAP>& EMAP,
|
|
const Eigen::MatrixBase<DeriveduEC>& uEC,
|
|
const Eigen::MatrixBase<DeriveduEE>& uEE,
|
|
const std::vector<std::vector<size_t> > & VF,
|
|
const std::vector<std::vector<size_t> > & VFi,
|
|
const CGAL::AABB_tree<
|
|
CGAL::AABB_traits<
|
|
Kernel,
|
|
CGAL::AABB_triangle_primitive<
|
|
Kernel, typename std::vector<
|
|
typename Kernel::Triangle_3 >::iterator > > > & tree,
|
|
const std::vector<typename Kernel::Triangle_3 > & triangles,
|
|
const std::vector<bool> & in_I,
|
|
Eigen::PlainObjectBase<DerivedR>& R,
|
|
Eigen::PlainObjectBase<DerivedS>& S)
|
|
{
|
|
typedef typename Kernel::Point_3 Point_3;
|
|
typedef typename Kernel::Plane_3 Plane_3;
|
|
typedef typename Kernel::Segment_3 Segment_3;
|
|
typedef typename Kernel::Triangle_3 Triangle;
|
|
typedef typename std::vector<Triangle>::iterator Iterator;
|
|
typedef typename CGAL::AABB_triangle_primitive<Kernel, Iterator> Primitive;
|
|
typedef typename CGAL::AABB_traits<Kernel, Primitive> AABB_triangle_traits;
|
|
typedef typename CGAL::AABB_tree<AABB_triangle_traits> Tree;
|
|
|
|
if (F.rows() <= 0 || I.rows() <= 0) {
|
|
throw std::runtime_error(
|
|
"Closest facet cannot be computed on empty mesh.");
|
|
}
|
|
|
|
auto on_the_positive_side = [&](size_t fid, const Point_3& p) -> bool
|
|
{
|
|
const auto& f = F.row(fid).eval();
|
|
Point_3 v0(V(f[0], 0), V(f[0], 1), V(f[0], 2));
|
|
Point_3 v1(V(f[1], 0), V(f[1], 1), V(f[1], 2));
|
|
Point_3 v2(V(f[2], 0), V(f[2], 1), V(f[2], 2));
|
|
auto ori = CGAL::orientation(v0, v1, v2, p);
|
|
switch (ori) {
|
|
case CGAL::POSITIVE:
|
|
return true;
|
|
case CGAL::NEGATIVE:
|
|
return false;
|
|
case CGAL::COPLANAR:
|
|
// Warning:
|
|
// This can only happen if fid contains a boundary edge.
|
|
// Categorized this ambiguous case as negative side.
|
|
return false;
|
|
default:
|
|
throw std::runtime_error("Unknown CGAL state.");
|
|
}
|
|
return false;
|
|
};
|
|
|
|
auto get_orientation = [&](size_t fid, size_t s, size_t d) -> bool
|
|
{
|
|
const auto& f = F.row(fid);
|
|
if ((size_t)f[0] == s && (size_t)f[1] == d) return false;
|
|
else if ((size_t)f[1] == s && (size_t)f[2] == d) return false;
|
|
else if ((size_t)f[2] == s && (size_t)f[0] == d) return false;
|
|
else if ((size_t)f[0] == d && (size_t)f[1] == s) return true;
|
|
else if ((size_t)f[1] == d && (size_t)f[2] == s) return true;
|
|
else if ((size_t)f[2] == d && (size_t)f[0] == s) return true;
|
|
else {
|
|
throw std::runtime_error(
|
|
"Cannot compute orientation due to incorrect connectivity");
|
|
return false;
|
|
}
|
|
};
|
|
auto index_to_signed_index = [&](size_t index, bool ori) -> int{
|
|
return (index+1) * (ori? 1:-1);
|
|
};
|
|
//auto signed_index_to_index = [&](int signed_index) -> size_t {
|
|
// return abs(signed_index) - 1;
|
|
//};
|
|
|
|
enum ElementType { VERTEX, EDGE, FACE };
|
|
auto determine_element_type = [&](const Point_3& p, const size_t fid,
|
|
size_t& element_index) -> ElementType {
|
|
const auto& tri = triangles[fid];
|
|
const Point_3 p0 = tri[0];
|
|
const Point_3 p1 = tri[1];
|
|
const Point_3 p2 = tri[2];
|
|
|
|
if (p == p0) { element_index = 0; return VERTEX; }
|
|
if (p == p1) { element_index = 1; return VERTEX; }
|
|
if (p == p2) { element_index = 2; return VERTEX; }
|
|
if (CGAL::collinear(p0, p1, p)) { element_index = 2; return EDGE; }
|
|
if (CGAL::collinear(p1, p2, p)) { element_index = 0; return EDGE; }
|
|
if (CGAL::collinear(p2, p0, p)) { element_index = 1; return EDGE; }
|
|
|
|
element_index = 0;
|
|
return FACE;
|
|
};
|
|
|
|
auto process_edge_case = [&](
|
|
size_t query_idx,
|
|
const size_t s, const size_t d,
|
|
size_t preferred_facet,
|
|
bool& orientation) -> size_t
|
|
{
|
|
Point_3 query_point(
|
|
P(query_idx, 0),
|
|
P(query_idx, 1),
|
|
P(query_idx, 2));
|
|
|
|
size_t corner_idx = std::numeric_limits<size_t>::max();
|
|
if ((s == F(preferred_facet, 0) && d == F(preferred_facet, 1)) ||
|
|
(s == F(preferred_facet, 1) && d == F(preferred_facet, 0)))
|
|
{
|
|
corner_idx = 2;
|
|
} else if ((s == F(preferred_facet, 0) && d == F(preferred_facet, 2)) ||
|
|
(s == F(preferred_facet, 2) && d == F(preferred_facet, 0)))
|
|
{
|
|
corner_idx = 1;
|
|
} else if ((s == F(preferred_facet, 1) && d == F(preferred_facet, 2)) ||
|
|
(s == F(preferred_facet, 2) && d == F(preferred_facet, 1)))
|
|
{
|
|
corner_idx = 0;
|
|
} else
|
|
{
|
|
// Should never happen.
|
|
//std::cerr << "s: " << s << "\t d:" << d << std::endl;
|
|
//std::cerr << F.row(preferred_facet) << std::endl;
|
|
throw std::runtime_error(
|
|
"Invalid connectivity, edge does not belong to facet");
|
|
}
|
|
|
|
auto ueid = EMAP(preferred_facet + corner_idx * F.rows());
|
|
std::vector<size_t> intersected_face_indices;
|
|
//auto eids = uE2E[ueid];
|
|
//for (auto eid : eids)
|
|
for(size_t j = uEC(ueid);j<uEC(ueid+1);j++)
|
|
{
|
|
const size_t eid = uEE(j);
|
|
const size_t fid = eid % F.rows();
|
|
if (in_I[fid])
|
|
{
|
|
intersected_face_indices.push_back(fid);
|
|
}
|
|
}
|
|
|
|
const size_t num_intersected_faces = intersected_face_indices.size();
|
|
std::vector<int> intersected_face_signed_indices(num_intersected_faces);
|
|
std::transform(
|
|
intersected_face_indices.begin(),
|
|
intersected_face_indices.end(),
|
|
intersected_face_signed_indices.begin(),
|
|
[&](size_t index) {
|
|
return index_to_signed_index(
|
|
index, get_orientation(index, s,d));
|
|
});
|
|
|
|
assert(num_intersected_faces >= 1);
|
|
if (num_intersected_faces == 1)
|
|
{
|
|
// The edge must be a boundary edge. Thus, the orientation can be
|
|
// simply determined by checking if the query point is on the
|
|
// positive side of the facet.
|
|
const size_t fid = intersected_face_indices[0];
|
|
orientation = on_the_positive_side(fid, query_point);
|
|
return fid;
|
|
}
|
|
|
|
Eigen::VectorXi order;
|
|
PlainMatrix<DerivedP,1> pivot = P.row(query_idx).eval();
|
|
igl::copyleft::cgal::order_facets_around_edge(V, F, s, d,
|
|
intersected_face_signed_indices,
|
|
pivot, order);
|
|
|
|
// Although first and last are equivalent, make the choice based on
|
|
// preferred_facet.
|
|
const size_t first = order[0];
|
|
const size_t last = order[num_intersected_faces-1];
|
|
if (intersected_face_indices[first] == preferred_facet) {
|
|
orientation = intersected_face_signed_indices[first] < 0;
|
|
return intersected_face_indices[first];
|
|
} else if (intersected_face_indices[last] == preferred_facet) {
|
|
orientation = intersected_face_signed_indices[last] > 0;
|
|
return intersected_face_indices[last];
|
|
} else {
|
|
orientation = intersected_face_signed_indices[order[0]] < 0;
|
|
return intersected_face_indices[order[0]];
|
|
}
|
|
};
|
|
|
|
auto process_face_case = [&F,&I,&process_edge_case](
|
|
const size_t query_idx,
|
|
const size_t fid,
|
|
bool& orientation) -> size_t
|
|
{
|
|
const auto& f = F.row(I(fid, 0));
|
|
return process_edge_case(query_idx, f[0], f[1], I(fid, 0), orientation);
|
|
};
|
|
|
|
// Given that the closest point to query point P(query_idx,:) on (V,F(I,:))
|
|
// is the vertex at V(s,:) which is incident at least on triangle
|
|
// F(preferred_facet,:), determine a facet incident on V(s,:) that is
|
|
// _exposed_ to the query point and determine whether that facet is facing
|
|
// _toward_ or _away_ from the query point.
|
|
//
|
|
// Inputs:
|
|
// query_idx index into P of query point
|
|
// s index into V of closest point at vertex
|
|
// preferred_facet facet incident on s
|
|
// Outputs:
|
|
// orientation whether returned face is facing toward or away from
|
|
// query (parity unclear)
|
|
// Returns face guaranteed to be "exposed" to P(query_idx,:)
|
|
auto process_vertex_case = [&](
|
|
const size_t query_idx,
|
|
size_t s,
|
|
bool& orientation) -> size_t
|
|
{
|
|
const Point_3 query_point(
|
|
P(query_idx, 0), P(query_idx, 1), P(query_idx, 2));
|
|
const Point_3 closest_point(V(s, 0), V(s, 1), V(s, 2));
|
|
std::vector<size_t> adj_faces;
|
|
std::vector<size_t> adj_face_corners;
|
|
{
|
|
// Gather adj faces to s within I.
|
|
const auto& all_adj_faces = VF[s];
|
|
const auto& all_adj_face_corners = VFi[s];
|
|
const size_t num_all_adj_faces = all_adj_faces.size();
|
|
for (size_t i=0; i<num_all_adj_faces; i++)
|
|
{
|
|
const size_t fid = all_adj_faces[i];
|
|
// Shouldn't this always be true if I is a full connected component?
|
|
if (in_I[fid])
|
|
{
|
|
adj_faces.push_back(fid);
|
|
adj_face_corners.push_back(all_adj_face_corners[i]);
|
|
}
|
|
}
|
|
}
|
|
const size_t num_adj_faces = adj_faces.size();
|
|
assert(num_adj_faces > 0);
|
|
|
|
std::set<size_t> adj_vertices_set;
|
|
std::unordered_multimap<size_t, size_t> v2f;
|
|
for (size_t i=0; i<num_adj_faces; i++)
|
|
{
|
|
const size_t fid = adj_faces[i];
|
|
const size_t cid = adj_face_corners[i];
|
|
const auto& f = F.row(adj_faces[i]);
|
|
const size_t next = f[(cid+1)%3];
|
|
const size_t prev = f[(cid+2)%3];
|
|
adj_vertices_set.insert(next);
|
|
adj_vertices_set.insert(prev);
|
|
v2f.insert({{next, fid}, {prev, fid}});
|
|
}
|
|
const size_t num_adj_vertices = adj_vertices_set.size();
|
|
std::vector<size_t> adj_vertices(num_adj_vertices);
|
|
std::copy(adj_vertices_set.begin(), adj_vertices_set.end(),
|
|
adj_vertices.begin());
|
|
|
|
std::vector<Point_3> adj_points;
|
|
for (size_t vid : adj_vertices)
|
|
{
|
|
adj_points.emplace_back(V(vid,0), V(vid,1), V(vid,2));
|
|
}
|
|
|
|
// A plane is on the exterior if all adj_points lies on or to
|
|
// one side of the plane.
|
|
auto is_on_exterior = [&](const Plane_3& separator) -> bool{
|
|
size_t positive=0;
|
|
size_t negative=0;
|
|
for (const auto& point : adj_points) {
|
|
switch(separator.oriented_side(point)) {
|
|
case CGAL::ON_POSITIVE_SIDE:
|
|
positive++;
|
|
break;
|
|
case CGAL::ON_NEGATIVE_SIDE:
|
|
negative++;
|
|
break;
|
|
case CGAL::ON_ORIENTED_BOUNDARY:
|
|
break;
|
|
default:
|
|
throw "Unknown plane-point orientation";
|
|
}
|
|
}
|
|
auto query_orientation = separator.oriented_side(query_point);
|
|
if (query_orientation == CGAL::ON_ORIENTED_BOUNDARY &&
|
|
(positive == 0 && negative == 0)) {
|
|
// All adj vertices and query point are coplanar.
|
|
// In this case, all separators are equally valid.
|
|
return true;
|
|
} else {
|
|
bool r = (positive == 0 && query_orientation == CGAL::POSITIVE)
|
|
|| (negative == 0 && query_orientation == CGAL::NEGATIVE);
|
|
return r;
|
|
}
|
|
};
|
|
|
|
size_t d = std::numeric_limits<size_t>::max();
|
|
for (size_t i=0; i<num_adj_vertices; i++) {
|
|
const size_t vi = adj_vertices[i];
|
|
for (size_t j=i+1; j<num_adj_vertices; j++) {
|
|
Plane_3 separator(closest_point, adj_points[i], adj_points[j]);
|
|
if (separator.is_degenerate()) {
|
|
continue;
|
|
}
|
|
if (is_on_exterior(separator)) {
|
|
if (!CGAL::collinear(
|
|
query_point, adj_points[i], closest_point)) {
|
|
d = vi;
|
|
break;
|
|
} else {
|
|
d = adj_vertices[j];
|
|
assert(!CGAL::collinear(
|
|
query_point, adj_points[j], closest_point));
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (d == std::numeric_limits<size_t>::max()) {
|
|
//PlainMatrix<DerivedV,Eigen::Dynamic> tmp_vertices(V.rows(), V.cols());
|
|
//for (size_t i=0; i<V.rows(); i++) {
|
|
// for (size_t j=0; j<V.cols(); j++) {
|
|
// tmp_vertices(i,j) = CGAL::to_double(V(i,j));
|
|
// }
|
|
//}
|
|
//PlainMatrix<DerivedF,Eigen::Dynamic,3> tmp_faces(adj_faces.size(), 3);
|
|
//for (size_t i=0; i<adj_faces.size(); i++) {
|
|
// tmp_faces.row(i) = F.row(adj_faces[i]);
|
|
//}
|
|
//igl::writePLY("debug.ply", tmp_vertices, tmp_faces, false);
|
|
throw std::runtime_error("Invalid vertex neighborhood");
|
|
}
|
|
const auto itr = v2f.equal_range(d);
|
|
assert(itr.first != itr.second);
|
|
|
|
return process_edge_case(query_idx, s, d, itr.first->second, orientation);
|
|
};
|
|
|
|
const size_t num_queries = P.rows();
|
|
R.resize(num_queries, 1);
|
|
S.resize(num_queries, 1);
|
|
for (size_t i=0; i<num_queries; i++) {
|
|
const Point_3 query(P(i,0), P(i,1), P(i,2));
|
|
auto projection = tree.closest_point_and_primitive(query);
|
|
const Point_3 closest_point = projection.first;
|
|
size_t fid = projection.second - triangles.begin();
|
|
bool fid_ori = false;
|
|
|
|
// Gether all facets sharing the closest point.
|
|
typename std::vector<typename Tree::Primitive_id> intersected_faces;
|
|
tree.all_intersected_primitives(Segment_3(closest_point, query),
|
|
std::back_inserter(intersected_faces));
|
|
const size_t num_intersected_faces = intersected_faces.size();
|
|
std::vector<size_t> intersected_face_indices(num_intersected_faces);
|
|
std::transform(intersected_faces.begin(),
|
|
intersected_faces.end(),
|
|
intersected_face_indices.begin(),
|
|
[&](const typename Tree::Primitive_id& itr) -> size_t
|
|
{ return I(itr-triangles.begin(), 0); });
|
|
|
|
size_t element_index;
|
|
auto element_type = determine_element_type(closest_point, fid,
|
|
element_index);
|
|
switch(element_type) {
|
|
case VERTEX:
|
|
{
|
|
const auto& f = F.row(I(fid, 0));
|
|
const size_t s = f[element_index];
|
|
fid = process_vertex_case(i, s, fid_ori);
|
|
}
|
|
break;
|
|
case EDGE:
|
|
{
|
|
const auto& f = F.row(I(fid, 0));
|
|
const size_t s = f[(element_index+1)%3];
|
|
const size_t d = f[(element_index+2)%3];
|
|
fid = process_edge_case(i, s, d, I(fid, 0), fid_ori);
|
|
}
|
|
break;
|
|
case FACE:
|
|
{
|
|
fid = process_face_case(i, fid, fid_ori);
|
|
}
|
|
break;
|
|
default:
|
|
throw std::runtime_error("Unknown element type.");
|
|
}
|
|
|
|
|
|
R(i,0) = fid;
|
|
S(i,0) = fid_ori;
|
|
}
|
|
}
|
|
|
|
template<
|
|
typename DerivedV,
|
|
typename DerivedF,
|
|
typename DerivedI,
|
|
typename DerivedP,
|
|
typename DerivedEMAP,
|
|
typename DeriveduEC,
|
|
typename DeriveduEE,
|
|
typename DerivedR,
|
|
typename DerivedS >
|
|
IGL_INLINE void igl::copyleft::cgal::closest_facet(
|
|
const Eigen::MatrixBase<DerivedV>& V,
|
|
const Eigen::MatrixBase<DerivedF>& F,
|
|
const Eigen::MatrixBase<DerivedI>& I,
|
|
const Eigen::MatrixBase<DerivedP>& P,
|
|
const Eigen::MatrixBase<DerivedEMAP>& EMAP,
|
|
const Eigen::MatrixBase<DeriveduEC>& uEC,
|
|
const Eigen::MatrixBase<DeriveduEE>& uEE,
|
|
Eigen::PlainObjectBase<DerivedR>& R,
|
|
Eigen::PlainObjectBase<DerivedS>& S)
|
|
{
|
|
|
|
typedef CGAL::Exact_predicates_exact_constructions_kernel Kernel;
|
|
typedef Kernel::Triangle_3 Triangle;
|
|
typedef std::vector<Triangle>::iterator Iterator;
|
|
typedef CGAL::AABB_triangle_primitive<Kernel, Iterator> Primitive;
|
|
typedef CGAL::AABB_traits<Kernel, Primitive> AABB_triangle_traits;
|
|
typedef CGAL::AABB_tree<AABB_triangle_traits> Tree;
|
|
|
|
if (F.rows() <= 0 || I.rows() <= 0) {
|
|
throw std::runtime_error(
|
|
"Closest facet cannot be computed on empty mesh.");
|
|
}
|
|
|
|
std::vector<std::vector<size_t> > VF, VFi;
|
|
igl::vertex_triangle_adjacency(V.rows(), F, VF, VFi);
|
|
std::vector<bool> in_I;
|
|
std::vector<Triangle> triangles;
|
|
Tree tree;
|
|
submesh_aabb_tree(V,F,I,tree,triangles,in_I);
|
|
|
|
return closest_facet(
|
|
V,F,I,P,EMAP,uEC,uEE,VF,VFi,tree,triangles,in_I,R,S);
|
|
}
|
|
|
|
template<
|
|
typename DerivedV,
|
|
typename DerivedF,
|
|
typename DerivedP,
|
|
typename DerivedEMAP,
|
|
typename DeriveduEC,
|
|
typename DeriveduEE,
|
|
typename DerivedR,
|
|
typename DerivedS >
|
|
IGL_INLINE void igl::copyleft::cgal::closest_facet(
|
|
const Eigen::MatrixBase<DerivedV>& V,
|
|
const Eigen::MatrixBase<DerivedF>& F,
|
|
const Eigen::MatrixBase<DerivedP>& P,
|
|
const Eigen::MatrixBase<DerivedEMAP>& EMAP,
|
|
const Eigen::MatrixBase<DeriveduEC>& uEC,
|
|
const Eigen::MatrixBase<DeriveduEE>& uEE,
|
|
Eigen::PlainObjectBase<DerivedR>& R,
|
|
Eigen::PlainObjectBase<DerivedS>& S) {
|
|
const size_t num_faces = F.rows();
|
|
Eigen::VectorXi I = igl::LinSpaced<Eigen::VectorXi>(num_faces, 0, num_faces-1);
|
|
igl::copyleft::cgal::closest_facet(V, F, I, P, EMAP, uEC, uEE, R, S);
|
|
}
|
|
|
|
|
|
#ifdef IGL_STATIC_LIBRARY
|
|
// Explicit template instantiation
|
|
// generated by autoexplicit.sh
|
|
template void igl::copyleft::cgal::closest_facet<Eigen::Matrix<CGAL::Epeck::FT, -1, -1, 1, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, 1, 0, -1, 1>, Eigen::Matrix<CGAL::Epeck::FT, -1, 3, 1, -1, 3>, Eigen::Matrix<int, -1, 1, 0, -1, 1>, Eigen::Matrix<int, -1, 1, 0, -1, 1>, Eigen::Matrix<int, -1, 1, 0, -1, 1>, CGAL::Epeck, Eigen::Matrix<int, -1, 1, 0, -1, 1>, Eigen::Matrix<int, -1, 1, 0, -1, 1>>(Eigen::MatrixBase<Eigen::Matrix<CGAL::Epeck::FT, -1, -1, 1, -1, -1>> const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, -1, 0, -1, -1>> const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, 1, 0, -1, 1>> const&, Eigen::MatrixBase<Eigen::Matrix<CGAL::Epeck::FT, -1, 3, 1, -1, 3>> const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, 1, 0, -1, 1>> const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, 1, 0, -1, 1>> const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, 1, 0, -1, 1>> const&, std::vector<std::vector<size_t, std::allocator<size_t>>, std::allocator<std::vector<size_t, std::allocator<size_t>>>> const&, std::vector<std::vector<size_t, std::allocator<size_t>>, std::allocator<std::vector<size_t, std::allocator<size_t>>>> const&, CGAL::AABB_tree<CGAL::AABB_traits<CGAL::Epeck, CGAL::AABB_triangle_primitive<CGAL::Epeck, std::vector<CGAL::Epeck::Triangle_3, std::allocator<CGAL::Epeck::Triangle_3>>::iterator, CGAL::Boolean_tag<false>>, CGAL::Default>> const&, std::vector<CGAL::Epeck::Triangle_3, std::allocator<CGAL::Epeck::Triangle_3>> const&, std::vector<bool, std::allocator<bool>> const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1>>&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1>>&);
|
|
// generated by autoexplicit.sh
|
|
template void igl::copyleft::cgal::closest_facet<Eigen::Matrix<CGAL::Epeck::FT, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, 1, 0, -1, 1>, Eigen::Matrix<CGAL::Epeck::FT, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 1, 0, -1, 1>, Eigen::Matrix<int, -1, 1, 0, -1, 1>, Eigen::Matrix<int, -1, 1, 0, -1, 1>, CGAL::Epeck, Eigen::Matrix<int, -1, 1, 0, -1, 1>, Eigen::Matrix<int, -1, 1, 0, -1, 1>>(Eigen::MatrixBase<Eigen::Matrix<CGAL::Epeck::FT, -1, -1, 0, -1, -1>> const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, -1, 0, -1, -1>> const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, 1, 0, -1, 1>> const&, Eigen::MatrixBase<Eigen::Matrix<CGAL::Epeck::FT, -1, 3, 0, -1, 3>> const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, 1, 0, -1, 1>> const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, 1, 0, -1, 1>> const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, 1, 0, -1, 1>> const&, std::vector<std::vector<size_t, std::allocator<size_t>>, std::allocator<std::vector<size_t, std::allocator<size_t>>>> const&, std::vector<std::vector<size_t, std::allocator<size_t>>, std::allocator<std::vector<size_t, std::allocator<size_t>>>> const&, CGAL::AABB_tree<CGAL::AABB_traits<CGAL::Epeck, CGAL::AABB_triangle_primitive<CGAL::Epeck, std::vector<CGAL::Epeck::Triangle_3, std::allocator<CGAL::Epeck::Triangle_3>>::iterator, CGAL::Boolean_tag<false>>, CGAL::Default>> const&, std::vector<CGAL::Epeck::Triangle_3, std::allocator<CGAL::Epeck::Triangle_3>> const&, std::vector<bool, std::allocator<bool>> const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1>>&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1>>&);
|
|
// generated by autoexplicit.sh
|
|
template void igl::copyleft::cgal::closest_facet<Eigen::Matrix<CGAL::Epeck::FT, -1, -1, 1, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, 1, 0, -1, 1>, Eigen::Matrix<CGAL::Epeck::FT, -1, -1, 1, -1, -1>, Eigen::Matrix<int, -1, 1, 0, -1, 1>, Eigen::Matrix<int, -1, 1, 0, -1, 1>, Eigen::Matrix<int, -1, 1, 0, -1, 1>, CGAL::Epeck, Eigen::Matrix<int, -1, 1, 0, -1, 1>, Eigen::Matrix<int, -1, 1, 0, -1, 1> >(
|
|
Eigen::MatrixBase<Eigen::Matrix<CGAL::Epeck::FT, -1, -1, 1, -1, -1> > const&,
|
|
Eigen::MatrixBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&,
|
|
Eigen::MatrixBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> > const&,
|
|
Eigen::MatrixBase<Eigen::Matrix<CGAL::Epeck::FT, -1, -1, 1, -1, -1> > const&,
|
|
Eigen::MatrixBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> > const&,
|
|
Eigen::MatrixBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> > const&,
|
|
Eigen::MatrixBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> > const&, std::vector<std::vector<size_t, std::allocator<size_t> >, std::allocator<std::vector<size_t, std::allocator<size_t> > > > const&, std::vector<std::vector<size_t, std::allocator<size_t> >, std::allocator<std::vector<size_t, std::allocator<size_t> > > > const&, CGAL::AABB_tree<CGAL::AABB_traits<CGAL::Epeck, CGAL::AABB_triangle_primitive<CGAL::Epeck, std::vector<CGAL::Epeck::Triangle_3, std::allocator<CGAL::Epeck::Triangle_3> >::iterator, CGAL::Boolean_tag<false> >, CGAL::Default> > const&, std::vector<CGAL::Epeck::Triangle_3, std::allocator<CGAL::Epeck::Triangle_3> > const&, std::vector<bool, std::allocator<bool> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&);
|
|
#include <cstdint>
|
|
template void igl::copyleft::cgal::closest_facet<Eigen::Matrix<CGAL::Epeck::FT, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, 1, 0, -1, 1>, Eigen::Matrix<CGAL::Epeck::FT, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, 1, 0, -1, 1>, Eigen::Matrix<int, -1, 1, 0, -1, 1>, Eigen::Matrix<int, -1, 1, 0, -1, 1>, CGAL::Epeck, Eigen::Matrix<int, -1, 1, 0, -1, 1>, Eigen::Matrix<int, -1, 1, 0, -1, 1> >(
|
|
Eigen::MatrixBase<Eigen::Matrix<CGAL::Epeck::FT, -1, -1, 0, -1, -1> > const&,
|
|
Eigen::MatrixBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&,
|
|
Eigen::MatrixBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> > const&,
|
|
Eigen::MatrixBase<Eigen::Matrix<CGAL::Epeck::FT, -1, -1, 0, -1, -1> > const&,
|
|
Eigen::MatrixBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> > const&,
|
|
Eigen::MatrixBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> > const&,
|
|
Eigen::MatrixBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> > const&, std::vector<std::vector<size_t, std::allocator<size_t> >, std::allocator<std::vector<size_t, std::allocator<size_t> > > > const&, std::vector<std::vector<size_t, std::allocator<size_t> >, std::allocator<std::vector<size_t, std::allocator<size_t> > > > const&, CGAL::AABB_tree<CGAL::AABB_traits<CGAL::Epeck, CGAL::AABB_triangle_primitive<CGAL::Epeck, std::vector<CGAL::Epeck::Triangle_3, std::allocator<CGAL::Epeck::Triangle_3> >::iterator, CGAL::Boolean_tag<false> >, CGAL::Default> > const&, std::vector<CGAL::Epeck::Triangle_3, std::allocator<CGAL::Epeck::Triangle_3> > const&, std::vector<bool, std::allocator<bool> > const&,
|
|
Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&,
|
|
Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&);
|
|
|
|
#endif
|