Factorize has_normals() methods

This commit is contained in:
Simon Giraudot 2016-09-09 15:03:23 +02:00
parent f9cdfbdfd9
commit a8afefb44d
8 changed files with 25 additions and 46 deletions

View File

@ -243,7 +243,6 @@ void Polyhedron_demo_point_set_normal_estimation_plugin::on_actionNormalEstimati
<< std::endl;
}
item->set_has_normals(true);
item->setRenderingMode(PointsPlusNormals);
//***************************************
@ -262,12 +261,6 @@ void Polyhedron_demo_point_set_normal_estimation_plugin::on_actionNormalEstimati
points->normal_pmap(),
dialog.orient_neighbors(), k);
//indicates that the point set has normals
if (first_unoriented_point != points->begin_or_selection_begin()){
item->set_has_normals(true);
item->setRenderingMode(PointsPlusNormals);
}
std::size_t nb_unoriented_normals = std::distance(first_unoriented_point, points->end());
std::size_t memory = CGAL::Memory_sizer().virtual_size();
std::cerr << "Orient normals: " << nb_unoriented_normals << " point(s) with an unoriented normal are selected ("

View File

@ -466,7 +466,8 @@ public Q_SLOTS:
QApplication::setOverrideCursor(Qt::WaitCursor);
Scene_points_with_normal_item* new_item = new Scene_points_with_normal_item();
new_item->setName(QString("%1 (selected points)").arg(point_set_item->name()));
new_item->set_has_normals (point_set_item->has_normals());
if (point_set_item->has_normals())
new_item->point_set()->add_normal_property();
new_item->setColor(point_set_item->color());
new_item->setRenderingMode(point_set_item->renderingMode());
new_item->setVisible(point_set_item->visible());
@ -475,7 +476,13 @@ public Q_SLOTS:
for(Point_set::iterator it = point_set_item->point_set()->begin ();
it != point_set_item->point_set()->end(); ++ it) {
if (point_set_item->point_set()->is_selected (it))
new_item->point_set()->push_back(point_set_item->point_set()->point(*it));
{
if (point_set_item->has_normals())
new_item->point_set()->push_back(point_set_item->point_set()->point(*it),
point_set_item->point_set()->normal(*it));
else
new_item->point_set()->push_back(point_set_item->point_set()->point(*it));
}
}
new_item->resetSelection();
new_item->invalidateOpenGLBuffers();

View File

@ -204,6 +204,7 @@ void Polyhedron_demo_point_set_shape_detection_plugin::on_actionDetect_triggered
}
Scene_points_with_normal_item *point_item = new Scene_points_with_normal_item;
BOOST_FOREACH(std::size_t i, shape->indices_of_assigned_points())
point_item->point_set()->push_back((*points)[i]);
@ -274,7 +275,6 @@ void Polyhedron_demo_point_set_shape_detection_plugin::on_actionDetect_triggered
//names[i] = ss.str(
point_item->setName(QString::fromStdString(ss.str()));
point_item->set_has_normals(true);
point_item->setRenderingMode(item->renderingMode());
if (dialog.generate_subset()){

View File

@ -88,7 +88,7 @@ void Polyhedron_demo_point_set_smoothing_plugin::on_actionJetSmoothing_triggered
points->invalidate_bounds();
// calling jet_smooth_point_set breaks the normals
item->set_has_normals(false);
points->remove_normal_property();
// update scene
item->invalidateOpenGLBuffers();

View File

@ -605,19 +605,12 @@ void Polyhedron_demo_surface_reconstruction_plugin::automatic_reconstruction
Scene_points_with_normal_item* new_item = NULL;
if (!(dialog.interpolate()))
{
new_item = new Scene_points_with_normal_item();
new_item = new Scene_points_with_normal_item(*pts_item);
new_item->setName(QString("%1 (preprocessed)").arg(pts_item->name()));
new_item->set_has_normals (pts_item->has_normals());
new_item->setColor(pts_item->color());
new_item->setRenderingMode(pts_item->renderingMode());
new_item->setVisible(pts_item->visible());
new_item->resetSelection();
new_item->invalidateOpenGLBuffers();
points = new_item->point_set();
std::copy (boost::make_transform_iterator(points->begin_or_selection_begin(), SurfaceReconstruction::Point_set_make_point(*points)),
boost::make_transform_iterator(points->end(), SurfaceReconstruction::Point_set_make_point(*points)),
points->point_back_inserter());
}
std::cerr << "Analysing isotropy of point set... ";
@ -658,7 +651,7 @@ void Polyhedron_demo_surface_reconstruction_plugin::automatic_reconstruction
std::cerr << "Denoising point set... ";
time.restart();
SurfaceReconstruction::smooth_point_set (*points, noise_scale);
new_item->set_has_normals (false);
new_item->point_set()->remove_normal_property();
std::cerr << "ok (" << time.elapsed() << " ms)" << std::endl;
}
@ -725,7 +718,7 @@ void Polyhedron_demo_surface_reconstruction_plugin::automatic_reconstruction
SurfaceReconstruction::compute_normals (*points, noise_scale);
new_item->set_has_normals (true);
new_item->point_set()->add_normal_property();
new_item->setRenderingMode(PointsPlusNormals);
std::cerr << "ok (" << time.elapsed() << " ms)" << std::endl;
@ -883,10 +876,10 @@ void Polyhedron_demo_surface_reconstruction_plugin::poisson_reconstruction
if (!(point_set_item->has_normals()))
{
std::cerr << "Estimation of normal vectors... ";
points->add_normal_property();
SurfaceReconstruction::compute_normals (*points, 12);
point_set_item->set_has_normals (true);
point_set_item->setRenderingMode(PointsPlusNormals);
}

View File

@ -32,8 +32,7 @@
struct Scene_points_with_normal_item_priv
{
Scene_points_with_normal_item_priv(Scene_points_with_normal_item* parent)
:m_points(new Point_set),
m_has_normals(false)
:m_points(new Point_set)
{
item = parent;
nb_points = 0;
@ -47,8 +46,7 @@ struct Scene_points_with_normal_item_priv
point_Slider->setMaximum(25);
}
Scene_points_with_normal_item_priv(const Scene_points_with_normal_item& toCopy, Scene_points_with_normal_item* parent)
: m_points(new Point_set(*toCopy.d->m_points)),
m_has_normals(toCopy.d->m_has_normals)
: m_points(new Point_set(*toCopy.d->m_points))
{
item = parent;
normal_Slider = new QSlider(Qt::Horizontal);
@ -59,8 +57,7 @@ struct Scene_points_with_normal_item_priv
point_Slider->setMaximum(25);
}
Scene_points_with_normal_item_priv(const Polyhedron& input_mesh, Scene_points_with_normal_item* parent)
: m_points(new Point_set),
m_has_normals(true)
: m_points(new Point_set)
{
item = parent;
nb_points = 0;
@ -106,7 +103,6 @@ struct Scene_points_with_normal_item_priv
NbOfVbos
};
Point_set* m_points;
bool m_has_normals;
QAction* actionDeleteSelection;
QAction* actionResetSelection;
QAction* actionSelectDuplicatedPoints;
@ -141,7 +137,7 @@ Scene_points_with_normal_item::Scene_points_with_normal_item(const Scene_points_
{
d = new Scene_points_with_normal_item_priv(toCopy, this);
if (d->m_has_normals)
if (has_normals())
{
setRenderingMode(PointsPlusNormals);
is_selected = true;
@ -286,8 +282,8 @@ void Scene_points_with_normal_item_priv::compute_normals_and_vertices() const
positions_selected_normals.reserve(m_points->nb_selected_points() * 3);
}
//Shuffle container to allow quick display random points
std::random_shuffle (m_points->begin(), m_points->first_selected());
std::random_shuffle (m_points->first_selected(), m_points->end());
// std::random_shuffle (m_points->begin(), m_points->first_selected());
// std::random_shuffle (m_points->first_selected(), m_points->end());
//The points
{
@ -310,8 +306,9 @@ void Scene_points_with_normal_item_priv::compute_normals_and_vertices() const
}
//The lines
if (item->has_normals())
{
// Stock normals
// Store normals
Kernel::Sphere_3 region_of_interest = m_points->region_of_interest();
#ifdef LINK_WITH_TBB
@ -816,16 +813,7 @@ void Scene_points_with_normal_item::setRenderingMode(RenderingMode m)
}
}
bool Scene_points_with_normal_item::has_normals() const { return d->m_has_normals; }
void Scene_points_with_normal_item::set_has_normals(bool b) {
if (b!=d->m_has_normals){
d->m_has_normals=b;
//reset the context menu
defaultContextMenu->deleteLater();
this->defaultContextMenu = 0;
}
}
bool Scene_points_with_normal_item::has_normals() const { return d->m_points->has_normals(); }
void Scene_points_with_normal_item::invalidateOpenGLBuffers()
{

View File

@ -70,7 +70,6 @@ public:
void computes_local_spacing(int k);
bool has_normals() const;
void set_has_normals(bool b);
public Q_SLOTS:
// Delete selection

View File

@ -203,7 +203,6 @@ public:
this->m_indices[i] = i;
}
/// Gets the bounding box.
Iso_cuboid bounding_box() const
{