Subject: CGAL users discussion list
List archive
- From: Sven Seele <>
- To:
- Subject: [cgal-discuss] Alpha shape vertex normals
- Date: Tue, 26 May 2009 16:37:54 +0200
Hi there,
I am fairly new to CGAL and still need some getting used to...Right now I need to calculate the normals per vertex from a 3D alpha shape and don't really know how to go about that.
At first I tried to derive a class from Alpha_shape_vertex_base_3 to use as vertex base for the alpha shape, which should then be able to calculate its own normal. Unfortunately, there seems to be no iterator or circulator accessible from Alpha_shape_vertex_base_3, like the Halfedge_around_vertex_const_circulator used in this thread: https://lists-sop.inria.fr/sympa/arc/cgal-discuss/2008-10/msg00238.html.
So now I am trying to extend a function that uses the Alpha_shape_facets_iterator to calculate the normals per triangle (see below). I tried to use Triangulation_utils_3::next_around_edge() and incident_facets() to acquire all adjacent triangles of a vertex. However, neither function gives me what I need and like I said, I am not familiar enough with CGAL to know how to further select triangles/facets/cells/vertices to get the right triangles.
I also remember reading that someone converted the whole alpha shape to a polyhedron and then used the halfedge circulator, but that seems to be too much effort to get something which sounds rather simple to me.
What would be the best way to solve this problem?
Any help is highly appreciated.
Best regards,
Sven
Here is the code to calculate the normals per triangle:
...
for (AlphaShape3::Alpha_shape_facets_iterator facet = mAlphaShape->alpha_shape_facets_begin();
facet != mAlphaShape->alpha_shape_facets_end(); ++facet)
{
AlphaShape3::Cell_handle cell = facet->first;
int vtx_idx = facet->second;
if (mAlphaShape->classify(*facet) == AlphaShape3::REGULAR &&
mAlphaShape->classify(cell) == AlphaShape3::INTERIOR)
{
cell = cell->neighbor(vtx_idx);
vtx_idx = cell->index(facet->first);
}
// convert triangle vertices and calculate normal
const int idx0 = AlphaShape3::Triangulation_utils_3::vertex_triple_index(vtx_idx, 0);
const int idx1 = AlphaShape3::Triangulation_utils_3::vertex_triple_index(vtx_idx, 1);
const int idx2 = AlphaShape3::Triangulation_utils_3::vertex_triple_index(vtx_idx, 2);
const Kernel::Point_3 &vtx0 = cell->vertex(idx0)->point();
const Kernel::Point_3 &vtx1 = cell->vertex(idx1)->point();
const Kernel::Point_3 &vtx2 = cell->vertex(idx2)->point();
const ::osg::Vec3 tri_vtx0(vtx0[0], vtx0[1], vtx0[2]);
const ::osg::Vec3 tri_vtx1(vtx1[0], vtx1[1], vtx1[2]);
const ::osg::Vec3 tri_vtx2(vtx2[0], vtx2[1], vtx2[2]);
::osg::Vec3 tri_nrm = (tri_vtx1 - tri_vtx0) ^ (tri_vtx2 - tri_vtx1);
tri_nrm.normalize();
...
- [cgal-discuss] Alpha shape vertex normals, Sven Seele, 05/26/2009
- Re: [cgal-discuss] Alpha shape vertex normals, Andreas Fabri, 05/26/2009
- Re: [cgal-discuss] Alpha shape vertex normals, Sven Seele, 05/26/2009
- Re: [cgal-discuss] Alpha shape vertex normals, Andreas Fabri, 05/26/2009
- Re: [cgal-discuss] Alpha shape vertex normals, Sven Seele, 05/29/2009
- Re: [cgal-discuss] Alpha shape vertex normals, Andreas Fabri, 05/26/2009
- Re: [cgal-discuss] Alpha shape vertex normals, Sven Seele, 05/26/2009
- Re: [cgal-discuss] Alpha shape vertex normals, Mariette Yvinec, 05/26/2009
- Re: [cgal-discuss] Alpha shape vertex normals, Andreas Fabri, 05/26/2009
Archive powered by MHonArc 2.6.16.