From 8855eb54c305ffeaec32cb6bc49bfb0a2e465cc2 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Mon, 26 Aug 2013 14:36:09 +0200 Subject: [PATCH 01/15] Performance Improvements - changed Cartesian to Simple_cartesian in the examples - changed list to vector in the code - removed unnecessary includes - introduced multipass_distance --- .../barycenter.cpp | 16 ++++----- .../bounding_box.cpp | 16 ++++----- .../Principal_component_analysis/centroid.cpp | 18 +++++----- .../linear_least_squares_fitting_points_2.cpp | 14 ++++---- ...near_least_squares_fitting_triangles_3.cpp | 18 +++++----- .../include/CGAL/centroid.h | 30 ++++++++++------ .../CGAL/linear_least_squares_fitting_2.h | 5 ++- .../CGAL/linear_least_squares_fitting_3.h | 6 ++-- .../linear_least_squares_fitting_circles_2.h | 1 - .../linear_least_squares_fitting_cuboids_3.h | 15 ++++---- .../linear_least_squares_fitting_points_2.h | 1 - .../linear_least_squares_fitting_points_3.h | 1 - ...inear_least_squares_fitting_rectangles_2.h | 10 +++--- .../linear_least_squares_fitting_segments_2.h | 5 +-- .../linear_least_squares_fitting_segments_3.h | 8 +++-- .../linear_least_squares_fitting_spheres_3.h | 1 - ...inear_least_squares_fitting_tetrahedra_3.h | 21 +++++++---- ...linear_least_squares_fitting_triangles_2.h | 6 ++-- ...linear_least_squares_fitting_triangles_3.h | 19 +++++----- .../include/CGAL/multipass_distance.h | 35 +++++++++++++++++++ 20 files changed, 150 insertions(+), 96 deletions(-) create mode 100755 STL_Extension/include/CGAL/multipass_distance.h diff --git a/Principal_component_analysis/examples/Principal_component_analysis/barycenter.cpp b/Principal_component_analysis/examples/Principal_component_analysis/barycenter.cpp index 66aba742b50..c9198c13230 100644 --- a/Principal_component_analysis/examples/Principal_component_analysis/barycenter.cpp +++ b/Principal_component_analysis/examples/Principal_component_analysis/barycenter.cpp @@ -1,21 +1,21 @@ // Example program for the barycenter() function for 2D and 3D points. -#include +#include #include -#include +#include #include #include -typedef double FT; -typedef CGAL::Cartesian K; -typedef K::Point_2 Point_2; -typedef K::Point_3 Point_3; +typedef double FT; +typedef CGAL::Simple_cartesian K; +typedef K::Point_2 Point_2; +typedef K::Point_3 Point_3; int main() { // barycenter of 2D weighted points - std::list > points_2; + std::vector > points_2; points_2.push_back(std::make_pair(Point_2(1.0, 0.0), 1.0)); points_2.push_back(std::make_pair(Point_2(2.0, 2.0), 2.0)); points_2.push_back(std::make_pair(Point_2(3.0, 5.0), -2.0)); @@ -24,7 +24,7 @@ int main() std::cout << c2 << std::endl; // barycenter of 3D weighted points - std::list > points_3; + std::vector > points_3; points_3.push_back(std::make_pair(Point_3(1.0, 0.0, 0.5), 1.0)); points_3.push_back(std::make_pair(Point_3(2.0, 2.0, 1.2), 2.0)); points_3.push_back(std::make_pair(Point_3(3.0, 5.0, 4.5), -5.0)); diff --git a/Principal_component_analysis/examples/Principal_component_analysis/bounding_box.cpp b/Principal_component_analysis/examples/Principal_component_analysis/bounding_box.cpp index b034f52e2cf..9d2d0b840ec 100644 --- a/Principal_component_analysis/examples/Principal_component_analysis/bounding_box.cpp +++ b/Principal_component_analysis/examples/Principal_component_analysis/bounding_box.cpp @@ -1,20 +1,20 @@ // Example program for the bounding_box() function for 2D points and 3D points. -#include +#include #include -#include +#include #include -typedef double FT; -typedef CGAL::Cartesian K; -typedef K::Point_2 Point_2; -typedef K::Point_3 Point_3; +typedef double FT; +typedef CGAL::Simple_cartesian K; +typedef K::Point_2 Point_2; +typedef K::Point_3 Point_3; int main() { // axis-aligned bounding box of 2D points - std::list points_2; + std::vector points_2; points_2.push_back(Point_2(1.0, 0.0)); points_2.push_back(Point_2(2.0, 2.0)); points_2.push_back(Point_2(3.0, 5.0)); @@ -23,7 +23,7 @@ int main() std::cout << c2 << std::endl; // axis-aligned bounding box of 3D points - std::list points_3; + std::vector points_3; points_3.push_back(Point_3(1.0, 0.0, 0.5)); points_3.push_back(Point_3(2.0, 2.0, 1.2)); points_3.push_back(Point_3(3.0, 5.0, 4.5)); diff --git a/Principal_component_analysis/examples/Principal_component_analysis/centroid.cpp b/Principal_component_analysis/examples/Principal_component_analysis/centroid.cpp index d39594f47ed..eeba74e6a50 100644 --- a/Principal_component_analysis/examples/Principal_component_analysis/centroid.cpp +++ b/Principal_component_analysis/examples/Principal_component_analysis/centroid.cpp @@ -1,21 +1,21 @@ // Example program for the centroid() function for 2D points, 3D points and 3D triangles. -#include +#include #include -#include +#include #include -typedef double FT; -typedef CGAL::Cartesian K; -typedef K::Point_2 Point_2; -typedef K::Point_3 Point_3; -typedef K::Triangle_3 Triangle_3; +typedef double FT; +typedef CGAL::Simple_cartesian K; +typedef K::Point_2 Point_2; +typedef K::Point_3 Point_3; +typedef K::Triangle_3 Triangle_3; int main() { // centroid of 2D points - std::list points_2; + std::vector points_2; points_2.push_back(Point_2(1.0, 0.0)); points_2.push_back(Point_2(2.0, 2.0)); points_2.push_back(Point_2(3.0, 5.0)); @@ -23,7 +23,7 @@ int main() std::cout << c2 << std::endl; // centroid of 3D points - std::list points_3; + std::vector points_3; points_3.push_back(Point_3(1.0, 0.0, 0.5)); points_3.push_back(Point_3(2.0, 2.0, 1.2)); points_3.push_back(Point_3(3.0, 5.0, 4.5)); diff --git a/Principal_component_analysis/examples/Principal_component_analysis/linear_least_squares_fitting_points_2.cpp b/Principal_component_analysis/examples/Principal_component_analysis/linear_least_squares_fitting_points_2.cpp index 01bee4976c3..c16a580b450 100644 --- a/Principal_component_analysis/examples/Principal_component_analysis/linear_least_squares_fitting_points_2.cpp +++ b/Principal_component_analysis/examples/Principal_component_analysis/linear_least_squares_fitting_points_2.cpp @@ -1,16 +1,16 @@ // Example program for linear least squares fitting of a 2D point set -#include +#include #include -#include +#include -typedef double FT; -typedef CGAL::Cartesian K; -typedef K::Line_2 Line; -typedef K::Point_2 Point; +typedef double FT; +typedef CGAL::Simple_cartesian K; +typedef K::Line_2 Line; +typedef K::Point_2 Point; int main() { - std::list points; + std::vector points; points.push_back(Point(1.0,2.0)); points.push_back(Point(3.0,4.0)); points.push_back(Point(5.0,6.0)); diff --git a/Principal_component_analysis/examples/Principal_component_analysis/linear_least_squares_fitting_triangles_3.cpp b/Principal_component_analysis/examples/Principal_component_analysis/linear_least_squares_fitting_triangles_3.cpp index 6641b423b05..f8d03464deb 100644 --- a/Principal_component_analysis/examples/Principal_component_analysis/linear_least_squares_fitting_triangles_3.cpp +++ b/Principal_component_analysis/examples/Principal_component_analysis/linear_least_squares_fitting_triangles_3.cpp @@ -1,19 +1,19 @@ // Example program for the linear_least_square_fitting function // on a set of 3D triangles -#include +#include #include -#include +#include -typedef double FT; -typedef CGAL::Cartesian K; -typedef K::Line_3 Line; -typedef K::Plane_3 Plane; -typedef K::Point_3 Point; -typedef K::Triangle_3 Triangle; +typedef double FT; +typedef CGAL::Simple_cartesian K; +typedef K::Line_3 Line; +typedef K::Plane_3 Plane; +typedef K::Point_3 Point; +typedef K::Triangle_3 Triangle; int main(void) { - std::list triangles; + std::vector triangles; Point a(1.0,2.0,3.0); Point b(4.0,0.0,6.0); Point c(7.0,8.0,9.0); diff --git a/Principal_component_analysis/include/CGAL/centroid.h b/Principal_component_analysis/include/CGAL/centroid.h index f23ad7b3046..c23f2c4dc75 100644 --- a/Principal_component_analysis/include/CGAL/centroid.h +++ b/Principal_component_analysis/include/CGAL/centroid.h @@ -27,12 +27,13 @@ #include #include #include +#include #include #include #include -#include +#include // Functions to compute the centroid of N points. // Works in 2D and 3D. @@ -92,7 +93,8 @@ centroid(InputIterator begin, CGAL_precondition(begin != end); - std::list points; + std::vector points; + points.reserve(2 * multipass_distance(begin, end)); for(InputIterator it = begin; it != end; it++) @@ -155,7 +157,8 @@ centroid(InputIterator begin, CGAL_precondition(begin != end); - std::list points; + std::vector points; + points.reserve(3* multipass_distance(begin,end)); for(InputIterator it = begin; it != end; it++) @@ -184,7 +187,8 @@ centroid(InputIterator begin, CGAL_precondition(begin != end); - std::list segments; + std::vector segments; + segments.reserve(3 * multipass_distance(begin,end)); for(InputIterator it = begin; it != end; it++) @@ -318,7 +322,8 @@ centroid(InputIterator begin, CGAL_precondition(begin != end); - std::list points; + std::vector points; + points.reserve(4 * multipass_distance(begin,end)); for(InputIterator it = begin; it != end; it++) @@ -348,7 +353,8 @@ centroid(InputIterator begin, CGAL_precondition(begin != end); - std::list segments; + std::vector segments; + segments.reserve(4 * multipass_distance(begin,end)); for(InputIterator it = begin; it != end; it++) @@ -477,7 +483,8 @@ centroid(InputIterator begin, CGAL_precondition(begin != end); - std::list points; + std::vector points; + points.reserve(3 * multipass_distance(begin,end)); for(InputIterator it = begin; it != end; it++) @@ -506,7 +513,8 @@ centroid(InputIterator begin, CGAL_precondition(begin != end); - std::list segments; + std::vector segments; + segments.reserve(3 * multipass_distance(begin,end)); for(InputIterator it = begin; it != end; it++) @@ -640,7 +648,8 @@ centroid(InputIterator begin, CGAL_precondition(begin != end); - std::list points; + std::vector points; + points.reserve(8 * multipass_distance(begin,end)); for(InputIterator it = begin; it != end; it++) @@ -674,7 +683,8 @@ centroid(InputIterator begin, CGAL_precondition(begin != end); - std::list segments; + std::vector segments; + segments.reserve(12 * multipass_distance(begin,end)); for(InputIterator it = begin; it != end; it++) diff --git a/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_2.h b/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_2.h index e1cd4102de9..3ef8b8ca794 100644 --- a/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_2.h +++ b/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_2.h @@ -21,9 +21,8 @@ #define CGAL_LINEAR_LEAST_SQUARES_FITTING_2_H #include -#include -#include -#include +//#include +//#include #include #include #include diff --git a/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_3.h b/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_3.h index d4173110b63..553fb285900 100644 --- a/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_3.h +++ b/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_3.h @@ -21,9 +21,8 @@ #define CGAL_LINEAR_LEAST_SQUARES_FITTING_3_H #include -#include -#include -#include +//#include +//#include #include #include @@ -35,7 +34,6 @@ #include #include -#include #include namespace CGAL { diff --git a/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_circles_2.h b/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_circles_2.h index aa57977d187..dd9bc675e70 100644 --- a/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_circles_2.h +++ b/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_circles_2.h @@ -21,7 +21,6 @@ #define CGAL_LINEAR_LEAST_SQUARES_FITTING_CIRCLES_2_H #include -#include #include #include #include diff --git a/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_cuboids_3.h b/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_cuboids_3.h index d122173a020..2b39fb0a12e 100644 --- a/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_cuboids_3.h +++ b/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_cuboids_3.h @@ -21,11 +21,10 @@ #define CGAL_LINEAR_LEAST_SQUARES_FITTING_CUBOIDS_3_H #include -#include #include #include #include - +#include #include #include @@ -115,7 +114,8 @@ linear_least_squares_fitting_3(InputIterator first, // precondition: at least one element in the container. CGAL_precondition(first != beyond); - std::list segments; + std::vector segments; + segments.reserve(12 * multipass_distance(first,beyond)); for(InputIterator it = first; it != beyond; it++) @@ -158,7 +158,8 @@ linear_least_squares_fitting_3(InputIterator first, // precondition: at least one element in the container. CGAL_precondition(first != beyond); - std::list points; + std::vector points; + points.reserve(8 * multipass_distance(first,beyond)); for(InputIterator it = first; it != beyond; it++) @@ -258,7 +259,8 @@ linear_least_squares_fitting_3(InputIterator first, // precondition: at least one element in the container. CGAL_precondition(first != beyond); - std::list segments; + std::vector segments; + segments.reserve(12 * multipass_distance(first,beyond)); for(InputIterator it = first; it != beyond; it++) @@ -301,7 +303,8 @@ linear_least_squares_fitting_3(InputIterator first, // precondition: at least one element in the container. CGAL_precondition(first != beyond); - std::list points; + std::vector points; + points.reserve(8 * multipass_distance(first,beyond)); for(InputIterator it = first; it != beyond; it++) diff --git a/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_points_2.h b/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_points_2.h index 96e1b81e7ef..7d1d6a9036e 100644 --- a/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_points_2.h +++ b/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_points_2.h @@ -21,7 +21,6 @@ #define CGAL_LINEAR_LEAST_SQUARES_FITTING_POINTS_2_H #include -#include #include #include diff --git a/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_points_3.h b/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_points_3.h index b4459bad20d..15355929e91 100644 --- a/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_points_3.h +++ b/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_points_3.h @@ -21,7 +21,6 @@ #define CGAL_LINEAR_LEAST_SQUARES_FITTING_POINTS_3_H #include -#include #include #include #include diff --git a/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_rectangles_2.h b/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_rectangles_2.h index 7086dcc0fd2..e999032cce5 100644 --- a/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_rectangles_2.h +++ b/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_rectangles_2.h @@ -21,12 +21,12 @@ #define CGAL_LINEAR_LEAST_SQUARES_FITTING_RECTANGLES_2_H #include -#include #include #include #include #include #include +#include #include #include @@ -168,8 +168,8 @@ linear_least_squares_fitting_2(InputIterator first, // precondition: at least one element in the container. CGAL_precondition(first != beyond); - std::list segments; - + std::vector segments; + segments.reserve(4 * multipass_distance(first,beyond)); for(InputIterator it = first; it != beyond; it++) @@ -204,8 +204,8 @@ linear_least_squares_fitting_2(InputIterator first, // precondition: at least one element in the container. CGAL_precondition(first != beyond); - std::list points; - + std::vector points; + points..reserve(4 * multipass_distance(first,beyond)); for(InputIterator it = first; it != beyond; it++) diff --git a/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_segments_2.h b/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_segments_2.h index e076e8b166b..5b2552410fb 100644 --- a/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_segments_2.h +++ b/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_segments_2.h @@ -21,12 +21,12 @@ #define CGAL_LINEAR_LEAST_SQUARES_FITTING_SEGMENTS_2_H #include -#include #include #include #include #include #include +#include #include #include @@ -156,7 +156,8 @@ linear_least_squares_fitting_2(InputIterator first, // precondition: at least one element in the container. CGAL_precondition(first != beyond); - std::list points; + std::vector points; + points.reserve(2 * multipass_distance(first,beyond)); for(InputIterator it = first; it != beyond; it++) diff --git a/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_segments_3.h b/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_segments_3.h index b444339b3f5..2245e76fff6 100644 --- a/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_segments_3.h +++ b/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_segments_3.h @@ -21,11 +21,11 @@ #define CGAL_LINEAR_LEAST_SQUARES_FITTING_SEGMENTS_3_H #include -#include #include #include #include #include +#include #include @@ -81,7 +81,8 @@ linear_least_squares_fitting_3(InputIterator first, // precondition: at least one element in the container. CGAL_precondition(first != beyond); - std::list points; + std::vector points; + points.reserve(2 * multipass_distance(first,beyond)); for(InputIterator it = first; it != beyond; it++) @@ -144,7 +145,8 @@ linear_least_squares_fitting_3(InputIterator first, // precondition: at least one element in the container. CGAL_precondition(first != beyond); - std::list points; + std::vector points; + points.reserve(2 * multipass_distance(first,beyond)); for(InputIterator it = first; it != beyond; it++) diff --git a/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_spheres_3.h b/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_spheres_3.h index 5de7d04a91c..1ae42e2957e 100644 --- a/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_spheres_3.h +++ b/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_spheres_3.h @@ -21,7 +21,6 @@ #define CGAL_LINEAR_LEAST_SQUARES_FITTING_SPHERES_3_H #include -#include #include #include #include diff --git a/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_tetrahedra_3.h b/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_tetrahedra_3.h index 2dded736a77..787cded68eb 100644 --- a/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_tetrahedra_3.h +++ b/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_tetrahedra_3.h @@ -21,7 +21,6 @@ #define CGAL_LINEAR_LEAST_SQUARES_FITTING_TETRAHEDRA_3_H #include -#include #include #include @@ -29,6 +28,7 @@ #include #include #include +#include #include @@ -83,7 +83,8 @@ linear_least_squares_fitting_3(InputIterator first, // precondition: at least one element in the container. CGAL_precondition(first != beyond); - std::list triangles; + std::vector triangles; + triangles.reserve(4 * multipass_distance(first,beyond)); for(InputIterator it = first; it != beyond; it++) @@ -118,7 +119,9 @@ linear_least_squares_fitting_3(InputIterator first, // precondition: at least one element in the container. CGAL_precondition(first != beyond); - std::list segments; + std::vector segments; + segments.reserve(6 * multipass_distance(first,beyond)); + for(InputIterator it = first; it != beyond; it++) @@ -155,7 +158,8 @@ linear_least_squares_fitting_3(InputIterator first, // precondition: at least one element in the container. CGAL_precondition(first != beyond); - std::list points; + std::vector points; + points.reserve(4 * multipass_distance(first,beyond)); for(InputIterator it = first; it != beyond; it++) @@ -220,7 +224,8 @@ linear_least_squares_fitting_3(InputIterator first, // precondition: at least one element in the container. CGAL_precondition(first != beyond); - std::list triangles; + std::vector triangles; + triangles.reserve(4 * multipass_distance(first,beyond)); for(InputIterator it = first; it != beyond; it++) @@ -255,7 +260,8 @@ linear_least_squares_fitting_3(InputIterator first, // precondition: at least one element in the container. CGAL_precondition(first != beyond); - std::list segments; + std::vector segments; + segments.reserve(6 * multipass_distance(first,beyond)); for(InputIterator it = first; it != beyond; it++) @@ -292,7 +298,8 @@ linear_least_squares_fitting_3(InputIterator first, // precondition: at least one element in the container. CGAL_precondition(first != beyond); - std::list points; + std::vector points; + points.reserve(4 * multipass_distance(first,beyond)); for(InputIterator it = first; it != beyond; it++) diff --git a/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_triangles_2.h b/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_triangles_2.h index 509a9d20136..9e6ba28b5f7 100644 --- a/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_triangles_2.h +++ b/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_triangles_2.h @@ -21,17 +21,16 @@ #define CGAL_LINEAR_LEAST_SQUARES_FITTING_TRIANGLES_2_H #include -#include #include #include #include #include #include +#include #include #include #include -#include namespace CGAL { @@ -203,7 +202,8 @@ linear_least_squares_fitting_2(InputIterator first, // precondition: at least one element in the container. CGAL_precondition(first != beyond); - std::list points; + std::vector points; + points.reserve(3 * multipass_distance(first,beyond)); for(InputIterator it = first; it != beyond; it++) diff --git a/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_triangles_3.h b/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_triangles_3.h index 835756c6f49..c40d2891a8c 100644 --- a/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_triangles_3.h +++ b/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_triangles_3.h @@ -21,11 +21,12 @@ #define CGAL_LINEAR_LEAST_SQUARES_FITTING_TRIANGLES_3_H #include -#include #include #include #include +#include +#include #include namespace CGAL { @@ -80,7 +81,8 @@ linear_least_squares_fitting_3(InputIterator first, // precondition: at least one element in the container. CGAL_precondition(first != beyond); - std::list segments; + std::vector segments; + segments.reserve(3* multipass_distance(first, beyond)); for(InputIterator it = first; it != beyond; it++) @@ -113,8 +115,8 @@ linear_least_squares_fitting_3(InputIterator first, // precondition: at least one element in the container. CGAL_precondition(first != beyond); - - std::list points; + std::vector points; + points.reserve(3* multipass_distance(first,beyond)); for(InputIterator it = first; it != beyond; it++) @@ -178,7 +180,8 @@ linear_least_squares_fitting_3(InputIterator first, // precondition: at least one element in the container. CGAL_precondition(first != beyond); - std::list segments; + std::vector segments; + segments.reserve(3* multipass_distance(first, beyond)); for(InputIterator it = first; it != beyond; it++) @@ -204,15 +207,15 @@ linear_least_squares_fitting_3(InputIterator first, typename K::Point_3& c, // centroid const typename K::Triangle_3*, // used for indirection const K& k, // kernel - const CGAL::Dimension_tag<0>& tag) + const CGAL::Dimension_tag<0>& tag) { typedef typename K::Triangle_3 Triangle; typedef typename K::Point_3 Point; // precondition: at least one element in the container. CGAL_precondition(first != beyond); - - std::list points; + std::vector points; + points.reserve(3* multipass_distance(first, beyond)); for(InputIterator it = first; it != beyond; it++) diff --git a/STL_Extension/include/CGAL/multipass_distance.h b/STL_Extension/include/CGAL/multipass_distance.h new file mode 100755 index 00000000000..e3ef04ba847 --- /dev/null +++ b/STL_Extension/include/CGAL/multipass_distance.h @@ -0,0 +1,35 @@ +#ifndef CGAL_MULTIPASS_DISTANCE_H +#define CGAL_MULTIPASS_DISTANCE_H + +#include + +namespace CGAL { + + + template + typename std::iterator_traits::difference_type + multipass_distance(const I& begin, const I& beyond, const Cat&) + { + return std::distance(begin, beyond); + } + + template + typename std::iterator_traits::difference_type + multipass_distance(const I& begin, const I& beyond, const std::input_iterator_tag&) + { + return 0; + } + + + template + typename std::iterator_traits::difference_type + multipass_distance(const I& begin, const I& beyond) + { + return multipass_distance(begin, beyond, typename std::iterator_traits::iterator_category()); + } + + +} + + +#endif // CGAL_MULTIPASS_DISTANCE_H From ca18c33778c6ded3d72c1902ef20802a428d0bf9 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Mon, 26 Aug 2013 15:52:09 +0200 Subject: [PATCH 02/15] Switching to Simple_cartesian gives better performance" --- Polyhedron/examples/Polyhedron/polyhedron_prog_subdiv.cpp | 4 ++-- .../Polyhedron/polyhedron_prog_subdiv_with_boundary.cpp | 5 +++-- Polyhedron/examples/Polyhedron/polyhedron_prog_traits.cpp | 4 ++-- Polyhedron/examples/Polyhedron/polyhedron_prog_vector.cpp | 4 ++-- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/Polyhedron/examples/Polyhedron/polyhedron_prog_subdiv.cpp b/Polyhedron/examples/Polyhedron/polyhedron_prog_subdiv.cpp index 7fb57529184..009841ff69a 100644 --- a/Polyhedron/examples/Polyhedron/polyhedron_prog_subdiv.cpp +++ b/Polyhedron/examples/Polyhedron/polyhedron_prog_subdiv.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include #include @@ -6,7 +6,7 @@ #include #include -typedef CGAL::Cartesian Kernel; +typedef CGAL::Simple_cartesian Kernel; typedef Kernel::Vector_3 Vector; typedef Kernel::Point_3 Point; typedef CGAL::Polyhedron_3 Polyhedron; diff --git a/Polyhedron/examples/Polyhedron/polyhedron_prog_subdiv_with_boundary.cpp b/Polyhedron/examples/Polyhedron/polyhedron_prog_subdiv_with_boundary.cpp index 96eb892efaa..90ead40b2ff 100644 --- a/Polyhedron/examples/Polyhedron/polyhedron_prog_subdiv_with_boundary.cpp +++ b/Polyhedron/examples/Polyhedron/polyhedron_prog_subdiv_with_boundary.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include #include @@ -8,7 +8,7 @@ #include #include -typedef CGAL::Cartesian Kernel; +typedef CGAL::Simple_cartesian Kernel; typedef Kernel::Vector_3 Vector; typedef Kernel::Point_3 Point; typedef CGAL::Polyhedron_3 Polyhedron; @@ -188,6 +188,7 @@ int main( int argc, char* argv[]) { } Polyhedron P; cin >> P; + for ( int i = 0; i != n; ++i) { cerr << "Subdivision " << i+1 << " ..." << endl; subdiv( P); diff --git a/Polyhedron/examples/Polyhedron/polyhedron_prog_traits.cpp b/Polyhedron/examples/Polyhedron/polyhedron_prog_traits.cpp index c77d71484de..5fd41789fe7 100644 --- a/Polyhedron/examples/Polyhedron/polyhedron_prog_traits.cpp +++ b/Polyhedron/examples/Polyhedron/polyhedron_prog_traits.cpp @@ -1,8 +1,8 @@ -#include +#include #include #include -typedef CGAL::Cartesian Kernel; +typedef CGAL::Simple_cartesian Kernel; typedef CGAL::Polyhedron_traits_3 Traits; typedef CGAL::Polyhedron_3 Polyhedron; typedef Polyhedron::Halfedge_handle Halfedge_handle; diff --git a/Polyhedron/examples/Polyhedron/polyhedron_prog_vector.cpp b/Polyhedron/examples/Polyhedron/polyhedron_prog_vector.cpp index b90e7456373..d9f2894b0d2 100644 --- a/Polyhedron/examples/Polyhedron/polyhedron_prog_vector.cpp +++ b/Polyhedron/examples/Polyhedron/polyhedron_prog_vector.cpp @@ -1,9 +1,9 @@ -#include +#include #include #include #include -typedef CGAL::Cartesian Kernel; +typedef CGAL::Simple_cartesian Kernel; typedef Kernel::Point_3 Point_3; typedef CGAL::Polyhedron_3< Kernel, CGAL::Polyhedron_items_3, From 46ee658eb7963f21820585dc613def3126dd27ff Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Mon, 26 Aug 2013 16:36:02 +0200 Subject: [PATCH 03/15] Cartesian -> Simple_cartesian --- BGL/examples/BGL_polyhedron_3/distance.cpp | 4 ++-- BGL/examples/BGL_polyhedron_3/kruskal.cpp | 4 ++-- BGL/examples/BGL_polyhedron_3/kruskal_with_stored_id.cpp | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/BGL/examples/BGL_polyhedron_3/distance.cpp b/BGL/examples/BGL_polyhedron_3/distance.cpp index 6c38bfacf70..1885bde3c84 100644 --- a/BGL/examples/BGL_polyhedron_3/distance.cpp +++ b/BGL/examples/BGL_polyhedron_3/distance.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include #include @@ -9,7 +9,7 @@ #include -typedef CGAL::Cartesian Kernel; +typedef CGAL::Simple_cartesian Kernel; typedef Kernel::Point_3 Point; typedef CGAL::Polyhedron_3 Polyhedron; diff --git a/BGL/examples/BGL_polyhedron_3/kruskal.cpp b/BGL/examples/BGL_polyhedron_3/kruskal.cpp index 4dbc8d5f5c8..c8df3ab4ca8 100644 --- a/BGL/examples/BGL_polyhedron_3/kruskal.cpp +++ b/BGL/examples/BGL_polyhedron_3/kruskal.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include #include @@ -10,7 +10,7 @@ #include -typedef CGAL::Cartesian Kernel; +typedef CGAL::Simple_cartesian Kernel; typedef Kernel::Vector_3 Vector; typedef Kernel::Point_3 Point; typedef CGAL::Polyhedron_3 Polyhedron; diff --git a/BGL/examples/BGL_polyhedron_3/kruskal_with_stored_id.cpp b/BGL/examples/BGL_polyhedron_3/kruskal_with_stored_id.cpp index 00b82a409e9..c25f10af425 100644 --- a/BGL/examples/BGL_polyhedron_3/kruskal_with_stored_id.cpp +++ b/BGL/examples/BGL_polyhedron_3/kruskal_with_stored_id.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include #include @@ -10,7 +10,7 @@ #include -typedef CGAL::Cartesian Kernel; +typedef CGAL::Simple_cartesian Kernel; typedef Kernel::Point_3 Point; typedef CGAL::Polyhedron_3 Polyhedron; From 4250b800b95a1a695b16001d85e993f3071c1b29 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Mon, 26 Aug 2013 17:06:42 +0200 Subject: [PATCH 04/15] Cartesian -> Simple_cartesian --- .../Authalic_parameterization.cpp | 4 ++-- .../Complete_parameterization_example.cpp | 6 ++---- .../Eigen_parameterization.cpp | 8 ++++---- .../Mesh_cutting_parameterization.cpp | 4 ++-- .../Simple_parameterization.cpp | 4 ++-- .../Square_border_parameterization.cpp | 4 ++-- .../Taucs_parameterization.cpp | 6 ++---- .../Surface_mesh_parameterization/include/Mesh_cutter.h | 2 -- .../Surface_mesh_parameterization/include/Polyhedron_ex.h | 4 ++-- .../polyhedron_ex_parameterization.cpp | 1 - 10 files changed, 18 insertions(+), 25 deletions(-) diff --git a/Surface_mesh_parameterization/examples/Surface_mesh_parameterization/Authalic_parameterization.cpp b/Surface_mesh_parameterization/examples/Surface_mesh_parameterization/Authalic_parameterization.cpp index e3caf0baf95..6665e621f15 100644 --- a/Surface_mesh_parameterization/examples/Surface_mesh_parameterization/Authalic_parameterization.cpp +++ b/Surface_mesh_parameterization/examples/Surface_mesh_parameterization/Authalic_parameterization.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include #include @@ -14,7 +14,7 @@ // Private types // ---------------------------------------------------------------------------- -typedef CGAL::Cartesian Kernel; +typedef CGAL::Simple_cartesian Kernel; typedef CGAL::Polyhedron_3 Polyhedron; diff --git a/Surface_mesh_parameterization/examples/Surface_mesh_parameterization/Complete_parameterization_example.cpp b/Surface_mesh_parameterization/examples/Surface_mesh_parameterization/Complete_parameterization_example.cpp index 7f6f126014c..e0d23c9b9aa 100644 --- a/Surface_mesh_parameterization/examples/Surface_mesh_parameterization/Complete_parameterization_example.cpp +++ b/Surface_mesh_parameterization/examples/Surface_mesh_parameterization/Complete_parameterization_example.cpp @@ -1,6 +1,4 @@ -#include // include basic.h before testing #defines - -#include +#include #include #include #include @@ -20,7 +18,7 @@ // Private types // ---------------------------------------------------------------------------- -typedef CGAL::Cartesian Kernel; +typedef CGAL::Simple_cartesian Kernel; typedef CGAL::Polyhedron_3 Polyhedron; // Polyhedron adaptor diff --git a/Surface_mesh_parameterization/examples/Surface_mesh_parameterization/Eigen_parameterization.cpp b/Surface_mesh_parameterization/examples/Surface_mesh_parameterization/Eigen_parameterization.cpp index 4116388e924..7c97b3f8823 100644 --- a/Surface_mesh_parameterization/examples/Surface_mesh_parameterization/Eigen_parameterization.cpp +++ b/Surface_mesh_parameterization/examples/Surface_mesh_parameterization/Eigen_parameterization.cpp @@ -1,6 +1,4 @@ -#include // include basic.h before testing #defines - -#include +#include #include #include #include @@ -17,7 +15,7 @@ // Private types // ---------------------------------------------------------------------------- -typedef CGAL::Cartesian Kernel; +typedef CGAL::Simple_cartesian Kernel; typedef CGAL::Polyhedron_3 Polyhedron; @@ -67,6 +65,7 @@ int main(int argc, char * argv[]) typedef CGAL::Parameterization_polyhedron_adaptor_3 Parameterization_polyhedron_adaptor; + Parameterization_polyhedron_adaptor mesh_adaptor(mesh); //*************************************** @@ -88,6 +87,7 @@ int main(int argc, char * argv[]) Parameterizer; Parameterizer::Error_code err = CGAL::parameterize(mesh_adaptor, Parameterizer()); + switch(err) { case Parameterizer::OK: // Success break; diff --git a/Surface_mesh_parameterization/examples/Surface_mesh_parameterization/Mesh_cutting_parameterization.cpp b/Surface_mesh_parameterization/examples/Surface_mesh_parameterization/Mesh_cutting_parameterization.cpp index 5985dbea6c8..413ecb4eaf0 100644 --- a/Surface_mesh_parameterization/examples/Surface_mesh_parameterization/Mesh_cutting_parameterization.cpp +++ b/Surface_mesh_parameterization/examples/Surface_mesh_parameterization/Mesh_cutting_parameterization.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include #include @@ -13,7 +13,7 @@ // Private types // ---------------------------------------------------------------------------- -typedef CGAL::Cartesian Kernel; +typedef CGAL::Simple_cartesian Kernel; typedef CGAL::Polyhedron_3 Polyhedron; // Polyhedron adaptor diff --git a/Surface_mesh_parameterization/examples/Surface_mesh_parameterization/Simple_parameterization.cpp b/Surface_mesh_parameterization/examples/Surface_mesh_parameterization/Simple_parameterization.cpp index d241d807bff..490a3761e26 100644 --- a/Surface_mesh_parameterization/examples/Surface_mesh_parameterization/Simple_parameterization.cpp +++ b/Surface_mesh_parameterization/examples/Surface_mesh_parameterization/Simple_parameterization.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include #include @@ -12,7 +12,7 @@ // Private types // ---------------------------------------------------------------------------- -typedef CGAL::Cartesian Kernel; +typedef CGAL::Simple_cartesian Kernel; typedef CGAL::Polyhedron_3 Polyhedron; diff --git a/Surface_mesh_parameterization/examples/Surface_mesh_parameterization/Square_border_parameterization.cpp b/Surface_mesh_parameterization/examples/Surface_mesh_parameterization/Square_border_parameterization.cpp index 751a5c68784..e6c5335d124 100644 --- a/Surface_mesh_parameterization/examples/Surface_mesh_parameterization/Square_border_parameterization.cpp +++ b/Surface_mesh_parameterization/examples/Surface_mesh_parameterization/Square_border_parameterization.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include #include @@ -13,7 +13,7 @@ // Private types // ---------------------------------------------------------------------------- -typedef CGAL::Cartesian Kernel; +typedef CGAL::Simple_cartesian Kernel; typedef CGAL::Polyhedron_3 Polyhedron; diff --git a/Surface_mesh_parameterization/examples/Surface_mesh_parameterization/Taucs_parameterization.cpp b/Surface_mesh_parameterization/examples/Surface_mesh_parameterization/Taucs_parameterization.cpp index c583d59c55a..670c7e92d03 100644 --- a/Surface_mesh_parameterization/examples/Surface_mesh_parameterization/Taucs_parameterization.cpp +++ b/Surface_mesh_parameterization/examples/Surface_mesh_parameterization/Taucs_parameterization.cpp @@ -1,6 +1,4 @@ -#include // include basic.h before testing #defines - -#include +#include #include #include #include @@ -17,7 +15,7 @@ // Private types // ---------------------------------------------------------------------------- -typedef CGAL::Cartesian Kernel; +typedef CGAL::Simple_cartesian Kernel; typedef CGAL::Polyhedron_3 Polyhedron; diff --git a/Surface_mesh_parameterization/examples/Surface_mesh_parameterization/include/Mesh_cutter.h b/Surface_mesh_parameterization/examples/Surface_mesh_parameterization/include/Mesh_cutter.h index 0158ee33cba..5d96126157d 100644 --- a/Surface_mesh_parameterization/examples/Surface_mesh_parameterization/include/Mesh_cutter.h +++ b/Surface_mesh_parameterization/examples/Surface_mesh_parameterization/include/Mesh_cutter.h @@ -16,8 +16,6 @@ #ifndef MESH_CUTTER_H #define MESH_CUTTER_H -#include - #include "Polyhedron_ex.h" #include diff --git a/Surface_mesh_parameterization/examples/Surface_mesh_parameterization/include/Polyhedron_ex.h b/Surface_mesh_parameterization/examples/Surface_mesh_parameterization/include/Polyhedron_ex.h index c2f8213c96b..402db914954 100644 --- a/Surface_mesh_parameterization/examples/Surface_mesh_parameterization/include/Polyhedron_ex.h +++ b/Surface_mesh_parameterization/examples/Surface_mesh_parameterization/include/Polyhedron_ex.h @@ -1,7 +1,7 @@ #ifndef POLYHEDRON_EX_H_INCLUDED #define POLYHEDRON_EX_H_INCLUDED -#include +#include #include #include @@ -13,7 +13,7 @@ // CGAL kernel -typedef CGAL::Cartesian My_kernel; +typedef CGAL::Simple_cartesian My_kernel; // compute facet center diff --git a/Surface_mesh_parameterization/examples/Surface_mesh_parameterization/polyhedron_ex_parameterization.cpp b/Surface_mesh_parameterization/examples/Surface_mesh_parameterization/polyhedron_ex_parameterization.cpp index cd601d226d9..254c8614169 100644 --- a/Surface_mesh_parameterization/examples/Surface_mesh_parameterization/polyhedron_ex_parameterization.cpp +++ b/Surface_mesh_parameterization/examples/Surface_mesh_parameterization/polyhedron_ex_parameterization.cpp @@ -30,7 +30,6 @@ // polyhedron_ex_parameterization -t lscm -b 2pts mesh.off mesh.obj -#include #include #include #include From 60ebed5255bfb00ebf35ac9f117d244fc15f774d Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Tue, 27 Aug 2013 09:28:10 +0200 Subject: [PATCH 05/15] Passing to Simple_cartesian makes it 30% faster Seeding random makes it reproducible --- .../Spatial_searching/searching_with_circular_query.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Spatial_searching/examples/Spatial_searching/searching_with_circular_query.cpp b/Spatial_searching/examples/Spatial_searching/searching_with_circular_query.cpp index abc2b5cc35a..221181cd185 100644 --- a/Spatial_searching/examples/Spatial_searching/searching_with_circular_query.cpp +++ b/Spatial_searching/examples/Spatial_searching/searching_with_circular_query.cpp @@ -1,24 +1,25 @@ -#include +#include #include #include #include #include #include -typedef CGAL::Cartesian K; +typedef CGAL::Simple_cartesian K; typedef K::Point_2 Point; typedef CGAL::Random_points_in_square_2 Random_points_iterator; typedef CGAL::Counting_iterator N_Random_points_iterator; typedef CGAL::Search_traits_2 Traits; typedef CGAL::Fuzzy_sphere Fuzzy_circle; typedef CGAL::Kd_tree Tree; - +typedef CGAL::Random Random; int main() { const int N=1000; // generator for random data points in the square ( (-1,-1), (1,1) ) - Random_points_iterator rpit( 1.0); + Random rnd(0); + Random_points_iterator rpit(1.0, rnd); // Insert also the N points in the tree Tree tree(N_Random_points_iterator(rpit,0), From d2f0eff3cb08a99770f39eb6882a776fbbdfe328 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Tue, 27 Aug 2013 09:56:39 +0200 Subject: [PATCH 06/15] Switch to Simple_cartesian. Remove a superfluous .cpp Reorder #includes --- Jet_fitting_3/examples/Jet_fitting_3/Mesh_estimation.cpp | 9 +++++---- Jet_fitting_3/examples/Jet_fitting_3/PolyhedralSurf.cpp | 9 --------- Jet_fitting_3/examples/Jet_fitting_3/PolyhedralSurf.h | 4 ++-- .../examples/Jet_fitting_3/Single_estimation.cpp | 7 +++---- 4 files changed, 10 insertions(+), 19 deletions(-) delete mode 100644 Jet_fitting_3/examples/Jet_fitting_3/PolyhedralSurf.cpp diff --git a/Jet_fitting_3/examples/Jet_fitting_3/Mesh_estimation.cpp b/Jet_fitting_3/examples/Jet_fitting_3/Mesh_estimation.cpp index 27f3325a631..29f0db53dbd 100644 --- a/Jet_fitting_3/examples/Jet_fitting_3/Mesh_estimation.cpp +++ b/Jet_fitting_3/examples/Jet_fitting_3/Mesh_estimation.cpp @@ -1,11 +1,10 @@ -#include +#include #include +#include #include #include -#include - #ifdef CGAL_USE_BOOST_PROGRAM_OPTIONS #include namespace po = boost::program_options; @@ -19,7 +18,7 @@ using namespace std; //Kernel of the PolyhedralSurf typedef double DFT; -typedef CGAL::Cartesian Data_Kernel; +typedef CGAL::Simple_cartesian Data_Kernel; typedef Data_Kernel::Point_3 DPoint; typedef Data_Kernel::Vector_3 DVector; @@ -305,5 +304,7 @@ int main() out_verbose->close(); delete out_verbose; } + + std::cerr << "done" << std::endl; return 0; } diff --git a/Jet_fitting_3/examples/Jet_fitting_3/PolyhedralSurf.cpp b/Jet_fitting_3/examples/Jet_fitting_3/PolyhedralSurf.cpp deleted file mode 100644 index 23d08fa6a16..00000000000 --- a/Jet_fitting_3/examples/Jet_fitting_3/PolyhedralSurf.cpp +++ /dev/null @@ -1,9 +0,0 @@ -#include "PolyhedralSurf.h" - - - -// Vector_3 PolyhedralSurf::getHalfedge_vector(Halfedge * h) -// { -// Vector_3 v = h->opposite()->vertex()->point() - h->vertex()->point(); -// return v; -// } diff --git a/Jet_fitting_3/examples/Jet_fitting_3/PolyhedralSurf.h b/Jet_fitting_3/examples/Jet_fitting_3/PolyhedralSurf.h index 910cf7ec9dd..d3f3ffcb650 100644 --- a/Jet_fitting_3/examples/Jet_fitting_3/PolyhedralSurf.h +++ b/Jet_fitting_3/examples/Jet_fitting_3/PolyhedralSurf.h @@ -1,7 +1,7 @@ #ifndef CGAL_POLYHEDRALSURF_H_ #define CGAL_POLYHEDRALSURF_H_ -#include +#include #include #include @@ -180,7 +180,7 @@ struct Wrappers_VFH:public CGAL::Polyhedron_items_3 { typedef double DFT; -typedef CGAL::Cartesian Data_Kernel; +typedef CGAL::Simple_cartesian Data_Kernel; typedef CGAL::Polyhedron_3 < Data_Kernel, Wrappers_VFH > Polyhedron; typedef Data_Kernel::Vector_3 Vector_3; diff --git a/Jet_fitting_3/examples/Jet_fitting_3/Single_estimation.cpp b/Jet_fitting_3/examples/Jet_fitting_3/Single_estimation.cpp index 7a435006f82..fd02d41dbb5 100644 --- a/Jet_fitting_3/examples/Jet_fitting_3/Single_estimation.cpp +++ b/Jet_fitting_3/examples/Jet_fitting_3/Single_estimation.cpp @@ -1,12 +1,11 @@ -#include - +#include +#include #include #include -#include typedef double DFT; -typedef CGAL::Cartesian Data_Kernel; +typedef CGAL::Simple_cartesian Data_Kernel; typedef Data_Kernel::Point_3 DPoint; typedef CGAL::Monge_via_jet_fitting My_Monge_via_jet_fitting; typedef My_Monge_via_jet_fitting::Monge_form My_Monge_form; From 8ad719e2698621f984b4b3404594c703bf6a5ea4 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Tue, 27 Aug 2013 10:20:13 +0200 Subject: [PATCH 07/15] Passed to Simple_cartesian Cleanup of inclusion order, and what files gets included --- Ridges_3/examples/Ridges_3/Compute_Ridges_Umbilics.cpp | 9 +++++---- Ridges_3/examples/Ridges_3/PolyhedralSurf.h | 4 ++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Ridges_3/examples/Ridges_3/Compute_Ridges_Umbilics.cpp b/Ridges_3/examples/Ridges_3/Compute_Ridges_Umbilics.cpp index d04367e216e..bc60a62b675 100644 --- a/Ridges_3/examples/Ridges_3/Compute_Ridges_Umbilics.cpp +++ b/Ridges_3/examples/Ridges_3/Compute_Ridges_Umbilics.cpp @@ -1,4 +1,8 @@ -#include + +//this is an enriched Polyhedron with facet normals +#include "PolyhedralSurf.h" +#include "PolyhedralSurf_rings.h" + #include #include #include @@ -12,9 +16,6 @@ namespace po = boost::program_options; using namespace std; -//this is an enriched Polyhedron with facets' normal -#include "PolyhedralSurf.h" -#include "PolyhedralSurf_rings.h" typedef PolyhedralSurf::Traits Kernel; typedef Kernel::FT FT; diff --git a/Ridges_3/examples/Ridges_3/PolyhedralSurf.h b/Ridges_3/examples/Ridges_3/PolyhedralSurf.h index 0bde81af0d8..9b2ecb03541 100644 --- a/Ridges_3/examples/Ridges_3/PolyhedralSurf.h +++ b/Ridges_3/examples/Ridges_3/PolyhedralSurf.h @@ -1,7 +1,7 @@ #ifndef CGAL_POLYHEDRALSURF_H_ #define CGAL_POLYHEDRALSURF_H_ -#include +#include #include #include @@ -59,7 +59,7 @@ struct Wrappers_VFH:public CGAL::Polyhedron_items_3 { //PolyhedralSurf with facet normal operations //------------------------------------------------ typedef double FT; -typedef CGAL::Cartesian Kernel; +typedef CGAL::Simple_cartesian Kernel; typedef CGAL::Polyhedron_3 < Kernel, Wrappers_VFH > Polyhedron; typedef Kernel::Vector_3 Vector_3; From b599bd387263077430f8e29b6b4c54b531207a9b Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Tue, 27 Aug 2013 10:52:05 +0200 Subject: [PATCH 08/15] Switching to Simple_cartesian leads to a performance gain of 50% for 100K points --- .../examples/Inscribed_areas/largest_empty_rectangle.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Inscribed_areas/examples/Inscribed_areas/largest_empty_rectangle.cpp b/Inscribed_areas/examples/Inscribed_areas/largest_empty_rectangle.cpp index 2a37da9c0e0..5128e958d84 100644 --- a/Inscribed_areas/examples/Inscribed_areas/largest_empty_rectangle.cpp +++ b/Inscribed_areas/examples/Inscribed_areas/largest_empty_rectangle.cpp @@ -1,11 +1,11 @@ -#include +#include #include #include #include typedef double Number_Type; -typedef CGAL::Cartesian K; +typedef CGAL::Simple_cartesian K; typedef CGAL::Largest_empty_iso_rectangle_2 Largest_empty_iso_rect_2; typedef K::Iso_rectangle_2 Iso_rectangle_2; typedef K::Point_2 Point_2; From 0eeaccfb030dfdbe3c82732912bc3892b67822da Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Tue, 27 Aug 2013 11:00:08 +0200 Subject: [PATCH 09/15] Remove unused include --- .../examples/Straight_skeleton_2/Low_level_API.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/Straight_skeleton_2/examples/Straight_skeleton_2/Low_level_API.cpp b/Straight_skeleton_2/examples/Straight_skeleton_2/Low_level_API.cpp index 36259c3e729..1cba9c43bd8 100644 --- a/Straight_skeleton_2/examples/Straight_skeleton_2/Low_level_API.cpp +++ b/Straight_skeleton_2/examples/Straight_skeleton_2/Low_level_API.cpp @@ -6,7 +6,6 @@ #include -#include #include #include #include From a971b5e9baf44ae683c116e378c7be805f71d25e Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Wed, 28 Aug 2013 14:29:01 +0200 Subject: [PATCH 10/15] Switch to Simple_cartesian --- .../minimum_enclosing_parallelogram_2.cpp | 5 ++--- .../Min_quadrilateral_2/minimum_enclosing_rectangle_2.cpp | 4 ++-- .../Min_quadrilateral_2/minimum_enclosing_strip_2.cpp | 4 ++-- .../Rectangular_p_center_2/rectangular_p_center_2.cpp | 4 ++-- .../examples/Inscribed_areas/extremal_polygon_2_area.cpp | 4 ++-- .../Inscribed_areas/extremal_polygon_2_perimeter.cpp | 4 ++-- .../examples/RangeSegmentTrees/range_tree_map_2.cpp | 6 +++--- .../examples/RangeSegmentTrees/range_tree_set_2.cpp | 6 +++--- .../examples/RangeSegmentTrees/segment_tree_map_2.cpp | 6 +++--- .../examples/RangeSegmentTrees/segment_tree_set_2.cpp | 6 +++--- .../examples/RangeSegmentTrees/segment_tree_set_3.cpp | 6 +++--- 11 files changed, 27 insertions(+), 28 deletions(-) diff --git a/Bounding_volumes/examples/Min_quadrilateral_2/minimum_enclosing_parallelogram_2.cpp b/Bounding_volumes/examples/Min_quadrilateral_2/minimum_enclosing_parallelogram_2.cpp index e95b462b816..f4c6d3ef568 100644 --- a/Bounding_volumes/examples/Min_quadrilateral_2/minimum_enclosing_parallelogram_2.cpp +++ b/Bounding_volumes/examples/Min_quadrilateral_2/minimum_enclosing_parallelogram_2.cpp @@ -1,12 +1,11 @@ -#include +#include #include #include #include #include #include -struct Kernel : public CGAL::Cartesian {}; - +typedef CGAL::Simple_cartesian Kernel; typedef Kernel::Point_2 Point_2; typedef Kernel::Line_2 Line_2; typedef CGAL::Polygon_2 Polygon_2; diff --git a/Bounding_volumes/examples/Min_quadrilateral_2/minimum_enclosing_rectangle_2.cpp b/Bounding_volumes/examples/Min_quadrilateral_2/minimum_enclosing_rectangle_2.cpp index 3127cbb47ad..66db5cef267 100644 --- a/Bounding_volumes/examples/Min_quadrilateral_2/minimum_enclosing_rectangle_2.cpp +++ b/Bounding_volumes/examples/Min_quadrilateral_2/minimum_enclosing_rectangle_2.cpp @@ -1,11 +1,11 @@ -#include +#include #include #include #include #include #include -struct Kernel : public CGAL::Cartesian {}; +typedef CGAL::Simple_cartesian Kernel; typedef Kernel::Point_2 Point_2; typedef Kernel::Line_2 Line_2; diff --git a/Bounding_volumes/examples/Min_quadrilateral_2/minimum_enclosing_strip_2.cpp b/Bounding_volumes/examples/Min_quadrilateral_2/minimum_enclosing_strip_2.cpp index bf87a3377a8..0bbfe6f8242 100644 --- a/Bounding_volumes/examples/Min_quadrilateral_2/minimum_enclosing_strip_2.cpp +++ b/Bounding_volumes/examples/Min_quadrilateral_2/minimum_enclosing_strip_2.cpp @@ -1,11 +1,11 @@ -#include +#include #include #include #include #include #include -struct Kernel : public CGAL::Cartesian {}; +typedef CGAL::Simple_cartesian Kernel; typedef Kernel::Point_2 Point_2; typedef Kernel::Line_2 Line_2; diff --git a/Bounding_volumes/examples/Rectangular_p_center_2/rectangular_p_center_2.cpp b/Bounding_volumes/examples/Rectangular_p_center_2/rectangular_p_center_2.cpp index 7af6bb7b543..ed47f2667eb 100644 --- a/Bounding_volumes/examples/Rectangular_p_center_2/rectangular_p_center_2.cpp +++ b/Bounding_volumes/examples/Rectangular_p_center_2/rectangular_p_center_2.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include #include @@ -9,7 +9,7 @@ typedef double FT; -typedef CGAL::Cartesian Kernel; +typedef CGAL::Simple_cartesian Kernel; typedef Kernel::Point_2 Point; typedef std::vector Cont; diff --git a/Inscribed_areas/examples/Inscribed_areas/extremal_polygon_2_area.cpp b/Inscribed_areas/examples/Inscribed_areas/extremal_polygon_2_area.cpp index 0e75643eb9e..df77ff62998 100644 --- a/Inscribed_areas/examples/Inscribed_areas/extremal_polygon_2_area.cpp +++ b/Inscribed_areas/examples/Inscribed_areas/extremal_polygon_2_area.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include #include @@ -8,7 +8,7 @@ typedef double FT; -typedef CGAL::Cartesian Kernel; +typedef CGAL::Simple_cartesian Kernel; typedef Kernel::Point_2 Point; typedef std::vector Index_cont; diff --git a/Inscribed_areas/examples/Inscribed_areas/extremal_polygon_2_perimeter.cpp b/Inscribed_areas/examples/Inscribed_areas/extremal_polygon_2_perimeter.cpp index b22cbf5bb06..f4a6ffedccb 100644 --- a/Inscribed_areas/examples/Inscribed_areas/extremal_polygon_2_perimeter.cpp +++ b/Inscribed_areas/examples/Inscribed_areas/extremal_polygon_2_perimeter.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include #include @@ -8,7 +8,7 @@ typedef double FT; -typedef CGAL::Cartesian Kernel; +typedef CGAL::Simple_cartesian Kernel; typedef Kernel::Point_2 Point; typedef std::vector Index_cont; diff --git a/SearchStructures/examples/RangeSegmentTrees/range_tree_map_2.cpp b/SearchStructures/examples/RangeSegmentTrees/range_tree_map_2.cpp index e57cc5b79ea..6924c9d7dbb 100644 --- a/SearchStructures/examples/RangeSegmentTrees/range_tree_map_2.cpp +++ b/SearchStructures/examples/RangeSegmentTrees/range_tree_map_2.cpp @@ -3,7 +3,7 @@ // Ti is the type of each dimension of the tree. -#include +#include #include #include #include @@ -12,8 +12,8 @@ #include -typedef CGAL::Cartesian Representation; -typedef CGAL::Range_tree_map_traits_2 Traits; +typedef CGAL::Simple_cartesian K; +typedef CGAL::Range_tree_map_traits_2 Traits; typedef CGAL::Range_tree_2 Range_tree_2_type; int main() diff --git a/SearchStructures/examples/RangeSegmentTrees/range_tree_set_2.cpp b/SearchStructures/examples/RangeSegmentTrees/range_tree_set_2.cpp index 43f2017b711..46518a75283 100644 --- a/SearchStructures/examples/RangeSegmentTrees/range_tree_set_2.cpp +++ b/SearchStructures/examples/RangeSegmentTrees/range_tree_set_2.cpp @@ -3,7 +3,7 @@ // Ti is the type of each dimension of the tree. -#include +#include #include #include #include @@ -11,8 +11,8 @@ #include #include -typedef CGAL::Cartesian Representation; -typedef CGAL::Range_segment_tree_set_traits_2 Traits; +typedef CGAL::Simple_cartesian K; +typedef CGAL::Range_segment_tree_set_traits_2 Traits; typedef CGAL::Range_tree_2 Range_tree_2_type; int main() diff --git a/SearchStructures/examples/RangeSegmentTrees/segment_tree_map_2.cpp b/SearchStructures/examples/RangeSegmentTrees/segment_tree_map_2.cpp index 9bb5bcde3cc..809960c5bf7 100644 --- a/SearchStructures/examples/RangeSegmentTrees/segment_tree_map_2.cpp +++ b/SearchStructures/examples/RangeSegmentTrees/segment_tree_map_2.cpp @@ -7,14 +7,14 @@ #include #include #include -#include +#include #include #include -typedef CGAL::Cartesian Representation; -typedef CGAL::Segment_tree_map_traits_2 Traits; +typedef CGAL::Simple_cartesian K; +typedef CGAL::Segment_tree_map_traits_2 Traits; typedef CGAL::Segment_tree_2 Segment_tree_2_type; int main() diff --git a/SearchStructures/examples/RangeSegmentTrees/segment_tree_set_2.cpp b/SearchStructures/examples/RangeSegmentTrees/segment_tree_set_2.cpp index 3d4ef8ccd48..bb49f6da73e 100644 --- a/SearchStructures/examples/RangeSegmentTrees/segment_tree_set_2.cpp +++ b/SearchStructures/examples/RangeSegmentTrees/segment_tree_set_2.cpp @@ -11,12 +11,12 @@ #include #include #include -#include +#include #include #include -typedef CGAL::Cartesian Representation; -typedef CGAL::Range_segment_tree_set_traits_2 Traits; +typedef CGAL::Simple_cartesian K; +typedef CGAL::Range_segment_tree_set_traits_2 Traits; typedef CGAL::Segment_tree_2 Segment_tree_2_type; int main() diff --git a/SearchStructures/examples/RangeSegmentTrees/segment_tree_set_3.cpp b/SearchStructures/examples/RangeSegmentTrees/segment_tree_set_3.cpp index 4e674b1dbb2..ae7ec3e8973 100644 --- a/SearchStructures/examples/RangeSegmentTrees/segment_tree_set_3.cpp +++ b/SearchStructures/examples/RangeSegmentTrees/segment_tree_set_3.cpp @@ -6,12 +6,12 @@ #include #include #include -#include +#include #include #include -typedef CGAL::Cartesian Representation; -typedef CGAL::Range_segment_tree_set_traits_3 Traits; +typedef CGAL::Simple_cartesian K; +typedef CGAL::Range_segment_tree_set_traits_3 Traits; typedef CGAL::Segment_tree_3 Segment_tree_3_type; int main() From a07b6620e402b7855772d7a209c188bab29ada15 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Thu, 29 Aug 2013 07:11:28 +0200 Subject: [PATCH 11/15] class..method() -> class.method() --- .../include/CGAL/linear_least_squares_fitting_rectangles_2.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_rectangles_2.h b/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_rectangles_2.h index e999032cce5..5f95e12c240 100644 --- a/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_rectangles_2.h +++ b/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_rectangles_2.h @@ -205,7 +205,7 @@ linear_least_squares_fitting_2(InputIterator first, CGAL_precondition(first != beyond); std::vector points; - points..reserve(4 * multipass_distance(first,beyond)); + points.reserve(4 * multipass_distance(first,beyond)); for(InputIterator it = first; it != beyond; it++) From a601b7bc06eee86f9c8a310ab188fab6280bb4c2 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Thu, 29 Aug 2013 11:16:54 +0200 Subject: [PATCH 12/15] Remove a superfluous .cpp (also from the documentation) Follow-up to the following commit: | commit d2f0eff3cb08a99770f39eb6882a776fbbdfe328 | Author: Andreas Fabri | Date: Tue Aug 27 09:56:39 2013 +0200 | | Switch to Simple_cartesian. | Remove a superfluous .cpp | Reorder #includes --- Jet_fitting_3/doc/Jet_fitting_3/examples.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/Jet_fitting_3/doc/Jet_fitting_3/examples.txt b/Jet_fitting_3/doc/Jet_fitting_3/examples.txt index a3a9ef2f0bb..86021482c02 100644 --- a/Jet_fitting_3/doc/Jet_fitting_3/examples.txt +++ b/Jet_fitting_3/doc/Jet_fitting_3/examples.txt @@ -1,5 +1,4 @@ /*! \example Jet_fitting_3/Mesh_estimation.cpp -\example Jet_fitting_3/PolyhedralSurf.cpp \example Jet_fitting_3/Single_estimation.cpp */ From 97d04b8f37897e5c4c18dbf7a35c2a884f78f4d2 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Thu, 5 Sep 2013 10:56:15 +0200 Subject: [PATCH 13/15] switch to Simple_cartesian --- Jet_fitting_3/examples/Jet_fitting_3/Mesh_estimation.cpp | 2 +- Jet_fitting_3/include/CGAL/Monge_via_jet_fitting.h | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Jet_fitting_3/examples/Jet_fitting_3/Mesh_estimation.cpp b/Jet_fitting_3/examples/Jet_fitting_3/Mesh_estimation.cpp index 29f0db53dbd..fa9c191941c 100644 --- a/Jet_fitting_3/examples/Jet_fitting_3/Mesh_estimation.cpp +++ b/Jet_fitting_3/examples/Jet_fitting_3/Mesh_estimation.cpp @@ -65,7 +65,7 @@ typedef boost::associative_property_map Facet_PM_type; typedef T_PolyhedralSurf_facet_ops Poly_facet_ops; typedef double LFT; -typedef CGAL::Cartesian Local_Kernel; +typedef CGAL::Simple_cartesian Local_Kernel; typedef CGAL::Monge_via_jet_fitting My_Monge_via_jet_fitting; typedef My_Monge_via_jet_fitting::Monge_form My_Monge_form; diff --git a/Jet_fitting_3/include/CGAL/Monge_via_jet_fitting.h b/Jet_fitting_3/include/CGAL/Monge_via_jet_fitting.h index e60f694a191..a13aee6da7d 100644 --- a/Jet_fitting_3/include/CGAL/Monge_via_jet_fitting.h +++ b/Jet_fitting_3/include/CGAL/Monge_via_jet_fitting.h @@ -19,7 +19,7 @@ #ifndef CGAL_MONGE_VIA_JET_FITTING_H_ #define CGAL_MONGE_VIA_JET_FITTING_H_ -#include +#include #include #include #include @@ -46,10 +46,10 @@ unsigned int fact(unsigned int n){ ////////////////////// CLASS Monge_via_jet_fitting //////////////////////// #ifdef CGAL_EIGEN3_ENABLED -template < class DataKernel, class LocalKernel = Cartesian, class SvdTraits = Eigen_svd > +template < class DataKernel, class LocalKernel = Simple_cartesian, class SvdTraits = Eigen_svd > #else #ifdef CGAL_LAPACK_ENABLED -template < class DataKernel, class LocalKernel = Cartesian, class SvdTraits = Lapack_svd> +template < class DataKernel, class LocalKernel = Simple_cartesian, class SvdTraits = Lapack_svd> #else template < class DataKernel, class LocalKernel, class SvdTraits > #endif From 179ad6975bf0e038d06c4e7df6f4141be851b525 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Wed, 11 Sep 2013 16:18:51 +0200 Subject: [PATCH 14/15] undo of switching to vector and multipass_distance --- .../include/CGAL/multipass_distance.h | 35 ------------------- 1 file changed, 35 deletions(-) delete mode 100755 STL_Extension/include/CGAL/multipass_distance.h diff --git a/STL_Extension/include/CGAL/multipass_distance.h b/STL_Extension/include/CGAL/multipass_distance.h deleted file mode 100755 index e3ef04ba847..00000000000 --- a/STL_Extension/include/CGAL/multipass_distance.h +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef CGAL_MULTIPASS_DISTANCE_H -#define CGAL_MULTIPASS_DISTANCE_H - -#include - -namespace CGAL { - - - template - typename std::iterator_traits::difference_type - multipass_distance(const I& begin, const I& beyond, const Cat&) - { - return std::distance(begin, beyond); - } - - template - typename std::iterator_traits::difference_type - multipass_distance(const I& begin, const I& beyond, const std::input_iterator_tag&) - { - return 0; - } - - - template - typename std::iterator_traits::difference_type - multipass_distance(const I& begin, const I& beyond) - { - return multipass_distance(begin, beyond, typename std::iterator_traits::iterator_category()); - } - - -} - - -#endif // CGAL_MULTIPASS_DISTANCE_H From 557c593afffcdbbb53293f770c054f3f3c43cdfd Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Wed, 11 Sep 2013 16:20:04 +0200 Subject: [PATCH 15/15] undo of switching to vector and multipass_distance --- .../include/CGAL/centroid.h | 30 +++++++------------ .../linear_least_squares_fitting_cuboids_3.h | 14 ++++----- ...inear_least_squares_fitting_rectangles_2.h | 9 ++---- .../linear_least_squares_fitting_segments_2.h | 6 ++-- .../linear_least_squares_fitting_segments_3.h | 8 ++--- ...inear_least_squares_fitting_tetrahedra_3.h | 19 ++++-------- ...linear_least_squares_fitting_triangles_2.h | 4 +-- ...linear_least_squares_fitting_triangles_3.h | 15 ++++------ 8 files changed, 35 insertions(+), 70 deletions(-) diff --git a/Principal_component_analysis/include/CGAL/centroid.h b/Principal_component_analysis/include/CGAL/centroid.h index c23f2c4dc75..f23ad7b3046 100644 --- a/Principal_component_analysis/include/CGAL/centroid.h +++ b/Principal_component_analysis/include/CGAL/centroid.h @@ -27,13 +27,12 @@ #include #include #include -#include #include #include #include -#include +#include // Functions to compute the centroid of N points. // Works in 2D and 3D. @@ -93,8 +92,7 @@ centroid(InputIterator begin, CGAL_precondition(begin != end); - std::vector points; - points.reserve(2 * multipass_distance(begin, end)); + std::list points; for(InputIterator it = begin; it != end; it++) @@ -157,8 +155,7 @@ centroid(InputIterator begin, CGAL_precondition(begin != end); - std::vector points; - points.reserve(3* multipass_distance(begin,end)); + std::list points; for(InputIterator it = begin; it != end; it++) @@ -187,8 +184,7 @@ centroid(InputIterator begin, CGAL_precondition(begin != end); - std::vector segments; - segments.reserve(3 * multipass_distance(begin,end)); + std::list segments; for(InputIterator it = begin; it != end; it++) @@ -322,8 +318,7 @@ centroid(InputIterator begin, CGAL_precondition(begin != end); - std::vector points; - points.reserve(4 * multipass_distance(begin,end)); + std::list points; for(InputIterator it = begin; it != end; it++) @@ -353,8 +348,7 @@ centroid(InputIterator begin, CGAL_precondition(begin != end); - std::vector segments; - segments.reserve(4 * multipass_distance(begin,end)); + std::list segments; for(InputIterator it = begin; it != end; it++) @@ -483,8 +477,7 @@ centroid(InputIterator begin, CGAL_precondition(begin != end); - std::vector points; - points.reserve(3 * multipass_distance(begin,end)); + std::list points; for(InputIterator it = begin; it != end; it++) @@ -513,8 +506,7 @@ centroid(InputIterator begin, CGAL_precondition(begin != end); - std::vector segments; - segments.reserve(3 * multipass_distance(begin,end)); + std::list segments; for(InputIterator it = begin; it != end; it++) @@ -648,8 +640,7 @@ centroid(InputIterator begin, CGAL_precondition(begin != end); - std::vector points; - points.reserve(8 * multipass_distance(begin,end)); + std::list points; for(InputIterator it = begin; it != end; it++) @@ -683,8 +674,7 @@ centroid(InputIterator begin, CGAL_precondition(begin != end); - std::vector segments; - segments.reserve(12 * multipass_distance(begin,end)); + std::list segments; for(InputIterator it = begin; it != end; it++) diff --git a/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_cuboids_3.h b/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_cuboids_3.h index 2b39fb0a12e..4bfcbdf601c 100644 --- a/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_cuboids_3.h +++ b/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_cuboids_3.h @@ -24,10 +24,10 @@ #include #include #include -#include #include #include +#include #include namespace CGAL { @@ -114,8 +114,7 @@ linear_least_squares_fitting_3(InputIterator first, // precondition: at least one element in the container. CGAL_precondition(first != beyond); - std::vector segments; - segments.reserve(12 * multipass_distance(first,beyond)); + std::list segments; for(InputIterator it = first; it != beyond; it++) @@ -158,8 +157,7 @@ linear_least_squares_fitting_3(InputIterator first, // precondition: at least one element in the container. CGAL_precondition(first != beyond); - std::vector points; - points.reserve(8 * multipass_distance(first,beyond)); + std::list points; for(InputIterator it = first; it != beyond; it++) @@ -259,8 +257,7 @@ linear_least_squares_fitting_3(InputIterator first, // precondition: at least one element in the container. CGAL_precondition(first != beyond); - std::vector segments; - segments.reserve(12 * multipass_distance(first,beyond)); + std::list segments; for(InputIterator it = first; it != beyond; it++) @@ -303,8 +300,7 @@ linear_least_squares_fitting_3(InputIterator first, // precondition: at least one element in the container. CGAL_precondition(first != beyond); - std::vector points; - points.reserve(8 * multipass_distance(first,beyond)); + std::list points; for(InputIterator it = first; it != beyond; it++) diff --git a/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_rectangles_2.h b/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_rectangles_2.h index 5f95e12c240..a1879152bf7 100644 --- a/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_rectangles_2.h +++ b/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_rectangles_2.h @@ -26,10 +26,9 @@ #include #include #include -#include #include -#include +#include #include namespace CGAL { @@ -168,8 +167,7 @@ linear_least_squares_fitting_2(InputIterator first, // precondition: at least one element in the container. CGAL_precondition(first != beyond); - std::vector segments; - segments.reserve(4 * multipass_distance(first,beyond)); + std::list segments; for(InputIterator it = first; it != beyond; it++) @@ -204,8 +202,7 @@ linear_least_squares_fitting_2(InputIterator first, // precondition: at least one element in the container. CGAL_precondition(first != beyond); - std::vector points; - points.reserve(4 * multipass_distance(first,beyond)); + std::list points; for(InputIterator it = first; it != beyond; it++) diff --git a/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_segments_2.h b/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_segments_2.h index 5b2552410fb..e2c3029b4df 100644 --- a/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_segments_2.h +++ b/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_segments_2.h @@ -26,10 +26,9 @@ #include #include #include -#include #include -#include +#include #include namespace CGAL { @@ -156,8 +155,7 @@ linear_least_squares_fitting_2(InputIterator first, // precondition: at least one element in the container. CGAL_precondition(first != beyond); - std::vector points; - points.reserve(2 * multipass_distance(first,beyond)); + std::list points; for(InputIterator it = first; it != beyond; it++) diff --git a/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_segments_3.h b/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_segments_3.h index 2245e76fff6..1be447a36a9 100644 --- a/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_segments_3.h +++ b/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_segments_3.h @@ -25,8 +25,8 @@ #include #include #include -#include +#include #include namespace CGAL { @@ -81,8 +81,7 @@ linear_least_squares_fitting_3(InputIterator first, // precondition: at least one element in the container. CGAL_precondition(first != beyond); - std::vector points; - points.reserve(2 * multipass_distance(first,beyond)); + std::list points; for(InputIterator it = first; it != beyond; it++) @@ -145,8 +144,7 @@ linear_least_squares_fitting_3(InputIterator first, // precondition: at least one element in the container. CGAL_precondition(first != beyond); - std::vector points; - points.reserve(2 * multipass_distance(first,beyond)); + std::list points; for(InputIterator it = first; it != beyond; it++) diff --git a/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_tetrahedra_3.h b/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_tetrahedra_3.h index 787cded68eb..c87fcd3a470 100644 --- a/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_tetrahedra_3.h +++ b/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_tetrahedra_3.h @@ -28,7 +28,6 @@ #include #include #include -#include #include @@ -83,8 +82,7 @@ linear_least_squares_fitting_3(InputIterator first, // precondition: at least one element in the container. CGAL_precondition(first != beyond); - std::vector triangles; - triangles.reserve(4 * multipass_distance(first,beyond)); + std::list triangles; for(InputIterator it = first; it != beyond; it++) @@ -119,8 +117,7 @@ linear_least_squares_fitting_3(InputIterator first, // precondition: at least one element in the container. CGAL_precondition(first != beyond); - std::vector segments; - segments.reserve(6 * multipass_distance(first,beyond)); + std::list segments; for(InputIterator it = first; it != beyond; @@ -158,8 +155,7 @@ linear_least_squares_fitting_3(InputIterator first, // precondition: at least one element in the container. CGAL_precondition(first != beyond); - std::vector points; - points.reserve(4 * multipass_distance(first,beyond)); + std::list points; for(InputIterator it = first; it != beyond; it++) @@ -224,8 +220,7 @@ linear_least_squares_fitting_3(InputIterator first, // precondition: at least one element in the container. CGAL_precondition(first != beyond); - std::vector triangles; - triangles.reserve(4 * multipass_distance(first,beyond)); + std::list triangles; for(InputIterator it = first; it != beyond; it++) @@ -260,8 +255,7 @@ linear_least_squares_fitting_3(InputIterator first, // precondition: at least one element in the container. CGAL_precondition(first != beyond); - std::vector segments; - segments.reserve(6 * multipass_distance(first,beyond)); + std::list segments; for(InputIterator it = first; it != beyond; it++) @@ -298,8 +292,7 @@ linear_least_squares_fitting_3(InputIterator first, // precondition: at least one element in the container. CGAL_precondition(first != beyond); - std::vector points; - points.reserve(4 * multipass_distance(first,beyond)); + std::list points; for(InputIterator it = first; it != beyond; it++) diff --git a/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_triangles_2.h b/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_triangles_2.h index 9e6ba28b5f7..7bd3d777d9d 100644 --- a/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_triangles_2.h +++ b/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_triangles_2.h @@ -26,7 +26,6 @@ #include #include #include -#include #include #include @@ -202,8 +201,7 @@ linear_least_squares_fitting_2(InputIterator first, // precondition: at least one element in the container. CGAL_precondition(first != beyond); - std::vector points; - points.reserve(3 * multipass_distance(first,beyond)); + std::list points; for(InputIterator it = first; it != beyond; it++) diff --git a/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_triangles_3.h b/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_triangles_3.h index c40d2891a8c..aca731b7191 100644 --- a/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_triangles_3.h +++ b/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_triangles_3.h @@ -24,9 +24,8 @@ #include #include #include -#include -#include +#include #include namespace CGAL { @@ -81,8 +80,7 @@ linear_least_squares_fitting_3(InputIterator first, // precondition: at least one element in the container. CGAL_precondition(first != beyond); - std::vector segments; - segments.reserve(3* multipass_distance(first, beyond)); + std::list segments; for(InputIterator it = first; it != beyond; it++) @@ -115,8 +113,7 @@ linear_least_squares_fitting_3(InputIterator first, // precondition: at least one element in the container. CGAL_precondition(first != beyond); - std::vector points; - points.reserve(3* multipass_distance(first,beyond)); + std::list points; for(InputIterator it = first; it != beyond; it++) @@ -180,8 +177,7 @@ linear_least_squares_fitting_3(InputIterator first, // precondition: at least one element in the container. CGAL_precondition(first != beyond); - std::vector segments; - segments.reserve(3* multipass_distance(first, beyond)); + std::list segments; for(InputIterator it = first; it != beyond; it++) @@ -214,8 +210,7 @@ linear_least_squares_fitting_3(InputIterator first, // precondition: at least one element in the container. CGAL_precondition(first != beyond); - std::vector points; - points.reserve(3* multipass_distance(first, beyond)); + std::list points; for(InputIterator it = first; it != beyond; it++)