Update Point_set_3 examples and tests, remove Point_set_processing overloads

This commit is contained in:
Simon Giraudot 2017-12-13 12:37:13 +01:00
parent b4ea6c81b4
commit 210bb83123
6 changed files with 23 additions and 358 deletions

View File

@ -21,28 +21,6 @@
## Class ##
- `CGAL::Point_set_3<Point,Vector>`
\defgroup PkgPointSet3PointSetProcessing3 Point Set Processing
\ingroup PkgPointSet3
\brief This module offers convenience overloads of functions available in the
\ref PkgPointSetProcessingSummary package. These overloads allow the
user to call point set processing algorithms without having to handle
manually property maps and iterators.
The overloads, available after including
`CGAL/Point_set_3/Point_set_processing_3.h`, all follow the same
pattern based on the original point set processing functions:
- Iterators and property maps of the original functions are replaced
with a single parameter `CGAL::Point_set_3<Point,Vector>`
- The other parameters (and their potential default values) are
following in the same order as the original function.
For a complete documentation of these functions, please refer to the
\ref PkgPointSetProcessing manual.
\defgroup PkgPointSet3IO Input/Output
\ingroup PkgPointSet3

View File

@ -19,11 +19,11 @@ int main (int argc, char** argv)
Point_set point_set;
point_set.add_normal_map();
// Reading input in OFF format
if (!f || !CGAL::read_off_points_and_normals
if (!f || !CGAL::read_off_points
(f,
point_set.index_back_inserter(), // OutputIterator
point_set.point_push_map(),
point_set.normal_push_map()))
CGAL::parameters::point_map(point_set.point_push_map()).
normal_map(point_set.normal_push_map())))
{
std::cerr << "Can't read input file " << std::endl;
return EXIT_FAILURE;

View File

@ -1,6 +1,5 @@
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Point_set_3.h>
//#include <CGAL/Point_set_3/Point_set_processing_3.h>
#include <CGAL/jet_estimate_normals.h>
#include <CGAL/grid_simplify_point_set.h>
#include <CGAL/point_generators_3.h>

View File

@ -310,11 +310,11 @@ read_xyz_point_set(
{
point_set.add_normal_map();
bool out = CGAL::read_xyz_points_and_normals
bool out = CGAL::read_xyz_points
(stream,
point_set.index_back_inserter(),
point_set.point_push_map(),
point_set.normal_push_map());
CGAL::parameters::point_map(point_set.point_push_map()).
normal_map(point_set.normal_push_map()));
bool has_normals = false;
for (typename CGAL::Point_set_3<Point, Vector>::const_iterator it = point_set.begin();
@ -342,11 +342,11 @@ read_off_point_set(
{
point_set.add_normal_map();
bool out = CGAL::read_off_points_and_normals
bool out = CGAL::read_off_points
(stream,
point_set.index_back_inserter(),
point_set.point_push_map(),
point_set.normal_push_map());
CGAL::parameters::point_map(point_set.point_push_map()).
normal_map(point_set.normal_push_map()));
bool has_normals = false;
for (typename CGAL::Point_set_3<Point, Vector>::const_iterator it = point_set.begin();
@ -794,7 +794,7 @@ write_las_point_set(
bool okay
= write_las_points_with_properties
(stream, point_set.begin(), point_set.end(),
(stream, point_set,
make_las_point_writer (point_set.point_map()),
std::make_pair (intensity, LAS_property::Intensity()),
std::make_pair (return_number, LAS_property::Return_number()),
@ -883,13 +883,14 @@ write_xyz_point_set(
const CGAL::Point_set_3<Point, Vector>& point_set) ///< point set
{
if (point_set.has_normal_map())
return CGAL::write_xyz_points_and_normals
(stream, point_set.begin(), point_set.end(),
point_set.point_map(), point_set.normal_map());
return CGAL::write_xyz_points
(stream, point_set,
CGAL::parameters::point_map(point_set.point_map()).
normal_map(point_set.normal_map()));
return CGAL::write_xyz_points
(stream, point_set.begin(), point_set.end(),
point_set.point_map());
(stream, point_set,
CGAL::parameters::point_map(point_set.point_map()));
}
/*!
@ -902,13 +903,14 @@ write_off_point_set(
const CGAL::Point_set_3<Point, Vector>& point_set) ///< point set
{
if (point_set.has_normal_map())
return CGAL::write_off_points_and_normals
(stream, point_set.begin(), point_set.end(),
point_set.point_map(), point_set.normal_map());
return CGAL::write_off_points
(stream, point_set,
CGAL::parameters::point_map(point_set.point_map()).
normal_map(point_set.normal_map()));
return CGAL::write_off_points
(stream, point_set.begin(), point_set.end(),
point_set.point_map());
(stream, point_set,
CGAL::parameters::point_map(point_set.point_map()));
}

View File

@ -1,311 +0,0 @@
// Copyright (c) 2016 GeometryFactory Sarl (France).
// All rights reserved.
//
// This file is part of CGAL (www.cgal.org).
// You can redistribute it and/or modify it under the terms of the GNU
// General Public License as published by the Free Software Foundation,
// either version 3 of the License, or (at your option) any later version.
//
// Licensees holding a valid commercial license may use this file in
// accordance with the commercial license agreement provided with the software.
//
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
//
// $URL$
// $Id$
// SPDX-License-Identifier: GPL-3.0+
//
//
// Author(s) : Simon Giraudot
#ifndef CGAL_POINT_SET_3_POINT_SET_PROCESSING_3_H
#define CGAL_POINT_SET_3_POINT_SET_PROCESSING_3_H
#include <CGAL/license/Point_set_3.h>
#include <CGAL/bilateral_smooth_point_set.h>
#include <CGAL/compute_average_spacing.h>
#include <CGAL/edge_aware_upsample_point_set.h>
#include <CGAL/grid_simplify_point_set.h>
#include <CGAL/hierarchy_simplify_point_set.h>
#include <CGAL/jet_estimate_normals.h>
#include <CGAL/jet_smooth_point_set.h>
#include <CGAL/mst_orient_normals.h>
#include <CGAL/pca_estimate_normals.h>
#include <CGAL/random_simplify_point_set.h>
#include <CGAL/remove_outliers.h>
#include <CGAL/vcm_estimate_normals.h>
#include <CGAL/wlop_simplify_and_regularize_point_set.h>
namespace CGAL {
/*!
\ingroup PkgPointSet3PointSetProcessing3
*/
template <typename Concurrency_tag,
typename Point,
typename Vector>
double
bilateral_smooth_point_set(
CGAL::Point_set_3<Point, Vector>& point_set, ///< point set
const unsigned int k, ///< number of neighbors.
double sharpness_angle) ///< control sharpness(0-90)
{
return CGAL::bilateral_smooth_point_set<Concurrency_tag>
(point_set.begin(), point_set.end(),
point_set.point_map(), point_set.normal_map(),
k, sharpness_angle);
}
/*!
\ingroup PkgPointSet3PointSetProcessing3
*/
template <typename Concurrency_tag,
typename Point, typename Vector>
double
compute_average_spacing(
const CGAL::Point_set_3<Point, Vector>& point_set, ///< point set
unsigned int k) ///< number of neighbors.
{
return CGAL::compute_average_spacing<Concurrency_tag>
(point_set.begin(), point_set.end(), point_set.point_map(), k);
}
/*!
\ingroup PkgPointSet3PointSetProcessing3
*/
template <typename Concurrency_tag,
typename Point, typename Vector>
void
edge_aware_upsample_point_set(
CGAL::Point_set_3<Point, Vector>& point_set, ///< point set
double sharpness_angle = 30, ///< control sharpness(0-90)
double edge_sensitivity = 1, ///< edge sensitivity(0-5)
double neighbor_radius = -1, ///< initial size of neighbors.
const std::size_t number_of_output_points = 1000)///< number of output points.
{
CGAL::edge_aware_upsample_point_set<Concurrency_tag>
(point_set.begin(), point_set.end(),
point_set.point_back_inserter(),
point_set.point_map(), point_set.normal_map(),
sharpness_angle, edge_sensitivity, neighbor_radius, number_of_output_points);
}
/*!
\ingroup PkgPointSet3PointSetProcessing3
\note No iterator is returned, points simplified are directly
removed from the point set.
*/
template <typename Point, typename Vector>
void grid_simplify_point_set(
CGAL::Point_set_3<Point, Vector>& point_set, ///< point set
double epsilon) ///< tolerance value when merging 3D points.
{
point_set.remove_from
(CGAL::grid_simplify_point_set
(point_set.begin(), point_set.end(), point_set.point_map(), epsilon));
}
/*!
\ingroup PkgPointSet3PointSetProcessing3
\note No iterator is returned, points simplified are directly
removed from the point set.
*/
template <typename Point, typename Vector>
void hierarchy_simplify_point_set(
CGAL::Point_set_3<Point, Vector>& point_set, ///< point set
const unsigned int size = 10, ///< maximum cluster size
const double var_max = 0.333) ///< maximal surface variation
{
point_set.remove_from
(CGAL::hierarchy_simplify_point_set
(point_set.begin(), point_set.end(), point_set.point_map(), size, var_max,
CGAL::Default_diagonalize_traits<double, 3>()));
}
/*!
\ingroup PkgPointSet3PointSetProcessing3
\note This function adds a normal map to the point set.
*/
template <typename Concurrency_tag,
typename Point, typename Vector>
void
jet_estimate_normals(
CGAL::Point_set_3<Point, Vector>& point_set, ///< point set
unsigned int k, ///< number of neighbors.
unsigned int degree_fitting = 2) ///< fitting degree
{
point_set.add_normal_map();
CGAL::jet_estimate_normals<Concurrency_tag>
(point_set.begin(), point_set.end(),
point_set.point_map(), point_set.normal_map(),
k, degree_fitting);
}
/*!
\ingroup PkgPointSet3PointSetProcessing3
*/
template <typename Concurrency_tag,
typename Point, typename Vector>
void
jet_smooth_point_set(
CGAL::Point_set_3<Point, Vector>& point_set, ///< point set
unsigned int k, ///< number of neighbors.
unsigned int degree_fitting = 2, ///< fitting degree
unsigned int degree_monge = 2) ///< Monge degree
{
CGAL::jet_smooth_point_set<Concurrency_tag>
(point_set.begin(), point_set.end(), point_set.point_map(),
k, degree_fitting, degree_monge);
}
/*!
\ingroup PkgPointSet3PointSetProcessing3
*/
template <typename Point, typename Vector>
typename CGAL::Point_set_3<Point, Vector>::iterator
mst_orient_normals(
CGAL::Point_set_3<Point, Vector>& point_set, ///< point set
unsigned int k) ///< number of neighbors
{
return CGAL::mst_orient_normals
(point_set.begin(), point_set.end(),
point_set.point_map(), point_set.normal_map(), k);
}
/*!
\ingroup PkgPointSet3PointSetProcessing3
\note This function adds a normal map to the point set.
*/
template <typename Concurrency_tag,
typename Point, typename Vector>
void
pca_estimate_normals(
CGAL::Point_set_3<Point, Vector>& point_set, ///< point set
unsigned int k) ///< number of neighbors.
{
point_set.add_normal_map();
CGAL::pca_estimate_normals<Concurrency_tag>
(point_set.begin(), point_set.end(),
point_set.point_map(), point_set.normal_map(),
k);
}
/*!
\ingroup PkgPointSet3PointSetProcessing3
\note No iterator is returned, points simplified are directly
removed from the point set.
*/
template <typename Point, typename Vector>
void random_simplify_point_set(
CGAL::Point_set_3<Point, Vector>& point_set, ///< point set
double removed_percentage) ///< percentage of points to remove
{
point_set.remove_from
(CGAL::random_simplify_point_set
(point_set.begin(), point_set.end(), point_set.point_map(), removed_percentage));
}
/*!
\ingroup PkgPointSet3PointSetProcessing3
\note No iterator is returned, points simplified are directly
removed from the point set.
*/
template <typename Point, typename Vector>
void remove_outliers(
CGAL::Point_set_3<Point, Vector>& point_set, ///< point set
unsigned int k, ///< number of neighbors.
double threshold_percent) ///< percentage of points to remove
{
point_set.remove_from
(CGAL::remove_outliers
(point_set.begin(), point_set.end(), point_set.point_map(), k, threshold_percent));
}
/*!
\ingroup PkgPointSet3PointSetProcessing3
\note This function adds a normal map to the point set.
*/
template <typename Point, typename Vector>
void
vcm_estimate_normals(
CGAL::Point_set_3<Point, Vector>& point_set, ///< point set
double offset_radius, ///< offset radius.
double convolution_radius) ///< convolution radius.
{
point_set.add_normal_map();
CGAL::vcm_estimate_normals
(point_set.begin(), point_set.end(),
point_set.point_map(), point_set.normal_map(),
offset_radius, convolution_radius);
}
/*!
\ingroup PkgPointSet3PointSetProcessing3
\note This function adds a normal map to the point set.
*/
template <typename Point, typename Vector>
void
vcm_estimate_normals(
CGAL::Point_set_3<Point, Vector>& point_set, ///< point set
double offset_radius, ///< offset radius.
unsigned int nb_neighbors_convolve) ///< number of neighbors used during the convolution.
{
point_set.add_normal_map();
CGAL::vcm_estimate_normals
(point_set.begin(), point_set.end(),
point_set.point_map(), point_set.normal_map(),
offset_radius, nb_neighbors_convolve);
}
/*!
\ingroup PkgPointSet3PointSetProcessing3
*/
template <typename Concurrency_tag,
typename Point, typename Vector>
void
wlop_simplify_and_regularize_point_set(
const CGAL::Point_set_3<Point, Vector>& input_point_set, ///< input point set
CGAL::Point_set_3<Point, Vector>& output_point_set, ///< output point set
const double select_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 require_uniform_sampling = false ///< if needed to compute density
/// to generate more rugularized result.
)
{
CGAL::wlop_simplify_and_regularize_point_set
(input_point_set.begin(), input_point_set.end(),
output_point_set.point_back_inserter(),
input_point_set.point_map(),
select_percentage,
neighbor_radius,
max_iter_number,
require_uniform_sampling);
}
} // namespace CGAL
#endif // CGAL_POINT_SET_3_POINT_SET_PROCESSING_3_H

View File

@ -1,7 +1,6 @@
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Point_set_3.h>
#include <CGAL/Point_set_3/Point_set_processing_3.h>
#include <CGAL/Point_set_3/IO.h>
#include <CGAL/grid_simplify_point_set.h>
@ -43,9 +42,7 @@ int main (int, char**)
f.close ();
Point_set::iterator
first_to_remove = CGAL::grid_simplify_point_set (point_set.begin(),
point_set.end(),
point_set.point_map(),
first_to_remove = CGAL::grid_simplify_point_set (point_set,
0.1);
std::size_t size = point_set.size ();