2016-09-15 11 views
0

Visual Studio C++で、メッシュの仕組みを理解しようとすると、数時間を費やすだけです。私が得たいのは、頂点と三角形のリスト(double [3]の形の頂点、intの形の三角形[3])へのアクセスです。ここで私は働いているスクリプトは次のとおりです。CGAL:メッシュから頂点と三角形を読み取る

http://doc.cgal.org/latest/Surface_mesher/Surface_mesher_2mesh_a_3d_gray_image_8cpp-example.html

ポイントがある - 機能CGAL::output_surface_facets_to_off (out, c2t3);出力くれ.off形式での素敵なファイル(MeshLabでアクセス可能)が、私はちょうど操作することにより、任意の類似を行うことはできませんc2t3またはtr変数。私が期待していたのは、整数の3倍の値を持つようなものでした:

c2t3.vertices(0からNまで)、c2t3.triangles(0からMまで)などです。私が得たのは、頂点のリスト、ファセットのリスト、セルのリスト、エッジのリストでした...そして、ソートされていない頂点のリスト内のすべての頂点番号を見つける以外の方法で、ファセットから頂点番号を取得する方法はありません。

誰でも私の問題を解決し、私が間違っていることを指摘できますか?また、CGALのAPIは非常にrawです。ソースの掘り出しも非常にハードコアなので、output_surface関数の本体が見つかりませんでした。

答えて

0

さて、私はComplex_2_in_triangulation_3_file_writer.hファイルで答えを見つけました。どうやら、CGALライブラリは頂点の全体マップを作成しており、このマップのファセット頂点を探しています。コード部分:

using CGAL::Surface_mesher::number_of_facets_on_surface; 

typedef typename C2t3::Triangulation Tr; 
typedef typename Tr::Finite_facets_iterator Finite_facets_iterator; 
typedef typename Tr::Finite_vertices_iterator Finite_vertices_iterator; 
typedef typename Tr::Facet Facet; 
typedef typename Tr::Edge Edge; 
typedef typename Tr::Vertex_handle Vertex_handle; 

std::map<Vertex_handle, int> V; 
int inum = 0; 
for(Finite_vertices_iterator vit = tr.finite_vertices_begin(); 
vit != tr.finite_vertices_end(); 
++vit) 
{ 
    V[vit] = inum++; 
} 

for(Finite_facets_iterator fit = tr.finite_facets_begin(); 
fit != tr.finite_facets_end(); ++fit) 
{ 
const typename Tr::Cell_handle cell = fit->first; 
const int& index = fit->second; 
    if (cell->is_facet_on_surface(index)==true) 
    { 
    const int index1 = V[cell->vertex(tr.vertex_triple_index(index, 0))]; 
    const int index2 = V[cell->vertex(tr.vertex_triple_index(index, 1))]; 
    const int index3 = V[cell->vertex(tr.vertex_triple_index(index, 2))]; 
    } 
} 
関連する問題