diff --git a/Installation/changes.html b/Installation/changes.html index 7c686d9919c..f1a18da224a 100755 --- a/Installation/changes.html +++ b/Installation/changes.html @@ -160,6 +160,17 @@ David A. Wheeler's 'SLOCCount', restricted to the include/CGAL/ an operator to accept and dispatch a tuple of values. + +

CGAL and Boost Property Maps

+ +

Release 4.2

diff --git a/Point_set_processing_3/doc/Point_set_processing_3/Point_set_processing_3.txt b/Point_set_processing_3/doc/Point_set_processing_3/Point_set_processing_3.txt index fb3fb5f0210..468ec744e2f 100644 --- a/Point_set_processing_3/doc/Point_set_processing_3/Point_set_processing_3.txt +++ b/Point_set_processing_3/doc/Point_set_processing_3/Point_set_processing_3.txt @@ -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` +- `Identity_property_map` - `First_of_pair_property_map` and `Second_of_pair_property_map` - `Nth_of_tuple_property_map` -`Dereference_property_map` is the default value of the +`Identity_property_map` 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` property +points. It uses the `Identity_property_map` 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} diff --git a/Point_set_processing_3/doc/Property_map/Property_map.txt b/Point_set_processing_3/doc/Property_map/Property_map.txt index 876c71a58c3..1e97f9a5a85 100644 --- a/Point_set_processing_3/doc/Property_map/Property_map.txt +++ b/Point_set_processing_3/doc/Property_map/Property_map.txt @@ -35,15 +35,14 @@ or as a `boost::tuple<..,Point_3, ..., Vector_3 >`. This component provides property maps to support these cases: -`Dereference_property_map` +- `Identity_property_map` +- `First_of_pair_property_map` and `Second_of_pair_property_map` +- `Nth_of_tuple_property_map` +- `Dereference_property_map` -`First_of_pair_property_map` and `Second_of_pair_property_map` +\subsection Property_mapExamplewithIdentity Example with Identity_property_map -`Nth_of_tuple_property_map` - -\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` as position property map. +The following example reads a point set and removes 5% of the points. It uses `Identity_property_map` as position property map. \cgalExample{Point_set_processing_3/remove_outliers_example.cpp} \subsection Property_mapExamplewithPairs Example with Pairs diff --git a/Point_set_processing_3/examples/Point_set_processing_3/average_spacing_example.cpp b/Point_set_processing_3/examples/Point_set_processing_3/average_spacing_example.cpp index fd2c681e7e2..3fba6dc804d 100644 --- a/Point_set_processing_3/examples/Point_set_processing_3/average_spacing_example.cpp +++ b/Point_set_processing_3/examples/Point_set_processing_3/average_spacing_example.cpp @@ -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; diff --git a/Point_set_processing_3/examples/Point_set_processing_3/property_map.cpp b/Point_set_processing_3/examples/Point_set_processing_3/property_map.cpp index 556d56e994d..78ae3802532 100644 --- a/Point_set_processing_3/examples/Point_set_processing_3/property_map.cpp +++ b/Point_set_processing_3/examples/Point_set_processing_3/property_map.cpp @@ -8,6 +8,8 @@ #include #include +#include + #include #include #include @@ -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 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::type()) + ); } @@ -75,13 +80,11 @@ template 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 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()); - + 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; } diff --git a/Point_set_processing_3/examples/Point_set_processing_3/remove_outliers_example.cpp b/Point_set_processing_3/examples/Point_set_processing_3/remove_outliers_example.cpp index 4e8fc2a53c9..778e134d61f 100644 --- a/Point_set_processing_3/examples/Point_set_processing_3/remove_outliers_example.cpp +++ b/Point_set_processing_3/examples/Point_set_processing_3/remove_outliers_example.cpp @@ -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 points; std::ifstream stream("data/oni.xyz"); if (!stream || !CGAL::read_xyz_points(stream, std::back_inserter(points), - CGAL::Dereference_property_map())) + CGAL::Identity_property_map())) { 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(), - nb_neighbors, removed_percentage), + CGAL::Identity_property_map(), + nb_neighbors, removed_percentage), points.end()); // Optional: after erase(), use Scott Meyer's "swap trick" to trim excess capacity std::vector(points).swap(points); return EXIT_SUCCESS; -} - +} \ No newline at end of file diff --git a/Point_set_processing_3/include/CGAL/IO/read_off_points.h b/Point_set_processing_3/include/CGAL/IO/read_off_points.h index e84bed076f2..8957cbe2360 100644 --- a/Point_set_processing_3/include/CGAL/IO/read_off_points.h +++ b/Point_set_processing_3/include/CGAL/IO/read_off_points.h @@ -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::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. /// It can be omitted if OutputIterator value_type is convertible to Point_3. @@ -55,21 +57,24 @@ namespace CGAL { /// @return true on success. // This variant requires all parameters. -template 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::type Enriched_point; + // typedef typename value_type_traits::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 +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 + ::type>( + stream, + output, + point_pmap, + normal_pmap, + kernel); +} +//----------------------------------------------------------------------------------- +/// @endcond + /// @cond SKIP_IN_MANUAL // This variant deduces the kernel from the point property map. +//----------------------------------------------------------------------------------- +template +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::value_type Point; + typedef typename Kernel_traits::Kernel Kernel; + return read_off_points_and_normals + ( + stream, + output, + point_pmap, + normal_pmap, + Kernel()); +} + template 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::value_type Point; - typedef typename Kernel_traits::Kernel Kernel; - return read_off_points_and_normals( + // just deduce value_type of OutputIterator + return read_off_points_and_normals + ::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 +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 + ( + stream, + output, +#ifdef CGAL_USE_PROPERTY_MAPS_API_V1 + make_dereference_property_map(output), +#else + make_identity_property_map(OutputIteratorValueType()), +#endif + normal_pmap); +} + template @@ -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 + ::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::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. /// It can be omitted if OutputIterator value_type is convertible to Point_3. @@ -210,7 +297,9 @@ read_off_points_and_normals( /// @return true on success. // This variant requires all parameters. -template @@ -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 + ( stream, output, point_pmap, @@ -230,8 +320,52 @@ read_off_points( kernel); } +/// @cond SKIP_IN_MANUAL +template +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 + ::type>( + stream, + output, + point_pmap, + kernel); +} +//----------------------------------------------------------------------------------- +/// @endcond + /// @cond SKIP_IN_MANUAL // This variant deduces the kernel from the point property map. +//----------------------------------------------------------------------------------- +template +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::value_type Point; + typedef typename Kernel_traits::Kernel Kernel; + return read_off_points + ( + stream, + output, + point_pmap, + Kernel()); +} + template @@ -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::value_type Point; - typedef typename Kernel_traits::Kernel Kernel; - return read_off_points( + // just deduce value_type of OutputIterator + return read_off_points + ::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 +bool +read_off_points( + std::istream& stream, ///< input stream. + OutputIterator output) ///< output iterator over points. +{ + return read_off_points + ( + stream, + output, +#ifdef CGAL_USE_PROPERTY_MAPS_API_V1 + make_dereference_property_map(output) +#else + make_identity_property_map(OutputIteratorValueType()) +#endif + ); +} + template 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 + ::type>( stream, - output, - make_dereference_property_map(output)); + output); } +//----------------------------------------------------------------------------------- + /// @endcond diff --git a/Point_set_processing_3/include/CGAL/IO/read_xyz_points.h b/Point_set_processing_3/include/CGAL/IO/read_xyz_points.h index 97b23b95faa..02ff8287ca1 100644 --- a/Point_set_processing_3/include/CGAL/IO/read_xyz_points.h +++ b/Point_set_processing_3/include/CGAL/IO/read_xyz_points.h @@ -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::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. /// It can be omitted if OutputIterator value_type is convertible to Point_3. @@ -56,7 +58,9 @@ namespace CGAL { /// @return true on success. // This variant requires all parameters. -template 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::type Enriched_point; + //typedef typename value_type_traits::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 +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 + ::type>( + stream, + output, + point_pmap, + normal_pmap, + kernel); +} +//----------------------------------------------------------------------------------- +/// @endcond + /// @cond SKIP_IN_MANUAL // This variant deduces the kernel from the point property map. +//----------------------------------------------------------------------------------- +template +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::value_type Point; + typedef typename Kernel_traits::Kernel Kernel; + return read_xyz_points_and_normals + ( + stream, + output, + point_pmap, + normal_pmap, + Kernel()); +} + template 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::value_type Point; - typedef typename Kernel_traits::Kernel Kernel; - return read_xyz_points_and_normals( + // just deduce value_type of OutputIterator + return read_xyz_points_and_normals + ::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 +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 + ( + stream, + output, +#ifdef CGAL_USE_PROPERTY_MAPS_API_V1 + make_dereference_property_map(output), +#else + make_identity_property_map(OutputIteratorValueType()), +#endif + normal_pmap); +} + template @@ -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 + ::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::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. /// It can be omitted if OutputIterator value_type is convertible to Point_3. @@ -207,7 +294,9 @@ read_xyz_points_and_normals( /// @return true on success. // This variant requires all parameters. -template @@ -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 + ( stream, output, point_pmap, @@ -227,8 +317,52 @@ read_xyz_points( kernel); } +/// @cond SKIP_IN_MANUAL +template +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 + ::type>( + stream, + output, + point_pmap, + kernel); +} +/// @endcond +//----------------------------------------------------------------------------------- + /// @cond SKIP_IN_MANUAL // This variant deduces the kernel from the point property map. +//----------------------------------------------------------------------------------- +template +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::value_type Point; + typedef typename Kernel_traits::Kernel Kernel; + return read_xyz_points + ( + stream, + output, + point_pmap, + Kernel()); +} + template @@ -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::value_type Point; - typedef typename Kernel_traits::Kernel Kernel; - return read_xyz_points( + // just deduce value_type of OutputIterator + return read_xyz_points + ::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 +bool +read_xyz_points( + std::istream& stream, ///< input stream. + OutputIterator output) ///< output iterator over points. +{ + return read_xyz_points + ( + stream, + output, +#ifdef CGAL_USE_PROPERTY_MAPS_API_V1 + make_dereference_property_map(output) +#else + make_identity_property_map(OutputIteratorValueType()) +#endif + ); +} + template 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 + ::type>( stream, - output, - make_dereference_property_map(output)); + output); } +//----------------------------------------------------------------------------------- /// @endcond diff --git a/Point_set_processing_3/include/CGAL/IO/write_off_points.h b/Point_set_processing_3/include/CGAL/IO/write_off_points.h index c2bd092ad66..d5b2c59c273 100644 --- a/Point_set_processing_3/include/CGAL/IO/write_off_points.h +++ b/Point_set_processing_3/include/CGAL/IO/write_off_points.h @@ -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. /// It can be omitted if ForwardIterator value_type is convertible to Point_3. -/// @tparam NormalPMap is a model of `WritablePropertyMap` with a value_type = Vector_3. +/// @tparam NormalPMap is a model of `ReadablePropertyMap` with a value_type = Vector_3. /// @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::value_type Point; typedef typename Kernel_traits::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 @@ -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::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::value_type Point; typedef typename Kernel_traits::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 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::value_type()) +#endif + ); } /// @endcond diff --git a/Point_set_processing_3/include/CGAL/IO/write_xyz_points.h b/Point_set_processing_3/include/CGAL/IO/write_xyz_points.h index 044a520525f..d96ace8d618 100644 --- a/Point_set_processing_3/include/CGAL/IO/write_xyz_points.h +++ b/Point_set_processing_3/include/CGAL/IO/write_xyz_points.h @@ -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. /// It can be omitted if ForwardIterator value_type is convertible to Point_3. -/// @tparam NormalPMap is a model of `WritablePropertyMap` with a value_type = Vector_3. +/// @tparam NormalPMap is a model of `ReadablePropertyMap` with a value_type = Vector_3. /// @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::value_type Point; typedef typename Kernel_traits::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 @@ -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::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::value_type Point; typedef typename Kernel_traits::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 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::value_type()) +#endif + ); } /// @endcond diff --git a/Point_set_processing_3/include/CGAL/Point_with_normal_3.h b/Point_set_processing_3/include/CGAL/Point_with_normal_3.h index ac30151afd3..94636bf2b3e 100644 --- a/Point_set_processing_3/include/CGAL/Point_with_normal_3.h +++ b/Point_set_processing_3/include/CGAL/Point_with_normal_3.h @@ -26,6 +26,8 @@ #include #include +#include + #include #if BOOST_VERSION >= 104000 #include @@ -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 +struct Normal_of_point_with_normal_pmap +{ + typedef Point_with_normal_3 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 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 // Point_with_normal type +Normal_of_point_with_normal_pmap< + typename CGAL::Kernel_traits::Kernel> + make_normal_of_point_with_normal_pmap(Point_with_normal) +{ + return Normal_of_point_with_normal_pmap::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::Kernel Kernel; return Normal_of_point_with_normal_pmap(); } +#endif /// \endcond diff --git a/Point_set_processing_3/include/CGAL/compute_average_spacing.h b/Point_set_processing_3/include/CGAL/compute_average_spacing.h index cf4174e9eb9..39cfa485a20 100644 --- a/Point_set_processing_3/include/CGAL/compute_average_spacing.h +++ b/Point_set_processing_3/include/CGAL/compute_average_spacing.h @@ -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 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(get(point_pmap,it),tree,k); + sum_spacings += internal::compute_average_spacing( + + #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::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::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::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::value_type()), +#endif k); } /// @endcond diff --git a/Point_set_processing_3/include/CGAL/grid_simplify_point_set.h b/Point_set_processing_3/include/CGAL/grid_simplify_point_set.h index c1f1e037b4a..ebd2a228e09 100644 --- a/Point_set_processing_3/include/CGAL/grid_simplify_point_set.h +++ b/Point_set_processing_3/include/CGAL/grid_simplify_point_set.h @@ -64,8 +64,13 @@ public: typedef typename boost::property_traits::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 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::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 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::value_type()), +#endif epsilon); } /// @endcond diff --git a/Point_set_processing_3/include/CGAL/improved_jet_smooth_point_set.h b/Point_set_processing_3/include/CGAL/improved_jet_smooth_point_set.h index e6c42a3e686..a910d1e9716 100644 --- a/Point_set_processing_3/include/CGAL/improved_jet_smooth_point_set.h +++ b/Point_set_processing_3/include/CGAL/improved_jet_smooth_point_set.h @@ -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. +/// @tparam PointPMap is a model of `ReadWritePropertyMap` with a value_type = Point_3. /// It can be omitted if ForwardIterator value_type is convertible to Point_3. /// @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 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 p(nb_points); // positions at step iter_n std::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(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 @@ -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::value_type()), +#endif k, iter_number, alpha, beta); diff --git a/Point_set_processing_3/include/CGAL/improved_laplacian_smooth_point_set.h b/Point_set_processing_3/include/CGAL/improved_laplacian_smooth_point_set.h index fd58a5b86e9..7008f4b2d78 100644 --- a/Point_set_processing_3/include/CGAL/improved_laplacian_smooth_point_set.h +++ b/Point_set_processing_3/include/CGAL/improved_laplacian_smooth_point_set.h @@ -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. +/// @tparam PointPMap is a model of `ReadWritePropertyMap` with a value_type = Point_3. /// It can be omitted if ForwardIterator value_type is convertible to Point_3. /// @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 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 p(nb_points); // positions at step iter_n std::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(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 @@ -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::value_type()), +#endif k, iter_number, alpha, beta); diff --git a/Point_set_processing_3/include/CGAL/jet_estimate_normals.h b/Point_set_processing_3/include/CGAL/jet_estimate_normals.h index 8823086669f..ba9d085b37a 100644 --- a/Point_set_processing_3/include/CGAL/jet_estimate_normals.h +++ b/Point_set_processing_3/include/CGAL/jet_estimate_normals.h @@ -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. /// It can be omitted if ForwardIterator value_type is convertible to Point_3. @@ -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 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(get(point_pmap,it), tree, k, degree_fitting); + Vector normal = internal::jet_estimate_normal( +#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 @@ -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::value_type()), +#endif normal_pmap, k, degree_fitting); diff --git a/Point_set_processing_3/include/CGAL/jet_smooth_point_set.h b/Point_set_processing_3/include/CGAL/jet_smooth_point_set.h index b69f4dce48c..f98f5251f7a 100644 --- a/Point_set_processing_3/include/CGAL/jet_smooth_point_set.h +++ b/Point_set_processing_3/include/CGAL/jet_smooth_point_set.h @@ -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. +/// @tparam PointPMap is a model of `ReadWritePropertyMap` with a value_type = Point_3. /// It can be omitted if InputIterator value_type is convertible to Point_3. /// @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 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(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(p,tree,k,degree_fitting,degree_monge) ); +#else + const Point& p = get(point_pmap, *it); + put(point_pmap, *it , + internal::jet_smooth_point(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 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::value_type()), +#endif k, degree_fitting,degree_monge); } diff --git a/Point_set_processing_3/include/CGAL/mst_orient_normals.h b/Point_set_processing_3/include/CGAL/mst_orient_normals.h index df9eb73b324..69894c99ee2 100644 --- a/Point_set_processing_3/include/CGAL/mst_orient_normals.h +++ b/Point_set_processing_3/include/CGAL/mst_orient_normals.h @@ -102,7 +102,7 @@ struct MST_graph_vertex_properties { bool is_oriented; ///< Is input point's normal oriented? }; template 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 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 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 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 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::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 @@ -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::value_type()), +#endif normal_pmap, k); } diff --git a/Point_set_processing_3/include/CGAL/pca_estimate_normals.h b/Point_set_processing_3/include/CGAL/pca_estimate_normals.h index 618604ef949..b69eafdeabd 100644 --- a/Point_set_processing_3/include/CGAL/pca_estimate_normals.h +++ b/Point_set_processing_3/include/CGAL/pca_estimate_normals.h @@ -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 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(get(point_pmap,it), tree, k); + Vector normal = internal::pca_estimate_normal( +#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::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 @@ -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::value_type()), +#endif normal_pmap, k); } diff --git a/Point_set_processing_3/include/CGAL/pca_smooth_point_set.h b/Point_set_processing_3/include/CGAL/pca_smooth_point_set.h index 7bf6eddbc6c..93be9c562c0 100644 --- a/Point_set_processing_3/include/CGAL/pca_smooth_point_set.h +++ b/Point_set_processing_3/include/CGAL/pca_smooth_point_set.h @@ -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. +/// @tparam PointPMap is a model of `ReadWritePropertyMap` with a value_type = Point_3. /// It can be omitted if InputIterator value_type is convertible to Point_3. /// @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 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(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(p,tree,k) ); +#else + const Point& p = get(point_pmap, *it); + put(point_pmap, *it, internal::pca_smooth_point(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::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 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::value_type()), +#endif k); } /// @endcond diff --git a/Point_set_processing_3/include/CGAL/property_map.h b/Point_set_processing_3/include/CGAL/property_map.h index dd49bdc08dd..fb201ea87a5 100644 --- a/Point_set_processing_3/include/CGAL/property_map.h +++ b/Point_set_processing_3/include/CGAL/property_map.h @@ -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::type>(); } +/// \ingroup PkgProperty_map +/// A `LvaluePropertyMap` property map mapping a key to itself (by reference). +/// +/// \cgalModels `LvaluePropertyMap` +template +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 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 // Key and value type +Identity_property_map + make_identity_property_map(T) +{ + return Identity_property_map(); +} + //========================================================================= - +#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 > { - 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 // Type convertible to key_type First_of_pair_property_map::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::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` +template +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 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 // Pair type +First_of_pair_property_map + make_first_of_pair_property_map(Pair) +{ + return First_of_pair_property_map(); +} +#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 > { - 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 // Type convertible to key_type Second_of_pair_property_map::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::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` +template +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 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 // Pair type +Second_of_pair_property_map + make_second_of_pair_property_map(Pair) +{ + return Second_of_pair_property_map(); +} +#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::type&, Nth_of_tuple_property_map > { - typedef Tuple* key_type; ///< typedef to 'Tuple*' + typedef Tuple* key_type; ///< typedef to `Tuple*` typedef typename boost::tuples::element::type value_type; ///< typedef to `boost::tuples::element::%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 // Type convertible to key_type Nth_of_tuple_property_map::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::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 +struct Nth_of_tuple_property_map +{ + typedef Tuple key_type; ///< typedef to `Tuple` + typedef typename boost::tuples::element::type value_type; ///< typedef to `boost::tuples::element::%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(); } + typedef Nth_of_tuple_property_map Self; + /// \name Put/get free functions + /// @{ + friend const value_type& get(const Self&,const key_type& k) {return k.template get();} + friend reference get(const Self&, key_type& k) {return k.template get();} + friend void put(const Self&,key_type& k, const value_type& v) {k.template get()=v;} + /// @} +}; + +/// Free function to create a Nth_of_tuple_property_map property map. +/// +/// \relates Nth_of_tuple_property_map +template // Tuple type +Nth_of_tuple_property_map + make_nth_of_tuple_property_map(Tuple) +{ + return Nth_of_tuple_property_map(); +} +#endif } // namespace CGAL diff --git a/Point_set_processing_3/include/CGAL/radial_orient_normals.h b/Point_set_processing_3/include/CGAL/radial_orient_normals.h index eb00919f98d..6da4deeb249 100644 --- a/Point_set_processing_3/include/CGAL/radial_orient_normals.h +++ b/Point_set_processing_3/include/CGAL/radial_orient_normals.h @@ -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 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::value_type Point; typedef typename Kernel_traits::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 @@ -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::value_type()), +#endif normal_pmap); } /// @endcond diff --git a/Point_set_processing_3/include/CGAL/random_simplify_point_set.h b/Point_set_processing_3/include/CGAL/random_simplify_point_set.h index 851a77b951b..f6b03392f21 100644 --- a/Point_set_processing_3/include/CGAL/random_simplify_point_set.h +++ b/Point_set_processing_3/include/CGAL/random_simplify_point_set.h @@ -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::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 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::value_type()), +#endif removed_percentage); } /// @endcond diff --git a/Point_set_processing_3/include/CGAL/remove_outliers.h b/Point_set_processing_3/include/CGAL/remove_outliers.h index 454ca391b2f..131c5593100 100644 --- a/Point_set_processing_3/include/CGAL/remove_outliers.h +++ b/Point_set_processing_3/include/CGAL/remove_outliers.h @@ -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 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 sorted_points; for(it = first; it != beyond; it++) { - FT sq_distance = internal::compute_avg_knn_sq_distance_3(get(point_pmap,it), tree, k); + FT sq_distance = internal::compute_avg_knn_sq_distance_3( +#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 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::value_type()), +#endif k,threshold_percent); } /// @endcond diff --git a/Point_set_processing_3/include/CGAL/remove_outliers_wrt_median_knn_sq_distance.h b/Point_set_processing_3/include/CGAL/remove_outliers_wrt_median_knn_sq_distance.h index e77c63b4825..7059f23587c 100644 --- a/Point_set_processing_3/include/CGAL/remove_outliers_wrt_median_knn_sq_distance.h +++ b/Point_set_processing_3/include/CGAL/remove_outliers_wrt_median_knn_sq_distance.h @@ -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 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 sorted_points; for(it = first; it != beyond; it++) { - FT sq_distance = internal::compute_median_knn_sq_distance_3(get(point_pmap,it), tree, k); + FT sq_distance = internal::compute_median_knn_sq_distance_3( +#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 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::value_type()), +#endif k,threshold_percent); } /// @endcond diff --git a/Point_set_processing_3/include/CGAL/value_type_traits.h b/Point_set_processing_3/include/CGAL/value_type_traits.h index bc77ccdec02..63f94945988 100644 --- a/Point_set_processing_3/include/CGAL/value_type_traits.h +++ b/Point_set_processing_3/include/CGAL/value_type_traits.h @@ -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::type value_type; - template struct value_type_traits { + #ifndef DOXYGEN_RUNNING typedef typename std::iterator_traits::value_type type; + #else + /// If `T` is `std::insert_iterator`, `std::back_insert_iterator` or + /// `std::front_insert_iterator`, then `type` is `Container::value_type`. + /// Otherwise, `type` is `std::iterator_traits::%value_type`. + + typedef Hidden_type type; + #endif }; -template -struct value_type_traits > +template +struct value_type_traits > { - typedef typename T::value_type type; + typedef typename Container::value_type type; }; -/// \endcond +template +struct value_type_traits > +{ + typedef typename Container::value_type type; +}; + +template +struct value_type_traits > +{ + typedef typename Container::value_type type; +}; } //namespace CGAL diff --git a/Point_set_processing_3/test/Point_set_processing_3/CMakeLists.txt b/Point_set_processing_3/test/Point_set_processing_3/CMakeLists.txt index 59efc4dc9ed..a04095be37f 100644 --- a/Point_set_processing_3/test/Point_set_processing_3/CMakeLists.txt +++ b/Point_set_processing_3/test/Point_set_processing_3/CMakeLists.txt @@ -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" ) diff --git a/Point_set_processing_3/test/Point_set_processing_3/data/read_test/simple.off b/Point_set_processing_3/test/Point_set_processing_3/data/read_test/simple.off new file mode 100644 index 00000000000..71f3a1ccc32 --- /dev/null +++ b/Point_set_processing_3/test/Point_set_processing_3/data/read_test/simple.off @@ -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 \ No newline at end of file diff --git a/Point_set_processing_3/test/Point_set_processing_3/data/read_test/simple.xyz b/Point_set_processing_3/test/Point_set_processing_3/data/read_test/simple.xyz new file mode 100644 index 00000000000..cdb89589b5a --- /dev/null +++ b/Point_set_processing_3/test/Point_set_processing_3/data/read_test/simple.xyz @@ -0,0 +1,3 @@ +1 1 1 2 2 2 +3 3 3 4 4 4 +5 5 5 6 6 6 \ No newline at end of file diff --git a/Point_set_processing_3/test/Point_set_processing_3/normal_estimation_test.cpp b/Point_set_processing_3/test/Point_set_processing_3/normal_estimation_test.cpp index c383b860193..02c1bbdf9d9 100644 --- a/Point_set_processing_3/test/Point_set_processing_3/normal_estimation_test.cpp +++ b/Point_set_processing_3/test/Point_set_processing_3/normal_estimation_test.cpp @@ -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) { diff --git a/Point_set_processing_3/test/Point_set_processing_3/read_test.cpp b/Point_set_processing_3/test/Point_set_processing_3/read_test.cpp old mode 100755 new mode 100644 diff --git a/Point_set_processing_3/test/Point_set_processing_3/read_test_with_different_pmaps.cpp b/Point_set_processing_3/test/Point_set_processing_3/read_test_with_different_pmaps.cpp new file mode 100644 index 00000000000..acd044e65dc --- /dev/null +++ b/Point_set_processing_3/test/Point_set_processing_3/read_test_with_different_pmaps.cpp @@ -0,0 +1,343 @@ +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#if BOOST_VERSION >= 104000 + #include +#else + #include +#endif + +typedef CGAL::Simple_cartesian Kernel; +typedef Kernel::Point_3 Point_3; +typedef Kernel::Vector_3 Vector_3; +typedef std::pair 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& points, + const boost::vector_property_map& normals, + const std::vector& pv_pairs, + const std::vector& 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& points_1, + const std::vector& points_2, + const std::vector& 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 points; + boost::vector_property_map normals; + std::vector indices; + + std::vector pv_pairs; + + // read with custom output iterator type + dummy_counter::counter = 0; + std::ifstream input(file_name); + CGAL::read_xyz_points_and_normals( + 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(), + CGAL::Second_of_pair_property_map(), + 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 points; + boost::vector_property_map normals; + std::vector indices; + + std::vector pv_pairs; + + // read with custom output iterator type + dummy_counter::counter = 0; + std::ifstream input(file_name); + CGAL::read_off_points_and_normals( + 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(), + CGAL::Second_of_pair_property_map(), + 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 points_1; \ + std::vector indices; + + std::vector points_2; + + // read with custom output iterator type + dummy_counter::counter = 0; + std::ifstream input(file_name); + CGAL::read_xyz_points( + 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(), + Kernel()); + + return check_points(points_1, points_2, indices); +} + +bool test_no_deduction_points_off(const char* file_name) +{ + boost::vector_property_map points_1; + std::vector indices; + + std::vector points_2; + + // read with custom output iterator type + dummy_counter::counter = 0; + std::ifstream input(file_name); + CGAL::read_off_points( + 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(), + Kernel()); + + return check_points(points_1, points_2, indices); +} + +void compile_test() { + std::deque points; + std::deque normals; + std::deque 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()); + input.clear(); + input.close(); + + input.open("data/read_test/simple.xyz"); + CGAL::read_xyz_points( + input, + std::front_inserter(points), + CGAL::Identity_property_map(), + Kernel()); + input.clear(); + input.close(); + + // this will span all OutputIteratorValueType versions + 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.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()); + input.clear(); + input.close(); + + input.open("data/read_test/simple.off"); + CGAL::read_off_points( + input, + std::front_inserter(points), + CGAL::Identity_property_map(), + Kernel()); + input.clear(); + input.close(); + + // this will span all OutputIteratorValueType versions + 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.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(), + CGAL::Second_of_pair_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(), + CGAL::Second_of_pair_property_map(), + Kernel()); + 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.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(), + CGAL::Second_of_pair_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(), + CGAL::Second_of_pair_property_map(), + Kernel()); + 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(); +} + +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; +} \ No newline at end of file diff --git a/Polyhedron/demo/Polyhedron/Polyhedron_demo_normal_estimation_plugin.cpp b/Polyhedron/demo/Polyhedron/Polyhedron_demo_normal_estimation_plugin.cpp index 1fee59949a1..38759135e8c 100644 --- a/Polyhedron/demo/Polyhedron/Polyhedron_demo_normal_estimation_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Polyhedron_demo_normal_estimation_plugin.cpp @@ -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()); diff --git a/Polyhedron/demo/Polyhedron/Polyhedron_demo_poisson_plugin_impl.cpp b/Polyhedron/demo/Polyhedron/Polyhedron_demo_poisson_plugin_impl.cpp index 98da1f5b69d..c5e9d1adf59 100644 --- a/Polyhedron/demo/Polyhedron/Polyhedron_demo_poisson_plugin_impl.cpp +++ b/Polyhedron/demo/Polyhedron/Polyhedron_demo_poisson_plugin_impl.cpp @@ -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 diff --git a/Polyhedron/demo/Polyhedron/Scene_points_with_normal_item.cpp b/Polyhedron/demo/Polyhedron/Scene_points_with_normal_item.cpp index 492e5e320d2..f5907ebb889 100644 --- a/Polyhedron/demo/Polyhedron/Scene_points_with_normal_item.cpp +++ b/Polyhedron/demo/Polyhedron/Scene_points_with_normal_item.cpp @@ -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 diff --git a/Polyhedron/demo/Polyhedron/include/UI_point_3.h b/Polyhedron/demo/Polyhedron/include/UI_point_3.h index 2c2407e6b23..78f27da1122 100644 --- a/Polyhedron/demo/Polyhedron/include/UI_point_3.h +++ b/Polyhedron/demo/Polyhedron/include/UI_point_3.h @@ -127,6 +127,14 @@ private: FT m_radius; }; +#include + +namespace CGAL{ +template +struct Kernel_traits< ::UI_point_3 >{ + typedef Gt Kernel; +}; +} //end of CGAL namespace #endif //UI_POINT_3_H diff --git a/Spatial_searching/examples/Spatial_searching/searching_with_point_with_info.cpp b/Spatial_searching/examples/Spatial_searching/searching_with_point_with_info.cpp index 0438c70c459..40925cd6beb 100644 --- a/Spatial_searching/examples/Spatial_searching/searching_with_point_with_info.cpp +++ b/Spatial_searching/examples/Spatial_searching/searching_with_point_with_info.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include @@ -11,23 +12,11 @@ typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel; typedef Kernel::Point_3 Point_3; typedef boost::tuple 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 Random_points_iterator; typedef CGAL::Search_traits_3 Traits_base; -typedef CGAL::Search_traits_adapter Traits; +typedef CGAL::Search_traits_adapter, + Traits_base> Traits; typedef CGAL::Orthogonal_k_neighbor_search K_neighbor_search; diff --git a/Spatial_sorting/examples/Spatial_sorting/sp_sort_using_property_map_2.cpp b/Spatial_sorting/examples/Spatial_sorting/sp_sort_using_property_map_2.cpp index cffcfd2f980..ebc176f3df5 100644 --- a/Spatial_sorting/examples/Spatial_sorting/sp_sort_using_property_map_2.cpp +++ b/Spatial_sorting/examples/Spatial_sorting/sp_sort_using_property_map_2.cpp @@ -1,6 +1,7 @@ #include #include #include +#include #include typedef CGAL::Simple_cartesian Kernel; @@ -8,21 +9,9 @@ typedef Kernel::Point_2 Point_2; typedef std::pair 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 Search_traits_2; +typedef CGAL::Spatial_sort_traits_adapter_2 +> Search_traits_2; int main() { diff --git a/Surface_reconstruction_points_3/demo/Surface_reconstruction_points_3/PS_demo_normal_estimation_plugin.cpp b/Surface_reconstruction_points_3/demo/Surface_reconstruction_points_3/PS_demo_normal_estimation_plugin.cpp index 81ab2b1fe5a..178fa439a36 100644 --- a/Surface_reconstruction_points_3/demo/Surface_reconstruction_points_3/PS_demo_normal_estimation_plugin.cpp +++ b/Surface_reconstruction_points_3/demo/Surface_reconstruction_points_3/PS_demo_normal_estimation_plugin.cpp @@ -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()); diff --git a/Surface_reconstruction_points_3/demo/Surface_reconstruction_points_3/PS_demo_poisson_plugin_cgal_code.cpp b/Surface_reconstruction_points_3/demo/Surface_reconstruction_points_3/PS_demo_poisson_plugin_cgal_code.cpp index 751af7822cc..843cbbfdfa0 100644 --- a/Surface_reconstruction_points_3/demo/Surface_reconstruction_points_3/PS_demo_poisson_plugin_cgal_code.cpp +++ b/Surface_reconstruction_points_3/demo/Surface_reconstruction_points_3/PS_demo_poisson_plugin_cgal_code.cpp @@ -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 diff --git a/Surface_reconstruction_points_3/demo/Surface_reconstruction_points_3/Point_set_scene_item.cpp b/Surface_reconstruction_points_3/demo/Surface_reconstruction_points_3/Point_set_scene_item.cpp index 4bac0af50c1..ab9eb2405e1 100644 --- a/Surface_reconstruction_points_3/demo/Surface_reconstruction_points_3/Point_set_scene_item.cpp +++ b/Surface_reconstruction_points_3/demo/Surface_reconstruction_points_3/Point_set_scene_item.cpp @@ -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 diff --git a/Surface_reconstruction_points_3/examples/Surface_reconstruction_points_3/poisson_reconstruction.cpp b/Surface_reconstruction_points_3/examples/Surface_reconstruction_points_3/poisson_reconstruction.cpp index 1c09392c928..ef703c4ead6 100644 --- a/Surface_reconstruction_points_3/examples/Surface_reconstruction_points_3/poisson_reconstruction.cpp +++ b/Surface_reconstruction_points_3/examples/Surface_reconstruction_points_3/poisson_reconstruction.cpp @@ -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 diff --git a/Surface_reconstruction_points_3/examples/Surface_reconstruction_points_3/poisson_reconstruction_example.cpp b/Surface_reconstruction_points_3/examples/Surface_reconstruction_points_3/poisson_reconstruction_example.cpp index a892132a5f8..4746f3bdd60 100644 --- a/Surface_reconstruction_points_3/examples/Surface_reconstruction_points_3/poisson_reconstruction_example.cpp +++ b/Surface_reconstruction_points_3/examples/Surface_reconstruction_points_3/poisson_reconstruction_example.cpp @@ -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. diff --git a/Surface_reconstruction_points_3/include/CGAL/IO/output_surface_facets_to_triangle_soup.h b/Surface_reconstruction_points_3/include/CGAL/IO/output_surface_facets_to_triangle_soup.h index ff3574bf088..26b0b5efaa4 100644 --- a/Surface_reconstruction_points_3/include/CGAL/IO/output_surface_facets_to_triangle_soup.h +++ b/Surface_reconstruction_points_3/include/CGAL/IO/output_surface_facets_to_triangle_soup.h @@ -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. -template ::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. +template 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::type Triangle; + // typedef typename value_type_traits::type Triangle; + typedef OutputIteratorValueType Triangle; const Tr& tr = c2t3.triangulation(); @@ -70,6 +74,17 @@ output_surface_facets_to_triangle_soup( } } +template +void +output_surface_facets_to_triangle_soup( + const SurfaceMeshComplex_2InTriangulation_3& c2t3, ///< Input surface. + OutputIterator output_iterator) +{ + output_surface_facets_to_triangle_soup + ::type> + (c2t3, output_iterator); +} } //namespace CGAL diff --git a/Surface_reconstruction_points_3/include/CGAL/Poisson_reconstruction_function.h b/Surface_reconstruction_points_3/include/CGAL/Poisson_reconstruction_function.h index 27856761f21..0fd3fac8a47 100644 --- a/Surface_reconstruction_points_3/include/CGAL/Poisson_reconstruction_function.h +++ b/Surface_reconstruction_points_3/include/CGAL/Poisson_reconstruction_function.h @@ -30,6 +30,7 @@ #include #include #include +#include #include #include @@ -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 > ) , 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 > ) , 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 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 >::type* = 0 @@ -339,7 +340,14 @@ public: : m_tr(new Triangulation), m_Bary(new std::vector > ) , 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::value_type()), +#endif + normal_pmap, Poisson_visitor()); CGAL::Timer task_timer; task_timer.start(); } /// \endcond diff --git a/Surface_reconstruction_points_3/include/CGAL/Reconstruction_triangulation_3.h b/Surface_reconstruction_points_3/include/CGAL/Reconstruction_triangulation_3.h index 71660ac3279..18e0499b88f 100644 --- a/Surface_reconstruction_points_3/include/CGAL/Reconstruction_triangulation_3.h +++ b/Surface_reconstruction_points_3/include/CGAL/Reconstruction_triangulation_3.h @@ -37,6 +37,7 @@ #include #include +#include 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 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 `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::value_type()), +#endif normal_pmap, visitor); } diff --git a/Surface_reconstruction_points_3/test/Surface_reconstruction_points_3/poisson_reconstruction_test.cpp b/Surface_reconstruction_points_3/test/Surface_reconstruction_points_3/poisson_reconstruction_test.cpp index d685c3cce4b..e2a754bc622 100644 --- a/Surface_reconstruction_points_3/test/Surface_reconstruction_points_3/poisson_reconstruction_test.cpp +++ b/Surface_reconstruction_points_3/test/Surface_reconstruction_points_3/poisson_reconstruction_test.cpp @@ -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.