From eeed92c94debd82d2db4e386213390ca8766a65a Mon Sep 17 00:00:00 2001 From: Simon Giraudot Date: Wed, 12 Dec 2018 09:16:57 +0100 Subject: [PATCH] Fix usage of concept Range (no resize() method, size should be taken care of by the user --- .../examples/Classification/example_classification.cpp | 4 ++-- .../examples/Classification/example_feature.cpp | 2 +- Classification/include/CGAL/Classification/classify.h | 9 --------- .../test/Classification/test_classification_io.cpp | 6 +++--- .../Plugins/Classification/Cluster_classification.cpp | 3 +++ .../Classification/Point_set_item_classification.cpp | 5 ++++- .../Classification/Surface_mesh_item_classification.cpp | 3 +++ 7 files changed, 16 insertions(+), 16 deletions(-) diff --git a/Classification/examples/Classification/example_classification.cpp b/Classification/examples/Classification/example_classification.cpp index 4ed9caccabd..665fb17f064 100644 --- a/Classification/examples/Classification/example_classification.cpp +++ b/Classification/examples/Classification/example_classification.cpp @@ -146,7 +146,7 @@ int main (int argc, char** argv) /////////////////////////////////////////////////////////////////// //! [Classify] - std::vector label_indices; + std::vector label_indices (pts.size(), -1); CGAL::Real_timer t; t.start(); @@ -200,7 +200,7 @@ int main (int argc, char** argv) { f << pts[i] << " "; - Label_handle label = labels[label_indices[i]]; + Label_handle label = labels[std::size_t(label_indices[i])]; if (label == ground) f << "245 180 0" << std::endl; else if (label == vegetation) diff --git a/Classification/examples/Classification/example_feature.cpp b/Classification/examples/Classification/example_feature.cpp index d1ce94e8fee..4cce763be1a 100644 --- a/Classification/examples/Classification/example_feature.cpp +++ b/Classification/examples/Classification/example_feature.cpp @@ -114,7 +114,7 @@ int main (int argc, char** argv) classifier.set_effect (b, my_feature, Classifier::PENALIZING); std::cerr << "Classifying" << std::endl; - std::vector label_indices(pts.size(), -1); + std::vector label_indices(pts.size(), -1); Classification::classify_with_graphcut (pts, Pmap(), labels, classifier, neighborhood.k_neighbor_query(12), diff --git a/Classification/include/CGAL/Classification/classify.h b/Classification/include/CGAL/Classification/classify.h index 59bd19cfe2f..492d1855237 100644 --- a/Classification/include/CGAL/Classification/classify.h +++ b/Classification/include/CGAL/Classification/classify.h @@ -370,8 +370,6 @@ namespace internal { const Classifier& classifier, LabelIndexRange& output) { - output.resize(input.size()); - internal::Classify_functor f (labels, classifier, output); @@ -404,11 +402,6 @@ namespace internal { LabelIndexRange& output, ProbabilitiesRanges& probabilities) { - output.resize (input.size()); - probabilities.resize (labels.size()); - for (std::size_t i = 0; i < probabilities.size(); ++ i) - probabilities[i].resize (input.size()); - internal::Classify_detailed_output_functor f (labels, classifier, output, probabilities); @@ -473,8 +466,6 @@ namespace internal { const NeighborQuery& neighbor_query, LabelIndexRange& output) { - output.resize(input.size()); - std::vector > values (labels.size(), std::vector (input.size(), -1.)); internal::Classify_functor_local_smoothing_preprocessing diff --git a/Classification/test/Classification/test_classification_io.cpp b/Classification/test/Classification/test_classification_io.cpp index bb1d770e47c..a9c9173d7b6 100644 --- a/Classification/test/Classification/test_classification_io.cpp +++ b/Classification/test/Classification/test_classification_io.cpp @@ -89,9 +89,9 @@ int main (int, char**) Classifier classifier3 (classifier, features); - std::vector label_indices; - std::vector label_indices_2; - std::vector label_indices_3; + std::vector label_indices (points.size()); + std::vector label_indices_2 (points.size()); + std::vector label_indices_3 (points.size()); Classification::classify (points, labels, classifier, label_indices); Classification::classify (points, labels, classifier2, label_indices_2); diff --git a/Polyhedron/demo/Polyhedron/Plugins/Classification/Cluster_classification.cpp b/Polyhedron/demo/Polyhedron/Plugins/Classification/Cluster_classification.cpp index b9e01c89204..6dce115eb68 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Classification/Cluster_classification.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Classification/Cluster_classification.cpp @@ -796,6 +796,9 @@ void Cluster_classification::train(int classifier, const QMultipleInputDialog& d reset_indices(); m_label_probabilities.clear(); + m_label_probabilities.resize (m_labels.size()); + for (std::size_t i = 0; i < m_label_probabilities.size(); ++ i) + m_label_probabilities[i].resize (m_clusters.size(), -1); std::vector nb_label (m_labels.size(), 0); std::size_t nb_total = 0; diff --git a/Polyhedron/demo/Polyhedron/Plugins/Classification/Point_set_item_classification.cpp b/Polyhedron/demo/Polyhedron/Plugins/Classification/Point_set_item_classification.cpp index ee308ac5e11..6273425fb8e 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Classification/Point_set_item_classification.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Classification/Point_set_item_classification.cpp @@ -707,7 +707,10 @@ void Point_set_item_classification::train(int classifier, const QMultipleInputDi reset_indices(); m_label_probabilities.clear(); - + m_label_probabilities.resize (m_labels.size()); + for (std::size_t i = 0; i < m_label_probabilities.size(); ++ i) + m_label_probabilities[i].resize (m_points->point_set()->size(), -1); + std::vector training (m_points->point_set()->size(), -1); std::vector indices (m_points->point_set()->size(), -1); diff --git a/Polyhedron/demo/Polyhedron/Plugins/Classification/Surface_mesh_item_classification.cpp b/Polyhedron/demo/Polyhedron/Plugins/Classification/Surface_mesh_item_classification.cpp index e04bc8330c1..3f6fdcec51f 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Classification/Surface_mesh_item_classification.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Classification/Surface_mesh_item_classification.cpp @@ -252,6 +252,9 @@ void Surface_mesh_item_classification::train (int classifier, const QMultipleInp } m_label_probabilities.clear(); + m_label_probabilities.resize (m_labels.size()); + for (std::size_t i = 0; i < m_label_probabilities.size(); ++ i) + m_label_probabilities[i].resize (num_faces(*(m_mesh->polyhedron()))); std::vector training (num_faces(*(m_mesh->polyhedron())), std::size_t(-1)); std::vector indices (num_faces(*(m_mesh->polyhedron())), std::size_t(-1));