File: ex_fixed_weighted_alpha_shapes_3.cpp

package info (click to toggle)
cgal 4.5-2
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 69,700 kB
  • ctags: 118,537
  • sloc: cpp: 571,870; ansic: 110,997; sh: 725; python: 92; makefile: 87
file content (57 lines) | stat: -rw-r--r-- 2,476 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Regular_triangulation_3.h>
#include <CGAL/Regular_triangulation_euclidean_traits_3.h>
#include <CGAL/Fixed_alpha_shape_3.h>
#include <CGAL/Fixed_alpha_shape_vertex_base_3.h>
#include <CGAL/Fixed_alpha_shape_cell_base_3.h>
#include <list>

typedef CGAL::Exact_predicates_inexact_constructions_kernel K;

typedef CGAL::Regular_triangulation_euclidean_traits_3<K> Gt;

typedef CGAL::Fixed_alpha_shape_vertex_base_3<Gt>         Vb;
typedef CGAL::Fixed_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::Fixed_alpha_shape_3<Triangulation_3>        Fixed_alpha_shape_3;

typedef Fixed_alpha_shape_3::Cell_handle                  Cell_handle;
typedef Fixed_alpha_shape_3::Vertex_handle                Vertex_handle;
typedef Fixed_alpha_shape_3::Facet                        Facet;
typedef Fixed_alpha_shape_3::Edge                         Edge;
typedef Gt::Weighted_point                                Weighted_point;
typedef Gt::Bare_point                                    Bare_point;

int main()
{
  std::list<Weighted_point> lwp;

  //input : a small molecule
  lwp.push_back(Weighted_point(Bare_point( 1, -1, -1), 4));
  lwp.push_back(Weighted_point(Bare_point(-1,  1, -1), 4));
  lwp.push_back(Weighted_point(Bare_point(-1, -1,  1), 4));
  lwp.push_back(Weighted_point(Bare_point( 1,  1,  1), 4));
  lwp.push_back(Weighted_point(Bare_point( 2,  2,  2), 1));

  //build one alpha_shape  with alpha=0
  Fixed_alpha_shape_3  as(lwp.begin(), lwp.end(), 0);

  //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),
			   Fixed_alpha_shape_3::INTERIOR);
  as.get_alpha_shape_facets(std::back_inserter(facets),
			    Fixed_alpha_shape_3::REGULAR);
  as.get_alpha_shape_facets(std::back_inserter(facets),
			    Fixed_alpha_shape_3::SINGULAR);
  as.get_alpha_shape_edges(std::back_inserter(edges),
			   Fixed_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;
  return 0;
}