mirror of https://github.com/CGAL/cgal
Small fixes
- Fix the reload item - Prints the warning about not oriented facets in the console, and explains how to convert a polygon_soup into a surface_mesh or a polyhedron.
This commit is contained in:
parent
4cb4c56658
commit
827adf63b8
|
|
@ -867,7 +867,7 @@ void MainWindow::reloadItem() {
|
|||
QString loader_name = item->property("loader_name").toString();
|
||||
if(filename.isEmpty() || loader_name.isEmpty()) {
|
||||
std::cerr << "Cannot reload item: "
|
||||
<< "the item has no \"source filename\" or no \"loader_name\" attached attached\n";
|
||||
<< "the item has no \"source filename\" or no \"loader_name\" attached\n";
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
#include <CGAL/Three/Polyhedron_demo_io_plugin_interface.h>
|
||||
#include <CGAL/Three/Polyhedron_demo_plugin_interface.h>
|
||||
#include <fstream>
|
||||
|
||||
#include <QApplication>
|
||||
|
|
@ -8,27 +9,43 @@
|
|||
#include <QDebug>
|
||||
#include "Scene_surface_mesh_item.h"
|
||||
#include "Scene_polygon_soup_item.h"
|
||||
#include "Messages_interface.h"
|
||||
|
||||
|
||||
//This plugin crates an action in Operations that displays "Hello World" in the 'console' dockwidet.
|
||||
class SurfaceMeshIoPlugin :
|
||||
public QObject,
|
||||
public CGAL::Three::Polyhedron_demo_io_plugin_interface
|
||||
public CGAL::Three::Polyhedron_demo_io_plugin_interface,
|
||||
public CGAL::Three::Polyhedron_demo_plugin_interface
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_INTERFACES(CGAL::Three::Polyhedron_demo_io_plugin_interface)
|
||||
Q_INTERFACES(CGAL::Three::Polyhedron_demo_plugin_interface CGAL::Three::Polyhedron_demo_io_plugin_interface)
|
||||
Q_PLUGIN_METADATA(IID "com.geometryfactory.PolyhedronDemo.PluginInterface/1.0")
|
||||
Q_PLUGIN_METADATA(IID "com.geometryfactory.PolyhedronDemo.IOPluginInterface/1.0")
|
||||
public:
|
||||
QString name() const { return "surface_mesh_io_plugin"; }
|
||||
QString nameFilters() const { return "OFF files (*.off)"; }
|
||||
bool canLoad() const { return true; }
|
||||
CGAL::Three::Scene_item* load(QFileInfo fileinfo) {
|
||||
void init(QMainWindow*, CGAL::Three::Scene_interface*, Messages_interface* m)
|
||||
{
|
||||
qDebug()<<"coucou";
|
||||
this->message = m;
|
||||
}
|
||||
bool applicable(QAction*) const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
QList<QAction*> actions() const
|
||||
{
|
||||
return QList<QAction*>();
|
||||
}
|
||||
QString name() const { return "surface_mesh_io_plugin"; }
|
||||
QString nameFilters() const { return "OFF files (*.off)"; }
|
||||
bool canLoad() const { return true; }
|
||||
CGAL::Three::Scene_item* load(QFileInfo fileinfo) {
|
||||
if(fileinfo.suffix().toLower() != "off") return 0;
|
||||
|
||||
// Open file
|
||||
std::ifstream in(fileinfo.filePath().toUtf8());
|
||||
if(!in) {
|
||||
std::cerr << "Error! Cannot open file " << (const char*)fileinfo.filePath().toUtf8() << std::endl;
|
||||
message->error(QString("Cannot open file %1").arg((const char*)fileinfo.filePath().toUtf8()));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
@ -36,36 +53,39 @@ public:
|
|||
in >> *surface_mesh;
|
||||
if(!in || surface_mesh->is_empty())
|
||||
{
|
||||
delete surface_mesh;
|
||||
delete surface_mesh;
|
||||
in.close();
|
||||
// Try to read .off in a polygon soup
|
||||
Scene_polygon_soup_item* soup_item = new Scene_polygon_soup_item();
|
||||
soup_item->setName(fileinfo.completeBaseName());
|
||||
std::ifstream in2(fileinfo.filePath().toUtf8());
|
||||
if(!soup_item->load(in2)) {
|
||||
message->error(QString("Cannot open file %1").arg((const char*)fileinfo.filePath().toUtf8()));
|
||||
delete soup_item;
|
||||
return 0;
|
||||
}
|
||||
message->information("The facets don't seem to be oriented. Loading a Soup of polygons instead."
|
||||
"To convert it to a Surface_mesh or a Polyhedron, use Polygon Mesh Processing -> Orient polygon soup");
|
||||
return soup_item;
|
||||
}
|
||||
Scene_surface_mesh_item* item = new Scene_surface_mesh_item(surface_mesh);
|
||||
item->setName(fileinfo.completeBaseName());
|
||||
return item;
|
||||
|
||||
}
|
||||
bool canSave(const CGAL::Three::Scene_item* ) {
|
||||
}
|
||||
bool canSave(const CGAL::Three::Scene_item* ) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool save(const CGAL::Three::Scene_item* , QFileInfo ) {
|
||||
bool save(const CGAL::Three::Scene_item* , QFileInfo ) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private:
|
||||
QList<QAction*> _actions;
|
||||
//The reference to the main window
|
||||
QMainWindow* mw;
|
||||
QList<QAction*> _actions;
|
||||
//The reference to the main window
|
||||
Messages_interface* message;
|
||||
};
|
||||
#include "Surface_mesh_io_plugin.moc"
|
||||
|
|
|
|||
|
|
@ -149,6 +149,7 @@ void Polyhedron_demo_orient_soup_plugin::orientPoly()
|
|||
poly_item->setVisible(item->visible());
|
||||
poly_item->invalidateOpenGLBuffers();
|
||||
poly_item->setProperty("source filename", item->property("source filename"));
|
||||
poly_item->setProperty("loader_name", item->property("loader_name"));
|
||||
scene->replaceItem(index, poly_item);
|
||||
item->deleteLater();
|
||||
} else {
|
||||
|
|
@ -192,6 +193,7 @@ void Polyhedron_demo_orient_soup_plugin::orientSM()
|
|||
sm_item->setRenderingMode(item->renderingMode());
|
||||
sm_item->setVisible(item->visible());
|
||||
sm_item->setProperty("source filename", item->property("source filename"));
|
||||
sm_item->setProperty("loader_name", item->property("loader_name"));
|
||||
scene->replaceItem(index, sm_item);
|
||||
item->deleteLater();
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Reference in New Issue