Merge pull request #3681 from maxGimeno/Demo-New_batch_of_bug_fixes-GF

Polyhedron Demo: new batch of bug fixes
This commit is contained in:
Laurent Rineau 2019-02-22 16:39:05 +01:00
commit c334407c46
14 changed files with 78 additions and 44 deletions

View File

@ -2433,7 +2433,7 @@ QString MainWindow::get_item_stats()
{
//1st step : get all classnames of the selected items
QList<QString> classnames;
Q_FOREACH(int id, getSelectedSceneItemIndices())
Q_FOREACH(int id, scene->selectionIndices())
{
QString classname = scene->item(id)->metaObject()->className();
if(!classnames.contains(classname))
@ -2442,7 +2442,7 @@ QString MainWindow::get_item_stats()
//2nd step : separate the selection in lists corresponding to their classname
QVector< QList<Scene_item*> > items;
items.resize(classnames.size());
Q_FOREACH(int id, getSelectedSceneItemIndices())
Q_FOREACH(int id, scene->selectionIndices())
{
Scene_item* s_item = scene->item(id);
for(int i=0; i<items.size(); i++)

View File

@ -7,6 +7,7 @@
#include <QColorDialog>
#include <QPalette>
#include <QColor>
#include <QStyleFactory>
#include <QMessageBox>
#include <CGAL/boost/graph/helpers.h>
@ -25,6 +26,7 @@
#include "triangulate_primitive.h"
#include <CGAL/Buffer_for_vao.h>
#include <CGAL/Three/Triangle_container.h>
#include <CGAL/Dynamic_property_map.h>
#define ARBITRARY_DBL_MIN 1.0E-30
#define ARBITRARY_DBL_MAX 1.0E+30
@ -33,6 +35,7 @@
//Item for heat values
typedef CGAL::Three::Triangle_container Tri;
typedef CGAL::Three::Viewer_interface VI;
class Scene_heat_item
: public CGAL::Three::Scene_item_rendering_helper
{
@ -309,6 +312,8 @@ class DisplayPropertyPlugin :
typedef SMesh::Property_map<boost::graph_traits<SMesh>::vertex_descriptor, double> Vertex_distance_map;
typedef CGAL::Heat_method_3::Surface_mesh_geodesic_distances_3<SMesh> Heat_method;
typedef CGAL::Heat_method_3::Surface_mesh_geodesic_distances_3<SMesh, CGAL::Heat_method_3::Intrinsic_Delaunay> Heat_method_idt;
typedef CGAL::dynamic_vertex_property_t<bool> Vertex_source_tag;
typedef boost::property_map<SMesh, Vertex_source_tag>::type Vertex_source_map;
public:
@ -338,6 +343,8 @@ public:
this->current_item = NULL;
QAction *actionDisplayAngles= new QAction(QString("Display Properties"), mw);
QAction *actionHeatMethod= new QAction(QString("Heat Method"), mw);
actionHeatMethod->setProperty("submenuName", "Color");
rm = 1.0;
rM = 0.0;
@ -350,7 +357,16 @@ public:
if(actionDisplayAngles) {
connect(actionDisplayAngles, SIGNAL(triggered()),
this, SLOT(openDialog()));
if(actionHeatMethod)
{
connect(actionHeatMethod, &QAction::triggered,
this, [this](){
this->dock_widget->propertyBox->setCurrentIndex(2);
this->dock_widget->show();
});
}
_actions << actionDisplayAngles;
_actions << actionHeatMethod;
}
dock_widget = new DockWidget("Property Displaying", mw);
@ -358,10 +374,12 @@ public:
addDockWidget(dock_widget);
QPalette palette(Qt::red);
dock_widget->minColorButton->setPalette(palette);
dock_widget->minColorButton->setStyle(QStyleFactory::create("Fusion"));
dock_widget->minColorButton->update();
palette = QPalette(Qt::green);
dock_widget->maxColorButton->setPalette(palette);
dock_widget->maxColorButton->setStyle(QStyleFactory::create("Fusion"));
dock_widget->maxColorButton->update();
connect(dock_widget->colorizeButton, SIGNAL(clicked(bool)),
this, SLOT(colorize()));
@ -387,6 +405,7 @@ public:
QPalette palette(minColor);
dock_widget->minColorButton->setPalette(palette);
dock_widget->minColorButton->update();
replaceRamp();
});
connect(dock_widget->maxColorButton, &QPushButton::pressed,
this, [this]()
@ -401,6 +420,7 @@ public:
dock_widget->maxColorButton->setPalette(palette);
dock_widget->maxColorButton->update();
replaceRamp();
});
connect(dock_widget->sourcePointsButton, SIGNAL(toggled(bool)),
@ -467,7 +487,6 @@ private Q_SLOTS:
replaceRamp();
item->face_graph()->collect_garbage();
item->face_graph()->collect_garbage();
switch(dock_widget->propertyBox->currentIndex()){
case 0:
displayAngles(item);
@ -553,12 +572,6 @@ private Q_SLOTS:
{
smesh.remove_property_map(angles);
}
SMesh::Property_map<vertex_descriptor, bool> is_source;
boost::tie(is_source, found) = smesh.property_map<vertex_descriptor,bool>("v:heat_source");
if(found)
{
smesh.remove_property_map(is_source);
}
}
void displayScaledJacobian(Scene_surface_mesh_item* item)
@ -777,10 +790,7 @@ private Q_SLOTS:
bool displayHeatIntensity(Scene_surface_mesh_item* item, bool iDT = false)
{
SMesh& mesh = *item->face_graph();
bool found = false;
SMesh::Property_map<vertex_descriptor, bool> is_source ;
boost::tie(is_source, found)=
mesh.property_map<vertex_descriptor,bool>("v:heat_source");
bool found = is_source.find(item) != is_source.end();
if(!found
|| ! source_points
|| source_points->point_set()->is_empty())
@ -832,9 +842,8 @@ private Q_SLOTS:
);
}
// AF: So far we only deal with adding sources
BOOST_FOREACH(vertex_descriptor vd, vertices(mesh)){
if(is_source[vd]){
if(get(is_source[item], vd)){
if(iDT){
hm_idt->add_source(vd);
} else
@ -1098,13 +1107,20 @@ private Q_SLOTS:
source_points=mesh_sources_map[current_item];
}
connect(item, SIGNAL(selected_vertex(void*)), this, SLOT(on_vertex_selected(void*)));
bool non_init;
SMesh::Property_map<vertex_descriptor, bool> is_source;
boost::tie(is_source, non_init) = current_item->face_graph()->add_property_map<vertex_descriptor, bool>("v:heat_source", false);
bool non_init = is_source.find(item) == is_source.end();
if(non_init)
{
Vertex_source_map map = get(Vertex_source_tag(), *item->face_graph());
is_source.insert(std::make_pair(item, map));
connect(item, &Scene_surface_mesh_item::itemChanged,
this, &DisplayPropertyPlugin::resetProperty);
connect(item, &Scene_surface_mesh_item::aboutToBeDestroyed,
[this, item](){
if(is_source.find(item) != is_source.end())
{
is_source.erase(item);
}
});
}
}
else
@ -1121,19 +1137,17 @@ private Q_SLOTS:
typedef boost::graph_traits<SMesh>::vertices_size_type size_type;
size_type h = static_cast<size_type>(reinterpret_cast<std::size_t>(void_ptr));
vertex_descriptor vd = static_cast<vertex_descriptor>(h) ;
bool found;
SMesh::Property_map<vertex_descriptor, bool> is_source;
boost::tie(is_source, found) = current_item->face_graph()->property_map<vertex_descriptor,bool>("v:heat_source");
bool found = is_source.find(current_item) != is_source.end();
if(found)
{
if(!is_source[vd])
if(!get(is_source[current_item], vd))
{
is_source[vd]=true;
put(is_source[current_item], vd, true);
source_points->point_set()->insert(current_item->face_graph()->point(vd));
}
else
{
is_source[vd]=false;
put(is_source[current_item], vd, false);
Point_set::iterator it;
for(it = source_points->point_set()->begin(); it != source_points->point_set()->end(); ++it)
if(source_points->point_set()->point(*it) == current_item->face_graph()->point(vd))
@ -1224,6 +1238,7 @@ private:
boost::unordered_map<Scene_surface_mesh_item*, std::pair<double, SMesh::Face_index> > angles_min;
boost::unordered_map<Scene_surface_mesh_item*, std::pair<double, SMesh::Face_index> > angles_max;
boost::unordered_map<Scene_surface_mesh_item*, Vertex_source_map> is_source;
double minBox;

View File

@ -672,7 +672,7 @@ treat_result(Scene_item& source_item,
{
Scene_surface_mesh_item* new_item = new Scene_surface_mesh_item;
CGAL::facets_in_complex_3_to_triangle_mesh(result_item->c3t3(), *new_item->face_graph());
new_item->setName(tr("%1 [Remeshed as Surface_mesh]").arg(source_item.name()));
new_item->setName(tr("%1 [Remeshed]").arg(source_item.name()));
Q_FOREACH(int ind, scene->selectionIndices()) {
scene->item(ind)->setVisible(false);
}

View File

@ -541,7 +541,6 @@ void Polyhedron_demo_affine_transform_plugin::start(Scene_points_with_normal_ite
void Polyhedron_demo_affine_transform_plugin::end(){
QApplication::restoreOverrideCursor();
double matrix[16];
transformMatrix(&matrix[0]);
const CGAL::qglviewer::Vec offset = static_cast<CGAL::Three::Viewer_interface*>(CGAL::QGLViewer::QGLViewerPool().first())->offset();
@ -600,6 +599,7 @@ void Polyhedron_demo_affine_transform_plugin::end(){
transform_points_item = NULL;
}
dock_widget->hide();
QApplication::restoreOverrideCursor();
}
void Polyhedron_demo_affine_transform_plugin::updateUiMatrix()

View File

@ -74,7 +74,7 @@ void Polyhedron_demo_orient_soup_plugin::init(QMainWindow* mainWindow,
scene = scene_interface;
mw = mainWindow;
messages = m;
actionOrientSM = new QAction(tr("&Orient Polygon Soup (as a surface_mesh)"), mainWindow);
actionOrientSM = new QAction(tr("&Orient Polygon Soup"), mainWindow);
actionOrientSM->setObjectName("actionOrientSM");
actionOrientSM->setProperty("subMenuName", "Polygon Mesh Processing");
connect(actionOrientSM, SIGNAL(triggered()),

View File

@ -235,6 +235,7 @@ public Q_SLOTS:
if(face_sel.empty())
{
contour_2d.clear();
qobject_cast<CGAL::Three::Viewer_interface*>(viewer)->set2DSelectionMode(false);
return;
}
//get border edges of the selected patches

View File

@ -789,7 +789,7 @@ public Q_SLOTS:
QMessageBox::warning(mw,
tr("Degenerated Face_graph"),
tr("Degenerated faces have been detected. Problems may occur "
"for operations other tha \"Move point\". "));
"for operations other than \"Move point\". "));
}
//remove lasso mode
selection_item->set_lasso_mode(false);

View File

@ -22,6 +22,7 @@
#include <CGAL/Side_of_triangle_mesh.h>
#include <CGAL/Polygon_mesh_processing/bbox.h>
#include <CGAL/Polygon_mesh_processing/orientation.h>
#include <CGAL/Timer.h>
#include <CGAL/make_mesh_3.h>
@ -297,7 +298,13 @@ CGAL::Three::Scene_item* cgal_off_meshing(QWidget*,
// add remesh as new polyhedron
Result_mesh *pRemesh = new Result_mesh;
CGAL::facets_in_complex_3_to_triangle_mesh(c3t3, *pRemesh);
return make_item(pRemesh);
if(CGAL::is_closed(*pRemesh)
&& ! CGAL::Polygon_mesh_processing::is_outward_oriented(*pRemesh))
{
CGAL::Polygon_mesh_processing::reverse_face_orientations(*pRemesh);
}
return make_item(pRemesh);
}
else
return 0;
@ -436,6 +443,7 @@ if(sm_item)
.arg(offset_value));
new_item->setColor(Qt::magenta);
new_item->setRenderingMode(item->renderingMode());
scene->addItem(new_item);
item->setVisible(false);
scene->itemChanged(index);

View File

@ -59,7 +59,8 @@ struct PRIV{
};
Scene_item_rendering_helper::Scene_item_rendering_helper()
:priv(new PRIV(this)){}
:Scene_item(0,0),
priv(new PRIV(this)){}
Scene_item_rendering_helper::~Scene_item_rendering_helper()
{

View File

@ -384,21 +384,21 @@ public:
std::string line;
std::size_t id, id2;
if(!std::getline(in, line)) { return true; }
if(!std::getline(in, line)) { compute_normal_maps(); return true; }
std::istringstream vertex_line(line);
while(vertex_line >> id) {
if(id >= all_vertices.size()) { return false; }
selected_vertices.insert(all_vertices[id]);
}
if(!std::getline(in, line)) { return true; }
if(!std::getline(in, line)) { compute_normal_maps(); return true; }
std::istringstream facet_line(line);
while(facet_line >> id) {
if(id >= all_facets.size()) { return false; }
selected_facets.insert(all_facets[id]);
}
if(!std::getline(in, line)) { return true; }
if(!std::getline(in, line)) { compute_normal_maps(); return true; }
std::istringstream edge_line(line);
while(edge_line >> id >> id2) {
if(id >= all_edges.size() || id2 >= all_edges.size()) { return false; }

View File

@ -116,11 +116,15 @@ Scene_polylines_item_private::computeElements() const
it != item->polylines.end();
++it)
{
if(it->empty()) continue;
if(it->empty()) continue;
if(it->front() == it->back())
nb_vertices += it->size() - 1;
else
nb_vertices += it->size();
for(size_t i = 0, end = it->size()-1;
i < end; ++i)
{
for(size_t i = 0, end = it->size()-1;
i < end; ++i)
{
const Point_3& a = (*it)[i];
const Point_3& b = (*it)[i+1];
if(a!=b)

View File

@ -1429,18 +1429,18 @@ void Scene_surface_mesh_item::setItemIsMulticolor(bool b)
void Scene_surface_mesh_item::show_feature_edges(bool b)
{
d->has_feature_edges = b;
if(b)
{
d->e_is_feature_map = d->smesh_->add_property_map<boost::graph_traits<SMesh>::edge_descriptor,bool>("e:is_feature").first;
invalidate(COLORS);
itemChanged();
}
d->has_feature_edges = b;
}
bool Scene_surface_mesh_item::isItemMulticolor()
{
return d->has_fcolors;
return d->has_fcolors || d->has_vcolors;
}
bool Scene_surface_mesh_item::hasPatchIds()
@ -1709,7 +1709,7 @@ CGAL::Three::Scene_item::Header_data Scene_surface_mesh_item::header() const
data.titles.append(QString("#Border Edges"));
data.titles.append(QString("Pure Triangle"));
data.titles.append(QString("Pure Quad"));
data.titles.append(QString("#Degenerated Faces"));
data.titles.append(QString("#Degenerate Faces"));
data.titles.append(QString("Connected Components of the Boundary"));
data.titles.append(QString("Area"));
data.titles.append(QString("Volume"));
@ -1729,7 +1729,7 @@ CGAL::Three::Scene_item::Header_data Scene_surface_mesh_item::header() const
data.titles.append(QString("Maximum Length"));
data.titles.append(QString("Median Length"));
data.titles.append(QString("Mean Length"));
data.titles.append(QString("#Null Length"));
data.titles.append(QString("#Degenerate Edges"));
data.titles.append(QString("Minimum"));
data.titles.append(QString("Maximum"));
data.titles.append(QString("Average"));

View File

@ -15,6 +15,7 @@
#include <cmath>
#include <QApplication>
#include <QOpenGLDebugLogger>
#include <QStyleFactory>
#include "ui_LightingDialog.h"
@ -122,18 +123,21 @@ public:
255*d->ambient.z());
palette.setColor(QPalette::Button,ambient);
ambientButton->setPalette(palette);
ambientButton->setStyle(QStyleFactory::create("Fusion"));
diffuse=QColor(255*d->diffuse.x(),
255*d->diffuse.y(),
255*d->diffuse.z());
palette.setColor(QPalette::Button,diffuse);
diffuseButton->setPalette(palette);
diffuseButton->setStyle(QStyleFactory::create("Fusion"));
specular=QColor(255*d->specular.x(),
255*d->specular.y(),
255*d->specular.z());
palette.setColor(QPalette::Button,specular);
specularButton->setPalette(palette);
specularButton->setStyle(QStyleFactory::create("Fusion"));
spec_powrSlider->setValue(static_cast<int>(d->spec_power));
connect(&ambient_dial, &QColorDialog::currentColorChanged, this, &LightingDialog::ambient_changed );

View File

@ -98,14 +98,15 @@ namespace CGAL {
}
else
scanner.skip_to_next_vertex(i);
if(!in)
return false;
}
if(!in)
return false;
bool has_fcolors = false;
for (std::size_t i = 0; i < scanner.size_of_facets(); ++i) {
std::size_t no;
scanner.scan_facet( no, i);
if(!in)
return false;
IO::internal::resize(polygons[i], no);
for(std::size_t j = 0; j < no; ++j) {
std::size_t id;