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
}
![](http://hiphotos.baidu.com/zjujzp/abpic/item/fc2cf003891bf3743812bb33.jpg)
pig.off
![](http://hiphotos.baidu.com/zjujzp/abpic/item/fab46806090c50780308813d.jpg)
convex hull of the pig model
You can download the framework from here:http://www.cgal.org/Tutorials/Polyhedron/
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
}
![](http://hiphotos.baidu.com/zjujzp/abpic/item/fc2cf003891bf3743812bb33.jpg)
pig.off
![](http://hiphotos.baidu.com/zjujzp/abpic/item/fab46806090c50780308813d.jpg)
convex hull of the pig model
You can download the framework from here:http://www.cgal.org/Tutorials/Polyhedron/
相关文章推荐
- Farthest points Sampling on 3D meshes with mesh kept based on diffusion distance
- 解决使用3DSprite出现vertices exceed the max size of vertex buffer, will set count to _vertexNumber-begin错误
- (Django) How do I set limit_choices_to another class from where the ManyToManyField points to? - django, django-models - TechQues.com
- 2. The Convex Hull of a Sequence of points
- The stack plug-in failed to set问题
- loaded the "BlueView" nib but the view outlet was not set 错误的解决办法。
- The SetStack Computer UVA - 12096
- 设置页面的默认焦点控件和默认接受事件控件How Do I Set the DefaultFocus or DefaultButton in a Page Based on a Master Page in ASP.NET 2.0
- ZOJ Problem Set - 3664 Split the Rectangle
- Given n points on a 2D plane, find the maximum number of points that lie on the same straight line.
- The method setPositiveButton(int, DialogInterface.OnClickListener) in the type AlertDialog.Builder i
- Bug:"XXXView" nib but the view outlet was not set
- VirtualBox - 桥接网络配置 | How to set the bridge mode
- Failed to set the 'value' property on 'HTMLInputElement': This input element解决办法
- 【Uva 12096】The SetStack Computer
- how to calculate the best fit to a plane in 3D, and how to find the corresponding statistical parameters
- UVa 12096 The SetStack Computer【STL】
- Codeforces Round #466 (Div. 2) A. Points on the line
- No Spring Session store is configured: set the 'spring.session.store-type' property
- A. Points on the line