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 a3672fd24ae..7f8e26fc3ab 100644 --- a/Point_set_processing_3/include/CGAL/jet_estimate_normals.h +++ b/Point_set_processing_3/include/CGAL/jet_estimate_normals.h @@ -184,7 +184,7 @@ jet_estimate_normals( using parameters::choose_parameter; using parameters::get_parameter; - CGAL_TRACE("Calls jet_estimate_normals()\n"); + CGAL_TRACE_STREAM << "Calls jet_estimate_normals()\n"; // basic geometric types typedef typename PointRange::iterator iterator; @@ -221,13 +221,15 @@ jet_estimate_normals( // precondition: at least 2 nearest neighbors CGAL_point_set_processing_precondition(k >= 2 || neighbor_radius > FT(0)); - std::size_t memory = CGAL::Memory_sizer().virtual_size(); CGAL_TRACE(" %ld Mb allocated\n", memory>>20); - CGAL_TRACE(" Creates KD-tree\n"); + std::size_t memory = CGAL::Memory_sizer().virtual_size(); + CGAL_TRACE_STREAM << (memory >> 20) << " Mb allocated\n"; + CGAL_TRACE_STREAM << " Creates KD-tree\n"; Neighbor_query neighbor_query (points, point_map); - memory = CGAL::Memory_sizer().virtual_size(); CGAL_TRACE(" %ld Mb allocated\n", memory>>20); - CGAL_TRACE(" Computes normals\n"); + memory = CGAL::Memory_sizer().virtual_size(); + CGAL_TRACE_STREAM << (memory >> 20) << " Mb allocated\n"; + CGAL_TRACE_STREAM << " Computes normals\n"; std::size_t nb_points = points.size(); @@ -251,8 +253,9 @@ jet_estimate_normals( callback_wrapper.join(); - memory = CGAL::Memory_sizer().virtual_size(); CGAL_TRACE(" %ld Mb allocated\n", memory>>20); - CGAL_TRACE("End of jet_estimate_normals()\n"); + memory = CGAL::Memory_sizer().virtual_size(); + CGAL_TRACE_STREAM << (memory >> 20) << " Mb allocated\n"; + CGAL_TRACE_STREAM << "End of jet_estimate_normals()\n"; } 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 544614a7fbc..cdc316fc7ad 100644 --- a/Point_set_processing_3/include/CGAL/mst_orient_normals.h +++ b/Point_set_processing_3/include/CGAL/mst_orient_normals.h @@ -245,7 +245,7 @@ mst_find_source( NormalMap normal_map, ///< property map: value_type of ForwardIterator -> Vector_3 const Kernel& /*kernel*/) ///< geometric traits. { - CGAL_TRACE(" mst_find_source()\n"); + CGAL_TRACE_STREAM << " mst_find_source()\n"; // Input points types typedef typename boost::property_traits::value_type Vector; @@ -270,8 +270,8 @@ mst_find_source( Vector_ref normal = get(normal_map,*top_point); const Vector Z(0, 0, 1); if (Z * normal < 0) { - CGAL_TRACE(" Flip top point normal\n"); - put(normal_map,*top_point, -normal); + CGAL_TRACE_STREAM << " Flip top point normal\n"; + put(normal_map,*top_point, -normal); } return top_point; @@ -329,13 +329,15 @@ create_riemannian_graph( // Number of input points const std::size_t num_input_points = points.size(); - std::size_t memory = CGAL::Memory_sizer().virtual_size(); CGAL_TRACE(" %ld Mb allocated\n", memory>>20); - CGAL_TRACE(" Creates KD-tree\n"); + std::size_t memory = CGAL::Memory_sizer().virtual_size(); + CGAL_TRACE_STREAM << (memory >> 20) << " Mb allocated\n"; + CGAL_TRACE_STREAM << " Creates KD-tree\n"; Neighbor_query neighbor_query (points, point_map); - memory = CGAL::Memory_sizer().virtual_size(); CGAL_TRACE(" %ld Mb allocated\n", memory>>20); - CGAL_TRACE(" Creates Riemannian Graph\n"); + memory = CGAL::Memory_sizer().virtual_size(); + CGAL_TRACE_STREAM << (memory >> 20) << " Mb allocated\n"; + CGAL_TRACE_STREAM << " Creates Riemannian Graph\n"; // Iterates over input points and creates Riemannian Graph: // - vertices are numbered like the input points index. @@ -465,8 +467,9 @@ create_mst_graph( // Number of input points const std::size_t num_input_points = num_vertices(riemannian_graph) - 1; - std::size_t memory = CGAL::Memory_sizer().virtual_size(); CGAL_TRACE(" %ld Mb allocated\n", memory>>20); - CGAL_TRACE(" Calls boost::prim_minimum_spanning_tree()\n"); + std::size_t memory = CGAL::Memory_sizer().virtual_size(); + CGAL_TRACE_STREAM << (memory >> 20) << " Mb allocated\n"; + CGAL_TRACE_STREAM << " Calls boost::prim_minimum_spanning_tree()\n"; // Computes Minimum Spanning Tree. std::size_t source_point_index = num_input_points; @@ -478,8 +481,9 @@ create_mst_graph( weight_map( riemannian_graph_weight_map ) .root_vertex( vertex(source_point_index, riemannian_graph) )); - memory = CGAL::Memory_sizer().virtual_size(); CGAL_TRACE(" %ld Mb allocated\n", memory>>20); - CGAL_TRACE(" Creates MST Graph\n"); + memory = CGAL::Memory_sizer().virtual_size(); + CGAL_TRACE_STREAM << (memory >> 20) << " Mb allocated\n"; + CGAL_TRACE_STREAM << " Creates MST Graph\n"; // Converts predecessor map to a MST graph: // - vertices are numbered like the input points index. @@ -605,7 +609,7 @@ mst_orient_normals( using parameters::choose_parameter; using parameters::get_parameter; - CGAL_TRACE("Calls mst_orient_normals()\n"); + CGAL_TRACE_STREAM << "Calls mst_orient_normals()\n"; typedef typename CGAL::GetPointMap::type PointMap; typedef typename Point_set_processing_3::GetNormalMap::type NormalMap; @@ -643,8 +647,9 @@ mst_orient_normals( // Precondition: at least 2 nearest neighbors CGAL_point_set_processing_precondition(k >= 2); - std::size_t memory = CGAL::Memory_sizer().virtual_size(); CGAL_TRACE(" %ld Mb allocated\n", memory>>20); - CGAL_TRACE(" Create Index_property_map\n"); + std::size_t memory = CGAL::Memory_sizer().virtual_size(); + CGAL_TRACE_STREAM << (memory >> 20) << " Mb allocated\n"; + CGAL_TRACE_STREAM << " Create Index_property_map\n"; // Create a property map Iterator -> index. // - if typename PointRange::iterator is a random access iterator (typically vector and deque), @@ -686,8 +691,9 @@ mst_orient_normals( kernel, riemannian_graph); - memory = CGAL::Memory_sizer().virtual_size(); CGAL_TRACE(" %ld Mb allocated\n", memory>>20); - CGAL_TRACE(" Calls boost::breadth_first_search()\n"); + memory = CGAL::Memory_sizer().virtual_size(); + CGAL_TRACE_STREAM << (memory >> 20) << " Mb allocated\n"; + CGAL_TRACE_STREAM << " Calls boost::breadth_first_search()\n"; const std::size_t num_input_points = distance(points.begin(), points.end()); std::size_t source_point_index = num_input_points; @@ -717,10 +723,11 @@ mst_orient_normals( std::copy(unoriented_points.begin(), unoriented_points.end(), first_unoriented_point); // At this stage, we have typically 0 unoriented normals if k is large enough - CGAL_TRACE(" => %u normals are unoriented\n", unoriented_points.size()); + CGAL_TRACE_STREAM << " => " << unoriented_points.size() << " normals are unoriented\n"; - memory = CGAL::Memory_sizer().virtual_size(); CGAL_TRACE(" %ld Mb allocated\n", memory>>20); - CGAL_TRACE("End of mst_orient_normals()\n"); + memory = CGAL::Memory_sizer().virtual_size(); + CGAL_TRACE_STREAM << (memory >> 20) << " Mb allocated\n"; + CGAL_TRACE_STREAM << "End of mst_orient_normals()\n"; return first_unoriented_point; } 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 8f20104b64d..5979f11086e 100644 --- a/Point_set_processing_3/include/CGAL/pca_estimate_normals.h +++ b/Point_set_processing_3/include/CGAL/pca_estimate_normals.h @@ -159,7 +159,7 @@ pca_estimate_normals( using parameters::choose_parameter; using parameters::get_parameter; - CGAL_TRACE("Calls pca_estimate_normals()\n"); + CGAL_TRACE_STREAM << "Calls pca_estimate_normals()\n"; // basic geometric types typedef typename CGAL::GetPointMap::type PointMap; @@ -192,13 +192,15 @@ pca_estimate_normals( // precondition: at least 2 nearest neighbors CGAL_point_set_processing_precondition(k >= 2); - std::size_t memory = CGAL::Memory_sizer().virtual_size(); CGAL_TRACE(" %ld Mb allocated\n", memory>>20); - CGAL_TRACE(" Creates KD-tree\n"); + std::size_t memory = CGAL::Memory_sizer().virtual_size(); + CGAL_TRACE_STREAM << (memory >> 20) << " Mb allocated\n"; + CGAL_TRACE_STREAM << " Creates KD-tree\n"; Neighbor_query neighbor_query (points, point_map); - memory = CGAL::Memory_sizer().virtual_size(); CGAL_TRACE(" %ld Mb allocated\n", memory>>20); - CGAL_TRACE(" Computes normals\n"); + memory = CGAL::Memory_sizer().virtual_size(); + CGAL_TRACE_STREAM << (memory >> 20) << " Mb allocated\n"; + CGAL_TRACE_STREAM << " Computes normals\n"; std::size_t nb_points = points.size(); @@ -223,8 +225,9 @@ pca_estimate_normals( callback_wrapper.join(); - memory = CGAL::Memory_sizer().virtual_size(); CGAL_TRACE(" %ld Mb allocated\n", memory>>20); - CGAL_TRACE("End of pca_estimate_normals()\n"); + memory = CGAL::Memory_sizer().virtual_size(); + CGAL_TRACE_STREAM << (memory >> 20) << " Mb allocated\n"; + CGAL_TRACE_STREAM << "End of pca_estimate_normals()\n"; } /// \cond SKIP_IN_MANUAL diff --git a/Poisson_surface_reconstruction_3/include/CGAL/Poisson_reconstruction_function.h b/Poisson_surface_reconstruction_3/include/CGAL/Poisson_reconstruction_function.h index e526d4ac91f..2c4cc8d1f7a 100644 --- a/Poisson_surface_reconstruction_3/include/CGAL/Poisson_reconstruction_function.h +++ b/Poisson_surface_reconstruction_3/include/CGAL/Poisson_reconstruction_function.h @@ -770,7 +770,7 @@ private: SparseLinearAlgebraTraits_d solver, ///< sparse linear solver double lambda) { - CGAL_TRACE("Calls solve_poisson()\n"); + CGAL_TRACE_STREAM << "Calls solve_poisson()\n"; double time_init = clock(); @@ -786,7 +786,7 @@ private: m_tr->index_unconstrained_vertices(); unsigned int nb_variables = static_cast(m_tr->number_of_vertices()-1); - CGAL_TRACE(" Number of variables: %ld\n", (long)(nb_variables)); + CGAL_TRACE_STREAM << " Number of variables: " << nb_variables << std::endl; // Assemble linear system A*X=B typename SparseLinearAlgebraTraits_d::Matrix A(nb_variables); // matrix is symmetric definite positive @@ -815,9 +815,9 @@ private: clear_duals(); clear_normals(); duration_assembly = (clock() - time_init)/CLOCKS_PER_SEC; - CGAL_TRACE(" Creates matrix: done (%.2lf s)\n", duration_assembly); + CGAL_TRACE_STREAM << " Creates matrix: done (" << duration_assembly << "sec.)\n"; - CGAL_TRACE(" Solve sparse linear system...\n"); + CGAL_TRACE_STREAM << " Solve sparse linear system...\n"; // Solve "A*X = B". On success, solution is (1/D) * X. time_init = clock(); @@ -827,7 +827,7 @@ private: CGAL_surface_reconstruction_points_assertion(D == 1.0); duration_solve = (clock() - time_init)/CLOCKS_PER_SEC; - CGAL_TRACE(" Solve sparse linear system: done (%.2lf s)\n", duration_solve); + CGAL_TRACE_STREAM << " Solve sparse linear system: done (" << duration_solve << "sec.)\n"; // copy function's values to vertices unsigned int index = 0; @@ -835,7 +835,7 @@ private: if(!m_tr->is_constrained(v)) v->f() = X[index++]; - CGAL_TRACE("End of solve_poisson()\n"); + CGAL_TRACE_STREAM << "End of solve_poisson()\n"; return true; } diff --git a/Stream_support/include/CGAL/IO/trace.h b/Stream_support/include/CGAL/IO/trace.h index d300ceada87..42ef6317665 100644 --- a/Stream_support/include/CGAL/IO/trace.h +++ b/Stream_support/include/CGAL/IO/trace.h @@ -11,32 +11,13 @@ #ifndef CGAL_IO_TRACE_H #define CGAL_IO_TRACE_H -#include -#include #include -#include /// \cond SKIP_IN_MANUAL // Trace utilities // --------------- -// print_stderr() = printf-like function to print to stderr -inline void CGAL_print_stderr(const char *fmt, ...) -{ - va_list argp; - va_start(argp, fmt); - vfprintf_s(stderr, fmt, argp); - va_end(argp); -} - -// CGAL_TRACE() = printf-like function to print to stderr -// if DEBUG_TRACE is defined (ignored otherwise) -#ifdef DEBUG_TRACE -#define CGAL_TRACE CGAL_print_stderr -#else - #define CGAL_TRACE if (false) CGAL_print_stderr -#endif // CGAL_TRACE_STREAM = C++ stream that prints to std::cerr // if DEBUG_TRACE is defined (ignored otherwise)