Quellcode durchsuchen

Merge pull request #1057 from libigl/PR_fix_mesh_to_polyhedron

Bug fix: mesh_to_polyhedron compiles
Alec Jacobson vor 6 Jahren
Ursprung
Commit
f140e63649

+ 7 - 7
include/igl/copyleft/cgal/mesh_to_polyhedron.cpp

@@ -10,12 +10,14 @@
 #include <CGAL/Polyhedron_incremental_builder_3.h>
 
 template <
-	typename Polyhedron,
-	typename DerivedV,
-	typename DerivedF>
+  typename DerivedV,
+  typename DerivedF,
+  typename Polyhedron>
 IGL_INLINE bool igl::copyleft::cgal::mesh_to_polyhedron(
-    const Eigen::MatrixBase<DerivedV>& V, const Eigen::MatrixBase<DerivedF>& F,
-    Polyhedron& poly) {
+  const Eigen::MatrixBase<DerivedV>& V, 
+  const Eigen::MatrixBase<DerivedF>& F,
+  Polyhedron& poly) 
+{
   typedef typename Polyhedron::HalfedgeDS HalfedgeDS;
   // Postcondition: hds is a valid polyhedral surface.
   CGAL::Polyhedron_incremental_builder_3<HalfedgeDS> B(poly.hds());
@@ -50,6 +52,4 @@ IGL_INLINE bool igl::copyleft::cgal::mesh_to_polyhedron(
 // Explicit template instantiation
 #include <CGAL/Simple_cartesian.h>
 #include <CGAL/Polyhedron_items_with_id_3.h>
-template bool igl::copyleft::cgal::mesh_to_polyhedron<CGAL::Polyhedron_3<CGAL::Simple_cartesian<double>, CGAL::Polyhedron_items_with_id_3, CGAL::HalfedgeDS_default, std::allocator<int> > >(Eigen::Matrix<double, -1, -1, 0, -1, -1> const&, Eigen::Matrix<int, -1, -1, 0, -1, -1> const&, CGAL::Polyhedron_3<CGAL::Simple_cartesian<double>, CGAL::Polyhedron_items_with_id_3, CGAL::HalfedgeDS_default, std::allocator<int> >&);
-template bool igl::copyleft::cgal::mesh_to_polyhedron<CGAL::Polyhedron_3<CGAL::Simple_cartesian<float>, CGAL::Polyhedron_items_with_id_3, CGAL::HalfedgeDS_default, std::allocator<int> > >(Eigen::Matrix<float, -1, -1, 0, -1, -1> const&, Eigen::Matrix<int, -1, -1, 0, -1, -1> const&, CGAL::Polyhedron_3<CGAL::Simple_cartesian<float>, CGAL::Polyhedron_items_with_id_3, CGAL::HalfedgeDS_default, std::allocator<int> >&);
 #endif

+ 3 - 3
include/igl/copyleft/cgal/mesh_to_polyhedron.h

@@ -28,9 +28,9 @@ namespace igl
       // Returns true only if (V,F) can be converted to a valid polyhedron (i.e. if
       // (V,F) is vertex and edge manifold).
       template <
-		  typename Polyhedron,
-		  typename DerivedV,
-		  typename DerivedF>
+        typename DerivedV,
+        typename DerivedF,
+        typename Polyhedron>
       IGL_INLINE bool mesh_to_polyhedron(
         const Eigen::MatrixBase<DerivedV> & V,
         const Eigen::MatrixBase<DerivedF> & F,

+ 41 - 0
tests/include/igl/copyleft/cgal/mesh_to_polyhedron.cpp

@@ -0,0 +1,41 @@
+#include <test_common.h>
+#include <igl/copyleft/cgal/mesh_to_polyhedron.h>
+#include <CGAL/Simple_cartesian.h>
+#include <CGAL/Polyhedron_items_with_id_3.h>
+
+TEST_CASE(
+  "igl_copyleft_cgal_mesh_to_polyhedron: positive",
+  "[igl/copyleft/cgal/]")
+{
+  const auto test_case = [](const std::string &param)
+  {
+    Eigen::MatrixXd V;
+    Eigen::MatrixXi F;
+    test_common::load_mesh(param, V, F);
+    CGAL::Polyhedron_3<
+      CGAL::Simple_cartesian<double>, 
+      CGAL::Polyhedron_items_with_id_3, 
+      CGAL::HalfedgeDS_default, 
+      std::allocator<int> > 
+      poly;
+    REQUIRE ( igl::copyleft::cgal::mesh_to_polyhedron(V,F,poly) );
+  };
+
+  test_common::run_test_cases(test_common::manifold_meshes(), test_case);
+}
+
+TEST_CASE(
+  "igl_copyleft_cgal_mesh_to_polyhedron: negative",
+  "[igl/copyleft/cgal/]")
+{
+  Eigen::MatrixXd V;
+  Eigen::MatrixXi F;
+  test_common::load_mesh("truck.obj", V, F);
+  CGAL::Polyhedron_3<
+    CGAL::Simple_cartesian<double>, 
+    CGAL::Polyhedron_items_with_id_3, 
+    CGAL::HalfedgeDS_default, 
+    std::allocator<int> > 
+    poly;
+  REQUIRE (! igl::copyleft::cgal::mesh_to_polyhedron(V,F,poly) );
+}