Skip to Content.
Sympa Menu

cgal-discuss - Re: [cgal-discuss] Help with 'filtration' and 'filtration_with_alpha_values'

Subject: CGAL users discussion list

List archive

Re: [cgal-discuss] Help with 'filtration' and 'filtration_with_alpha_values'


Chronological Thread 
  • From: Mariette Yvinec <>
  • To:
  • Subject: Re: [cgal-discuss] Help with 'filtration' and 'filtration_with_alpha_values'
  • Date: Thu, 10 Jul 2014 11:30:16 +0200

Hi Stevens

the problem might come fron the declaration :
std::list        objects; 
where the template parameter is missing.
The template parameter should be a CGAL::Object.
A CGAL::Object has to be casted into a real types (here Vb, Fb, Facet or Edge
before being able to call the output operator on it.

Regards,
Mariette


Le 06/07/14 02:43, stevens a écrit :
Hi everybody.

I'm trying to make an output for the Alpha Complex Filtration of an initial
point cloud I have on a text file but I really can't make the options
'filtration_with_alpha_values' and 'filtration' works.
My aim is to generate a text file with the information of "all the faces of
the triangulation in increasing order of the alpha value for which they
appear in the alpha complex. "
I've followed the example Alpha_shapes_3/ex_weighted_alpha_shapes_3.cpp
found on CGAL webpage and I've gotten the next code: 

#include <CGAL/Regular_triangulation_euclidean_traits_3.h>
#include <CGAL/Regular_triangulation_3.h>
#include <CGAL/Alpha_shape_3.h>
#include <list>
#include <fstream>
#include <cassert>
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <CGAL/Object.h>
#include <CGAL/tuple.h>

using namespace std;

typedef CGAL::Exact_predicates_inexact_constructions_kernel K;

typedef CGAL::Regular_triangulation_euclidean_traits_3<K> 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::Regular_triangulation_3<Gt,Tds>       Triangulation_3;
typedef CGAL::Alpha_shape_3<Triangulation_3>        Alpha_shape_3;

typedef Alpha_shape_3::Cell_handle          Cell_handle;
typedef Alpha_shape_3::Vertex_handle        Vertex_handle;
typedef Alpha_shape_3::Facet                Facet;
typedef Alpha_shape_3::Edge                 Edge;
typedef Gt::Weighted_point                  Weighted_point;
typedef Gt::Bare_point                      Bare_point;
typedef Gt::Point_3                         Point;

typedef Alpha_shape_3::Alpha_iterator               Alpha_iterator;
typedef Gt::FT FT;

typedef CGAL::Object    Object;

int main(int argc, char* argv[])
{
  std::list<Weighted_point> lwp;
  string infile = argv[1];
  string outfile = (argc >= 3)? argv[2] : "output";
  string eng = (argc >= 4) ? argv[3] : "a";
  std::ifstream is;
  is.open(infile.c_str(), ifstream::in);
	if (!is.good())
	{
		std::cout<<"\nUnable to Open File "<<infile&lt;&lt;&quot; for
reading!&quot;;
		return -2;
	}
  int n;
  is >> n;
  std::cout << "Reading " << n << " points " << std::endl;
  double x, y, z, r;
  for( ; n>0 ; n--)    {
    //is >> p;
    is >> x;
    is >> y;
    is >> z;
    is >> r;
    lwp.push_back(Weighted_point(Bare_point( x,  y,  z), r));
  }
  is.close();

  //build alpha_shape  in GENERAL mode and set alpha=0
  Alpha_shape_3  as(lwp.begin(), lwp.end(),0, Alpha_shape_3::GENERAL);
  //explore the 0-shape - It is dual to the boundary of the union.
  std::list<Cell_handle> cells;
  std::list<Facet>       facets;
  std::list<Edge>        edges;
 
as.get_alpha_shape_cells(std::back_inserter(cells),Alpha_shape_3::INTERIOR);
 
as.get_alpha_shape_facets(std::back_inserter(facets),Alpha_shape_3::REGULAR);
 
as.get_alpha_shape_facets(std::back_inserter(facets),Alpha_shape_3::SINGULAR);
 
as.get_alpha_shape_edges(std::back_inserter(edges),Alpha_shape_3::SINGULAR);

  std::cout << " The 0-shape has : " << std::endl;
  std::cout << cells.size() << " interior tetrahedra" << std::endl;
  std::cout << facets.size() << " boundary facets" << std::endl;
  std::cout << edges.size()  << " singular edges" << std::endl;
  
  //i'm not sure if this is the correct way to access the filtration
  std::list        objects;   
  as.filtration(std::back_inserter(objects));
  std::cout << objects.size() << std::endl;
  std::list::iterator pos;
  pos = objects.begin();
  while (pos != objects.end()){
    cout << *pos << endl;
    pos++;
  }

It works, but the information I've found in objects is wrong.
Thanks so much for all your suggestions.

Regards
Stevens



--
View this message in context: http://cgal-discuss.949826.n4.nabble.com/Help-with-filtration-and-filtration-with-alpha-values-tp4659524.html
Sent from the cgal-discuss mailing list archive at Nabble.com.


-- 
Mariette Yvinec
Geometrica project team
INRIA  Sophia-Antipolis  





Archive powered by MHonArc 2.6.18.

Top of Page