mirror of https://github.com/CGAL/cgal
Correct Range access (no operator[]) + update Polyhedron plugin
This commit is contained in:
parent
6db1db20c0
commit
9817cadfde
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ public:
|
|||
for(std::size_t t=0; t<grid.indices(k,l).size();t++){
|
||||
|
||||
std::size_t ip = grid.indices(k,l)[t];
|
||||
if(get(echo_map, input[ip]) > 1)
|
||||
if(get(echo_map, *(input.begin()+ip)) > 1)
|
||||
NB_echo_sup++;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -105,7 +105,7 @@ public:
|
|||
for(std::size_t t=0; t<grid.indices(k,l).size();t++)
|
||||
{
|
||||
std::size_t ip = grid.indices(k,l)[t];
|
||||
hori.push_back (get(point_map, input[ip]).z());
|
||||
hori.push_back (get(point_map, *(input.begin()+ip)).z());
|
||||
}
|
||||
if (hori.empty())
|
||||
continue;
|
||||
|
|
|
|||
|
|
@ -98,7 +98,7 @@ public:
|
|||
|
||||
for (std::size_t i = 0; i < input.size(); i++)
|
||||
{
|
||||
typename Kernel::Vector_3 normal = get(normal_map, input[i]);
|
||||
typename Kernel::Vector_3 normal = get(normal_map, *(input.begin()+i));
|
||||
normal = normal / CGAL::sqrt (normal * normal);
|
||||
verticality_attribute.push_back (1. - std::fabs(normal * vertical));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,6 +20,8 @@
|
|||
#ifndef CGAL_CLASSIFICATION_ATTRIBUTE_BASE_H
|
||||
#define CGAL_CLASSIFICATION_ATTRIBUTE_BASE_H
|
||||
|
||||
#include <boost/shared_ptr.hpp>
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace CGAL {
|
||||
|
|
|
|||
|
|
@ -83,16 +83,16 @@ public:
|
|||
for (std::size_t i = 0; i < input.size(); i++)
|
||||
{
|
||||
std::vector<std::size_t> 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<Point> 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();
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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]; }
|
||||
};
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@
|
|||
|
||||
#include <CGAL/Classification/Attribute/Effect.h>
|
||||
|
||||
#include <boost/shared_ptr.hpp>
|
||||
|
||||
namespace CGAL {
|
||||
|
||||
namespace Classification {
|
||||
|
|
|
|||
|
|
@ -215,7 +215,7 @@ public:
|
|||
for (std::size_t s=0; s < m_input.size(); ++ s)
|
||||
{
|
||||
std::vector<std::size_t> 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<double> mean (values.size(), 0.);
|
||||
for (std::size_t n = 0; n < neighbors.size(); ++ n)
|
||||
|
|
@ -286,7 +286,7 @@ public:
|
|||
{
|
||||
std::vector<std::size_t> 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,7 +818,7 @@ public:
|
|||
\tparam IndexRange range of `std::size_t`, model of `ConstRange`.
|
||||
*/
|
||||
template <class IndexRange>
|
||||
bool add_training_set (Type_handle class_type,
|
||||
bool set_inliers (Type_handle class_type,
|
||||
IndexRange indices)
|
||||
{
|
||||
std::size_t type_idx = (std::size_t)(-1);
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
|
||||
/*!
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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,7 +289,7 @@ 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<double>::digits10 + 2);
|
||||
|
|
@ -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<Point_set::Index> indices;
|
||||
|
||||
boost::tie (indices, boost::tuples::ignore)
|
||||
= m_points->point_set()->property_map<Point_set::Index>("index");
|
||||
Point_set::Property_map<Point_set::Index> indices
|
||||
= m_points->point_set()->property_map<Point_set::Index>("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<boost::uint8_t> echo_map;
|
||||
bool okay;
|
||||
boost::tie (echo_map, okay) = m_points->point_set()->template property_map<boost::uint8_t>("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<boost::uint8_t>("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();
|
||||
|
||||
|
|
|
|||
|
|
@ -2,16 +2,16 @@
|
|||
#define POINT_SET_CLASSIFICATION_ITEM_H
|
||||
|
||||
#include <CGAL/Three/Scene_item.h>
|
||||
#include <CGAL/Classifier.h>
|
||||
#include <CGAL/Classification/Attribute.h>
|
||||
#include <CGAL/Classification/Attribute_vertical_dispersion.h>
|
||||
#include <CGAL/Classification/Attribute_elevation.h>
|
||||
#include <CGAL/Classification/Attribute_verticality.h>
|
||||
#include <CGAL/Classification/Attribute_distance_to_plane.h>
|
||||
#include <CGAL/Classification/Attribute_color.h>
|
||||
#include <CGAL/Classification/Attribute_echo_scatter.h>
|
||||
#include <CGAL/Classification/Attributes_eigen.h>
|
||||
#include <CGAL/Classification/Helper.h>
|
||||
#include <CGAL/Point_set_classifier.h>
|
||||
#include <CGAL/Classification/Attribute_base.h>
|
||||
#include <CGAL/Classification/Attribute/Vertical_dispersion.h>
|
||||
#include <CGAL/Classification/Attribute/Elevation.h>
|
||||
#include <CGAL/Classification/Attribute/Verticality.h>
|
||||
#include <CGAL/Classification/Attribute/Distance_to_plane.h>
|
||||
#include <CGAL/Classification/Attribute/Hsv.h>
|
||||
#include <CGAL/Classification/Attribute/Echo_scatter.h>
|
||||
#include <CGAL/Classification/Attribute/Eigen.h>
|
||||
|
||||
|
||||
#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<Point_set> Color_map;
|
||||
|
||||
typedef CGAL::Classifier<Iterator, Point_map> PSC;
|
||||
typedef CGAL::Classification::Helper<Kernel, Iterator, Point_map> Helper;
|
||||
typedef CGAL::Point_set_classifier<Kernel, Point_set, Point_map> PSC;
|
||||
typedef CGAL::Classification::Type_handle Type_handle;
|
||||
typedef CGAL::Classification::Attribute_handle Attribute_handle;
|
||||
typedef CGAL::Classification::Attribute_vertical_dispersion<Kernel, Iterator, Point_map> Dispersion;
|
||||
typedef CGAL::Classification::Attribute_elevation<Kernel, Iterator, Point_map> Elevation;
|
||||
typedef CGAL::Classification::Attribute_verticality<Kernel, Iterator, Point_map> Verticality;
|
||||
typedef CGAL::Classification::Attribute_distance_to_plane<Kernel, Iterator, Point_map> Distance_to_plane;
|
||||
typedef CGAL::Classification::Attribute::Vertical_dispersion<Kernel, Point_set, Point_map> Dispersion;
|
||||
typedef CGAL::Classification::Attribute::Elevation<Kernel, Point_set, Point_map> Elevation;
|
||||
typedef CGAL::Classification::Attribute::Verticality<Kernel, Point_set, Point_map> Verticality;
|
||||
typedef CGAL::Classification::Attribute::Distance_to_plane<Kernel, Point_set, Point_map> 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<std::pair<Type_handle, QColor> >& 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<Iterator, Vector_3>(),
|
||||
CGAL::Empty_property_map<Iterator, Color>(),
|
||||
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<Iterator, Vector_3>(),
|
||||
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<Iterator, Vector_3>(),
|
||||
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<Iterator, Color>(),
|
||||
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<Iterator, Color>());
|
||||
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<std::pair<Type_handle, QColor> > 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;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue