mirror of https://github.com/CGAL/cgal
Merge branch 'First_of_pair_property_map-new_version-iyaz'
related to this small-feature: Features/Small_Features/Property_maps_change_of_key_type Successfully tested in CGAL-4.3-Ic-59 and approved by the release manager Conflicts: Installation/changes.html
This commit is contained in:
commit
a7b80aa998
|
|
@ -160,6 +160,17 @@ David A. Wheeler's 'SLOCCount'</a>, restricted to the <code>include/CGAL/</code>
|
|||
an operator to accept and dispatch a tuple of values.
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h3>CGAL and Boost Property Maps</h3>
|
||||
<ul>
|
||||
<li> The <code>key_type</code> of the property maps provided by CGAL used to be an iterator. In order to be more easily re-used,
|
||||
the <code>key_type</code> has been changed to be the <code>value_type</code> of the iterator.
|
||||
The packages that have been updated to match these changes are <b>Point Set Processing</b> and <b>Surface Reconstruction from Point Sets</b>.
|
||||
However, for most users this change should be transparent if the default property maps were used.
|
||||
For convenience, the former behavior can be enabled by defining the macro <code>CGAL_USE_PROPERTY_MAPS_API_V1</code>.
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
|
||||
<h2 id="release4.2">Release 4.2 </h2>
|
||||
|
|
|
|||
|
|
@ -61,11 +61,11 @@ The following classes described in Chapter \ref chapterProperty_map
|
|||
provide property maps for the implementations of points with normals
|
||||
listed above:
|
||||
|
||||
- `Dereference_property_map<T>`
|
||||
- `Identity_property_map<T>`
|
||||
- `First_of_pair_property_map<Pair>` and `Second_of_pair_property_map<Pair>`
|
||||
- `Nth_of_tuple_property_map<N, Tuple>`
|
||||
|
||||
`Dereference_property_map<Point_3>` is the default value of the
|
||||
`Identity_property_map<Point_3>` is the default value of the
|
||||
position property map expected by all functions in this component.
|
||||
|
||||
See below examples using pair and tuple property maps.
|
||||
|
|
@ -128,7 +128,7 @@ input points in increasing order of average squared distances to their
|
|||
\subsection Point_set_processing_3Example_2 Example
|
||||
|
||||
The following example reads a point set and removes 5% of the
|
||||
points. It uses the `Dereference_property_map<Point_3>` property
|
||||
points. It uses the `Identity_property_map<Point_3>` property
|
||||
map (optional as it is the default position property map of all
|
||||
functions in this component.)
|
||||
\cgalExample{Point_set_processing_3/remove_outliers_example.cpp}
|
||||
|
|
|
|||
|
|
@ -35,15 +35,14 @@ or as a `boost::tuple<..,Point_3<K>, ..., Vector_3<K> >`.
|
|||
|
||||
This component provides property maps to support these cases:
|
||||
|
||||
`Dereference_property_map<T>`
|
||||
- `Identity_property_map<T>`
|
||||
- `First_of_pair_property_map<Pair>` and `Second_of_pair_property_map<Pair>`
|
||||
- `Nth_of_tuple_property_map<N, Tuple>`
|
||||
- `Dereference_property_map<T>`
|
||||
|
||||
`First_of_pair_property_map<Pair>` and `Second_of_pair_property_map<Pair>`
|
||||
\subsection Property_mapExamplewithIdentity Example with Identity_property_map
|
||||
|
||||
`Nth_of_tuple_property_map<N, Tuple>`
|
||||
|
||||
\subsection Property_mapExamplewithDereferencepropertymap Example with Dereference_property_map
|
||||
|
||||
The following example reads a point set and removes 5% of the points. It uses `Dereference_property_map<Point_3>` as position property map.
|
||||
The following example reads a point set and removes 5% of the points. It uses `Identity_property_map<Point_3>` as position property map.
|
||||
\cgalExample{Point_set_processing_3/remove_outliers_example.cpp}
|
||||
|
||||
\subsection Property_mapExamplewithPairs Example with Pairs
|
||||
|
|
|
|||
|
|
@ -47,9 +47,9 @@ int main(void)
|
|||
// Computes average spacing.
|
||||
const unsigned int nb_neighbors = 6; // 1 ring
|
||||
FT average_spacing = CGAL::compute_average_spacing(
|
||||
points.begin(), points.end(),
|
||||
CGAL::Nth_of_tuple_property_map<1,IndexedPointWithColorTuple>(),
|
||||
nb_neighbors);
|
||||
points.begin(), points.end(),
|
||||
CGAL::Nth_of_tuple_property_map<1,IndexedPointWithColorTuple>(),
|
||||
nb_neighbors);
|
||||
std::cout << "Average spacing: " << average_spacing << std::endl;
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@
|
|||
|
||||
#include <CGAL/Simple_cartesian.h>
|
||||
#include <CGAL/property_map.h>
|
||||
#include <CGAL/value_type_traits.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <vector>
|
||||
#include <boost/tuple/tuple.hpp>
|
||||
|
|
@ -42,7 +44,7 @@ struct MyLess {
|
|||
|
||||
bool operator()(const T& t0, const T& t1) const
|
||||
{
|
||||
return get(pmap, &t0) < get(pmap, &t1);
|
||||
return get(pmap, t0) < get(pmap, t1);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -64,7 +66,10 @@ void process_point_set(Iterator beg, Iterator end, PointPMap pmap)
|
|||
template <typename Iterator>
|
||||
void process_point_set(Iterator beg, Iterator end)
|
||||
{
|
||||
process_point_set(beg,end, CGAL::make_dereference_property_map(beg));
|
||||
process_point_set(beg,end,
|
||||
CGAL::make_identity_property_map(
|
||||
typename CGAL::value_type_traits<Iterator>::type())
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -75,13 +80,11 @@ template <typename Iterator, typename OrientationPMap, typename NormalPMap >
|
|||
void orient_normals(Iterator beg, Iterator end, OrientationPMap orient_pmap, NormalPMap normal_pmap)
|
||||
{
|
||||
for(;beg!= end;++beg){
|
||||
Vector_3& v = get(normal_pmap, beg);
|
||||
|
||||
boost::put(orient_pmap, beg, (v == CGAL::NULL_VECTOR));
|
||||
const Vector_3& v = get(normal_pmap, *beg);
|
||||
put(orient_pmap, *beg, (v == CGAL::NULL_VECTOR));
|
||||
|
||||
if(v.x() < 0){
|
||||
v = -v;
|
||||
boost::put(normal_pmap, beg, v);
|
||||
put(normal_pmap,*beg, -v);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -95,7 +98,7 @@ int main()
|
|||
// Here we run it on plain points. No need for a property map
|
||||
{
|
||||
std::vector<Point_3> points;
|
||||
|
||||
|
||||
process_point_set(points.begin(), points.end());
|
||||
}
|
||||
|
||||
|
|
@ -108,11 +111,11 @@ int main()
|
|||
for(int i = 0; i < 10; i++){
|
||||
points.push_back(std::make_pair(Point_3(9-i,0,0), Vector_3(i,0,0)));
|
||||
}
|
||||
|
||||
|
||||
process_point_set(points.begin(),
|
||||
points.end(),
|
||||
CGAL::First_of_pair_property_map<PointVectorPair>());
|
||||
|
||||
|
||||
for(int i = 0; i < 10; i++){
|
||||
std::cout << points[i].first << "\t" << points[i].second << std::endl;
|
||||
}
|
||||
|
|
@ -131,11 +134,11 @@ int main()
|
|||
double x = (i%2)?i:-i;
|
||||
points.push_back(boost::make_tuple(i,Point_3(9-i,0,0), false, Vector_3(x,0,0)));
|
||||
}
|
||||
|
||||
|
||||
process_point_set(points.begin(),
|
||||
points.end(),
|
||||
CGAL::Nth_of_tuple_property_map<1,IndexedPointWithOrientableNormalTuple>());
|
||||
|
||||
|
||||
std::cout << boost::tuples::set_open('[') << boost::tuples::set_close(']') << boost::tuples::set_delimiter(',');
|
||||
|
||||
for(int i = 0; i < 10; i++){
|
||||
|
|
@ -145,14 +148,13 @@ int main()
|
|||
//We keep the sequence in order, but determine the normal and if it is different from zero set the Boolean to true
|
||||
orient_normals(points.begin(),
|
||||
points.end(),
|
||||
CGAL::make_nth_of_tuple_property_map<2>(points.begin()),
|
||||
CGAL::make_nth_of_tuple_property_map<3>(points.begin()));
|
||||
|
||||
CGAL::make_nth_of_tuple_property_map<2>(IndexedPointWithOrientableNormalTuple()),
|
||||
CGAL::make_nth_of_tuple_property_map<3>(IndexedPointWithOrientableNormalTuple()));
|
||||
|
||||
std::cout << "\nAfter orient_normals\n";
|
||||
for(int i = 0; i < 10; i++){
|
||||
std::cout << points[i] << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,29 +13,28 @@ typedef Kernel::Point_3 Point;
|
|||
int main(void)
|
||||
{
|
||||
// Reads a .xyz point set file in points[].
|
||||
// The Dereference_property_map property map can be omitted here as it is the default value.
|
||||
// The Identity_property_map property map can be omitted here as it is the default value.
|
||||
std::vector<Point> points;
|
||||
std::ifstream stream("data/oni.xyz");
|
||||
if (!stream ||
|
||||
!CGAL::read_xyz_points(stream, std::back_inserter(points),
|
||||
CGAL::Dereference_property_map<Point>()))
|
||||
CGAL::Identity_property_map<Point>()))
|
||||
{
|
||||
std::cerr << "Error: cannot read file data/oni.xyz" << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
// Removes outliers using erase-remove idiom.
|
||||
// The Dereference_property_map property map can be omitted here as it is the default value.
|
||||
// The Identity_property_map property map can be omitted here as it is the default value.
|
||||
const double removed_percentage = 5.0; // percentage of points to remove
|
||||
const int nb_neighbors = 24; // considers 24 nearest neighbor points
|
||||
points.erase(CGAL::remove_outliers(points.begin(), points.end(),
|
||||
CGAL::Dereference_property_map<Point>(),
|
||||
nb_neighbors, removed_percentage),
|
||||
CGAL::Identity_property_map<Point>(),
|
||||
nb_neighbors, removed_percentage),
|
||||
points.end());
|
||||
|
||||
// Optional: after erase(), use Scott Meyer's "swap trick" to trim excess capacity
|
||||
std::vector<Point>(points).swap(points);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -45,6 +45,8 @@ namespace CGAL {
|
|||
/// optionally followed by the nx ny nz normal.
|
||||
/// Faces are ignored.
|
||||
///
|
||||
/// @tparam OutputIteratorValueType type of objects that can be put in `OutputIterator`.
|
||||
/// It is default to `value_type_traits<OutputIterator>::type` and can be omitted when the default is fine.
|
||||
/// @tparam OutputIterator iterator over output points.
|
||||
/// @tparam PointPMap is a model of `WritablePropertyMap` with a value_type = Point_3<Kernel>.
|
||||
/// It can be omitted if OutputIterator value_type is convertible to Point_3<Kernel>.
|
||||
|
|
@ -55,21 +57,24 @@ namespace CGAL {
|
|||
/// @return true on success.
|
||||
|
||||
// This variant requires all parameters.
|
||||
template <typename OutputIterator,
|
||||
//-----------------------------------------------------------------------------------
|
||||
template <typename OutputIteratorValueType,
|
||||
typename OutputIterator,
|
||||
typename PointPMap,
|
||||
typename NormalPMap,
|
||||
typename Kernel
|
||||
>
|
||||
bool
|
||||
read_off_points_and_normals(
|
||||
std::istream& stream, ///< input stream.
|
||||
OutputIterator output, ///< output iterator over points.
|
||||
PointPMap point_pmap, ///< property map OutputIterator -> Point_3.
|
||||
NormalPMap normal_pmap, ///< property map OutputIterator -> Vector_3.
|
||||
const Kernel& /*kernel*/) ///< geometric traits.
|
||||
std::istream& stream, ///< input stream.
|
||||
OutputIterator output, ///< output iterator over points.
|
||||
PointPMap point_pmap, ///< property map: value_type of OutputIterator -> Point_3.
|
||||
NormalPMap normal_pmap, ///< property map: value_type of OutputIterator -> Vector_3.
|
||||
const Kernel& /*kernel*/) ///< geometric traits.
|
||||
{
|
||||
// value_type_traits is a workaround as back_insert_iterator's value_type is void
|
||||
typedef typename value_type_traits<OutputIterator>::type Enriched_point;
|
||||
// typedef typename value_type_traits<OutputIterator>::type Enriched_point;
|
||||
typedef OutputIteratorValueType Enriched_point;
|
||||
|
||||
typedef typename Kernel::Point_3 Point;
|
||||
typedef typename Kernel::Vector_3 Vector;
|
||||
|
|
@ -127,18 +132,23 @@ read_off_points_and_normals(
|
|||
Vector normal = CGAL::NULL_VECTOR;
|
||||
// ... + normal...
|
||||
if (iss >> nx)
|
||||
{
|
||||
// In case we could read one number, we expect that there are two more
|
||||
if(iss >> ny >> nz){
|
||||
normal = Vector(nx,ny,nz);
|
||||
} else {
|
||||
std::cerr << "Error line " << lineNumber << " of file" << std::endl;
|
||||
return false;
|
||||
}
|
||||
{
|
||||
// In case we could read one number, we expect that there are two more
|
||||
if(iss >> ny >> nz){
|
||||
normal = Vector(nx,ny,nz);
|
||||
} else {
|
||||
std::cerr << "Error line " << lineNumber << " of file" << std::endl;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Enriched_point pwn;
|
||||
#ifdef CGAL_USE_PROPERTY_MAPS_API_V1
|
||||
put(point_pmap, &pwn, point); // point_pmap[&pwn] = point
|
||||
put(normal_pmap, &pwn, normal); // normal_pmap[&pwn] = normal
|
||||
#else
|
||||
put(point_pmap, pwn, point); // point_pmap[&pwn] = point
|
||||
put(normal_pmap, pwn, normal); // normal_pmap[&pwn] = normal
|
||||
#endif
|
||||
*output++ = pwn;
|
||||
pointsRead++;
|
||||
}
|
||||
|
|
@ -150,8 +160,58 @@ read_off_points_and_normals(
|
|||
return true;
|
||||
}
|
||||
|
||||
/// @cond SKIP_IN_MANUAL
|
||||
template <typename OutputIterator,
|
||||
typename PointPMap,
|
||||
typename NormalPMap,
|
||||
typename Kernel
|
||||
>
|
||||
bool
|
||||
read_off_points_and_normals(
|
||||
std::istream& stream, ///< input stream.
|
||||
OutputIterator output, ///< output iterator over points.
|
||||
PointPMap point_pmap, ///< property map: value_type of OutputIterator -> Point_3.
|
||||
NormalPMap normal_pmap, ///< property map: value_type of OutputIterator -> Vector_3.
|
||||
const Kernel& kernel) ///< geometric traits.
|
||||
{
|
||||
// just deduce value_type of OutputIterator
|
||||
return read_off_points_and_normals
|
||||
<typename value_type_traits<OutputIterator>::type>(
|
||||
stream,
|
||||
output,
|
||||
point_pmap,
|
||||
normal_pmap,
|
||||
kernel);
|
||||
}
|
||||
//-----------------------------------------------------------------------------------
|
||||
/// @endcond
|
||||
|
||||
/// @cond SKIP_IN_MANUAL
|
||||
// This variant deduces the kernel from the point property map.
|
||||
//-----------------------------------------------------------------------------------
|
||||
template <typename OutputIteratorValueType,
|
||||
typename OutputIterator,
|
||||
typename PointPMap,
|
||||
typename NormalPMap
|
||||
>
|
||||
bool
|
||||
read_off_points_and_normals(
|
||||
std::istream& stream, ///< input stream.
|
||||
OutputIterator output, ///< output iterator over points.
|
||||
PointPMap point_pmap, ///< property map: value_type of OutputIterator -> Point_3.
|
||||
NormalPMap normal_pmap) ///< property map: value_type of OutputIterator -> Vector_3.
|
||||
{
|
||||
typedef typename boost::property_traits<PointPMap>::value_type Point;
|
||||
typedef typename Kernel_traits<Point>::Kernel Kernel;
|
||||
return read_off_points_and_normals
|
||||
<OutputIteratorValueType>(
|
||||
stream,
|
||||
output,
|
||||
point_pmap,
|
||||
normal_pmap,
|
||||
Kernel());
|
||||
}
|
||||
|
||||
template <typename OutputIterator,
|
||||
typename PointPMap,
|
||||
typename NormalPMap
|
||||
|
|
@ -160,22 +220,45 @@ bool
|
|||
read_off_points_and_normals(
|
||||
std::istream& stream, ///< input stream.
|
||||
OutputIterator output, ///< output iterator over points.
|
||||
PointPMap point_pmap, ///< property map OutputIterator -> Point_3.
|
||||
NormalPMap normal_pmap) ///< property map OutputIterator -> Vector_3.
|
||||
PointPMap point_pmap, ///< property map: value_type of OutputIterator -> Point_3.
|
||||
NormalPMap normal_pmap) ///< property map: value_type of OutputIterator -> Vector_3.
|
||||
{
|
||||
typedef typename boost::property_traits<PointPMap>::value_type Point;
|
||||
typedef typename Kernel_traits<Point>::Kernel Kernel;
|
||||
return read_off_points_and_normals(
|
||||
// just deduce value_type of OutputIterator
|
||||
return read_off_points_and_normals
|
||||
<typename value_type_traits<OutputIterator>::type>(
|
||||
stream,
|
||||
output,
|
||||
point_pmap,
|
||||
normal_pmap,
|
||||
Kernel());
|
||||
normal_pmap);
|
||||
}
|
||||
//-----------------------------------------------------------------------------------
|
||||
/// @endcond
|
||||
|
||||
/// @cond SKIP_IN_MANUAL
|
||||
// This variant creates a default point property map = Dereference_property_map.
|
||||
// This variant creates a default point property map = Identity_property_map.
|
||||
//-----------------------------------------------------------------------------------
|
||||
template <typename OutputIteratorValueType,
|
||||
typename OutputIterator,
|
||||
typename NormalPMap
|
||||
>
|
||||
bool
|
||||
read_off_points_and_normals(
|
||||
std::istream& stream, ///< input stream.
|
||||
OutputIterator output, ///< output iterator over points.
|
||||
NormalPMap normal_pmap) ///< property map: value_type of OutputIterator -> Vector_3.
|
||||
{
|
||||
return read_off_points_and_normals
|
||||
<OutputIteratorValueType>(
|
||||
stream,
|
||||
output,
|
||||
#ifdef CGAL_USE_PROPERTY_MAPS_API_V1
|
||||
make_dereference_property_map(output),
|
||||
#else
|
||||
make_identity_property_map(OutputIteratorValueType()),
|
||||
#endif
|
||||
normal_pmap);
|
||||
}
|
||||
|
||||
template <typename OutputIterator,
|
||||
typename NormalPMap
|
||||
>
|
||||
|
|
@ -183,14 +266,16 @@ bool
|
|||
read_off_points_and_normals(
|
||||
std::istream& stream, ///< input stream.
|
||||
OutputIterator output, ///< output iterator over points.
|
||||
NormalPMap normal_pmap) ///< property map OutputIterator -> Vector_3.
|
||||
NormalPMap normal_pmap) ///< property map: value_type of OutputIterator -> Vector_3.
|
||||
{
|
||||
return read_off_points_and_normals(
|
||||
// just deduce value_type of OutputIterator
|
||||
return read_off_points_and_normals
|
||||
<typename value_type_traits<OutputIterator>::type>(
|
||||
stream,
|
||||
output,
|
||||
make_dereference_property_map(output),
|
||||
normal_pmap);
|
||||
}
|
||||
//-----------------------------------------------------------------------------------
|
||||
/// @endcond
|
||||
|
||||
|
||||
|
|
@ -201,6 +286,8 @@ read_off_points_and_normals(
|
|||
/// If the position is followed by the nx ny nz normal, then the normal will be ignored.
|
||||
/// Faces are ignored.
|
||||
///
|
||||
/// @tparam OutputIteratorValueType type of objects that can be put in `OutputIterator`.
|
||||
/// It is default to `value_type_traits<OutputIterator>::type` and can be omitted when the default is fine.
|
||||
/// @tparam OutputIterator iterator over output points.
|
||||
/// @tparam PointPMap is a model of `WritablePropertyMap` with a value_type = Point_3<Kernel>.
|
||||
/// It can be omitted if OutputIterator value_type is convertible to Point_3<Kernel>.
|
||||
|
|
@ -210,7 +297,9 @@ read_off_points_and_normals(
|
|||
/// @return true on success.
|
||||
|
||||
// This variant requires all parameters.
|
||||
template <typename OutputIterator,
|
||||
//-----------------------------------------------------------------------------------
|
||||
template <typename OutputIteratorValueType,
|
||||
typename OutputIterator,
|
||||
typename PointPMap,
|
||||
typename Kernel
|
||||
>
|
||||
|
|
@ -218,11 +307,12 @@ bool
|
|||
read_off_points(
|
||||
std::istream& stream, ///< input stream.
|
||||
OutputIterator output, ///< output iterator over points.
|
||||
PointPMap point_pmap, ///< property map OutputIterator -> Point_3.
|
||||
PointPMap point_pmap, ///< property map: value_type of OutputIterator -> Point_3.
|
||||
const Kernel& kernel) ///< geometric traits.
|
||||
{
|
||||
// Calls read_off_points_and_normals() with a normal property map = boost::dummy_property_map
|
||||
return read_off_points_and_normals(
|
||||
return read_off_points_and_normals
|
||||
<OutputIteratorValueType>(
|
||||
stream,
|
||||
output,
|
||||
point_pmap,
|
||||
|
|
@ -230,8 +320,52 @@ read_off_points(
|
|||
kernel);
|
||||
}
|
||||
|
||||
/// @cond SKIP_IN_MANUAL
|
||||
template <typename OutputIterator,
|
||||
typename PointPMap,
|
||||
typename Kernel
|
||||
>
|
||||
bool
|
||||
read_off_points(
|
||||
std::istream& stream, ///< input stream.
|
||||
OutputIterator output, ///< output iterator over points.
|
||||
PointPMap point_pmap, ///< property map: value_type of OutputIterator -> Point_3.
|
||||
const Kernel& kernel) ///< geometric traits.
|
||||
{
|
||||
// just deduce value_type of OutputIterator
|
||||
return read_off_points
|
||||
<typename value_type_traits<OutputIterator>::type>(
|
||||
stream,
|
||||
output,
|
||||
point_pmap,
|
||||
kernel);
|
||||
}
|
||||
//-----------------------------------------------------------------------------------
|
||||
/// @endcond
|
||||
|
||||
/// @cond SKIP_IN_MANUAL
|
||||
// This variant deduces the kernel from the point property map.
|
||||
//-----------------------------------------------------------------------------------
|
||||
template <typename OutputIteratorValueType,
|
||||
typename OutputIterator,
|
||||
typename PointPMap
|
||||
>
|
||||
bool
|
||||
read_off_points(
|
||||
std::istream& stream, ///< input stream.
|
||||
OutputIterator output, ///< output iterator over points.
|
||||
PointPMap point_pmap) ///< property map: value_type of OutputIterator -> Point_3.
|
||||
{
|
||||
typedef typename boost::property_traits<PointPMap>::value_type Point;
|
||||
typedef typename Kernel_traits<Point>::Kernel Kernel;
|
||||
return read_off_points
|
||||
<OutputIteratorValueType>(
|
||||
stream,
|
||||
output,
|
||||
point_pmap,
|
||||
Kernel());
|
||||
}
|
||||
|
||||
template <typename OutputIterator,
|
||||
typename PointPMap
|
||||
>
|
||||
|
|
@ -239,20 +373,41 @@ bool
|
|||
read_off_points(
|
||||
std::istream& stream, ///< input stream.
|
||||
OutputIterator output, ///< output iterator over points.
|
||||
PointPMap point_pmap) ///< property map OutputIterator -> Point_3.
|
||||
PointPMap point_pmap) ///< property map: value_type of OutputIterator -> Point_3.
|
||||
{
|
||||
typedef typename boost::property_traits<PointPMap>::value_type Point;
|
||||
typedef typename Kernel_traits<Point>::Kernel Kernel;
|
||||
return read_off_points(
|
||||
// just deduce value_type of OutputIterator
|
||||
return read_off_points
|
||||
<typename value_type_traits<OutputIterator>::type>(
|
||||
stream,
|
||||
output,
|
||||
point_pmap,
|
||||
Kernel());
|
||||
point_pmap);
|
||||
}
|
||||
//-----------------------------------------------------------------------------------
|
||||
/// @endcond
|
||||
|
||||
/// @cond SKIP_IN_MANUAL
|
||||
// This variant creates a default point property map = Dereference_property_map.
|
||||
// This variant creates a default point property map = Identity_property_map.
|
||||
//-----------------------------------------------------------------------------------
|
||||
template <typename OutputIteratorValueType,
|
||||
typename OutputIterator
|
||||
>
|
||||
bool
|
||||
read_off_points(
|
||||
std::istream& stream, ///< input stream.
|
||||
OutputIterator output) ///< output iterator over points.
|
||||
{
|
||||
return read_off_points
|
||||
<OutputIteratorValueType>(
|
||||
stream,
|
||||
output,
|
||||
#ifdef CGAL_USE_PROPERTY_MAPS_API_V1
|
||||
make_dereference_property_map(output)
|
||||
#else
|
||||
make_identity_property_map(OutputIteratorValueType())
|
||||
#endif
|
||||
);
|
||||
}
|
||||
|
||||
template <typename OutputIterator
|
||||
>
|
||||
bool
|
||||
|
|
@ -260,11 +415,14 @@ read_off_points(
|
|||
std::istream& stream, ///< input stream.
|
||||
OutputIterator output) ///< output iterator over points.
|
||||
{
|
||||
return read_off_points(
|
||||
// just deduce value_type of OutputIterator
|
||||
return read_off_points
|
||||
<typename value_type_traits<OutputIterator>::type>(
|
||||
stream,
|
||||
output,
|
||||
make_dereference_property_map(output));
|
||||
output);
|
||||
}
|
||||
//-----------------------------------------------------------------------------------
|
||||
|
||||
/// @endcond
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -46,6 +46,8 @@ namespace CGAL {
|
|||
/// The first line may contain the number of points in the file.
|
||||
/// Empty lines and comments starting by # character are allowed.
|
||||
///
|
||||
/// @tparam OutputIteratorValueType type of objects that can be put in `OutputIterator`.
|
||||
/// It is default to `value_type_traits<OutputIterator>::type` and can be omitted when the default is fine.
|
||||
/// @tparam OutputIterator iterator over output points.
|
||||
/// @tparam PointPMap is a model of `WritablePropertyMap` with a value_type = Point_3<Kernel>.
|
||||
/// It can be omitted if OutputIterator value_type is convertible to Point_3<Kernel>.
|
||||
|
|
@ -56,7 +58,9 @@ namespace CGAL {
|
|||
/// @return true on success.
|
||||
|
||||
// This variant requires all parameters.
|
||||
template <typename OutputIterator,
|
||||
//-----------------------------------------------------------------------------------
|
||||
template <typename OutputIteratorValueType,
|
||||
typename OutputIterator,
|
||||
typename PointPMap,
|
||||
typename NormalPMap,
|
||||
typename Kernel
|
||||
|
|
@ -65,12 +69,13 @@ bool
|
|||
read_xyz_points_and_normals(
|
||||
std::istream& stream, ///< input stream.
|
||||
OutputIterator output, ///< output iterator over points.
|
||||
PointPMap point_pmap, ///< property map OutputIterator -> Point_3.
|
||||
NormalPMap normal_pmap, ///< property map OutputIterator -> Vector_3.
|
||||
PointPMap point_pmap, ///< property map: value_type of OutputIterator -> Point_3.
|
||||
NormalPMap normal_pmap, ///< property map: value_type of OutputIterator -> Vector_3.
|
||||
const Kernel& /*kernel*/) ///< geometric traits.
|
||||
{
|
||||
// value_type_traits is a workaround as back_insert_iterator's value_type is void
|
||||
typedef typename value_type_traits<OutputIterator>::type Enriched_point;
|
||||
//typedef typename value_type_traits<OutputIterator>::type Enriched_point;
|
||||
typedef OutputIteratorValueType Enriched_point;
|
||||
|
||||
typedef typename Kernel::Point_3 Point;
|
||||
typedef typename Kernel::Vector_3 Vector;
|
||||
|
|
@ -124,8 +129,13 @@ read_xyz_points_and_normals(
|
|||
}
|
||||
}
|
||||
Enriched_point pwn;
|
||||
#ifdef CGAL_USE_PROPERTY_MAPS_API_V1
|
||||
put(point_pmap, &pwn, point); // point_pmap[&pwn] = point
|
||||
put(normal_pmap, &pwn, normal); // normal_pmap[&pwn] = normal
|
||||
#else
|
||||
put(point_pmap, pwn, point); // point_pmap[pwn] = point
|
||||
put(normal_pmap, pwn, normal); // normal_pmap[pwn] = normal
|
||||
#endif
|
||||
*output++ = pwn;
|
||||
continue;
|
||||
}
|
||||
|
|
@ -146,8 +156,58 @@ read_xyz_points_and_normals(
|
|||
return true;
|
||||
}
|
||||
|
||||
/// @cond SKIP_IN_MANUAL
|
||||
template <typename OutputIterator,
|
||||
typename PointPMap,
|
||||
typename NormalPMap,
|
||||
typename Kernel
|
||||
>
|
||||
bool
|
||||
read_xyz_points_and_normals(
|
||||
std::istream& stream, ///< input stream.
|
||||
OutputIterator output, ///< output iterator over points.
|
||||
PointPMap point_pmap, ///< property map: value_type of OutputIterator -> Point_3.
|
||||
NormalPMap normal_pmap, ///< property map: value_type of OutputIterator -> Vector_3.
|
||||
const Kernel& kernel) ///< geometric traits.
|
||||
{
|
||||
// just deduce value_type of OutputIterator
|
||||
return read_xyz_points_and_normals
|
||||
<typename value_type_traits<OutputIterator>::type>(
|
||||
stream,
|
||||
output,
|
||||
point_pmap,
|
||||
normal_pmap,
|
||||
kernel);
|
||||
}
|
||||
//-----------------------------------------------------------------------------------
|
||||
/// @endcond
|
||||
|
||||
/// @cond SKIP_IN_MANUAL
|
||||
// This variant deduces the kernel from the point property map.
|
||||
//-----------------------------------------------------------------------------------
|
||||
template <typename OutputIteratorValueType,
|
||||
typename OutputIterator,
|
||||
typename PointPMap,
|
||||
typename NormalPMap
|
||||
>
|
||||
bool
|
||||
read_xyz_points_and_normals(
|
||||
std::istream& stream, ///< input stream.
|
||||
OutputIterator output, ///< output iterator over points.
|
||||
PointPMap point_pmap, ///< property map: value_type of OutputIterator -> Point_3.
|
||||
NormalPMap normal_pmap) ///< property map: value_type of OutputIterator -> Vector_3.
|
||||
{
|
||||
typedef typename boost::property_traits<PointPMap>::value_type Point;
|
||||
typedef typename Kernel_traits<Point>::Kernel Kernel;
|
||||
return read_xyz_points_and_normals
|
||||
<OutputIteratorValueType>(
|
||||
stream,
|
||||
output,
|
||||
point_pmap,
|
||||
normal_pmap,
|
||||
Kernel());
|
||||
}
|
||||
|
||||
template <typename OutputIterator,
|
||||
typename PointPMap,
|
||||
typename NormalPMap
|
||||
|
|
@ -156,22 +216,45 @@ bool
|
|||
read_xyz_points_and_normals(
|
||||
std::istream& stream, ///< input stream.
|
||||
OutputIterator output, ///< output iterator over points.
|
||||
PointPMap point_pmap, ///< property map OutputIterator -> Point_3.
|
||||
NormalPMap normal_pmap) ///< property map OutputIterator -> Vector_3.
|
||||
PointPMap point_pmap, ///< property map: value_type of OutputIterator -> Point_3.
|
||||
NormalPMap normal_pmap) ///< property map: value_type of OutputIterator -> Vector_3.
|
||||
{
|
||||
typedef typename boost::property_traits<PointPMap>::value_type Point;
|
||||
typedef typename Kernel_traits<Point>::Kernel Kernel;
|
||||
return read_xyz_points_and_normals(
|
||||
// just deduce value_type of OutputIterator
|
||||
return read_xyz_points_and_normals
|
||||
<typename value_type_traits<OutputIterator>::type>(
|
||||
stream,
|
||||
output,
|
||||
point_pmap,
|
||||
normal_pmap,
|
||||
Kernel());
|
||||
normal_pmap);
|
||||
}
|
||||
//-----------------------------------------------------------------------------------
|
||||
/// @endcond
|
||||
|
||||
/// @cond SKIP_IN_MANUAL
|
||||
// This variant creates a default point property map = Dereference_property_map.
|
||||
// This variant creates a default point property map = Identity_property_map.
|
||||
//-----------------------------------------------------------------------------------
|
||||
template <typename OutputIteratorValueType,
|
||||
typename OutputIterator,
|
||||
typename NormalPMap
|
||||
>
|
||||
bool
|
||||
read_xyz_points_and_normals(
|
||||
std::istream& stream, ///< input stream.
|
||||
OutputIterator output, ///< output iterator over points.
|
||||
NormalPMap normal_pmap) ///< property map: value_type of OutputIterator -> Vector_3.
|
||||
{
|
||||
return read_xyz_points_and_normals
|
||||
<OutputIteratorValueType>(
|
||||
stream,
|
||||
output,
|
||||
#ifdef CGAL_USE_PROPERTY_MAPS_API_V1
|
||||
make_dereference_property_map(output),
|
||||
#else
|
||||
make_identity_property_map(OutputIteratorValueType()),
|
||||
#endif
|
||||
normal_pmap);
|
||||
}
|
||||
|
||||
template <typename OutputIterator,
|
||||
typename NormalPMap
|
||||
>
|
||||
|
|
@ -179,14 +262,16 @@ bool
|
|||
read_xyz_points_and_normals(
|
||||
std::istream& stream, ///< input stream.
|
||||
OutputIterator output, ///< output iterator over points.
|
||||
NormalPMap normal_pmap) ///< property map OutputIterator -> Vector_3.
|
||||
NormalPMap normal_pmap) ///< property map: value_type of OutputIterator -> Vector_3.
|
||||
{
|
||||
return read_xyz_points_and_normals(
|
||||
// just deduce value_type of OutputIterator
|
||||
return read_xyz_points_and_normals
|
||||
<typename value_type_traits<OutputIterator>::type>(
|
||||
stream,
|
||||
output,
|
||||
make_dereference_property_map(output),
|
||||
normal_pmap);
|
||||
}
|
||||
//-----------------------------------------------------------------------------------
|
||||
/// @endcond
|
||||
|
||||
|
||||
|
|
@ -198,6 +283,8 @@ read_xyz_points_and_normals(
|
|||
/// The first line may contain the number of points in the file.
|
||||
/// Empty lines and comments starting by # character are allowed.
|
||||
///
|
||||
/// @tparam OutputIteratorValueType type of objects that can be put in `OutputIterator`.
|
||||
/// It is default to `value_type_traits<OutputIterator>::type` and can be omitted when the default is fine.
|
||||
/// @tparam OutputIterator iterator over output points.
|
||||
/// @tparam PointPMap is a model of `WritablePropertyMap` with a value_type = Point_3<Kernel>.
|
||||
/// It can be omitted if OutputIterator value_type is convertible to Point_3<Kernel>.
|
||||
|
|
@ -207,7 +294,9 @@ read_xyz_points_and_normals(
|
|||
/// @return true on success.
|
||||
|
||||
// This variant requires all parameters.
|
||||
template <typename OutputIterator,
|
||||
//-----------------------------------------------------------------------------------
|
||||
template <typename OutputIteratorValueType,
|
||||
typename OutputIterator,
|
||||
typename PointPMap,
|
||||
typename Kernel
|
||||
>
|
||||
|
|
@ -215,11 +304,12 @@ bool
|
|||
read_xyz_points(
|
||||
std::istream& stream, ///< input stream.
|
||||
OutputIterator output, ///< output iterator over points.
|
||||
PointPMap point_pmap, ///< property map OutputIterator -> Point_3.
|
||||
PointPMap point_pmap, ///< property map: value_type of OutputIterator -> Point_3.
|
||||
const Kernel& kernel) ///< geometric traits.
|
||||
{
|
||||
// Calls read_xyz_points_and_normals() with a normal property map = boost::dummy_property_map
|
||||
return read_xyz_points_and_normals(
|
||||
return read_xyz_points_and_normals
|
||||
<OutputIteratorValueType>(
|
||||
stream,
|
||||
output,
|
||||
point_pmap,
|
||||
|
|
@ -227,8 +317,52 @@ read_xyz_points(
|
|||
kernel);
|
||||
}
|
||||
|
||||
/// @cond SKIP_IN_MANUAL
|
||||
template <typename OutputIterator,
|
||||
typename PointPMap,
|
||||
typename Kernel
|
||||
>
|
||||
bool
|
||||
read_xyz_points(
|
||||
std::istream& stream, ///< input stream.
|
||||
OutputIterator output, ///< output iterator over points.
|
||||
PointPMap point_pmap, ///< property map: value_type of OutputIterator -> Point_3.
|
||||
const Kernel& kernel) ///< geometric traits.
|
||||
{
|
||||
// just deduce value_type of OutputIterator
|
||||
return read_xyz_points
|
||||
<typename value_type_traits<OutputIterator>::type>(
|
||||
stream,
|
||||
output,
|
||||
point_pmap,
|
||||
kernel);
|
||||
}
|
||||
/// @endcond
|
||||
//-----------------------------------------------------------------------------------
|
||||
|
||||
/// @cond SKIP_IN_MANUAL
|
||||
// This variant deduces the kernel from the point property map.
|
||||
//-----------------------------------------------------------------------------------
|
||||
template <typename OutputIteratorValueType,
|
||||
typename OutputIterator,
|
||||
typename PointPMap
|
||||
>
|
||||
bool
|
||||
read_xyz_points(
|
||||
std::istream& stream, ///< input stream.
|
||||
OutputIterator output, ///< output iterator over points.
|
||||
PointPMap point_pmap) ///< property map: value_type of OutputIterator -> Point_3.
|
||||
{
|
||||
typedef typename boost::property_traits<PointPMap>::value_type Point;
|
||||
typedef typename Kernel_traits<Point>::Kernel Kernel;
|
||||
return read_xyz_points
|
||||
<OutputIteratorValueType>(
|
||||
stream,
|
||||
output,
|
||||
point_pmap,
|
||||
Kernel());
|
||||
}
|
||||
|
||||
template <typename OutputIterator,
|
||||
typename PointPMap
|
||||
>
|
||||
|
|
@ -236,20 +370,41 @@ bool
|
|||
read_xyz_points(
|
||||
std::istream& stream, ///< input stream.
|
||||
OutputIterator output, ///< output iterator over points.
|
||||
PointPMap point_pmap) ///< property map OutputIterator -> Point_3.
|
||||
PointPMap point_pmap) ///< property map: value_type of OutputIterator -> Point_3.
|
||||
{
|
||||
typedef typename boost::property_traits<PointPMap>::value_type Point;
|
||||
typedef typename Kernel_traits<Point>::Kernel Kernel;
|
||||
return read_xyz_points(
|
||||
// just deduce value_type of OutputIterator
|
||||
return read_xyz_points
|
||||
<typename value_type_traits<OutputIterator>::type>(
|
||||
stream,
|
||||
output,
|
||||
point_pmap,
|
||||
Kernel());
|
||||
point_pmap);
|
||||
}
|
||||
//-----------------------------------------------------------------------------------
|
||||
/// @endcond
|
||||
|
||||
/// @cond SKIP_IN_MANUAL
|
||||
// This variant creates a default point property map = Dereference_property_map.
|
||||
// This variant creates a default point property map = Identity_property_map.
|
||||
//-----------------------------------------------------------------------------------
|
||||
template <typename OutputIteratorValueType,
|
||||
typename OutputIterator
|
||||
>
|
||||
bool
|
||||
read_xyz_points(
|
||||
std::istream& stream, ///< input stream.
|
||||
OutputIterator output) ///< output iterator over points.
|
||||
{
|
||||
return read_xyz_points
|
||||
<OutputIteratorValueType>(
|
||||
stream,
|
||||
output,
|
||||
#ifdef CGAL_USE_PROPERTY_MAPS_API_V1
|
||||
make_dereference_property_map(output)
|
||||
#else
|
||||
make_identity_property_map(OutputIteratorValueType())
|
||||
#endif
|
||||
);
|
||||
}
|
||||
|
||||
template <typename OutputIterator
|
||||
>
|
||||
bool
|
||||
|
|
@ -257,11 +412,13 @@ read_xyz_points(
|
|||
std::istream& stream, ///< input stream.
|
||||
OutputIterator output) ///< output iterator over points.
|
||||
{
|
||||
return read_xyz_points(
|
||||
// just deduce value_type of OutputIterator
|
||||
return read_xyz_points
|
||||
<typename value_type_traits<OutputIterator>::type>(
|
||||
stream,
|
||||
output,
|
||||
make_dereference_property_map(output));
|
||||
output);
|
||||
}
|
||||
//-----------------------------------------------------------------------------------
|
||||
/// @endcond
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ namespace CGAL {
|
|||
/// @tparam ForwardIterator iterator over input points.
|
||||
/// @tparam PointPMap is a model of `ReadablePropertyMap` with a value_type = Point_3<Kernel>.
|
||||
/// It can be omitted if ForwardIterator value_type is convertible to Point_3<Kernel>.
|
||||
/// @tparam NormalPMap is a model of `WritablePropertyMap` with a value_type = Vector_3<Kernel>.
|
||||
/// @tparam NormalPMap is a model of `ReadablePropertyMap` with a value_type = Vector_3<Kernel>.
|
||||
/// @tparam Kernel Geometric traits class.
|
||||
/// It can be omitted and deduced automatically from PointPMap value_type.
|
||||
///
|
||||
|
|
@ -64,8 +64,8 @@ write_off_points_and_normals(
|
|||
std::ostream& stream, ///< output stream.
|
||||
ForwardIterator first, ///< iterator over the first input point.
|
||||
ForwardIterator beyond, ///< past-the-end iterator over the input points.
|
||||
PointPMap point_pmap, ///< property map ForwardIterator -> Point_3.
|
||||
NormalPMap normal_pmap, ///< property map ForwardIterator -> Vector_3.
|
||||
PointPMap point_pmap, ///< property map: value_type of ForwardIterator -> Point_3.
|
||||
NormalPMap normal_pmap, ///< property map: value_type of ForwardIterator -> Vector_3.
|
||||
const Kernel& /*kernel*/) ///< geometric traits.
|
||||
{
|
||||
// basic geometric types
|
||||
|
|
@ -88,8 +88,13 @@ write_off_points_and_normals(
|
|||
// Write positions + normals
|
||||
for(ForwardIterator it = first; it != beyond; it++)
|
||||
{
|
||||
#ifdef CGAL_USE_PROPERTY_MAPS_API_V1
|
||||
Point p = get(point_pmap, it);
|
||||
Vector n = get(normal_pmap, it);
|
||||
#else
|
||||
Point p = get(point_pmap, *it);
|
||||
Vector n = get(normal_pmap, *it);
|
||||
#endif
|
||||
stream << p << " " << n << std::endl;
|
||||
}
|
||||
|
||||
|
|
@ -107,8 +112,8 @@ write_off_points_and_normals(
|
|||
std::ostream& stream, ///< output stream.
|
||||
ForwardIterator first, ///< first input point.
|
||||
ForwardIterator beyond, ///< past-the-end input point.
|
||||
PointPMap point_pmap, ///< property map OutputIterator -> Point_3.
|
||||
NormalPMap normal_pmap) ///< property map OutputIterator -> Vector_3.
|
||||
PointPMap point_pmap, ///< property map: value_type of OutputIterator -> Point_3.
|
||||
NormalPMap normal_pmap) ///< property map: value_type of OutputIterator -> Vector_3.
|
||||
{
|
||||
typedef typename boost::property_traits<PointPMap>::value_type Point;
|
||||
typedef typename Kernel_traits<Point>::Kernel Kernel;
|
||||
|
|
@ -122,7 +127,7 @@ write_off_points_and_normals(
|
|||
/// @endcond
|
||||
|
||||
/// @cond SKIP_IN_MANUAL
|
||||
// This variant creates a default point property map = Dereference_property_map.
|
||||
// This variant creates a default point property map = Identity_property_map.
|
||||
template <typename ForwardIterator,
|
||||
typename NormalPMap
|
||||
>
|
||||
|
|
@ -131,12 +136,17 @@ write_off_points_and_normals(
|
|||
std::ostream& stream, ///< output stream.
|
||||
ForwardIterator first, ///< first input point.
|
||||
ForwardIterator beyond, ///< past-the-end input point.
|
||||
NormalPMap normal_pmap) ///< property map OutputIterator -> Vector_3.
|
||||
NormalPMap normal_pmap) ///< property map: value_type of OutputIterator -> Vector_3.
|
||||
{
|
||||
return write_off_points_and_normals(
|
||||
stream,
|
||||
first, beyond,
|
||||
#ifdef CGAL_USE_PROPERTY_MAPS_API_V1
|
||||
make_dereference_property_map(first),
|
||||
#else
|
||||
make_identity_property_map(
|
||||
typename std::iterator_traits<ForwardIterator>::value_type()),
|
||||
#endif
|
||||
normal_pmap);
|
||||
}
|
||||
/// @endcond
|
||||
|
|
@ -165,7 +175,7 @@ write_off_points(
|
|||
std::ostream& stream, ///< output stream.
|
||||
ForwardIterator first, ///< iterator over the first input point.
|
||||
ForwardIterator beyond, ///< past-the-end iterator over the input points.
|
||||
PointPMap point_pmap, ///< property map ForwardIterator -> Point_3.
|
||||
PointPMap point_pmap, ///< property map: value_type of ForwardIterator -> Point_3.
|
||||
const Kernel& ) ///< geometric traits.
|
||||
{
|
||||
// basic geometric types
|
||||
|
|
@ -187,7 +197,11 @@ write_off_points(
|
|||
// Write positions
|
||||
for(ForwardIterator it = first; it != beyond; it++)
|
||||
{
|
||||
#ifdef CGAL_USE_PROPERTY_MAPS_API_V1
|
||||
Point p = get(point_pmap, it);
|
||||
#else
|
||||
Point p = get(point_pmap, *it);
|
||||
#endif
|
||||
stream << p << std::endl;
|
||||
}
|
||||
|
||||
|
|
@ -204,7 +218,7 @@ write_off_points(
|
|||
std::ostream& stream, ///< output stream.
|
||||
ForwardIterator first, ///< first input point.
|
||||
ForwardIterator beyond, ///< past-the-end input point.
|
||||
PointPMap point_pmap) ///< property map OutputIterator -> Point_3.
|
||||
PointPMap point_pmap) ///< property map: value_type of OutputIterator -> Point_3.
|
||||
{
|
||||
typedef typename boost::property_traits<PointPMap>::value_type Point;
|
||||
typedef typename Kernel_traits<Point>::Kernel Kernel;
|
||||
|
|
@ -217,7 +231,7 @@ write_off_points(
|
|||
/// @endcond
|
||||
|
||||
/// @cond SKIP_IN_MANUAL
|
||||
// This variant creates a default point property map = Dereference_property_map.
|
||||
// This variant creates a default point property map = Identity_property_map.
|
||||
template <typename ForwardIterator
|
||||
>
|
||||
bool
|
||||
|
|
@ -229,7 +243,13 @@ write_off_points(
|
|||
return write_off_points(
|
||||
stream,
|
||||
first, beyond,
|
||||
make_dereference_property_map(first));
|
||||
#ifdef CGAL_USE_PROPERTY_MAPS_API_V1
|
||||
make_dereference_property_map(first)
|
||||
#else
|
||||
make_identity_property_map(
|
||||
typename std::iterator_traits<ForwardIterator>::value_type())
|
||||
#endif
|
||||
);
|
||||
}
|
||||
/// @endcond
|
||||
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ namespace CGAL {
|
|||
/// @tparam ForwardIterator iterator over input points.
|
||||
/// @tparam PointPMap is a model of `ReadablePropertyMap` with a value_type = Point_3<Kernel>.
|
||||
/// It can be omitted if ForwardIterator value_type is convertible to Point_3<Kernel>.
|
||||
/// @tparam NormalPMap is a model of `WritablePropertyMap` with a value_type = Vector_3<Kernel>.
|
||||
/// @tparam NormalPMap is a model of `ReadablePropertyMap` with a value_type = Vector_3<Kernel>.
|
||||
/// @tparam Kernel Geometric traits class.
|
||||
/// It can be omitted and deduced automatically from PointPMap value_type.
|
||||
///
|
||||
|
|
@ -64,8 +64,8 @@ write_xyz_points_and_normals(
|
|||
std::ostream& stream, ///< output stream.
|
||||
ForwardIterator first, ///< iterator over the first input point.
|
||||
ForwardIterator beyond, ///< past-the-end iterator over the input points.
|
||||
PointPMap point_pmap, ///< property map ForwardIterator -> Point_3.
|
||||
NormalPMap normal_pmap, ///< property map ForwardIterator -> Vector_3.
|
||||
PointPMap point_pmap, ///< property map: value_type of ForwardIterator -> Point_3.
|
||||
NormalPMap normal_pmap, ///< property map: value_type of ForwardIterator -> Vector_3.
|
||||
const Kernel& /*kernel*/) ///< geometric traits.
|
||||
{
|
||||
// basic geometric types
|
||||
|
|
@ -83,8 +83,13 @@ write_xyz_points_and_normals(
|
|||
// Write positions + normals
|
||||
for(ForwardIterator it = first; it != beyond; it++)
|
||||
{
|
||||
#ifdef CGAL_USE_PROPERTY_MAPS_API_V1
|
||||
Point p = get(point_pmap, it);
|
||||
Vector n = get(normal_pmap, it);
|
||||
#else
|
||||
Point p = get(point_pmap, *it);
|
||||
Vector n = get(normal_pmap, *it);
|
||||
#endif
|
||||
stream << p << " " << n << std::endl;
|
||||
}
|
||||
|
||||
|
|
@ -102,8 +107,8 @@ write_xyz_points_and_normals(
|
|||
std::ostream& stream, ///< output stream.
|
||||
ForwardIterator first, ///< first input point.
|
||||
ForwardIterator beyond, ///< past-the-end input point.
|
||||
PointPMap point_pmap, ///< property map OutputIterator -> Point_3.
|
||||
NormalPMap normal_pmap) ///< property map OutputIterator -> Vector_3.
|
||||
PointPMap point_pmap, ///< property map: value_type of OutputIterator -> Point_3.
|
||||
NormalPMap normal_pmap) ///< property map: value_type of OutputIterator -> Vector_3.
|
||||
{
|
||||
typedef typename boost::property_traits<PointPMap>::value_type Point;
|
||||
typedef typename Kernel_traits<Point>::Kernel Kernel;
|
||||
|
|
@ -117,7 +122,7 @@ write_xyz_points_and_normals(
|
|||
/// @endcond
|
||||
|
||||
/// @cond SKIP_IN_MANUAL
|
||||
// This variant creates a default point property map = Dereference_property_map.
|
||||
// This variant creates a default point property map = Identity_property_map.
|
||||
template <typename ForwardIterator,
|
||||
typename NormalPMap
|
||||
>
|
||||
|
|
@ -126,12 +131,17 @@ write_xyz_points_and_normals(
|
|||
std::ostream& stream, ///< output stream.
|
||||
ForwardIterator first, ///< first input point.
|
||||
ForwardIterator beyond, ///< past-the-end input point.
|
||||
NormalPMap normal_pmap) ///< property map OutputIterator -> Vector_3.
|
||||
NormalPMap normal_pmap) ///< property map: value_type of ForwardIterator -> Vector_3.
|
||||
{
|
||||
return write_xyz_points_and_normals(
|
||||
stream,
|
||||
first, beyond,
|
||||
make_dereference_property_map(first),
|
||||
#ifdef CGAL_USE_PROPERTY_MAPS_API_V1
|
||||
make_dereference_property_map(output),
|
||||
#else
|
||||
make_identity_property_map(
|
||||
typename std::iterator_traits<ForwardIterator>::value_type()),
|
||||
#endif
|
||||
normal_pmap);
|
||||
}
|
||||
/// @endcond
|
||||
|
|
@ -160,7 +170,7 @@ write_xyz_points(
|
|||
std::ostream& stream, ///< output stream.
|
||||
ForwardIterator first, ///< iterator over the first input point.
|
||||
ForwardIterator beyond, ///< past-the-end iterator over the input points.
|
||||
PointPMap point_pmap, ///< property map ForwardIterator -> Point_3.
|
||||
PointPMap point_pmap, ///< property map: value_type of ForwardIterator -> Point_3.
|
||||
const Kernel& /*kernel*/) ///< geometric traits.
|
||||
{
|
||||
// basic geometric types
|
||||
|
|
@ -177,7 +187,12 @@ write_xyz_points(
|
|||
// Write positions
|
||||
for(ForwardIterator it = first; it != beyond; it++)
|
||||
{
|
||||
#ifdef CGAL_USE_PROPERTY_MAPS_API_V1
|
||||
Point p = get(point_pmap, it);
|
||||
#else
|
||||
Point p = get(point_pmap, *it);
|
||||
#endif
|
||||
|
||||
stream << p << std::endl;
|
||||
}
|
||||
|
||||
|
|
@ -194,7 +209,7 @@ write_xyz_points(
|
|||
std::ostream& stream, ///< output stream.
|
||||
ForwardIterator first, ///< first input point.
|
||||
ForwardIterator beyond, ///< past-the-end input point.
|
||||
PointPMap point_pmap) ///< property map OutputIterator -> Point_3.
|
||||
PointPMap point_pmap) ///< property map: value_type of OutputIterator -> Point_3.
|
||||
{
|
||||
typedef typename boost::property_traits<PointPMap>::value_type Point;
|
||||
typedef typename Kernel_traits<Point>::Kernel Kernel;
|
||||
|
|
@ -207,7 +222,7 @@ write_xyz_points(
|
|||
/// @endcond
|
||||
|
||||
/// @cond SKIP_IN_MANUAL
|
||||
// This variant creates a default point property map = Dereference_property_map.
|
||||
// This variant creates a default point property map = Identity_property_map.
|
||||
template <typename ForwardIterator
|
||||
>
|
||||
bool
|
||||
|
|
@ -219,7 +234,13 @@ write_xyz_points(
|
|||
return write_xyz_points(
|
||||
stream,
|
||||
first, beyond,
|
||||
make_dereference_property_map(first));
|
||||
#ifdef CGAL_USE_PROPERTY_MAPS_API_V1
|
||||
make_dereference_property_map(output)
|
||||
#else
|
||||
make_identity_property_map(
|
||||
typename std::iterator_traits<ForwardIterator>::value_type())
|
||||
#endif
|
||||
);
|
||||
}
|
||||
/// @endcond
|
||||
|
||||
|
|
|
|||
|
|
@ -26,6 +26,8 @@
|
|||
#include <CGAL/Origin.h>
|
||||
#include <CGAL/value_type_traits.h>
|
||||
|
||||
#include <CGAL/property_map.h>
|
||||
|
||||
#include <boost/version.hpp>
|
||||
#if BOOST_VERSION >= 104000
|
||||
#include <boost/property_map/property_map.hpp>
|
||||
|
|
@ -126,12 +128,56 @@ private:
|
|||
|
||||
//=========================================================================
|
||||
|
||||
#ifndef CGAL_USE_PROPERTY_MAPS_API_V1
|
||||
/// Property map that accesses the normal vector from a Point_with_normal_3 object
|
||||
///
|
||||
/// @heading Is Model for the Concepts:
|
||||
/// \cgalModels `LvaluePropertyMap`
|
||||
///
|
||||
/// @heading Parameters:
|
||||
/// @param Gt Geometric traits class.
|
||||
|
||||
template <class Gt>
|
||||
struct Normal_of_point_with_normal_pmap
|
||||
{
|
||||
typedef Point_with_normal_3<Gt> Point_with_normal; ///< Position + normal
|
||||
typedef typename Gt::Vector_3 Vector; /// normal
|
||||
|
||||
typedef Point_with_normal key_type;
|
||||
typedef Vector value_type;
|
||||
typedef value_type& reference;
|
||||
typedef boost::lvalue_property_map_tag category;
|
||||
|
||||
/// Access a property map element
|
||||
reference operator[](key_type& pwn) const { return pwn.normal(); }
|
||||
|
||||
typedef Normal_of_point_with_normal_pmap<Gt> Self;
|
||||
/// \name Put/get free functions
|
||||
/// @{
|
||||
friend const value_type& get(const Self&,const key_type& k) {return k.normal();}
|
||||
friend reference get(const Self&, key_type& k) {return k.normal();}
|
||||
friend void put(const Self&,key_type& k, const value_type& v) {k.normal()=v;}
|
||||
/// @};}
|
||||
};
|
||||
|
||||
/// Free function to create a Normal_of_point_with_normal_pmap property map.
|
||||
///
|
||||
/// @relates Normal_of_point_with_normal_pmap
|
||||
|
||||
template <class Point_with_normal> // Point_with_normal type
|
||||
Normal_of_point_with_normal_pmap<
|
||||
typename CGAL::Kernel_traits<Point_with_normal>::Kernel>
|
||||
make_normal_of_point_with_normal_pmap(Point_with_normal)
|
||||
{
|
||||
return Normal_of_point_with_normal_pmap<typename CGAL::Kernel_traits<Point_with_normal>::Kernel>();
|
||||
}
|
||||
|
||||
#else
|
||||
/// Property map that accesses the normal vector from a Point_with_normal_3* pointer
|
||||
/// (or in general an iterator over Point_with_normal_3 elements).
|
||||
///
|
||||
/// @heading Is Model for the Concepts:
|
||||
/// Model of `LvaluePropertyMap` concept.
|
||||
/// \cgalModels `LvaluePropertyMap`
|
||||
///
|
||||
/// @heading Parameters:
|
||||
/// @param Gt Geometric traits class.
|
||||
|
|
@ -169,6 +215,7 @@ make_normal_of_point_with_normal_pmap(Iter)
|
|||
typedef typename CGAL::Kernel_traits<Value_type>::Kernel Kernel;
|
||||
return Normal_of_point_with_normal_pmap<Kernel>();
|
||||
}
|
||||
#endif
|
||||
|
||||
/// \endcond
|
||||
|
||||
|
|
|
|||
|
|
@ -114,7 +114,7 @@ typename Kernel::FT
|
|||
compute_average_spacing(
|
||||
InputIterator first, ///< iterator over the first input point.
|
||||
InputIterator beyond, ///< past-the-end iterator over the input points.
|
||||
PointPMap point_pmap, ///< property map InputIterator -> Point_3
|
||||
PointPMap point_pmap, ///< property map: value_type of InputIterator -> Point_3
|
||||
unsigned int k, ///< number of neighbors.
|
||||
const Kernel& /*kernel*/) ///< geometric traits.
|
||||
{
|
||||
|
|
@ -140,7 +140,11 @@ compute_average_spacing(
|
|||
std::vector<Point> kd_tree_points;
|
||||
for(InputIterator it = first; it != beyond; it++)
|
||||
{
|
||||
#ifdef CGAL_USE_PROPERTY_MAPS_API_V1
|
||||
Point point = get(point_pmap, it);
|
||||
#else
|
||||
Point point = get(point_pmap, *it);
|
||||
#endif
|
||||
kd_tree_points.push_back(point);
|
||||
}
|
||||
Tree tree(kd_tree_points.begin(), kd_tree_points.end());
|
||||
|
|
@ -151,7 +155,14 @@ compute_average_spacing(
|
|||
unsigned int nb_points = 0;
|
||||
for(InputIterator it = first; it != beyond; it++)
|
||||
{
|
||||
sum_spacings += internal::compute_average_spacing<Kernel,Tree>(get(point_pmap,it),tree,k);
|
||||
sum_spacings += internal::compute_average_spacing<Kernel,Tree>(
|
||||
|
||||
#ifdef CGAL_USE_PROPERTY_MAPS_API_V1
|
||||
get(point_pmap,it),
|
||||
#else
|
||||
get(point_pmap,*it),
|
||||
#endif
|
||||
tree,k);
|
||||
nb_points++;
|
||||
}
|
||||
|
||||
|
|
@ -168,7 +179,7 @@ typename Kernel_traits<typename boost::property_traits<PointPMap>::value_type>::
|
|||
compute_average_spacing(
|
||||
InputIterator first, ///< iterator over the first input point.
|
||||
InputIterator beyond, ///< past-the-end iterator over the input points.
|
||||
PointPMap point_pmap, ///< property map InputIterator -> Point_3
|
||||
PointPMap point_pmap, ///< property map: value_type of InputIterator -> Point_3
|
||||
unsigned int k) ///< number of neighbors
|
||||
{
|
||||
typedef typename boost::property_traits<PointPMap>::value_type Point;
|
||||
|
|
@ -182,7 +193,7 @@ compute_average_spacing(
|
|||
/// @endcond
|
||||
|
||||
/// @cond SKIP_IN_MANUAL
|
||||
// This variant creates a default point property map = Dereference_property_map.
|
||||
// This variant creates a default point property map = Identity_property_map.
|
||||
template < typename InputIterator >
|
||||
typename Kernel_traits<typename std::iterator_traits<InputIterator>::value_type>::Kernel::FT
|
||||
compute_average_spacing(
|
||||
|
|
@ -192,7 +203,12 @@ compute_average_spacing(
|
|||
{
|
||||
return compute_average_spacing(
|
||||
first,beyond,
|
||||
#ifdef CGAL_USE_PROPERTY_MAPS_API_V1
|
||||
make_dereference_property_map(first),
|
||||
#else
|
||||
make_identity_property_map(
|
||||
typename std::iterator_traits<InputIterator>::value_type()),
|
||||
#endif
|
||||
k);
|
||||
}
|
||||
/// @endcond
|
||||
|
|
|
|||
|
|
@ -64,8 +64,13 @@ public:
|
|||
typedef typename boost::property_traits<PointPMap>::value_type Point;
|
||||
|
||||
// Round points to multiples of m_epsilon, then compare.
|
||||
Point a_n = get(point_pmap,&a),
|
||||
b_n = get(point_pmap,&b);
|
||||
#ifdef CGAL_USE_PROPERTY_MAPS_API_V1
|
||||
Point a_n = get(point_pmap,&a);
|
||||
Point b_n = get(point_pmap,&b);
|
||||
#else
|
||||
Point a_n = get(point_pmap,a);
|
||||
Point b_n = get(point_pmap,b);
|
||||
#endif
|
||||
|
||||
Point rounded_a(round_epsilon(a_n.x(), m_epsilon),
|
||||
round_epsilon(a_n.y(), m_epsilon),
|
||||
|
|
@ -150,7 +155,7 @@ template <typename ForwardIterator,
|
|||
ForwardIterator grid_simplify_point_set(
|
||||
ForwardIterator first, ///< iterator over the first input point.
|
||||
ForwardIterator beyond, ///< past-the-end iterator over the input points.
|
||||
PointPMap point_pmap, ///< property map ForwardIterator -> Point_3
|
||||
PointPMap point_pmap, ///< property map: value_type of ForwardIterator -> Point_3
|
||||
double epsilon, ///< tolerance value when merging 3D points.
|
||||
const Kernel& /*kernel*/) ///< geometric traits.
|
||||
{
|
||||
|
|
@ -188,7 +193,7 @@ ForwardIterator
|
|||
grid_simplify_point_set(
|
||||
ForwardIterator first, ///< iterator over the first input point
|
||||
ForwardIterator beyond, ///< past-the-end iterator
|
||||
PointPMap point_pmap, ///< property map ForwardIterator -> Point_3
|
||||
PointPMap point_pmap, ///< property map: value_type of ForwardIterator -> Point_3
|
||||
double epsilon) ///< tolerance value when merging 3D points
|
||||
{
|
||||
typedef typename boost::property_traits<PointPMap>::value_type Point;
|
||||
|
|
@ -202,7 +207,7 @@ grid_simplify_point_set(
|
|||
/// @endcond
|
||||
|
||||
/// @cond SKIP_IN_MANUAL
|
||||
// This variant creates a default point property map = Dereference_property_map.
|
||||
// This variant creates a default point property map = Identity_property_map.
|
||||
template <typename ForwardIterator
|
||||
>
|
||||
ForwardIterator
|
||||
|
|
@ -213,7 +218,12 @@ grid_simplify_point_set(
|
|||
{
|
||||
return grid_simplify_point_set(
|
||||
first,beyond,
|
||||
#ifdef CGAL_USE_PROPERTY_MAPS_API_V1
|
||||
make_dereference_property_map(first),
|
||||
#else
|
||||
make_identity_property_map(
|
||||
typename std::iterator_traits<ForwardIterator>::value_type()),
|
||||
#endif
|
||||
epsilon);
|
||||
}
|
||||
/// @endcond
|
||||
|
|
|
|||
|
|
@ -205,7 +205,7 @@ improved_jet_smooth_point(
|
|||
/// \pre `k >= 2`
|
||||
///
|
||||
/// @tparam ForwardIterator iterator over input points.
|
||||
/// @tparam PointPMap is a model of `ReadablePropertyMap` with a value_type = Point_3<Kernel>.
|
||||
/// @tparam PointPMap is a model of `ReadWritePropertyMap` with a value_type = Point_3<Kernel>.
|
||||
/// It can be omitted if ForwardIterator value_type is convertible to Point_3<Kernel>.
|
||||
/// @tparam Kernel Geometric traits class.
|
||||
/// It can be omitted and deduced automatically from PointPMap value_type.
|
||||
|
|
@ -219,7 +219,7 @@ void
|
|||
improved_jet_smooth_point_set(
|
||||
ForwardIterator first, ///< iterator over the first input point.
|
||||
ForwardIterator beyond, ///< past-the-end iterator over the input points.
|
||||
PointPMap point_pmap, ///< property map ForwardIterator -> Point_3.
|
||||
PointPMap point_pmap, ///< property map: value_type of ForwardIterator -> Point_3.
|
||||
unsigned int k, ///< number of neighbors.
|
||||
const unsigned int iter_number, ///< number of iterations.
|
||||
const Kernel& kernel, ///< geometric traits.
|
||||
|
|
@ -255,15 +255,25 @@ improved_jet_smooth_point_set(
|
|||
std::vector<KdTreeElement> treeElements;
|
||||
for (it = first, i=0 ; it != beyond ; ++it,++i)
|
||||
{
|
||||
Point& p0 = get(point_pmap,it);
|
||||
#ifdef CGAL_USE_PROPERTY_MAPS_API_V1
|
||||
const Point& p0 = get(point_pmap,it);
|
||||
#else
|
||||
const Point& p0 = get(point_pmap,*it);
|
||||
#endif
|
||||
treeElements.push_back(KdTreeElement(p0,i));
|
||||
}
|
||||
Tree tree(treeElements.begin(), treeElements.end());
|
||||
|
||||
std::vector<Point> p(nb_points); // positions at step iter_n
|
||||
std::vector<Vector> b(nb_points); // ...
|
||||
for(it = first, i=0; it != beyond; it++, ++i)
|
||||
p[i] = get(point_pmap,it);
|
||||
for(it = first, i=0; it != beyond; it++, ++i) {
|
||||
#ifdef CGAL_USE_PROPERTY_MAPS_API_V1
|
||||
p[i] = get(point_pmap,it);
|
||||
#else
|
||||
p[i] = get(point_pmap,*it);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
// loop until convergence
|
||||
for(int iter_n = 0; iter_n < iter_number ; ++iter_n)
|
||||
|
|
@ -273,7 +283,11 @@ improved_jet_smooth_point_set(
|
|||
// Iterates over input points, computes (original) Laplacian smoothing and b[].
|
||||
for(it = first, i=0; it != beyond; it++, ++i)
|
||||
{
|
||||
Point& p0 = get(point_pmap,it);
|
||||
#ifdef CGAL_USE_PROPERTY_MAPS_API_V1
|
||||
const Point& p0 = get(point_pmap,it);
|
||||
#else
|
||||
const Point& p0 = get(point_pmap,*it);
|
||||
#endif
|
||||
Point np = improved_jet_smoothing_i::jet_smooth_point<Kernel>(p0,tree,kk);
|
||||
b[i] = alpha*(np - p0) + (1-alpha)*(np - p[i]);
|
||||
p[i] = np;
|
||||
|
|
@ -290,8 +304,11 @@ improved_jet_smooth_point_set(
|
|||
// Implementation note: the cast to Point& allows to modify only the point's position.
|
||||
for(it = first, i=0; it != beyond; it++, ++i)
|
||||
{
|
||||
Point& p0 = get(point_pmap,it);
|
||||
p0 = p[i];
|
||||
#ifdef CGAL_USE_PROPERTY_MAPS_API_V1
|
||||
put(point_pmap, it, p[i]);
|
||||
#else
|
||||
put(point_pmap, *it, p[i]);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -305,7 +322,7 @@ void
|
|||
improved_jet_smooth_point_set(
|
||||
ForwardIterator first, ///< iterator over the first input point
|
||||
ForwardIterator beyond, ///< past-the-end iterator
|
||||
PointPMap point_pmap, ///< property map ForwardIterator -> Point_3
|
||||
PointPMap point_pmap, ///< property map: value_type of ForwardIterator -> Point_3
|
||||
unsigned int k, ///< number of neighbors.
|
||||
const unsigned int iter_number,
|
||||
FT alpha,
|
||||
|
|
@ -324,7 +341,7 @@ improved_jet_smooth_point_set(
|
|||
/// @endcond
|
||||
|
||||
/// @cond SKIP_IN_MANUAL
|
||||
// This variant creates a default point property map = Dereference_property_map.
|
||||
// This variant creates a default point property map = Identity_property_map.
|
||||
template <typename ForwardIterator,
|
||||
typename FT
|
||||
>
|
||||
|
|
@ -339,7 +356,12 @@ improved_jet_smooth_point_set(
|
|||
{
|
||||
return improved_jet_smooth_point_set(
|
||||
first,beyond,
|
||||
#ifdef CGAL_USE_PROPERTY_MAPS_API_V1
|
||||
make_dereference_property_map(first),
|
||||
#else
|
||||
make_identity_property_map(
|
||||
typename std::iterator_traits<ForwardIterator>::value_type()),
|
||||
#endif
|
||||
k,
|
||||
iter_number,
|
||||
alpha, beta);
|
||||
|
|
|
|||
|
|
@ -188,7 +188,7 @@ improved_laplacian_smooth_point(
|
|||
/// \pre `k >= 2`
|
||||
///
|
||||
/// @tparam ForwardIterator iterator over input points.
|
||||
/// @tparam PointPMap is a model of `ReadablePropertyMap` with a value_type = Point_3<Kernel>.
|
||||
/// @tparam PointPMap is a model of `ReadWritePropertyMap` with a value_type = Point_3<Kernel>.
|
||||
/// It can be omitted if ForwardIterator value_type is convertible to Point_3<Kernel>.
|
||||
/// @tparam Kernel Geometric traits class.
|
||||
/// It can be omitted and deduced automatically from PointPMap value_type.
|
||||
|
|
@ -202,7 +202,7 @@ void
|
|||
improved_laplacian_smooth_point_set(
|
||||
ForwardIterator first, ///< iterator over the first input point.
|
||||
ForwardIterator beyond, ///< past-the-end iterator over the input points.
|
||||
PointPMap point_pmap, ///< property map ForwardIterator -> Point_3.
|
||||
PointPMap point_pmap, ///< property map: value_type of ForwardIterator -> Point_3.
|
||||
unsigned int k, ///< number of neighbors.
|
||||
const unsigned int iter_number, ///< number of iterations.
|
||||
const Kernel& kernel, ///< geometric traits.
|
||||
|
|
@ -238,15 +238,24 @@ improved_laplacian_smooth_point_set(
|
|||
std::vector<KdTreeElement> treeElements;
|
||||
for (it = first, i=0 ; it != beyond ; ++it,++i)
|
||||
{
|
||||
Point& p0 = get(point_pmap,it);
|
||||
#ifdef CGAL_USE_PROPERTY_MAPS_API_V1
|
||||
const Point& p0 = get(point_pmap,it);
|
||||
#else
|
||||
const Point& p0 = get(point_pmap,*it);
|
||||
#endif
|
||||
treeElements.push_back(KdTreeElement(p0,i));
|
||||
}
|
||||
Tree tree(treeElements.begin(), treeElements.end());
|
||||
|
||||
std::vector<Point> p(nb_points); // positions at step iter_n
|
||||
std::vector<Vector> b(nb_points); // ...
|
||||
for(it = first, i=0; it != beyond; it++, ++i)
|
||||
for(it = first, i=0; it != beyond; it++, ++i) {
|
||||
#ifdef CGAL_USE_PROPERTY_MAPS_API_V1
|
||||
p[i] = get(point_pmap,it);
|
||||
#else
|
||||
p[i] = get(point_pmap,*it);
|
||||
#endif
|
||||
}
|
||||
|
||||
// loop until convergence
|
||||
for(int iter_n = 0; iter_n < iter_number ; ++iter_n)
|
||||
|
|
@ -254,7 +263,11 @@ improved_laplacian_smooth_point_set(
|
|||
// Iterates over input points, computes (original) Laplacian smoothing and b[].
|
||||
for(it = first, i=0; it != beyond; it++, ++i)
|
||||
{
|
||||
Point& p0 = get(point_pmap,it);
|
||||
#ifdef CGAL_USE_PROPERTY_MAPS_API_V1
|
||||
const Point& p0 = get(point_pmap,it);
|
||||
#else
|
||||
const Point& p0 = get(point_pmap,*it);
|
||||
#endif
|
||||
Point np = improved_laplacian_smoothing_i::laplacian_smooth_point<Kernel>(p0,tree,k);
|
||||
b[i] = alpha*(np - p0) + (1-alpha)*(np - p[i]);
|
||||
p[i] = np;
|
||||
|
|
@ -271,8 +284,11 @@ improved_laplacian_smooth_point_set(
|
|||
// Implementation note: the cast to Point& allows to modify only the point's position.
|
||||
for(it = first, i=0; it != beyond; it++, ++i)
|
||||
{
|
||||
Point& p0 = get(point_pmap,it);
|
||||
p0 = p[i];
|
||||
#ifdef CGAL_USE_PROPERTY_MAPS_API_V1
|
||||
put(point_pmap, it, p[i]);
|
||||
#else
|
||||
put(point_pmap, *it, p[i]);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -286,7 +302,7 @@ void
|
|||
improved_laplacian_smooth_point_set(
|
||||
ForwardIterator first, ///< iterator over the first input point
|
||||
ForwardIterator beyond, ///< past-the-end iterator
|
||||
PointPMap point_pmap, ///< property map ForwardIterator -> Point_3
|
||||
PointPMap point_pmap, ///< property map: value_type of ForwardIterator -> Point_3
|
||||
unsigned int k, ///< number of neighbors.
|
||||
const unsigned int iter_number,
|
||||
FT alpha,
|
||||
|
|
@ -305,7 +321,7 @@ improved_laplacian_smooth_point_set(
|
|||
/// @endcond
|
||||
|
||||
/// @cond SKIP_IN_MANUAL
|
||||
// This variant creates a default point property map = Dereference_property_map.
|
||||
// This variant creates a default point property map = Identity_property_map.
|
||||
template <typename ForwardIterator,
|
||||
typename FT
|
||||
>
|
||||
|
|
@ -320,7 +336,12 @@ improved_laplacian_smooth_point_set(
|
|||
{
|
||||
return improved_laplacian_smooth_point_set(
|
||||
first,beyond,
|
||||
#ifdef CGAL_USE_PROPERTY_MAPS_API_V1
|
||||
make_dereference_property_map(first),
|
||||
#else
|
||||
make_identity_property_map(
|
||||
typename std::iterator_traits<ForwardIterator>::value_type()),
|
||||
#endif
|
||||
k,
|
||||
iter_number,
|
||||
alpha, beta);
|
||||
|
|
|
|||
|
|
@ -114,6 +114,7 @@ jet_estimate_normal(const typename Kernel::Point_3& query, ///< point to compute
|
|||
///
|
||||
/// \pre `k >= 2`
|
||||
///
|
||||
|
||||
/// @tparam ForwardIterator iterator model of the concept of the same name over input points and able to store output normals.
|
||||
/// @tparam PointPMap is a model of `ReadablePropertyMap` with a value_type = Point_3<Kernel>.
|
||||
/// It can be omitted if ForwardIterator value_type is convertible to Point_3<Kernel>.
|
||||
|
|
@ -131,8 +132,8 @@ void
|
|||
jet_estimate_normals(
|
||||
ForwardIterator first, ///< iterator over the first input point.
|
||||
ForwardIterator beyond, ///< past-the-end iterator over the input points.
|
||||
PointPMap point_pmap, ///< property map ForwardIterator -> Point_3.
|
||||
NormalPMap normal_pmap, ///< property map ForwardIterator -> Vector_3.
|
||||
PointPMap point_pmap, ///< property map: value_type of ForwardIterator -> Point_3.
|
||||
NormalPMap normal_pmap, ///< property map: value_type of ForwardIterator -> Vector_3.
|
||||
unsigned int k, ///< number of neighbors.
|
||||
const Kernel& /*kernel*/, ///< geometric traits.
|
||||
unsigned int degree_fitting = 2) ///< fitting degree
|
||||
|
|
@ -168,7 +169,11 @@ jet_estimate_normals(
|
|||
std::vector<Point> kd_tree_points;
|
||||
for(it = first; it != beyond; it++)
|
||||
{
|
||||
#ifdef CGAL_USE_PROPERTY_MAPS_API_V1
|
||||
Point point = get(point_pmap, it);
|
||||
#else
|
||||
Point point = get(point_pmap, *it);
|
||||
#endif
|
||||
kd_tree_points.push_back(point);
|
||||
}
|
||||
Tree tree(kd_tree_points.begin(), kd_tree_points.end());
|
||||
|
|
@ -180,8 +185,20 @@ jet_estimate_normals(
|
|||
// vectors (already normalized)
|
||||
for(it = first; it != beyond; it++)
|
||||
{
|
||||
Vector normal = internal::jet_estimate_normal<Kernel,Tree>(get(point_pmap,it), tree, k, degree_fitting);
|
||||
Vector normal = internal::jet_estimate_normal<Kernel,Tree>(
|
||||
#ifdef CGAL_USE_PROPERTY_MAPS_API_V1
|
||||
get(point_pmap,it),
|
||||
#else
|
||||
get(point_pmap,*it),
|
||||
#endif
|
||||
tree, k, degree_fitting);
|
||||
|
||||
#ifdef CGAL_USE_PROPERTY_MAPS_API_V1
|
||||
put(normal_pmap, it, normal); // normal_pmap[it] = normal
|
||||
#else
|
||||
put(normal_pmap, *it, normal); // normal_pmap[it] = normal
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
memory = CGAL::Memory_sizer().virtual_size(); CGAL_TRACE(" %ld Mb allocated\n", memory>>20);
|
||||
|
|
@ -198,8 +215,8 @@ void
|
|||
jet_estimate_normals(
|
||||
ForwardIterator first, ///< iterator over the first input point.
|
||||
ForwardIterator beyond, ///< past-the-end iterator over the input points.
|
||||
PointPMap point_pmap, ///< property map ForwardIterator -> Point_3.
|
||||
NormalPMap normal_pmap, ///< property map ForwardIterator -> Vector_3.
|
||||
PointPMap point_pmap, ///< property map: value_type of ForwardIterator -> Point_3.
|
||||
NormalPMap normal_pmap, ///< property map: value_type of ForwardIterator -> Vector_3.
|
||||
unsigned int k, ///< number of neighbors.
|
||||
unsigned int degree_fitting = 2)
|
||||
{
|
||||
|
|
@ -216,7 +233,7 @@ jet_estimate_normals(
|
|||
/// @endcond
|
||||
|
||||
/// @cond SKIP_IN_MANUAL
|
||||
// This variant creates a default point property map = Dereference_property_map.
|
||||
// This variant creates a default point property map = Identity_property_map.
|
||||
template <typename ForwardIterator,
|
||||
typename NormalPMap
|
||||
>
|
||||
|
|
@ -224,13 +241,18 @@ void
|
|||
jet_estimate_normals(
|
||||
ForwardIterator first, ///< iterator over the first input point.
|
||||
ForwardIterator beyond, ///< past-the-end iterator over the input points.
|
||||
NormalPMap normal_pmap, ///< property map ForwardIterator -> Vector_3.
|
||||
NormalPMap normal_pmap, ///< property map: value_type of ForwardIterator -> Vector_3.
|
||||
unsigned int k, ///< number of neighbors.
|
||||
unsigned int degree_fitting = 2)
|
||||
{
|
||||
jet_estimate_normals(
|
||||
first,beyond,
|
||||
make_dereference_property_map(first),
|
||||
#ifdef CGAL_USE_PROPERTY_MAPS_API_V1
|
||||
make_dereference_property_map(first),
|
||||
#else
|
||||
make_identity_property_map(
|
||||
typename std::iterator_traits<ForwardIterator>::value_type()),
|
||||
#endif
|
||||
normal_pmap,
|
||||
k,
|
||||
degree_fitting);
|
||||
|
|
|
|||
|
|
@ -115,7 +115,7 @@ jet_smooth_point(
|
|||
/// \pre `k >= 2`
|
||||
///
|
||||
/// @tparam InputIterator iterator over input points.
|
||||
/// @tparam PointPMap is a model of `ReadablePropertyMap` with a value_type = Point_3<Kernel>.
|
||||
/// @tparam PointPMap is a model of `ReadWritePropertyMap` with a value_type = Point_3<Kernel>.
|
||||
/// It can be omitted if InputIterator value_type is convertible to Point_3<Kernel>.
|
||||
/// @tparam Kernel Geometric traits class.
|
||||
/// It can be omitted and deduced automatically from PointPMap value_type.
|
||||
|
|
@ -129,7 +129,7 @@ void
|
|||
jet_smooth_point_set(
|
||||
InputIterator first, ///< iterator over the first input point.
|
||||
InputIterator beyond, ///< past-the-end iterator over the input points.
|
||||
PointPMap point_pmap, ///< property map InputIterator -> Point_3.
|
||||
PointPMap point_pmap, ///< property map: value_type of InputIterator -> Point_3.
|
||||
unsigned int k, ///< number of neighbors.
|
||||
const Kernel& /*kernel*/, ///< geometric traits.
|
||||
unsigned int degree_fitting = 2, ///< fitting degree
|
||||
|
|
@ -158,7 +158,11 @@ jet_smooth_point_set(
|
|||
std::vector<Point> kd_tree_points;
|
||||
for(it = first; it != beyond; it++)
|
||||
{
|
||||
#ifdef CGAL_USE_PROPERTY_MAPS_API_V1
|
||||
Point point = get(point_pmap, it);
|
||||
#else
|
||||
Point point = get(point_pmap, *it);
|
||||
#endif
|
||||
kd_tree_points.push_back(point);
|
||||
}
|
||||
Tree tree(kd_tree_points.begin(), kd_tree_points.end());
|
||||
|
|
@ -167,8 +171,15 @@ jet_smooth_point_set(
|
|||
// Implementation note: the cast to Point& allows to modify only the point's position.
|
||||
for(it = first; it != beyond; it++)
|
||||
{
|
||||
Point& p = get(point_pmap, it);
|
||||
p = internal::jet_smooth_point<Kernel>(p,tree,k,degree_fitting,degree_monge);
|
||||
#ifdef CGAL_USE_PROPERTY_MAPS_API_V1
|
||||
const Point& p = get(point_pmap, it);
|
||||
put(point_pmap, it ,
|
||||
internal::jet_smooth_point<Kernel>(p,tree,k,degree_fitting,degree_monge) );
|
||||
#else
|
||||
const Point& p = get(point_pmap, *it);
|
||||
put(point_pmap, *it ,
|
||||
internal::jet_smooth_point<Kernel>(p,tree,k,degree_fitting,degree_monge) );
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -181,7 +192,7 @@ void
|
|||
jet_smooth_point_set(
|
||||
InputIterator first, ///< iterator over the first input point
|
||||
InputIterator beyond, ///< past-the-end iterator
|
||||
PointPMap point_pmap, ///< property map InputIterator -> Point_3
|
||||
PointPMap point_pmap, ///< property map: value_type of InputIterator -> Point_3
|
||||
unsigned int k, ///< number of neighbors.
|
||||
const unsigned int degree_fitting = 2,
|
||||
const unsigned int degree_monge = 2)
|
||||
|
|
@ -198,7 +209,7 @@ jet_smooth_point_set(
|
|||
/// @endcond
|
||||
|
||||
/// @cond SKIP_IN_MANUAL
|
||||
// This variant creates a default point property map = Dereference_property_map.
|
||||
// This variant creates a default point property map = Identity_property_map.
|
||||
template <typename InputIterator
|
||||
>
|
||||
void
|
||||
|
|
@ -211,7 +222,12 @@ jet_smooth_point_set(
|
|||
{
|
||||
jet_smooth_point_set(
|
||||
first,beyond,
|
||||
#ifdef CGAL_USE_PROPERTY_MAPS_API_V1
|
||||
make_dereference_property_map(first),
|
||||
#else
|
||||
make_identity_property_map(
|
||||
typename std::iterator_traits<InputIterator>::value_type()),
|
||||
#endif
|
||||
k,
|
||||
degree_fitting,degree_monge);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -102,7 +102,7 @@ struct MST_graph_vertex_properties {
|
|||
bool is_oriented; ///< Is input point's normal oriented?
|
||||
};
|
||||
template <typename ForwardIterator, ///< Input point iterator
|
||||
typename NormalPMap, ///< property map ForwardIterator -> Normal
|
||||
typename NormalPMap, ///< property map: value_type of ForwardIterator -> Normal
|
||||
typename Kernel ///< Geometric traits class
|
||||
>
|
||||
class MST_graph
|
||||
|
|
@ -134,7 +134,7 @@ public:
|
|||
/// @tparam Kernel Geometric traits class.
|
||||
|
||||
template <typename ForwardIterator, ///< Input point iterator
|
||||
typename NormalPMap, ///< property map ForwardIterator -> Normal
|
||||
typename NormalPMap, ///< property map: value_type of ForwardIterator -> Normal
|
||||
typename Kernel
|
||||
>
|
||||
struct Propagate_normal_orientation
|
||||
|
|
@ -158,21 +158,33 @@ struct Propagate_normal_orientation
|
|||
|
||||
// Gets source normal
|
||||
vertex_descriptor source_vertex = boost::source(edge, mst_graph);
|
||||
const Vector source_normal = mst_graph.m_normal_pmap[mst_graph[source_vertex].input_point];
|
||||
#ifdef CGAL_USE_PROPERTY_MAPS_API_V1
|
||||
const Vector source_normal = get(mst_graph.m_normal_pmap, mst_graph[source_vertex].input_point);
|
||||
#else
|
||||
const Vector source_normal = get(mst_graph.m_normal_pmap, *(mst_graph[source_vertex].input_point) );
|
||||
#endif
|
||||
const bool source_normal_is_oriented = mst_graph[source_vertex].is_oriented;
|
||||
|
||||
// Gets target normal
|
||||
vertex_descriptor target_vertex = boost::target(edge, mst_graph);
|
||||
Vector& target_normal = mst_graph.m_normal_pmap[mst_graph[target_vertex].input_point];
|
||||
#ifdef CGAL_USE_PROPERTY_MAPS_API_V1
|
||||
const Vector& target_normal = get( mst_graph.m_normal_pmap, mst_graph[target_vertex].input_point);
|
||||
#else
|
||||
const Vector& target_normal = get( mst_graph.m_normal_pmap, *(mst_graph[target_vertex].input_point) );
|
||||
#endif
|
||||
bool& target_normal_is_oriented = ((MST_graph&)mst_graph)[target_vertex].is_oriented;
|
||||
|
||||
if ( ! target_normal_is_oriented )
|
||||
{
|
||||
// -> ->
|
||||
// Orients target_normal parallel to source_normal
|
||||
double normals_dot = source_normal * target_normal;
|
||||
if (normals_dot < 0)
|
||||
target_normal = -target_normal;
|
||||
{
|
||||
#ifdef CGAL_USE_PROPERTY_MAPS_API_V1
|
||||
put( mst_graph.m_normal_pmap, mst_graph[target_vertex].input_point, -target_normal);
|
||||
#else
|
||||
put( mst_graph.m_normal_pmap, *(mst_graph[target_vertex].input_point), -target_normal );
|
||||
#endif
|
||||
}
|
||||
|
||||
// Is orientation robust?
|
||||
target_normal_is_oriented
|
||||
|
|
@ -204,8 +216,8 @@ ForwardIterator
|
|||
mst_find_source(
|
||||
ForwardIterator first, ///< iterator over the first input point.
|
||||
ForwardIterator beyond, ///< past-the-end iterator over the input points.
|
||||
PointPMap point_pmap, ///< property map ForwardIterator -> Point_3
|
||||
NormalPMap normal_pmap, ///< property map ForwardIterator -> Vector_3
|
||||
PointPMap point_pmap, ///< property map: value_type of ForwardIterator -> Point_3
|
||||
NormalPMap normal_pmap, ///< property map: value_type of ForwardIterator -> Vector_3
|
||||
const Kernel& /*kernel*/) ///< geometric traits.
|
||||
{
|
||||
CGAL_TRACE(" mst_find_source()\n");
|
||||
|
|
@ -220,18 +232,33 @@ mst_find_source(
|
|||
ForwardIterator top_point = first;
|
||||
for (ForwardIterator v = ++first; v != beyond; v++)
|
||||
{
|
||||
|
||||
#ifdef CGAL_USE_PROPERTY_MAPS_API_V1
|
||||
double top_z = get(point_pmap,top_point).z(); // top_point's Z coordinate
|
||||
double z = get(point_pmap,v).z();
|
||||
#else
|
||||
double top_z = get(point_pmap,*top_point).z(); // top_point's Z coordinate
|
||||
double z = get(point_pmap,*v).z();
|
||||
#endif
|
||||
|
||||
if (top_z < z)
|
||||
top_point = v;
|
||||
}
|
||||
|
||||
// Orients its normal towards +Z axis
|
||||
Vector& normal = get(normal_pmap,top_point);
|
||||
#ifdef CGAL_USE_PROPERTY_MAPS_API_V1
|
||||
const Vector& normal = get(normal_pmap,top_point);
|
||||
#else
|
||||
const Vector& normal = get(normal_pmap,*top_point);
|
||||
#endif
|
||||
const Vector Z(0, 0, 1);
|
||||
if (Z * normal < 0) {
|
||||
CGAL_TRACE(" Flip top point normal\n");
|
||||
normal = -normal;
|
||||
#ifdef CGAL_USE_PROPERTY_MAPS_API_V1
|
||||
put(normal_pmap,top_point, -normal);
|
||||
#else
|
||||
put(normal_pmap,*top_point, -normal);
|
||||
#endif
|
||||
}
|
||||
|
||||
return top_point;
|
||||
|
|
@ -263,8 +290,8 @@ Riemannian_graph<ForwardIterator>
|
|||
create_riemannian_graph(
|
||||
ForwardIterator first, ///< iterator over the first input point.
|
||||
ForwardIterator beyond, ///< past-the-end iterator over the input points.
|
||||
PointPMap point_pmap, ///< property map ForwardIterator -> Point_3
|
||||
NormalPMap normal_pmap, ///< property map ForwardIterator -> Vector_3
|
||||
PointPMap point_pmap, ///< property map: value_type of ForwardIterator -> Point_3
|
||||
NormalPMap normal_pmap, ///< property map: value_type of ForwardIterator -> Vector_3
|
||||
IndexPMap index_pmap, ///< property map ForwardIterator -> index
|
||||
unsigned int k, ///< number of neighbors
|
||||
const Kernel& /*kernel*/) ///< geometric traits.
|
||||
|
|
@ -303,7 +330,12 @@ create_riemannian_graph(
|
|||
std::vector<Point_vertex_handle_3> kd_tree_points; kd_tree_points.reserve(num_input_points);
|
||||
for (ForwardIterator it = first; it != beyond; it++)
|
||||
{
|
||||
|
||||
#ifdef CGAL_USE_PROPERTY_MAPS_API_V1
|
||||
Point point = get(point_pmap, it);
|
||||
#else
|
||||
Point point = get(point_pmap, *it);
|
||||
#endif
|
||||
Point_vertex_handle_3 point_wrapper(point.x(), point.y(), point.z(), it);
|
||||
kd_tree_points.push_back(point_wrapper);
|
||||
}
|
||||
|
|
@ -335,13 +367,22 @@ create_riemannian_graph(
|
|||
for (ForwardIterator it = first; it != beyond; it++)
|
||||
{
|
||||
std::size_t it_index = get(index_pmap,it);
|
||||
#ifdef CGAL_USE_PROPERTY_MAPS_API_V1
|
||||
Vector it_normal_vector = get(normal_pmap,it);
|
||||
|
||||
#else
|
||||
Vector it_normal_vector = get(normal_pmap,*it);
|
||||
#endif
|
||||
|
||||
// Gather set of (k+1) neighboring points.
|
||||
// Perform k+1 queries (as in point set, the query point is
|
||||
// output first). Search may be aborted if k is greater
|
||||
// than number of input points.
|
||||
|
||||
#ifdef CGAL_USE_PROPERTY_MAPS_API_V1
|
||||
Point point = get(point_pmap, it);
|
||||
#else
|
||||
Point point = get(point_pmap, *it);
|
||||
#endif
|
||||
Point_vertex_handle_3 point_wrapper(point.x(), point.y(), point.z(), it);
|
||||
Neighbor_search search(*tree, point_wrapper, k+1);
|
||||
Search_iterator search_iterator = search.begin();
|
||||
|
|
@ -365,7 +406,12 @@ create_riemannian_graph(
|
|||
// -> ->
|
||||
// Computes edge weight = 1 - | normal1 * normal2 |
|
||||
// where normal1 and normal2 are the normal at the edge extremities.
|
||||
|
||||
#ifdef CGAL_USE_PROPERTY_MAPS_API_V1
|
||||
Vector neighbor_normal_vector = get(normal_pmap,neighbor);
|
||||
#else
|
||||
Vector neighbor_normal_vector = get(normal_pmap,*neighbor);
|
||||
#endif
|
||||
double weight = 1.0 - std::abs(it_normal_vector * neighbor_normal_vector);
|
||||
if (weight < 0)
|
||||
weight = 0; // safety check
|
||||
|
|
@ -403,8 +449,8 @@ MST_graph<ForwardIterator, NormalPMap, Kernel>
|
|||
create_mst_graph(
|
||||
ForwardIterator first, ///< iterator over the first input point.
|
||||
ForwardIterator beyond, ///< past-the-end iterator over the input points.
|
||||
PointPMap point_pmap, ///< property map ForwardIterator -> Point_3
|
||||
NormalPMap normal_pmap, ///< property map ForwardIterator -> Vector_3
|
||||
PointPMap point_pmap, ///< property map: value_type of ForwardIterator -> Point_3
|
||||
NormalPMap normal_pmap, ///< property map: value_type of ForwardIterator -> Vector_3
|
||||
IndexPMap index_pmap, ///< property map ForwardIterator -> index
|
||||
unsigned int k, ///< number of neighbors
|
||||
const Kernel& kernel, ///< geometric traits.
|
||||
|
|
@ -517,8 +563,8 @@ ForwardIterator
|
|||
mst_orient_normals(
|
||||
ForwardIterator first, ///< iterator over the first input point.
|
||||
ForwardIterator beyond, ///< past-the-end iterator over the input points.
|
||||
PointPMap point_pmap, ///< property map ForwardIterator -> Point_3.
|
||||
NormalPMap normal_pmap, ///< property map ForwardIterator -> Vector_3.
|
||||
PointPMap point_pmap, ///< property map: value_type of ForwardIterator -> Point_3.
|
||||
NormalPMap normal_pmap, ///< property map: value_type of ForwardIterator -> Vector_3.
|
||||
unsigned int k, ///< number of neighbors
|
||||
const Kernel& kernel) ///< geometric traits.
|
||||
{
|
||||
|
|
@ -625,8 +671,8 @@ ForwardIterator
|
|||
mst_orient_normals(
|
||||
ForwardIterator first, ///< iterator over the first input point.
|
||||
ForwardIterator beyond, ///< past-the-end iterator over the input points.
|
||||
PointPMap point_pmap, ///< property map ForwardIterator -> Point_3.
|
||||
NormalPMap normal_pmap, ///< property map ForwardIterator -> Vector_3.
|
||||
PointPMap point_pmap, ///< property map: value_type of ForwardIterator -> Point_3.
|
||||
NormalPMap normal_pmap, ///< property map: value_type of ForwardIterator -> Vector_3.
|
||||
unsigned int k) ///< number of neighbors
|
||||
{
|
||||
typedef typename boost::property_traits<PointPMap>::value_type Point;
|
||||
|
|
@ -641,7 +687,7 @@ mst_orient_normals(
|
|||
/// @endcond
|
||||
|
||||
/// @cond SKIP_IN_MANUAL
|
||||
// This variant creates a default point property map = Dereference_property_map.
|
||||
// This variant creates a default point property map = Identity_property_map.
|
||||
template <typename ForwardIterator,
|
||||
typename NormalPMap
|
||||
>
|
||||
|
|
@ -649,12 +695,17 @@ ForwardIterator
|
|||
mst_orient_normals(
|
||||
ForwardIterator first, ///< iterator over the first input point.
|
||||
ForwardIterator beyond, ///< past-the-end iterator over the input points.
|
||||
NormalPMap normal_pmap, ///< property map ForwardIterator -> Vector_3.
|
||||
NormalPMap normal_pmap, ///< property map: value_type of ForwardIterator -> Vector_3.
|
||||
unsigned int k) ///< number of neighbors
|
||||
{
|
||||
return mst_orient_normals(
|
||||
first,beyond,
|
||||
#ifdef CGAL_USE_PROPERTY_MAPS_API_V1
|
||||
make_dereference_property_map(first),
|
||||
#else
|
||||
make_identity_property_map(
|
||||
typename std::iterator_traits<ForwardIterator>::value_type()),
|
||||
#endif
|
||||
normal_pmap,
|
||||
k);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -126,8 +126,8 @@ void
|
|||
pca_estimate_normals(
|
||||
ForwardIterator first, ///< iterator over the first input point.
|
||||
ForwardIterator beyond, ///< past-the-end iterator over the input points.
|
||||
PointPMap point_pmap, ///< property map ForwardIterator -> Point_3.
|
||||
NormalPMap normal_pmap, ///< property map ForwardIterator -> Vector_3.
|
||||
PointPMap point_pmap, ///< property map: value_type of ForwardIterator -> Point_3.
|
||||
NormalPMap normal_pmap, ///< property map: value_type of ForwardIterator -> Vector_3.
|
||||
unsigned int k, ///< number of neighbors.
|
||||
const Kernel& /*kernel*/) ///< geometric traits.
|
||||
{
|
||||
|
|
@ -162,7 +162,11 @@ pca_estimate_normals(
|
|||
std::vector<Point> kd_tree_points;
|
||||
for(it = first; it != beyond; it++)
|
||||
{
|
||||
#ifdef CGAL_USE_PROPERTY_MAPS_API_V1
|
||||
Point point = get(point_pmap, it);
|
||||
#else
|
||||
Point point = get(point_pmap, *it);
|
||||
#endif
|
||||
kd_tree_points.push_back(point);
|
||||
}
|
||||
Tree tree(kd_tree_points.begin(), kd_tree_points.end());
|
||||
|
|
@ -174,8 +178,20 @@ pca_estimate_normals(
|
|||
// vectors (already normalized)
|
||||
for(it = first; it != beyond; it++)
|
||||
{
|
||||
Vector normal = internal::pca_estimate_normal<Kernel,Tree>(get(point_pmap,it), tree, k);
|
||||
Vector normal = internal::pca_estimate_normal<Kernel,Tree>(
|
||||
#ifdef CGAL_USE_PROPERTY_MAPS_API_V1
|
||||
get(point_pmap,it),
|
||||
#else
|
||||
get(point_pmap,*it),
|
||||
#endif
|
||||
tree,
|
||||
k);
|
||||
|
||||
#ifdef CGAL_USE_PROPERTY_MAPS_API_V1
|
||||
put(normal_pmap, it, normal); // normal_pmap[it] = normal
|
||||
#else
|
||||
put(normal_pmap, *it, normal); // normal_pmap[it] = normal
|
||||
#endif
|
||||
}
|
||||
|
||||
memory = CGAL::Memory_sizer().virtual_size(); CGAL_TRACE(" %ld Mb allocated\n", memory>>20);
|
||||
|
|
@ -192,8 +208,8 @@ void
|
|||
pca_estimate_normals(
|
||||
ForwardIterator first, ///< iterator over the first input point.
|
||||
ForwardIterator beyond, ///< past-the-end iterator over the input points.
|
||||
PointPMap point_pmap, ///< property map ForwardIterator -> Point_3.
|
||||
NormalPMap normal_pmap, ///< property map ForwardIterator -> Vector_3.
|
||||
PointPMap point_pmap, ///< property map: value_type of ForwardIterator -> Point_3.
|
||||
NormalPMap normal_pmap, ///< property map: value_type of ForwardIterator -> Vector_3.
|
||||
unsigned int k) ///< number of neighbors.
|
||||
{
|
||||
typedef typename boost::property_traits<PointPMap>::value_type Point;
|
||||
|
|
@ -208,7 +224,7 @@ pca_estimate_normals(
|
|||
/// @endcond
|
||||
|
||||
/// @cond SKIP_IN_MANUAL
|
||||
// This variant creates a default point property map = Dereference_property_map.
|
||||
// This variant creates a default point property map = Identity_property_map.
|
||||
template <typename ForwardIterator,
|
||||
typename NormalPMap
|
||||
>
|
||||
|
|
@ -216,12 +232,17 @@ void
|
|||
pca_estimate_normals(
|
||||
ForwardIterator first, ///< iterator over the first input point.
|
||||
ForwardIterator beyond, ///< past-the-end iterator over the input points.
|
||||
NormalPMap normal_pmap, ///< property map ForwardIterator -> Vector_3.
|
||||
NormalPMap normal_pmap, ///< property map: value_type of ForwardIterator -> Vector_3.
|
||||
unsigned int k) ///< number of neighbors.
|
||||
{
|
||||
pca_estimate_normals(
|
||||
first,beyond,
|
||||
#ifdef CGAL_USE_PROPERTY_MAPS_API_V1
|
||||
make_dereference_property_map(first),
|
||||
#else
|
||||
make_identity_property_map(
|
||||
typename std::iterator_traits<ForwardIterator>::value_type()),
|
||||
#endif
|
||||
normal_pmap,
|
||||
k);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -97,7 +97,6 @@ pca_smooth_point(
|
|||
|
||||
} /* namespace internal */
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Public section
|
||||
// ----------------------------------------------------------------------------
|
||||
|
|
@ -112,7 +111,7 @@ pca_smooth_point(
|
|||
/// \pre `k >= 2`
|
||||
///
|
||||
/// @tparam InputIterator iterator over input points.
|
||||
/// @tparam PointPMap is a model of `ReadablePropertyMap` with a value_type = Point_3<Kernel>.
|
||||
/// @tparam PointPMap is a model of `ReadWritePropertyMap` with a value_type = Point_3<Kernel>.
|
||||
/// It can be omitted if InputIterator value_type is convertible to Point_3<Kernel>.
|
||||
/// @tparam Kernel Geometric traits class.
|
||||
/// It can be omitted and deduced automatically from PointPMap value_type.
|
||||
|
|
@ -126,7 +125,7 @@ void
|
|||
pca_smooth_point_set(
|
||||
InputIterator first, ///< iterator over the first input point.
|
||||
InputIterator beyond, ///< past-the-end iterator over the input points.
|
||||
PointPMap point_pmap, ///< property map InputIterator -> Point_3.
|
||||
PointPMap point_pmap, ///< property map: value_type of InputIterator -> Point_3.
|
||||
unsigned int k, ///< number of neighbors.
|
||||
const Kernel& kernel) ///< geometric traits.
|
||||
{
|
||||
|
|
@ -153,7 +152,11 @@ pca_smooth_point_set(
|
|||
std::vector<Point> kd_tree_points;
|
||||
for(it = first; it != beyond; it++)
|
||||
{
|
||||
#ifdef CGAL_USE_PROPERTY_MAPS_API_V1
|
||||
Point point = get(point_pmap, it);
|
||||
#else
|
||||
Point point = get(point_pmap, *it);
|
||||
#endif
|
||||
kd_tree_points.push_back(point);
|
||||
}
|
||||
Tree tree(kd_tree_points.begin(), kd_tree_points.end());
|
||||
|
|
@ -162,8 +165,13 @@ pca_smooth_point_set(
|
|||
// Implementation note: the cast to Point& allows to modify only the point's position.
|
||||
for(it = first; it != beyond; it++)
|
||||
{
|
||||
Point& p = get(point_pmap, it);
|
||||
p = internal::pca_smooth_point<Kernel>(p,tree,k);
|
||||
#ifdef CGAL_USE_PROPERTY_MAPS_API_V1
|
||||
const Point& p = get(point_pmap, it);
|
||||
put(point_pmap, it, internal::pca_smooth_point<Kernel>(p,tree,k) );
|
||||
#else
|
||||
const Point& p = get(point_pmap, *it);
|
||||
put(point_pmap, *it, internal::pca_smooth_point<Kernel>(p,tree,k) );
|
||||
#endif
|
||||
}
|
||||
}
|
||||
/// @endcond
|
||||
|
|
@ -177,7 +185,7 @@ void
|
|||
pca_smooth_point_set(
|
||||
InputIterator first, ///< iterator over the first input point
|
||||
InputIterator beyond, ///< past-the-end iterator
|
||||
PointPMap point_pmap, ///< property map InputIterator -> Point_3
|
||||
PointPMap point_pmap, ///< property map: value_type of InputIterator -> Point_3
|
||||
unsigned int k) ///< number of neighbors.
|
||||
{
|
||||
typedef typename boost::property_traits<PointPMap>::value_type Point;
|
||||
|
|
@ -191,7 +199,7 @@ pca_smooth_point_set(
|
|||
/// @endcond
|
||||
|
||||
/// @cond SKIP_IN_MANUAL
|
||||
// This variant creates a default point property map = Dereference_property_map.
|
||||
// This variant creates a default point property map = Identity_property_map.
|
||||
template <typename InputIterator
|
||||
>
|
||||
void
|
||||
|
|
@ -202,7 +210,12 @@ pca_smooth_point_set(
|
|||
{
|
||||
pca_smooth_point_set(
|
||||
first,beyond,
|
||||
#ifdef CGAL_USE_PROPERTY_MAPS_API_V1
|
||||
make_dereference_property_map(first),
|
||||
#else
|
||||
make_identity_property_map(
|
||||
typename std::iterator_traits<InputIterator>::value_type()),
|
||||
#endif
|
||||
k);
|
||||
}
|
||||
/// @endcond
|
||||
|
|
|
|||
|
|
@ -34,7 +34,6 @@
|
|||
|
||||
namespace CGAL {
|
||||
|
||||
|
||||
/// \ingroup PkgProperty_map
|
||||
/// Property map that converts a `T*` pointer (or in general an iterator
|
||||
/// over `T` elements) to the `T` object.
|
||||
|
|
@ -67,9 +66,43 @@ make_dereference_property_map(Iter)
|
|||
return Dereference_property_map<typename CGAL::value_type_traits<Iter>::type>();
|
||||
}
|
||||
|
||||
/// \ingroup PkgProperty_map
|
||||
/// A `LvaluePropertyMap` property map mapping a key to itself (by reference).
|
||||
///
|
||||
/// \cgalModels `LvaluePropertyMap`
|
||||
template <typename T>
|
||||
struct Identity_property_map
|
||||
{
|
||||
typedef T key_type; ///< typedef to `T`
|
||||
typedef T value_type; ///< typedef to `T`
|
||||
typedef T& reference; ///< typedef to `T&`
|
||||
typedef boost::lvalue_property_map_tag category; ///< `boost::lvalue_property_map_tag`
|
||||
/// Access a property map element.
|
||||
/// @param k a key which is returned as mapped value.
|
||||
reference operator[](key_type& k) const { return k; }
|
||||
|
||||
typedef Identity_property_map<T> Self;
|
||||
/// \name Put/get free functions
|
||||
/// @{
|
||||
friend const value_type& get(const Self&,const key_type& k) {return k;}
|
||||
friend reference get(const Self&, key_type& k) {return k;}
|
||||
friend void put(const Self&,key_type& k, const value_type& v) {k=v;}
|
||||
/// @}
|
||||
};
|
||||
|
||||
/// Free function to create a `Identity_property_map` property map.
|
||||
///
|
||||
/// \relates Identity_property_map
|
||||
template <class T> // Key and value type
|
||||
Identity_property_map<T>
|
||||
make_identity_property_map(T)
|
||||
{
|
||||
return Identity_property_map<T>();
|
||||
}
|
||||
|
||||
|
||||
//=========================================================================
|
||||
|
||||
#ifdef CGAL_USE_PROPERTY_MAPS_API_V1
|
||||
/// \ingroup PkgProperty_map
|
||||
/// Property map that accesses the first item of a `std::pair`.
|
||||
/// \tparam Pair Instance of `std::pair`.
|
||||
|
|
@ -81,7 +114,7 @@ struct First_of_pair_property_map
|
|||
: public boost::put_get_helper<typename Pair::first_type&,
|
||||
First_of_pair_property_map<Pair> >
|
||||
{
|
||||
typedef Pair* key_type; ///< typedef to 'Pair*'
|
||||
typedef Pair* key_type; ///< typedef to `Pair*`
|
||||
typedef typename Pair::first_type value_type; ///< typedef to `Pair::first_type`
|
||||
typedef value_type& reference; ///< typedef to `value_type&`
|
||||
typedef boost::lvalue_property_map_tag category; ///< boost::lvalue_property_map_tag
|
||||
|
|
@ -98,12 +131,51 @@ struct First_of_pair_property_map
|
|||
/// \relates First_of_pair_property_map
|
||||
template <class Iter> // Type convertible to key_type
|
||||
First_of_pair_property_map<typename CGAL::value_type_traits<Iter>::type>
|
||||
make_first_of_pair_property_map(Iter)
|
||||
make_first_of_pair_property_map(Iter)
|
||||
{
|
||||
// value_type_traits is a workaround as back_insert_iterator's value_type is void
|
||||
return First_of_pair_property_map<typename CGAL::value_type_traits<Iter>::type>();
|
||||
}
|
||||
#else
|
||||
/// \ingroup PkgProperty_map
|
||||
/// Property map that accesses the first item of a `std::pair`.
|
||||
/// \tparam Pair Instance of `std::pair`.
|
||||
/// \cgalModels `LvaluePropertyMap`
|
||||
///
|
||||
/// \sa `CGAL::Second_of_pair_property_map<Pair>`
|
||||
template <typename Pair>
|
||||
struct First_of_pair_property_map
|
||||
{
|
||||
typedef Pair key_type; ///< typedef to `Pair`
|
||||
typedef typename Pair::first_type value_type; ///< typedef to `Pair::first_type`
|
||||
typedef value_type& reference; ///< typedef to `value_type&`
|
||||
typedef boost::lvalue_property_map_tag category; ///< boost::lvalue_property_map_tag
|
||||
|
||||
/// Access a property map element.
|
||||
/// @param pair a key whose first item is accessed
|
||||
reference operator[](key_type& pair) const { return pair.first; }
|
||||
|
||||
typedef First_of_pair_property_map<Pair> Self;
|
||||
/// \name Put/get free functions
|
||||
/// @{
|
||||
friend const value_type& get(const Self&,const key_type& k) {return k.first;}
|
||||
friend reference get(const Self&, key_type& k) {return k.first;}
|
||||
friend void put(const Self&,key_type& k, const value_type& v) {k.first=v;}
|
||||
/// @}
|
||||
};
|
||||
|
||||
/// Free function to create a `First_of_pair_property_map` property map.
|
||||
///
|
||||
/// \relates First_of_pair_property_map
|
||||
template <class Pair> // Pair type
|
||||
First_of_pair_property_map<Pair>
|
||||
make_first_of_pair_property_map(Pair)
|
||||
{
|
||||
return First_of_pair_property_map<Pair>();
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CGAL_USE_PROPERTY_MAPS_API_V1
|
||||
/// \ingroup PkgProperty_map
|
||||
///
|
||||
/// Property map that accesses the second item of a `std::pair`.
|
||||
|
|
@ -118,7 +190,7 @@ struct Second_of_pair_property_map
|
|||
: public boost::put_get_helper<typename Pair::second_type&,
|
||||
Second_of_pair_property_map<Pair> >
|
||||
{
|
||||
typedef Pair* key_type; ///< typedef to 'Pair*'
|
||||
typedef Pair* key_type; ///< typedef to `Pair*`
|
||||
typedef typename Pair::second_type value_type; ///< typedef to `Pair::second_type`
|
||||
typedef value_type& reference; ///< typedef to `value_type&`
|
||||
typedef boost::lvalue_property_map_tag category; ///< `boost::lvalue_property_map_tag`
|
||||
|
|
@ -135,16 +207,58 @@ struct Second_of_pair_property_map
|
|||
/// \relates Second_of_pair_property_map
|
||||
template <class Iter> // Type convertible to key_type
|
||||
Second_of_pair_property_map<typename CGAL::value_type_traits<Iter>::type>
|
||||
make_second_of_pair_property_map(Iter)
|
||||
make_second_of_pair_property_map(Iter)
|
||||
{
|
||||
// value_type_traits is a workaround as back_insert_iterator's value_type is void
|
||||
return Second_of_pair_property_map<typename CGAL::value_type_traits<Iter>::type>();
|
||||
}
|
||||
#else
|
||||
/// \ingroup PkgProperty_map
|
||||
///
|
||||
/// Property map that accesses the second item of a `std::pair`.
|
||||
///
|
||||
/// \tparam Pair Instance of `std::pair`.
|
||||
///
|
||||
/// \cgalModels `LvaluePropertyMap`
|
||||
///
|
||||
/// \sa `CGAL::First_of_pair_property_map<Pair>`
|
||||
template <typename Pair>
|
||||
struct Second_of_pair_property_map
|
||||
{
|
||||
typedef Pair key_type; ///< typedef to `Pair`
|
||||
typedef typename Pair::second_type value_type; ///< typedef to `Pair::first_type`
|
||||
typedef value_type& reference; ///< typedef to `value_type&`
|
||||
typedef boost::lvalue_property_map_tag category; ///< boost::lvalue_property_map_tag
|
||||
|
||||
/// Access a property map element.
|
||||
/// @param pair a key whose second item is accessed
|
||||
reference operator[](key_type& pair) const { return pair.second; }
|
||||
|
||||
typedef Second_of_pair_property_map<Pair> Self;
|
||||
/// \name Put/get free functions
|
||||
/// @{
|
||||
friend const value_type& get(const Self&,const key_type& k) {return k.second;}
|
||||
friend reference get(const Self&, key_type& k) {return k.second;}
|
||||
friend void put(const Self&,key_type& k, const value_type& v) {k.second=v;}
|
||||
/// @}
|
||||
};
|
||||
|
||||
/// Free function to create a Second_of_pair_property_map property map.
|
||||
///
|
||||
/// \relates Second_of_pair_property_map
|
||||
template <class Pair> // Pair type
|
||||
Second_of_pair_property_map<Pair>
|
||||
make_second_of_pair_property_map(Pair)
|
||||
{
|
||||
return Second_of_pair_property_map<Pair>();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
//=========================================================================
|
||||
|
||||
|
||||
#ifdef CGAL_USE_PROPERTY_MAPS_API_V1
|
||||
/// \ingroup PkgProperty_map
|
||||
///
|
||||
/// Property map that accesses the Nth item of a `boost::tuple`.
|
||||
|
|
@ -158,7 +272,7 @@ struct Nth_of_tuple_property_map
|
|||
: public boost::put_get_helper<typename boost::tuples::element<N,Tuple>::type&,
|
||||
Nth_of_tuple_property_map<N,Tuple> >
|
||||
{
|
||||
typedef Tuple* key_type; ///< typedef to 'Tuple*'
|
||||
typedef Tuple* key_type; ///< typedef to `Tuple*`
|
||||
typedef typename boost::tuples::element<N,Tuple>::type value_type; ///< typedef to `boost::tuples::element<N,Tuple>::%type`
|
||||
typedef value_type& reference; ///< typedef to `value_type&`
|
||||
typedef boost::lvalue_property_map_tag category; ///< `boost::lvalue_property_map_tag`
|
||||
|
|
@ -175,12 +289,50 @@ struct Nth_of_tuple_property_map
|
|||
/// \relates Nth_of_tuple_property_map
|
||||
template <int N, class Iter> // Type convertible to key_type
|
||||
Nth_of_tuple_property_map<N, typename CGAL::value_type_traits<Iter>::type>
|
||||
make_nth_of_tuple_property_map(Iter)
|
||||
make_nth_of_tuple_property_map(Iter)
|
||||
{
|
||||
// value_type_traits is a workaround as back_insert_iterator's `value_type` is void
|
||||
return Nth_of_tuple_property_map<N, typename CGAL::value_type_traits<Iter>::type>();
|
||||
}
|
||||
#else
|
||||
/// \ingroup PkgProperty_map
|
||||
///
|
||||
/// Property map that accesses the Nth item of a `boost::tuple`.
|
||||
///
|
||||
/// \tparam N Index of the item to access.
|
||||
/// \tparam Tuple Instance of `boost::tuple`.
|
||||
///
|
||||
/// \cgalModels `LvaluePropertyMap`
|
||||
template <int N, typename Tuple>
|
||||
struct Nth_of_tuple_property_map
|
||||
{
|
||||
typedef Tuple key_type; ///< typedef to `Tuple`
|
||||
typedef typename boost::tuples::element<N,Tuple>::type value_type; ///< typedef to `boost::tuples::element<N,Tuple>::%type`
|
||||
typedef value_type& reference; ///< typedef to `value_type&`
|
||||
typedef boost::lvalue_property_map_tag category; ///< `boost::lvalue_property_map_tag`
|
||||
/// Access a property map element.
|
||||
/// @param tuple a key whose Nth item is accessed
|
||||
reference operator[](key_type& tuple) const { return tuple.template get<N>(); }
|
||||
|
||||
typedef Nth_of_tuple_property_map<N,Tuple> Self;
|
||||
/// \name Put/get free functions
|
||||
/// @{
|
||||
friend const value_type& get(const Self&,const key_type& k) {return k.template get<N>();}
|
||||
friend reference get(const Self&, key_type& k) {return k.template get<N>();}
|
||||
friend void put(const Self&,key_type& k, const value_type& v) {k.template get<N>()=v;}
|
||||
/// @}
|
||||
};
|
||||
|
||||
/// Free function to create a Nth_of_tuple_property_map property map.
|
||||
///
|
||||
/// \relates Nth_of_tuple_property_map
|
||||
template <int N, class Tuple> // Tuple type
|
||||
Nth_of_tuple_property_map<N, Tuple>
|
||||
make_nth_of_tuple_property_map(Tuple)
|
||||
{
|
||||
return Nth_of_tuple_property_map<N, Tuple>();
|
||||
}
|
||||
#endif
|
||||
|
||||
} // namespace CGAL
|
||||
|
||||
|
|
|
|||
|
|
@ -58,8 +58,8 @@ ForwardIterator
|
|||
radial_orient_normals(
|
||||
ForwardIterator first, ///< iterator over the first input point.
|
||||
ForwardIterator beyond, ///< past-the-end iterator over the input points.
|
||||
PointPMap point_pmap, ///< property map ForwardIterator -> Point_3.
|
||||
NormalPMap normal_pmap, ///< property map ForwardIterator -> Vector_3.
|
||||
PointPMap point_pmap, ///< property map: value_type of ForwardIterator -> Point_3.
|
||||
NormalPMap normal_pmap, ///< property map: value_type of ForwardIterator -> Vector_3.
|
||||
const Kernel& kernel) ///< geometric traits.
|
||||
{
|
||||
CGAL_TRACE("Calls radial_orient_normals()\n");
|
||||
|
|
@ -80,7 +80,11 @@ radial_orient_normals(
|
|||
int nb_points = 0;
|
||||
for (ForwardIterator it = first; it != beyond; it++)
|
||||
{
|
||||
#ifdef CGAL_USE_PROPERTY_MAPS_API_V1
|
||||
Point point = get(point_pmap, it);
|
||||
#else
|
||||
Point point = get(point_pmap, *it);
|
||||
#endif
|
||||
sum = sum + (point - CGAL::ORIGIN);
|
||||
nb_points++;
|
||||
}
|
||||
|
|
@ -91,21 +95,32 @@ radial_orient_normals(
|
|||
std::deque<Enriched_point> oriented_points, unoriented_points;
|
||||
for (ForwardIterator it = first; it != beyond; it++)
|
||||
{
|
||||
#ifdef CGAL_USE_PROPERTY_MAPS_API_V1
|
||||
Point point = get(point_pmap, it);
|
||||
|
||||
#else
|
||||
Point point = get(point_pmap, *it);
|
||||
#endif
|
||||
// Radial vector towards exterior of the point set
|
||||
Vector vec1 = point - barycenter;
|
||||
|
||||
// Point's normal
|
||||
Vector vec2 = normal_pmap[it];
|
||||
|
||||
#ifdef CGAL_USE_PROPERTY_MAPS_API_V1
|
||||
Vector vec2 = get(normal_pmap, it);
|
||||
#else
|
||||
Vector vec2 = get(normal_pmap, *it);
|
||||
#endif
|
||||
|
||||
// -> ->
|
||||
// Orients vec2 parallel to vec1
|
||||
double dot = vec1 * vec2;
|
||||
if (dot < 0)
|
||||
vec2 = -vec2;
|
||||
|
||||
it->normal() = vec2;
|
||||
#ifdef CGAL_USE_PROPERTY_MAPS_API_V1
|
||||
put(normal_pmap, it, vec2);
|
||||
#else
|
||||
put(normal_pmap, *it, vec2);
|
||||
#endif
|
||||
|
||||
// Is orientation robust?
|
||||
bool oriented = (std::abs(dot) > std::cos(80.*CGAL_PI/180.)); // robust iff angle < 80 degrees
|
||||
|
|
@ -136,8 +151,8 @@ ForwardIterator
|
|||
radial_orient_normals(
|
||||
ForwardIterator first, ///< iterator over the first input point.
|
||||
ForwardIterator beyond, ///< past-the-end iterator over the input points.
|
||||
PointPMap point_pmap, ///< property map ForwardIterator -> Point_3.
|
||||
NormalPMap normal_pmap) ///< property map ForwardIterator -> Vector_3.
|
||||
PointPMap point_pmap, ///< property map: value_type of ForwardIterator -> Point_3.
|
||||
NormalPMap normal_pmap) ///< property map: value_type of ForwardIterator -> Vector_3.
|
||||
{
|
||||
typedef typename boost::property_traits<PointPMap>::value_type Point;
|
||||
typedef typename Kernel_traits<Point>::Kernel Kernel;
|
||||
|
|
@ -149,7 +164,7 @@ radial_orient_normals(
|
|||
/// @endcond
|
||||
|
||||
/// @cond SKIP_IN_MANUAL
|
||||
// This variant creates a default point property map = Dereference_property_map.
|
||||
// This variant creates a default point property map = Identity_property_map.
|
||||
template <typename ForwardIterator,
|
||||
typename NormalPMap
|
||||
>
|
||||
|
|
@ -157,11 +172,16 @@ ForwardIterator
|
|||
radial_orient_normals(
|
||||
ForwardIterator first, ///< iterator over the first input point.
|
||||
ForwardIterator beyond, ///< past-the-end iterator over the input points.
|
||||
NormalPMap normal_pmap) ///< property map ForwardIterator -> Vector_3.
|
||||
NormalPMap normal_pmap) ///< property map: value_type of ForwardIterator -> Vector_3.
|
||||
{
|
||||
return radial_orient_normals(
|
||||
first,beyond,
|
||||
make_dereference_property_map(first),
|
||||
#ifdef CGAL_USE_PROPERTY_MAPS_API_V1
|
||||
make_dereference_property_map(first),
|
||||
#else
|
||||
make_identity_property_map(
|
||||
typename std::iterator_traits<ForwardIterator>::value_type()),
|
||||
#endif
|
||||
normal_pmap);
|
||||
}
|
||||
/// @endcond
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ ForwardIterator
|
|||
random_simplify_point_set(
|
||||
ForwardIterator first, ///< iterator over the first input point.
|
||||
ForwardIterator beyond, ///< past-the-end iterator over the input points.
|
||||
PointPMap /*point_pmap*/, ///< property map ForwardIterator -> Point_3
|
||||
PointPMap /*point_pmap*/, ///< property map: value_type of ForwardIterator -> Point_3
|
||||
double removed_percentage, ///< percentage of points to remove.
|
||||
const Kernel& /*kernel*/) ///< geometric traits.
|
||||
{
|
||||
|
|
@ -81,7 +81,7 @@ ForwardIterator
|
|||
random_simplify_point_set(
|
||||
ForwardIterator first, ///< iterator over the first input point
|
||||
ForwardIterator beyond, ///< past-the-end iterator
|
||||
PointPMap point_pmap, ///< property map ForwardIterator -> Point_3
|
||||
PointPMap point_pmap, ///< property map: value_type of ForwardIterator -> Point_3
|
||||
double removed_percentage) ///< percentage of points to remove
|
||||
{
|
||||
typedef typename boost::property_traits<PointPMap>::value_type Point;
|
||||
|
|
@ -95,7 +95,7 @@ random_simplify_point_set(
|
|||
/// @endcond
|
||||
|
||||
/// @cond SKIP_IN_MANUAL
|
||||
// This variant creates a default point property map = Dereference_property_map.
|
||||
// This variant creates a default point property map = Identity_property_map.
|
||||
template <typename ForwardIterator
|
||||
>
|
||||
ForwardIterator
|
||||
|
|
@ -106,7 +106,12 @@ random_simplify_point_set(
|
|||
{
|
||||
return random_simplify_point_set(
|
||||
first,beyond,
|
||||
#ifdef CGAL_USE_PROPERTY_MAPS_API_V1
|
||||
make_dereference_property_map(first),
|
||||
#else
|
||||
make_identity_property_map(
|
||||
typename std::iterator_traits<ForwardIterator>::value_type()),
|
||||
#endif
|
||||
removed_percentage);
|
||||
}
|
||||
/// @endcond
|
||||
|
|
|
|||
|
|
@ -128,7 +128,7 @@ InputIterator
|
|||
remove_outliers(
|
||||
InputIterator first, ///< iterator over the first input point.
|
||||
InputIterator beyond, ///< past-the-end iterator over the input points.
|
||||
PointPMap point_pmap, ///< property map InputIterator -> Point_3
|
||||
PointPMap point_pmap, ///< property map: value_type of InputIterator -> Point_3
|
||||
unsigned int k, ///< number of neighbors.
|
||||
double threshold_percent, ///< percentage of points to remove.
|
||||
const Kernel& /*kernel*/) ///< geometric traits.
|
||||
|
|
@ -164,7 +164,11 @@ remove_outliers(
|
|||
std::vector<Point> kd_tree_points;
|
||||
for(it = first; it != beyond; it++)
|
||||
{
|
||||
#ifdef CGAL_USE_PROPERTY_MAPS_API_V1
|
||||
Point point = get(point_pmap, it);
|
||||
#else
|
||||
Point point = get(point_pmap, *it);
|
||||
#endif
|
||||
kd_tree_points.push_back(point);
|
||||
}
|
||||
Tree tree(kd_tree_points.begin(), kd_tree_points.end());
|
||||
|
|
@ -173,7 +177,13 @@ remove_outliers(
|
|||
std::multimap<FT,Enriched_point> sorted_points;
|
||||
for(it = first; it != beyond; it++)
|
||||
{
|
||||
FT sq_distance = internal::compute_avg_knn_sq_distance_3<Kernel>(get(point_pmap,it), tree, k);
|
||||
FT sq_distance = internal::compute_avg_knn_sq_distance_3<Kernel>(
|
||||
#ifdef CGAL_USE_PROPERTY_MAPS_API_V1
|
||||
get(point_pmap,it),
|
||||
#else
|
||||
get(point_pmap,*it),
|
||||
#endif
|
||||
tree, k);
|
||||
sorted_points.insert( std::make_pair(sq_distance, *it) );
|
||||
}
|
||||
|
||||
|
|
@ -205,7 +215,7 @@ InputIterator
|
|||
remove_outliers(
|
||||
InputIterator first, ///< iterator over the first input point
|
||||
InputIterator beyond, ///< past-the-end iterator
|
||||
PointPMap point_pmap, ///< property map InputIterator -> Point_3
|
||||
PointPMap point_pmap, ///< property map: value_type of InputIterator -> Point_3
|
||||
unsigned int k, ///< number of neighbors.
|
||||
double threshold_percent) ///< percentage of points to remove
|
||||
{
|
||||
|
|
@ -220,7 +230,7 @@ remove_outliers(
|
|||
/// @endcond
|
||||
|
||||
/// @cond SKIP_IN_MANUAL
|
||||
// This variant creates a default point property map = Dereference_property_map.
|
||||
// This variant creates a default point property map = Identity_property_map.
|
||||
template <typename InputIterator
|
||||
>
|
||||
InputIterator
|
||||
|
|
@ -232,7 +242,12 @@ remove_outliers(
|
|||
{
|
||||
return remove_outliers(
|
||||
first,beyond,
|
||||
#ifdef CGAL_USE_PROPERTY_MAPS_API_V1
|
||||
make_dereference_property_map(first),
|
||||
#else
|
||||
make_identity_property_map(
|
||||
typename std::iterator_traits<InputIterator>::value_type()),
|
||||
#endif
|
||||
k,threshold_percent);
|
||||
}
|
||||
/// @endcond
|
||||
|
|
|
|||
|
|
@ -125,7 +125,7 @@ InputIterator
|
|||
remove_outliers_wrt_median_knn_sq_distance(
|
||||
InputIterator first, ///< iterator over the first input point.
|
||||
InputIterator beyond, ///< past-the-end iterator over the input points.
|
||||
PointPMap point_pmap, ///< property map InputIterator -> Point_3
|
||||
PointPMap point_pmap, ///< property map: value_type of InputIterator -> Point_3
|
||||
unsigned int k, ///< number of neighbors.
|
||||
double threshold_percent, ///< percentage of points to remove.
|
||||
const Kernel& kernel) ///< geometric traits.
|
||||
|
|
@ -162,7 +162,11 @@ remove_outliers_wrt_median_knn_sq_distance(
|
|||
std::vector<Point> kd_tree_points;
|
||||
for(it = first; it != beyond; it++)
|
||||
{
|
||||
#ifdef CGAL_USE_PROPERTY_MAPS_API_V1
|
||||
Point point = get(point_pmap, it);
|
||||
#else
|
||||
Point point = get(point_pmap, *it);
|
||||
#endif
|
||||
kd_tree_points.push_back(point);
|
||||
}
|
||||
Tree tree(kd_tree_points.begin(), kd_tree_points.end());
|
||||
|
|
@ -171,7 +175,13 @@ remove_outliers_wrt_median_knn_sq_distance(
|
|||
std::multimap<FT,Enriched_point> sorted_points;
|
||||
for(it = first; it != beyond; it++)
|
||||
{
|
||||
FT sq_distance = internal::compute_median_knn_sq_distance_3<Kernel>(get(point_pmap,it), tree, k);
|
||||
FT sq_distance = internal::compute_median_knn_sq_distance_3<Kernel>(
|
||||
#ifdef CGAL_USE_PROPERTY_MAPS_API_V1
|
||||
get(point_pmap,it),
|
||||
#else
|
||||
get(point_pmap,*it),
|
||||
#endif
|
||||
tree, k);
|
||||
sorted_points.insert( std::make_pair(sq_distance, *it) );
|
||||
}
|
||||
|
||||
|
|
@ -203,7 +213,7 @@ InputIterator
|
|||
remove_outliers_wrt_median_knn_sq_distance(
|
||||
InputIterator first, ///< iterator over the first input point
|
||||
InputIterator beyond, ///< past-the-end iterator
|
||||
PointPMap point_pmap, ///< property map InputIterator -> Point_3
|
||||
PointPMap point_pmap, ///< property map: value_type of InputIterator -> Point_3
|
||||
unsigned int k, ///< number of neighbors.
|
||||
double threshold_percent) ///< percentage of points to remove
|
||||
{
|
||||
|
|
@ -218,7 +228,7 @@ remove_outliers_wrt_median_knn_sq_distance(
|
|||
/// @endcond
|
||||
|
||||
/// @cond SKIP_IN_MANUAL
|
||||
// This variant creates a default point property map = Dereference_property_map.
|
||||
// This variant creates a default point property map = Identity_property_map.
|
||||
template <typename InputIterator
|
||||
>
|
||||
InputIterator
|
||||
|
|
@ -230,7 +240,12 @@ remove_outliers_wrt_median_knn_sq_distance(
|
|||
{
|
||||
return remove_outliers_wrt_median_knn_sq_distance(
|
||||
first,beyond,
|
||||
make_dereference_property_map(first),
|
||||
#ifdef CGAL_USE_PROPERTY_MAPS_API_V1
|
||||
make_dereference_property_map(first),
|
||||
#else
|
||||
make_identity_property_map(
|
||||
typename std::iterator_traits<InputIterator>::value_type()),
|
||||
#endif
|
||||
k,threshold_percent);
|
||||
}
|
||||
/// @endcond
|
||||
|
|
|
|||
|
|
@ -24,29 +24,41 @@
|
|||
|
||||
namespace CGAL {
|
||||
|
||||
/// \cond SKIP_IN_MANUAL
|
||||
|
||||
/// Traits class to get the value type of any iterator,
|
||||
/// including an output iterator.
|
||||
/// Based on code posted by Alberto Ganesh Barbati at
|
||||
/// http://www.adras.com/Why-no-std-back-insert-iterator-value-type.t2639-153-3.html
|
||||
/// \ingroup PkgPointSetProcessing
|
||||
/// Class providing the value type of an iterator, and
|
||||
/// in the case of an output iterator, a type of objects that can be put in it.
|
||||
///
|
||||
/// Usage is:
|
||||
/// typedef typename value_type_traits<Iter>::type value_type;
|
||||
|
||||
template <class T>
|
||||
struct value_type_traits
|
||||
{
|
||||
#ifndef DOXYGEN_RUNNING
|
||||
typedef typename std::iterator_traits<T>::value_type type;
|
||||
#else
|
||||
/// If `T` is `std::insert_iterator<Container>`, `std::back_insert_iterator<Container>` or
|
||||
/// `std::front_insert_iterator<Container>`, then `type` is `Container::value_type`.
|
||||
/// Otherwise, `type` is `std::iterator_traits<T>::%value_type`.
|
||||
|
||||
typedef Hidden_type type;
|
||||
#endif
|
||||
};
|
||||
|
||||
template <class T>
|
||||
struct value_type_traits<std::back_insert_iterator<T> >
|
||||
template <class Container>
|
||||
struct value_type_traits<std::back_insert_iterator<Container> >
|
||||
{
|
||||
typedef typename T::value_type type;
|
||||
typedef typename Container::value_type type;
|
||||
};
|
||||
|
||||
/// \endcond
|
||||
template <class Container>
|
||||
struct value_type_traits<std::insert_iterator<Container> >
|
||||
{
|
||||
typedef typename Container::value_type type;
|
||||
};
|
||||
|
||||
template <class Container>
|
||||
struct value_type_traits<std::front_insert_iterator<Container> >
|
||||
{
|
||||
typedef typename Container::value_type type;
|
||||
};
|
||||
|
||||
} //namespace CGAL
|
||||
|
||||
|
|
|
|||
|
|
@ -50,6 +50,7 @@ if ( CGAL_FOUND )
|
|||
|
||||
# Executables that do *not* require LAPACK
|
||||
create_single_source_cgal_program( "read_test.cpp" )
|
||||
create_single_source_cgal_program( "read_test_with_different_pmaps.cpp" )
|
||||
create_single_source_cgal_program( "analysis_test.cpp" )
|
||||
create_single_source_cgal_program( "remove_outliers_test.cpp" )
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,5 @@
|
|||
OFF
|
||||
3 0 0
|
||||
1 1 1 2 2 2
|
||||
3 3 3 4 4 4
|
||||
5 5 5 6 6 6
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
1 1 1 2 2 2
|
||||
3 3 3 4 4 4
|
||||
5 5 5 6 6 6
|
||||
|
|
@ -127,7 +127,11 @@ bool run_pca_estimate_normals(PointList& points, // input points + output normal
|
|||
<< nb_neighbors_pca_normals << ")...\n";
|
||||
|
||||
CGAL::pca_estimate_normals(points.begin(), points.end(),
|
||||
#ifdef CGAL_USE_PROPERTY_MAPS_API_V1
|
||||
CGAL::make_normal_of_point_with_normal_pmap(points.begin()),
|
||||
#else
|
||||
CGAL::make_normal_of_point_with_normal_pmap(PointList::value_type()),
|
||||
#endif
|
||||
nb_neighbors_pca_normals);
|
||||
|
||||
long memory = CGAL::Memory_sizer().virtual_size();
|
||||
|
|
@ -151,7 +155,11 @@ bool run_jet_estimate_normals(PointList& points, // input points + output normal
|
|||
<< nb_neighbors_jet_fitting_normals << ")...\n";
|
||||
|
||||
CGAL::jet_estimate_normals(points.begin(), points.end(),
|
||||
#ifdef CGAL_USE_PROPERTY_MAPS_API_V1
|
||||
CGAL::make_normal_of_point_with_normal_pmap(points.begin()),
|
||||
#else
|
||||
CGAL::make_normal_of_point_with_normal_pmap(PointList::value_type()),
|
||||
#endif
|
||||
nb_neighbors_jet_fitting_normals);
|
||||
|
||||
long memory = CGAL::Memory_sizer().virtual_size();
|
||||
|
|
@ -231,7 +239,11 @@ bool run_mst_orient_normals(PointList& points, // input points + input/output no
|
|||
|
||||
PointList::iterator unoriented_points_begin =
|
||||
CGAL::mst_orient_normals(points.begin(), points.end(),
|
||||
CGAL::make_normal_of_point_with_normal_pmap(points.begin()),
|
||||
#ifdef CGAL_USE_PROPERTY_MAPS_API_V1
|
||||
CGAL::make_normal_of_point_with_normal_pmap(points.begin()),
|
||||
#else
|
||||
CGAL::make_normal_of_point_with_normal_pmap(PointList::value_type()),
|
||||
#endif
|
||||
nb_neighbors_mst);
|
||||
|
||||
long memory = CGAL::Memory_sizer().virtual_size();
|
||||
|
|
@ -303,7 +315,12 @@ int main(int argc, char * argv[])
|
|||
success = stream &&
|
||||
CGAL::read_off_points_and_normals(stream,
|
||||
std::back_inserter(points),
|
||||
CGAL::make_normal_of_point_with_normal_pmap(std::back_inserter(points)));
|
||||
#ifdef CGAL_USE_PROPERTY_MAPS_API_V1
|
||||
CGAL::make_normal_of_point_with_normal_pmap(std::back_inserter(points))
|
||||
#else
|
||||
CGAL::make_normal_of_point_with_normal_pmap(PointList::value_type())
|
||||
#endif
|
||||
);
|
||||
}
|
||||
// If XYZ file format
|
||||
else if (extension == ".xyz" || extension == ".XYZ" ||
|
||||
|
|
@ -313,7 +330,12 @@ int main(int argc, char * argv[])
|
|||
success = stream &&
|
||||
CGAL::read_xyz_points_and_normals(stream,
|
||||
std::back_inserter(points),
|
||||
CGAL::make_normal_of_point_with_normal_pmap(std::back_inserter(points)));
|
||||
#ifdef CGAL_USE_PROPERTY_MAPS_API_V1
|
||||
CGAL::make_normal_of_point_with_normal_pmap(std::back_inserter(points))
|
||||
#else
|
||||
CGAL::make_normal_of_point_with_normal_pmap(PointList::value_type())
|
||||
#endif
|
||||
);
|
||||
}
|
||||
if (success)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -0,0 +1,343 @@
|
|||
#include <CGAL/Simple_cartesian.h>
|
||||
#include <CGAL/property_map.h>
|
||||
#include <CGAL/IO/read_off_points.h>
|
||||
#include <CGAL/IO/read_xyz_points.h>
|
||||
|
||||
#include <vector>
|
||||
#include <deque>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
|
||||
#include <boost/version.hpp>
|
||||
#if BOOST_VERSION >= 104000
|
||||
#include <boost/property_map/vector_property_map.hpp>
|
||||
#else
|
||||
#include <boost/vector_property_map.hpp>
|
||||
#endif
|
||||
|
||||
typedef CGAL::Simple_cartesian<double> Kernel;
|
||||
typedef Kernel::Point_3 Point_3;
|
||||
typedef Kernel::Vector_3 Vector_3;
|
||||
typedef std::pair<Point_3, Vector_3> PointVectorPair;
|
||||
|
||||
// this is going to be custom OutputIterator value_type
|
||||
struct dummy_counter {
|
||||
static std::size_t counter;
|
||||
|
||||
dummy_counter() { ++counter; }
|
||||
operator std::size_t() { return counter-1; }
|
||||
};
|
||||
std::size_t dummy_counter::counter = 0;
|
||||
|
||||
bool check_points_and_vectors(
|
||||
const boost::vector_property_map<Point_3>& points,
|
||||
const boost::vector_property_map<Vector_3>& normals,
|
||||
const std::vector<PointVectorPair>& pv_pairs,
|
||||
const std::vector<std::size_t>& indices)
|
||||
{
|
||||
if(pv_pairs.size() != indices.size()) {
|
||||
std::cerr << "Error: inconsistency between point / normal size." << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
for(std::size_t i = 0; i < pv_pairs.size(); ++i ) {
|
||||
if(pv_pairs[i].first != points[i]) {
|
||||
std::cerr << "Error: points are not equal." << std::endl;
|
||||
return false;
|
||||
}
|
||||
if(pv_pairs[i].second != normals[i]) {
|
||||
std::cerr << "Error: normals are not equal." << std::endl;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool check_points(
|
||||
const boost::vector_property_map<Point_3>& points_1,
|
||||
const std::vector<Point_3>& points_2,
|
||||
const std::vector<std::size_t>& indices)
|
||||
{
|
||||
if(points_2.size() != indices.size()) {
|
||||
std::cerr << "Error: inconsistency between point / normal size." << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
for(std::size_t i = 0; i < points_2.size(); ++i ) {
|
||||
if(points_2[i] != points_1[i]) {
|
||||
std::cerr << "Error: points are not equal." << std::endl;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool test_no_deduction_points_and_normals_xyz(const char* file_name)
|
||||
{
|
||||
boost::vector_property_map<Point_3> points;
|
||||
boost::vector_property_map<Vector_3> normals;
|
||||
std::vector<std::size_t> indices;
|
||||
|
||||
std::vector<PointVectorPair> pv_pairs;
|
||||
|
||||
// read with custom output iterator type
|
||||
dummy_counter::counter = 0;
|
||||
std::ifstream input(file_name);
|
||||
CGAL::read_xyz_points_and_normals<dummy_counter>(
|
||||
input, back_inserter(indices), points, normals, Kernel());
|
||||
|
||||
// read with ordinary pmaps
|
||||
input.clear();
|
||||
input.close();
|
||||
input.open(file_name);
|
||||
CGAL::read_xyz_points_and_normals(
|
||||
input, back_inserter(pv_pairs),
|
||||
CGAL::First_of_pair_property_map<PointVectorPair>(),
|
||||
CGAL::Second_of_pair_property_map<PointVectorPair>(),
|
||||
Kernel());
|
||||
|
||||
return check_points_and_vectors(points, normals, pv_pairs, indices);
|
||||
}
|
||||
|
||||
bool test_no_deduction_points_and_normals_off(const char* file_name)
|
||||
{
|
||||
boost::vector_property_map<Point_3> points;
|
||||
boost::vector_property_map<Vector_3> normals;
|
||||
std::vector<std::size_t> indices;
|
||||
|
||||
std::vector<PointVectorPair> pv_pairs;
|
||||
|
||||
// read with custom output iterator type
|
||||
dummy_counter::counter = 0;
|
||||
std::ifstream input(file_name);
|
||||
CGAL::read_off_points_and_normals<dummy_counter>(
|
||||
input, back_inserter(indices), points, normals, Kernel());
|
||||
|
||||
// read with ordinary pmaps
|
||||
input.clear();
|
||||
input.close();
|
||||
input.open(file_name);
|
||||
CGAL::read_off_points_and_normals(
|
||||
input, back_inserter(pv_pairs),
|
||||
CGAL::First_of_pair_property_map<PointVectorPair>(),
|
||||
CGAL::Second_of_pair_property_map<PointVectorPair>(),
|
||||
Kernel());
|
||||
|
||||
return check_points_and_vectors(points, normals, pv_pairs, indices);
|
||||
}
|
||||
|
||||
bool test_no_deduction_points_xyz(const char* file_name)
|
||||
{
|
||||
boost::vector_property_map<Point_3> points_1; \
|
||||
std::vector<std::size_t> indices;
|
||||
|
||||
std::vector<Point_3> points_2;
|
||||
|
||||
// read with custom output iterator type
|
||||
dummy_counter::counter = 0;
|
||||
std::ifstream input(file_name);
|
||||
CGAL::read_xyz_points<dummy_counter>(
|
||||
input, back_inserter(indices), points_1, Kernel());
|
||||
|
||||
// read with ordinary pmaps
|
||||
input.clear();
|
||||
input.close();
|
||||
input.open(file_name);
|
||||
CGAL::read_xyz_points(
|
||||
input, back_inserter(points_2),
|
||||
CGAL::Identity_property_map<Point_3>(),
|
||||
Kernel());
|
||||
|
||||
return check_points(points_1, points_2, indices);
|
||||
}
|
||||
|
||||
bool test_no_deduction_points_off(const char* file_name)
|
||||
{
|
||||
boost::vector_property_map<Point_3> points_1;
|
||||
std::vector<std::size_t> indices;
|
||||
|
||||
std::vector<Point_3> points_2;
|
||||
|
||||
// read with custom output iterator type
|
||||
dummy_counter::counter = 0;
|
||||
std::ifstream input(file_name);
|
||||
CGAL::read_off_points<dummy_counter>(
|
||||
input, back_inserter(indices), points_1, Kernel());
|
||||
|
||||
// read with ordinary pmaps
|
||||
input.clear();
|
||||
input.close();
|
||||
input.open(file_name);
|
||||
CGAL::read_off_points(
|
||||
input, back_inserter(points_2),
|
||||
CGAL::Identity_property_map<Point_3>(),
|
||||
Kernel());
|
||||
|
||||
return check_points(points_1, points_2, indices);
|
||||
}
|
||||
|
||||
void compile_test() {
|
||||
std::deque<Point_3> points;
|
||||
std::deque<Vector_3> normals;
|
||||
std::deque<PointVectorPair> pv_pairs;
|
||||
std::ifstream input;
|
||||
|
||||
input.open("data/read_test/simple.xyz");
|
||||
CGAL::read_xyz_points(
|
||||
input,
|
||||
std::front_inserter(points));
|
||||
input.clear();
|
||||
input.close();
|
||||
|
||||
input.open("data/read_test/simple.xyz");
|
||||
CGAL::read_xyz_points(
|
||||
input,
|
||||
std::front_inserter(points),
|
||||
CGAL::Identity_property_map<Point_3>());
|
||||
input.clear();
|
||||
input.close();
|
||||
|
||||
input.open("data/read_test/simple.xyz");
|
||||
CGAL::read_xyz_points(
|
||||
input,
|
||||
std::front_inserter(points),
|
||||
CGAL::Identity_property_map<Point_3>(),
|
||||
Kernel());
|
||||
input.clear();
|
||||
input.close();
|
||||
|
||||
// this will span all OutputIteratorValueType versions
|
||||
input.open("data/read_test/simple.xyz");
|
||||
CGAL::read_xyz_points<Point_3>(
|
||||
input,
|
||||
std::front_inserter(points));
|
||||
input.clear();
|
||||
input.close();
|
||||
//-----------------------------------------------------------------------
|
||||
input.open("data/read_test/simple.off");
|
||||
CGAL::read_off_points(
|
||||
input,
|
||||
std::front_inserter(points));
|
||||
input.clear();
|
||||
input.close();
|
||||
|
||||
input.open("data/read_test/simple.off");
|
||||
CGAL::read_off_points(
|
||||
input,
|
||||
std::front_inserter(points),
|
||||
CGAL::Identity_property_map<Point_3>());
|
||||
input.clear();
|
||||
input.close();
|
||||
|
||||
input.open("data/read_test/simple.off");
|
||||
CGAL::read_off_points(
|
||||
input,
|
||||
std::front_inserter(points),
|
||||
CGAL::Identity_property_map<Point_3>(),
|
||||
Kernel());
|
||||
input.clear();
|
||||
input.close();
|
||||
|
||||
// this will span all OutputIteratorValueType versions
|
||||
input.open("data/read_test/simple.off");
|
||||
CGAL::read_off_points<Point_3>(
|
||||
input,
|
||||
std::front_inserter(points));
|
||||
input.clear();
|
||||
input.close();
|
||||
//-----------------------------------------------------------------------
|
||||
input.open("data/read_test/simple.xyz");
|
||||
CGAL::read_xyz_points_and_normals(
|
||||
input,
|
||||
std::front_inserter(points),
|
||||
boost::dummy_property_map());
|
||||
input.clear();
|
||||
input.close();
|
||||
|
||||
input.open("data/read_test/simple.xyz");
|
||||
CGAL::read_xyz_points_and_normals(
|
||||
input,
|
||||
std::front_inserter(pv_pairs),
|
||||
CGAL::First_of_pair_property_map<PointVectorPair>(),
|
||||
CGAL::Second_of_pair_property_map<PointVectorPair>());
|
||||
input.clear();
|
||||
input.close();
|
||||
|
||||
input.open("data/read_test/simple.xyz");
|
||||
CGAL::read_xyz_points_and_normals(
|
||||
input,
|
||||
std::front_inserter(pv_pairs),
|
||||
CGAL::First_of_pair_property_map<PointVectorPair>(),
|
||||
CGAL::Second_of_pair_property_map<PointVectorPair>(),
|
||||
Kernel());
|
||||
input.clear();
|
||||
input.close();
|
||||
|
||||
input.open("data/read_test/simple.xyz");
|
||||
CGAL::read_xyz_points_and_normals<Point_3>(
|
||||
input,
|
||||
std::front_inserter(points),
|
||||
boost::dummy_property_map());
|
||||
input.clear();
|
||||
input.close();
|
||||
//-----------------------------------------------------------------------
|
||||
input.open("data/read_test/simple.off");
|
||||
CGAL::read_off_points_and_normals(
|
||||
input,
|
||||
std::front_inserter(points),
|
||||
boost::dummy_property_map());
|
||||
input.clear();
|
||||
input.close();
|
||||
|
||||
input.open("data/read_test/simple.off");
|
||||
CGAL::read_off_points_and_normals(
|
||||
input,
|
||||
std::front_inserter(pv_pairs),
|
||||
CGAL::First_of_pair_property_map<PointVectorPair>(),
|
||||
CGAL::Second_of_pair_property_map<PointVectorPair>());
|
||||
input.clear();
|
||||
input.close();
|
||||
|
||||
input.open("data/read_test/simple.off");
|
||||
CGAL::read_off_points_and_normals(
|
||||
input,
|
||||
std::front_inserter(pv_pairs),
|
||||
CGAL::First_of_pair_property_map<PointVectorPair>(),
|
||||
CGAL::Second_of_pair_property_map<PointVectorPair>(),
|
||||
Kernel());
|
||||
input.clear();
|
||||
input.close();
|
||||
|
||||
input.open("data/read_test/simple.off");
|
||||
CGAL::read_off_points_and_normals<Point_3>(
|
||||
input,
|
||||
std::front_inserter(points),
|
||||
boost::dummy_property_map());
|
||||
input.clear();
|
||||
input.close();
|
||||
}
|
||||
|
||||
int main() {
|
||||
if(!test_no_deduction_points_and_normals_xyz("data/read_test/simple.xyz")) {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
std::cerr << "test_no_deduction_points_and_normals_xyz OK." << std::endl;
|
||||
|
||||
if(!test_no_deduction_points_and_normals_off("data/read_test/simple.off")) {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
std::cerr << "test_no_deduction_points_and_normals_off OK." << std::endl;
|
||||
|
||||
if(!test_no_deduction_points_xyz("data/read_test/simple.xyz")) {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
std::cerr << "test_no_deduction_points_xyz OK." << std::endl;
|
||||
|
||||
if(!test_no_deduction_points_off("data/read_test/simple.off")) {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
std::cerr << "test_no_deduction_points_off OK." << std::endl;
|
||||
|
||||
compile_test();
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
|
@ -126,7 +126,7 @@ void Polyhedron_demo_normal_estimation_plugin::on_actionNormalEstimation_trigger
|
|||
|
||||
// Estimates normals direction.
|
||||
CGAL::pca_estimate_normals(points->begin(), points->end(),
|
||||
CGAL::make_normal_of_point_with_normal_pmap(points->begin()),
|
||||
CGAL::make_normal_of_point_with_normal_pmap(*points->begin()),
|
||||
dialog.directionNbNeighbors());
|
||||
|
||||
// Mark all normals as unoriented
|
||||
|
|
@ -144,7 +144,7 @@ void Polyhedron_demo_normal_estimation_plugin::on_actionNormalEstimation_trigger
|
|||
|
||||
// Estimates normals direction.
|
||||
CGAL::jet_estimate_normals(points->begin(), points->end(),
|
||||
CGAL::make_normal_of_point_with_normal_pmap(points->begin()),
|
||||
CGAL::make_normal_of_point_with_normal_pmap(*points->begin()),
|
||||
dialog.directionNbNeighbors());
|
||||
|
||||
// Mark all normals as unoriented
|
||||
|
|
@ -166,7 +166,7 @@ void Polyhedron_demo_normal_estimation_plugin::on_actionNormalEstimation_trigger
|
|||
// Tries to orient normals
|
||||
first_unoriented_point =
|
||||
CGAL::mst_orient_normals(points->begin(), points->end(),
|
||||
CGAL::make_normal_of_point_with_normal_pmap(points->begin()),
|
||||
CGAL::make_normal_of_point_with_normal_pmap(*points->begin()),
|
||||
dialog.orientationNbNeighbors());
|
||||
|
||||
std::size_t nb_unoriented_normals = std::distance(first_unoriented_point, points->end());
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ Polyhedron* poisson_reconstruct(const Point_set& points,
|
|||
// The position property map can be omitted here as we use iterators over Point_3 elements.
|
||||
Poisson_reconstruction_function function(
|
||||
points.begin(), points.end(),
|
||||
CGAL::make_normal_of_point_with_normal_pmap(points.begin()));
|
||||
CGAL::make_normal_of_point_with_normal_pmap(*points.begin()));
|
||||
|
||||
bool ok = false;
|
||||
#ifdef CGAL_TAUCS_ENABLED
|
||||
|
|
|
|||
|
|
@ -106,7 +106,7 @@ bool Scene_points_with_normal_item::read_off_point_set(std::istream& stream)
|
|||
bool ok = stream &&
|
||||
CGAL::read_off_points_and_normals(stream,
|
||||
std::back_inserter(*m_points),
|
||||
CGAL::make_normal_of_point_with_normal_pmap(std::back_inserter(*m_points))) &&
|
||||
CGAL::make_normal_of_point_with_normal_pmap(*m_points->begin())) &&
|
||||
!isEmpty();
|
||||
|
||||
return ok;
|
||||
|
|
@ -120,7 +120,7 @@ bool Scene_points_with_normal_item::write_off_point_set(std::ostream& stream) co
|
|||
return stream &&
|
||||
CGAL::write_off_points_and_normals(stream,
|
||||
m_points->begin(), m_points->end(),
|
||||
CGAL::make_normal_of_point_with_normal_pmap(m_points->begin()));
|
||||
CGAL::make_normal_of_point_with_normal_pmap(*m_points->begin()));
|
||||
}
|
||||
|
||||
// Loads point set from .XYZ file
|
||||
|
|
@ -132,7 +132,7 @@ bool Scene_points_with_normal_item::read_xyz_point_set(std::istream& stream)
|
|||
bool ok = stream &&
|
||||
CGAL::read_xyz_points_and_normals(stream,
|
||||
std::back_inserter(*m_points),
|
||||
CGAL::make_normal_of_point_with_normal_pmap(std::back_inserter(*m_points))) &&
|
||||
CGAL::make_normal_of_point_with_normal_pmap(*m_points->begin())) &&
|
||||
!isEmpty();
|
||||
|
||||
return ok;
|
||||
|
|
@ -146,7 +146,7 @@ bool Scene_points_with_normal_item::write_xyz_point_set(std::ostream& stream) co
|
|||
return stream &&
|
||||
CGAL::write_xyz_points_and_normals(stream,
|
||||
m_points->begin(), m_points->end(),
|
||||
CGAL::make_normal_of_point_with_normal_pmap(m_points->begin()));
|
||||
CGAL::make_normal_of_point_with_normal_pmap(*m_points->begin()));
|
||||
}
|
||||
|
||||
QString
|
||||
|
|
|
|||
|
|
@ -127,6 +127,14 @@ private:
|
|||
FT m_radius;
|
||||
};
|
||||
|
||||
#include <CGAL/Kernel_traits.h>
|
||||
|
||||
namespace CGAL{
|
||||
template<class Gt>
|
||||
struct Kernel_traits< ::UI_point_3<Gt> >{
|
||||
typedef Gt Kernel;
|
||||
};
|
||||
} //end of CGAL namespace
|
||||
|
||||
#endif //UI_POINT_3_H
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
#include <CGAL/Search_traits_adapter.h>
|
||||
#include <CGAL/point_generators_3.h>
|
||||
#include <CGAL/Orthogonal_k_neighbor_search.h>
|
||||
#include <CGAL/property_map.h>
|
||||
#include <boost/iterator/zip_iterator.hpp>
|
||||
#include <utility>
|
||||
|
||||
|
|
@ -11,23 +12,11 @@ typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
|
|||
typedef Kernel::Point_3 Point_3;
|
||||
typedef boost::tuple<Point_3,int> Point_and_int;
|
||||
|
||||
//definition of the property map
|
||||
struct My_point_property_map{
|
||||
typedef Point_3 value_type;
|
||||
typedef const value_type& reference;
|
||||
typedef const Point_and_int& key_type;
|
||||
typedef boost::readable_property_map_tag category;
|
||||
};
|
||||
|
||||
//get function for the property map
|
||||
My_point_property_map::reference
|
||||
get(My_point_property_map,My_point_property_map::key_type p)
|
||||
{return boost::get<0>(p);}
|
||||
|
||||
|
||||
typedef CGAL::Random_points_in_cube_3<Point_3> Random_points_iterator;
|
||||
typedef CGAL::Search_traits_3<Kernel> Traits_base;
|
||||
typedef CGAL::Search_traits_adapter<Point_and_int,My_point_property_map,Traits_base> Traits;
|
||||
typedef CGAL::Search_traits_adapter<Point_and_int,
|
||||
CGAL::Nth_of_tuple_property_map<0, Point_and_int>,
|
||||
Traits_base> Traits;
|
||||
|
||||
|
||||
typedef CGAL::Orthogonal_k_neighbor_search<Traits> K_neighbor_search;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#include <CGAL/Simple_cartesian.h>
|
||||
#include <CGAL/spatial_sort.h>
|
||||
#include <CGAL/Spatial_sort_traits_adapter_2.h>
|
||||
#include <CGAL/property_map.h>
|
||||
#include <vector>
|
||||
|
||||
typedef CGAL::Simple_cartesian<double> Kernel;
|
||||
|
|
@ -8,21 +9,9 @@ typedef Kernel::Point_2 Point_2;
|
|||
typedef std::pair<Point_2,int> Point_with_info;
|
||||
typedef std::vector< Point_with_info > Data_vector;
|
||||
|
||||
//property map
|
||||
struct First_of_pair{
|
||||
//classical typedefs
|
||||
typedef Point_with_info key_type;
|
||||
typedef Point_2 value_type;
|
||||
typedef const Point_2& reference;
|
||||
typedef boost::readable_property_map_tag category;
|
||||
};
|
||||
//get function for property map
|
||||
First_of_pair::reference
|
||||
get(const First_of_pair&, const First_of_pair::key_type& k) {
|
||||
return k.first;
|
||||
}
|
||||
|
||||
typedef CGAL::Spatial_sort_traits_adapter_2<Kernel,First_of_pair> Search_traits_2;
|
||||
typedef CGAL::Spatial_sort_traits_adapter_2<Kernel,
|
||||
CGAL::First_of_pair_property_map<Point_with_info>
|
||||
> Search_traits_2;
|
||||
|
||||
int main()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -127,7 +127,12 @@ void PS_demo_normal_estimation_plugin::on_actionNormalEstimation_triggered()
|
|||
|
||||
// Estimates normals direction.
|
||||
CGAL::pca_estimate_normals(points->begin(), points->end(),
|
||||
CGAL::make_normal_of_point_with_normal_pmap(points->begin()),
|
||||
#ifdef CGAL_USE_PROPERTY_MAPS_API_V1
|
||||
CGAL::make_normal_of_point_with_normal_pmap(points->begin()),
|
||||
#else
|
||||
CGAL::make_normal_of_point_with_normal_pmap(Point_set::value_type()),
|
||||
#endif
|
||||
|
||||
dialog.directionNbNeighbors());
|
||||
|
||||
// Mark all normals as unoriented
|
||||
|
|
@ -145,7 +150,11 @@ void PS_demo_normal_estimation_plugin::on_actionNormalEstimation_triggered()
|
|||
|
||||
// Estimates normals direction.
|
||||
CGAL::jet_estimate_normals(points->begin(), points->end(),
|
||||
CGAL::make_normal_of_point_with_normal_pmap(points->begin()),
|
||||
#ifdef CGAL_USE_PROPERTY_MAPS_API_V1
|
||||
CGAL::make_normal_of_point_with_normal_pmap(points->begin()),
|
||||
#else
|
||||
CGAL::make_normal_of_point_with_normal_pmap(Point_set::value_type()),
|
||||
#endif
|
||||
dialog.directionNbNeighbors());
|
||||
|
||||
// Mark all normals as unoriented
|
||||
|
|
@ -167,7 +176,11 @@ void PS_demo_normal_estimation_plugin::on_actionNormalEstimation_triggered()
|
|||
// Tries to orient normals
|
||||
first_unoriented_point =
|
||||
CGAL::mst_orient_normals(points->begin(), points->end(),
|
||||
CGAL::make_normal_of_point_with_normal_pmap(points->begin()),
|
||||
#ifdef CGAL_USE_PROPERTY_MAPS_API_V1
|
||||
CGAL::make_normal_of_point_with_normal_pmap(points->begin()),
|
||||
#else
|
||||
CGAL::make_normal_of_point_with_normal_pmap(Point_set::value_type()),
|
||||
#endif
|
||||
dialog.orientationNbNeighbors());
|
||||
|
||||
int nb_unoriented_normals = std::distance(first_unoriented_point, points->end());
|
||||
|
|
|
|||
|
|
@ -89,8 +89,13 @@ Polyhedron* poisson_reconstruct(const Point_set& points,
|
|||
// + property maps to access each point's position and normal.
|
||||
// The position property map can be omitted here as we use iterators over Point_3 elements.
|
||||
Poisson_reconstruction_function function(
|
||||
points.begin(), points.end(),
|
||||
CGAL::make_normal_of_point_with_normal_pmap(points.begin()) );
|
||||
points.begin(), points.end(),
|
||||
#ifdef CGAL_USE_PROPERTY_MAPS_API_V1
|
||||
CGAL::make_normal_of_point_with_normal_pmap(points.begin())
|
||||
#else
|
||||
CGAL::make_normal_of_point_with_normal_pmap(Point_set::value_type())
|
||||
#endif
|
||||
);
|
||||
|
||||
bool ok = false;
|
||||
#ifdef CGAL_TAUCS_ENABLED
|
||||
|
|
|
|||
|
|
@ -102,8 +102,13 @@ bool Point_set_scene_item::read_off_point_set(std::istream& stream)
|
|||
m_points->clear();
|
||||
bool ok = stream &&
|
||||
CGAL::read_off_points_and_normals(stream,
|
||||
std::back_inserter(*m_points),
|
||||
CGAL::make_normal_of_point_with_normal_pmap(std::back_inserter(*m_points))) &&
|
||||
std::back_inserter(*m_points),
|
||||
#ifdef CGAL_USE_PROPERTY_MAPS_API_V1
|
||||
CGAL::make_normal_of_point_with_normal_pmap(std::back_inserter(*m_points))
|
||||
#else
|
||||
CGAL::make_normal_of_point_with_normal_pmap(Point_set::value_type())
|
||||
#endif
|
||||
) &&
|
||||
!isEmpty();
|
||||
|
||||
return ok;
|
||||
|
|
@ -116,8 +121,13 @@ bool Point_set_scene_item::write_off_point_set(std::ostream& stream) const
|
|||
|
||||
return stream &&
|
||||
CGAL::write_off_points_and_normals(stream,
|
||||
m_points->begin(), m_points->end(),
|
||||
CGAL::make_normal_of_point_with_normal_pmap(m_points->begin()));
|
||||
m_points->begin(), m_points->end(),
|
||||
#ifdef CGAL_USE_PROPERTY_MAPS_API_V1
|
||||
CGAL::make_normal_of_point_with_normal_pmap(m_points->begin())
|
||||
#else
|
||||
CGAL::make_normal_of_point_with_normal_pmap(Point_set::value_type())
|
||||
#endif
|
||||
);
|
||||
}
|
||||
|
||||
// Loads point set from .XYZ file
|
||||
|
|
@ -129,7 +139,12 @@ bool Point_set_scene_item::read_xyz_point_set(std::istream& stream)
|
|||
bool ok = stream &&
|
||||
CGAL::read_xyz_points_and_normals(stream,
|
||||
std::back_inserter(*m_points),
|
||||
CGAL::make_normal_of_point_with_normal_pmap(std::back_inserter(*m_points))) &&
|
||||
#ifdef CGAL_USE_PROPERTY_MAPS_API_V1
|
||||
CGAL::make_normal_of_point_with_normal_pmap(std::back_inserter(*m_points))
|
||||
#else
|
||||
CGAL::make_normal_of_point_with_normal_pmap(Point_set::value_type())
|
||||
#endif
|
||||
) &&
|
||||
!isEmpty();
|
||||
|
||||
return ok;
|
||||
|
|
@ -142,8 +157,13 @@ bool Point_set_scene_item::write_xyz_point_set(std::ostream& stream) const
|
|||
|
||||
return stream &&
|
||||
CGAL::write_xyz_points_and_normals(stream,
|
||||
m_points->begin(), m_points->end(),
|
||||
CGAL::make_normal_of_point_with_normal_pmap(m_points->begin()));
|
||||
m_points->begin(), m_points->end(),
|
||||
#ifdef CGAL_USE_PROPERTY_MAPS_API_V1
|
||||
CGAL::make_normal_of_point_with_normal_pmap(m_points->begin())
|
||||
#else
|
||||
CGAL::make_normal_of_point_with_normal_pmap(Point_set::value_type())
|
||||
#endif
|
||||
);
|
||||
}
|
||||
|
||||
QString
|
||||
|
|
|
|||
|
|
@ -214,7 +214,7 @@ int main(int argc, char * argv[])
|
|||
!CGAL::read_xyz_points_and_normals(
|
||||
stream,
|
||||
std::back_inserter(points),
|
||||
CGAL::make_normal_of_point_with_normal_pmap(std::back_inserter(points))))
|
||||
CGAL::make_normal_of_point_with_normal_pmap(PointList::value_type())))
|
||||
{
|
||||
std::cerr << "Error: cannot read file " << input_filename << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
|
|
@ -269,8 +269,8 @@ int main(int argc, char * argv[])
|
|||
// The position property map can be omitted here as we use iterators over Point_3 elements.
|
||||
Poisson_reconstruction_function function(
|
||||
points.begin(), points.end(),
|
||||
CGAL::make_dereference_property_map(points.begin()),
|
||||
CGAL::make_normal_of_point_with_normal_pmap(points.begin()),
|
||||
CGAL::make_identity_property_map(PointList::value_type()),
|
||||
CGAL::make_normal_of_point_with_normal_pmap(PointList::value_type()),
|
||||
visitor);
|
||||
|
||||
#ifdef CGAL_TAUCS_ENABLED
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ int main(void)
|
|||
!CGAL::read_xyz_points_and_normals(
|
||||
stream,
|
||||
std::back_inserter(points),
|
||||
CGAL::make_normal_of_point_with_normal_pmap(std::back_inserter(points))))
|
||||
CGAL::make_normal_of_point_with_normal_pmap(PointList::value_type())))
|
||||
{
|
||||
std::cerr << "Error: cannot read file data/kitten.xyz" << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
|
|
@ -57,7 +57,7 @@ int main(void)
|
|||
// + property maps to access each point's position and normal.
|
||||
// The position property map can be omitted here as we use iterators over Point_3 elements.
|
||||
Poisson_reconstruction_function function(points.begin(), points.end(),
|
||||
CGAL::make_normal_of_point_with_normal_pmap(points.begin()) );
|
||||
CGAL::make_normal_of_point_with_normal_pmap(PointList::value_type()) );
|
||||
|
||||
// Computes the Poisson indicator function f()
|
||||
// at each vertex of the triangulation.
|
||||
|
|
|
|||
|
|
@ -32,9 +32,12 @@ namespace CGAL {
|
|||
/// This variant exports the surface as a triangle soup.
|
||||
///
|
||||
/// @commentheading Template Parameters:
|
||||
/// @param SurfaceMeshComplex_2InTriangulation_3 model of the SurfaceMeshComplex_2InTriangulation_3 concept.
|
||||
/// @param OutputIterator value_type must be convertible from Triangle_3<Kernel>.
|
||||
template <class SurfaceMeshComplex_2InTriangulation_3,
|
||||
/// @tparam OutputIteratorValueType value_type of OutputIterator.
|
||||
/// It is default to value_type_traits<OutputIterator>::type, and can be omitted when the default is fine.
|
||||
/// @tparam SurfaceMeshComplex_2InTriangulation_3 model of the SurfaceMeshComplex_2InTriangulation_3 concept.
|
||||
/// @tparam OutputIterator value_type must be convertible from Triangle_3<Kernel>.
|
||||
template <typename OutputIteratorValueType,
|
||||
class SurfaceMeshComplex_2InTriangulation_3,
|
||||
typename OutputIterator>
|
||||
void
|
||||
output_surface_facets_to_triangle_soup(
|
||||
|
|
@ -48,7 +51,8 @@ output_surface_facets_to_triangle_soup(
|
|||
typedef typename Tr::Point Point;
|
||||
|
||||
// value_type_traits is a workaround as back_insert_iterator's value_type is void
|
||||
typedef typename value_type_traits<OutputIterator>::type Triangle;
|
||||
// typedef typename value_type_traits<OutputIterator>::type Triangle;
|
||||
typedef OutputIteratorValueType Triangle;
|
||||
|
||||
const Tr& tr = c2t3.triangulation();
|
||||
|
||||
|
|
@ -70,6 +74,17 @@ output_surface_facets_to_triangle_soup(
|
|||
}
|
||||
}
|
||||
|
||||
template <class SurfaceMeshComplex_2InTriangulation_3,
|
||||
typename OutputIterator>
|
||||
void
|
||||
output_surface_facets_to_triangle_soup(
|
||||
const SurfaceMeshComplex_2InTriangulation_3& c2t3, ///< Input surface.
|
||||
OutputIterator output_iterator)
|
||||
{
|
||||
output_surface_facets_to_triangle_soup
|
||||
<typename value_type_traits<OutputIterator>::type>
|
||||
(c2t3, output_iterator);
|
||||
}
|
||||
|
||||
} //namespace CGAL
|
||||
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@
|
|||
#include <deque>
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include <iterator>
|
||||
|
||||
#include <CGAL/trace.h>
|
||||
#include <CGAL/Reconstruction_triangulation_3.h>
|
||||
|
|
@ -297,8 +298,8 @@ public:
|
|||
Poisson_reconstruction_function(
|
||||
InputIterator first, ///< iterator over the first input point.
|
||||
InputIterator beyond, ///< past-the-end iterator over the input points.
|
||||
PointPMap point_pmap, ///< property map to access the position of an input point.
|
||||
NormalPMap normal_pmap ///< property map to access the *oriented* normal of an input point.
|
||||
PointPMap point_pmap, ///< property map: `value_type of InputIterator` -> `Point` (the position of an input point).
|
||||
NormalPMap normal_pmap ///< property map: `value_type of InputIterator` -> `Vector` (the *oriented* normal of an input point).
|
||||
)
|
||||
: m_tr(new Triangulation), m_Bary(new std::vector<boost::array<double,9> > )
|
||||
, average_spacing(CGAL::compute_average_spacing(first, beyond, 6))
|
||||
|
|
@ -315,8 +316,8 @@ public:
|
|||
Poisson_reconstruction_function(
|
||||
InputIterator first, ///< iterator over the first input point.
|
||||
InputIterator beyond, ///< past-the-end iterator over the input points.
|
||||
PointPMap point_pmap, ///< property map to access the position of an input point.
|
||||
NormalPMap normal_pmap, ///< property map to access the *oriented* normal of an input point.
|
||||
PointPMap point_pmap, ///< property map: `value_type of InputIterator` -> `Point` (the position of an input point).
|
||||
NormalPMap normal_pmap, ///< property map: `value_type of InputIterator` -> `Vector` (the *oriented* normal of an input point).
|
||||
Visitor visitor)
|
||||
: m_tr(new Triangulation), m_Bary(new std::vector<boost::array<double,9> > )
|
||||
, average_spacing(CGAL::compute_average_spacing(first, beyond, 6))
|
||||
|
|
@ -324,14 +325,14 @@ public:
|
|||
forward_constructor(first, beyond, point_pmap, normal_pmap, visitor);
|
||||
}
|
||||
|
||||
// This variant creates a default point property map = Dereference_property_map and Visitor=Poisson_visitor
|
||||
// This variant creates a default point property map = Identity_property_map and Visitor=Poisson_visitor
|
||||
template <typename InputIterator,
|
||||
typename NormalPMap
|
||||
>
|
||||
Poisson_reconstruction_function(
|
||||
InputIterator first, ///< iterator over the first input point.
|
||||
InputIterator beyond, ///< past-the-end iterator over the input points.
|
||||
NormalPMap normal_pmap, ///< property map to access the *oriented* normal of an input point.
|
||||
NormalPMap normal_pmap, ///< property map: `value_type of InputIterator` -> `Vector` (the *oriented* normal of an input point).
|
||||
typename boost::enable_if<
|
||||
boost::is_convertible<typename InputIterator::value_type, Point>
|
||||
>::type* = 0
|
||||
|
|
@ -339,7 +340,14 @@ public:
|
|||
: m_tr(new Triangulation), m_Bary(new std::vector<boost::array<double,9> > )
|
||||
, average_spacing(CGAL::compute_average_spacing(first, beyond, 6))
|
||||
{
|
||||
forward_constructor(first, beyond, make_dereference_property_map(first), normal_pmap, Poisson_visitor());
|
||||
forward_constructor(first, beyond,
|
||||
#ifdef CGAL_USE_PROPERTY_MAPS_API_V1
|
||||
make_dereference_property_map(first),
|
||||
#else
|
||||
make_identity_property_map(
|
||||
typename std::iterator_traits<InputIterator>::value_type()),
|
||||
#endif
|
||||
normal_pmap, Poisson_visitor());
|
||||
CGAL::Timer task_timer; task_timer.start();
|
||||
}
|
||||
/// \endcond
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@
|
|||
#include <boost/random/linear_congruential.hpp>
|
||||
|
||||
#include <vector>
|
||||
#include <iterator>
|
||||
|
||||
namespace CGAL {
|
||||
|
||||
|
|
@ -372,8 +373,8 @@ public:
|
|||
int insert(
|
||||
InputIterator first, ///< iterator over the first input point.
|
||||
InputIterator beyond, ///< past-the-end iterator over the input points.
|
||||
PointPMap point_pmap, ///< property map to access the position of an input point.
|
||||
NormalPMap normal_pmap, ///< property map to access the *oriented* normal of an input point.
|
||||
PointPMap point_pmap, ///< property map: `value_type of InputIterator` -> `Point_3` (the position of an input point).
|
||||
NormalPMap normal_pmap, ///< property map: `value_type of InputIterator` -> `Vector_3` (the *oriented* normal of an input point).
|
||||
Visitor visitor)
|
||||
{
|
||||
if(! points.empty()){
|
||||
|
|
@ -383,8 +384,12 @@ public:
|
|||
//std::vector<Point_with_normal> points;
|
||||
for (InputIterator it = first; it != beyond; ++it)
|
||||
{
|
||||
Point_with_normal pwn(get(point_pmap,it), get(normal_pmap,it));
|
||||
points.push_back(pwn);
|
||||
#ifdef CGAL_USE_PROPERTY_MAPS_API_V1
|
||||
Point_with_normal pwn(get(point_pmap,it), get(normal_pmap,it));
|
||||
#else
|
||||
Point_with_normal pwn(get(point_pmap,*it), get(normal_pmap,*it));
|
||||
#endif
|
||||
points.push_back(pwn);
|
||||
}
|
||||
std::size_t n = points.size();
|
||||
|
||||
|
|
@ -435,7 +440,7 @@ public:
|
|||
}
|
||||
|
||||
/// \cond SKIP_IN_MANUAL
|
||||
// This variant creates a default point property map = Dereference_property_map.
|
||||
// This variant creates a default point property map = Identity_property_map.
|
||||
template <typename InputIterator,
|
||||
typename NormalPMap,
|
||||
typename Visitor
|
||||
|
|
@ -443,12 +448,17 @@ public:
|
|||
int insert(
|
||||
InputIterator first, ///< iterator over the first input point.
|
||||
InputIterator beyond, ///< past-the-end iterator over the input points.
|
||||
NormalPMap normal_pmap, ///< property map to access the *oriented* normal of an input point.
|
||||
NormalPMap normal_pmap, ///< property map: `value_type of InputIterator` -> `Vector_3` (the *oriented* normal of an input point).
|
||||
Visitor visitor)
|
||||
{
|
||||
return insert(
|
||||
first,beyond,
|
||||
#ifdef CGAL_USE_PROPERTY_MAPS_API_V1
|
||||
make_dereference_property_map(first),
|
||||
#else
|
||||
make_identity_property_map(
|
||||
typename std::iterator_traits<InputIterator>::value_type()),
|
||||
#endif
|
||||
normal_pmap,
|
||||
visitor);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -145,7 +145,12 @@ int main(int argc, char * argv[])
|
|||
!CGAL::read_xyz_points_and_normals(
|
||||
stream,
|
||||
std::back_inserter(points),
|
||||
CGAL::make_normal_of_point_with_normal_pmap(std::back_inserter(points))))
|
||||
#ifdef CGAL_USE_PROPERTY_MAPS_API_V1
|
||||
CGAL::make_normal_of_point_with_normal_pmap(std::back_inserter(points))
|
||||
#else
|
||||
CGAL::make_normal_of_point_with_normal_pmap(PointList::value_type())
|
||||
#endif
|
||||
))
|
||||
{
|
||||
std::cerr << "Error: cannot read file " << input_filename << std::endl;
|
||||
accumulated_fatal_err = EXIT_FAILURE;
|
||||
|
|
@ -201,7 +206,12 @@ int main(int argc, char * argv[])
|
|||
// The position property map can be omitted here as we use iterators over Point_3 elements.
|
||||
Poisson_reconstruction_function function(
|
||||
points.begin(), points.end(),
|
||||
CGAL::make_normal_of_point_with_normal_pmap(points.begin()) );
|
||||
#ifdef CGAL_USE_PROPERTY_MAPS_API_V1
|
||||
CGAL::make_normal_of_point_with_normal_pmap(points.begin())
|
||||
#else
|
||||
CGAL::make_normal_of_point_with_normal_pmap(PointList::value_type())
|
||||
#endif
|
||||
);
|
||||
|
||||
// Computes the Poisson indicator function f()
|
||||
// at each vertex of the triangulation.
|
||||
|
|
|
|||
Loading…
Reference in New Issue