mirror of https://github.com/CGAL/cgal
added face base with info (+ example)
This commit is contained in:
parent
5499e265ff
commit
cc498412f7
|
|
@ -0,0 +1,62 @@
|
|||
#include <fstream>
|
||||
|
||||
// CGAL headers
|
||||
#include <CGAL/IO/io.h>
|
||||
|
||||
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
|
||||
|
||||
#include <CGAL/Hyperbolic_triangulation_face_base_with_info_2.h>
|
||||
#include <CGAL/Hyperbolic_Delaunay_triangulation_2.h>
|
||||
#include <CGAL/Hyperbolic_Delaunay_triangulation_traits_2.h>
|
||||
|
||||
#include <CGAL/IO/Color.h>
|
||||
|
||||
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
|
||||
typedef CGAL::Hyperbolic_Delaunay_triangulation_traits_2< K > Gt;
|
||||
|
||||
typedef Gt::Point_2 Point_2;
|
||||
|
||||
typedef CGAL::Hyperbolic_triangulation_face_base_with_info_2<CGAL::Color, Gt> Fb;
|
||||
typedef CGAL::Triangulation_data_structure_2 <
|
||||
CGAL::Triangulation_vertex_base_2<Gt>, Fb > TDS;
|
||||
typedef CGAL::Hyperbolic_Delaunay_triangulation_2<Gt, TDS> Dt;
|
||||
|
||||
int main()
|
||||
{
|
||||
std::vector<Point_2> pts;
|
||||
Point_2 p;
|
||||
|
||||
std::ifstream ifs("input-file");
|
||||
while(ifs >> p) {
|
||||
pts.push_back(p);
|
||||
}
|
||||
|
||||
Dt dt;
|
||||
|
||||
dt.insert(pts.begin(),pts.end());
|
||||
Dt::Vertex_handle vo = dt.insert(Point_2(0,0));
|
||||
|
||||
int origin_faces = 0;
|
||||
Dt::Hyperbolic_faces_iterator fit;
|
||||
for (fit = dt.hyperbolic_faces_begin(); fit != dt.hyperbolic_faces_end(); ++fit)
|
||||
if (fit->has_vertex(vo))
|
||||
{
|
||||
fit->info() = CGAL::RED;
|
||||
origin_faces++;
|
||||
}
|
||||
|
||||
int red_faces = 0;
|
||||
for (fit = dt.hyperbolic_faces_begin(); fit != dt.hyperbolic_faces_end(); ++fit)
|
||||
if (fit->info() == CGAL::RED)
|
||||
red_faces++;
|
||||
|
||||
assert(red_faces == origin_faces);
|
||||
|
||||
std::cout << "number of points " << std::distance(pts.begin(),pts.end())+1 << std::endl;
|
||||
std::cout << "Number of (finite) vertices: " << dt.number_of_vertices() << std::endl;
|
||||
std::cout << "number of (finite) Euclidean faces: " << dt.number_of_faces() << std::endl;
|
||||
std::cout << "number of hyperbolic faces: " << dt.number_of_hyperbolic_faces() << std::endl;
|
||||
std::cout << "number of faces having the origin as vertex: " << origin_faces << std::endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -0,0 +1,71 @@
|
|||
// Copyright (c) 2003 INRIA Sophia-Antipolis (France).
|
||||
// All rights reserved.
|
||||
//
|
||||
// This file is part of CGAL (www.cgal.org).
|
||||
// You can redistribute it and/or modify it under the terms of the GNU
|
||||
// General Public License as published by the Free Software Foundation,
|
||||
// either version 3 of the License, or (at your option) any later version.
|
||||
//
|
||||
// Licensees holding a valid commercial license may use this file in
|
||||
// accordance with the commercial license agreement provided with the software.
|
||||
//
|
||||
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
||||
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// $URL$
|
||||
// $Id$
|
||||
//
|
||||
//
|
||||
// Author(s) : Monique Teillaud
|
||||
|
||||
|
||||
#ifndef CGAL_HYPERBOLIC_TRIANGULATION_FACE_BASE_WITH_INFO_2_H
|
||||
#define CGAL_HYPERBOLIC_TRIANGULATION_FACE_BASE_WITH_INFO_2_H
|
||||
|
||||
#include <CGAL/Hyperbolic_triangulation_face_base_2.h>
|
||||
|
||||
namespace CGAL {
|
||||
|
||||
template < typename Info_, typename GT,
|
||||
typename Fb_ = Hyperbolic_triangulation_face_base_2<GT> >
|
||||
class Hyperbolic_triangulation_face_base_with_info_2
|
||||
: public Fb_
|
||||
{
|
||||
Info_ _info;
|
||||
public:
|
||||
typedef typename Fb_::Vertex_handle Vertex_handle;
|
||||
typedef typename Fb_::Face_handle Face_handle;
|
||||
typedef Info_ Info;
|
||||
|
||||
template < typename TDS2 >
|
||||
struct Rebind_TDS {
|
||||
typedef typename Fb_::template Rebind_TDS<TDS2>::Other Fb2;
|
||||
typedef Hyperbolic_triangulation_face_base_with_info_2<Info, GT, Fb2> Other;
|
||||
};
|
||||
|
||||
Hyperbolic_triangulation_face_base_with_info_2()
|
||||
: Fb_()
|
||||
{}
|
||||
|
||||
Hyperbolic_triangulation_face_base_with_info_2(Vertex_handle v0,
|
||||
Vertex_handle v1,
|
||||
Vertex_handle v2)
|
||||
: Fb_(v0, v1, v2)
|
||||
{}
|
||||
|
||||
Hyperbolic_triangulation_face_base_with_info_2(Vertex_handle v0,
|
||||
Vertex_handle v1,
|
||||
Vertex_handle v2,
|
||||
Face_handle n0,
|
||||
Face_handle n1,
|
||||
Face_handle n2 )
|
||||
: Fb_(v0, v1, v2, n0, n1, n2)
|
||||
{}
|
||||
|
||||
const Info& info() const { return _info; }
|
||||
Info& info() { return _info; }
|
||||
};
|
||||
|
||||
} //namespace CGAL
|
||||
|
||||
#endif // CGAL_HYPERBOLIC_TRIANGULATION_FACE_BASE_WITH_INFO_2_H
|
||||
Loading…
Reference in New Issue