mirror of https://github.com/CGAL/cgal
Add obj IO for soups in demo
This commit is contained in:
parent
4b28101397
commit
12c5fbe719
|
|
@ -218,7 +218,16 @@ Polyhedron_demo_off_plugin::load_obj(QFileInfo fileinfo) {
|
||||||
item->setName(fileinfo.baseName());
|
item->setName(fileinfo.baseName());
|
||||||
if(item->load_obj(in))
|
if(item->load_obj(in))
|
||||||
return item;
|
return item;
|
||||||
return 0;
|
//if not polygonmesh load in soup
|
||||||
|
std::vector<Point_3> points;
|
||||||
|
std::vector<std::vector<std::size_t> > polygons;
|
||||||
|
if(CGAL::read_OBJ(in, points, polygons))
|
||||||
|
{
|
||||||
|
Scene_polygon_soup_item* soup_item = new Scene_polygon_soup_item();
|
||||||
|
soup_item->load(points, polygons);
|
||||||
|
return soup_item;
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Polyhedron_demo_off_plugin::canSave(const CGAL::Three::Scene_item* item)
|
bool Polyhedron_demo_off_plugin::canSave(const CGAL::Three::Scene_item* item)
|
||||||
|
|
@ -262,7 +271,8 @@ save(QFileInfo fileinfo,QList<CGAL::Three::Scene_item*>& items)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(fileinfo.suffix().toLower() == "obj"){
|
if(fileinfo.suffix().toLower() == "obj"){
|
||||||
bool res = (sm_item && sm_item->save_obj(out));
|
bool res = (sm_item && sm_item->save_obj(out))
|
||||||
|
|| (soup_item && CGAL::write_OBJ(out, soup_item->points(), soup_item->polygons()));
|
||||||
if(res)
|
if(res)
|
||||||
{
|
{
|
||||||
items.pop_front();
|
items.pop_front();
|
||||||
|
|
|
||||||
|
|
@ -23,13 +23,15 @@ struct Polygon_soup
|
||||||
typedef std::vector<CGAL::Color> Colors;
|
typedef std::vector<CGAL::Color> Colors;
|
||||||
typedef std::set<Edge> Edges;
|
typedef std::set<Edge> Edges;
|
||||||
typedef Polygons::size_type size_type;
|
typedef Polygons::size_type size_type;
|
||||||
Points points;
|
|
||||||
Polygons polygons;
|
|
||||||
Edges_map edges;
|
Edges_map edges;
|
||||||
Colors fcolors;
|
Colors fcolors;
|
||||||
Colors vcolors;
|
Colors vcolors;
|
||||||
Edges non_manifold_edges;
|
Edges non_manifold_edges;
|
||||||
bool display_non_manifold_edges;
|
bool display_non_manifold_edges;
|
||||||
|
Points points;
|
||||||
|
Polygons polygons;
|
||||||
|
|
||||||
Polygon_soup():
|
Polygon_soup():
|
||||||
display_non_manifold_edges(false){}
|
display_non_manifold_edges(false){}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue