|
@@ -10,6 +10,7 @@
|
|
|
#include "flip_edge.h"
|
|
|
#include "lexicographic_triangulation.h"
|
|
|
#include "unique_edge_map.h"
|
|
|
+#include "is_delaunay.h"
|
|
|
|
|
|
#include <vector>
|
|
|
#include <sstream>
|
|
@@ -20,9 +21,9 @@ template<
|
|
|
typename InCircle,
|
|
|
typename DerivedF>
|
|
|
IGL_INLINE void igl::delaunay_triangulation(
|
|
|
- const Eigen::PlainObjectBase<DerivedV>& V,
|
|
|
- Orient2D orient2D,
|
|
|
- InCircle incircle,
|
|
|
+ const Eigen::MatrixBase<DerivedV>& V,
|
|
|
+ const Orient2D orient2D,
|
|
|
+ const InCircle incircle,
|
|
|
Eigen::PlainObjectBase<DerivedF>& F)
|
|
|
{
|
|
|
assert(V.cols() == 2);
|
|
@@ -36,43 +37,18 @@ IGL_INLINE void igl::delaunay_triangulation(
|
|
|
}
|
|
|
assert(F.cols() == 3);
|
|
|
|
|
|
- Eigen::MatrixXi E;
|
|
|
- Eigen::MatrixXi uE;
|
|
|
+ typedef Eigen::Matrix<typename DerivedF::Scalar,Eigen::Dynamic,2> MatrixX2I;
|
|
|
+ MatrixX2I E,uE;
|
|
|
Eigen::VectorXi EMAP;
|
|
|
std::vector<std::vector<Index> > uE2E;
|
|
|
igl::unique_edge_map(F, E, uE, EMAP, uE2E);
|
|
|
|
|
|
- auto is_delaunay = [&V,&F,&uE2E,num_faces,&incircle](size_t uei) {
|
|
|
- auto& half_edges = uE2E[uei];
|
|
|
- if (half_edges.size() != 2) {
|
|
|
- throw "Cannot flip non-manifold or boundary edge";
|
|
|
- }
|
|
|
-
|
|
|
- const size_t f1 = half_edges[0] % num_faces;
|
|
|
- const size_t f2 = half_edges[1] % num_faces;
|
|
|
- const size_t c1 = half_edges[0] / num_faces;
|
|
|
- const size_t c2 = half_edges[1] / num_faces;
|
|
|
- assert(c1 < 3);
|
|
|
- assert(c2 < 3);
|
|
|
- assert(f1 != f2);
|
|
|
- const size_t v1 = F(f1, (c1+1)%3);
|
|
|
- const size_t v2 = F(f1, (c1+2)%3);
|
|
|
- const size_t v4 = F(f1, c1);
|
|
|
- const size_t v3 = F(f2, c2);
|
|
|
- const Scalar p1[] = {V(v1, 0), V(v1, 1)};
|
|
|
- const Scalar p2[] = {V(v2, 0), V(v2, 1)};
|
|
|
- const Scalar p3[] = {V(v3, 0), V(v3, 1)};
|
|
|
- const Scalar p4[] = {V(v4, 0), V(v4, 1)};
|
|
|
- auto orientation = incircle(p1, p2, p4, p3);
|
|
|
- return orientation <= 0;
|
|
|
- };
|
|
|
-
|
|
|
bool all_delaunay = false;
|
|
|
while(!all_delaunay) {
|
|
|
all_delaunay = true;
|
|
|
for (size_t i=0; i<uE2E.size(); i++) {
|
|
|
if (uE2E[i].size() == 2) {
|
|
|
- if (!is_delaunay(i)) {
|
|
|
+ if (!is_delaunay(V,F,uE2E,incircle,i)) {
|
|
|
all_delaunay = false;
|
|
|
flip_edge(F, E, uE, EMAP, uE2E, i);
|
|
|
}
|
|
@@ -82,8 +58,9 @@ IGL_INLINE void igl::delaunay_triangulation(
|
|
|
}
|
|
|
|
|
|
#ifdef IGL_STATIC_LIBRARY
|
|
|
-template void igl::delaunay_triangulation<Eigen::Matrix<double, -1, -1, 0, -1, -1>, short (*)(double const*, double const*, double const*), short (*)(double const*, double const*, double const*, double const*), Eigen::Matrix<int, -1, -1, 0, -1, -1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, short (*)(double const*, double const*, double const*), short (*)(double const*, double const*, double const*, double const*), Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&);
|
|
|
+// Explicit template instantiation
|
|
|
+template void igl::delaunay_triangulation<Eigen::Matrix<double, -1, -1, 0, -1, -1>, short (*)(double const*, double const*, double const*), short (*)(double const*, double const*, double const*, double const*), Eigen::Matrix<int, -1, -1, 0, -1, -1> >(Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, short (*)(double const*, double const*, double const*), short (*)(double const*, double const*, double const*, double const*), Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&);
|
|
|
#ifdef WIN32
|
|
|
-template void igl::delaunay_triangulation<Eigen::Matrix<double, -1, -1, 0, -1, -1>, short (*)(double const * const, double const * const, double const * const), short(*)(double const * const, double const * const, double const * const, double const * const), Eigen::Matrix<int, -1, -1, 0, -1, -1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const &, short(*)(double const * const, double const * const, double const * const), short(*)(double const * const, double const * const, double const * const, double const * const), Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > &);
|
|
|
+template void igl::delaunay_triangulation<Eigen::Matrix<double, -1, -1, 0, -1, -1>, short (*)(double const * const, double const * const, double const * const), short(*)(double const * const, double const * const, double const * const, double const * const), Eigen::Matrix<int, -1, -1, 0, -1, -1> >(Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const &, short(*)(double const * const, double const * const, double const * const), short(*)(double const * const, double const * const, double const * const, double const * const), Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > &);
|
|
|
+#endif
|
|
|
#endif
|
|
|
-#endif
|