xc
BasicAlphaShape2d.h
1 // -*-c++-*-
2 //----------------------------------------------------------------------------
3 // xc utils library; general purpose classes and functions.
4 //
5 // Copyright (C) Luis C. Pérez Tato
6 //
7 // XC utils is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by
9 // the Free Software Foundation, either version 3 of the License, or
10 // (at your option) any later version.
11 //
12 // This software is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with this program.
19 // If not, see <http://www.gnu.org/licenses/>.
20 //----------------------------------------------------------------------------
21 //BasicAlphaShape2d.h
22 
23 #ifndef BASICALPHASHAPE2D_H
24 #define BASICALPHASHAPE2D_H
25 
26 #include "utility/geom/d2/GeomObj2d.h"
27 #include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
28 #include <CGAL/Alpha_shape_2.h>
29 #include <CGAL/Alpha_shape_vertex_base_2.h>
30 #include <CGAL/Alpha_shape_face_base_2.h>
31 #include <CGAL/Delaunay_triangulation_2.h>
32 #include <CGAL/algorithm.h>
33 #include <CGAL/assertions.h>
34 #include <fstream>
35 #include <iostream>
36 #include <list>
37 #include <vector>
38 typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
39 typedef K::FT FT;
40 typedef K::Point_2 Point_2;
41 typedef K::Segment_2 Segment;
42 typedef CGAL::Alpha_shape_vertex_base_2<K> Vb;
43 typedef CGAL::Alpha_shape_face_base_2<K> Fb;
44 typedef CGAL::Triangulation_data_structure_2<Vb,Fb> Tds;
45 typedef CGAL::Delaunay_triangulation_2<K,Tds> Triangulation_2;
46 typedef CGAL::Alpha_shape_2<Triangulation_2> Alpha_shape_2;
47 
48 class Polygon2d;
49 
51 //
56 
58 //
64  {
65  protected:
66  Alpha_shape_2 *A;
67  void alloc(const GeomObj::list_Pos2d &lp, const double &alpha);
68  void free(void);
69  public:
70  BasicAlphaShape2d(const GeomObj::list_Pos2d &lp, const double &alpha);
71  ~BasicAlphaShape2d(void);
72 
73  void setAlpha(const double alpha);
74  double getOptimalAlpha(const size_t &nb_components= 1) const;
75  Polygon2d getPolygon2d(void);
76  };
77 
78 
79 
80 #endif
void alloc(const GeomObj::list_Pos2d &lp, const double &alpha)
Creates alpha shape object.
Definition: BasicAlphaShape2d.cc:63
Base class for position lists.
Definition: PolyPos.h:35
Polygon2d getPolygon2d(void)
Return the alpha shape from the point list.
Definition: BasicAlphaShape2d.cc:107
~BasicAlphaShape2d(void)
Destructor.
Definition: BasicAlphaShape2d.cc:99
Polígono en dos dimensiones.
Definition: Polygon2d.h:38
void free(void)
Frees memory.
Definition: BasicAlphaShape2d.cc:83
Polygon2d get_basic_alpha_shape2d(const GeomObj::list_Pos2d &)
Return the basic alpha shap of the point set argument.
Definition: BasicAlphaShape2d.cc:116
BasicAlphaShape2d(const GeomObj::list_Pos2d &lp, const double &alpha)
Constructor.
Definition: BasicAlphaShape2d.cc:91
Basic alpha shape of the point set argument.
Definition: BasicAlphaShape2d.h:63