added wlop default parameters, estimate default neighborhood radius

This commit is contained in:
Shihao Wu 2013-08-28 10:45:42 +08:00
parent 34b13cefc2
commit 4da24d2c1c
2 changed files with 45 additions and 20 deletions

View File

@ -15,8 +15,8 @@ typedef Kernel::Point_3 Point;
int main(void)
{
//const std::string INPUT_FILENAME_WITHOUT_EXT = "data/sphere_20k";
const std::string INPUT_FILENAME_WITHOUT_EXT = "data/saint_jean_370K";
const std::string INPUT_FILENAME_WITHOUT_EXT = "data/sphere_20k";
//const std::string INPUT_FILENAME_WITHOUT_EXT = "data/saint_jean_370K";
// Reads a .xyz point set file in points[], *with normals*.
std::vector<Point> points;
@ -30,9 +30,9 @@ int main(void)
}
//Algorithm parameters
const double retain_percentage = 1; // percentage of points to retain.
const double neighbor_radius = 0.03; // neighbors size.
const unsigned int iter_number = 2; // number of iterations.
const double retain_percentage = 5; // percentage of points to retain.
const double neighbor_radius = 0.25; // neighbors size.
const unsigned int iter_number = 35; // number of iterations.
const bool need_compute_density = true; // if needed to compute density.
// Make room for sample points
@ -44,14 +44,19 @@ int main(void)
std::cout << "Run algorithm example: " << std::endl;
// Run algorithm
//std::vector<Point>::const_iterator sample_points_begin =
// CGAL::wlop_simplify_and_regularize_point_set(
// points.begin(),
// points.end(),
// retain_percentage,
// neighbor_radius,
// iter_number,
// need_compute_density);
std::vector<Point>::const_iterator sample_points_begin =
CGAL::wlop_simplify_and_regularize_point_set(
CGAL::wlop_simplify_and_regularize_point_set(
points.begin(),
points.end(),
retain_percentage,
neighbor_radius,
iter_number,
need_compute_density);
points.end());
// Copy results to sample points
std::copy(sample_points_begin,

View File

@ -307,14 +307,13 @@ wlop_simplify_and_regularize_point_set(
ForwardIterator beyond, ///< past-the-end iterator over the input points.
PointPMap point_pmap, ///< property map ForwardIterator -> Point_3
const typename Kernel::FT retain_percentage, ///< percentage to retain.
const typename Kernel::FT neighbor_radius, ///< size of neighbors.
typename Kernel::FT neighbor_radius, ///< size of neighbors.
const unsigned int max_iter_number,///< number of iterations.
const bool need_compute_density, ///< if needed to compute density to
///generate more rugularized result.
const Kernel& /*kernel*/ ///< geometric traits.
)
{
CGAL_point_set_processing_precondition(neighbor_radius > 0);
Timer task_timer;
// basic geometric types
@ -373,7 +372,8 @@ wlop_simplify_and_regularize_point_set(
std::vector<Rich_point> original_rich_points(nb_points_original);
std::vector<Rich_point> sample_rich_points(nb_points_sample);
CGAL::Bbox_3 bbox;
CGAL::Bbox_3 bbox(0, 0, 0, 0, 0, 0);
original_iter = original_points.begin();
int index = 0;
std::vector<Rich_point>::iterator origianl_rich_iter;
@ -385,6 +385,21 @@ wlop_simplify_and_regularize_point_set(
bbox += original_iter->bbox();
}
//compute default neighbor_radius
if (neighbor_radius < 0)
{
Point max_p(bbox.xmax(), bbox.ymax(), bbox.zmax());
Point min_p(bbox.xmin(), bbox.ymin(), bbox.zmin());
FT bbox_diameter = CGAL::squared_distance(max_p, min_p);
neighbor_radius = std::sqrt(bbox_diameter) * 0.05;
#ifdef CGAL_DEBUG_MODE
std::cout << "default estimate radius: " << neighbor_radius
<< std::endl << std::endl;
#endif
}
CGAL_point_set_processing_precondition(neighbor_radius > 0);
// Compute original density weight for original points if user needed
std::vector<FT> original_densities;
if (need_compute_density)
@ -617,11 +632,11 @@ ForwardIterator
wlop_simplify_and_regularize_point_set(
ForwardIterator first, ///< iterator over the first input point
ForwardIterator beyond, ///< past-the-end iterator
double retain_percentage, ///< percentage of points to retain
double neighbor_radius, ///< size of neighbors.
const unsigned int max_iter_number, ///< number of iterations.
const bool need_compute_density ///< if needed to compute density to generate
/// more rugularized result.
double retain_percentage = 5, ///< percentage of points to retain
double neighbor_radius = -1, ///< size of neighbors.
const unsigned int max_iter_number = 35, ///< number of iterations.
const bool need_compute_density = true ///< if needed to compute density to
/// generate more uniform result.
)
{
return wlop_simplify_and_regularize_point_set(
@ -632,10 +647,15 @@ wlop_simplify_and_regularize_point_set(
make_identity_property_map(typename std::iterator_traits<ForwardIterator>::
value_type()),
#endif
retain_percentage, neighbor_radius, max_iter_number, need_compute_density);
retain_percentage,
neighbor_radius,
max_iter_number,
need_compute_density);
}
/// @endcond
} //namespace CGAL
#endif // CGAL_SIMPLIFY_AND_REGULARIZE_POINT_SET_BALL_TREE_H