diff --git a/Shape_detection/include/CGAL/Shape_detection/Efficient_RANSAC/Efficient_RANSAC.h b/Shape_detection/include/CGAL/Shape_detection/Efficient_RANSAC/Efficient_RANSAC.h index 8b13c5333b5..a97ecb80df7 100644 --- a/Shape_detection/include/CGAL/Shape_detection/Efficient_RANSAC/Efficient_RANSAC.h +++ b/Shape_detection/include/CGAL/Shape_detection/Efficient_RANSAC/Efficient_RANSAC.h @@ -561,11 +561,13 @@ public: do { do { - - first_sample = get_default_random()( - static_cast(m_num_available_points)); + first_sample = get_default_random()(static_cast(m_num_available_points)); } while (m_shape_index[first_sample] != -1); - std::cerr << first_sample << std::endl; + std::cerr << "first sample: " << first_sample << std::endl; + std::cerr << "point index: " << *(m_input_iterator_first + first_sample) << std::endl; + + auto point = get(m_point_pmap, + *(m_input_iterator_first + first_sample)); done = drawSamplesFromCellContainingPoint(m_global_octree, @@ -576,8 +578,6 @@ public: m_shape_index, required_samples); - std::cerr << m_shape_index[first_sample] << std::endl; - if (callback && !callback(num_invalid / double(m_num_total_points))) return false; @@ -1121,6 +1121,8 @@ private: const std::vector &shapeIndex, std::size_t requiredSamples) { + std::cerr << " point: " << p << std::endl; + typedef typename Octree::Node Cell; const Cell *cur = node_containing_point(octree, p, level); diff --git a/Shape_detection/include/CGAL/Shape_detection/Efficient_RANSAC/Octree.h b/Shape_detection/include/CGAL/Shape_detection/Efficient_RANSAC/Octree.h index 7cf5cb259e7..dcaa922098c 100644 --- a/Shape_detection/include/CGAL/Shape_detection/Efficient_RANSAC/Octree.h +++ b/Shape_detection/include/CGAL/Shape_detection/Efficient_RANSAC/Octree.h @@ -135,6 +135,7 @@ class Indexed_octree { typedef typename Traits::Input_range::iterator Input_iterator; typedef typename Traits::Point_map Point_map; + typedef typename Traits::FT FT; typedef std::vector Input_range; typedef Point_map_to_indexed_point_map Indexed_point_map; @@ -177,7 +178,21 @@ public: void refine(double cluster_epsilon_for_max_level_recomputation = -1., std::size_t bucketSize = 2, std::size_t maxLevel = 10) { - // TODO: I need to find out what cluster_epsilon is used for + if (cluster_epsilon_for_max_level_recomputation > 0.) { + + auto m_bBox = m_octree.bbox(m_octree.root()); + + FT bbox_diagonal = (FT) CGAL::sqrt( + (m_bBox.xmax() - m_bBox.xmin()) * (m_bBox.xmax() - m_bBox.xmin()) + + (m_bBox.ymax() - m_bBox.ymin()) * (m_bBox.ymax() - m_bBox.ymin()) + + (m_bBox.zmax() - m_bBox.zmin()) * (m_bBox.zmax() - m_bBox.zmin())); + + maxLevel = std::size_t(std::log(bbox_diagonal + / cluster_epsilon_for_max_level_recomputation) + / std::log(2.0)); + + } + m_octree.refine(maxLevel, bucketSize); }