mirror of https://github.com/CGAL/cgal
correctly handling wrong values in new classes
This commit is contained in:
parent
c018af84bf
commit
d82ca437c4
|
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
#include <CGAL/license/Shape_detection.h>
|
#include <CGAL/license/Shape_detection.h>
|
||||||
|
|
||||||
|
#include <cmath>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include <CGAL/assertions.h>
|
#include <CGAL/assertions.h>
|
||||||
|
|
@ -218,6 +219,10 @@ public:
|
||||||
if (indices.size() < 6)
|
if (indices.size() < 6)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
// TODO: Why do we get so many nan in this class?
|
||||||
|
if (std::isnan(m_radius))
|
||||||
|
return false;
|
||||||
|
|
||||||
// If radius is out of bound, nothing fits, early ending
|
// If radius is out of bound, nothing fits, early ending
|
||||||
if (m_radius < m_min_radius || m_radius > m_max_radius)
|
if (m_radius < m_min_radius || m_radius > m_max_radius)
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -226,16 +231,22 @@ public:
|
||||||
const Point_2& query_point = get(m_point_map, key);
|
const Point_2& query_point = get(m_point_map, key);
|
||||||
Vector_2 normal = get(m_normal_map, key);
|
Vector_2 normal = get(m_normal_map, key);
|
||||||
|
|
||||||
FT distance_to_center = m_sqrt(m_squared_distance_2 (query_point, m_center));
|
const FT sq_dist = m_squared_distance_2(query_point, m_center);
|
||||||
|
if (std::isnan(sq_dist)) return false;
|
||||||
|
FT distance_to_center = m_sqrt (sq_dist);
|
||||||
FT distance_to_circle = CGAL::abs (distance_to_center - m_radius);
|
FT distance_to_circle = CGAL::abs (distance_to_center - m_radius);
|
||||||
|
|
||||||
if (distance_to_circle > m_distance_threshold)
|
if (distance_to_circle > m_distance_threshold)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
normal = normal / m_sqrt (normal * normal);
|
const FT sq_norm = normal * normal;
|
||||||
|
if (std::isnan(sq_norm)) return false;
|
||||||
|
normal = normal / m_sqrt (sq_norm);
|
||||||
|
|
||||||
Vector_2 ray (m_center, query_point);
|
Vector_2 ray (m_center, query_point);
|
||||||
ray = ray / m_sqrt (ray * ray);
|
const FT sq_ray = ray * ray;
|
||||||
|
if (std::isnan(sq_ray)) return false;
|
||||||
|
ray = ray / m_sqrt (sq_ray);
|
||||||
|
|
||||||
if (CGAL::abs (normal * ray) < m_normal_threshold)
|
if (CGAL::abs (normal * ray) < m_normal_threshold)
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
#include <CGAL/license/Shape_detection.h>
|
#include <CGAL/license/Shape_detection.h>
|
||||||
|
|
||||||
|
#include <cmath>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include <CGAL/assertions.h>
|
#include <CGAL/assertions.h>
|
||||||
|
|
@ -218,6 +219,7 @@ public:
|
||||||
if (indices.size() < 6)
|
if (indices.size() < 6)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
// TODO: Why do we get so many nan in this class?
|
||||||
if (std::isnan(m_radius))
|
if (std::isnan(m_radius))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
@ -232,17 +234,23 @@ public:
|
||||||
// TODO: Why do we have m_axis = 0 here sometimes?
|
// TODO: Why do we have m_axis = 0 here sometimes?
|
||||||
// Should it ever happen?
|
// Should it ever happen?
|
||||||
if (m_axis.to_vector() == Vector_3(0, 0, 0)) return false;
|
if (m_axis.to_vector() == Vector_3(0, 0, 0)) return false;
|
||||||
FT distance_to_center = m_sqrt(m_squared_distance_3 (query_point, m_axis));
|
const FT sq_dist = m_squared_distance_3(query_point, m_axis);
|
||||||
|
if (std::isnan(sq_dist)) return false;
|
||||||
|
FT distance_to_center = m_sqrt (sq_dist);
|
||||||
FT distance_to_cylinder = CGAL::abs (distance_to_center - m_radius);
|
FT distance_to_cylinder = CGAL::abs (distance_to_center - m_radius);
|
||||||
|
|
||||||
if (distance_to_cylinder > m_distance_threshold)
|
if (distance_to_cylinder > m_distance_threshold)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
normal = normal / m_sqrt (normal * normal);
|
const FT sq_norm = normal * normal;
|
||||||
|
if (std::isnan(sq_norm)) return false;
|
||||||
|
normal = normal / m_sqrt (sq_norm);
|
||||||
|
|
||||||
Point_3 proj = m_axis.projection(query_point);
|
Point_3 proj = m_axis.projection(query_point);
|
||||||
Vector_3 ray (proj, query_point);
|
Vector_3 ray (proj, query_point);
|
||||||
ray = ray / m_sqrt (ray * ray);
|
const FT sq_ray = ray * ray;
|
||||||
|
if (std::isnan(sq_ray)) return false;
|
||||||
|
ray = ray / m_sqrt (sq_ray);
|
||||||
|
|
||||||
if (CGAL::abs (normal * ray) < m_normal_threshold)
|
if (CGAL::abs (normal * ray) < m_normal_threshold)
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
#include <CGAL/license/Shape_detection.h>
|
#include <CGAL/license/Shape_detection.h>
|
||||||
|
|
||||||
|
#include <cmath>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include <CGAL/assertions.h>
|
#include <CGAL/assertions.h>
|
||||||
|
|
@ -224,6 +225,10 @@ public:
|
||||||
if (indices.size() < 6)
|
if (indices.size() < 6)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
// TODO: Why do we get so many nan in this class?
|
||||||
|
if (std::isnan(m_radius))
|
||||||
|
return false;
|
||||||
|
|
||||||
// If radius is out of bound, nothing fits, early ending
|
// If radius is out of bound, nothing fits, early ending
|
||||||
if (m_radius < m_min_radius || m_radius > m_max_radius)
|
if (m_radius < m_min_radius || m_radius > m_max_radius)
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -232,16 +237,22 @@ public:
|
||||||
const Point_3& query_point = get(m_point_map, key);
|
const Point_3& query_point = get(m_point_map, key);
|
||||||
Vector_3 normal = get(m_normal_map, key);
|
Vector_3 normal = get(m_normal_map, key);
|
||||||
|
|
||||||
FT distance_to_center = m_sqrt(m_squared_distance_3 (query_point, m_center));
|
const FT sq_dist = m_squared_distance_3(query_point, m_center);
|
||||||
|
if (std::isnan(sq_dist)) return false;
|
||||||
|
FT distance_to_center = m_sqrt (sq_dist);
|
||||||
FT distance_to_sphere = CGAL::abs (distance_to_center - m_radius);
|
FT distance_to_sphere = CGAL::abs (distance_to_center - m_radius);
|
||||||
|
|
||||||
if (distance_to_sphere > m_distance_threshold)
|
if (distance_to_sphere > m_distance_threshold)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
normal = normal / m_sqrt (normal * normal);
|
const FT sq_norm = normal * normal;
|
||||||
|
if (std::isnan(sq_norm)) return false;
|
||||||
|
normal = normal / m_sqrt (sq_norm);
|
||||||
|
|
||||||
Vector_3 ray (m_center, query_point);
|
Vector_3 ray (m_center, query_point);
|
||||||
ray = ray / m_sqrt (ray * ray);
|
const FT sq_ray = ray * ray;
|
||||||
|
if (std::isnan(sq_ray)) return false;
|
||||||
|
ray = ray / m_sqrt (sq_ray);
|
||||||
|
|
||||||
if (CGAL::abs (normal * ray) < m_normal_threshold)
|
if (CGAL::abs (normal * ray) < m_normal_threshold)
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue