CGAL - 不能使用 import_from_polyhedron_3
CGAL - cannot use import_from_polyhedron_3
我想简化从 .off 文件读取的表面并使用 CGAL 查看它。
我将表面读取为 Polyhedron_3,我想将其转换为 Linear_cell_complex_for_combinatorial_map 以查看它,但是 import_from_polyhedron_3 方法
中存在问题
我的代码:
typedef CGAL::Linear_cell_complex_for_combinatorial_map<2,3> LCC_3;
typedef LCC_3::Dart_handle Dart_handle;
typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
typedef CGAL::Polyhedron_3<Kernel> Polyhedron;
QWidget* viewer ;
QString fileName;
LCC_3 lcc;
QMainWindow qWin;
CGAL::DefaultColorFunctorLCC fcolor;
Polyhedron P;
void MainWindow::preview()
{
QWidget* centralWidget = new QWidget(viewer);
centralWidget->setSizePolicy(QSizePolicy::Maximum,QSizePolicy::Maximum);
CGAL::import_from_polyhedron_3<LCC_3, Polyhedron>(lcc, P);
setCentralWidget( new CGAL::SimpleLCCViewerQt<LCC_3, CGAL::DefaultColorFunctorLCC>(&qWin ,
lcc,
"Basic LCC Viewer",
false,
fcolor ) );
show();
}
void MainWindow::fileOpen()
{
fileName = QFileDialog::getOpenFileName(this,tr("Select object"), ".", tr("*.off"));
std::ofstream out(fileName.toLocal8Bit());
out<<P;
preview();
}
void MainWindow ::simplify()
{
bool ok;
int n = QInputDialog::getInt(this, "", tr("Number of vertices in each cell:"),P.size_of_vertices(),0, P.size_of_vertices(),1, &ok);
if (ok){
int r = P.size_of_vertices() - n;
int target_edges = P.size_of_halfedges()/2 - r*3;
n=target_edges+1;
}
typedef CGAL::Polyhedron_3<Kernel> Surface;
SaveOFF("temp.off");
namespace SMS = CGAL::Surface_mesh_simplification ;
Surface surface;
std::ifstream is("temp.off") ; is >> surface ;
// This is a stop predicate (defines when the algorithm terminates).
// In this example, the simplification stops when the number of undirected edges
// left in the surface drops below the specified number (1000)
SMS::Count_stop_predicate<Surface> stop(n);
// This the actual call to the simplification algorithm.
// The surface and stop conditions are mandatory arguments.
// The index maps are needed because the vertices and edges
// of this surface lack an "id()" field.
int r = SMS::edge_collapse
(surface
,stop
,CGAL::parameters::vertex_index_map(get(CGAL::vertex_external_index,surface))
.halfedge_index_map (get(CGAL::halfedge_external_index ,surface))
);
std::ofstream os("temp.off"); os << surface ;
OpenOFF("temp.off");
std::cout << "Finished..." << r << " edges removed."<<std::endl;
std::cout<<P.size_of_vertices()<<" Vertices"<<std::endl;
std::cout<<P.size_of_facets()<<" Facets"<<std::endl;
std::cout<<P.size_of_halfedges()<<" Halfedges"<<std::endl;
preview();
}
它向我显示以下错误:
‘import_from_polyhedron_3’不是‘CGAL’的成员
CGAL::import_from_polyhedron_3(lcc, P);
另一个问题是在简化后无法在查看器中重新加载表面,它显示以下错误:
它显示错误 "The inferior stopped because it received a signal from the operating system."
我需要任何帮助
谢谢
缺少#include< CGAL/Polyhedron_3_to_lcc.h >(cf doc here)
我想简化从 .off 文件读取的表面并使用 CGAL 查看它。 我将表面读取为 Polyhedron_3,我想将其转换为 Linear_cell_complex_for_combinatorial_map 以查看它,但是 import_from_polyhedron_3 方法
中存在问题我的代码:
typedef CGAL::Linear_cell_complex_for_combinatorial_map<2,3> LCC_3;
typedef LCC_3::Dart_handle Dart_handle;
typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
typedef CGAL::Polyhedron_3<Kernel> Polyhedron;
QWidget* viewer ;
QString fileName;
LCC_3 lcc;
QMainWindow qWin;
CGAL::DefaultColorFunctorLCC fcolor;
Polyhedron P;
void MainWindow::preview()
{
QWidget* centralWidget = new QWidget(viewer);
centralWidget->setSizePolicy(QSizePolicy::Maximum,QSizePolicy::Maximum);
CGAL::import_from_polyhedron_3<LCC_3, Polyhedron>(lcc, P);
setCentralWidget( new CGAL::SimpleLCCViewerQt<LCC_3, CGAL::DefaultColorFunctorLCC>(&qWin ,
lcc,
"Basic LCC Viewer",
false,
fcolor ) );
show();
}
void MainWindow::fileOpen()
{
fileName = QFileDialog::getOpenFileName(this,tr("Select object"), ".", tr("*.off"));
std::ofstream out(fileName.toLocal8Bit());
out<<P;
preview();
}
void MainWindow ::simplify()
{
bool ok;
int n = QInputDialog::getInt(this, "", tr("Number of vertices in each cell:"),P.size_of_vertices(),0, P.size_of_vertices(),1, &ok);
if (ok){
int r = P.size_of_vertices() - n;
int target_edges = P.size_of_halfedges()/2 - r*3;
n=target_edges+1;
}
typedef CGAL::Polyhedron_3<Kernel> Surface;
SaveOFF("temp.off");
namespace SMS = CGAL::Surface_mesh_simplification ;
Surface surface;
std::ifstream is("temp.off") ; is >> surface ;
// This is a stop predicate (defines when the algorithm terminates).
// In this example, the simplification stops when the number of undirected edges
// left in the surface drops below the specified number (1000)
SMS::Count_stop_predicate<Surface> stop(n);
// This the actual call to the simplification algorithm.
// The surface and stop conditions are mandatory arguments.
// The index maps are needed because the vertices and edges
// of this surface lack an "id()" field.
int r = SMS::edge_collapse
(surface
,stop
,CGAL::parameters::vertex_index_map(get(CGAL::vertex_external_index,surface))
.halfedge_index_map (get(CGAL::halfedge_external_index ,surface))
);
std::ofstream os("temp.off"); os << surface ;
OpenOFF("temp.off");
std::cout << "Finished..." << r << " edges removed."<<std::endl;
std::cout<<P.size_of_vertices()<<" Vertices"<<std::endl;
std::cout<<P.size_of_facets()<<" Facets"<<std::endl;
std::cout<<P.size_of_halfedges()<<" Halfedges"<<std::endl;
preview();
}
它向我显示以下错误: ‘import_from_polyhedron_3’不是‘CGAL’的成员 CGAL::import_from_polyhedron_3(lcc, P);
另一个问题是在简化后无法在查看器中重新加载表面,它显示以下错误: 它显示错误 "The inferior stopped because it received a signal from the operating system."
我需要任何帮助 谢谢
缺少#include< CGAL/Polyhedron_3_to_lcc.h >(cf doc here)