diff --git a/Classification/include/CGAL/Classification/Attribute/Distance_to_plane.h b/Classification/include/CGAL/Classification/Attribute/Distance_to_plane.h index e0182799f2b..dbadba62d03 100644 --- a/Classification/include/CGAL/Classification/Attribute/Distance_to_plane.h +++ b/Classification/include/CGAL/Classification/Attribute/Distance_to_plane.h @@ -72,7 +72,7 @@ public: this->set_weight(1.); for(std::size_t i = 0; i < input.size(); i++) distance_to_plane_attribute.push_back - (CGAL::sqrt (CGAL::squared_distance (get(point_map, input[i]), eigen.plane(i)))); + (CGAL::sqrt (CGAL::squared_distance (get(point_map, *(input.begin()+i)), eigen.plane(i)))); this->compute_mean_max (distance_to_plane_attribute, this->mean, this->max); // max *= 2; diff --git a/Classification/include/CGAL/Classification/Attribute/Echo_scatter.h b/Classification/include/CGAL/Classification/Attribute/Echo_scatter.h index d1cc9015498..2085d64893a 100644 --- a/Classification/include/CGAL/Classification/Attribute/Echo_scatter.h +++ b/Classification/include/CGAL/Classification/Attribute/Echo_scatter.h @@ -85,7 +85,7 @@ public: for(std::size_t t=0; t 1) + if(get(echo_map, *(input.begin()+ip)) > 1) NB_echo_sup++; } diff --git a/Classification/include/CGAL/Classification/Attribute/Elevation.h b/Classification/include/CGAL/Classification/Attribute/Elevation.h index b6a1520f8e0..36a35138740 100644 --- a/Classification/include/CGAL/Classification/Attribute/Elevation.h +++ b/Classification/include/CGAL/Classification/Attribute/Elevation.h @@ -92,7 +92,7 @@ public: continue; double mean = 0.; for (std::size_t k = 0; k < grid.indices(i,j).size(); ++ k) - mean += get(point_map, input[grid.indices(i,j)[k]]).z(); + mean += get(point_map, *(input.begin()+grid.indices(i,j)[k])).z(); mean /= grid.indices(i,j).size(); dem(i,j) = mean; } @@ -146,7 +146,7 @@ public: for (std::size_t i = 0; i < input.size(); i++){ std::size_t I = grid.x(i); std::size_t J = grid.y(i); - elevation_attribute.push_back ((double)(get(point_map, input[i]).z()-dtm(I,J))); + elevation_attribute.push_back ((double)(get(point_map, *(input.begin()+i)).z()-dtm(I,J))); } this->compute_mean_max (elevation_attribute, this->mean, this->max); diff --git a/Classification/include/CGAL/Classification/Attribute/Hsv.h b/Classification/include/CGAL/Classification/Attribute/Hsv.h index a9a3b436183..ab2ba69645c 100644 --- a/Classification/include/CGAL/Classification/Attribute/Hsv.h +++ b/Classification/include/CGAL/Classification/Attribute/Hsv.h @@ -85,7 +85,7 @@ public: this->set_weight(1.); for(std::size_t i = 0; i < input.size();i++) { - HSV_Color c = Classification::rgb_to_hsv (get(color_map, input[i])); + HSV_Color c = Classification::rgb_to_hsv (get(color_map, *(input.begin()+i))); color_attribute.push_back (std::exp (-(c[channel] - mean) * (c[channel] - mean) / (2. * sd * sd))); } this->compute_mean_max (color_attribute, this->mean, this->max); diff --git a/Classification/include/CGAL/Classification/Attribute/Vertical_dispersion.h b/Classification/include/CGAL/Classification/Attribute/Vertical_dispersion.h index b895fdc01f1..d41dcf262cb 100644 --- a/Classification/include/CGAL/Classification/Attribute/Vertical_dispersion.h +++ b/Classification/include/CGAL/Classification/Attribute/Vertical_dispersion.h @@ -105,7 +105,7 @@ public: for(std::size_t t=0; t + #include namespace CGAL { diff --git a/Classification/include/CGAL/Classification/Local_eigen_analysis.h b/Classification/include/CGAL/Classification/Local_eigen_analysis.h index 6ec812c319a..828339536da 100644 --- a/Classification/include/CGAL/Classification/Local_eigen_analysis.h +++ b/Classification/include/CGAL/Classification/Local_eigen_analysis.h @@ -83,16 +83,16 @@ public: for (std::size_t i = 0; i < input.size(); i++) { std::vector neighbors; - neighbor_query (get(point_map, input[i]), std::back_inserter (neighbors)); + neighbor_query (get(point_map, *(input.begin()+i)), std::back_inserter (neighbors)); std::vector neighbor_points; for (std::size_t j = 0; j < neighbors.size(); ++ j) - neighbor_points.push_back (get(point_map, input[neighbors[j]])); + neighbor_points.push_back (get(point_map, *(input.begin()+neighbors[j]))); - m_mean_range += CGAL::sqrt (CGAL::squared_distance (get(point_map, input[i]), - get(point_map, input[neighbors.back()]))); + m_mean_range += CGAL::sqrt (CGAL::squared_distance (get(point_map, *(input.begin() + i)), + get(point_map, *(input.begin() + neighbors.back())))); - compute (get(point_map, input[i]), neighbor_points); + compute (get(point_map, *(input.begin()+i)), neighbor_points); } m_mean_range /= input.size(); diff --git a/Classification/include/CGAL/Classification/Planimetric_grid.h b/Classification/include/CGAL/Classification/Planimetric_grid.h index 804c68b608a..e1384f3a435 100644 --- a/Classification/include/CGAL/Classification/Planimetric_grid.h +++ b/Classification/include/CGAL/Classification/Planimetric_grid.h @@ -67,7 +67,7 @@ public: for (std::size_t i = 0; i < input.size(); ++ i) { - const Point_3& p = get(point_map, input[i]); + const Point_3& p = get(point_map, *(input.begin()+i)); m_x.push_back ((std::size_t)((p.x() - bbox.xmin()) / grid_resolution)); m_y.push_back ((std::size_t)((p.y() - bbox.ymin()) / grid_resolution)); m_grid(m_x.back(), m_y.back()).push_back (i); diff --git a/Classification/include/CGAL/Classification/Point_set_neighborhood.h b/Classification/include/CGAL/Classification/Point_set_neighborhood.h index 3469faf599e..0505cc743d2 100644 --- a/Classification/include/CGAL/Classification/Point_set_neighborhood.h +++ b/Classification/include/CGAL/Classification/Point_set_neighborhood.h @@ -57,7 +57,7 @@ class Point_set_neighborhood My_point_property_map () { } My_point_property_map (const Range *input, PointMap point_map) : input (input), point_map (point_map) { } - reference operator[] (key_type k) const { return get(point_map, (*input)[k]); } + reference operator[] (key_type k) const { return get(point_map, *(input->begin()+k)); } friend inline reference get (const My_point_property_map& ppmap, key_type i) { return ppmap[i]; } }; diff --git a/Classification/include/CGAL/Classification/Type.h b/Classification/include/CGAL/Classification/Type.h index d5959307f62..2a82a9c877c 100644 --- a/Classification/include/CGAL/Classification/Type.h +++ b/Classification/include/CGAL/Classification/Type.h @@ -3,6 +3,8 @@ #include +#include + namespace CGAL { namespace Classification { diff --git a/Classification/include/CGAL/Classifier.h b/Classification/include/CGAL/Classifier.h index 9d77befb1d1..5289635c63b 100644 --- a/Classification/include/CGAL/Classifier.h +++ b/Classification/include/CGAL/Classifier.h @@ -215,7 +215,7 @@ public: for (std::size_t s=0; s < m_input.size(); ++ s) { std::vector neighbors; - neighbor_query (get (m_item_map, m_input[s]), std::back_inserter (neighbors)); + neighbor_query (get (m_item_map, *(m_input.begin()+s)), std::back_inserter (neighbors)); std::vector mean (values.size(), 0.); for (std::size_t n = 0; n < neighbors.size(); ++ n) @@ -286,7 +286,7 @@ public: { std::vector neighbors; - neighbor_query (get(m_item_map, m_input[s]), std::back_inserter (neighbors)); + neighbor_query (get(m_item_map, *(m_input.begin()+s)), std::back_inserter (neighbors)); for (std::size_t i = 0; i < neighbors.size(); ++ i) if (s != neighbors[i]) @@ -818,8 +818,8 @@ public: \tparam IndexRange range of `std::size_t`, model of `ConstRange`. */ template - bool add_training_set (Type_handle class_type, - IndexRange indices) + bool set_inliers (Type_handle class_type, + IndexRange indices) { std::size_t type_idx = (std::size_t)(-1); for (std::size_t i = 0; i < m_types.size(); ++ i) diff --git a/Classification/include/CGAL/Point_set_classifier.h b/Classification/include/CGAL/Point_set_classifier.h index 99b4e4a4c8b..eefb4ef399c 100644 --- a/Classification/include/CGAL/Point_set_classifier.h +++ b/Classification/include/CGAL/Point_set_classifier.h @@ -324,6 +324,9 @@ public: for (std::size_t i = 0; i < m_scales.size(); ++ i) delete m_scales[i]; m_scales.clear(); + + this->clear_classification_types(); + this->clear_attributes(); } /*! diff --git a/Polyhedron/demo/Polyhedron/Plugins/Point_set/Point_set_classification_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/Point_set/Point_set_classification_plugin.cpp index 0c0821b28c9..607cc58764a 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Point_set/Point_set_classification_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Point_set/Point_set_classification_plugin.cpp @@ -279,7 +279,7 @@ public Q_SLOTS: // Add types for (std::size_t i = 0; i < item->types().size(); ++ i) - add_new_class (ClassRow (dock_widget, item->types()[i].first->id().c_str(), + add_new_class (ClassRow (dock_widget, item->types()[i].first->name().c_str(), item->types()[i].second)); // Enabled classif if features computed @@ -797,11 +797,11 @@ public Q_SLOTS: for (std::size_t i = 0; i < classification_item->types().size(); ++ i) { - CGAL::Classification::Type::Attribute_effect + CGAL::Classification::Attribute::Effect eff = classification_item->types()[i].first->attribute_effect(att); - if (eff == CGAL::Classification::Type::PENALIZING) + if (eff == CGAL::Classification::Attribute::PENALIZING) class_rows[i].effect->setCurrentIndex(0); - else if (eff == CGAL::Classification::Type::NEUTRAL) + else if (eff == CGAL::Classification::Attribute::NEUTRAL) class_rows[i].effect->setCurrentIndex(1); else class_rows[i].effect->setCurrentIndex(2); @@ -824,7 +824,7 @@ public Q_SLOTS: if (att == Scene_point_set_classification_item::Attribute_handle()) return; - att->weight() = std::tan ((CGAL_PI/2.) * v / 1001.); + att->set_weight(std::tan ((CGAL_PI/2.) * v / 1001.)); // std::cerr << att->weight << std::endl; for (std::size_t i = 0; i < class_rows.size(); ++ i) @@ -854,19 +854,19 @@ public Q_SLOTS: if (v == 0) { classification_item->types()[i].first->set_attribute_effect - (att, CGAL::Classification::Type::PENALIZING); + (att, CGAL::Classification::Attribute::PENALIZING); // std::cerr << " penalized for "; } else if (v == 1) { classification_item->types()[i].first->set_attribute_effect - (att, CGAL::Classification::Type::NEUTRAL); + (att, CGAL::Classification::Attribute::NEUTRAL); // std::cerr << " neutral for "; } else { classification_item->types()[i].first->set_attribute_effect - (att, CGAL::Classification::Type::FAVORING); + (att, CGAL::Classification::Attribute::FAVORING); // std::cerr << " favored for "; } // std::cerr << classification_item->types()[i].first->id() << std::endl; diff --git a/Polyhedron/demo/Polyhedron/Scene_point_set_classification_item.cpp b/Polyhedron/demo/Polyhedron/Scene_point_set_classification_item.cpp index 07c981ee48f..3fd48a2dbe2 100644 --- a/Polyhedron/demo/Polyhedron/Scene_point_set_classification_item.cpp +++ b/Polyhedron/demo/Polyhedron/Scene_point_set_classification_item.cpp @@ -18,8 +18,7 @@ Scene_point_set_classification_item::Scene_point_set_classification_item(PSC* psc) : Scene_item(NbOfVbos,NbOfVaos), m_points (NULL), - m_psc (psc), - m_helper (NULL) + m_psc (psc) { setRenderingMode(PointsPlusNormals); m_nb_scales = 5; @@ -34,8 +33,7 @@ Scene_point_set_classification_item::Scene_point_set_classification_item(PSC* ps Scene_point_set_classification_item::Scene_point_set_classification_item(Scene_points_with_normal_item* points) : Scene_item(NbOfVbos,NbOfVaos), m_points (points), - m_psc (NULL), - m_helper (NULL) + m_psc (NULL) { setRenderingMode(PointsPlusNormals); m_nb_scales = 5; @@ -45,7 +43,7 @@ Scene_point_set_classification_item::Scene_point_set_classification_item(Scene_p reset_indices(); - m_psc = new PSC(m_points->point_set()->begin(), m_points->point_set()->end(), m_points->point_set()->point_map()); + m_psc = new PSC(*(m_points->point_set()), m_points->point_set()->point_map()); Type_handle ground = m_psc->add_classification_type("ground"); Type_handle vegetation = m_psc->add_classification_type("vegetation"); @@ -66,8 +64,7 @@ Scene_point_set_classification_item::Scene_point_set_classification_item(Scene_p Scene_point_set_classification_item::Scene_point_set_classification_item(const Scene_point_set_classification_item&) :Scene_item(NbOfVbos,NbOfVaos), // do not call superclass' copy constructor m_points (NULL), - m_psc (NULL), - m_helper (NULL) + m_psc (NULL) { setRenderingMode(PointsPlusNormals); m_nb_scales = 5; @@ -83,8 +80,6 @@ Scene_point_set_classification_item::~Scene_point_set_classification_item() { if (m_psc != NULL) delete m_psc; - if (m_helper != NULL) - delete m_helper; } void Scene_point_set_classification_item::initializeBuffers(CGAL::Three::Viewer_interface *viewer) const @@ -263,7 +258,7 @@ void Scene_point_set_classification_item::compute_normals_and_vertices() const { Attribute_handle att = m_psc->get_attribute(index_color - 3); double weight = att->weight(); - att->weight() = att->max; + att->set_weight(att->max); for (Point_set::const_iterator it = m_points->point_set()->begin(); it != m_points->point_set()->first_selected(); ++ it) { @@ -271,7 +266,7 @@ void Scene_point_set_classification_item::compute_normals_and_vertices() const colors_points.push_back (ramp.g(att->normalized(*it))); colors_points.push_back (ramp.b(att->normalized(*it))); } - att->weight() = weight; + att->set_weight(weight); } for (Point_set::const_iterator it = m_points->point_set()->first_selected(); @@ -294,9 +289,9 @@ Scene_point_set_classification_item::clone() const // Write point set to .PLY file bool Scene_point_set_classification_item::write_ply_point_set(std::ostream& stream) { - if (m_helper == NULL) + if (m_psc->number_of_attributes() == 0) return false; - + stream.precision (std::numeric_limits::digits10 + 2); reset_indices(); @@ -310,12 +305,7 @@ bool Scene_point_set_classification_item::write_ply_point_set(std::ostream& stre colors.push_back (c); } - m_helper->write_ply (stream, - m_points->point_set()->begin(), - m_points->point_set()->end(), - m_points->point_set()->point_map(), - *m_psc, - &colors); + m_psc->write_classification_to_ply (stream); return true; } @@ -448,10 +438,8 @@ int Scene_point_set_classification_item::real_index_color() const void Scene_point_set_classification_item::reset_indices () { - Point_set::Property_map indices; - - boost::tie (indices, boost::tuples::ignore) - = m_points->point_set()->property_map("index"); + Point_set::Property_map indices + = m_points->point_set()->property_map("index").first; m_points->point_set()->unselect_all(); Point_set::Index idx; @@ -468,44 +456,32 @@ void Scene_point_set_classification_item::compute_features () reset_indices(); std::cerr << "Computing features with " << m_nb_scales << " scale(s)" << std::endl; + if (m_psc->number_of_attributes() != 0) + m_psc->clear(); compute_bbox(); - if (m_helper != NULL) delete m_helper; - - - m_helper = new Helper (m_points->point_set()->begin(), - m_points->point_set()->end(), - m_points->point_set()->point_map(), - m_nb_scales); - - m_helper->generate_point_based_attributes (*m_psc, - m_points->point_set()->begin(), - m_points->point_set()->end(), - m_points->point_set()->point_map()); - - if (m_points->point_set()->has_normal_map()) - m_helper->generate_normal_based_attributes (*m_psc, - m_points->point_set()->begin(), - m_points->point_set()->end(), - m_points->point_set()->normal_map()); - else - m_helper->generate_normal_based_attributes (*m_psc, - m_points->point_set()->begin(), - m_points->point_set()->end()); + bool normals = m_points->point_set()->has_normal_map(); + bool colors = m_points->point_set()->has_colors(); Point_set::Property_map echo_map; - bool okay; - boost::tie (echo_map, okay) = m_points->point_set()->template property_map("echo"); - if (okay) - m_helper->generate_echo_based_attributes (*m_psc, - m_points->point_set()->begin(), - m_points->point_set()->end(), - echo_map); + bool echo; + boost::tie (echo_map, echo) = m_points->point_set()->template property_map("echo"); - if (m_points->point_set()->has_colors()) - m_helper->generate_color_based_attributes (*m_psc, - m_points->point_set()->begin(), - m_points->point_set()->end(), - Color_map(m_points->point_set())); + if (!normals && !colors && !echo) + m_psc->generate_attributes (m_nb_scales); + else if (!normals && !colors && echo) + m_psc->generate_attributes (m_nb_scales, CGAL::Default(), CGAL::Default(), echo_map); + else if (!normals && colors && !echo) + m_psc->generate_attributes (m_nb_scales, CGAL::Default(), Color_map(m_points->point_set())); + else if (!normals && colors && echo) + m_psc->generate_attributes (m_nb_scales, CGAL::Default(), Color_map(m_points->point_set()), echo_map); + else if (normals && !colors && !echo) + m_psc->generate_attributes (m_nb_scales, m_points->point_set()->normal_map()); + else if (normals && !colors && echo) + m_psc->generate_attributes (m_nb_scales, m_points->point_set()->normal_map(), CGAL::Default(), echo_map); + else if (normals && colors && !echo) + m_psc->generate_attributes (m_nb_scales, m_points->point_set()->normal_map(), Color_map(m_points->point_set())); + else + m_psc->generate_attributes (m_nb_scales, m_points->point_set()->normal_map(), Color_map(m_points->point_set()), echo_map); } @@ -513,7 +489,7 @@ void Scene_point_set_classification_item::compute_features () void Scene_point_set_classification_item::train() { - if (m_helper == NULL) + if (m_psc->number_of_attributes() == 0) { std::cerr << "Error: features not computed" << std::endl; return; @@ -521,13 +497,12 @@ void Scene_point_set_classification_item::train() m_psc->train(m_nb_trials); m_psc->run(); - m_helper->info(); - + m_psc->info(); } bool Scene_point_set_classification_item::run (int method) { - if (m_helper == NULL) + if (m_psc->number_of_attributes() == 0) { std::cerr << "Error: features not computed" << std::endl; return false; @@ -537,9 +512,9 @@ bool Scene_point_set_classification_item::run (int method) if (method == 0) m_psc->run(); else if (method == 1) - m_psc->run_with_local_smoothing (m_helper->neighborhood().range_neighbor_query(m_helper->radius_neighbors())); + m_psc->run_with_local_smoothing (m_psc->neighborhood().range_neighbor_query(m_psc->radius_neighbors())); else if (method == 2) - m_psc->run_with_graphcut (m_helper->neighborhood().k_neighbor_query(12), m_smoothing); + m_psc->run_with_graphcut (m_psc->neighborhood().k_neighbor_query(12), m_smoothing); invalidateOpenGLBuffers(); Q_EMIT itemChanged(); diff --git a/Polyhedron/demo/Polyhedron/Scene_point_set_classification_item.h b/Polyhedron/demo/Polyhedron/Scene_point_set_classification_item.h index 3abe0b8a86f..22da4645bb5 100644 --- a/Polyhedron/demo/Polyhedron/Scene_point_set_classification_item.h +++ b/Polyhedron/demo/Polyhedron/Scene_point_set_classification_item.h @@ -2,16 +2,16 @@ #define POINT_SET_CLASSIFICATION_ITEM_H #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + #include "Scene_point_set_classification_item_config.h" #include "Scene_points_with_normal_item.h" @@ -62,19 +62,17 @@ class SCENE_POINT_SET_CLASSIFICATION_ITEM_EXPORT Scene_point_set_classification_ typedef Kernel::Vector_3 Vector_3; typedef CGAL::Classification::RGB_Color Color; - typedef Point_set::iterator Iterator; typedef Point_set::Point_map Point_map; typedef Point_set::Vector_map Vector_map; typedef Point_set_color_map Color_map; - typedef CGAL::Classifier PSC; - typedef CGAL::Classification::Helper Helper; + typedef CGAL::Point_set_classifier PSC; typedef CGAL::Classification::Type_handle Type_handle; typedef CGAL::Classification::Attribute_handle Attribute_handle; - typedef CGAL::Classification::Attribute_vertical_dispersion Dispersion; - typedef CGAL::Classification::Attribute_elevation Elevation; - typedef CGAL::Classification::Attribute_verticality Verticality; - typedef CGAL::Classification::Attribute_distance_to_plane Distance_to_plane; + typedef CGAL::Classification::Attribute::Vertical_dispersion Dispersion; + typedef CGAL::Classification::Attribute::Elevation Elevation; + typedef CGAL::Classification::Attribute::Verticality Verticality; + typedef CGAL::Classification::Attribute::Distance_to_plane Distance_to_plane; public: @@ -126,7 +124,7 @@ class SCENE_POINT_SET_CLASSIFICATION_ITEM_EXPORT Scene_point_set_classification_ for (std::size_t i = 0; i < m_types.size(); ++ i) { items.push_back (new Item); - items.back()->setName (QString("%1 (%2)").arg(name).arg(m_types[i].first->id().c_str())); + items.back()->setName (QString("%1 (%2)").arg(name).arg(m_types[i].first->name().c_str())); items.back()->setColor (m_types[i].second); map_types[m_types[i].first] = i; } @@ -162,7 +160,7 @@ class SCENE_POINT_SET_CLASSIFICATION_ITEM_EXPORT Scene_point_set_classification_ Type_handle get_classification_type (const char* name) { for (std::size_t i = 0; i < m_types.size(); ++ i) - if (m_types[i].first->id() == name) + if (m_types[i].first->name() == name) return m_types[i].first; return Type_handle(); } @@ -178,9 +176,9 @@ class SCENE_POINT_SET_CLASSIFICATION_ITEM_EXPORT Scene_point_set_classification_ it != m_points->point_set()->end(); ++ it) m_psc->set_classification_type_of(*it, class_type); - m_psc->add_training_set(class_type, - m_points->point_set()->first_selected(), - m_points->point_set()->end()); + m_psc->set_inliers(class_type, + boost::make_iterator_range(m_points->point_set()->first_selected(), + m_points->point_set()->end())); m_points->resetSelection(); } @@ -193,7 +191,7 @@ class SCENE_POINT_SET_CLASSIFICATION_ITEM_EXPORT Scene_point_set_classification_ it != m_points->point_set()->end(); ++ it) { Type_handle t = m_psc->classification_type_of(*it); - m_psc->add_training_index (t, *it); + m_psc->set_inlier (t, *it); } m_points->resetSelection(); @@ -202,7 +200,7 @@ class SCENE_POINT_SET_CLASSIFICATION_ITEM_EXPORT Scene_point_set_classification_ double& smoothing() { return m_smoothing; } std::size_t& nb_scales() { return m_nb_scales; } std::size_t& number_of_trials() { return m_nb_trials; } - bool features_computed() const { return (m_helper != NULL); } + bool features_computed() const { return (m_psc->number_of_attributes() != 0); } std::vector >& types() { return m_types; } std::size_t number_of_attributes() const { return m_psc->number_of_attributes(); } @@ -216,7 +214,7 @@ class SCENE_POINT_SET_CLASSIFICATION_ITEM_EXPORT Scene_point_set_classification_ void remove_type (const char* name) { for (std::size_t i = 0; i < m_types.size(); ++ i) - if (m_types[i].first->id() == name) + if (m_types[i].first->name() == name) { m_psc->remove_classification_type (m_types[i].first); m_types.erase (m_types.begin() + i); @@ -229,7 +227,7 @@ class SCENE_POINT_SET_CLASSIFICATION_ITEM_EXPORT Scene_point_set_classification_ void change_type_color (const char* name, const QColor& color) { for (std::size_t i = 0; i < m_types.size(); ++ i) - if (m_types[i].first->id() == name) + if (m_types[i].first->name() == name) { m_types[i].second = color; break; @@ -241,9 +239,9 @@ class SCENE_POINT_SET_CLASSIFICATION_ITEM_EXPORT Scene_point_set_classification_ { for (std::size_t i = 0; i < m_psc->number_of_attributes(); ++ i) { - std::size_t scale = m_helper->scale_of_attribute(m_psc->get_attribute(i)); + std::size_t scale = m_psc->scale_of_attribute(m_psc->get_attribute(i)); std::ostringstream oss; - oss << "Attribute " << m_psc->get_attribute(i)->id() << "_" << scale; + oss << "Attribute " << m_psc->get_attribute(i)->name() << "_" << scale; cb->addItem (oss.str().c_str()); cb1->addItem (oss.str().c_str()); } @@ -251,23 +249,21 @@ class SCENE_POINT_SET_CLASSIFICATION_ITEM_EXPORT Scene_point_set_classification_ void save_config(const char* filename) { - if (m_helper == NULL) + if (m_psc->number_of_attributes() == 0) { std::cerr << "Error: features not computed" << std::endl; return; } std::ofstream f (filename); - m_helper->save (f, *m_psc); + m_psc->save_configuration (f); } void load_config(const char* filename) { - if (m_helper != NULL) - delete m_helper; + if (m_psc->number_of_attributes() != 0) + m_psc->clear(); - m_psc->clear_classification_types(); - m_psc->clear_attributes(); reset_indices(); bool normals = m_points->point_set()->has_normal_map(); @@ -278,62 +274,21 @@ class SCENE_POINT_SET_CLASSIFICATION_ITEM_EXPORT Scene_point_set_classification_ std::ifstream f (filename); if (!normals && !colors && !echo) - m_helper = new Helper (f, *m_psc, - m_points->point_set()->begin(), - m_points->point_set()->end(), - m_points->point_set()->point_map()); + m_psc->load_configuration (f); else if (!normals && !colors && echo) - m_helper = new Helper (f, *m_psc, - m_points->point_set()->begin(), - m_points->point_set()->end(), - m_points->point_set()->point_map(), - CGAL::Empty_property_map(), - CGAL::Empty_property_map(), - echo_map); + m_psc->load_configuration (f, CGAL::Default(), CGAL::Default(), echo_map); else if (!normals && colors && !echo) - m_helper = new Helper (f, *m_psc, - m_points->point_set()->begin(), - m_points->point_set()->end(), - m_points->point_set()->point_map(), - CGAL::Empty_property_map(), - Color_map(m_points->point_set())); + m_psc->load_configuration (f, CGAL::Default(), Color_map(m_points->point_set())); else if (!normals && colors && echo) - m_helper = new Helper (f, *m_psc, - m_points->point_set()->begin(), - m_points->point_set()->end(), - m_points->point_set()->point_map(), - CGAL::Empty_property_map(), - Color_map(m_points->point_set()), - echo_map); + m_psc->load_configuration (f, CGAL::Default(), Color_map(m_points->point_set()), echo_map); else if (normals && !colors && !echo) - m_helper = new Helper (f, *m_psc, - m_points->point_set()->begin(), - m_points->point_set()->end(), - m_points->point_set()->point_map(), - m_points->point_set()->normal_map()); + m_psc->load_configuration (f, m_points->point_set()->normal_map()); else if (normals && !colors && echo) - m_helper = new Helper (f, *m_psc, - m_points->point_set()->begin(), - m_points->point_set()->end(), - m_points->point_set()->point_map(), - m_points->point_set()->normal_map(), - CGAL::Empty_property_map(), - echo_map); + m_psc->load_configuration (f, m_points->point_set()->normal_map(), CGAL::Default(), echo_map); else if (normals && colors && !echo) - m_helper = new Helper (f, *m_psc, - m_points->point_set()->begin(), - m_points->point_set()->end(), - m_points->point_set()->point_map(), - m_points->point_set()->normal_map(), - CGAL::Empty_property_map()); + m_psc->load_configuration (f, m_points->point_set()->normal_map(), Color_map(m_points->point_set())); else - m_helper = new Helper (f, *m_psc, - m_points->point_set()->begin(), - m_points->point_set()->end(), - m_points->point_set()->point_map(), - m_points->point_set()->normal_map(), - Color_map(m_points->point_set()), - echo_map); + m_psc->load_configuration (f, m_points->point_set()->normal_map(), Color_map(m_points->point_set()), echo_map); std::vector > new_types; for (std::size_t i = 0; i < m_psc->number_of_classification_types(); ++ i) @@ -344,7 +299,7 @@ class SCENE_POINT_SET_CLASSIFICATION_ITEM_EXPORT Scene_point_set_classification_ 192 + rand() % 60); for (std::size_t j = 0; j < m_types.size(); ++ j) - if (t->id() == m_types[j].first->id()) + if (t->name() == m_types[j].first->name()) { color = m_types[j].second; break; @@ -362,7 +317,6 @@ class SCENE_POINT_SET_CLASSIFICATION_ITEM_EXPORT Scene_point_set_classification_ Scene_points_with_normal_item* m_points; PSC* m_psc; - Helper* m_helper; std::size_t m_nb_scales;