summaryrefslogtreecommitdiff
path: root/src/Alpha_complex
diff options
context:
space:
mode:
authorvrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2017-12-21 19:08:54 +0000
committervrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2017-12-21 19:08:54 +0000
commitf6e028d90a036e357485a977edd8b3a6010b762b (patch)
tree0ed94077f96693d402da45a0ac0c669e1a068f8d /src/Alpha_complex
parente898db7707f6f4cd45a4759a3ebf6688d8eb826e (diff)
Code review fix : Bad cmake utility name, file read check, non negative weight check
git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/trunk@3095 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 09c0342e7c06f69b62f01c3ba8330a99b963399c
Diffstat (limited to 'src/Alpha_complex')
-rw-r--r--src/Alpha_complex/utilities/CMakeLists.txt2
-rw-r--r--src/Alpha_complex/utilities/weighted_periodic_alpha_complex_3d_persistence.cpp16
2 files changed, 11 insertions, 7 deletions
diff --git a/src/Alpha_complex/utilities/CMakeLists.txt b/src/Alpha_complex/utilities/CMakeLists.txt
index 79d9e7dd..a2dfac20 100644
--- a/src/Alpha_complex/utilities/CMakeLists.txt
+++ b/src/Alpha_complex/utilities/CMakeLists.txt
@@ -54,7 +54,7 @@ if(CGAL_FOUND)
target_link_libraries(weighted_periodic_alpha_complex_3d_persistence ${TBB_LIBRARIES})
endif(TBB_FOUND)
- add_test(NAME Persistent_cohomology_example_weigted_periodic_alpha_complex_3d COMMAND $<TARGET_FILE:weighted_periodic_alpha_complex_3d_persistence>
+ add_test(NAME Alpha_complex_utilities_weigted_periodic_alpha_complex_3d COMMAND $<TARGET_FILE:weighted_periodic_alpha_complex_3d_persistence>
"${CMAKE_SOURCE_DIR}/data/points/grid_10_10_10_in_0_1.off" "${CMAKE_SOURCE_DIR}/data/points/grid_10_10_10_in_0_1.weights"
"${CMAKE_SOURCE_DIR}/data/points/iso_cuboid_3_in_0_1.txt" "3" "1.0")
diff --git a/src/Alpha_complex/utilities/weighted_periodic_alpha_complex_3d_persistence.cpp b/src/Alpha_complex/utilities/weighted_periodic_alpha_complex_3d_persistence.cpp
index f7a89454..0fe8931f 100644
--- a/src/Alpha_complex/utilities/weighted_periodic_alpha_complex_3d_persistence.cpp
+++ b/src/Alpha_complex/utilities/weighted_periodic_alpha_complex_3d_persistence.cpp
@@ -117,8 +117,12 @@ int main(int argc, char* const argv[]) {
// Read iso_cuboid_3 information from file
std::ifstream iso_cuboid_str(argv[3]);
double x_min, y_min, z_min, x_max, y_max, z_max;
- if (iso_cuboid_str.good()) {
- iso_cuboid_str >> x_min >> y_min >> z_min >> x_max >> y_max >> z_max;
+ if (iso_cuboid_str.is_open()) {
+ if (!(iso_cuboid_str >> x_min >> y_min >> z_min >> x_max >> y_max >> z_max)) {
+ std::cerr << argv[3] << " - Bad file format." << std::endl;
+ usage(argv[0]);
+ }
+
} else {
std::cerr << "Unable to read file " << argv[3] << std::endl;
usage(argv[0]);
@@ -130,21 +134,21 @@ int main(int argc, char* const argv[]) {
exit(-1);
}
- double maximal_possible_weigth = 0.015625 * (x_max-x_min) * (x_max-x_min);
+ double maximal_possible_weight = 0.015625 * (x_max-x_min) * (x_max-x_min);
// Read weights information from file
std::ifstream weights_ifstr(argv[2]);
std::vector<Weighted_point_3> wp;
- if (weights_ifstr.good()) {
+ if (weights_ifstr.is_open()) {
double weight = 0.0;
std::size_t index = 0;
wp.reserve(lp.size());
// Attempt read the weight in a double format, return false if it fails
while ((weights_ifstr >> weight) && (index < lp.size())) {
- if (weight >= maximal_possible_weigth)
+ if ((weight >= maximal_possible_weight) || (weight < 0))
{
std::cerr << "At line " << (index + 1) << ", the weight (" << weight
- << ") is more or equal to maximal possible weight (" << maximal_possible_weigth
+ << ") is negative or more than or equal to maximal possible weight (" << maximal_possible_weight
<< ") = 1/64*cuboid length squared, which is not an acceptable input." << std::endl;
exit(-1);
}