Replace stop criterion with split criterion

This commit is contained in:
Jackson Campolattaro 2020-06-20 19:51:16 -04:00
parent ed1395d63b
commit cdd3ad38ff
2 changed files with 15 additions and 26 deletions

View File

@ -23,7 +23,7 @@
#define CGAL_OCTREE_3_H
#include <CGAL/Octree/Octree_node.h>
#include <CGAL/Octree/Stop_criterion.h>
#include <CGAL/Octree/Split_criterion.h>
#include <CGAL/bounding_box.h>
#include <boost/iterator/transform_iterator.hpp>
@ -128,7 +128,7 @@ namespace CGAL {
m_root.unsplit();
}
void refine(std::function<bool(const Node &)> stop_criterion) {
void refine(std::function<bool(const Node &)> split_criterion) {
// create a side length map
for (int i = 0; i <= (int) 10; i++)
@ -147,7 +147,7 @@ namespace CGAL {
int depth = current->depth();
// Check if this node needs to be processed
if (!stop_criterion(*current)) {
if (split_criterion(*current)) {
// Split this node
current->split();
@ -164,7 +164,7 @@ namespace CGAL {
}
void refine(size_t max_depth, size_t bucket_size) {
refine(Stop_at_max_depth_or_bucket_size(max_depth, bucket_size));
refine(Split_to_max_depth_or_bucket_size(max_depth, bucket_size));
}
Node &root() { return m_root; }

View File

@ -1,50 +1,39 @@
#ifndef OCTREE_STOP_CRITERION_H
#define OCTREE_STOP_CRITERION_H
#ifndef OCTREE_SPLIT_CRITERION_H
#define OCTREE_SPLIT_CRITERION_H
#include <iostream>
namespace CGAL {
struct Stop_at_max_depth_or_bucket_size {
struct Split_to_max_depth_or_bucket_size {
std::size_t m_max_depth, m_bucket_size;
Stop_at_max_depth_or_bucket_size(std::size_t max_depth, std::size_t bucket_size) :
Split_to_max_depth_or_bucket_size(std::size_t max_depth, std::size_t bucket_size) :
m_max_depth(max_depth), m_bucket_size(bucket_size) {}
template<class Node>
bool operator()(const Node &n) const {
return (n.num_points() <= m_bucket_size || n.depth() == m_max_depth);
return (n.num_points() > m_bucket_size && n.depth() < m_max_depth);
}
};
struct Stop_at_max_depth {
struct Split_to_max_depth {
std::size_t m_max_depth;
Stop_at_max_depth(std::size_t max_depth) : m_max_depth(max_depth) {}
Split_to_max_depth(std::size_t max_depth) : m_max_depth(max_depth) {}
template<class Node>
bool operator()(const Node &n) const {
return n.depth() == m_max_depth;
return n.depth() < m_max_depth;
}
};
}
/*
struct Stop_at_max_number_of_points {
std::size_t max_nb_points;
Stop_at_max_number_of_points(const std::size_t &max_nb_points)
: max_nb_points(max_nb_points) {}
bool operator()(const Node &n) const {
return n.number_of_points() // internally, the node can use std::distance(begin, end)
< max_nb_points;
}
};
// Just for an example using outside info (like a normal map)
// The normals remain unknown to the octree but are used for construction
struct Stop_at_normal_deviation {
@ -71,4 +60,4 @@ struct Stop_at_normal_deviation {
*/
#endif //OCTREE_STOP_CRITERION_H
#endif //OCTREE_SPLIT_CRITERION_H