Subject: CGAL users discussion list
List archive
- From: loc <>
- To:
- Subject: [cgal-discuss] how to obtain surface triangles from delaunay_3d triangulation
- Date: Mon, 7 Oct 2013 15:33:58 -0700 (PDT)
i have a point cloud of a scan building. i want to write a program whereby i
can pick any point from this point cloud, search for it's K nearest
neighbors then triangulate this points and finally retrieve the triangles
that corresponds to the surface facets of the triangulation that are
incident on the this target point (no interior facet is needed). after
running from one library to the other, i finally came across CGAL library
which seems to provide a solution to my need. i read through the
documentations and manuals but i could not still figure out how to obtain
the surface facet from Delaunay_Triangulation_3D. after may trials and
failures, i thought of using Projection_traits_xy_3 with
delaunay_triangulation_2D. but the problem is that, the points to be
triangulated can be in any plane or form two, or even three different
intersecting planes and as such i could not figure out how i can apply that
approach in such situation since arbitrarily projecting the point onto one
plane may give me a line or something close.
Here is some of what i have tried so far but i can't still get the working
solution.
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::Triangulation_vertex_base_3<K> Vb;
typedef CGAL::Triangulation_hierarchy_vertex_base_3<Vb> Vbh;
typedef CGAL::Triangulation_data_structure_3<Vbh> Tds;
typedef CGAL::Delaunay_triangulation_3<K,Tds,CGAL::Fast_location>
Triangulation;
typedef Triangulation::Vertex_handle Vertex_handle;
typedef Triangulation::Cell_handle Cell_handle;
typedef Triangulation::Facet Facet;
typedef Triangulation::Edge Edges;
typedef Triangulation::Point Point;
typedef Triangulation::Triangle Triangle;
.
.
.
.
Triangulation t;
t.insert(points.begin(), points.end());
if(t.is_valid()){
Vertex_handle targetvertex;
if(t.is_vertex ( targetpoint, targetvertex)) {
std::list<Cell_handle> cells;
t.incident_cells(t.infinite_vertex(), std::back_inserter(cells));
std::list<Cell_handle>::iterator cit;
for( cit = cells.begin(); cit != cells.end(); cit++ ){
Cell_handle cell = *cit;
const int& i = cell->index( t.infinite_vertex());
Facet f = std::make_pair( cell, i );
int k1 = (i+1)&3;
int k2 = (i+2)&3;
int k3 = (i+3)&3;
// determine if this facet is incident on targetvertex
if(t.has_vertex(f,targetvertex)){// targetvertex is a vertexhandle of point
whose surface incident
// //facets are needed
const Vertex_handle& v1 = f.first->vertex(k1);
const Vertex_handle& v2 = f.first->vertex(k2);
const Vertex_handle& v3 = f.first->vertex(k3);
T = Triangle(v1->point(),v2->point(),v3->point());
if(!T.is_degenerate())
tr.push_back(T);
}
}
}
}
i tried this no success. when i visualized the triangles, i got a very weird
figure. i changed to the following but still the same. probably i am missing
something that i need to understand.
std::vector<Cell_handle> Cells;
t.incident_cells(t.infinite_vertex(), std::back_inserter(Cells));
for(std::vector<Cell_handle>::iterator it = Cells.begin(); it !=
Cells.end(); ++it)
{
Vertex_handle va, vb, vc;
//here i assume the facet of this cell on the surface should be
opposite to infinite vertex
if((*it)->vertex(0) == t.infinite_vertex())
{
va = (*it)->vertex(3);
vb = (*it)->vertex(2);
vc = (*it)->vertex(1);
}
else if((*it)->vertex(1) == t.infinite_vertex())
{
va = (*it)->vertex(0);
vb = (*it)->vertex(2);
vc = (*it)->vertex(3);
}
else if((*it)->vertex(2) == t.infinite_vertex())
{
va = (*it)->vertex(0);
vb = (*it)->vertex(3);
vc= (*it)->vertex(1);
}
else if((*it)->vertex(3) == t.infinite_vertex())
{
va = (*it)->vertex(2);
vb = (*it)->vertex(0);
vc = (*it)->vertex(1);
}
else
assert(0);
// determine if this facets is incident on targetvertex
if(va == targetvertex || vb == targetvertex || vc ==
targetvertex){
T = (Triangle(va->point(),vb->point(), vc->point()));
if(!T.is_degenerate())
tr.push_back(T);
}
}
what am i missing? or am i doing completely wrong thing? i tried this for
about a month now but can't find a way out and i really need to get a way
out of it since it a way through the next stage of my project.
Any suggestion or guide will be highly appreciated.
Thank you.
--
View this message in context:
http://cgal-discuss.949826.n4.nabble.com/how-to-obtain-surface-triangles-from-delaunay-3d-triangulation-tp4658143.html
Sent from the cgal-discuss mailing list archive at Nabble.com.
- [cgal-discuss] how to obtain surface triangles from delaunay_3d triangulation, loc, 10/08/2013
Archive powered by MHonArc 2.6.18.