我从来没有使用过CGAL,几乎没有C/C++的经验。但是,随着谷歌 我已经然而设法编译示例 “Alpha_shapes_3” (\ CGAL-4.1-β1\例子\ Alpha_shapes_3)使用 Visual Studio 2010中保存CGAL alpha形状表面网格
现在Windows 7的64位计算机上如果我们检查程序“ex_alpha_shapes_3”的源代码,我们 注意到名为“bunny_1000”的数据文件在红点位于集群所在的3d点 处。 现在我的问题是如何更改源代码,以便在为给定点计算阿尔法 形状后,阿尔法形状的表面网格将在外部文件中保存/写入 。它可以是简单的多边形列表和它们各自的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 2014-01-09 10:26:21
@lrineau我无法解决问题。但如果你能在这里帮助我,这将会很棒。 – PlatoManiac 2014-01-09 12:22:29