From d17c5a763a1bf0cea221431e6d573978e26d86d9 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Wed, 6 Mar 2013 18:09:58 +0100 Subject: [PATCH] re-add and fix OFF-output; size_t and static_cast --- .../extract.cpp | 11 ++++++---- .../include/CGAL/AFSR_cell_base_3.h | 4 ++-- .../Advancing_front_surface_reconstruction.h | 10 ++++----- .../Advancing_front_surface_reconstruction.h | 22 +++++++------------ 4 files changed, 22 insertions(+), 25 deletions(-) diff --git a/Advancing_front_surface_reconstruction/examples/Advancing_front_surface_reconstruction/extract.cpp b/Advancing_front_surface_reconstruction/examples/Advancing_front_surface_reconstruction/extract.cpp index 2bf5dd81adc..4a58a06c27b 100644 --- a/Advancing_front_surface_reconstruction/examples/Advancing_front_surface_reconstruction/extract.cpp +++ b/Advancing_front_surface_reconstruction/examples/Advancing_front_surface_reconstruction/extract.cpp @@ -60,7 +60,7 @@ bool file_input(const Options& opt, std::vector& points) { const char* finput = opt.finname; - int number_of_points = opt.number_of_points; + std::size_t number_of_points = opt.number_of_points; bool xyz = opt.xyz; std::ios::openmode mode = (opt.binary) ? std::ios::binary : std::ios::in; @@ -78,17 +78,19 @@ file_input(const Options& opt, std::vector& points) else std::cout << "Input from file : " << finput << std::endl; - int n; + std::size_t n; if(! xyz){ is >> n; std::cout << " reading " << n << " points" << std::endl; points.reserve(n); - CGAL::copy_n(std::istream_iterator(is), n, std::back_inserter(points)); + CGAL::cpp11::copy_n(std::istream_iterator(is), n, std::back_inserter(points)); } else { // we do not know beforehand how many points we will read std::istream_iterator it(is), eof; + char ignore[256]; while(it!= eof){ points.push_back(*it); + is.getline(ignore,256); it++; } n = points.size(); @@ -478,7 +480,8 @@ int main(int argc, char* argv[]) std::cout << "Total time: " << timer.time() << " sec." << std::endl; - write_to_file_vrml2(opt.foutname, S, opt.contour, opt.red, opt.green, opt.blue, opt.no_header); + // write_to_file_vrml2(opt.foutname, S, opt.contour, opt.red, opt.green, opt.blue, opt.no_header); + write_to_file(opt.foutname, S, opt.contour, opt.out_format, opt.red, opt.green, opt.blue, opt.no_header); std::cout << " " << S.number_of_outliers() diff --git a/Advancing_front_surface_reconstruction/include/CGAL/AFSR_cell_base_3.h b/Advancing_front_surface_reconstruction/include/CGAL/AFSR_cell_base_3.h index 7274c0263c1..e08b57c609c 100755 --- a/Advancing_front_surface_reconstruction/include/CGAL/AFSR_cell_base_3.h +++ b/Advancing_front_surface_reconstruction/include/CGAL/AFSR_cell_base_3.h @@ -179,12 +179,12 @@ facet_number(int i) inline bool is_selected_facet(const int& i) { - return selected_facet & (1 << i); + return (selected_facet & (1 << i)) != 0; } inline bool has_facet_on_surface(const int& i) { - return selected_facet & (1 << i); + return (selected_facet & (1 << i)) != 0; } #ifdef AFSR_LAZY diff --git a/Advancing_front_surface_reconstruction/include/CGAL/Advancing_front_surface_reconstruction.h b/Advancing_front_surface_reconstruction/include/CGAL/Advancing_front_surface_reconstruction.h index b07feecc4ea..7137fe42a31 100755 --- a/Advancing_front_surface_reconstruction/include/CGAL/Advancing_front_surface_reconstruction.h +++ b/Advancing_front_surface_reconstruction/include/CGAL/Advancing_front_surface_reconstruction.h @@ -238,7 +238,7 @@ public: : T(T_), _number_of_border(1), SLIVER_ANGULUS(.86), DELTA(opt.delta), min_K(HUGE_VAL), eps(1e-7), inv_eps_2(coord_type(1)/(eps*eps)), eps_3(eps*eps*eps), STANDBY_CANDIDATE(3), STANDBY_CANDIDATE_BIS(STANDBY_CANDIDATE+1), - NOT_VALID_CANDIDATE(STANDBY_CANDIDATE+2), _vh_number(T.number_of_vertices()), _facet_number(0), + NOT_VALID_CANDIDATE(STANDBY_CANDIDATE+2), _vh_number(static_cast(T.number_of_vertices())), _facet_number(0), _postprocessing_counter(0), _size_before_postprocessing(0), area(opt.area), perimeter(opt.perimeter), abs_area(opt.abs_area), abs_perimeter(opt.abs_perimeter), total_area(0), total_perimeter(0), _number_of_connected_components(0) @@ -321,7 +321,7 @@ public: int number_of_outliers() const { - return outliers.size(); + return static_cast(outliers.size()); } typedef typename std::list::const_iterator Outlier_iterator; @@ -1060,7 +1060,7 @@ public: void ordered_map_erase(const criteria& value, const IO_edge_type* pkey) { - int number_of_conflict = _ordered_border.count(value); + std::size_t number_of_conflict = _ordered_border.count(value); if (number_of_conflict == 1) { _ordered_border.erase(_ordered_border.find(value)); @@ -1073,7 +1073,7 @@ public: _ordered_border.find(value); // si ca foire jamais on peut s'areter des que l'elt // est trouve!!! - for(int jj=0; (jjsecond) == ((long) pkey)) { @@ -1908,7 +1908,7 @@ public: L_v.push_back(v_it); } - unsigned int itmp, L_v_size_mem; + std::size_t itmp, L_v_size_mem; L_v_size_mem = L_v.size(); if ((vh_on_border_inserted != 0)&& // pour ne post-traiter que les bords (L_v.size() < .1 * _size_before_postprocessing)) diff --git a/Advancing_front_surface_reconstruction/include/CGAL/IO/Advancing_front_surface_reconstruction.h b/Advancing_front_surface_reconstruction/include/CGAL/IO/Advancing_front_surface_reconstruction.h index 31cc943795b..9cd8e11558f 100755 --- a/Advancing_front_surface_reconstruction/include/CGAL/IO/Advancing_front_surface_reconstruction.h +++ b/Advancing_front_surface_reconstruction/include/CGAL/IO/Advancing_front_surface_reconstruction.h @@ -59,9 +59,9 @@ write_to_file_medit(char* foutput, const Surface& S) CGAL::set_ascii_mode(os_faces); // af: what is the relationship to _vh_number in Extract_surface - int _vh_number = std::count_if(T.finite_vertices_begin(), - T.finite_vertices_end(), - Is_not_exterior()); + std::size_t _vh_number = std::count_if(T.finite_vertices_begin(), + T.finite_vertices_end(), + Is_not_exterior()); os_points << _vh_number << std::endl; @@ -147,9 +147,9 @@ write_to_file_gv(char* foutput, const Surface& S) CGAL::set_ascii_mode(os); - int _vh_number = std::count_if(T.finite_vertices_begin(), - T.finite_vertices_end(), - Is_not_exterior()); + std::size_t _vh_number = std::count_if(T.finite_vertices_begin(), + T.finite_vertices_end(), + Is_not_exterior()); // Header. os << "OFF" << std::endl << _vh_number << " " << S.number_of_facets() << " " << 0 << std::endl; @@ -186,10 +186,7 @@ write_to_file_gv(char* foutput, const Surface& S) os << 3 << " "; os << vertex_index_map[c->vertex(i1)] << " "; os << vertex_index_map[c->vertex(i2)] << " "; - os << vertex_index_map[c->vertex(i3)] << " "; - os << 0 << std::endl; // without color. - // os << 4 << drand48() << drand48() << drand48() << 1.0; // random - // color + os << vertex_index_map[c->vertex(i3)] << "\n"; } if (n->is_selected_facet(ni)) @@ -200,10 +197,7 @@ write_to_file_gv(char* foutput, const Surface& S) os << 3 << " "; os << vertex_index_map[n->vertex(i1)] << " "; os << vertex_index_map[n->vertex(i2)] << " "; - os << vertex_index_map[n->vertex(i3)] << " "; - os << 0 << std::endl; // without color. - // os << 4 << drand48() << drand48() << drand48() << 1.0; // random - // color + os << vertex_index_map[n->vertex(i3)] << "\n"; } }