diff --git a/Point_set_shape_detection_3/examples/Point_set_shape_detection_3/shape_detection_3_basic.cpp b/Point_set_shape_detection_3/examples/Point_set_shape_detection_3/shape_detection_3_basic.cpp index a67cb7d03aa..0478d679251 100644 --- a/Point_set_shape_detection_3/examples/Point_set_shape_detection_3/shape_detection_3_basic.cpp +++ b/Point_set_shape_detection_3/examples/Point_set_shape_detection_3/shape_detection_3_basic.cpp @@ -19,7 +19,7 @@ typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel; typedef Kernel::FT FT; typedef Kernel::Point_3 Point; typedef CGAL::Point_with_normal_3 Point_with_normal; -typedef std::vector Point_list; +typedef std::vector Pwn_list; typedef CGAL::Identity_property_map Point_pmap; typedef CGAL::Normal_of_point_with_normal_pmap Normal_pmap; @@ -31,18 +31,20 @@ typedef CGAL::Shape_detection_3 Shape_detection; int main(int argc, char **argv) { - Point_list points; - // Loading a point set from a file. + // List of points with normals. + Pwn_list points; + + // Loads input point set from a file. // read_xyz_points_and_normals takes an OutputIterator for writing the points // and a property map for storing the normal vector associated to each point. - std::ifstream stream("cube.xyz"); + std::ifstream stream("cube.pwn"); if (!stream || !CGAL::read_xyz_points_and_normals(stream, std::back_inserter(points), Normal_pmap())) { - std::cerr << "Error: cannot read file cube.xyz" << std::endl; + std::cerr << "Error: cannot read file cube.pwn" << std::endl; return EXIT_FAILURE; } @@ -50,8 +52,7 @@ int main(int argc, char **argv) { Shape_detection sd(points.begin(), points.end(), Point_pmap(), Normal_pmap()); - // Shapes to be detected are registered - // by using the template Shape_factory + // Registers planar shapes via the template Shape_factory sd.add_shape_factory(new CGAL::Shape_factory >); diff --git a/Point_set_shape_detection_3/examples/Point_set_shape_detection_3/shape_detection_3_parameters.cpp b/Point_set_shape_detection_3/examples/Point_set_shape_detection_3/shape_detection_3_parameters.cpp index 2712f4a50ac..8fb6cb565fc 100644 --- a/Point_set_shape_detection_3/examples/Point_set_shape_detection_3/shape_detection_3_parameters.cpp +++ b/Point_set_shape_detection_3/examples/Point_set_shape_detection_3/shape_detection_3_parameters.cpp @@ -19,7 +19,7 @@ typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel; typedef Kernel::FT FT; typedef Kernel::Point_3 Point; typedef CGAL::Point_with_normal_3 Point_with_normal; -typedef std::vector Point_list; +typedef std::vector Pwn_list; typedef CGAL::Identity_property_map Point_pmap; typedef CGAL::Normal_of_point_with_normal_pmap Normal_pmap; @@ -31,18 +31,18 @@ typedef CGAL::Shape_detection_3 Shape_detection; int main(int argc, char **argv) { - Point_list points; + Pwn_list points; // Loads point set from a file. // read_xyz_points_and_normals takes an OutputIterator for writing the points // and a property map for storing the normal vector associated to each point. - std::ifstream stream("cube.xyz"); + std::ifstream stream("cube.pwn"); if (!stream || !CGAL::read_xyz_points_and_normals(stream, std::back_inserter(points), Normal_pmap())) { - std::cerr << "Error: cannot read file cube.xyz" << std::endl; + std::cerr << "Error: cannot read file cube.pwn" << std::endl; return EXIT_FAILURE; } @@ -90,7 +90,7 @@ int main(int argc, char **argv) { sd.detect(parameters); // Prints number of detected shapes and unassigned points. - std::cout << sd.number_of_shapes() << " detecte shapes, " + std::cout << sd.number_of_shapes() << " detected shapes, " << sd.number_of_unassigned_points() << " unassigned points." << std::endl; diff --git a/Point_set_shape_detection_3/examples/Point_set_shape_detection_3/shape_detection_3_point_access.cpp b/Point_set_shape_detection_3/examples/Point_set_shape_detection_3/shape_detection_3_point_access.cpp index d4b0ca46144..545fbdfe327 100644 --- a/Point_set_shape_detection_3/examples/Point_set_shape_detection_3/shape_detection_3_point_access.cpp +++ b/Point_set_shape_detection_3/examples/Point_set_shape_detection_3/shape_detection_3_point_access.cpp @@ -19,7 +19,7 @@ typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel; typedef Kernel::FT FT; typedef Kernel::Point_3 Point; typedef CGAL::Point_with_normal_3 Point_with_normal; -typedef std::vector Point_list; +typedef std::vector Pwn_list; typedef CGAL::Identity_property_map Point_pmap; typedef CGAL::Normal_of_point_with_normal_pmap Normal_pmap; @@ -31,18 +31,18 @@ typedef CGAL::Shape_detection_3 Shape_detection; int main(int argc, char **argv) { - Point_list points; + Pwn_list points; // Loading a point set from file. // read_xyz_points_and_normals takes an OutputIterator for storing the points // and a property map to store the normal vector with each point. - std::ifstream stream("cube.xyz"); + std::ifstream stream("cube.pwn"); if (!stream || !CGAL::read_xyz_points_and_normals(stream, std::back_inserter(points), Normal_pmap())) { - std::cerr << "Error: cannot read file cube.xyz" << std::endl; + std::cerr << "Error: cannot read file cube.pwn" << std::endl; return EXIT_FAILURE; } @@ -80,31 +80,30 @@ int main(int argc, char **argv) { // the parameters of the detected shape. std::cout << (*it)->info(); - // Sum distances of points to detected shapes. + // Sums distances of points to detected shapes. FT sum_distances = 0.f; - // Iterate through point indices assigned to each detected shape. + // Iterates through point indices assigned to each detected shape. std::vector::const_iterator - indexIt = (*it)->assigned_points().begin(); + index_it = (*it)->assigned_points().begin(); - while (indexIt != (*it)->assigned_points().end()) { + while (index_it != (*it)->assigned_points().end()) { - // Retrieve point - const Point &p = *(points.begin() + (*indexIt)); + // Retrieves point + const Point &p = *(points.begin() + (*index_it)); - // Add Euclidean distance between point and shape. + // Adds Euclidean distance between point and shape. sum_distances += sqrt((*it)->squared_distance(p)); - // Proceed with next point. - indexIt++; + // Proceeds with next point. + index_it++; } - // Compute average distance. + // Computes and prints average distance. const FT average_distance = sum_distances / shape->assigned_points().size(); - std::cout << " average distance: " << average_distance << std::endl; - // Proceed with next detected shape. + // Proceeds with next detected shape. it++; }