您的位置:首页 > 其它

Compute the convex hull of 3D points set.

2008-05-13 10:25 155 查看
Tool: CGAL 3.2 + vs.net 2003(MFC) + OpenGL

void CMeshDoc::getPointsSet(std::vector<Point_3> & pp)
{
Enriched_polyhedron<Enriched_kernel,Enriched_items>::Vertex_iterator pVertex = m_pMesh->vertices_begin();

for(;pVertex != m_pMesh->vertices_end();pVertex++) {
const Enriched_polyhedron<Enriched_kernel,Enriched_items>::Point& pt = pVertex->point();
Point_3 p(pt.x(),pt.y(),pt.z());
pp.push_back(p);
} // for(;pVertex != m_pMesh->vertices_end();pVertex++)
}

void CMeshDoc::OnComputeConvexHull()
{
// TODO: Add your command handler code here
std::vector<Point_3> pointset;
CGAL::Object ch_object;

// get the points set from off file
getPointsSet(pointset);

// compute convex hull
CGAL::convex_hull_3(pointset.begin(), pointset.end(), ch_object);

Polyhedron_3 polyhedron;
if ( CGAL::assign (polyhedron, ch_object) )
std::cout << "convex hull is a polyhedron " << std::endl;
else
std::cout << "convex hull error!" << std::endl;

// display polyhedron
}




pig.off



convex hull of the pig model

You can download the framework from here:http://www.cgal.org/Tutorials/Polyhedron/
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: