فهرست منبع

Remove unused code and throw exception instead of asserting false.

Former-commit-id: 44597402d0bdb6a03dd123b2e0b0b0589742e561
Qingnan Zhou 9 سال پیش
والد
کامیت
8b211a343b
2فایلهای تغییر یافته به همراه11 افزوده شده و 10 حذف شده
  1. 0 6
      include/igl/cgal/closest_facet.cpp
  2. 11 4
      include/igl/cgal/order_facets_around_edge.cpp

+ 0 - 6
include/igl/cgal/closest_facet.cpp

@@ -153,12 +153,6 @@ IGL_INLINE void igl::cgal::closest_facet(
 
         Eigen::VectorXi order;
         DerivedP pivot = P.row(query_idx).eval();
-        auto get_opposite_vertex = [&](size_t fid) {
-            const auto& f = F.row(fid);
-            if (f[0] != s && f[0] != d) return V.row(f[0]).eval();
-            if (f[1] != s && f[1] != d) return V.row(f[1]).eval();
-            if (f[2] != s && f[2] != d) return V.row(f[2]).eval();
-        };
         igl::cgal::order_facets_around_edge(V, F, s, d,
                 intersected_face_signed_indices,
                 pivot, order);

+ 11 - 4
include/igl/cgal/order_facets_around_edge.cpp

@@ -1,6 +1,8 @@
 #include "order_facets_around_edge.h"
 #include <CGAL/Exact_predicates_exact_constructions_kernel.h>
 
+#include <stdexcept>
+
 namespace igl
 {
     namespace cgal
@@ -131,7 +133,10 @@ void igl::cgal::order_facets_around_edge(
     const Point_3 p_d(V(d, 0), V(d, 1), V(d, 2));
     const Point_3 p_o(V(o, 0), V(o, 1), V(o, 2));
     const Plane_3 separator(p_s, p_d, p_o);
-    assert(!separator.is_degenerate());
+    if (separator.is_degenerate()) {
+        throw std::runtime_error(
+                "Cannot order facets around edge due to degenerated facets");
+    }
 
     std::vector<Point_3> opposite_vertices;
     for (size_t i=0; i<num_adj_faces; i++)
@@ -180,14 +185,15 @@ void igl::cgal::order_facets_around_edge(
                             break;
                         case CGAL::COLLINEAR:
                         default:
-                            assert(false);
+                            throw std::runtime_error(
+                                    "Degenerated facet detected.");
                             break;
                     }
                 }
                 break;
             default:
                 // Should not be here.
-                assert(false);
+                throw std::runtime_error("Unknown CGAL state detected.");
         }
     }
 
@@ -304,7 +310,8 @@ void igl::cgal::order_facets_around_edge(
         K::Point_3 pd(V(d,0), V(d,1), V(d,2));
         K::Point_3 pp(pivot_point(0,0), pivot_point(0,1), pivot_point(0,2));
         if (CGAL::collinear(ps, pd, pp)) {
-            throw "Pivot point is collinear with the outer edge!";
+            throw std::runtime_error(
+                    "Pivot point is collinear with the outer edge!");
         }
     }