1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
|
#include "Scene_nef_polyhedron_item.h"
#include "Nef_type.h"
#include <CGAL/Three/CGAL_Lab_io_plugin_interface.h>
#include <CGAL/Three/Three.h>
#include <fstream>
using namespace CGAL::Three;
class CGAL_Lab_off_to_nef_plugin :
public QObject,
public CGAL_Lab_io_plugin_interface
{
Q_OBJECT
Q_INTERFACES(CGAL::Three::CGAL_Lab_io_plugin_interface)
Q_PLUGIN_METADATA(IID "com.geometryfactory.CGALLab.IOPluginInterface/1.90" FILE "off_to_nef_io_plugin.json")
public:
QString name() const { return "off_to_nef_plugin"; }
QString nameFilters() const { return "OFF files, into nef (*.off)"; }
bool canLoad(QFileInfo) const;
QList<Scene_item*> load(QFileInfo fileinfo, bool& ok, bool add_to_scene=true);
bool canSave(const CGAL::Three::Scene_item*);
bool save(QFileInfo fileinfo,QList<CGAL::Three::Scene_item*>& );
};
bool CGAL_Lab_off_to_nef_plugin::canLoad(QFileInfo) const {
return true;
}
QList<Scene_item*> CGAL_Lab_off_to_nef_plugin::
load(QFileInfo fileinfo, bool& ok, bool add_to_scene){
std::ifstream in(fileinfo.filePath().toUtf8());
if(!in)
std::cerr << "Error!\n";
Scene_nef_polyhedron_item* item = new Scene_nef_polyhedron_item();
if(fileinfo.size() == 0)
{
CGAL::Three::Three::warning( tr("The file you are trying to load is empty."));
item->setName(fileinfo.completeBaseName());
ok = true;
if(add_to_scene)
CGAL::Three::Three::scene()->addItem(item);
return QList<Scene_item*>()<<item;
}
if(!item->load_from_off(in))
{
delete item;
ok = false;
return QList<Scene_item*>()<<item;
}
item->setName(fileinfo.completeBaseName());
ok = true;
if(add_to_scene)
CGAL::Three::Three::scene()->addItem(item);
return QList<Scene_item*>()<<item;
}
bool CGAL_Lab_off_to_nef_plugin::canSave(const CGAL::Three::Scene_item*)
{
return false;
}
bool CGAL_Lab_off_to_nef_plugin::
save(QFileInfo ,QList<CGAL::Three::Scene_item*>&)
{
return false;
}
#include "OFF_to_nef_io_plugin.moc"
|