我從來沒有使用過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