【发布时间】:2013-04-01 02:42:36
【问题描述】:
我从未使用过 CGAL,几乎没有 C/C++ 经验。但跟随 谷歌但是我设法编译了示例“Alpha_shapes_3” (\CGAL-4.1-beta1\examples\Alpha_shapes_3) 在 Windows 7 64 位机器上使用 视觉工作室 2010。
现在,如果我们检查程序“ex_alpha_shapes_3”的源代码,我们 请注意,名为“bunny_1000”的数据文件是红色的,其中 3d 点 集群驻留。 现在我的问题是如何更改源代码,以便在 alpha 之后 为给定的点计算形状,alpha 形状的表面网格是 保存/写入外部文件。它可以是简单的多边形列表和 它们各自的 3D 顶点。我猜这些多边形将定义 alpha 形状的表面网格。如果我能做到,我可以看到输出 我熟悉的外部工具中的 alpha 形状生成程序。
我知道这很简单,但我无法用我的 CGAL知识有限。
我知道你们有代码,但我再次粘贴它以完成。
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Delaunay_triangulation_3.h>
#include <CGAL/Alpha_shape_3.h>
#include <fstream>
#include <list>
#include <cassert>
typedef CGAL::Exact_predicates_inexact_constructions_kernel Gt;
typedef CGAL::Alpha_shape_vertex_base_3<Gt> Vb;
typedef CGAL::Alpha_shape_cell_base_3<Gt> Fb;
typedef CGAL::Triangulation_data_structure_3<Vb,Fb> Tds;
typedef CGAL::Delaunay_triangulation_3<Gt,Tds> Triangulation_3;
typedef CGAL::Alpha_shape_3<Triangulation_3> Alpha_shape_3;
typedef Gt::Point_3 Point;
typedef Alpha_shape_3::Alpha_iterator Alpha_iterator;
int main()
{
std::list<Point> lp;
//read input
std::ifstream is("./data/bunny_1000");
int n;
is >> n;
std::cout << "Reading " << n << " points " << std::endl;
Point p;
for( ; n>0 ; n--) {
is >> p;
lp.push_back(p);
}
// compute alpha shape
Alpha_shape_3 as(lp.begin(),lp.end());
std::cout << "Alpha shape computed in REGULARIZED mode by default"
<< std::endl;
// find optimal alpha value
Alpha_iterator opt = as.find_optimal_alpha(1);
std::cout << "Optimal alpha value to get one connected component is "
<< *opt << std::endl;
as.set_alpha(*opt);
assert(as.number_of_solid_components() == 1);
return 0;
}
在互联网上搜索了很多之后,我发现可能我们需要使用类似的东西
std::list<Facet> facets;
alpha_shape.get_alpha_shape_facets
(
std::back_inserter(facets),Alpha_shape::REGULAR
);
但我仍然完全不知道如何在上面的代码中使用它!
【问题讨论】:
-
你的问题最终解决了吗?
-
@lrineau 我无法解决问题。但是,如果您能在这里帮助我,那就太好了。