From 298c080b45250f2b8f16a0c31ace9bb6fc666c93 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Wed, 16 Mar 2016 08:33:04 +0000 Subject: CppCheck and CppLint fixes for alpha complexes git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/alphashapes@1047 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: a9b42ad2f8751384b5227fa3da8f380cda9b3696 --- src/Alpha_complex/doc/Intro_alpha_complex.h | 4 ++-- .../example/Alpha_complex_from_off.cpp | 2 +- src/Alpha_complex/include/gudhi/Alpha_complex.h | 21 ++++++++++----------- src/GudhUI/model/Model.h | 2 +- src/GudhUI/utils/Bar_code_persistence.h | 11 ++++++++--- src/GudhUI/utils/Persistence_compute.h | 1 - src/GudhUI/view/FirstCoordProjector.h | 1 - .../example/alpha_complex_3d_persistence.cpp | 15 ++++----------- .../example/Delaunay_triangulation_off_rw.cpp | 14 +++++++------- .../include/gudhi/Delaunay_triangulation_off_io.h | 10 +++------- src/common/include/gudhi/Off_reader.h | 2 +- 11 files changed, 37 insertions(+), 46 deletions(-) diff --git a/src/Alpha_complex/doc/Intro_alpha_complex.h b/src/Alpha_complex/doc/Intro_alpha_complex.h index deecf93f..f55d7029 100644 --- a/src/Alpha_complex/doc/Intro_alpha_complex.h +++ b/src/Alpha_complex/doc/Intro_alpha_complex.h @@ -161,8 +161,8 @@ namespace alphacomplex { */ /** @} */ // end defgroup alpha_complex -} // namespace alphacomplex +} // namespace alphacomplex -} // namespace Gudhi +} // namespace Gudhi #endif // INTRO_ALPHA_COMPLEX_H_ diff --git a/src/Alpha_complex/example/Alpha_complex_from_off.cpp b/src/Alpha_complex/example/Alpha_complex_from_off.cpp index 80445a22..18a1a20d 100644 --- a/src/Alpha_complex/example/Alpha_complex_from_off.cpp +++ b/src/Alpha_complex/example/Alpha_complex_from_off.cpp @@ -27,7 +27,7 @@ int main(int argc, char **argv) { std::streambuf* streambufffer; std::ofstream ouput_file_stream; - + if (argc == 4) { ouput_file_stream.open(std::string(argv[3])); streambufffer = ouput_file_stream.rdbuf(); diff --git a/src/Alpha_complex/include/gudhi/Alpha_complex.h b/src/Alpha_complex/include/gudhi/Alpha_complex.h index a69afb51..eab66384 100644 --- a/src/Alpha_complex/include/gudhi/Alpha_complex.h +++ b/src/Alpha_complex/include/gudhi/Alpha_complex.h @@ -20,8 +20,8 @@ * along with this program. If not, see . */ -#ifndef ALPHA_COMPLEX_H_ -#define ALPHA_COMPLEX_H_ +#ifndef DOC_ALPHA_COMPLEX_INTRO_ALPHA_COMPLEX_H_ +#define DOC_ALPHA_COMPLEX_INTRO_ALPHA_COMPLEX_H_ // to construct a simplex_tree from Delaunay_triangulation #include @@ -97,7 +97,6 @@ class Alpha_complex : public Simplex_tree<> { // Double map type to switch from CGAL vertex iterator to simplex tree vertex handle and vice versa. typedef typename std::map< CGAL_vertex_iterator, Vertex_handle > Map_vertex_iterator_to_handle; - //typedef typename std::map< Vertex_handle, CGAL_vertex_iterator > Map_vertex_handle_to_iterator; typedef typename std::vector< CGAL_vertex_iterator > Vector_vertex_iterator; private: @@ -141,7 +140,7 @@ class Alpha_complex : public Simplex_tree<> { Alpha_complex(Delaunay_triangulation* triangulation_ptr, Filtration_value max_alpha_square = std::numeric_limits::infinity()) : triangulation_(triangulation_ptr) { - init(max_alpha_square); + init(max_alpha_square); } /** \brief Alpha_complex constructor from a list of points. @@ -160,17 +159,17 @@ class Alpha_complex : public Simplex_tree<> { : triangulation_(nullptr) { auto first = std::begin(points); auto last = std::end(points); - + GUDHI_CHECK((first == last), - std::invalid_argument ("Alpha_complex::Alpha_complex(InputPointRange) - Empty input point range")); - + std::invalid_argument("Alpha_complex::Alpha_complex(InputPointRange) - Empty input point range")); + if (first != last) { // point_dimension function initialization Point_Dimension point_dimension = kernel_.point_dimension_d_object(); // Delaunay triangulation is point dimension minus one. triangulation_ = new Delaunay_triangulation(point_dimension(*first) - 1); - + size_type inserted = triangulation_->insert(first, last); if (inserted != (last -first)) { std::cerr << "Alpha_complex - insertion failed " << inserted << " != " << (last -first) << "\n"; @@ -227,7 +226,7 @@ class Alpha_complex : public Simplex_tree<> { } set_dimension(triangulation_->maximal_dimension()); - // set_filtration to +inf for prune_above_filtration to be done (if necessary) + // set_filtration to +inf for prune_above_filtration to be done (if necessary) set_filtration(std::numeric_limits::infinity()); // -------------------------------------------------------------------------------------------- @@ -247,7 +246,7 @@ class Alpha_complex : public Simplex_tree<> { } } // -------------------------------------------------------------------------------------------- - + // -------------------------------------------------------------------------------------------- // Simplex_tree construction from loop on triangulation finite full cells list for (auto cit = triangulation_->finite_full_cells_begin(); cit != triangulation_->finite_full_cells_end(); ++cit) { @@ -393,4 +392,4 @@ class Alpha_complex : public Simplex_tree<> { } // namespace Gudhi -#endif // ALPHA_COMPLEX_H_ +#endif // DOC_ALPHA_COMPLEX_INTRO_ALPHA_COMPLEX_H_ diff --git a/src/GudhUI/model/Model.h b/src/GudhUI/model/Model.h index 99a82eba..1c39c0d7 100644 --- a/src/GudhUI/model/Model.h +++ b/src/GudhUI/model/Model.h @@ -71,7 +71,7 @@ class CGAL_geometric_flag_complex_wrapper { void maximal_face(std::vector vertices) { if (!load_only_points_) { - //std::cout << "size:" << vertices.size() << std::endl; + // std::cout << "size:" << vertices.size() << std::endl; for (int i = 0; i < vertices.size(); ++i) for (int j = i + 1; j < vertices.size(); ++j) complex_.add_edge(Vertex_handle(vertices[i]), Vertex_handle(vertices[j])); diff --git a/src/GudhUI/utils/Bar_code_persistence.h b/src/GudhUI/utils/Bar_code_persistence.h index a4cd8156..b527d684 100644 --- a/src/GudhUI/utils/Bar_code_persistence.h +++ b/src/GudhUI/utils/Bar_code_persistence.h @@ -12,6 +12,10 @@ #include #include // NaN, infinity #include // for pair +#include + +#ifndef UTILS_BAR_CODE_PERSISTENCE_H_ +#define UTILS_BAR_CODE_PERSISTENCE_H_ class Bar_code_persistence { private: @@ -21,7 +25,6 @@ class Bar_code_persistence { double max_death; public: - Bar_code_persistence() : min_birth(std::numeric_limits::quiet_NaN()), max_death(std::numeric_limits::quiet_NaN()) { } @@ -45,13 +48,13 @@ class Bar_code_persistence { QGraphicsScene * scene = new QGraphicsScene(); view->setScene(scene); double ratio = 600.0 / (max_death - min_birth); - //std::cout << "min_birth=" << min_birth << " - max_death=" << max_death << " - ratio=" << ratio << std::endl; + // std::cout << "min_birth=" << min_birth << " - max_death=" << max_death << " - ratio=" << ratio << std::endl; double height = 0.0, birth = 0.0, death = 0.0; int pers_num = 1; for (auto& persistence : persistence_vector) { height = 5.0 * pers_num; - //std::cout << "[" << pers_num << "] birth=" << persistence.first << " - death=" << persistence.second << std::endl; + // std::cout << "[" << pers_num << "] birth=" << persistence.first << " - death=" << persistence.second << std::endl; if (std::isfinite(persistence.first)) birth = ((persistence.first - min_birth) * ratio) + 50.0; else @@ -83,3 +86,5 @@ class Bar_code_persistence { view->show(); } }; + +#endif // UTILS_BAR_CODE_PERSISTENCE_H_ diff --git a/src/GudhUI/utils/Persistence_compute.h b/src/GudhUI/utils/Persistence_compute.h index 1f04cc6b..97165490 100644 --- a/src/GudhUI/utils/Persistence_compute.h +++ b/src/GudhUI/utils/Persistence_compute.h @@ -85,7 +85,6 @@ template class Persistence_compute { stream << "p dimension birth death: \n"; pcoh.output_diagram(stream); - } }; diff --git a/src/GudhUI/view/FirstCoordProjector.h b/src/GudhUI/view/FirstCoordProjector.h index 3ceda3f5..a4027b7f 100644 --- a/src/GudhUI/view/FirstCoordProjector.h +++ b/src/GudhUI/view/FirstCoordProjector.h @@ -36,7 +36,6 @@ class FirstCoordProjector3D : public Projector3D { return Point_3(p.x(), p.y(), p.z()); else if (p.dimension() >= 2) return Point_3(p.x(), p.y(), 0.0); - } }; diff --git a/src/Persistent_cohomology/example/alpha_complex_3d_persistence.cpp b/src/Persistent_cohomology/example/alpha_complex_3d_persistence.cpp index ac208957..f81951ce 100644 --- a/src/Persistent_cohomology/example/alpha_complex_3d_persistence.cpp +++ b/src/Persistent_cohomology/example/alpha_complex_3d_persistence.cpp @@ -39,9 +39,6 @@ #include #include -using namespace Gudhi; -using namespace Gudhi::persistent_cohomology; - // Alpha_shape_3 templates type definitions typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel; typedef CGAL::Alpha_shape_vertex_base_3 Vb; @@ -66,11 +63,12 @@ typedef Alpha_shape_3::Edge Edge_3; typedef std::list Vertex_list; // gudhi type definition -typedef Simplex_tree ST; +typedef Gudhi::Simplex_tree ST; typedef ST::Vertex_handle Simplex_tree_vertex; typedef std::map Alpha_shape_simplex_tree_map; typedef std::pair Alpha_shape_simplex_tree_pair; typedef std::vector< Simplex_tree_vertex > Simplex_tree_vector_vertex; +typedef Gudhi::persistent_cohomology::Persistent_cohomology< ST, Gudhi::persistent_cohomology::Field_Zp > PCOH; Vertex_list from(const Cell_handle& ch) { Vertex_list the_list; @@ -131,12 +129,7 @@ int main(int argc, char * const argv[]) { usage(argv[0]); } - int coeff_field_characteristic = 0; - int returnedScanValue = sscanf(argv[2], "%d", &coeff_field_characteristic); - if ((returnedScanValue == EOF) || (coeff_field_characteristic <= 0)) { - std::cerr << "Error: " << argv[2] << " is not correct\n"; - usage(argv[0]); - } + int coeff_field_characteristic = atoi(argv[2]); Filtration_value min_persistence = 0.0; returnedScanValue = sscanf(argv[3], "%lf", &min_persistence); @@ -282,7 +275,7 @@ int main(int argc, char * const argv[]) { std::cout << "Simplex_tree dim: " << simplex_tree.dimension() << std::endl; // Compute the persistence diagram of the complex - Persistent_cohomology< ST, Field_Zp > pcoh(simplex_tree); + PCOH pcoh(simplex_tree); // initializes the coefficient field for homology pcoh.init_coefficients(coeff_field_characteristic); diff --git a/src/common/example/Delaunay_triangulation_off_rw.cpp b/src/common/example/Delaunay_triangulation_off_rw.cpp index 75e4fafb..4c7a9aaf 100644 --- a/src/common/example/Delaunay_triangulation_off_rw.cpp +++ b/src/common/example/Delaunay_triangulation_off_rw.cpp @@ -10,12 +10,12 @@ // Use dynamic_dimension_tag for the user to be able to set dimension typedef CGAL::Epick_d< CGAL::Dynamic_dimension_tag > K; typedef CGAL::Delaunay_triangulation T; -// The triangulation uses the default instantiation of the +// The triangulation uses the default instantiation of the // TriangulationDataStructure template parameter void usage(char * const progName) { std::cerr << "Usage: " << progName << " inputFile.off outputFile.off" << std::endl; - exit(-1); // ----- >> + exit(-1); } int main(int argc, char **argv) { @@ -30,9 +30,9 @@ int main(int argc, char **argv) { // Check the read operation was correct if (!off_reader.is_valid()) { std::cerr << "Unable to read file " << offInputFile << std::endl; - exit(-1); // ----- >> + exit(-1); } - + // Retrieve the triangulation T* triangulation = off_reader.get_complex(); // Operations on triangulation @@ -47,8 +47,8 @@ int main(int argc, char **argv) { // Check the write operation was correct if (!off_writer.is_valid()) { std::cerr << "Unable to write file " << offOutputFile << std::endl; - exit(-1); // ----- >> + exit(-1); } - + return 0; -} \ No newline at end of file +} diff --git a/src/common/include/gudhi/Delaunay_triangulation_off_io.h b/src/common/include/gudhi/Delaunay_triangulation_off_io.h index 529774f0..e623cf7b 100644 --- a/src/common/include/gudhi/Delaunay_triangulation_off_io.h +++ b/src/common/include/gudhi/Delaunay_triangulation_off_io.h @@ -44,8 +44,8 @@ class Delaunay_triangulation_off_visitor_reader { Complex* complex_; typedef typename Complex::Point Point; std::vector point_cloud; - public: + public: // TODO(VR) : Pass a Complex as a parameter is required, even if not used. Otherwise, compilation is KO. /** \brief Delaunay_triangulation_off_visitor_reader constructor @@ -153,7 +153,6 @@ class Delaunay_triangulation_off_visitor_reader { template class Delaunay_triangulation_off_reader { public: - /** \brief Reads the OFF file and constructs the Delaunay triangulation from the points * that are in the OFF file. * @@ -180,7 +179,6 @@ class Delaunay_triangulation_off_reader { std::cerr << "Delaunay_triangulation_off_reader::Delaunay_triangulation_off_reader could not open file " << name_file << "\n"; } - } /** \brief Returns if the OFF file read operation was successful or not. @@ -201,7 +199,6 @@ class Delaunay_triangulation_off_reader { if (valid_) return complex_; return nullptr; - } private: @@ -285,7 +282,6 @@ class Delaunay_triangulation_off_writer { } for (auto cit = complex_ptr->finite_full_cells_begin(); cit != complex_ptr->finite_full_cells_end(); ++cit) { - std::vector vertexVector; stream << std::distance(cit->vertices_begin(), cit->vertices_end()) << " "; for (auto vit = cit->vertices_begin(); vit != cit->vertices_end(); ++vit) { stream << points_to_vh[(*vit)->point()] - 1 << " "; @@ -299,7 +295,7 @@ class Delaunay_triangulation_off_writer { name_file << "\n"; } } - + /** \brief Returns if the OFF write operation was successful or not. * * @return OFF file write status. @@ -313,6 +309,6 @@ class Delaunay_triangulation_off_writer { bool valid_; }; -} // namespace Gudhi +} // namespace Gudhi #endif // DELAUNAY_TRIANGULATION_OFF_IO_H_ diff --git a/src/common/include/gudhi/Off_reader.h b/src/common/include/gudhi/Off_reader.h index e45a7600..2420ae72 100644 --- a/src/common/include/gudhi/Off_reader.h +++ b/src/common/include/gudhi/Off_reader.h @@ -160,7 +160,7 @@ class Off_reader { iss >> num_face_vertices; std::vector face; face.assign(std::istream_iterator(iss), std::istream_iterator()); - //if (face.size() != (off_info_.dim + 1)) return false; + // if (face.size() != (off_info_.dim + 1)) return false; visitor.maximal_face(face); } return true; -- cgit v1.2.3