Skip to Content.
Sympa Menu

cgal-discuss - [cgal-discuss] question about saving alpha shape triangulation

Subject: CGAL users discussion list

List archive

[cgal-discuss] question about saving alpha shape triangulation


Chronological Thread 
  • From: pradi <>
  • To:
  • Subject: [cgal-discuss] question about saving alpha shape triangulation
  • Date: Sat, 16 Feb 2013 13:52:35 -0800 (PST)

I have never used CGAL and have got almost no C/C++ experience. But following
Google I have however managed to compile the example "Alpha_shapes_3"
(\CGAL-4.1-beta1\examples\Alpha_shapes_3) on a Windows 7 64bit machine using
visual studio 2010.
<http://cgal-discuss.949826.n4.nabble.com/file/n4656742/Untitled-2.png>
Now if we check the source code for the program "ex_alpha_shapes_3" we
notice that a data file called "bunny_1000" is red where the 3d point
cluster resides.
Now my question is how can I change the source code so that after the alpha
shape is computed for the given points, surface mesh of the alpha shape is
saved/wrote in an external file. It can be simply the list of polygons and
their respective 3D vertices. I guess these polygons will be defining the
surface mesh of the alpha shape. If I can do that I can see the output of
the alpha shape generation program in an external tool I am familiar with
(here Mathematica).

I know this is very straightforward but I could not figure this out with my
limited knowledge of CGAL.

I know you gueys have the code but I am pasting it again for completion.

#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;
}




--
View this message in context:
http://cgal-discuss.949826.n4.nabble.com/question-about-saving-alpha-shape-triangulation-tp4656742.html
Sent from the cgal-discuss mailing list archive at Nabble.com.


  • [cgal-discuss] question about saving alpha shape triangulation, pradi, 02/16/2013

Archive powered by MHonArc 2.6.18.

Top of Page