Merge branch 'Triangulation-add_regular_tri-cjamin_mglisse-old' into Triangulation-add_regular_tri-cjamin_mglisse

This commit is contained in:
Clement Jamin 2016-05-18 19:41:22 +02:00
commit 9487c71ad1
78 changed files with 4381 additions and 559 deletions

View File

@ -37,6 +37,7 @@ icc 15 work.
\cgalModels `Kernel_d`
\cgalModels `DelaunayTriangulationTraits`
\cgalModels `RegularTriangulationTraits`
\sa `CGAL::Cartesian_d<FieldNumberType>`
\sa `CGAL::Homogeneous_d<RingNumberType>`
@ -74,6 +75,21 @@ Cartesian_const_iterator_d cartesian_begin()const;
Cartesian_const_iterator_d cartesian_end()const;
};
/*!
represents a weighted point in the Euclidean space
\cgalModels `DefaultConstructible`
\cgalModels `Assignable`
*/
class Weighted_point_d {
public:
/*! introduces a weighted point with point p and weight w. */
Weighted_point_d(const Point_d& p, const double& w);
/*! extracts the point of a weighted point. */
Point_d point() const;
/*! extracts the weight of a weighted point. */
double weight() const;
};
/*! \cgalModels `Kernel_d::Center_of_sphere_d`
*/
struct Construct_circumcenter_d {

View File

@ -26,6 +26,7 @@
#include <CGAL/NewKernel_d/Kernel_d_interface.h>
#include <CGAL/internal/Exact_type_selector.h>
#include <CGAL/Interval_nt.h>
#include <CGAL/NewKernel_d/Types/Weighted_point.h>
namespace CGAL {

View File

@ -86,6 +86,7 @@ struct Cartesian_LA_base_d : public Dimension_base<Dim_>
::add<Segment_tag>::type
::add<Hyperplane_tag>::type
::add<Sphere_tag>::type
::add<Weighted_point_tag>::type
Object_list;
typedef typeset< Point_cartesian_const_iterator_tag>::type

View File

@ -89,6 +89,7 @@ template<class R_> struct Construct_flat_orientation : private Store_kernel<R_>
std::vector<int>& rest=o.rest; rest.reserve(dim+1);
for(int i=0; i<dim+1; ++i) rest.push_back(i);
for( ; f != e ; ++col, ++f ) {
//std::cerr << "(*f)[0]=" << (*f)[0] << std::endl;
Point const&p=*f;
// use a coordinate iterator instead?
for(int i=0; i<dim; ++i) coord(col, i) = ccc(p, i);
@ -268,11 +269,61 @@ template<class R_> struct In_flat_side_of_oriented_sphere : private Store_kernel
}
};
template<class R_> struct In_flat_power_test_raw : private Store_kernel<R_> {
CGAL_FUNCTOR_INIT_STORE(In_flat_power_test_raw)
typedef R_ R;
typedef typename Get_type<R, FT_tag>::type FT;
typedef typename Get_type<R, Point_tag>::type Point;
typedef typename Get_type<R, Orientation_tag>::type result_type;
typedef typename Increment_dimension<typename R::Default_ambient_dimension,2>::type D1;
typedef typename Increment_dimension<typename R::Max_ambient_dimension,2>::type D2;
typedef typename R::LA::template Rebind_dimension<D1,D2>::Other LA;
typedef typename LA::Square_matrix Matrix;
template<class Iter, class IterW, class Wt>
result_type operator()(Flat_orientation const&o, Iter f, Iter e, IterW fw, Point const&x, Wt const&w) const {
// TODO: can't work in the projection, but we should at least remove the row of 1s.
typename Get_functor<R, Compute_point_cartesian_coordinate_tag>::type c(this->kernel());
typename Get_functor<R, Point_dimension_tag>::type pd(this->kernel());
int d=pd(*f);
Matrix m(d+2,d+2);
int i=0;
for(;f!=e;++f,++fw,++i) {
Point const& p=*f;
m(i,0)=1;
m(i,d+1)=-*fw;
for(int j=0;j<d;++j){
m(i,j+1)=c(p,j);
m(i,d+1)+=CGAL_NTS square(m(i,j+1));
}
}
for(std::vector<int>::const_iterator it = o.rest.begin(); it != o.rest.end() /* i<d+1 */; ++i, ++it) {
m(i,0)=1;
for(int j=0;j<d;++j){
m(i,j+1)=0; // unneeded if the matrix is initialized to 0
}
if(*it != d) m(i,d+1)=m(i,1+*it)=1;
else m(i,d+1)=0;
}
m(d+1,0)=1;
m(d+1,d+1)=-w;
for(int j=0;j<d;++j){
m(d+1,j+1)=c(x,j);
m(d+1,d+1)+=CGAL_NTS square(m(d+1,j+1));
}
result_type ret = -LA::sign_of_determinant(CGAL_MOVE(m));
if(o.reverse) ret=-ret;
return ret;
}
};
}
CGAL_KD_DEFAULT_TYPE(Flat_orientation_tag,(CGAL::CartesianDKernelFunctors::Flat_orientation),(),());
CGAL_KD_DEFAULT_FUNCTOR(In_flat_orientation_tag,(CartesianDKernelFunctors::In_flat_orientation<K>),(Point_tag),(Compute_point_cartesian_coordinate_tag,Point_dimension_tag));
CGAL_KD_DEFAULT_FUNCTOR(In_flat_side_of_oriented_sphere_tag,(CartesianDKernelFunctors::In_flat_side_of_oriented_sphere<K>),(Point_tag),(Compute_point_cartesian_coordinate_tag,Point_dimension_tag));
CGAL_KD_DEFAULT_FUNCTOR(In_flat_power_test_raw_tag,(CartesianDKernelFunctors::In_flat_power_test_raw<K>),(Point_tag),(Compute_point_cartesian_coordinate_tag,Point_dimension_tag));
CGAL_KD_DEFAULT_FUNCTOR(Construct_flat_orientation_tag,(CartesianDKernelFunctors::Construct_flat_orientation<K>),(Point_tag),(Compute_point_cartesian_coordinate_tag,Point_dimension_tag,In_flat_orientation_tag));
CGAL_KD_DEFAULT_FUNCTOR(Contained_in_affine_hull_tag,(CartesianDKernelFunctors::Contained_in_affine_hull<K>),(Point_tag),(Compute_point_cartesian_coordinate_tag,Point_dimension_tag));
}

View File

@ -97,7 +97,7 @@ class KernelD_converter_
//typedef typename KOC::argument_type K1_Obj;
//typedef typename KOC::result_type K2_Obj;
public:
using Base::operator(); // don't use directly, just make it accessible to the next level
using Base::operator(); // don't use directly, just make it accessible to the next level
K2_Obj helper(K1_Obj const& o,CGAL_BOOSTD true_type)const{
return KOC()(this->myself().kernel(),this->myself().kernel2(),this->myself(),o);
}

View File

@ -54,6 +54,7 @@ template <class Base_> struct Kernel_d_interface : public Base_ {
typedef typename Get_type<Base, Ray_tag>::type Ray_d;
typedef typename Get_type<Base, Iso_box_tag>::type Iso_box_d;
typedef typename Get_type<Base, Aff_transformation_tag>::type Aff_transformation_d;
typedef typename Get_type<Base, Weighted_point_tag>::type Weighted_point_d;
typedef typename Get_functor<Base, Compute_point_cartesian_coordinate_tag>::type Compute_coordinate_d;
typedef typename Get_functor<Base, Compare_lexicographically_tag>::type Compare_lexicographically_d;
typedef typename Get_functor<Base, Equal_points_tag>::type Equal_d;
@ -64,10 +65,12 @@ template <class Base_> struct Kernel_d_interface : public Base_ {
typedef typename Get_functor<Base, Less_point_cartesian_coordinate_tag>::type Less_coordinate_d;
typedef typename Get_functor<Base, Point_dimension_tag>::type Point_dimension_d;
typedef typename Get_functor<Base, Side_of_oriented_sphere_tag>::type Side_of_oriented_sphere_d;
typedef typename Get_functor<Base, Power_test_tag>::type Power_test_d;
typedef typename Get_functor<Base, Contained_in_affine_hull_tag>::type Contained_in_affine_hull_d;
typedef typename Get_functor<Base, Construct_flat_orientation_tag>::type Construct_flat_orientation_d;
typedef typename Get_functor<Base, In_flat_orientation_tag>::type In_flat_orientation_d;
typedef typename Get_functor<Base, In_flat_side_of_oriented_sphere_tag>::type In_flat_side_of_oriented_sphere_d;
typedef typename Get_functor<Base, In_flat_power_test_tag>::type In_flat_power_test_d;
typedef typename Get_functor<Base, Point_to_vector_tag>::type Point_to_vector_d;
typedef typename Get_functor<Base, Vector_to_point_tag>::type Vector_to_point_d;
typedef typename Get_functor<Base, Scaled_vector_tag>::type Scaled_vector_d;
@ -83,6 +86,7 @@ template <class Base_> struct Kernel_d_interface : public Base_ {
typedef typename Get_functor<Base, Construct_ttag<Ray_tag> >::type Construct_ray_d;
typedef typename Get_functor<Base, Construct_ttag<Iso_box_tag> >::type Construct_iso_box_d;
typedef typename Get_functor<Base, Construct_ttag<Aff_transformation_tag> >::type Construct_aff_transformation_d;
typedef typename Get_functor<Base, Construct_ttag<Weighted_point_tag> >::type Construct_weighted_point_d;
typedef typename Get_functor<Base, Midpoint_tag>::type Midpoint_d;
struct Component_accessor_d : private Store_kernel<Kernel> {
typedef Kernel R_; // for the macro
@ -164,6 +168,9 @@ template <class Base_> struct Kernel_d_interface : public Base_ {
typedef typename Get_functor<Base, Construct_min_vertex_tag>::type Construct_min_vertex_d;
typedef typename Get_functor<Base, Construct_max_vertex_tag>::type Construct_max_vertex_d;
typedef typename Get_functor<Base, Point_weight_tag>::type Point_weight_d;
typedef typename Get_functor<Base, Point_drop_weight_tag>::type Point_drop_weight_d;
//TODO:
//typedef ??? Intersect_d;
@ -180,6 +187,7 @@ template <class Base_> struct Kernel_d_interface : public Base_ {
Point_dimension_d point_dimension_d_object()const{ return Point_dimension_d(*this); }
Point_of_sphere_d point_of_sphere_d_object()const{ return Point_of_sphere_d(*this); }
Side_of_oriented_sphere_d side_of_oriented_sphere_d_object()const{ return Side_of_oriented_sphere_d(*this); }
Power_test_d power_test_d_object()const{ return Power_test_d(*this); }
Side_of_bounded_sphere_d side_of_bounded_sphere_d_object()const{ return Side_of_bounded_sphere_d(*this); }
Contained_in_affine_hull_d contained_in_affine_hull_d_object()const{ return Contained_in_affine_hull_d(*this); }
Contained_in_linear_hull_d contained_in_linear_hull_d_object()const{ return Contained_in_linear_hull_d(*this); }
@ -187,6 +195,7 @@ template <class Base_> struct Kernel_d_interface : public Base_ {
Construct_flat_orientation_d construct_flat_orientation_d_object()const{ return Construct_flat_orientation_d(*this); }
In_flat_orientation_d in_flat_orientation_d_object()const{ return In_flat_orientation_d(*this); }
In_flat_side_of_oriented_sphere_d in_flat_side_of_oriented_sphere_d_object()const{ return In_flat_side_of_oriented_sphere_d(*this); }
In_flat_power_test_d in_flat_power_test_d_object()const{ return In_flat_power_test_d(*this); }
Point_to_vector_d point_to_vector_d_object()const{ return Point_to_vector_d(*this); }
Vector_to_point_d vector_to_point_d_object()const{ return Vector_to_point_d(*this); }
Scaled_vector_d scaled_vector_d_object()const{ return Scaled_vector_d(*this); }
@ -221,6 +230,10 @@ template <class Base_> struct Kernel_d_interface : public Base_ {
Construct_aff_transformation_d construct_aff_transformation_d_object()const{ return Construct_aff_transformation_d(*this); }
Construct_min_vertex_d construct_min_vertex_d_object()const{ return Construct_min_vertex_d(*this); }
Construct_max_vertex_d construct_max_vertex_d_object()const{ return Construct_max_vertex_d(*this); }
Construct_weighted_point_d construct_weighted_point_d_object()const{ return Construct_weighted_point_d(*this); }
Point_weight_d point_weight_d_object()const{ return Point_weight_d(*this); }
Point_drop_weight_d point_drop_weight_d_object()const{ return Point_drop_weight_d(*this); }
// Dummies for those required functors missing a concept.
typedef Null_functor Position_on_line_d;

View File

@ -118,5 +118,17 @@ template <class K1, class K2> struct KO_converter<Sphere_tag,K1,K2>{
}
};
template <class K1, class K2> struct KO_converter<Weighted_point_tag,K1,K2>{
typedef typename Get_type<K1, Weighted_point_tag>::type argument_type;
typedef typename Get_type<K2, Weighted_point_tag>::type result_type;
template <class C>
result_type operator()(K1 const& k1, K2 const& k2, C const& conv, argument_type const& s) const {
typename Get_functor<K1, Point_drop_weight_tag>::type pdw(k1);
typename Get_functor<K1, Point_weight_tag>::type pw(k1);
typename Get_functor<K2, Construct_ttag<Weighted_point_tag> >::type cwp(k2);
return cwp(conv(pdw(s)),conv(pw(s)));
}
};
}
#endif

View File

@ -0,0 +1,125 @@
// Copyright (c) 2014
// INRIA Saclay-Ile de France (France)
//
// This file is part of CGAL (www.cgal.org); you can redistribute it and/or
// modify it under the terms of the GNU Lesser 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) : Marc Glisse
#ifndef CGAL_KD_TYPE_WP_H
#define CGAL_KD_TYPE_WP_H
#include <CGAL/NewKernel_d/store_kernel.h>
#include <boost/iterator/counting_iterator.hpp>
namespace CGAL {
namespace KerD {
template <class R_> class Weighted_point {
typedef typename Get_type<R_, FT_tag>::type FT_;
typedef typename Get_type<R_, Point_tag>::type Point_;
Point_ c_;
FT_ w_;
public:
Weighted_point(Point_ const&p, FT_ const&w): c_(p), w_(w) {}
// TODO: Add a piecewise constructor?
Point_ const& point()const{return c_;}
FT_ const& weight()const{return w_;}
};
}
namespace CartesianDKernelFunctors {
template <class R_> struct Construct_weighted_point : Store_kernel<R_> {
CGAL_FUNCTOR_INIT_STORE(Construct_weighted_point)
typedef typename Get_type<R_, Weighted_point_tag>::type result_type;
typedef typename Get_type<R_, Point_tag>::type Point;
typedef typename Get_type<R_, FT_tag>::type FT;
result_type operator()(Point const&a, FT const&b)const{
return result_type(a,b);
}
// Not really needed
result_type operator()()const{
typename Get_functor<R_, Construct_ttag<Point_tag> >::type cp(this->kernel());
return result_type(cp(),0);
}
};
template <class R_> struct Point_drop_weight {
CGAL_FUNCTOR_INIT_IGNORE(Point_drop_weight)
typedef typename Get_type<R_, Weighted_point_tag>::type argument_type;
typedef typename Get_type<R_, Point_tag>::type const& result_type;
// Returning a reference is fragile
result_type operator()(argument_type const&s)const{
return s.point();
}
};
template <class R_> struct Point_weight {
CGAL_FUNCTOR_INIT_IGNORE(Point_weight)
typedef typename Get_type<R_, Weighted_point_tag>::type argument_type;
typedef typename Get_type<R_, FT_tag>::type result_type;
result_type operator()(argument_type const&s)const{
return s.weight();
}
};
template<class R_> struct Power_test : private Store_kernel<R_> {
CGAL_FUNCTOR_INIT_STORE(Power_test)
typedef R_ R;
typedef typename Get_type<R, Oriented_side_tag>::type result_type;
template<class Iter, class Pt>
result_type operator()(Iter const& f, Iter const& e, Pt const& p0) const {
typename Get_functor<R, Power_test_raw_tag>::type ptr(this->kernel());
typename Get_functor<R, Point_drop_weight_tag>::type pdw(this->kernel());
typename Get_functor<R, Point_weight_tag>::type pw(this->kernel());
return ptr (
make_transforming_iterator (f, pdw),
make_transforming_iterator (e, pdw),
make_transforming_iterator (f, pw),
pdw (p0),
pw (p0));
}
};
template<class R_> struct In_flat_power_test : private Store_kernel<R_> {
CGAL_FUNCTOR_INIT_STORE(In_flat_power_test)
typedef R_ R;
typedef typename Get_type<R, Oriented_side_tag>::type result_type;
template<class Fo, class Iter, class Pt>
result_type operator()(Fo const& fo, Iter const& f, Iter const& e, Pt const& p0) const {
typename Get_functor<R, In_flat_power_test_raw_tag>::type ptr(this->kernel());
typename Get_functor<R, Point_drop_weight_tag>::type pdw(this->kernel());
typename Get_functor<R, Point_weight_tag>::type pw(this->kernel());
return ptr (
fo,
make_transforming_iterator (f, pdw),
make_transforming_iterator (e, pdw),
make_transforming_iterator (f, pw),
pdw (p0),
pw (p0));
}
};
}
CGAL_KD_DEFAULT_TYPE(Weighted_point_tag,(CGAL::KerD::Weighted_point<K>),(Point_tag),());
CGAL_KD_DEFAULT_FUNCTOR(Construct_ttag<Weighted_point_tag>,(CartesianDKernelFunctors::Construct_weighted_point<K>),(Weighted_point_tag,Point_tag),());
CGAL_KD_DEFAULT_FUNCTOR(Point_drop_weight_tag,(CartesianDKernelFunctors::Point_drop_weight<K>),(Weighted_point_tag,Point_tag),());
CGAL_KD_DEFAULT_FUNCTOR(Point_weight_tag,(CartesianDKernelFunctors::Point_weight<K>),(Weighted_point_tag,Point_tag),());
CGAL_KD_DEFAULT_FUNCTOR(Power_test_tag,(CartesianDKernelFunctors::Power_test<K>),(Weighted_point_tag),(Power_test_raw_tag,Point_drop_weight_tag,Point_weight_tag));
CGAL_KD_DEFAULT_FUNCTOR(In_flat_power_test_tag,(CartesianDKernelFunctors::In_flat_power_test<K>),(Weighted_point_tag),(In_flat_power_test_raw_tag,Point_drop_weight_tag,Point_weight_tag));
} // namespace CGAL
#endif

View File

@ -33,6 +33,7 @@
#include <CGAL/NewKernel_d/Wrapper/Segment_d.h>
#include <CGAL/NewKernel_d/Wrapper/Sphere_d.h>
#include <CGAL/NewKernel_d/Wrapper/Hyperplane_d.h>
#include <CGAL/NewKernel_d/Wrapper/Weighted_point_d.h>
#include <CGAL/NewKernel_d/Wrapper/Ref_count_obj.h>
@ -111,6 +112,7 @@ CGAL_REGISTER_OBJECT_WRAPPER(Vector);
CGAL_REGISTER_OBJECT_WRAPPER(Segment);
CGAL_REGISTER_OBJECT_WRAPPER(Sphere);
CGAL_REGISTER_OBJECT_WRAPPER(Hyperplane);
CGAL_REGISTER_OBJECT_WRAPPER(Weighted_point);
#undef CGAL_REGISTER_OBJECT_WRAPPER
// Note: this tends to be an all or nothing thing currently, wrapping

View File

@ -0,0 +1,129 @@
// Copyright (c) 2014
// INRIA Saclay-Ile de France (France)
//
// This file is part of CGAL (www.cgal.org); you can redistribute it and/or
// modify it under the terms of the GNU Lesser 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) : Marc Glisse
#ifndef CGAL_WRAPPER_WEIGHTED_POINT_D_H
#define CGAL_WRAPPER_WEIGHTED_POINT_D_H
#include <CGAL/representation_tags.h>
#include <boost/static_assert.hpp>
#include <boost/type_traits.hpp>
#include <CGAL/Kernel/Return_base_tag.h>
#include <CGAL/Dimension.h>
#ifndef CGAL_CXX11
#include <boost/preprocessor/repetition.hpp>
#endif
#include <boost/utility/result_of.hpp>
namespace CGAL {
namespace Wrap {
template <class R_>
class Weighted_point_d : public Get_type<typename R_::Kernel_base, Weighted_point_tag>::type
{
typedef typename Get_type<R_, FT_tag>::type FT_;
typedef typename R_::Kernel_base Kbase;
typedef typename Get_type<R_, Point_tag>::type Point_;
typedef typename Get_functor<Kbase, Construct_ttag<Weighted_point_tag> >::type CWPBase;
typedef typename Get_functor<Kbase, Point_drop_weight_tag>::type PDWBase;
typedef typename Get_functor<Kbase, Point_weight_tag>::type PWBase;
typedef Weighted_point_d Self;
BOOST_STATIC_ASSERT((boost::is_same<Self, typename Get_type<R_, Weighted_point_tag>::type>::value));
public:
typedef Tag_true Is_wrapper;
typedef typename R_::Default_ambient_dimension Ambient_dimension;
typedef Dimension_tag<0> Feature_dimension;
typedef typename Get_type<Kbase, Weighted_point_tag>::type Rep;
const Rep& rep() const
{
return *this;
}
Rep& rep()
{
return *this;
}
typedef R_ R;
#ifdef CGAL_CXX11
template<class...U,class=typename std::enable_if<!std::is_same<std::tuple<typename std::decay<U>::type...>,std::tuple<Weighted_point_d> >::value>::type> explicit Weighted_point_d(U&&...u)
: Rep(CWPBase()(std::forward<U>(u)...)){}
// // called from Construct_point_d
// template<class...U> explicit Point_d(Eval_functor&&,U&&...u)
// : Rep(Eval_functor(), std::forward<U>(u)...){}
template<class F,class...U> explicit Weighted_point_d(Eval_functor&&,F&&f,U&&...u)
: Rep(std::forward<F>(f)(std::forward<U>(u)...)){}
#if 0
// the new standard may make this necessary
Point_d(Point_d const&)=default;
Point_d(Point_d &);//=default;
Point_d(Point_d &&)=default;
#endif
// try not to use these
Weighted_point_d(Rep const& v) : Rep(v) {}
Weighted_point_d(Rep& v) : Rep(static_cast<Rep const&>(v)) {}
Weighted_point_d(Rep&& v) : Rep(std::move(v)) {}
#else
Weighted_point_d() : Rep(CWPBase()()) {}
Weighted_point_d(Rep const& v) : Rep(v) {} // try not to use it
#define CGAL_CODE(Z,N,_) template<BOOST_PP_ENUM_PARAMS(N,class T)> \
explicit Weighted_point_d(BOOST_PP_ENUM_BINARY_PARAMS(N,T,const&t)) \
: Rep(CWPBase()( \
BOOST_PP_ENUM_PARAMS(N,t))) {} \
\
template<class F,BOOST_PP_ENUM_PARAMS(N,class T)> \
Weighted_point_d(Eval_functor,F const& f,BOOST_PP_ENUM_BINARY_PARAMS(N,T,const&t)) \
: Rep(f(BOOST_PP_ENUM_PARAMS(N,t))) {}
/*
template<BOOST_PP_ENUM_PARAMS(N,class T)> \
Point_d(Eval_functor,BOOST_PP_ENUM_BINARY_PARAMS(N,T,const&t)) \
: Rep(Eval_functor(), BOOST_PP_ENUM_PARAMS(N,t)) {}
*/
BOOST_PP_REPEAT_FROM_TO(1,11,CGAL_CODE,_)
#undef CGAL_CODE
#endif
//TODO: use references?
Point_ point()const{
return Point_(Eval_functor(),PDWBase(),rep());
}
FT_ weight()const{
return PWBase()(rep());
}
};
} //namespace Wrap
} //namespace CGAL
#endif // CGAL_WRAPPER_SPHERE_D_H

View File

@ -554,6 +554,60 @@ template<class R_> struct Orientation<R_,false> : private Store_kernel<R_> {
}
#endif
namespace CartesianDKernelFunctors {
template<class R_> struct Power_test_raw : private Store_kernel<R_> {
CGAL_FUNCTOR_INIT_STORE(Power_test_raw)
typedef R_ R;
typedef typename Get_type<R, RT_tag>::type RT;
typedef typename Get_type<R, FT_tag>::type FT;
typedef typename Get_type<R, Point_tag>::type Point;
typedef typename Get_type<R, Oriented_side_tag>::type result_type;
typedef typename Increment_dimension<typename R::Default_ambient_dimension>::type D1;
typedef typename Increment_dimension<typename R::Max_ambient_dimension>::type D2;
typedef typename R::LA::template Rebind_dimension<D1,D2>::Other LA;
typedef typename LA::Square_matrix Matrix;
template<class IterP, class IterW, class Pt, class Wt>
result_type operator()(IterP f, IterP const& e, IterW fw, Pt const& p0, Wt const& w0) const {
typedef typename Get_functor<R, Squared_distance_to_origin_tag>::type Sqdo;
typename Get_functor<R, Compute_point_cartesian_coordinate_tag>::type c(this->kernel());
typename Get_functor<R, Point_dimension_tag>::type pd(this->kernel());
int d=pd(p0);
Matrix m(d+1,d+1);
if(CGAL::Is_stored<Sqdo>::value) {
Sqdo sqdo(this->kernel());
FT const& h0 = sqdo(p0) - w0;
for(int i=0;f!=e;++f,++fw,++i) {
Point const& p=*f;
for(int j=0;j<d;++j){
RT const& x=c(p,j);
m(i,j)=x-c(p0,j);
}
m(i,d) = sqdo(p) - *fw - h0;
}
} else {
for(int i=0;f!=e;++f,++fw,++i) {
Point const& p=*f;
m(i,d) = w0 - *fw;
for(int j=0;j<d;++j){
RT const& x=c(p,j);
m(i,j)=x-c(p0,j);
m(i,d)+=CGAL::square(m(i,j));
}
}
}
if(d%2)
return -LA::sign_of_determinant(CGAL_MOVE(m));
else
return LA::sign_of_determinant(CGAL_MOVE(m));
}
};
}
CGAL_KD_DEFAULT_FUNCTOR(Power_test_raw_tag,(CartesianDKernelFunctors::Power_test_raw<K>),(Point_tag),(Point_dimension_tag,Squared_distance_to_origin_tag,Compute_point_cartesian_coordinate_tag));
// TODO: make Side_of_oriented_sphere call Power_test_raw
namespace CartesianDKernelFunctors {
template<class R_> struct Side_of_oriented_sphere : private Store_kernel<R_> {
CGAL_FUNCTOR_INIT_STORE(Side_of_oriented_sphere)

View File

@ -172,6 +172,7 @@ namespace CGAL {
CGAL_DECL_OBJ(Iso_box, Object);
CGAL_DECL_OBJ(Bbox, Object);
CGAL_DECL_OBJ(Aff_transformation, Object);
CGAL_DECL_OBJ(Weighted_point, Object);
#undef CGAL_DECL_OBJ_
#undef CGAL_DECL_OBJ
@ -214,6 +215,7 @@ namespace CGAL {
CGAL_DECL_COMPUTE(Scalar_product);
CGAL_DECL_COMPUTE(Hyperplane_translation);
CGAL_DECL_COMPUTE(Value_at);
CGAL_DECL_COMPUTE(Point_weight);
#undef CGAL_DECL_COMPUTE
#define CGAL_DECL_ITER_OBJ(X,Y,Z,C) struct X##_tag {}; \
@ -266,6 +268,7 @@ namespace CGAL {
CGAL_DECL_CONSTRUCT(Construct_min_vertex,Point);
CGAL_DECL_CONSTRUCT(Construct_max_vertex,Point);
CGAL_DECL_CONSTRUCT(Construct_circumcenter,Point);
CGAL_DECL_CONSTRUCT(Point_drop_weight,Point);
#undef CGAL_DECL_CONSTRUCT
#if 0
#define CGAL_DECL_ITER_CONSTRUCT(X,Y) struct X##_tag {}; \
@ -306,6 +309,10 @@ namespace CGAL {
CGAL_DECL_PREDICATE(Affinely_independent);
CGAL_DECL_PREDICATE(Contained_in_linear_hull);
CGAL_DECL_PREDICATE(Contained_in_simplex);
CGAL_DECL_PREDICATE(Power_test_raw);
CGAL_DECL_PREDICATE(Power_test);
CGAL_DECL_PREDICATE(In_flat_power_test_raw);
CGAL_DECL_PREDICATE(In_flat_power_test);
#undef CGAL_DECL_PREDICATE
#define CGAL_DECL_MISC(X) struct X##_tag {}; \

View File

@ -22,6 +22,10 @@
#include <boost/iterator/iterator_adaptor.hpp>
#include <boost/utility/result_of.hpp>
#include <boost/type_traits/is_empty.hpp>
#include <boost/type_traits/is_reference.hpp>
#include <boost/type_traits/is_integral.hpp>
#include <boost/mpl/if.hpp>
#include <boost/mpl/or.hpp>
#include <CGAL/Default.h>
#include <utility>
@ -54,23 +58,31 @@ template<class T> struct Functor_as_base<T,true> : public T {
template <typename Derived, typename F, typename Iter, typename Ref, typename Val>
class transforming_iterator_helper
{
typedef std::iterator_traits<Iter> Iter_traits;
typedef typename Iter_traits::reference Iter_ref;
typedef typename Default::Get<Ref,
#ifdef CGAL_CXX11
decltype(std::declval<F>()(std::declval<typename std::iterator_traits<Iter>::reference>()))
decltype(std::declval<F>()(std::declval<Iter_ref>()))
#else
typename boost::result_of<F(typename std::iterator_traits<Iter>::value_type)>::type
typename boost::result_of<F(typename Iter_traits::value_type)>::type
// should be reference instead of value_type
#endif
>::type reference;
>::type reference_;
typedef typename Default::Get<Val,typename boost::remove_cv<typename boost::remove_reference<reference>::type>::type>::type value_type;
typedef typename Default::Get<Val,typename boost::remove_cv<typename boost::remove_reference<reference_>::type>::type>::type value_type;
// Crappy heuristic. If we have *it that returns a Weighted_point and F that returns a reference to the Point contained in the Weighted_point it takes as argument, we do NOT want the transformed iterator to return a reference to the temporary *it. On the other hand, if *it returns an int n, and F returns a reference to array[n] it is not so good to lose the reference. This probably should be done elsewhere and should at least be made optional...
typedef typename boost::mpl::if_<
boost::mpl::or_<boost::is_reference<Iter_ref>,
boost::is_integral<Iter_ref> >,
reference_, value_type>::type reference;
public:
typedef boost::iterator_adaptor<
Derived,
Iter,
value_type,
typename std::iterator_traits<Iter>::iterator_category,
typename Iter_traits::iterator_category,
reference
> type;
};

View File

@ -23,6 +23,7 @@ int main()
#include <CGAL/use.h>
#include <iostream>
#include <sstream>
#include <CGAL/NewKernel_d/Types/Weighted_point.h>
//typedef CGAL::Cartesian_base_d<double,CGAL::Dimension_tag<2> > K0;
//typedef CGAL::Cartesian_base_d<CGAL::Interval_nt_advanced,CGAL::Dimension_tag<2> > KA;
@ -534,6 +535,7 @@ void test3(){
P x4=cp(0,0,1);
P x5=cp(0,0,0);
P x6=cp(0,0,-1);
assert(!ed(x1,x2));
P tab2[]={x1,x2,x3,x4,x5};
assert(cis(tab2+0,tab2+4,x5));
assert(po(tab2+0,tab2+4)==CGAL::POSITIVE);
@ -591,6 +593,26 @@ void test3(){
assert(sbds(t1+0,t1+2,cp(2,2,3.415)) == CGAL::ON_UNBOUNDED_SIDE);
assert(sbds(t1+0,t1+3,cp(2.1,3.5,1.9)) == CGAL::ON_BOUNDED_SIDE);
assert(sbds(t1+0,t1+3,cp(10,10,10)) == CGAL::ON_UNBOUNDED_SIDE);
typedef typename K1::Weighted_point_d WP;
typedef typename K1::Construct_weighted_point_d CWP;
typedef typename K1::Point_drop_weight_d PDW;
typedef typename K1::Point_weight_d PW;
typedef typename K1::Power_test_d PT;
typedef typename K1::In_flat_power_test_d IFPT;
CWP cwp Kinit(construct_weighted_point_d_object);
PDW pdw Kinit(point_drop_weight_d_object);
PW pw Kinit(point_weight_d_object);
PT pt Kinit(power_test_d_object);
IFPT ifpt Kinit(in_flat_power_test_d_object);
WP wp;
wp = cwp (x1, 2);
WP xw6 = cwp (x6, 0);
assert (pw(wp) == 2);
assert (ed(pdw(wp), x1));
WP tabw[]={cwp(x1,0),cwp(x2,0),cwp(x3,0),cwp(x4,0),cwp(x5,0)};
assert(pt(tabw+0,tabw+4,tabw[4])==CGAL::ON_POSITIVE_SIDE);
assert(ifpt(fo4,tabw+0,tabw+3,xw6)==CGAL::ON_POSITIVE_SIDE);
}
template struct CGAL::Epick_d<CGAL::Dimension_tag<2> >;
template struct CGAL::Epick_d<CGAL::Dimension_tag<3> >;

View File

@ -155,6 +155,17 @@ namespace Eigen {
MulCost = 100
};
};
namespace internal {
template<>
struct significant_decimals_impl<CGAL::Gmpq>
{
static inline int run()
{
return 0;
}
};
}
}
//since types are included by Gmp_coercion_traits.h:

View File

@ -1283,6 +1283,13 @@ namespace Eigen {
MulCost = 10
};
};
namespace internal {
template<class> struct significant_decimals_impl;
template<bool b>
struct significant_decimals_impl<CGAL::Interval_nt<b> >
: significant_decimals_impl<typename CGAL::Interval_nt<b>::value_type> { };
}
}
#endif // CGAL_INTERVAL_NT_H

View File

@ -0,0 +1,69 @@
# Created by the script cgal_create_cmake_script_with_options
# This is the CMake script for compiling a set of CGAL applications.
project( Triangulation_apps )
cmake_minimum_required(VERSION 2.6.2)
if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" VERSION_GREATER 2.6)
if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION}" VERSION_GREATER 2.8.3)
cmake_policy(VERSION 2.8.4)
else()
cmake_policy(VERSION 2.6)
endif()
endif()
set( CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true )
if ( COMMAND cmake_policy )
cmake_policy( SET CMP0003 NEW )
endif()
# CGAL and its components
find_package( CGAL QUIET COMPONENTS )
if ( NOT CGAL_FOUND )
message(STATUS "This project requires the CGAL library, and will not be compiled.")
return()
endif()
# include helper file
include( ${CGAL_USE_FILE} )
# Boost and its components
find_package( Boost REQUIRED )
if ( NOT Boost_FOUND )
message(STATUS "This project requires the Boost library, and will not be compiled.")
return()
endif()
find_package(Eigen3 3.1.0)
if (EIGEN3_FOUND)
include( ${EIGEN3_USE_FILE} )
endif()
# include for local directory
include_directories( BEFORE include )
# include for local package
include_directories( BEFORE ../../include )
# Creating entries for all .cpp/.C files with "main" routine
# ##########################################################
include( CGAL_CreateSingleSourceCGALProgram )
create_single_source_cgal_program( "points_to_RT_to_off.cpp" )
create_single_source_cgal_program( "points_to_DT_to_off.cpp" )

View File

@ -0,0 +1,11 @@
2
0.0071 1.6899 0
0.3272 1.3694 0.05
1.3697 1.8296 0.1
0.6722 0.3012 0.15
1.1726 0.1899 0.2
0.4374 2.8541 100.25
2.5923 0.1904 0.3
1.3083 2.5462 200.35
1.4981 1.3929 0.4
2.1304 2.055 0.45

View File

@ -0,0 +1,20 @@
2
0 0 6.28953
-2.85086 -0.471442 6.12896
1.90972 0.101219 0.988689
0.637771 2.59367 5.80372
2.22209 0.903198 2.19478
-0.487202 -2.71506 4.90996
1.1193 -1.91787 2.99626
1.54714 0.109831 0
0.44556 -2.73047 4.48142
0.427936 1.28495 6.23624
-2.67212 0.766674 5.29623
1.5763 -1.59828 2.58905
-0.476603 2.2546 6.04797
1.57172 -0.514711 6.11405
1.84528 2.10139 5.53936
-2.99827 -0.101677 5.92246
-0.482122 -2.39584 4.44264
-2.25558 -1.492 6.23448
0.128475 -1.75125 3.18916

View File

@ -0,0 +1,11 @@
3
0.0071 1.6899 2.521 0
0.3272 1.3694 3.15 0.05
1.3697 1.8296 2.654 0.1
-10.6722 0.3012 0.1548 1000.15
1.1726 0.1899 0.3658 0.2
0.4374 20.8541 1.45894 2000.25
2.5923 0.1904 0.6971 0.3
10.3083 2.5462 1.3658 1000.35
1.4981 1.3929 2.949 0.4
2.1304 2.055 0.6597455 1.45

View File

@ -0,0 +1,11 @@
3
0.0071 1.6899 2.521 0
0.3272 1.3694 3.15 0
1.3697 1.8296 2.654 0
-10.6722 0.3012 0.1548 0
1.1726 0.1899 0.3658 0
0.4374 20.8541 1.45894 0
2.5923 0.1904 0.6971 0
10.3083 2.5462 1.3658 0
1.4981 1.3929 2.949 0
2.1304 2.055 0.6597455 0

View File

@ -0,0 +1,11 @@
3
0.0071 1.6899 2.521 0
0.3272 1.3694 3.15 0.05
1.3697 1.8296 2.654 0.1
-10.6722 0.3012 0.1548 1000.15
1.1726 0.1899 0.3658 0.2
0.4374 20.8541 1.45894 2000.25
2.5923 0.1904 0.6971 0.3
10.3083 2.5462 1.3658 1000.35
1.4981 1.3929 2.949 0.4
2.1304 2.055 0.6597455 1.45

View File

@ -0,0 +1,42 @@
#include <CGAL/Epick_d.h>
#include <CGAL/Delaunay_triangulation.h>
#include <CGAL/IO/Triangulation_off_ostream.h>
#include <fstream>
typedef CGAL::Epick_d<CGAL::Dynamic_dimension_tag> K;
typedef CGAL::Delaunay_triangulation<K> DT;
void test(int dim)
{
std::stringstream input_filename;
input_filename << "data/points_" << dim << ".cin";
std::ifstream in(input_filename.str());
DT::Point p;
std::vector<DT::Point> points;
int dim_from_file;
in >> dim_from_file;
while(in >> p)
points.push_back(p);
// Build the Regular Triangulation
DT dt(dim_from_file);
dt.insert(points.begin(), points.end());
CGAL_assertion(dt.is_valid(true));
// Export
std::stringstream output_filename;
output_filename << "data/dt_dim" << dim << ".off";
std::ofstream off_stream(output_filename.str());
CGAL::export_triangulation_to_off(off_stream, dt);
}
int main()
{
//test(2);
//test(3);
test(10);
return 0;
}

View File

@ -0,0 +1,41 @@
#include <CGAL/Epick_d.h>
#include <CGAL/Regular_triangulation.h>
#include <CGAL/IO/Triangulation_off_ostream.h>
#include <fstream>
typedef CGAL::Epick_d<CGAL::Dynamic_dimension_tag> K;
typedef CGAL::Regular_triangulation<K> RT;
void test(int dim)
{
std::stringstream input_filename;
input_filename << "data/points_" << dim << ".cin";
std::ifstream in(input_filename.str());
RT::Weighted_point wp;
std::vector<RT::Weighted_point> wpoints;
int dim_from_file;
in >> dim_from_file;
while(in >> wp)
wpoints.push_back(wp);
// Build the Regular Triangulation
RT rt(dim_from_file);
rt.insert(wpoints.begin(), wpoints.end());
CGAL_assertion(rt.is_valid(true));
// Export
std::stringstream output_filename;
output_filename << "data/rt_dim" << dim << ".off";
std::ofstream off_stream(output_filename.str());
CGAL::export_triangulation_to_off(off_stream, rt);
}
int main()
{
test(2);
test(3);
return 0;
}

View File

@ -21,6 +21,7 @@ if ( CGAL_FOUND )
include_directories (BEFORE "../../include")
include_directories (BEFORE "include")
create_single_source_cgal_program( "delaunay.cpp" )
create_single_source_cgal_program( "Td_vs_T2_and_T3.cpp" )
else()
message(STATUS "NOTICE: Some of the executables in this directory need Eigen 3.1 (or greater) and will not be compiled.")

View File

@ -0,0 +1,267 @@
// To deactivate statics filters in the 2D/3D case
//#define CGAL_NO_STATIC_FILTERS
#include <CGAL/Epick_d.h>
#include <CGAL/Delaunay_triangulation.h>
#include <CGAL/Regular_triangulation.h>
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Regular_triangulation_euclidean_traits_2.h>
#include <CGAL/Regular_triangulation_filtered_traits_2.h>
#include <CGAL/Regular_triangulation_euclidean_traits_3.h>
#include <CGAL/Regular_triangulation_filtered_traits_3.h>
#include <CGAL/Delaunay_triangulation_2.h>
#include <CGAL/Delaunay_triangulation_3.h>
#include <CGAL/Regular_triangulation_2.h>
#include <CGAL/Regular_triangulation_3.h>
#include <CGAL/point_generators_2.h>
#include <CGAL/point_generators_3.h>
#include <CGAL/point_generators_d.h>
#include <CGAL/Timer.h>
#include <CGAL/algorithm.h>
#include <vector>
#include <string>
#include "console_color.h"
template <typename DT_>
struct Stats_getter;
// T2 specialization
template <typename K>
struct Stats_getter<CGAL::Delaunay_triangulation_2<K> >
{
typedef CGAL::Delaunay_triangulation_2<K> DT;
Stats_getter(DT const& dt) : m_dt(dt) {}
std::size_t number_of_vertices() { return m_dt.number_of_vertices(); }
std::size_t number_of_finite_cells() { return m_dt.number_of_faces(); }
DT m_dt;
};
// RT2 specialization
template <typename K>
struct Stats_getter<CGAL::Regular_triangulation_2<K> >
{
typedef CGAL::Regular_triangulation_2<K> DT;
Stats_getter(DT const& dt) : m_dt(dt) {}
std::size_t number_of_vertices() { return m_dt.number_of_vertices(); }
std::size_t number_of_finite_cells() { return m_dt.number_of_faces(); }
DT m_dt;
};
// T3 specialization
template <typename K>
struct Stats_getter<CGAL::Delaunay_triangulation_3<K> >
{
typedef CGAL::Delaunay_triangulation_3<K> DT;
Stats_getter(DT const& dt) : m_dt(dt) {}
std::size_t number_of_vertices() { return m_dt.number_of_vertices(); }
std::size_t number_of_finite_cells() { return m_dt.number_of_finite_cells(); }
DT m_dt;
};
// RT3 specialization
template <typename K>
struct Stats_getter<CGAL::Regular_triangulation_3<K> >
{
typedef CGAL::Regular_triangulation_3<K> DT;
Stats_getter(DT const& dt) : m_dt(dt) {}
std::size_t number_of_vertices() { return m_dt.number_of_vertices(); }
std::size_t number_of_finite_cells() { return m_dt.number_of_finite_cells(); }
DT m_dt;
};
template<typename DT_d, typename DT_23,
typename Pt_d_range, typename Pt_23_range>
void test(
int d, int N, Pt_d_range const& points_d, Pt_23_range const& points_23,
std::string const& DTd_static_or_dyn)
{
// Td
{
DT_d dt(d);
CGAL::Timer timer;
timer.start();
dt.insert(points_d.begin(), points_d.end());
std::cerr << " * Td: " << yellow << timer.time() << " s"
<< white << std::endl;
std::cerr << " " << dt.number_of_vertices() << " vertices, "
<< dt.number_of_finite_full_cells() << " finite cells."
<< std::endl;
}
// T2 or T3
{
CGAL::Timer timer;
timer.start();
DT_23 dt;
dt.insert(points_23.begin(), points_23.end());
std::cerr << " * T" << d << ": " << yellow << timer.time() << " s"
<< white << std::endl;
Stats_getter<DT_23> sg(dt);
std::cerr << " " << sg.number_of_vertices() << " vertices, "
<< sg.number_of_finite_cells() << " finite cells."
<< std::endl;
}
}
template< int D, typename Dim_tag >
void go(const int N)
{
CGAL_assertion(D == 2 || D == 3);
// Generate points (in a common "array" format)
std::vector<CGAL::cpp11::array<double, D> > coords;
coords.reserve(N);
for (int i = 0; i < N; ++i)
{
CGAL::cpp11::array<double, D> pt;
for (int j = 0; j < D; ++j)
pt[j] = CGAL::default_random.get_double(-1., 1.);
coords.push_back(pt);
}
// Generate weights
std::vector<double> weights;
weights.reserve(N);
for (int i = 0; i < N; ++i)
weights.push_back(CGAL::default_random.get_double(-10., 10.));
// DTd
typedef CGAL::Epick_d<Dim_tag> Kd;
typedef CGAL::Delaunay_triangulation<Kd> DT_d;
typedef typename DT_d::Point Point_d;
std::vector<Point_d> points_d;
points_d.reserve(N);
for (int i = 0; i < N; ++i)
points_d.push_back(Point_d(D, coords[i].begin(), coords[i].end()));
// RTd
typedef CGAL::Regular_triangulation<Kd> RT_d;
typedef typename RT_d::Bare_point Bare_point_d;
typedef typename RT_d::Point WPoint_d;
std::vector<WPoint_d> wpoints_d;
wpoints_d.reserve(N);
for (int i = 0; i < N; ++i)
{
wpoints_d.push_back(WPoint_d(
Bare_point_d(D, coords[i].begin(), coords[i].end()),
weights[i]));
}
// T2 or T3
typedef CGAL::Exact_predicates_inexact_constructions_kernel K23;
if (D == 2)
{
// Delaunay
typedef CGAL::Delaunay_triangulation_2<K23> DT_2;
typedef typename DT_2::Point Point;
std::vector<Point> points;
points.reserve(N);
for (int i = 0; i < N; ++i)
points.push_back(Point(coords[i][0], coords[i][1]));
std::cerr << std::endl << "DELAUNAY - dim " << D << " - "
<< N << " points." << std::endl;
test<DT_d, DT_2>(D, N, points_d, points, "static");
// Regular
typedef CGAL::Regular_triangulation_filtered_traits_2<K23> Traits_2;
typedef CGAL::Regular_triangulation_2<Traits_2> RT_2;
typedef typename RT_2::Bare_point Bare_point;
typedef typename RT_2::Point WPoint;
std::vector<WPoint> wpoints;
wpoints.reserve(N);
for (int i = 0; i < N; ++i)
{
wpoints.push_back(WPoint(
Bare_point(coords[i][0], coords[i][1]),
weights[i]));
}
std::cerr << std::endl << "REGULAR - dim " << D << " - "
<< N << " points." << std::endl;
test<RT_d, RT_2>(D, N, wpoints_d, wpoints, "static");
}
else if (D == 3)
{
typedef CGAL::Delaunay_triangulation_3<K23> DT_3;
typedef typename DT_3::Point Point;
std::vector<Point> points;
points.reserve(N);
for (int i = 0; i < N; ++i)
points.push_back(Point(coords[i][0], coords[i][1], coords[i][2]));
std::cerr << std::endl << "DELAUNAY - dim " << D << " - "
<< N << " points." << std::endl;
test<DT_d, DT_3>(D, N, points_d, points, "static");
// Regular
typedef CGAL::Regular_triangulation_filtered_traits_3<K23> Traits_3;
typedef CGAL::Regular_triangulation_3<Traits_3> RT_3;
typedef typename RT_3::Bare_point Bare_point;
typedef typename RT_3::Point WPoint;
std::vector<WPoint> wpoints;
wpoints.reserve(N);
for (int i = 0; i < N; ++i)
{
wpoints.push_back(WPoint(
Bare_point(coords[i][0], coords[i][1], coords[i][2]),
weights[i]));
}
std::cerr << std::endl << "REGULAR - dim " << D << " - "
<< N << " points." << std::endl;
test<RT_d, RT_3>(D, N, wpoints_d, wpoints, "static");
}
}
int main(int argc, char **argv)
{
srand(static_cast<unsigned int>(time(NULL)));
#ifdef _DEBUG
int N = 100;
#else
int N = 100000;
#endif
if (argc > 1) N = atoi(argv[1]);
std::cerr << "-----------------------------------------" << std::endl;
std::cerr << "-- STATIC --" << std::endl;
std::cerr << "-----------------------------------------" << std::endl;
go<2, CGAL::Dimension_tag<2> >(N);
go<3, CGAL::Dimension_tag<3> >(N);
std::cerr << std::endl;
std::cerr << "-----------------------------------------" << std::endl;
std::cerr << "-- DYNAMIC --" << std::endl;
std::cerr << "-----------------------------------------" << std::endl;
go<2, CGAL::Dynamic_dimension_tag>(N);
go<3, CGAL::Dynamic_dimension_tag>(N);
std::cerr << std::endl;
return 0;
}

View File

@ -0,0 +1,68 @@
#ifndef CONSOLE_COLOR_H_
#define CONSOLE_COLOR_H_
#include <iostream>
#if defined(WIN32)
#include <windows.h>
#endif
inline std::ostream& blue(std::ostream &s)
{
#if defined(WIN32)
HANDLE hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(hStdout,
FOREGROUND_BLUE|FOREGROUND_GREEN|FOREGROUND_INTENSITY);
#else
s << "\x1b[0;34m";
#endif
return s;
}
inline std::ostream& red(std::ostream &s)
{
#if defined(WIN32)
HANDLE hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(hStdout, FOREGROUND_RED|FOREGROUND_INTENSITY);
#else
s << "\x1b[0;31m";
#endif
return s;
}
inline std::ostream& green(std::ostream &s)
{
#if defined(WIN32)
HANDLE hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(hStdout, FOREGROUND_GREEN|FOREGROUND_INTENSITY);
#else
s << "\x1b[0;32m";
#endif
return s;
}
inline std::ostream& yellow(std::ostream &s)
{
#if defined(WIN32)
HANDLE hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(hStdout,
FOREGROUND_GREEN|FOREGROUND_RED|FOREGROUND_INTENSITY);
#else
s << "\x1b[0;33m";
#endif
return s;
}
inline std::ostream& white(std::ostream &s)
{
#if defined(WIN32)
HANDLE hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(hStdout,
FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE);
#else
s << "\x1b[0;37m";
#endif
return s;
}
#endif

View File

@ -1,70 +1,128 @@
#include <CGAL/Epick_d.h>
#include <CGAL/Delaunay_triangulation.h>
#include <CGAL/IO/Triangulation_off_ostream.h>
#include <CGAL/point_generators_d.h>
#include <CGAL/Timer.h>
#include <CGAL/algorithm.h>
#include <CGAL/Memory_sizer.h>
#include <vector>
#include <string>
#include <fstream>
#include <cstdlib>
#include <algorithm>
//#define USE_DYNAMIC_KERNEL
#define OUTPUT_STATS_IN_CSV
//#define EXPORT_POINTS_TO_A_FILE
template<typename DT>
void test(const int d, const std::string & type, const int N)
#ifdef OUTPUT_STATS_IN_CSV
static std::ofstream csv_file("stats.csv");
#endif
// Return the number of Bytes used
template<int D>
std::size_t compute_triangulation(std::size_t N)
{
typedef typename DT::Vertex Vertex;
typedef typename DT::Vertex_handle Vertex_handle;
typedef typename DT::Full_cell Full_cell;
typedef typename DT::Full_cell_handle Full_cell_handle;
typedef typename DT::Facet Facet;
typedef typename DT::Point Point;
typedef typename DT::Geom_traits::RT RT;
typedef typename DT::Finite_full_cell_const_iterator Finite_full_cell_const_iterator;
#ifdef USE_DYNAMIC_KERNEL
typedef CGAL::Epick_d<CGAL::Dynamic_dimension_tag> K;
#else
typedef CGAL::Epick_d<CGAL::Dimension_tag<D> > K;
#endif
typedef CGAL::Delaunay_triangulation<K> DT;
typedef CGAL::Random_points_in_cube_d<Point> Random_points_iterator;
CGAL::Timer cost; // timer
typedef typename DT::Vertex Vertex;
typedef typename DT::Vertex_handle Vertex_handle;
typedef typename DT::Full_cell Full_cell;
typedef typename DT::Full_cell_handle Full_cell_handle;
typedef typename DT::Facet Facet;
typedef typename DT::Point Point;
typedef typename DT::Geom_traits::RT RT;
typedef typename DT::Finite_full_cell_const_iterator Finite_full_cell_const_iterator;
DT dt(d);
assert(dt.empty());
typedef CGAL::Random_points_in_cube_d<Point> Random_points_iterator;
CGAL::Timer cost; // timer
std::vector<Point> points;
CGAL::Random rng;
Random_points_iterator rand_it(d, 2.0, rng);
CGAL::cpp11::copy_n(rand_it, N, std::back_inserter(points));
cost.reset();cost.start();
std::cout << " Delaunay triangulation of "<<N<<" points in dim "<<d<< std::flush;
dt.insert(points.begin(), points.end());
std::cout << " done in "<<cost.time()<<" seconds." << std::endl;
std::size_t nbfc= dt.number_of_finite_full_cells();
std::size_t nbc= dt.number_of_full_cells();
std::cout << dt.number_of_vertices() << " vertices, "
<< nbfc << " finite simplices and "
<< (nbc-nbfc) << " convex hull Facets."
<< std::endl;
// Generate points
std::vector<Point> points;
CGAL::Random rng;
Random_points_iterator rand_it(D, 2.0, rng);
CGAL::cpp11::copy_n(rand_it, N, std::back_inserter(points));
#ifdef EXPORT_POINTS_TO_A_FILE
std::ofstream os("points.txt");
for (auto const& p : points)
{
CGAL::Triangulation_IO::output_point(os, K(), p);
os << std::endl;
}
#endif
std::size_t mem_before = CGAL::Memory_sizer().virtual_size();
cost.reset();
cost.start();
std::cout << "Delaunay triangulation of " << N <<
" points in dim " << D << ":" << std::endl;
DT dt(D);
dt.insert(points.begin(), points.end());
std::size_t mem = CGAL::Memory_sizer().virtual_size() - mem_before;
double timing = cost.time();
std::cout << " Done in " << timing << " seconds." << std::endl;
std::cout << " Memory consumption: " << (mem >> 10) << " KB.\n";
std::size_t nbfc= dt.number_of_finite_full_cells();
std::size_t nbc= dt.number_of_full_cells();
std::cout << " " << dt.number_of_vertices() << " vertices, "
<< nbfc << " finite simplices and "
<< (nbc-nbfc) << " convex hull Facets."
<< std::endl;
#ifdef OUTPUT_STATS_IN_CSV
csv_file
<< D << ";"
<< N << ";"
<< timing << ";"
<< mem << ";"
<< nbfc << "\n"
<< std::flush;
#endif
return mem;
}
template< int D >
void go(const int N)
// Will compute triangulations of i*num_points_steps points,
// with i in [1, 2...], stopping after the last computation that takes
// more memory than mem_threshold_in_bytes
template<int D>
void go(
std::size_t num_points_increment,
std::size_t mem_threshold_in_MB = (3 << 10)) // 3 GB
{
typedef CGAL::Epick_d<CGAL::Dimension_tag<D> > K;
//typedef CGAL::Epick_d<CGAL::Dynamic_dimension_tag> K;
typedef CGAL::Delaunay_triangulation<K> Triangulation;
test<Triangulation>(D, "static", N);
std::size_t mem = 0;
for (std::size_t i = 1 ; mem < (mem_threshold_in_MB << 20) ; ++i)
{
mem = compute_triangulation<D>(i*num_points_increment);
}
}
int main(int argc, char **argv)
{
srand(static_cast<unsigned int>(time(NULL)));
int N = 100; if( argc > 1 ) N = atoi(argv[1]);
go<2>(N);
go<3>(N);
go<4>(N);
go<5>(N);
go<6>(N);
go<7>(N);
go<8>(N);
srand(static_cast<unsigned int>(time(NULL)));
//int N = 100; if( argc > 1 ) N = atoi(argv[1]);
go<2>(5000000);
//go<3>(1000000);
//go<4>(300000);
//go<5>(50000);
//go<6>(5000);
//go<7>(1000);
//go<8>(300);
//go<9>(100);
//go<10>(30);
//go<11>(20);
//go<12>(15);
return 0;
return 0;
}

View File

@ -20,35 +20,32 @@ A <I>circumscribing ball</I> of a simplex is a ball
having all vertices of the simplex on its boundary.
\tparam DelaunayTriangulationTraits is the geometric traits class that provides the geometric types
and predicates needed by Delaunay triangulations. `DelaunayTriangulationTraits` must be a model of
\tparam DelaunayTriangulationTraits_ is the geometric traits class that provides the geometric types
and predicates needed by Delaunay triangulations. `DelaunayTriangulationTraits_` must be a model of
the concept `DelaunayTriangulationTraits`.
\tparam TriangulationDataStructure must be a model of the concept
\tparam TriangulationDataStructure_ must be a model of the concept
`TriangulationDataStructure`. This model is used to store
the faces of the triangulation. The parameter `TriangulationDataStructure` defaults to
the faces of the triangulation. The parameter `TriangulationDataStructure_` defaults to
`Triangulation_data_structure` whose template parameters are instantiated as
follows:
<UL>
<LI>`DelaunayTriangulationTraits::Dimension`</LI>
<LI>`Triangulation_vertex<DelaunayTriangulationTraits>`</LI>
<LI>`Triangulation_full_cell<DelaunayTriangulationTraits>`.</LI>
<LI>`DelaunayTriangulationTraits_::Dimension`</LI>
<LI>`Triangulation_vertex<DelaunayTriangulationTraits_>`</LI>
<LI>`Triangulation_full_cell<DelaunayTriangulationTraits_>`.</LI>
</UL>
The class template `Delaunay_triangulation` can
\tparam Delaunay_triangulation can
be defined by specifying only the first parameter, or by using the
tag `CGAL::Default` as the second parameter.
The class `Delaunay_triangulation<DelaunayTriangulationTraits, TriangulationDataStructure>` inherits all the types
defined in the base class `Triangulation<DelaunayTriangulationTraits, TriangulationDataStructure>`. Additionally, it
defines or overloads the following methods:
\sa `Triangulation_data_structure<Dimensionality, TriangulationDSVertex, TriangulationDSFullCell>`
\sa `Regular_triangulation`
\sa `Triangulation_data_structure`
*/
template< typename DelaunayTriangulationTraits, typename TriangulationDataStructure >
template< typename DelaunayTriangulationTraits_, typename TriangulationDataStructure_ >
class Delaunay_triangulation
: public Triangulation<DelaunayTriangulationTraits, TriangulationDataStructure>
: public Triangulation<DelaunayTriangulationTraits_, TriangulationDataStructure_>
{
public:
@ -139,7 +136,7 @@ is called.)
The parameters `lt`, `f`, `ft`
and `c` must be consistent with the localization of point `p` in the
Delaunay triangulation e.g. by a call to
`c = locate(p, lt, f, ft)`.
`Triangulation::locate(const Point &, Locate_type &, Face &, Vertex_handle) const`.
\cgalAdvancedEnd
*/
Vertex_handle insert(const Point & p, const Locate_type lt,
@ -151,8 +148,7 @@ Inserts the point `p` in the Delaunay triangulation. Returns a handle to the
(possibly newly created) vertex at that position.
\pre The point `p`
must lie outside the affine hull of the Delaunay triangulation. This implies that
`dt`.`current_dimension()` must be less that
`dt`.`maximal_dimension()`.
`dt`.`current_dimension()` must be less than `dt`.`maximal_dimension()`.
\cgalAdvancedEnd
*/
Vertex_handle insert_outside_affine_hull(const Point & p);
@ -182,15 +178,13 @@ const;
/*!
\cgalAdvancedBegin
Outputs handles to the full cells in confict with
Outputs handles to the full cells in conflict with
point `p` into the `OutputIterator out`. The full cell `c` is used
as a starting point for gathering the full cells in conflict with
`p`.
A facet `(cc,i)` on the boundary of the conflict zone with
`cc` in conflict is returned.
\pre `c` is in conflict
with `p`.
`dt`.`current_dimension()`\f$ \geq2\f$.
\pre `c` is in conflict with `p` and `dt`.`current_dimension()`\f$ \geq2\f$.
\cgalAdvancedEnd
*/
template< typename OutputIterator >

View File

@ -0,0 +1,171 @@
namespace CGAL {
/*!
\ingroup PkgTriangulationsTriangulationClasses
This class is used to maintain the
regular triangulation -- also known as weighted Delaunay triangulation --
of a set of weighted points in \f$ \mathbb{R}^D \f$.
The dimension \f$ D\f$ can be specified at compile-time or
run-time. It should be kept reasonably small -- see the performance
section in the user manual for what reasonable means.
\warning The removal of points is not supported yet.
A comprehensive definition of regular triangulations is available in the
User Manual.
Parameters
--------------
\tparam RegularTriangulationTraits_ is the geometric traits class that provides the
geometric types and predicates needed by regular triangulations.
`RegularTriangulationTraits_` must be a model of the concept
`RegularTriangulationTraits`.
\tparam TriangulationDataStructure_ must be a model of the concept
`TriangulationDataStructure`. This model is used to store
the faces of the triangulation. The parameter `TriangulationDataStructure_`
defaults to `Triangulation_data_structure` whose template parameters are
instantiated as follows:
<UL>
<LI>`RegularTriangulationTraits_::Dimension`</LI>
<LI>`Triangulation_vertex<CGAL::Regular_triangulation_euclidean_traits<RegularTriangulationTraits_> >`</LI>
<LI>`Triangulation_full_cell<CGAL::Regular_triangulation_euclidean_traits<RegularTriangulationTraits_> >`.</LI>
</UL>
\tparam Regular_triangulation can
be defined by specifying only the first parameter, or by using the
tag `CGAL::Default` as the second parameter.
\sa `Delaunay_triangulation`
\sa `Triangulation_data_structure`
*/
template< typename RegularTriangulationTraits_, typename TriangulationDataStructure_ >
class Regular_triangulation
: public Triangulation<RegularTriangulationTraits_, TriangulationDataStructure_>
{
public:
/// \name Types
/// @{
/*!
A point in Euclidean space with an associated weight.
*/
typedef RegularTriangulationTraits_::Weighted_point Weighted_point;
/// @}
/// \name Creation
/// @{
/*!
Instantiates a regular triangulation with one vertex (the vertex
at infinity). See the description of the inherited nested type
`Triangulation::Maximal_dimension` for an explanation of
the use of the parameter `dim`. The complex stores a copy of the geometric
traits `gt`.
*/
Regular_triangulation(const int dim, const Geom_traits gt = Geom_traits());
/// @}
/// \name Point insertion
/// @{
/*!
Inserts weighted point `p` in the triangulation and returns the corresponding
vertex. Returns a handle to the (possibly newly created) vertex at that
position.
Prior to the actual insertion, `p` is located in the triangulation;
`hint` is used as a starting place for locating `p`.
*/
Vertex_handle insert(const Weighted_point & p, Full_cell_handle hint
= Full_cell_handle());
/*!
Same as above but uses a vertex as starting place for the search.
*/
Vertex_handle insert(const Weighted_point & p, Vertex_handle hint);
/*!
\cgalAdvancedBegin
Inserts weighted point `p` in the triangulation and returns the corresponding
vertex. Similar to the above `insert()` function, but takes as additional
parameter the return values of a previous location query. See description of
`Triangulation::locate()`.
\cgalAdvancedEnd
*/
Vertex_handle insert(const Weighted_point & p, const Locate_type lt,
const Face & f, const Facet & ft, const Full_cell_handle c);
/*!
Inserts the weighted points found in range `[s,e)` in the regular triangulation.
Returns the difference of the number of vertices between after and
before the insertions (it may be negative due to hidden points).
Note that this function is not guaranteed to insert the points
following the order of `ForwardIterator` because `spatial_sort()`
is used to improve efficiency.
\tparam ForwardIterator must be an input iterator with the value
type `Weighted_point`.
*/
template< typename ForwardIterator >
std::ptrdiff_t insert(ForwardIterator s, ForwardIterator e);
/*!
\cgalAdvancedBegin
Inserts the point `p` in the regular triangulation. Returns a handle to the
(possibly newly created) vertex at that position.
\pre The point `p`
must lie outside the affine hull of the regular triangulation. This implies that
`rt`.`current_dimension()` must be less than `rt`.`maximal_dimension()`.
\cgalAdvancedEnd
*/
Vertex_handle insert_outside_affine_hull(const Weighted_point & p);
/*!
\cgalAdvancedBegin
Inserts the point `p` in the regular triangulation. Returns a handle to the
(possibly newly created) vertex at that position.
\pre The point `p` must be in conflict with the full cell `c`.
\cgalAdvancedEnd
*/
Vertex_handle insert_in_conflicting_cell(const Weighted_point & p, const
Full_cell_handle c);
/// @}
/// \name Queries
/// @{
/*!
Returns `true` if and only if the point `p` is in
conflict with full cell `c` (A weighted point `p` is said to be in conflict
with a cell `c` if it has a negative power distance to the power sphere of `c`.)
*/
bool is_in_conflict(const Weighted_point & p, Full_cell_const_handle c)
const;
/*!
\cgalAdvancedBegin
Outputs handles to the full cells in conflict with
point `p` into the `OutputIterator out`. The full cell `c` is used
as a starting point for gathering the full cells in conflict with
`p`.
A facet `(cc,i)` on the boundary of the conflict zone with
`cc` in conflict is returned.
\pre `c` is in conflict with `p` and `rt`.`current_dimension()`\f$ \geq2\f$.
\cgalAdvancedEnd
*/
template< typename OutputIterator >
Facet compute_conflict_zone(const Weighted_point & p, const Full_cell_handle c,
OutputIterator out) const;
/// @}
}; /* end regular_triangulation */
} /* end namespace CGAL */

View File

@ -17,25 +17,25 @@ incident to the infinite vertex and to an \f$ (i-1)\f$-simplex of the
convex hull boundary.
\tparam TriangulationTraits is the geometric traits class that provides the geometric types
and predicates needed by triangulations. `TriangulationTraits` must be a model of the
\tparam `TriangulationTraits_` is the geometric traits class that provides the geometric types
and predicates needed by triangulations. `TriangulationTraits_` must be a model of the
concept `TriangulationTraits`.
\tparam TriangulationDataStructure must be a model of the concept
\tparam `TriangulationDataStructure_` must be a model of the concept
`TriangulationDataStructure`. This model is used to store
the faces of the triangulation. The parameter `TriangulationDataStructure` defaults to
the faces of the triangulation. The parameter `TriangulationDataStructure_` defaults to
`Triangulation_data_structure` whose template parameters are instantiated as
follows:
<UL>
<LI>`DelaunayTriangulationTraits::Dimension`</LI>
<LI>`Triangulation_vertex<DelaunayTriangulationTraits>`</LI>
<LI>`Triangulation_full_cell<DelaunayTriangulationTraits>`.</LI>
<LI>`TriangulationTraits_::Dimension`</LI>
<LI>`Triangulation_vertex<TriangulationTraits_>`</LI>
<LI>`Triangulation_full_cell<TriangulationTraits_>`.</LI>
</UL>
The triangulation deduces its maximal dimension from the type
`TriangulationTraits::Dimension`. This dimension has to match
`TriangulationTraits_::Dimension`. This dimension has to match
the dimension returned by
`TriangulationDataStructure::maximal_dimension()`.
`TriangulationDataStructure_::maximal_dimension()`.
Input/Output
--------------
@ -47,25 +47,25 @@ full cell, plus the non-combinatorial information about each full cell, then the
indices of the neighbors of each full cell, where the index corresponds to the
preceding list of full cells.
\sa `Triangulation_data_structure<Dimensionality, TriangulationDSVertex, TriangulationDSFullCell>`
\sa `Delaunay_triangulation<DelaunayTriangulationTraits, TriangulationDataStructure>`
\sa `Triangulation_data_structure<Dimensionality, TriangulationDSVertex_, TriangulationDSFullCell_>`
\sa `Delaunay_triangulation<DelaunayTriangulationTraits_, TriangulationDataStructure_>`
*/
template< typename TriangulationTraits, typename TriangulationDataStructure >
template< typename TriangulationTraits_, typename TriangulationDataStructure_>
class Triangulation {
public:
/// \name Types
/// @{
/*!
Type for the model of the `TriangulationTraits` concept.
Type for the model of the `TriangulationTraits_` concept.
*/
typedef TriangulationTraits Geom_traits;
typedef TriangulationTraits_ Geom_traits;
/*!
A point in Euclidean space.
*/
typedef TriangulationTraits::Point_d Point;
typedef TriangulationTraits_::Point_d Point;
/*!
This indicates whether the maximal dimension is static
@ -75,34 +75,34 @@ or dynamic (i.e.\ if the type of `Maximal_dimension` is
In the latter case, the `dim` parameter passed to the class's constructor
is used.
*/
typedef TriangulationTraits::Dimension Maximal_dimension;
typedef TriangulationTraits_::Dimension Maximal_dimension;
/*!
The second template parameter: the triangulation data structure.
*/
typedef TriangulationDataStructure Triangulation_ds;
typedef TriangulationDataStructure_ Triangulation_ds;
/*!
A model of the concept `TriangulationVertex`.
*/
typedef TriangulationDataStructure::Vertex Vertex;
typedef TriangulationDataStructure_::Vertex Vertex;
/*!
A model of the concept
`TriangulationFullCell`.
*/
typedef TriangulationDataStructure::Full_cell Full_cell;
typedef TriangulationDataStructure_::Full_cell Full_cell;
/*!
The facet
class
*/
typedef TriangulationDataStructure::Facet Facet;
typedef TriangulationDataStructure_::Facet Facet;
/*!
A model of the concept `TriangulationDSFace`.
*/
typedef TriangulationDataStructure::Face Face;
typedef TriangulationDataStructure_::Face Face;
/// @}
@ -122,25 +122,25 @@ typedef TriangulationDataStructure::Face Face;
/*!
handle to a a vertex
*/
typedef TriangulationDataStructure::Vertex_handle
typedef TriangulationDataStructure_::Vertex_handle
Vertex_handle;
/*!
const handle to a a vertex
*/
typedef TriangulationDataStructure::Vertex_const_handle
typedef TriangulationDataStructure_::Vertex_const_handle
Vertex_const_handle;
/*!
iterator over all vertices (including the infinite one)
*/
typedef TriangulationDataStructure::Vertex_iterator
typedef TriangulationDataStructure_::Vertex_iterator
Vertex_iterator;
/*!
const iterator over all vertices (including the infinite one)
*/
typedef TriangulationDataStructure::Vertex_const_iterator
typedef TriangulationDataStructure_::Vertex_const_iterator
Vertex_const_iterator;
/*!
@ -156,27 +156,27 @@ typedef unspecified_type Finite_vertex_const_iterator;
/*!
handle to a full cell
*/
typedef TriangulationDataStructure::Full_cell_handle
typedef TriangulationDataStructure_::Full_cell_handle
Full_cell_handle;
/*!
const handle to a full cell
*/
typedef TriangulationDataStructure::Full_cell_const_handle
typedef TriangulationDataStructure_::Full_cell_const_handle
Full_cell_const_handle;
/*!
iterator over all full cells (including the infinite ones)
*/
typedef
TriangulationDataStructure::Full_cell_iterator
TriangulationDataStructure_::Full_cell_iterator
Full_cell_iterator;
/*!
const iterator over all full cells (including the infinite ones)
*/
typedef
TriangulationDataStructure::Full_cell_const_iterator
TriangulationDataStructure_::Full_cell_const_iterator
Full_cell_const_iterator;
/*!
@ -192,7 +192,7 @@ typedef unspecified_type Finite_full_cell_const_iterator;
/*!
iterator over all facets (including the infinite ones)
*/
typedef TriangulationDataStructure::Facet_iterator
typedef TriangulationDataStructure_::Facet_iterator
Facet_iterator;
/*!
@ -204,13 +204,13 @@ typedef unspecified_type Finite_facet_iterator;
Size type (an unsigned integral
type).
*/
typedef TriangulationDataStructure::size_type size_type;
typedef TriangulationDataStructure_::size_type size_type;
/*!
Difference
type (a signed integral type).
*/
typedef TriangulationDataStructure::difference_type difference_type;
typedef TriangulationDataStructure_::difference_type difference_type;
/*!
specifies which case occurs when locating a point in the triangulation.

View File

@ -9,29 +9,29 @@ of dimension \f$ d\leq D\f$ (`D` is the maximal dimension).
\tparam Dimensionality can be either <UL>
<LI>CGAL::`Dimension_tag<D>` for some integer `D`. This
<LI>`CGAL::Dimension_tag<D>` for some integer `D`. This
indicates that the triangulation data structure can store simplices (full cells) of dimension at most
`D`. The maximal dimension `D` is known by the compiler, which
triggers some optimizations. Or
<LI>CGAL::`Dynamic_dimension_tag`. In this case, the maximum
<LI>`CGAL::Dynamic_dimension_tag`. In this case, the maximum
dimension of the simplices (full cells) is passed as an integer argument to an instance
constructor (see `TriangulationDataStructure`).</UL>
\tparam TriangulationDSVertex stands for a class to
\tparam `TriangulationDSVertex_` stands for a class to
be used as the base `Vertex` type in the triangulation data structure.
It must be a model of the concept
`TriangulationDSVertex`. The class template `Triangulation_data_structure` can be
defined by specifying
only the first parameter. It also accepts the tag `CGAL::Default` as
second parameter. In both cases, `TriangulationDSVertex` defaults to
second parameter. In both cases, `TriangulationDSVertex_` defaults to
`CGAL::Triangulation_ds_vertex<>`.
\tparam TriangulationDSFullCell stands for a class to
\tparam `TriangulationDSFullCell_` stands for a class to
be used as the base `Full_cell` type in the triangulation data structure.
It must be a model of the concept
`TriangulationDSFullCell`. The class template `Triangulation_data_structure` accepts that no
third parameter be specified. It also accepts the tag `CGAL::Default` as
third parameter. In both cases, `TriangulationDSFullCell` defaults to
third parameter. In both cases, `TriangulationDSFullCell_` defaults to
`CGAL::Triangulation_ds_full_cell<>`.
\cgalModels `TriangulationDataStructure`. In addition, the class
@ -41,7 +41,7 @@ methods.
\sa `Triangulation_ds_vertex`
\sa `Triangulation_ds_full_cell`
*/
template< typename Dimensionality, typename TriangulationDSVertex, typename TriangulationDSFullCell >
template< typename Dimensionality, typename TriangulationDSVertex_, typename TriangulationDSFullCell_ >
class Triangulation_data_structure {
public:

View File

@ -17,7 +17,7 @@ This class can be used directly or can serve as a base to derive other classes
with some additional attributes tuned for a specific application.
\tparam TriangulationDataStructure must be a model of the
\tparam `TriangulationDataStructure_` must be a model of the
`TriangulationDataStructure` concept.
\tparam TriangulationDSFullCellStoragePolicy indicates whether or not
@ -49,11 +49,11 @@ Rebind mechanism
In case of derivation from that class, the nested class
`Rebind_TDS` need to be provided in the derived class.
\sa `Triangulation_ds_vertex<TriangulationDataStructure>`
\sa `Triangulation_data_structure<Dimensionality, TriangulationDSVertex, TriangulationDSFullCell>>`
\sa `Triangulation_ds_vertex<TriangulationDataStructure_>`
\sa `Triangulation_data_structure<Dimensionality, TriangulationDSVertex_, TriangulationDSFullCell_>`
*/
template< typename TriangulationDataStructure, typename TriangulationDSFullCellStoragePolicy >
template< typename TriangulationDataStructure_, typename TriangulationDSFullCellStoragePolicy >
class Triangulation_ds_full_cell {
public:

View File

@ -5,7 +5,7 @@ namespace CGAL {
\ingroup PkgTriangulationsVertexCellClasses
The class `Triangulation_ds_vertex` serves as the default vertex template parameter in the
class `Triangulation_data_structure<Dimensionality, TriangulationDSVertex, TriangulationDSFullCell>`.
class `Triangulation_data_structure<Dimensionality, TriangulationDSVertex_, TriangulationDSFullCell_>`.
This class does not contain any geometric information but only combinatorial
(adjacency) information. Thus, if the `Triangulation_data_structure` is
@ -18,7 +18,7 @@ with some additional attributes tuned for a specific application (a color for
example).
\tparam TriangulationDataStructure must be a model of the
\tparam `TriangulationDataStructure_` must be a model of the
`TriangulationDataStructure` concept.
\cgalModels `TriangulationDSVertex`
@ -29,11 +29,11 @@ Rebind Mechanism
In case of derivation from that class, the nested class
`Rebind_TDS` need to be provided in the derived class.
\sa `Triangulation_ds_full_cell<TriangulationDataStructure, TriangulationDSFullCellStoragePolicy>`
\sa `Triangulation_data_structure<Dimensionality, TriangulationDSVertex, TriangulationDSFullCell>>`
\sa `Triangulation_ds_full_cell<TriangulationDataStructure_, TriangulationDSFullCellStoragePolicy>`
\sa `Triangulation_data_structure<Dimensionality, TriangulationDSVertex_, TriangulationDSFullCell_>`
*/
template< typename TriangulationDataStructure >
template< typename TriangulationDataStructure_ >
class Triangulation_ds_vertex {
public:

View File

@ -5,7 +5,7 @@ namespace CGAL {
A `Triangulation_face` is a model of the concept `TriangulationDSFace`.
\tparam TriangulationDataStructure must be a model of the concept
\tparam TriangulationDataStructure_ must be a model of the concept
`TriangulationDataStructure`.
Actually, `Triangulation_face` needs only that this concept defines the types
`Full_cell_handle`,
@ -18,7 +18,7 @@ Actually, `Triangulation_face` needs only that this concept defines the types
\sa `TriangulationDataStructure`
*/
template< typename TriangulationDataStructure >
template< typename TriangulationDataStructure_ >
class Triangulation_face {
}; /* end Triangulation_face */

View File

@ -6,15 +6,15 @@ namespace CGAL {
The class `Triangulation_full_cell` is a model of the concept `TriangulationFullCell`. It
is used by default for representing full cells in the class
`Triangulation<TriangulationTraits, TriangulationDataStructure>`.
`Triangulation<TriangulationTraits_, TriangulationDataStructure_>`.
A `Triangulation_full_cell` stores handles to the vertices of the cell as well as handles
to its adjacent cells.
\tparam TriangulationTraits must be a model of the concept `TriangulationTraits`. It
\tparam `TriangulationTraits_` must be a model of the concept `TriangulationTraits`. It
provides geometric types and predicates for use in the
`Triangulation<TriangulationTraits, TriangulationDataStructure>` class.
`Triangulation<TriangulationTraits_, TriangulationDataStructure_>` class.
\tparam Data is an optional type of data to be stored in the full cell class. The
class template `Triangulation_full_cell` accepts that no second parameter be specified. In
@ -31,13 +31,13 @@ cases, `TriangulationDSFullCell_` defaults to `CGAL::Triangulation_ds_full_cell<
`Triangulation_full_cell` provides the following types,
constructors and methods:
\sa `Triangulation_vertex<TriangulationTraits, Data, TriangulationDSVertex>`
\sa `Triangulation_data_structure<Dimensionality, TriangulationDSVertex, TriangulationDSFullCell>`
\sa `Triangulation<TriangulationTraits,TriangulationDataStructure>`
\sa `Delaunay_triangulation<DelaunayTriangulationTraits, TriangulationDataStructure>`
\sa `Triangulation_vertex<TriangulationTraits_, Data, TriangulationDSVertex_>`
\sa `Triangulation_data_structure<Dimensionality, TriangulationDSVertex_, TriangulationDSFullCell_>`
\sa `Triangulation<TriangulationTraits_, TriangulationDataStructure_>`
\sa `Delaunay_triangulation<DelaunayTriangulationTraits_, TriangulationDataStructure_>`
*/
template< typename TriangulationTraits, typename Data, typename TriangulationDSFullCell_ >
template< typename TriangulationTraits_, typename Data, typename TriangulationDSFullCell_ >
class Triangulation_full_cell : public TriangulationDSFullCell_ {
public:

View File

@ -6,14 +6,14 @@ namespace CGAL {
The class `Triangulation_vertex` is a model of the concept `TriangulationVertex`. It is
used by default for representing vertices in the class
`Triangulation<TriangulationTraits, TriangulationDataStructure>`.
`Triangulation<TriangulationTraits_, TriangulationDataStructure_>`.
A `Triangulation_vertex` stores a point and an incident full cell.
\tparam TriangulationTraits must be a model of the concept `TriangulationTraits`. It
\tparam `TriangulationTraits_` must be a model of the concept `TriangulationTraits`. It
provides geometric types and predicates for use in the
`Triangulation<TriangulationTraits, TriangulationDataStructure>` class. It is of interest here for its
`Triangulation<TriangulationTraits_, TriangulationDataStructure_>` class. It is of interest here for its
declaration of the `Point` type.
\tparam Data is an optional type of data to be stored in the vertex class. The
@ -22,22 +22,22 @@ this case, `Data` defaults to `CGAL::No_vertex_data`.
`CGAL::No_vertex_data` can be explicitely specified to allow to access the
third parameter.
\tparam TriangulationDSVertex must be a model of the concept `TriangulationDSVertex`. The
\tparam `TriangulationDSVertex_` must be a model of the concept `TriangulationDSVertex`. The
class template `Triangulation_vertex` accepts that no third parameter be specified. It
also accepts the tag `CGAL::Default` as third parameter. In both cases,
`TriangulationDSVertex` defaults to `CGAL::Triangulation_ds_vertex<>`.
`TriangulationDSVertex_` defaults to `CGAL::Triangulation_ds_vertex<>`.
\cgalModels `TriangulationVertex` Additionally, the class
`Triangulation_vertex` provides the following types, constructors
and methods:
\sa `Triangulation_full_cell<TriangulationTraits, Data, TriangulationDSFullCell>`
\sa `Triangulation_data_structure<Dimensionality, TriangulationDSVertex, TriangulationDSFullCell>`
\sa `Triangulation<TriangulationTraits,TriangulationDataStructure>`
\sa `Delaunay_triangulation<DelaunayTriangulationTraits, TriangulationDataStructure>`
\sa `Triangulation_full_cell<TriangulationTraits_, Data, TriangulationDSFullCell_>`
\sa `Triangulation_data_structure<Dimensionality, TriangulationDSVertex_, TriangulationDSFullCell_>`
\sa `Triangulation<TriangulationTraits_, TriangulationDataStructure_>`
\sa `Delaunay_triangulation<DelaunayTriangulationTraits_, TriangulationDataStructure_>`
*/
template< typename TriangulationTraits, typename Data, typename TriangulationDSVertex >
class Triangulation_vertex {
template< typename TriangulationTraits_, typename Data, typename TriangulationDSVertex_ >
class Triangulation_vertex {
public:
/// \name Types

View File

@ -5,7 +5,7 @@
This concept describes the geometric types and predicates required to build
a Delaunay triangulation. It corresponds to the first template parameter of the class
`CGAL::Delaunay_triangulation<DelaunayTriangulationTraits, TriangulationDataStructure>`.
`CGAL::Delaunay_triangulation<DelaunayTriangulationTraits_, TriangulationDataStructure_>`.
\cgalRefines `TriangulationTraits`
@ -32,7 +32,7 @@ defined by the points in range `[start,end)`.
If the simplex is positively
oriented, then the positive side of sphere corresponds geometrically
to its bounded side.
\pre If `Dimension`=`CGAL::``Dimension_tag<D>`,
\pre If `Dimension`=`CGAL::Dimension_tag<D>`,
then `std::distance(start,end)=D+1`.
The points in range
`[start,end)` must be affinely independent, i.e., the simplex must
@ -70,14 +70,16 @@ typedef unspecified_type In_flat_side_of_oriented_sphere_d;
/// @{
/*!
The default constructor.
The default constructor (optional).
This is not required if an instance of the traits will be provided
to the constructor of `CGAL::Delaunay_triangulation`.
*/
DelaunayTriangulationTraits();
/// @}
/// \name Operations
/// The following methods permit access to the traits class's predicates:
/// The following methods permit access to the traits class's predicates and functors:
/// @{
/*!

View File

@ -0,0 +1,130 @@
/*!
\ingroup PkgTriangulationsConcepts
\cgalConcept
This concept describes the geometric types and predicates required to build
a regular triangulation. It corresponds to the first template parameter of the class
`CGAL::Regular_triangulation<RegularTriangulationTraits_, TriangulationDataStructure_>`.
\cgalRefines ::TriangulationTraits.
\cgalHasModel `CGAL::Epick_d<Dim>`
*/
class RegularTriangulationTraits {
public:
/// \name Types
/// @{
/*!
A number type that is a model for `RingNumberType`.
*/
typedef unspecified_type RT;
/*!
The weighted point type.
*/
typedef unspecified_type Weighted_point_d;
/*!
A function object that must provide the operator
`Point_d operator()(const Weighted_point & wp)`, returning
`wp` without its weight.
*/
typedef unspecified_type Point_drop_weight_d;
/*!
A function object that must provide the operator
`RT operator()(const Weighted_point & wp)`, returning
the weight of `wp`.
*/
typedef unspecified_type Point_weight_d;
/*!
A predicate object that must provide the templated operator
`template<typename ForwardIterator> Oriented_side operator()(ForwardIterator start, ForwardIterator end, const Weighted_point_d & p)`.
Let \f$ S \f$ be the power sphere of the weighted points in range `[start,end)`.
The operator returns:
- `ON_ORIENTED_BOUNDARY` if `p` is orthogonal to
\f$ S \f$,
- `ON_NEGATIVE_SIDE` if the power distance between `p` and \f$ S \f$ is
positive.
- `ON_POSITIVE_SIDE` otherwise.
\pre If `Dimension` is `CGAL::Dimension_tag<D>`,
then `std::distance(start,end)=D+1`.
The weighted points in range
`[start,end)` must be affinely independent, i.e., the simplex must
not be flat.
*/
typedef unspecified_type Power_test_d;
/*!
A predicate object that must provide the templated operator
`template<typename ForwardIterator> Oriented_side operator()(Flat_orientation_d orient, ForwardIterator start, ForwardIterator end, const Weighted_point_d & p)`.
The points in range `[start,end)` and `p` are supposed to belong to the lower-dimensional flat
whose orientation is given by `orient`.
Let \f$ S \f$ be the power sphere of the weighted points in range `[start,end)`
in this lower dimensional flat.
The operator returns:
- `ON_ORIENTED_BOUNDARY` if `p` is orthogonal to
\f$ S \f$,
- `ON_NEGATIVE_SIDE` if the power distance between `p` and \f$ S \f$ is
positive.
- `ON_POSITIVE_SIDE` otherwise.
\pre `std::distance(start,end)=k+1` where \f$ k\f$ is the number of
points used to construct `orient` (dimension of the flat).
The points in range `[start,end)` must be affinely independent.
`p` must be in the flat generated by these points.
*/
typedef unspecified_type In_flat_power_test_d;
/// @}
/// \name Creation
/// @{
/*!
The default constructor (optional).
This is not required if an instance of the traits will be provided
to the constructor of `CGAL::Regular_triangulation`.
*/
RegularTriangulationTraits();
/// @}
/// \name Operations
/// The following methods permit access to the traits class's predicates and functors:
/// @{
/*!
*/
Point_drop_weight_d point_drop_weight_d_object() const;
/*!
*/
Point_weight_d point_weight_d_object() const;
/*!
*/
Power_test_d power_test_d_object() const;
/*!
*/
In_flat_power_test_d in_flat_power_test_d_object() const;
/// @}
}; /* end RegularTriangulationTraits */

View File

@ -15,7 +15,7 @@ The dimension of a face is implicitely set when
`TriangulationDSFace::set_index` is called two times to set the
first two vertices (`i = 0` and `i = 1`), then the dimension is 1.
\cgalHasModel `CGAL::Triangulation_face<TriangulationDataStructure>`
\cgalHasModel `CGAL::Triangulation_face<TriangulationDataStructure_>`
\sa `TriangulationDSFullCell`
\sa `TriangulationDSVertex`

View File

@ -36,8 +36,8 @@ of `CGAL::Triangulation_data_structure::Vertex`.
\cgalRefines `TriangulationDataStructure::FullCell`
\cgalHasModel ` CGAL::Triangulation_ds_full_cell<TriangulationDataStructure,DSFullCellStoragePolicy>`
\cgalHasModel `CGAL::Triangulation_full_cell<TriangulationTraits, Data, TriangulationDSFullCell>`
\cgalHasModel `CGAL::Triangulation_ds_full_cell<TriangulationDataStructure_, DSFullCellStoragePolicy>`
\cgalHasModel `CGAL::Triangulation_full_cell<TriangulationTraits_, Data, TriangulationDSFullCell_>`
\sa `TriangulationDSVertex`
\sa `TriangulationDSFace`

View File

@ -36,8 +36,8 @@ of `CGAL::Triangulation_data_structure::Vertex`.
\cgalRefines `TriangulationDataStructure::Vertex`
\cgalHasModel `CGAL::Triangulation_ds_vertex<TriangulationDataStructure>`
\cgalHasModel `CGAL::Triangulation_vertex<TriangulationTraits, Data, TriangulationDSVertex>`
\cgalHasModel `CGAL::Triangulation_ds_vertex<TriangulationDataStructure_>`
\cgalHasModel `CGAL::Triangulation_vertex<TriangulationTraits_, Data, TriangulationDSVertex_>`
\sa `TriangulationDSFullCell`
\sa `TriangulationDSFace`

View File

@ -26,8 +26,8 @@ which is also the unique vertex and the unique full cell in the
`TriangulationDataStructure`.
In a
geometric realization of the `TriangulationDataStructure` (<I>e.g.</I>, in a
`Triangulation<TriangulationTraits, TriangulationDataStructure>` or a
`Delaunay_triangulation<DelaunayTriangulationTraits, TriangulationDataStructure>`), this vertex
`Triangulation<TriangulationTraits_, TriangulationDataStructure_>` or a
`Delaunay_triangulation<DelaunayTriangulationTraits_, TriangulationDataStructure_>`), this vertex
corresponds to <I>the vertex at infinity</I>.
<DT><B>0</B><DD> This corresponds to two vertices, each incident to one \f$ 0\f$-face;
@ -70,7 +70,7 @@ The classes `Vertex` and
`Full_cell` have to provide the relevant I/O operators
(possibly empty).
\cgalHasModel `CGAL::Triangulation_data_structure<Dimensionality, TriangulationDSVertex, TriangulationDSFullCell>`
\cgalHasModel `CGAL::Triangulation_data_structure<Dimensionality, TriangulationDSVertex_, TriangulationDSFullCell_>`
\sa `TriangulationDataStructure::Vertex`
\sa `TriangulationDataStructure::FullCell`
@ -257,11 +257,13 @@ The predicate must return `true`
if the traversal of that `Facet` leads to a good full cell.
All the good full cells are output into the last argument `out`.
\pre `start != Full_cell_handle()` and `start` is a good cell.
Returns a facet on the boundary of the set of cells.
\pre `start != Full_cell_handle()` and `start` is a good cell.
*/
template< typename TraversalPredicate, typename OutputIterator >
void gather_full_cells(Full_cell_handle start, TraversalPredicate & tp,
Facet gather_full_cells(Full_cell_handle start, TraversalPredicate & tp,
OutputIterator & out) const;
/*!
@ -656,8 +658,8 @@ It sets requirements of combinatorial nature
only, as geometry is not concerned here. In particular, we only require that
the vertex holds a handle to a full cell incident to it in the triangulation.
\cgalHasModel `CGAL::Triangulation_ds_vertex<TriangulationDataStructure>`
\cgalHasModel `CGAL::Triangulation_vertex<TriangulationTraits, Data, TriangulationDSVertex>`
\cgalHasModel `CGAL::Triangulation_ds_vertex<TriangulationDataStructure_>`
\cgalHasModel `CGAL::Triangulation_vertex<TriangulationTraits_, Data, TriangulationDSVertex_>`
\sa `TriangulationDataStructure::FullCell`
\sa `TriangulationDataStructure::Face`
@ -763,8 +765,8 @@ full cell as well as handles to the adjacent full cells. Two full cells
are said to be adjacent when they share a facet. Adjacent full cells are
called hereafter neighbors.
\cgalHasModel `CGAL::Triangulation_ds_full_cell<TriangulationDataStructure,DSFullCellStoragePolicy>`
\cgalHasModel `CGAL::Triangulation_full_cell<TriangulationTraits, Data, TriangulationDSFullCell>`
\cgalHasModel `CGAL::Triangulation_ds_full_cell<TriangulationDataStructure_, DSFullCellStoragePolicy>`
\cgalHasModel `CGAL::Triangulation_full_cell<TriangulationTraits_, Data, TriangulationDSFullCell_>`
\sa `TriangulationDataStructure::FullCell`
\sa `TriangulationDataStructure::Face`

View File

@ -4,17 +4,17 @@
\cgalConcept
The concept `TriangulationFullCell` describes the requirements on the type used by the
class `CGAL::Triangulation<TriangulationTraits, TriangulationDataStructure>`, and its derived classes, to
class `CGAL::Triangulation<TriangulationTraits_, TriangulationDataStructure_>`, and its derived classes, to
represent a full cell.
\cgalRefines `TriangulationDSFullCell` We only list below the
additional specific requirements of `TriangulationFullCell`.
\cgalHasModel `CGAL::Triangulation_full_cell<TriangulationTraits, TriangulationDSFullCell>`
\cgalHasModel `CGAL::Triangulation_full_cell<TriangulationTraits_, TriangulationDSFullCell_>`
\sa `CGAL::Triangulation_full_cell<TriangulationTraits, Data, TriangulationDSFullCell>`
\sa `CGAL::Triangulation_full_cell<TriangulationTraits_, Data, TriangulationDSFullCell_>`
\sa `TriangulationVertex`
\sa `CGAL::Triangulation<TriangulationTraits, TriangulationDataStructure>`
\sa `CGAL::Triangulation<TriangulationTraits_, TriangulationDataStructure_>`
*/

View File

@ -5,7 +5,7 @@
This concept describes the geometric types and predicates required to build
a triangulation. It corresponds to the first template parameter of the class
`CGAL::Triangulation<TriangulationTraits, TriangulationDataStructure>`.
`CGAL::Triangulation<TriangulationTraits_, TriangulationDataStructure_>`.
\cgalRefines `SpatialSortingTraits_d`
@ -30,8 +30,8 @@ A type representing the dimension of the predicates
(but not necessarily the one of `Point_d`). If \f$ n \f$ is the number of
points required by the `Orientation_d` predicate, then
`Dimension` \f$ = n - 1\f$.
It can be static (`Dimension`=`CGAL::``Dimension_tag<int dim>`) or
dynamic (`Dimension`=`CGAL::``Dynamic_dimension_tag`).
It can be static (`Dimension`=`CGAL::Dimension_tag<int dim>`) or
dynamic (`Dimension`=`CGAL::Dynamic_dimension_tag`).
*/
typedef unspecified_type Dimension;
@ -48,7 +48,7 @@ templated operator
The operator returns the orientation of the simplex defined by the points
in the range `[start, end)`; the value can be
`CGAL::POSITIVE`, `CGAL::NEGATIVE` or `CGAL::COPLANAR`.
\pre If `Dimension`=`CGAL::``Dimension_tag<D>`, then `std::distance(start,end)=D+1`.
\pre If `Dimension`=`CGAL::Dimension_tag<D>`, then `std::distance(start,end)=D+1`.
*/
typedef unspecified_type Orientation_d;
@ -59,7 +59,7 @@ the templated operator
The operator returns `true` if and only if point `p` is
contained in the affine space spanned by the points in the range `[start, end)`. That affine space is also called the <I>affine hull</I> of the points
in the range.
\pre If `Dimension`=`CGAL::``Dimension_tag<D>`,
\pre If `Dimension`=`CGAL::Dimension_tag<D>`,
then `std::distance(start,end)=D+1`.
The points in the range
must be affinely independent. Note that in the CGAL kernels, this predicate
@ -97,7 +97,7 @@ the range `R=[start, end)` can be oriented in two different ways,
the operator
returns an object that allow to orient that flat so that `R=[start, end)`
defines a positive simplex.
\pre If `Dimension`=`CGAL::``Dimension_tag<D>`,
\pre If `Dimension`=`CGAL::Dimension_tag<D>`,
then `std::distance(start,end)=D+1`.
The points in range
`[start,end)` must be affinely independent.
@ -137,7 +137,9 @@ typedef unspecified_type Compare_lexicographically_d;
/// @{
/*!
The default constructor.
The default constructor (optional).
This is not required if an instance of the traits will be provided
to the constructor of `CGAL::Triangulation`.
*/
TriangulationTraits();

View File

@ -4,7 +4,7 @@
\cgalConcept
The concept `TriangulationVertex` describes the requirements on the type used by the
class `CGAL::Triangulation<TriangulationTraits, TriangulationDataStructure>`, and its derived classes, to
class `CGAL::Triangulation<TriangulationTraits_, TriangulationDataStructure_>`, and its derived classes, to
represent a vertex.
\cgalRefines `TriangulationDSVertex`
@ -12,7 +12,7 @@ We only list below the additional specific requirements of ::TriangulationVertex
Compared to ::TriangulationDSVertex, the main difference is the addition of
an association of the vertex with a geometric point.
\cgalHasModel `CGAL::Triangulation_vertex<TriangulationTraits, Data, TriangulationDSVertex> `
\cgalHasModel `CGAL::Triangulation_vertex<TriangulationTraits_, Data, TriangulationDSVertex_>`
Input/Output
--------------
@ -20,9 +20,9 @@ Input/Output
These operators can be used directly and are called by the I/O
operator of class `Triangulation`.
\sa `CGAL::Triangulation_vertex<TriangulationTraits, Data, TriangulationDSVertex>`
\sa `CGAL::Triangulation_vertex<TriangulationTraits_, Data, TriangulationDSVertex_>`
\sa `TriangulationFullCell`
\sa `CGAL::Triangulation<TriangulationTraits, TriangulationDataStructure>`
\sa `CGAL::Triangulation<TriangulationTraits_, TriangulationDataStructure_>`
*/
@ -36,7 +36,7 @@ public:
The type of the point stored in the vertex. It must be
the same as the point type `TriangulationTraits::Point` (or its refined
concepts) when the `TriangulationVertex` is used in the class
`Triangulation<TriangulationTraits, TriangulationDataStructure>` (or its derived classes).
`Triangulation<TriangulationTraits_, TriangulationDataStructure_>` (or its derived classes).
*/
typedef unspecified_type Point;

View File

@ -13,7 +13,7 @@
\cgalPkgDescriptionBegin{dD Triangulations,PkgTriangulationsSummary}
\cgalPkgPicture{Hypertriangle.png}
\cgalPkgSummaryBegin
\cgalPkgAuthors{Samuel Hornus, Olivier Devillers and Clément Jamin}
\cgalPkgAuthors{Olivier Devillers, Samuel Hornus, and Clément Jamin}
\cgalPkgDesc{This package provides classes for manipulating
triangulations (pure simplicial complexes) in Euclidean spaces whose dimension
can be specified at compile-time or at run-time. Specifically, it provides a
@ -84,6 +84,7 @@ is opposite to the vertex with the same index.
- `TriangulationTraits`
- `DelaunayTriangulationTraits`
- `RegularTriangulationTraits`
- `TriangulationVertex`
- `TriangulationFullCell`
@ -93,17 +94,18 @@ The latter two concepts are also abbreviated respectively as `TrVertex` and `TrF
## Triangulation Data Structure ##
- `CGAL::Triangulation_data_structure<Dimensionality, TriangulationDSVertex, TriangulationDSFullCell>`
- `CGAL::Triangulation_ds_vertex<TriangulationDataStructure>`
- `CGAL::Triangulation_ds_full_cell<TriangulationDataStructure, TriangulationDSFullCellStoragePolicy>`
- `CGAL::Triangulation_face<TriangulationDataStructure>`
- `CGAL::Triangulation_data_structure<Dimensionality, TriangulationDSVertex_, TriangulationDSFullCell_>`
- `CGAL::Triangulation_ds_vertex<TriangulationDataStructure_>`
- `CGAL::Triangulation_ds_full_cell<TriangulationDataStructure_, TriangulationDSFullCellStoragePolicy>`
- `CGAL::Triangulation_face<TriangulationDataStructure_>`
## (Geometric) Triangulations ##
- `CGAL::Triangulation<TriangulationTraits, TriangulationDataStructure>`
- `CGAL::Delaunay_triangulation<DelaunayTriangulationTraits, TriangulationDataStructure>`
- `CGAL::Triangulation_vertex<TriangulationTraits, Data, TriangulationDSVertex>`
- `CGAL::Triangulation_full_cell<TriangulationTraits, Data, TriangulationDSFullCell>`
- `CGAL::Triangulation<TriangulationTraits_, TriangulationDataStructure_>`
- `CGAL::Delaunay_triangulation<DelaunayTriangulationTraits_, TriangulationDataStructure_>`
- `CGAL::Regular_triangulation<RegularTriangulationTraits_, TriangulationDataStructure_>`
- `CGAL::Triangulation_vertex<TriangulationTraits_, Data, TriangulationDSVertex_>`
- `CGAL::Triangulation_full_cell<TriangulationTraits_, Data, TriangulationDSFullCell_>`
## Enums ##

View File

@ -6,17 +6,17 @@ namespace CGAL {
\anchor Chapter_Triangulations
\cgalAutoToc
\authors Samuel Hornus, Olivier Devillers and Clément Jamin.
\authors Olivier Devillers, Samuel Hornus, and Clément Jamin.
This package proposes data structures and algorithms to compute
triangulations of points in any dimensions.
The `Triangulation_data_structure` handles the
combinatorial aspect of triangulations while the geometric classes
`Triangulation` and `Delaunay_triangulation` allows to
compute and maintain triangulations and Delaunay triangulations of
sets of points.
`Triangulation`, `Delaunay_triangulation` and `Regular_triangulation` allow to
compute and maintain triangulations, Delaunay triangulations, and
regular triangulations of sets of points.
# Introduction #
\section TriangulationSecIntro Introduction
## Some Definitions ##
@ -30,64 +30,28 @@ The sets in \f$ S\f$ (which are subsets of \f$ V\f$) are called
singular of which is <I>simplex</I>).
A simplex \f$ s\in S\f$ is <I>maximal</I> if it is not a proper subset of some other
set in \f$ S\f$.
A simplex having \f$ d+1 \f$ vertices is said of dimension \f$ d \f$.
A simplex having \f$ k+1 \f$ vertices is said of dimension \f$ k \f$.
An \f$ k\f$-face denotes a \f$ k\f$-dimensional simplex, i.e., a simplex with \f$ k+1\f$
vertices.
The simplicial complex is <I>pure</I> if all the maximal simplices
have the same dimension.
A <i>triangulation</i> is a simplicial complex
that is pure, connected and without boundaries nor singularities. The
<i>dimension</i> of the triangulation is the dimension of its maximal
simplices.
<!--- cardinality, i.e., they have the same number of vertices.--->
In the sequel, we will call these maximal simplices <I>full cells</I>.
A <I>face</I> of a simplex is a subset of this simplex.
A <I>proper face</I> of a simplex is a strict subset of this simplex.
Two faces \f$ \sigma\f$ and \f$ \sigma'\f$ are <I>incident</I> if and only if
\f$ \sigma'\f$ is a proper face of \f$ \sigma\f$ or <I>vice versa</I>.
A complex has <i>no boundaries</i> if any proper face of a simplex is also a
proper face of another simplex.
If the vertices are embedded into Euclidean space \f$ \mathbb{R}^d\f$,
we deal with
<I>finite simplicial complexes</I> which have slightly different simplices
and additional requirements:
<UL>
<LI>vertices corresponds to points in space.
<LI>a simplex \f$ s\in S\f$ is the convex hull of its vertices.
<LI>the vertices of a simplex \f$ s\in S\f$ are affinely independent.
<LI>the intersection of any two simplices of \f$ S\f$ is a proper face of both
simplices (the empty set counts).
</UL>
See the <A HREF="http://en.wikipedia.org/wiki/Simplicial_complex">wikipedia
entry</A> for more about simplicial complexes.
## What's in this Package? ##
This \cgal package provides three main classes
for creating and manipulating triangulations.
The class `CGAL::Triangulation_data_structure<Dimensionality, TriangulationDSVertex, TriangulationDSFullCell>`
models an <I>abstract triangulation</I>: vertices in this
class are not embedded in Euclidean space but are only of combinatorial
nature. It deals with simplicial complexes
which are pure, connected and without boundaries nor singularities.
The class `CGAL::Triangulation<TriangulationTraits, TriangulationDataStructure>`
describes an embedded triangulation that has as vertices a given set of points.
Methods are provided for the insertion of points in the triangulation, the
traversal of various elements of the triangulation, as well as the localization of a
query point inside the triangulation.
The triangulation covers the convex hull of the set of points.
The class `CGAL::Delaunay_triangulation<DelaunayTriangulationTraits, TriangulationDataStructure>`
builds the Delaunay triangulation of a set of points.
In a Delaunay triangulation, each face has the so-called
<I>Delaunay</I> or <I>empty-ball</I> property: there exists a
circumscribing ball whose interior does not contain
any vertex of the triangulation.
## Further Definitions ##
An \f$ i\f$-face denotes an \f$ i\f$-dimensional simplex, or a simplex with \f$ i+1\f$
vertices. When these vertices are embedded in Euclidean space, they must be
affinely independent.
If the maximal dimension of a simplex in the triangulation is
\f$ d\f$, we use the following terminology:<UL>
If the triangulation is of dimension \f$ d \f$, we use the following terminology:<UL>
<LI><I>face</I>: an \f$ i\f$-face for some \f$ i\in[0,d]\f$;
<LI><I>vertex</I>: a \f$ 0\f$-face;
<LI><I>edge</I>: a \f$ 1\f$-face;
@ -96,32 +60,69 @@ If the maximal dimension of a simplex in the triangulation is
<LI><I>full cell</I>: a \f$ d\f$-face.
</UL>
Two faces \f$ \sigma\f$ and \f$ \sigma'\f$ are <I>incident</I> if and only if
\f$ \sigma'\f$ is a proper sub-face of \f$ \sigma\f$ or <I>vice versa</I>.
If the vertices are embedded into Euclidean space \f$ \mathbb{R}^n\f$,
we deal with
<I>finite simplicial complexes</I>, which have slightly different simplices
and additional requirements:
<UL>
<LI>vertices correspond to points in space.
<LI>a simplex \f$ s\in S\f$ is the convex hull of its vertices.
<LI>the vertices of a simplex \f$ s\in S\f$ are affinely independent.
<LI>the intersection of any two simplices of \f$ S\f$ is a proper face of both
simplices (the empty set counts).
</UL>
# %Triangulation Data Structure #
## What's in this Package? ##
This \cgal package provides four main classes
for creating and manipulating triangulations.
The class `CGAL::Triangulation_data_structure<Dimensionality, TriangulationDSVertex_, TriangulationDSFullCell_>`
models an <I>abstract triangulation</I>: vertices in this
class are not embedded in Euclidean space but are only of combinatorial
nature.
The class `CGAL::Triangulation<TriangulationTraits_, TriangulationDataStructure_>`
describes an embedded triangulation that has as vertices a given set of points.
Methods are provided for the insertion of points in the triangulation, the
traversal of various elements of the triangulation, as well as the location of a
query point inside the triangulation.
The triangulation covers the convex hull of the set of points.
The class `CGAL::Delaunay_triangulation<DelaunayTriangulationTraits_, TriangulationDataStructure_>`
builds the Delaunay triangulation of a set of points.
In a Delaunay triangulation, each face has the so-called
<I>Delaunay</I> or <I>empty-ball</I> property: there exists a
circumscribing ball whose interior does not contain
any vertex of the triangulation.
The class `CGAL::Regular_triangulation<RegularTriangulationTraits_, TriangulationDataStructure_>`
builds the regular triangulation
-- also known as weighted Delaunay triangulation -- of a set of points.
A detailed definition of such a triangulation is available in section
\ref TriangulationSecRT.
\section TriangulationSecTDS Triangulation Data Structure
In this section, we describe the concept `TriangulationDataStructure` for
which \cgal provides one model class:
`CGAL::Triangulation_data_structure<Dimensionality, TriangulationDSVertex, TriangulationDSFullCell>`.
`CGAL::Triangulation_data_structure<Dimensionality, TriangulationDSVertex_, TriangulationDSFullCell_>`.
A `TriangulationDataStructure` can represent an abstract pure complex
such that any facet is incident to exactly two full cells.
A triangulation data structure can represent an abstract triangulation.
A `TriangulationDataStructure` has a <!--- property called the --->
<I>maximal dimension</I> which is a
The <I>maximal dimension</I> of a triangulation data structure is a
positive integer equal to the maximum dimension a full cell can have.
This maximal dimension can be chosen by the user at the creation of a
`TriangulationDataStructure` and can then be queried using the method `tds.maximal_dimension()`.
A `TriangulationDataStructure` also knows the <I>current dimension</I> of its full cells,
which can be queried with `tds.current_dimension()`. In the sequel, let
This maximal dimension can be chosen by the user at the creation of the
triangulation data structure and can then be obtained using the method `tds.maximal_dimension()`.
A triangulation data structure also knows the <I>current dimension</I> of its full cells,
which can be obtained using `tds.current_dimension()`. In the sequel, let
us denote the maximal dimension with \f$ D \f$ and the current dimension with \f$ d \f$.
The inequalities \f$ -2 \leq d \leq D\f$ and \f$ 0 \le D\f$ always hold.
The special meaning of negative values for \f$d\f$ is explained below.
### The Set of Faces ###
## The Set of Faces ##
The set of faces of a `TriangulationDataStructure` with
The set of faces of a triangulation data structure with
current dimension \f$ d \f$ forms a triangulation of the
topological sphere \f$ \mathbb{S}^d\f$.
@ -132,7 +133,7 @@ Possible values of \f$d\f$ (the <I>current dimension</I> of the triangulation) i
<BLOCKQUOTE>
<DL>
<DT><B>\f$d=-2\f$</B><DD> This corresponds to an empty
`TriangulationDataStructure`.
triangulation data structure.
<DT><B>\f$d=-1\f$</B><DD> This corresponds to an abstract simplicial
complex reduced to a single vertex.
<!--- and a single full cell. In a geometric triangulation, this vertex corresponds to the vertex at infinity.--->
@ -149,16 +150,16 @@ the sphere \f$ \mathbb{S}^d\f$.
## The `Triangulation_data_structure` Class ##
We give here some details about the class
`Triangulation_data_structure<Dimensionality, TriangulationDSVertex, TriangulationDSFullCell>`
`Triangulation_data_structure<Dimensionality, TriangulationDSVertex_, TriangulationDSFullCell_>`
implementing the concept `TriangulationDataStructure`.
### Storage ###
A `TriangulationDataStructure` explicitly stores its vertices and full cells.
A triangulation data structure explicitly stores its vertices and full cells.
Each vertex stores a reference to one of its incident full cells.
Each full cell stores references to its \f$ d+1\f$ vertices and
Each full cell \f$ \sigma \f$ stores references to its \f$ d+1\f$ vertices and
neighbors. Its vertices and neighbors are indexed from \f$ 0\f$ to \f$ d \f$. The indices
of its neighbors have the following meaning: the \f$ i\f$-th neighbor of \f$ \sigma\f$
is the unique neighbor of \f$ \sigma\f$ that does not contain the \f$ i\f$-th vertex of
@ -190,7 +191,7 @@ indices alongside the references to the vertices and neighbors in a
full cell. This improves speed a little, but requires more memory.
\cgalAdvanced \cgal provides the class template
`Triangulation_ds_full_cell<TriangulationDataStructure,
`Triangulation_ds_full_cell<TriangulationDataStructure_,
TriangulationDSFullCellStoragePolicy>` for representing full cells in a
triangulation. Its second template parameter is used to specify wether
or not the mirror indices should be kept in memory or computed
@ -200,41 +201,41 @@ documentation of that class template for specific details.
###Template Parameters###
The `Triangulation_data_structure<Dimensionality, TriangulationDSVertex, TriangulationDSFullCell>`
The `Triangulation_data_structure<Dimensionality, TriangulationDSVertex_, TriangulationDSFullCell_>`
class is designed in such a way that its user can choose
<UL>
<LI>the maximal dimension of the triangulation data structure by specifying the `Dimensionality` template parameter,
<LI>the type used to represent vertices by specifying the `TriangulationDSVertex`
<LI>the type used to represent vertices by specifying the `TriangulationDSVertex_`
template parameter and
<LI>the type used to represent full cells by specifying the
`TriangulationDSFullCell` template parameter.
`TriangulationDSFullCell_` template parameter.
</UL>
The last two parameters have default values and are thus not necessary, unless
the user needs custom types (see the reference manual page for this class
template). The first template parameter, `Dimensionality`, must be
one of the following:
the user needs custom types (see `Triangulation_data_structure`).
The first template parameter, `Dimensionality`, must be one of the following:
<UL>
<LI>CGAL::`Dimension_tag<D>` for some integer \f$ D \f$. This
<LI>`CGAL::Dimension_tag<D>` for some integer \f$ D \f$. This
indicates that the triangulation can store full cells of dimension at most
\f$ D \f$. The maximum dimension \f$ D \f$ is known by the compiler, which
triggers some optimizations.
<LI>CGAL::`Dynamic_dimension_tag`. In this case, the maximum
<LI>`CGAL::Dynamic_dimension_tag`. In this case, the maximum
dimension of the full cells must be passed as an integer argument to an instance
constructor (see `TriangulationDataStructure`).
</UL>
The `TriangulationDSVertex` and `TriangulationDSFullCell` parameters to the class template
The `TriangulationDSVertex_` and `TriangulationDSFullCell_` parameters to the class template
must be models of the concepts `TriangulationDSVertex` and
`TriangulationDSFullCell` respectively. \cgal provides models for these
concepts: `Triangulation_ds_vertex<TriangulationDataStructure>` and
`Triangulation_ds_full_cell<TriangulationDataStructure, TriangulationDSFullCellStoragePolicy>`, which, as one
can see, take the `TriangulationDataStructure` as a template parameter in order to get access to
some nested types in `TriangulationDataStructure`.
concepts: `Triangulation_ds_vertex<TriangulationDataStructure_>` and
`Triangulation_ds_full_cell<TriangulationDataStructure_, TriangulationDSFullCellStoragePolicy>`, which, as one
can see, take the triangulation data structure as a template parameter in order to get access to
some nested types in `TriangulationDataStructure_`.
The default values are `CGAL::Triangulation_ds_vertex<TDS>`
and `CGAL::Triangulation_ds_full_cell<TDS>`
where `TDS` is the current class `Triangulation_data_structure<Dimensionality, TriangulationDSVertex, TriangulationDSFullCell>`
where `TDS` is the current class
`Triangulation_data_structure<Dimensionality, TriangulationDSVertex_, TriangulationDSFullCell_>`.
<I>This creates a circular dependency</I>, which we resolve in the same way
as in the \cgal `Triangulation_2` and `Triangulation_3` packages (see
Chapters \ref Chapter_2D_Triangulation_Data_Structure, \ref Chapter_2D_Triangulations,
@ -276,8 +277,7 @@ full cells adjacent to `c` are automatically subdivided to match the
subdivision of the full cell `c`. The barycentric subdivision of `c` is
obtained by enumerating all the faces of `c` in order of decreasing
dimension, from the dimension of `c` to dimension 1, and inserting a new
vertex in each face. For the enumeration, we use a combination enumerator,
which is not documented, but provided in \cgal.
vertex in each face.
\cgalFigureBegin{triangulationfigbarycentric,barycentric-subdivision.png}
Barycentric subdivision in dimension \f$ d=2\f$.
@ -285,9 +285,9 @@ Barycentric subdivision in dimension \f$ d=2\f$.
\cgalExample{barycentric_subdivision.cpp}
# Triangulations #
\section TriangulationSecTriangulations Triangulations
The class `CGAL::Triangulation<TriangulationTraits, TriangulationDataStructure>`
The class `CGAL::Triangulation<TriangulationTraits_, TriangulationDataStructure_>`
maintains a triangulation embedded in Euclidean space. The triangulation
covers the convex hull of the input points (the embedded vertices of the
triangulation).
@ -300,39 +300,39 @@ Each infinite \f$ i\f$-simplex is
incident to the infinite vertex and to an \f$ (i-1)\f$-simplex of the
convex hull boundary.
See Chapters \ref Chapter_2D_Triangulations "2D Triangulations" and
See Chapters \ref Chapter_2D_Triangulations "2D Triangulations" or
\ref Chapter_3D_Triangulations "3D Triangulations" for more details
about infinite vertices and cells.
Methods are provided for the insertion of points in the triangulation, the
contraction of faces, the traversal of various elements of the triangulation
as well as the localization of a query point inside the triangulation.
as well as the location of a query point inside the triangulation.
The ordering of the vertices of a full cell defines an orientation of
that full cell.
As long as no <I>advanced</I> class method is called, it is guaranteed
that all finite full cells have positive orientation. The infinite full
cells are oriented as if the infinite vertex was on the other side
of the hyperplane supported by the convex hull facets that the other points.
that all finite full cells have positive orientation. Each infinite full
cell is oriented as if its infinite vertex was on the side of
the hyperplane supported by its finite facet where there is no other point.
## Implementation ##
The class `CGAL::Triangulation<TriangulationTraits, TriangulationDataStructure>`
stores a model of the concept `TriangulationDataStructure` which is
The class `CGAL::Triangulation<TriangulationTraits_, TriangulationDataStructure_>`
stores a model of the concept `TriangulationDataStructure` that is
instantiated with a vertex type that stores a point.
The template parameter `TriangulationTraits` must be a model of the concept
`TriangulationTraits` which provides the `Point` type as well
The template parameter `TriangulationTraits_` must be a model of the concept
`TriangulationTraits`, which provides the point type as well
as various geometric predicates used by the `Triangulation` class.
The `TriangulationTraits` concept includes a nested type
`TriangulationTraits::Dimension` which is the dimension of the predicates.
This dimension governs the number of points given as arguments to the
predicates. This type is either `CGAL::Dimension_tag<D>` or
`CGAL::Dynamic_dimension_tag`. In any case, the dimension of the traits
must match the maximal dimension of the `TriangulationDataStructure`.
`TriangulationTraits::Dimension`. This dimension governs the number of points
given as arguments to the predicates. This type is either
`CGAL::Dimension_tag<D>` or `CGAL::Dynamic_dimension_tag`.
In any case, the dimension of the traits
must match the maximal dimension of the triangulation data structure.
The template parameter `TriangulationDataStructure` must be a model of the concept
The template parameter `TriangulationDataStructure_` must be a model of the concept
`TriangulationDataStructure` which provides the triangulation data
structure as described in the previous section.
@ -382,11 +382,11 @@ One important difference between the two examples above is that the first uses
visits <I>only</I> the infinite full cells but stores handles to them into the
<I>potentially big</I> array <tt>infinite_full_cells</tt>.
# Delaunay Triangulations #
\section TriangulationSecDT Delaunay Triangulations
The class `CGAL::Delaunay_triangulation<DelaunayTriangulationTraits, TriangulationDataStructure>` derives from
`CGAL::Triangulation<DelaunayTriangulationTraits, TriangulationDataStructure>`
and represent Delaunay triangulations.
The class `CGAL::Delaunay_triangulation<DelaunayTriangulationTraits_, TriangulationDataStructure_>` derives from
`CGAL::Triangulation<DelaunayTriangulationTraits_, TriangulationDataStructure_>`
and represents Delaunay triangulations.
A <I>circumscribing ball</I> of a simplex is a ball
having all vertices of the simplex on its boundary.
@ -396,8 +396,11 @@ circumscribing ball whose interior does not contain
any vertex of the triangulation.
In case of degeneracies (co-spherical points) the triangulation is not
uniquely defined. Note however that the \cgal implementation computes a unique
triangulation even in these cases.
uniquely defined. Note however that the \cgal implementation computes
one of the possible Delaunay triangulations.
The computed triangulation is uniquely defined for a given insertion
order of the points (which is always the same if inserted using
`CGAL::Delaunay_triangulation::insert(ForwardIterator s, ForwardIterator e)`).
When a new point `p` is inserted into a Delaunay triangulation, the
full cells whose circumscribing ball contains `p` are said to
@ -409,20 +412,23 @@ in the conflict zone are removed, leaving a hole that contains `p`. That
hole is ``star shaped'' around `p` and thus is re-triangulated using
`p` as a center vertex.
Delaunay triangulations also support vertex removal.
Delaunay triangulations support insertion of points, removal of vertices,
and location of a query point inside the triangulation.
Note that inserting a large set of points at once is much faster
than inserting the same points one by one.
## Implementation ##
The class `CGAL::Delaunay_triangulation<DelaunayTriangulationTraits, TriangulationDataStructure>` derives from
`CGAL::Triangulation<DelaunayTriangulationTraits, TriangulationDataStructure>`. It thus stores a model of
the concept `TriangulationDataStructure` which is instantiated with a vertex
The class `CGAL::Delaunay_triangulation<DelaunayTriangulationTraits_, TriangulationDataStructure_>` derives from
`CGAL::Triangulation<DelaunayTriangulationTraits_, TriangulationDataStructure_>`. It thus stores a model of
the concept `TriangulationDataStructure`, which is instantiated with a vertex
type that stores a geometric point and allows its retrieval.
The template parameter `DelaunayTriangulationTraits` must be a model of the concept
The template parameter `DelaunayTriangulationTraits_` must be a model of the concept
`DelaunayTriangulationTraits` which provides the geometric `Point` type as
well as various geometric predicates used by the `Delaunay_triangulation` class.
The concept `DelaunayTriangulationTraits` refines the concept
`TriangulationTraits` by requiring a few other geometric predicates, necessary
`TriangulationTraits` by requiring a few additional geometric predicates, necessary
for the computation of Delaunay triangulations.
## Examples ##
@ -438,45 +444,129 @@ retaining an efficient update of the Delaunay triangulation.
\cgalExample{delaunay_triangulation.cpp}
# Complexity and Performances #
\section TriangulationSecRT Regular Triangulations
The class `CGAL::Regular_triangulation<RegularTriangulationTraits_, TriangulationDataStructure_>` derives from
`CGAL::Triangulation<RegularTriangulationTraits_, TriangulationDataStructure_>`
and represents regular triangulations.
Regular triangulations are similar to Delaunay triangulations, but
with weighted points.
Let \f$ {S}^{(w)}\f$ be a set of weighted points in \f$ \mathbb{R}^D\f$. Let
\f$ {p}^{(w)}=(p,w_p), p\in\mathbb{R}^D, w_p\in\mathbb{R}\f$ and
\f$ {z}^{(w)}=(z,w_z), z\in\mathbb{R}^D, w_z\in\mathbb{R}\f$
be two weighted points.
If all weights are positive, a weighted point
\f$ {p}^{(w)}=(p,w_p)\f$ can also be seen as a sphere of center \f$ p\f$ and
radius \f$ \sqrt{w_p}\f$.
The <I>power product</I> (or <I>power distance</I> )
between \f$ {p}^{(w)}\f$ and \f$ {z}^{(w)}\f$ is
defined as
\f[ \Pi({p}^{(w)},{z}^{(w)}) = {\|{p-z}\|^2-w_p-w_z} \f]
where \f$ \|{p-z}\|\f$ is the Euclidean distance between \f$ p\f$ and \f$ z\f$.
\f$ {p}^{(w)}\f$ and \f$ {z}^{(w)}\f$
are said to be <I>orthogonal</I> if \f$ \Pi{({p}^{(w)}-{z}^{(w)})}
= 0\f$.
\f$D + 1\f$ weighted points have a unique common orthogonal weighted point
called the <I>power sphere</I>. A sphere \f$ {z}^{(w)}\f$ is said to be
<I>regular</I> if \f$ \forall {p}^{(w)}\in{S}^{(w)},
\Pi{({p}^{(w)}-{z}^{(w)})}\geq 0\f$.
A triangulation of \f$ {S}^{(w)}\f$ is <I>regular</I> if the power spheres
of all simplices are regular.
Regular triangulations support insertion of weighted points,
and location of a query point inside the triangulation.
Note that inserting a large set of points at once is much faster
than inserting the same points one by one.
\warning The removal of vertices is not supported yet.
## Implementation ##
The class `CGAL::Regular_triangulation<RegularTriangulationTraits_, TriangulationDataStructure_>` derives from
`CGAL::Triangulation<RegularTriangulationTraits_, TriangulationDataStructure_>`. It thus stores a model of
the concept `TriangulationDataStructure_` which is instantiated with a vertex
type that stores a weighted point and allows its retrieval.
The template parameter `RegularTriangulationTraits_` must be a model of the concept
`RegularTriangulationTraits`. It must provide the `%Weighted_point`
type as well as various geometric predicates used by the
`Regular_triangulation` class.
The concept `RegularTriangulationTraits` refines the concept
`TriangulationTraits`.
## Example ##
This simple example shows how to create a regular triangulation.
\cgalExample{regular_triangulation.cpp}
\section TriangulationSecPerf Complexity and Performances
The current implementation locates points by walking in the
triangulation, and sorts the points with spatial sort to insert a
set of points. Thus the theoretical complexity are
\f$ O(n\log n)\f$ for inserting \f$ n\f$ random points and \f$ O(n^{\frac{1}{d}})\f$
for inserting one point in a triangulation of \f$ n\f$ random points.
In the worst case, the expected complexity is
\f$ O(n^{\lceil\frac{d}{2}\rceil}+n\log n)\f$.
set of points. In the worst case, the expected complexity is
\f$ O(n^{\lceil\frac{d}{2}\rceil}+n\log n)\f$. When the algorithm is
run on \f$ n \f$ random points, the cost of inserting one point is
\f$ O(n^{1/d}) \f$.
We provide below (Figure \cgalFigureRef{Triangulationfigbenchmarks}) the
We provide below (Figure \cgalFigureRef{Triangulationfigbenchmarks100},
\cgalFigureRef{Triangulationfigbenchmarks1000} and
\cgalFigureRef{triangulationfigbenchmarkchart}) the
performance of the Delaunay triangulation on randomly distributed points.
The machine used is a PC running
Windows 7 64-bits with an Intel Xeon CPU clocked at 2.80 GHz with 32GB of RAM.
The program has been compiled with Microsoft Visual C++ 2012 in Release mode.
\cgalFigureAnchor{Triangulationfigbenchmarks}
The program has been compiled with Microsoft Visual C++ 2013 in Release mode.
\cgalFigureAnchor{Triangulationfigbenchmarks100}
<CENTER>
<TABLE CELLSPACING=15>
<TABLE CELLSPACING=15 align=center>
<tr><td ALIGN=LEFT NOWRAP COLSPAN=13><HR></td></tr>
<tr><th ALIGN=RIGHT NOWRAP>Dimension</th><th>2</th><th>3</th><th>4</th><th>5</th><th>6</th><th>7</th><th>8</th><th>9</th><th>10</th><th>11</th><th>12</th></tr>
<tr><td ALIGN=LEFT NOWRAP COLSPAN=13><HR></td></tr>
<tr align=center><td align=right>Time (s)</td><td>0.003</td><td>0.007</td><td>0.03</td><td>0.14</td><td>0.56</td><td>2.7</td><td>11.3</td><td>45</td><td>185</td><td>686</td><td>2390</td></tr>
<tr align=center><td align=right>Memory (MB)</td><td>< 1</td><td>< 1</td><td>< 1</td><td>1</td><td>3</td><td>13</td><td>53</td><td>182</td><td>662</td><td>2187</td><td>7156</td></tr>
<tr align=center><td align=right>Number of maximal simplices</td><td>184</td><td>487</td><td>1,548</td><td>5,548</td><td>19,598</td><td>67,102</td><td>230,375</td><td>715,984</td><td>2,570,623</td><td>7,293,293</td><td>21,235,615</td></tr>
<tr align=center><td align=right>Number of convex hull facets</td><td>14</td><td>66</td><td>308</td><td>1,164</td><td>4,410</td><td>16,974</td><td>57,589</td><td>238,406</td><td>670,545</td><td>2,574,326</td><td>8,603,589</td></tr></td><td>
<tr><td ALIGN=LEFT NOWRAP COLSPAN=13><HR></td></tr>
</TABLE>
</CENTER>
\cgalFigureCaptionBegin{Triangulationfigbenchmarks100}
Performance of the insertion of 100 points in a Delaunay triangulation.
\cgalFigureCaptionEnd
\cgalFigureAnchor{Triangulationfigbenchmarks1000}
<CENTER>
<TABLE CELLSPACING=15 align=center>
<tr><td ALIGN=LEFT NOWRAP COLSPAN=9><HR></td></tr>
<tr><th ALIGN=RIGHT NOWRAP>Dimension</th><th>2</th><th>3</th><th>4</th><th>5</th><th>6</th><th>7</th><th>8</th></tr>
<tr><td ALIGN=LEFT NOWRAP COLSPAN=9><HR></td></tr>
<tr><td>Inserting 100 points</td><td>0.003</td><td>0.007</td><td>0.03</td><td>0.14</td><td>0.56</td><td>2.7</td><td>11.3</td></tr>
<tr><td>Inserting 1000 points</td><td>0.015</td><td>0.056</td><td>0.52</td><td>3.5</td><td>26.2</td><td>185</td><td>1385</td></tr>
<tr align=center><td align=right>Time (s)</td><td>0.01</td><td>0.05</td><td>0.5</td><td>3.4</td><td>24</td><td>183</td><td>1365</td></tr>
<tr align=center><td align=right>Memory (MB)</td><td>< 1</td><td>< 1</td><td>2.7</td><td>14</td><td>81</td><td>483</td><td>2827</td></tr>
<tr align=center><td align=right>Number of maximal simplices</td><td>1,979</td><td>6,315</td><td>25,845</td><td>122,116</td><td>596,927</td><td>3,133,318</td><td>16,403,337</td></tr>
<tr align=center><td align=right>Number of convex hull facets</td><td>19</td><td>138</td><td>963</td><td>6,184</td><td>41,135</td><td>241,540</td><td>1,406,797</td></tr></td><td>
<tr><td ALIGN=LEFT NOWRAP COLSPAN=9><HR></td></tr>
</TABLE>
</CENTER>
\cgalFigureCaptionBegin{Triangulationfigbenchmarks}
Running times in seconds for algorithms on Delaunay triangulations.
\cgalFigureCaptionBegin{Triangulationfigbenchmarks1000}
Performance of the insertion of 1000 points in a Delaunay triangulation.
\cgalFigureCaptionEnd
# Design and Implementation History #
\cgalFigureBegin{triangulationfigbenchmarkchart,benchmark_DTd.png}
Running time wrt. number of maximal simplices, for dimensions for 2 to 12.
\cgalFigureEnd
\section TriangulationSecDesign Design and Implementation History
This package is heavily inspired by the works of
Monique Teillaud and Sylvain Pion (`Triangulation_3`)
and Mariette Yvinec (`Triangulation_2`).
The first version was written by Samuel Hornus. The final version is a joint
work by Samuel Hornus, Olivier Devillers and Clément Jamin.
work by Samuel Hornus, Olivier Devillers and Clément Jamin. In 2015, Clément
Jamin added the regular triangulations.
Clément Jamin's work was supported by the
<a href="http://cordis.europa.eu/project/rcn/111529_en.html">Advanced Grant of the European Research Council GUDHI</a>

View File

@ -1,6 +1,7 @@
/*!
\example barycentric_subdivision.cpp
\example delaunay_triangulation.cpp
\example regular_triangulation.cpp
\example triangulation.cpp
\example triangulation1.cpp
\example triangulation2.cpp

Binary file not shown.

After

Width:  |  Height:  |  Size: 112 KiB

View File

@ -1,3 +1,2 @@
TODO
include/CGAL/Convex_hull.h
include/CGAL/Regular_triangulation.h

View File

@ -22,6 +22,8 @@ if ( CGAL_FOUND )
create_single_source_cgal_program( "barycentric_subdivision.cpp" )
create_single_source_cgal_program( "delaunay_triangulation.cpp" )
create_single_source_cgal_program( "convex_hull.cpp" )
create_single_source_cgal_program( "regular_triangulation.cpp" )
create_single_source_cgal_program( "triangulation.cpp" )
create_single_source_cgal_program( "triangulation_data_structure_dynamic.cpp" )
create_single_source_cgal_program( "triangulation_data_structure_static.cpp" )

View File

@ -1,5 +1,5 @@
#include <CGAL/Triangulation_data_structure.h>
#include <CGAL/internal/Combination_enumerator.h>
#include <CGAL/Combination_enumerator.h>
#include <CGAL/assertions.h>
#include <iostream>
@ -34,8 +34,8 @@ void barycentric_subdivide(TDS & tds, typename TDS::Full_cell_handle fc)
face_vertices.resize(d+1);
// The following class
// enumerates all (d+1)-tuple of the set {0, 1, ..., dim}
CGAL::internal::Combination_enumerator combi(d+1, 0, dim);
while( ! combi.end() )
CGAL::Combination_enumerator<unsigned int> combi(d+1, 0, dim);
while ( !combi.finished() )
{
for( int i = 0; i <= d; ++i )
face_vertices[i] = vertices[combi[i]];

View File

@ -0,0 +1,70 @@
#include <CGAL/Epick_d.h>
#include <CGAL/point_generators_d.h>
#include <CGAL/Delaunay_triangulation.h>
#include <CGAL/algorithm.h>
#include <CGAL/Timer.h>
#include <CGAL/assertions.h>
#include <iostream>
#include <iterator>
#include <vector>
const int D = 10;
typedef CGAL::Epick_d< CGAL::Dimension_tag<D> > K;
typedef CGAL::Delaunay_triangulation<K> T;
// The triangulation uses the default instanciation of the
// TriangulationDataStructure template parameter
int main(int argc, char **argv)
{
int N = 100; // number of points
if (argc > 1)
N = atoi(argv[1]);
CGAL::Timer cost; // timer
// Generate N random points
typedef CGAL::Random_points_in_cube_d<T::Point> Random_points_iterator;
Random_points_iterator rand_it(D, 1.0, CGAL::get_default_random());
std::vector<T::Point> points;
CGAL::cpp11::copy_n(rand_it, N, std::back_inserter(points));
T t(D);
CGAL_assertion(t.empty());
// insert the points in the triangulation, only if they are outside the
// convex hull
std::cout << " Convex hull of "<<N<<" points in dim " << D << std::flush;
cost.reset();
cost.start();
// Spatial sort points to speed-up localization
CGAL::spatial_sort(points.begin(), points.end(), t.geom_traits());
int c = 0;
T::Full_cell_handle hint;
for (std::vector<T::Point>::iterator it_p = points.begin() ;
it_p != points.end() ; ++it_p)
{
T::Locate_type lt;
T::Face f(t.maximal_dimension());
T::Facet ft;
T::Full_cell_handle fch = t.locate(*it_p, lt, f, ft, hint);
if (lt == T::OUTSIDE_CONVEX_HULL || lt == T::OUTSIDE_AFFINE_HULL)
{
hint = t.insert(*it_p, lt, f, ft, fch)->full_cell();
++c;
}
else
{
hint = fch;
}
}
std::cout << " done in " << cost.time() << " seconds.\n";
std::cout << c << " points where actually inserted.\n";
CGAL_assertion( t.is_valid() );
return 0;
}

View File

@ -9,69 +9,42 @@ int main()
#else
#include <CGAL/Epick_d.h>
#include <CGAL/point_generators_d.h>
#include <CGAL/Delaunay_triangulation.h>
#include <CGAL/algorithm.h>
#include <CGAL/Timer.h>
#include <CGAL/assertions.h>
#include <iostream>
#include <iterator>
#include <vector>
const int D=5;
typedef CGAL::Epick_d< CGAL::Dimension_tag<D> > K;
typedef CGAL::Delaunay_triangulation<K> T;
// The triangulation uses the default instanciation of the
// TriangulationDataStructure template parameter
int main(int argc, char **argv)
int main()
{
int N = 100; if( argc > 2 )N = atoi(argv[1]); // number of points
CGAL::Timer cost; // timer
double pointsIn[][7] = {
{ 42.89, 0, 60.55, 30.72, 0, 0, 0 },
{ 45.65, 50.83, 50.37, 16.13, 0, 0, 0 },
{ 79.06, 57.84, 61.59, 2.52, 0, 0, 0 },
{ 44.47, 39.46, 39.53, 28.72, 0, 0, 0 },
{ 0, 100, 0, 0, 100, 0, 53.47 },
{ 66.95, 100, 33.6, 0, 0, 0, 0 },
{ 42.89, 0, 0, 30.72, 100, 0, 53.47 },
{ 100, 100, 100, 100, 100, 100, 100 }
};
typedef CGAL::Triangulation<CGAL::Epick_d< CGAL::Dimension_tag<7> > > T;
T dt(7);
// Instanciate a random point generator
CGAL::Random rng(0);
typedef CGAL::Random_points_in_cube_d<T::Point> Random_points_iterator;
Random_points_iterator rand_it(D, 1.0, rng);
// Generate N random points
std::vector<T::Point> points;
CGAL::cpp11::copy_n(rand_it, N, std::back_inserter(points));
T t(D);
CGAL_assertion(t.empty());
// insert the points in the triangulation
cost.reset();cost.start();
std::cout << " Delaunay triangulation of "<<N<<" points in dim "<<D<< std::flush;
t.insert(points.begin(), points.end());
std::cout << " done in "<<cost.time()<<" seconds." << std::endl;
CGAL_assertion( t.is_valid() );
// insert with special operations in conflict zone and new created cells
cost.reset();
std::cout << " adding "<<N<<" other points "<< std::endl;
for(int i=0; i<N; ++i)
{
T::Vertex_handle v;
T::Face f(t.current_dimension());
T::Facet ft;
T::Full_cell_handle c;
T::Locate_type lt;
typedef std::vector<T::Full_cell_handle> Full_cells;
Full_cells zone, new_full_cells;
std::back_insert_iterator<Full_cells> out(zone);
c = t.locate(*++rand_it, lt, f, ft, v);
// previously inserted vertex v is used as hint for point location (if defined)
T::Facet ftc = t.compute_conflict_zone(*rand_it, c, out);
std::cout<<i<<" conflict zone of size "<<zone.size()<<" -> "<<std::flush;
out = std::back_inserter(new_full_cells);
CGAL_assertion( t.is_valid() );
v = t.insert_in_hole(*rand_it, zone.begin(), zone.end(), ftc, out);
std::cout<<new_full_cells.size()<<" new cells"<<std::endl;
points.reserve(8);
for (int j = 0; j < 8; ++j) {
T::Point p(&pointsIn[j][0], &pointsIn[j][7]);
points.push_back(p);
}
std::cout << " done in "<<cost.time()<<" seconds." << std::endl;
T::Vertex_handle hint;
int i = 0;
for (std::vector<T::Point>::iterator it = points.begin(); it != points.end(); ++it) {
if (T::Vertex_handle() != hint) {
hint = dt.insert(*it, hint);
}
else {
hint = dt.insert(*it);
}
printf("Processing: %d/%d\n", ++i, (int)points.size());
}
return 0;
}

View File

@ -0,0 +1,42 @@
#include <CGAL/Epick_d.h>
#include <CGAL/point_generators_d.h>
#include <CGAL/Regular_triangulation.h>
#include <CGAL/assertions.h>
#include <iostream>
#include <iterator>
#include <vector>
const int D = 5; // Dimension
const int N = 100; // Number of points
typedef CGAL::Epick_d< CGAL::Dimension_tag<D> > K;
typedef CGAL::Regular_triangulation<
CGAL::Regular_triangulation_euclidean_traits<K> > T;
typedef T::Bare_point Bare_point;
typedef T::Weighted_point Weighted_point;
int main()
{
// Instanciate a random point generator
CGAL::Random rng(0);
typedef CGAL::Random_points_in_cube_d<Bare_point> Random_points_iterator;
Random_points_iterator rand_it(D, 1.0, rng);
// Generate N random points
std::vector<Weighted_point> points;
for (int i = 0; i < N; ++i)
points.push_back(Weighted_point(*rand_it++, rng.get_double(0., 10.)));
T t(D);
CGAL_assertion(t.empty());
// Insert the points in the triangulation
t.insert(points.begin(), points.end());
CGAL_assertion( t.is_valid() );
std::cout << "Regular triangulation successfully computed: "
<< t.number_of_vertices() << " vertices, "
<< t.number_of_finite_full_cells() << " finite cells."
<< std::endl;
return 0;
}

View File

@ -76,17 +76,23 @@ public: // PUBLIC NESTED TYPES
typedef typename Base::Full_cell_iterator Full_cell_iterator;
typedef typename Base::Full_cell_const_handle Full_cell_const_handle;
typedef typename Base::Full_cell_const_iterator Full_cell_const_iterator;
typedef typename Base::Finite_full_cell_const_iterator
Finite_full_cell_const_iterator;
typedef typename Base::size_type size_type;
typedef typename Base::difference_type difference_type;
typedef typename Base::Locate_type Locate_type;
//Tag to distinguish triangulations with weighted_points
typedef Tag_false Weighted_tag;
protected: // DATA MEMBERS
public:
using typename Base::Rotor;
using Base::maximal_dimension;
using Base::are_incident_full_cells_valid;
using Base::coaffine_orientation_predicate;
@ -96,11 +102,12 @@ public:
//using Base::incident_full_cells;
using Base::geom_traits;
using Base::index_of_covertex;
//using Base::index_of_second_covertex;
using Base::infinite_vertex;
using Base::rotate_rotor;
using Base::insert_in_hole;
using Base::insert_outside_convex_hull_1;
using Base::is_infinite;
using Base::is_valid;
using Base::locate;
using Base::points_begin;
using Base::set_neighbors;
@ -112,6 +119,8 @@ public:
using Base::full_cell;
using Base::full_cells_begin;
using Base::full_cells_end;
using Base::finite_full_cells_begin;
using Base::finite_full_cells_end;
using Base::vertices_begin;
using Base::vertices_end;
// using Base::
@ -144,36 +153,9 @@ private:
};
public:
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - UTILITIES
// A co-dimension 2 sub-simplex. called a Rotor because we can rotate
// the two "covertices" around the sub-simplex. Useful for traversing the
// boundary of a hole. NOT DOCUMENTED
typedef cpp11::tuple<Full_cell_handle, int, int> Rotor;
/*Full_cell_handle full_cell(const Rotor & r) const // NOT DOCUMENTED
{
return cpp11::get<0>(r);
}
int index_of_covertex(const Rotor & r) const // NOT DOCUMENTED
{
return cpp11::get<1>(r);
}
int index_of_second_covertex(const Rotor & r) const // NOT DOCUMENTED
{
return cpp11::get<2>(r);
}*/
Rotor rotate_rotor(Rotor & r) // NOT DOCUMENTED...
{
int opposite = cpp11::get<0>(r)->mirror_index(cpp11::get<1>(r));
Full_cell_handle s = cpp11::get<0>(r)->neighbor(cpp11::get<1>(r));
int new_second = s->index(cpp11::get<0>(r)->vertex(cpp11::get<2>(r)));
return Rotor(s, new_second, opposite);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - CREATION / CONSTRUCTORS
Delaunay_triangulation(int dim, const Geom_traits k = Geom_traits())
Delaunay_triangulation(int dim, const Geom_traits &k = Geom_traits())
: Base(dim, k)
{
}
@ -186,7 +168,7 @@ public:
Delaunay_triangulation(
int dim,
const std::pair<int, const Flat_orientation_d *> &preset_flat_orientation,
const Geom_traits k = Geom_traits())
const Geom_traits &k = Geom_traits())
: Base(dim, preset_flat_orientation, k)
{
}
@ -341,6 +323,10 @@ public:
return pred_(dc_.full_cell(f)->neighbor(dc_.index_of_covertex(f)));
}
};
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - VALIDITY
bool is_valid(bool verbose = false, int level = 0) const;
private:
// Some internal types to shorten notation
@ -354,27 +340,6 @@ private:
Conflict_traversal_pred_in_subspace;
typedef Conflict_traversal_predicate<Conflict_pred_in_fullspace>
Conflict_traversal_pred_in_fullspace;
// This is used in the |remove(v)| member function to manage sets of Full_cell_handles
template< typename FCH >
struct Full_cell_set : public std::vector<FCH>
{
typedef std::vector<FCH> Base_set;
using Base_set::begin;
using Base_set::end;
void make_searchable()
{ // sort the full cell handles
std::sort(begin(), end());
}
bool contains(const FCH & fch) const
{
return std::binary_search(begin(), end(), fch);
}
bool contains_1st_and_not_2nd(const FCH & fst, const FCH & snd) const
{
return ( ! contains(snd) ) && ( contains(fst) );
}
};
};
// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
@ -404,24 +369,14 @@ Delaunay_triangulation<DCTraits, TDS>
return Full_cell_handle();
}
Full_cell_handle left = v->full_cell();
if( is_infinite(left) && left->neighbor(0)->index(left) == 0 ) // we are on the infinite right.
left = left->neighbor(0);
if( 0 == left->index(v) )
left = left->neighbor(1);
CGAL_assertion( 1 == left->index(v) );
Full_cell_handle right = left->neighbor(0);
if( ! is_infinite(right) )
{
tds().associate_vertex_with_full_cell(left, 1, right->vertex(1));
set_neighbors(left, 0, right->neighbor(0), right->mirror_index(0));
}
else
{
tds().associate_vertex_with_full_cell(left, 1, left->vertex(0));
tds().associate_vertex_with_full_cell(left, 0, infinite_vertex());
set_neighbors(left, 0, left->neighbor(1), left->mirror_index(1));
set_neighbors(left, 1, right->neighbor(1), right->mirror_index(1));
}
tds().delete_vertex(v);
tds().delete_full_cell(right);
return left;
@ -429,7 +384,7 @@ Delaunay_triangulation<DCTraits, TDS>
// THE CASE cur_dim >= 2
// Gather the finite vertices sharing an edge with |v|
typedef Full_cell_set<Full_cell_handle> Simplices;
typedef typename Base::template Full_cell_set<Full_cell_handle> Simplices;
Simplices simps;
std::back_insert_iterator<Simplices> out(simps);
tds().incident_full_cells(v, out);
@ -510,24 +465,16 @@ Delaunay_triangulation<DCTraits, TDS>
{
int v_idx = (*it)->index(v);
tds().associate_vertex_with_full_cell(*it, v_idx, infinite_vertex());
if( v_idx != 0 )
{
// we must put the infinite vertex at index 0.
// OK, now with the new convention that the infinite vertex
// does not have to be at index 0, this is not necessary,
// but still, I prefer to keep this piece of code here. [-- Samuel Hornus]
(*it)->swap_vertices(0, v_idx);
// Now, we preserve the positive orientation of the full_cell
(*it)->swap_vertices(current_dimension() - 1, current_dimension());
}
}
// Make the handles to infinite full cells searchable
infinite_simps.make_searchable();
// Then, modify the neighboring relation
for( typename Simplices::iterator it = simps.begin(); it != simps.end(); ++it )
{
for( int i = 1; i <= current_dimension(); ++i )
for( int i = 0; i <= current_dimension(); ++i )
{
if (is_infinite((*it)->vertex(i)))
continue;
(*it)->vertex(i)->set_full_cell(*it);
Full_cell_handle n = (*it)->neighbor(i);
// Was |n| a finite full cell prior to removing |v| ?
@ -565,7 +512,7 @@ Delaunay_triangulation<DCTraits, TDS>
Dark_s_handle dark_ret_s = dark_s;
Full_cell_handle ret_s;
typedef Full_cell_set<Dark_s_handle> Dark_full_cells;
typedef typename Base::template Full_cell_set<Dark_s_handle> Dark_full_cells;
Dark_full_cells conflict_zone;
std::back_insert_iterator<Dark_full_cells> dark_out(conflict_zone);
@ -771,6 +718,35 @@ Delaunay_triangulation<DCTraits, TDS>
CGAL_assertion( ZERO != o );
if( NEGATIVE == o )
reorient_full_cells();
// We just inserted the second finite point and the right infinite
// cell is like : (inf_v, v), but we want it to be (v, inf_v) to be
// consistent with the rest of the cells
if (current_dimension() == 1)
{
// Is "inf_v_cell" the right infinite cell?
// Then inf_v_index should be 1
if (inf_v_cell->neighbor(inf_v_index)->index(inf_v_cell) == 0
&& inf_v_index == 0)
{
inf_v_cell->swap_vertices(
current_dimension() - 1, current_dimension());
}
// Otherwise, let's find the right infinite cell
else
{
inf_v_cell = inf_v_cell->neighbor((inf_v_index + 1) % 2);
inf_v_index = inf_v_cell->index(infinite_vertex());
// Is "inf_v_cell" the right infinite cell?
// Then inf_v_index should be 1
if (inf_v_cell->neighbor(inf_v_index)->index(inf_v_cell) == 0
&& inf_v_index == 0)
{
inf_v_cell->swap_vertices(
current_dimension() - 1, current_dimension());
}
}
}
}
return v;
}
@ -892,6 +868,48 @@ Delaunay_triangulation<DCTraits, TDS>
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - VALIDITY
template< typename DCTraits, typename TDS >
bool
Delaunay_triangulation<DCTraits, TDS>
::is_valid(bool verbose, int level) const
{
if (!Base::is_valid(verbose, level))
return false;
int dim = current_dimension();
if (dim == maximal_dimension())
{
for (Finite_full_cell_const_iterator cit = finite_full_cells_begin() ;
cit != finite_full_cells_end() ; ++cit )
{
Full_cell_const_handle ch = cit.base();
for(int i = 0; i < dim+1 ; ++i )
{
// If the i-th neighbor is not an infinite cell
Vertex_handle opposite_vh =
ch->neighbor(i)->vertex(ch->neighbor(i)->index(ch));
if (!is_infinite(opposite_vh))
{
Side_of_oriented_sphere_d side =
geom_traits().side_of_oriented_sphere_d_object();
if (side(Point_const_iterator(ch->vertices_begin()),
Point_const_iterator(ch->vertices_end()),
opposite_vh->point()) == ON_BOUNDED_SIDE)
{
if (verbose)
CGAL_warning_msg(false, "Non-empty sphere");
return false;
}
}
}
}
}
return true;
}
} //namespace CGAL
#endif // CGAL_DELAUNAY_COMPLEX_H

View File

@ -0,0 +1,296 @@
// Copyright (c) 2014 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 Lesser 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) : Clement Jamin
#ifndef CGAL_TRIANGULATION_IO_H
#define CGAL_TRIANGULATION_IO_H
#include <CGAL/Epick_d.h>
#include <CGAL/Triangulation.h>
#include <sstream>
#include <iostream>
namespace CGAL {
namespace Triangulation_IO
{
// TODO: test if the stream is binary or text?
template<typename Traits, typename P>
int
output_point(std::ostream & os, const Traits &traits, const P & p)
{
typedef typename Traits::Compute_coordinate_d Ccd;
const Ccd ccd = traits.compute_coordinate_d_object();
const int dim = traits.point_dimension_d_object()(p);
if (dim > 0)
{
os << ccd(p, 0);
for (int i = 1 ; i < dim ; ++i)
os << " " << CGAL::to_double(ccd(p, i));
}
return dim;
}
// TODO: test if the stream is binary or text?
template<typename Traits, typename P>
int
output_weighted_point(std::ostream & os, const Traits &traits, const P & p,
bool output_weight = true)
{
typedef typename Traits::Compute_coordinate_d Ccd;
typename Traits::Point_drop_weight_d drop_w =
traits.point_drop_weight_d_object();
typename Traits::Point_weight_d pt_weight = traits.point_weight_d_object();
const Ccd ccd = traits.compute_coordinate_d_object();
const int dim = traits.point_dimension_d_object()(p);
if (dim > 0)
{
output_point(os, traits, p);
if (output_weight)
os << " " << pt_weight(p);
}
return dim;
}
// TODO: test if the stream is binary or text?
template<typename Traits, typename FCH>
void
output_full_cell(std::ostream & os, const Traits &traits, const FCH & fch,
bool output_weights = false)
{
typename FCH::value_type::Vertex_handle_iterator vit = fch->vertices_begin();
for( ; vit != fch->vertices_end(); ++vit )
{
int dim;
if (output_weights)
dim = output_weighted_point(os, traits, (*vit)->point());
else
dim = output_point(os, traits, (*vit)->point());
if (dim > 0)
os << std::endl;
}
}
// TODO: test if the stream is binary or text?
/*template<typename Traits, typename P>
void
input_point(std::istream & is, const Traits &traits, P & p)
{
typedef typename Traits::FT FT;
std::vector<FT> coords;
std::string line;
for(;;)
{
if (!std::getline(is, line))
return is;
if (line != "")
break;
}
std::stringstream line_sstr(line);
FT temp;
while (line_sstr >> temp)
coords.push_back(temp);
p = traits.construct_point_d_object()(coords.begin(), coords.end());
}*/
} // namespace Triangulation_IO
///////////////////////////////////////////////////////////////
// TODO: replace these operator>> by an "input_point" function
///////////////////////////////////////////////////////////////
// TODO: test if the stream is binary or text?
template<typename K>
std::istream &
operator>>(std::istream &is, typename Wrap::Point_d<K> & p)
{
typedef typename Wrap::Point_d<K> P;
typedef typename K::FT FT;
std::vector<FT> coords;
std::string line;
for(;;)
{
if (!std::getline(is, line))
return is;
if (line != "")
break;
}
std::stringstream line_sstr(line);
FT temp;
while (line_sstr >> temp)
coords.push_back(temp);
p = P(coords.begin(), coords.end());
return is;
}
// TODO: test if the stream is binary or text?
template<typename K>
std::istream &
operator>>(std::istream &is, typename Wrap::Weighted_point_d<K> & wp)
{
typedef typename Wrap::Point_d<K> P;
typedef typename Wrap::Weighted_point_d<K> WP;
typedef typename K::FT FT;
std::string line;
for(;;)
{
if (!std::getline(is, line))
return is;
if (line != "")
break;
}
std::stringstream line_sstr(line);
FT temp;
std::vector<FT> coords;
while (line_sstr >> temp)
coords.push_back(temp);
typename std::vector<FT>::iterator last = coords.end() - 1;
P p = P(coords.begin(), last);
wp = WP(p, *last);
return is;
}
template < class GT, class TDS >
std::ostream &
export_triangulation_to_off(std::ostream & os,
const Triangulation<GT,TDS> & tr,
bool in_3D_export_surface_only = false)
{
typedef Triangulation<GT,TDS> Tr;
typedef typename Tr::Vertex_const_handle Vertex_handle;
typedef typename Tr::Vertex_const_iterator Vertex_iterator;
typedef typename Tr::Finite_vertex_const_iterator Finite_vertex_iterator;
typedef typename Tr::Full_cell_const_handle Full_cell_handle;
typedef typename Tr::Finite_full_cell_const_iterator Finite_full_cell_iterator;
typedef typename Tr::Full_cell_const_iterator Full_cell_iterator;
typedef typename Tr::Full_cell Full_cell;
typedef typename Full_cell::Vertex_handle_const_iterator Full_cell_vertex_iterator;
if (tr.maximal_dimension() < 2 || tr.maximal_dimension() > 3)
{
std::cerr << "Warning: export_tds_to_off => dimension should be 2 or 3.";
os << "Warning: export_tds_to_off => dimension should be 2 or 3.";
return os;
}
size_t n = tr.number_of_vertices();
std::stringstream output;
// write the vertices
std::map<Vertex_handle, int> index_of_vertex;
int i = 0;
for(Finite_vertex_iterator it = tr.finite_vertices_begin();
it != tr.finite_vertices_end(); ++it, ++i)
{
Triangulation_IO::output_point(output, tr.geom_traits(), it->point());
if (tr.maximal_dimension() == 2)
output << " 0";
output << std::endl;
index_of_vertex[it.base()] = i;
}
CGAL_assertion( i == n );
size_t number_of_triangles = 0;
if (tr.maximal_dimension() == 2)
{
for (Finite_full_cell_iterator fch = tr.finite_full_cells_begin() ;
fch != tr.finite_full_cells_end() ; ++fch)
{
output << "3 ";
for (Full_cell_vertex_iterator vit = fch->vertices_begin() ;
vit != fch->vertices_end() ; ++vit)
{
output << index_of_vertex[*vit] << " ";
}
output << std::endl;
++number_of_triangles;
}
}
else if (tr.maximal_dimension() == 3)
{
if (in_3D_export_surface_only)
{
// Parse boundary facets
for (Full_cell_iterator fch = tr.full_cells_begin() ;
fch != tr.full_cells_end() ; ++fch)
{
if (tr.is_infinite(fch))
{
output << "3 ";
for (Full_cell_vertex_iterator vit = fch->vertices_begin() ;
vit != fch->vertices_end() ; ++vit)
{
if (!tr.is_infinite(*vit))
output << index_of_vertex[*vit] << " ";
}
output << std::endl;
++number_of_triangles;
}
}
}
else
{
// Parse finite cells
for (Finite_full_cell_iterator fch = tr.finite_full_cells_begin() ;
fch != tr.finite_full_cells_end() ; ++fch)
{
output << "3 "
<< index_of_vertex[fch->vertex(0)] << " "
<< index_of_vertex[fch->vertex(1)] << " "
<< index_of_vertex[fch->vertex(2)]
<< std::endl;
output << "3 "
<< index_of_vertex[fch->vertex(0)] << " "
<< index_of_vertex[fch->vertex(2)] << " "
<< index_of_vertex[fch->vertex(3)]
<< std::endl;
output << "3 "
<< index_of_vertex[fch->vertex(1)] << " "
<< index_of_vertex[fch->vertex(2)] << " "
<< index_of_vertex[fch->vertex(3)]
<< std::endl;
output << "3 "
<< index_of_vertex[fch->vertex(0)] << " "
<< index_of_vertex[fch->vertex(1)] << " "
<< index_of_vertex[fch->vertex(3)]
<< std::endl;
number_of_triangles += 4;
}
}
}
os << "OFF \n"
<< n << " "
<< number_of_triangles << " 0\n"
<< output.str();
return os;
}
} //namespace CGAL
#endif // CGAL_TRIANGULATION_IO_H

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,279 @@
// Copyright (c) 2014 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) : Clement Jamin
#ifndef CGAL_REGULAR_TRIANGULATION_EUCLIDEAN_TRAITS_H
#define CGAL_REGULAR_TRIANGULATION_EUCLIDEAN_TRAITS_H
#include <CGAL/basic.h>
#include <boost/iterator/transform_iterator.hpp>
namespace CGAL {
template <class K>
class Regular_triangulation_euclidean_traits
: public K
{
public:
typedef K Base;
// Required by TriangulationTraits
typedef typename K::Dimension Dimension;
typedef typename K::FT FT;
typedef typename K::Flat_orientation_d Flat_orientation_d;
typedef typename K::Weighted_point_d Point_d;
// Required by RegularTriangulationTraits
typedef typename K::Point_d Bare_point;
typedef typename K::Weighted_point_d Weighted_point;
typedef typename K::Point_drop_weight_d Point_drop_weight_d;
typedef typename K::Point_weight_d Point_weight_d;
typedef typename K::Power_test_d Power_test_d;
typedef typename K::In_flat_power_test_d In_flat_power_test_d;
//===========================================================================
// Custom types
//===========================================================================
// Required by SpatialSortingTraits_d
class Less_coordinate_d
{
const K &m_kernel;
public:
typedef bool result_type;
Less_coordinate_d(const K &kernel)
: m_kernel(kernel) {}
result_type operator()(
Weighted_point const& p, Weighted_point const& q, int i) const
{
Point_drop_weight_d pdw = m_kernel.point_drop_weight_d_object();
return m_kernel.less_coordinate_d_object() (pdw(p), pdw(q), i);
}
};
//===========================================================================
// Required by TriangulationTraits
class Orientation_d
{
const K &m_kernel;
public:
typedef Orientation result_type;
Orientation_d(const K &kernel)
: m_kernel(kernel) {}
template <typename ForwardIterator>
result_type operator()(ForwardIterator start, ForwardIterator end) const
{
Point_drop_weight_d pdw = m_kernel.point_drop_weight_d_object();
return m_kernel.orientation_d_object() (
boost::make_transform_iterator(start, pdw),
boost::make_transform_iterator(end, pdw)
);
}
};
//===========================================================================
// Required by TriangulationTraits
class Construct_flat_orientation_d
{
const K &m_kernel;
public:
typedef Flat_orientation_d result_type;
Construct_flat_orientation_d(const K &kernel)
: m_kernel(kernel) {}
template <typename ForwardIterator>
result_type operator()(ForwardIterator start, ForwardIterator end) const
{
Point_drop_weight_d pdw = m_kernel.point_drop_weight_d_object();
return m_kernel.construct_flat_orientation_d_object() (
boost::make_transform_iterator(start, pdw),
boost::make_transform_iterator(end, pdw)
);
}
};
//===========================================================================
// Required by TriangulationTraits
class In_flat_orientation_d
{
const K &m_kernel;
public:
typedef Orientation result_type;
In_flat_orientation_d(const K &kernel)
: m_kernel(kernel) {}
template <typename ForwardIterator>
result_type operator()(Flat_orientation_d orient,
ForwardIterator start, ForwardIterator end) const
{
Point_drop_weight_d pdw = m_kernel.point_drop_weight_d_object();
return m_kernel.in_flat_orientation_d_object() (
orient,
boost::make_transform_iterator(start, pdw),
boost::make_transform_iterator(end, pdw)
);
}
};
//===========================================================================
// Required by TriangulationTraits
class Contained_in_affine_hull_d
{
const K &m_kernel;
public:
typedef bool result_type;
Contained_in_affine_hull_d(const K &kernel)
: m_kernel(kernel) {}
template <typename ForwardIterator>
result_type operator()(ForwardIterator start, ForwardIterator end,
const Weighted_point & p) const
{
Point_drop_weight_d pdw = m_kernel.point_drop_weight_d_object();
return m_kernel.contained_in_affine_hull_d_object() (
boost::make_transform_iterator(start, pdw),
boost::make_transform_iterator(end, pdw),
pdw(p)
);
}
};
//===========================================================================
// Required by TriangulationTraits
class Compare_lexicographically_d
{
const K &m_kernel;
public:
typedef Comparison_result result_type;
Compare_lexicographically_d(const K &kernel)
: m_kernel(kernel) {}
result_type operator()(
const Weighted_point & p, const Weighted_point & q) const
{
Point_drop_weight_d pdw = m_kernel.point_drop_weight_d_object();
return m_kernel.compare_lexicographically_d_object()(pdw(p), pdw(q));
}
};
//===========================================================================
// Only for Triangulation_off_ostream.h (undocumented)
class Compute_coordinate_d
{
const K &m_kernel;
public:
typedef FT result_type;
Compute_coordinate_d(const K &kernel)
: m_kernel(kernel) {}
result_type operator()(
const Weighted_point & p, const int i) const
{
Point_drop_weight_d pdw = m_kernel.point_drop_weight_d_object();
return m_kernel.compute_coordinate_d_object()(pdw(p), i);
}
};
//===========================================================================
// To satisfy SpatialSortingTraits_d
// and also for Triangulation_off_ostream.h (undocumented)
class Point_dimension_d
{
const K &m_kernel;
public:
typedef int result_type;
Point_dimension_d(const K &kernel)
: m_kernel(kernel) {}
result_type operator()(
const Weighted_point & p) const
{
Point_drop_weight_d pdw = m_kernel.point_drop_weight_d_object();
return m_kernel.point_dimension_d_object()(pdw(p));
}
};
//===========================================================================
// Object creation
//===========================================================================
Less_coordinate_d less_coordinate_d_object() const
{
return Less_coordinate_d(*this);
}
Contained_in_affine_hull_d contained_in_affine_hull_d_object() const
{
return Contained_in_affine_hull_d(*this);
}
Orientation_d orientation_d_object() const
{
return Orientation_d(*this);
}
Construct_flat_orientation_d construct_flat_orientation_d_object() const
{
return Construct_flat_orientation_d(*this);
}
In_flat_orientation_d in_flat_orientation_d_object() const
{
return In_flat_orientation_d(*this);
}
Compare_lexicographically_d compare_lexicographically_d_object() const
{
return Compare_lexicographically_d(*this);
}
Compute_coordinate_d compute_coordinate_d_object() const
{
return Compute_coordinate_d(*this);
}
Point_dimension_d point_dimension_d_object() const
{
return Point_dimension_d(*this);
}
};
} //namespace CGAL
#endif // CGAL_REGULAR_TRIANGULATION_EUCLIDEAN_TRAITS_H

View File

@ -29,6 +29,7 @@
#include <CGAL/Dimension.h>
#include <CGAL/iterator.h>
#include <CGAL/Default.h>
#include <CGAL/Random.h>
#include <boost/iterator/filter_iterator.hpp>
#include <boost/iterator/transform_iterator.hpp>
@ -226,7 +227,35 @@ public:
{
return tds().index_of_covertex(f);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - UTILITIES
// A co-dimension 2 sub-simplex. called a Rotor because we can rotate
// the two "covertices" around the sub-simplex. Useful for traversing the
// boundary of a hole. NOT DOCUMENTED
typedef cpp11::tuple<Full_cell_handle, int, int> Rotor;
// Commented out because it was causing "internal compiler error" in MSVC
/*Full_cell_handle full_cell(const Rotor & r) const // NOT DOCUMENTED
{
return cpp11::get<0>(r);
}
int index_of_covertex(const Rotor & r) const // NOT DOCUMENTED
{
return cpp11::get<1>(r);
}
int index_of_second_covertex(const Rotor & r) const // NOT DOCUMENTED
{
return cpp11::get<2>(r);
}*/
Rotor rotate_rotor(Rotor & r) // NOT DOCUMENTED...
{
int opposite = cpp11::get<0>(r)->mirror_index(cpp11::get<1>(r));
Full_cell_handle s = cpp11::get<0>(r)->neighbor(cpp11::get<1>(r));
int new_second = s->index(cpp11::get<0>(r)->vertex(cpp11::get<2>(r)));
return Rotor(s, new_second, opposite);
}
// - - - - - - - - - - - - - - - - - - - - - - - - CREATION / CONSTRUCTORS
Triangulation(int dim, const Geom_traits k = Geom_traits())
@ -539,7 +568,7 @@ public:
}
template< typename OutputIterator >
OutputIterator incident_faces(Vertex_const_handle v, int d, OutputIterator out)
OutputIterator incident_faces(Vertex_const_handle v, int d, OutputIterator out) const
{
return tds().incident_faces(v, d, out);
}
@ -601,7 +630,12 @@ public:
return tds().new_full_cell();
}
Vertex_handle new_vertex(const Point & p)
Vertex_handle new_vertex()
{
return tds().new_vertex();
}
Vertex_handle new_vertex(const Point & p)
{
return tds().new_vertex(p);
}
@ -706,6 +740,43 @@ public:
// make sure all full_cells have positive orientation
void reorient_full_cells();
protected:
// This is used in the |remove(v)| member function to manage sets of Full_cell_handles
template< typename FCH >
struct Full_cell_set : public std::vector<FCH>
{
typedef std::vector<FCH> Base_set;
using Base_set::begin;
using Base_set::end;
void make_searchable()
{ // sort the full cell handles
std::sort(begin(), end());
}
bool contains(const FCH & fch) const
{
return std::binary_search(begin(), end(), fch);
}
bool contains_1st_and_not_2nd(const FCH & fst, const FCH & snd) const
{
return ( ! contains(snd) ) && ( contains(fst) );
}
};
void display_all_full_cells__debugging() const
{
std::cerr << "ALL FULL CELLS:" << std::endl;
for (Full_cell_const_iterator cit = full_cells_begin() ;
cit != full_cells_end() ; ++cit )
{
std::cerr << std::hex << &*cit << ": ";
for (int jj = 0 ; jj <= current_dimension() ; ++jj)
std::cerr << (is_infinite(cit->vertex(jj)) ? 0xFFFFFFFF : (unsigned int)&*cit->vertex(jj)) << " - ";
std::cerr << std::dec << std::endl;
}
std::cerr << std::endl;
}
}; // Triangulation<...>
// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
@ -719,17 +790,15 @@ Triangulation<TT, TDS>
{
if( current_dimension() < 1 )
return;
Full_cell_iterator sit = full_cells_begin();
Full_cell_iterator send = full_cells_end();
while( sit != send )
for ( ; sit != send ; ++sit)
{
if( is_infinite(sit) && (1 == current_dimension()) )
if( ! (is_infinite(sit) && (1 == current_dimension())) )
{
++sit;
continue;
sit->swap_vertices(current_dimension() - 1, current_dimension());
}
sit->swap_vertices(current_dimension() - 1, current_dimension());
++sit;
}
}
@ -851,13 +920,8 @@ Triangulation<TT, TDS>
CGAL_precondition( is_infinite(s) );
CGAL_precondition( 1 == current_dimension() );
int inf_v_index = s->index(infinite_vertex());
bool swap = (0 == s->neighbor(inf_v_index)->index(s));
Vertex_handle v = tds().insert_in_full_cell(s);
v->set_point(p);
if( swap )
{
s->swap_vertices(0, 1);
}
return v;
}
@ -914,6 +978,36 @@ Triangulation<TT, TDS>
CGAL_assertion( COPLANAR != o );
if( NEGATIVE == o )
reorient_full_cells();
// We just inserted the second finite point and the right infinite
// cell is like : (inf_v, v), but we want it to be (v, inf_v) to be
// consistent with the rest of the cells
if (current_dimension() == 1)
{
// Is "inf_v_cell" the right infinite cell?
// Then inf_v_index should be 1
if (inf_v_cell->neighbor(inf_v_index)->index(inf_v_cell) == 0
&& inf_v_index == 0)
{
inf_v_cell->swap_vertices(
current_dimension() - 1, current_dimension());
}
// Otherwise, let's find the right infinite cell
else
{
inf_v_cell = inf_v_cell->neighbor((inf_v_index + 1) % 2);
inf_v_index = inf_v_cell->index(infinite_vertex());
// Is "inf_v_cell" the right infinite cell?
// Then inf_v_index should be 1
if (inf_v_cell->neighbor(inf_v_index)->index(inf_v_cell) == 0
&& inf_v_index == 0)
{
inf_v_cell->swap_vertices(
current_dimension() - 1, current_dimension());
}
}
}
}
return v;
}

View File

@ -417,7 +417,6 @@ private:
void clear_visited_marks(Full_cell_handle) const;
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - DANGEROUS UPDATE OPERATIONS
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - DANGEROUS UPDATE OPERATIONS
private:
@ -612,7 +611,7 @@ public:
return incident_faces(v, dim, out, cmp, true);
}
template< typename OutputIterator, typename Comparator = std::less<Vertex_const_handle> >
OutputIterator incident_faces(Vertex_const_handle, const int, OutputIterator, Comparator = Comparator(), bool = false);
OutputIterator incident_faces(Vertex_const_handle, const int, OutputIterator, Comparator = Comparator(), bool = false) const;
#else
template< typename OutputIterator, typename Comparator >
OutputIterator incident_upper_faces(Vertex_const_handle v, const int dim, OutputIterator out, Comparator cmp = Comparator())
@ -625,10 +624,10 @@ public:
return incident_faces(v, dim, out, std::less<Vertex_const_handle>(), true);
}
template< typename OutputIterator, typename Comparator >
OutputIterator incident_faces(Vertex_const_handle, const int, OutputIterator, Comparator = Comparator(), bool = false);
OutputIterator incident_faces(Vertex_const_handle, const int, OutputIterator, Comparator = Comparator(), bool = false) const;
template< typename OutputIterator >
OutputIterator incident_faces(Vertex_const_handle, const int, OutputIterator,
std::less<Vertex_const_handle> = std::less<Vertex_const_handle>(), bool = false);
std::less<Vertex_const_handle> = std::less<Vertex_const_handle>(), bool = false) const;
#endif
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - INPUT / OUTPUT
@ -724,7 +723,7 @@ template< typename OutputIterator >
OutputIterator
Triangulation_data_structure<Dim, Vb, Fcb>
::incident_faces(Vertex_const_handle v, const int dim, OutputIterator out,
std::less<Vertex_const_handle> cmp, bool upper_faces)
std::less<Vertex_const_handle> cmp, bool upper_faces) const
{
return incident_faces<OutputIterator, std::less<Vertex_const_handle> >(v, dim, out, cmp, upper_faces);
}
@ -734,7 +733,7 @@ template< class Dim, class Vb, class Fcb >
template< typename OutputIterator, typename Comparator >
OutputIterator
Triangulation_data_structure<Dim, Vb, Fcb>
::incident_faces(Vertex_const_handle v, const int dim, OutputIterator out, Comparator cmp, bool upper_faces)
::incident_faces(Vertex_const_handle v, const int dim, OutputIterator out, Comparator cmp, bool upper_faces) const
{
CGAL_precondition( 0 < dim );
if( dim >= current_dimension() )
@ -788,13 +787,13 @@ Triangulation_data_structure<Dim, Vb, Fcb>
// init state for enumerating all candidate faces:
internal::Combination_enumerator f_idx(dim, v_idx + 1, current_dimension());
Face f(*s);
f.set_index(0, v_idx);
f.set_index(0, sorted_idx[v_idx]);
while( ! f_idx.end() )
{
// check if face has already been found
for( int i = 0; i < dim; ++i )
f.set_index(1 + i, sorted_idx[f_idx[i]]);
face_set.insert(f);
face_set.insert(f); // checks if face has already been found
// compute next sorted face (lexicographic enumeration)
++f_idx;
}
@ -889,8 +888,7 @@ Triangulation_data_structure<Dim, Vb, Fcb>
if( v_idx != current_dimension() )
{
(*it)->swap_vertices(v_idx, current_dimension());
if( ( ! (*it)->has_vertex(star) ) || (current_dimension() > 2) )
(*it)->swap_vertices(current_dimension() - 2, current_dimension() - 1);
(*it)->swap_vertices(current_dimension() - 2, current_dimension() - 1);
}
(*it)->set_vertex(current_dimension(), Vertex_handle());
(*it)->set_neighbor(current_dimension(), Full_cell_handle());
@ -1000,7 +998,7 @@ Triangulation_data_structure<Dim, Vb, Fcb>
associate_vertex_with_full_cell(new_s, facet_index, v);
set_neighbors(new_s,
facet_index,
neighbor(old_s, facet_index),
outside_neighbor,
mirror_index(old_s, facet_index));
// add the new full_cell to the list of new full_cells
@ -1139,11 +1137,6 @@ void Triangulation_data_structure<Dim, Vb, Fcb>
for( int k = 1; k <= cur_dim; ++k )
associate_vertex_with_full_cell(S_new, k, vertex(S, k - 1));
}
else if( cur_dim == 2 )
{ // if cur. dim. is 2, we must take care of the 'rightmost' infinite vertex.
if( S->mirror_index(S->index(star)) == 0 )
swap_me = S;
}
}
// now we setup the neighbors
set_visited(start, false);
@ -1523,7 +1516,9 @@ operator>>(std::istream & is, Triangulation_data_structure<Dimen, Vb, Fcb> & tr)
// - the neighbors of each full_cell by their index in the preceding list
{
typedef Triangulation_data_structure<Dimen, Vb, Fcb> TDS;
typedef typename TDS::Vertex_handle Vertex_handle;
typedef typename TDS::Full_cell_handle Full_cell_handle;
typedef typename TDS::Full_cell_iterator Full_cell_iterator;
typedef typename TDS::Vertex_handle Vertex_handle;
// read current dimension and number of vertices
std::size_t n;
@ -1573,8 +1568,10 @@ operator<<(std::ostream & os, const Triangulation_data_structure<Dimen, Vb, Fcb>
// - the neighbors of each full_cell by their index in the preceding list
{
typedef Triangulation_data_structure<Dimen, Vb, Fcb> TDS;
typedef typename TDS::Vertex_const_handle Vertex_handle;
typedef typename TDS::Vertex_const_iterator Vertex_iterator;
typedef typename TDS::Full_cell_const_handle Full_cell_handle;
typedef typename TDS::Full_cell_const_iterator Full_cell_iterator;
typedef typename TDS::Vertex_const_handle Vertex_handle;
typedef typename TDS::Vertex_const_iterator Vertex_iterator;
// outputs dimension and number of vertices
std::size_t n = tr.number_of_vertices();
@ -1594,7 +1591,7 @@ operator<<(std::ostream & os, const Triangulation_data_structure<Dimen, Vb, Fcb>
int i = 0;
for( Vertex_iterator it = tr.vertices_begin(); it != tr.vertices_end(); ++it, ++i )
{
os << *it; // write the vertex
os << *it << std::endl; // write the vertex
index_of_vertex[it] = i;
}
CGAL_assertion( (std::size_t) i == n );

View File

@ -61,7 +61,6 @@ public:
/// Set 's' as an incident full_cell
void set_full_cell(Full_cell_handle s) /* Concept */
{
CGAL_precondition( Full_cell_handle() != s );
full_cell_ = s;
}

View File

@ -22,7 +22,6 @@
#include <CGAL/Triangulation_ds_vertex.h>
#include <CGAL/Default.h>
#include <CGAL/Random.h>
namespace CGAL {

View File

@ -98,7 +98,7 @@ public:
template< class T >
struct Compare_points_for_perturbation
{
typedef typename T::Point_d Point;
typedef typename T::Geom_traits::Point_d Point;
const T & t_;
@ -119,8 +119,8 @@ public:
template< class T >
struct Point_from_pointer
{
typedef const typename T::Point_d * argument_type;
typedef const typename T::Point_d result_type;
typedef const typename T::Geom_traits::Point_d * argument_type;
typedef const typename T::Geom_traits::Point_d result_type;
result_type & operator()(argument_type & x) const
{
return (*x);

View File

@ -1,7 +1,6 @@
# Created by the script cgal_create_cmake_script
# This is the CMake script for compiling a CGAL application.
project( Triangulation_test )
cmake_minimum_required(VERSION 2.8.11)
@ -21,18 +20,18 @@ if ( CGAL_FOUND )
include_directories (BEFORE "../../include")
include_directories (BEFORE "include")
create_single_source_cgal_program( "test_triangulation.cpp" )
create_single_source_cgal_program( "test_delaunay.cpp" )
create_single_source_cgal_program( "test_regular.cpp" )
create_single_source_cgal_program( "test_tds.cpp" )
create_single_source_cgal_program( "test_torture.cpp" )
create_single_source_cgal_program( "test_triangulation.cpp" )
create_single_source_cgal_program( "test_insert_if_in_star.cpp" )
else()
message(STATUS "NOTICE: Some of the executables in this directory need Eigen 3.1 (or greater) and will not be compiled.")
endif()
else()
message(STATUS "This program requires the CGAL library, and will not be compiled.")
endif()

View File

@ -34,79 +34,80 @@ void test(const int d, const string & type, const int N)
typedef CGAL::Random_points_in_cube_d<Point> Random_points_iterator;
DC pc(d);
DC dt(d);
cerr << "\nBuilding Delaunay triangulation of (" << type << d << ") dimension with " << N << " points";
assert(pc.empty());
assert(dt.empty());
vector<Point> points;
CGAL::Random rng;
Random_points_iterator rand_it(d, 2.0, rng);
//CGAL::Random rng;
//Random_points_iterator rand_it(d, 2.0, rng);
//CGAL::cpp11::copy_n(rand_it, N, back_inserter(points));
vector<int> coords(d);
srand(10);
for( int i = 0; i < N; ++i )
{
vector<double> coords(d);
for( int j = 0; j < d; ++j )
coords[j] = rand() % 100000;
coords[j] = static_cast<double>(rand() % 100000)/10000;
points.push_back(Point(d, coords.begin(), coords.end()));
}
pc.insert(points.begin(), points.end());
dt.insert(points.begin(), points.end());
cerr << "\nChecking topology and geometry...";
assert( pc.is_valid() );
assert( dt.is_valid() );
cerr << "\nTraversing finite full_cells... ";
size_t nbfs(0), nbis(0);
Finite_full_cell_const_iterator fsit = pc.finite_full_cells_begin();
while( fsit != pc.finite_full_cells_end() )
Finite_full_cell_const_iterator fsit = dt.finite_full_cells_begin();
while( fsit != dt.finite_full_cells_end() )
++fsit, ++nbfs;
cerr << nbfs << " + ";
vector<Full_cell_handle> infinite_full_cells;
pc.tds().incident_full_cells(pc.infinite_vertex(), back_inserter(infinite_full_cells));
dt.tds().incident_full_cells(dt.infinite_vertex(), back_inserter(infinite_full_cells));
nbis = infinite_full_cells.size();
cerr << nbis << " = " << (nbis+nbfs)
<< " = " << pc.number_of_full_cells();
cerr << "\nThe triangulation has current dimension " << pc.current_dimension();
CGAL_assertion( pc.number_of_full_cells() == nbis+nbfs);
<< " = " << dt.number_of_full_cells();
cerr << "\nThe triangulation has current dimension " << dt.current_dimension();
CGAL_assertion( dt.number_of_full_cells() == nbis+nbfs);
cerr << "\nTraversing finite vertices... ";
size_t nbfv(0);
Finite_vertex_iterator fvit = pc.finite_vertices_begin();
while( fvit != pc.finite_vertices_end() )
Finite_vertex_iterator fvit = dt.finite_vertices_begin();
while( fvit != dt.finite_vertices_end() )
++fvit, ++nbfv;
cerr << nbfv <<endl;
// Count convex hull vertices:
if( pc.maximal_dimension() > 1 )
if( dt.maximal_dimension() > 1 )
{
typedef vector<Face> Faces;
Faces edges;
back_insert_iterator<Faces> out(edges);
pc.tds().incident_faces(pc.infinite_vertex(), 1, out);
dt.tds().incident_faces(dt.infinite_vertex(), 1, out);
cout << "\nThere are " << edges.size() << " vertices on the convex hull.";
edges.clear();
}
else // pc.maximal_dimension() == 1
else // dt.maximal_dimension() == 1
{
typedef vector<Full_cell_handle> Cells;
Cells cells;
back_insert_iterator<Cells> out(cells);
pc.tds().incident_full_cells(pc.infinite_vertex(), out);
dt.tds().incident_full_cells(dt.infinite_vertex(), out);
cout << "\nThere are " << cells.size() << " vertices on the convex hull.";
cells.clear();
}
// Remove all !
cerr << "\nBefore removal: " << pc.number_of_vertices() << " vertices. After: ";
cerr << "\nBefore removal: " << dt.number_of_vertices() << " vertices. After: ";
random_shuffle(points.begin(), points.end());
pc.remove(points.begin(), points.end());
assert( pc.is_valid() );
cerr << pc.number_of_vertices() << " vertices.";
// assert( pc.empty() ); NOT YET !
dt.remove(points.begin(), points.end());
assert( dt.is_valid() );
cerr << dt.number_of_vertices() << " vertices.";
// assert( dt.empty() ); NOT YET !
// CLEAR
pc.clear();
assert( -1 == pc.current_dimension() );
assert( pc.empty() );
assert( pc.is_valid() );
dt.clear();
assert( -1 == dt.current_dimension() );
assert( dt.empty() );
assert( dt.is_valid() );
}
template< int D >
@ -122,14 +123,14 @@ void go(const int N)
int main(int argc, char **argv)
{
srand(static_cast<unsigned int>(time(NULL)));
int N = 100;
int N = 10;
if( argc > 1 )
N = atoi(argv[1]);
go<5>(N);
go<4>(N);
go<3>(N);
go<2>(N);
go<1>(N);
//go<5>(N);
go<4>(N);
go<3>(N);
go<2>(N);
go<1>(N);
cerr << endl;
return 0;

View File

@ -0,0 +1,92 @@
#include <CGAL/Epick_d.h>
#include <CGAL/point_generators_d.h>
#include <CGAL/Regular_triangulation.h>
#include <CGAL/IO/Triangulation_off_ostream.h>
#include <CGAL/algorithm.h>
#include <vector>
#include <string>
#include <fstream>
#include <cstdlib>
#include <algorithm>
using namespace std;
template<typename RTri>
void test(const int d, const string & type, const int N)
{
typedef typename RTri::Vertex_handle Vertex_handle;
typedef typename RTri::Point Point;
typedef typename RTri::Bare_point Bare_point;
typedef CGAL::Random_points_in_cube_d<Bare_point> Random_points_iterator;
RTri rt(d);
RTri rt_star_only(d);
cerr << "\nBuilding Regular triangulation of (" << type << d
<< ") dimension with " << N << " points\n";
assert(rt.empty());
assert(rt_star_only.empty());
srand(static_cast<unsigned int>(time(NULL)));
// Insert first point (0, 0...)
vector<double> coords(d);
for( int j = 0; j < d; ++j )
coords[j] = 0;
Point p = Point(
Bare_point(d, coords.begin(), coords.end()),
static_cast<double>(rand() % 10000)/100000);
rt.insert(p);
Vertex_handle first_vertex = rt_star_only.insert(p);
// Insert the other points
for( int i = 1 ; i < N ; ++i )
{
for( int j = 0; j < d; ++j )
coords[j] = 10.*(rand() % RAND_MAX)/RAND_MAX - 5.;
p = Point(
Bare_point(d, coords.begin(), coords.end()),
static_cast<double>(rand() % 10000)/1000000);
rt.insert(p);
rt_star_only.insert_if_in_star(p, first_vertex);
}
cerr << "\nChecking topology and geometry..."
<< (rt.is_valid(true) ? "OK.\n" : "Error.\n");
cerr << "\nThe triangulation using 'insert' has current dimension " << rt.current_dimension()
<< " and " << rt.number_of_full_cells() << " full cells\n";
cerr << "\nThe triangulation using 'insert_if_in_star' has current dimension " << rt.current_dimension()
<< " and " << rt_star_only.number_of_full_cells() << " full cells\n";
// Export
if (d <= 3)
{
std::ofstream off_stream_all("data/test_insert_all.off");
CGAL::export_triangulation_to_off(off_stream_all, rt);
std::ofstream off_stream_star_only("data/test_insert_if_in_star.off");
CGAL::export_triangulation_to_off(off_stream_star_only, rt_star_only);
}
}
template< int D >
void go(const int N)
{
//typedef CGAL::Epick_d<CGAL::Dynamic_dimension_tag> FK;
typedef CGAL::Epick_d<CGAL::Dimension_tag<D> > FK;
typedef CGAL::Regular_triangulation<FK> Triangulation;
//test<Triangulation>(D, "dynamic", N);
test<Triangulation>(D, "static", N);
}
int main(int argc, char **argv)
{
go<2>(100);
return 0;
}

View File

@ -0,0 +1,130 @@
#include <CGAL/Epick_d.h>
#include <CGAL/point_generators_d.h>
#include <CGAL/Regular_triangulation.h>
#include <CGAL/algorithm.h>
#include <tilted_grid.h>
#include <vector>
#include <string>
#include <fstream>
#include <cstdlib>
#include <algorithm>
using namespace std;
template<typename RTri>
void test(const int d, const string & type, const int N)
{
typedef typename RTri::Full_cell_handle Full_cell_handle;
typedef typename RTri::Face Face;
typedef typename RTri::Point Point;
typedef typename RTri::Bare_point Bare_point;
typedef typename RTri::Finite_full_cell_const_iterator Finite_full_cell_const_iterator;
typedef typename RTri::Finite_vertex_iterator Finite_vertex_iterator;
typedef CGAL::Random_points_in_cube_d<Bare_point> Random_points_iterator;
RTri rt(d);
cerr << "\nBuilding Regular triangulation of (" << type << d << ") dimension with " << N << " points";
assert(rt.empty());
vector<Point> points;
srand(10);
for( int i = 0; i < N; ++i )
{
vector<double> coords(d);
for( int j = 0; j < d; ++j )
coords[j] = static_cast<double>(rand() % 100000)/10000;
points.push_back(Point(
Bare_point(d, coords.begin(), coords.end()),
static_cast<double>(rand() % 100000)/100000
));
}
rt.insert(points.begin(), points.end());
cerr << "\nChecking topology and geometry...";
assert( rt.is_valid(true) );
cerr << "\nTraversing finite full_cells... ";
size_t nbfs(0), nbis(0);
Finite_full_cell_const_iterator fsit = rt.finite_full_cells_begin();
while( fsit != rt.finite_full_cells_end() )
++fsit, ++nbfs;
cerr << nbfs << " + ";
vector<Full_cell_handle> infinite_full_cells;
rt.tds().incident_full_cells(rt.infinite_vertex(), back_inserter(infinite_full_cells));
nbis = infinite_full_cells.size();
cerr << nbis << " = " << (nbis+nbfs)
<< " = " << rt.number_of_full_cells();
cerr << "\nThe triangulation has current dimension " << rt.current_dimension();
CGAL_assertion( rt.number_of_full_cells() == nbis+nbfs);
cerr << "\nTraversing finite vertices... ";
size_t nbfv(0);
Finite_vertex_iterator fvit = rt.finite_vertices_begin();
while( fvit != rt.finite_vertices_end() )
++fvit, ++nbfv;
cerr << nbfv <<endl;
// Count convex hull vertices:
if( rt.maximal_dimension() > 1 )
{
typedef vector<Face> Faces;
Faces edges;
back_insert_iterator<Faces> out(edges);
rt.tds().incident_faces(rt.infinite_vertex(), 1, out);
cout << "\nThere are " << edges.size() << " vertices on the convex hull.";
edges.clear();
}
else // rt.maximal_dimension() == 1
{
typedef vector<Full_cell_handle> Cells;
Cells cells;
back_insert_iterator<Cells> out(cells);
rt.tds().incident_full_cells(rt.infinite_vertex(), out);
cout << "\nThere are " << cells.size() << " vertices on the convex hull.";
cells.clear();
}
// Remove all !
cerr << "\nBefore removal: " << rt.number_of_vertices() << " vertices. After: ";
random_shuffle(points.begin(), points.end());
rt.remove(points.begin(), points.end());
assert( rt.is_valid() );
//std::cerr << ((rt.is_valid(true)) ? "VALID!" : "NOT VALID :(") << std::endl;
cerr << rt.number_of_vertices() << " vertices.";
// assert( rt.empty() ); NOT YET !
// CLEAR
rt.clear();
assert( -1 == rt.current_dimension() );
assert( rt.empty() );
assert( rt.is_valid() );
//std::cerr << ((rt.is_valid(true)) ? "VALID!" : "NOT VALID :(") << std::endl;
}
template< int D >
void go(const int N)
{
//typedef CGAL::Epick_d<CGAL::Dynamic_dimension_tag> FK;
typedef CGAL::Epick_d<CGAL::Dimension_tag<D> > FK;
typedef CGAL::Regular_triangulation<
CGAL::Regular_triangulation_euclidean_traits<FK> > Triangulation;
//test<Triangulation>(D, "dynamic", N);
test<Triangulation>(D, "static", N);
}
int main(int argc, char **argv)
{
srand(static_cast<unsigned int>(time(NULL)));
int N = 10;
if( argc > 1 )
N = atoi(argv[1]);
//go<5>(N);
go<4>(N);
go<3>(N);
go<2>(N);
go<1>(N);
cerr << endl;
return 0;
}

View File

@ -124,10 +124,11 @@ int main(int argc, char **argv)
int N = 1000;
if( argc > 1 )
N = atoi(argv[1]);
go<5>(N);
go<3>(N);
go<2>(N);
go<1>(N);
//go<5>(N);
go<4>(N);
go<3>(N);
go<2>(N);
go<1>(N);
cerr << std::endl;
return 0;

View File

@ -0,0 +1,19 @@
0 0 6.28953
-2.85086 -0.471442 6.12896
1.90972 0.101219 0.988689
0.637771 2.59367 5.80372
2.22209 0.903198 2.19478
-0.487202 -2.71506 4.90996
1.1193 -1.91787 2.99626
1.54714 0.109831 0
0.44556 -2.73047 4.48142
0.427936 1.28495 6.23624
-2.67212 0.766674 5.29623
1.5763 -1.59828 2.58905
-0.476603 2.2546 6.04797
1.57172 -0.514711 6.11405
1.84528 2.10139 5.53936
-2.99827 -0.101677 5.92246
-0.482122 -2.39584 4.44264
-2.25558 -1.492 6.23448
0.128475 -1.75125 3.18916

View File

@ -0,0 +1,28 @@
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Regular_triangulation_euclidean_traits_2.h>
#include <CGAL/Regular_triangulation_filtered_traits_2.h>
#include <CGAL/Regular_triangulation_2.h>
#include <CGAL/IO/Triangulation_off_ostream_2.h>
#include <fstream>
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::Regular_triangulation_filtered_traits_2<K> Traits;
typedef CGAL::Regular_triangulation_2<Traits> Regular_triangulation;
int main()
{
std::ifstream in("data/points.cin");
Regular_triangulation::Weighted_point wp;
std::vector<Regular_triangulation::Weighted_point> wpoints;
while(in >> wp)
wpoints.push_back(wp);
Regular_triangulation rt(wpoints.begin(), wpoints.end());
CGAL_assertion(rt.is_valid(true));
std::ofstream off_stream("data/rt2.off");
CGAL::export_triangulation_2_to_off(off_stream, rt);
return 0;
}

View File

@ -0,0 +1,79 @@
// Copyright (c) 2014 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 Lesser 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) : Clement Jamin
#ifndef CGAL_TRIANGULATION_OFF_OSTREAM_2_H
#define CGAL_TRIANGULATION_OFF_OSTREAM_2_H
#include <CGAL/Triangulation_2.h>
#include <sstream>
#include <iostream>
namespace CGAL {
template < class GT, class TDS >
std::ostream &
export_triangulation_2_to_off(std::ostream & os,
const Triangulation_2<GT,TDS> & tr)
{
typedef Triangulation_2<GT,TDS> Tr;
typedef typename Tr::Vertex_handle Vertex_handle;
typedef typename Tr::Vertex_iterator Vertex_iterator;
typedef typename Tr::Finite_vertices_iterator Finite_vertex_iterator;
typedef typename Tr::Finite_faces_iterator Finite_faces_iterator;
size_t n = tr.number_of_vertices();
std::stringstream output;
// write the vertices
std::map<Vertex_handle, int> index_of_vertex;
int i = 0;
for(Finite_vertex_iterator it = tr.finite_vertices_begin();
it != tr.finite_vertices_end(); ++it, ++i)
{
output << it->point().x() << " " << it->point().y() << " 0" << std::endl;
index_of_vertex[it.base()] = i;
}
CGAL_assertion( i == n );
size_t number_of_triangles = 0;
for (Finite_faces_iterator fit = tr.finite_faces_begin() ;
fit != tr.finite_faces_end() ; ++fit)
{
output << "3 "
<< index_of_vertex[fit->vertex(0)] << " "
<< index_of_vertex[fit->vertex(1)] << " "
<< index_of_vertex[fit->vertex(2)]
<< std::endl;
++number_of_triangles;
}
os << "OFF \n"
<< n << " "
<< number_of_triangles << " 0\n"
<< output.str();
return os;
}
} //namespace CGAL
#endif // CGAL_TRIANGULATION_OFF_OSTREAM_2_H

View File

@ -0,0 +1,10 @@
0.0071 1.6899 2.521 0
0.3272 1.3694 3.15 0.05
1.3697 1.8296 2.654 0.1
-10.6722 0.3012 0.1548 1000.15
1.1726 0.1899 0.3658 0.2
0.4374 20.8541 1.45894 2000.25
2.5923 0.1904 0.6971 0.3
10.3083 2.5462 1.3658 1000.35
1.4981 1.3929 2.949 0.4
2.1304 2.055 0.6597455 1.45

View File

@ -0,0 +1,10 @@
0.0071 1.6899 2.521 0
0.3272 1.3694 3.15 0
1.3697 1.8296 2.654 0
-10.6722 0.3012 0.1548 0
1.1726 0.1899 0.3658 0
0.4374 20.8541 1.45894 0
2.5923 0.1904 0.6971 0
10.3083 2.5462 1.3658 0
1.4981 1.3929 2.949 0
2.1304 2.055 0.6597455 0

View File

@ -0,0 +1,10 @@
0.0071 1.6899 2.521 0
0.3272 1.3694 3.15 0
1.3697 1.8296 2.654 0
-10.6722 0.3012 0.1548 0
1.1726 0.1899 0.3658 0
0.4374 20.8541 1.45894 0
2.5923 0.1904 0.6971 0
10.3083 2.5462 1.3658 0
1.4981 1.3929 2.949 0
2.1304 2.055 0.6597455 0

View File

@ -0,0 +1,26 @@
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Regular_triangulation_3.h>
#include <CGAL/Regular_triangulation_euclidean_traits_3.h>
#include <CGAL/IO/Triangulation_off_ostream_3.h>
#include <fstream>
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::Regular_triangulation_euclidean_traits_3<K> Traits;
typedef CGAL::Regular_triangulation_3<Traits> Regular_triangulation;
int main()
{
std::ifstream in("data/points.cin");
Regular_triangulation::Weighted_point wp;
std::vector<Regular_triangulation::Weighted_point> wpoints;
while(in >> wp)
wpoints.push_back(wp);
Regular_triangulation rt(wpoints.begin(), wpoints.end());
std::ofstream off_stream("data/rt3.off");
CGAL::export_triangulation_3_to_off(off_stream, rt);
return 0;
}

View File

@ -0,0 +1,119 @@
// Copyright (c) 2014 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 Lesser 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) : Clement Jamin
#ifndef CGAL_TRIANGULATION_OFF_OSTREAM_3_H
#define CGAL_TRIANGULATION_OFF_OSTREAM_3_H
#include <CGAL/Triangulation_3.h>
#include <sstream>
#include <iostream>
namespace CGAL {
template < class GT, class TDS >
std::ostream &
export_triangulation_3_to_off(std::ostream & os,
const Triangulation_3<GT,TDS> & tr,
bool export_surface_only = false)
{
typedef Triangulation_3<GT,TDS> Tr;
typedef typename Tr::Vertex_handle Vertex_handle;
typedef typename Tr::Vertex_iterator Vertex_iterator;
typedef typename Tr::Finite_vertices_iterator Finite_vertex_iterator;
typedef typename Tr::All_cells_iterator Cells_iterator;
typedef typename Tr::Finite_cells_iterator Finite_cells_iterator;
size_t n = tr.number_of_vertices();
std::stringstream output;
// write the vertices
std::map<Vertex_handle, int> index_of_vertex;
int i = 0;
for(Finite_vertex_iterator it = tr.finite_vertices_begin();
it != tr.finite_vertices_end(); ++it, ++i)
{
output << it->point().x() << " "
<< it->point().y() << " "
<< it->point().z() << std::endl;
index_of_vertex[it.base()] = i;
}
CGAL_assertion( i == n );
size_t number_of_triangles = 0;
if (export_surface_only)
{
for (Cells_iterator cit = tr.cells_begin() ;
cit != tr.cells_end() ; ++cit)
{
if (tr.is_infinite(cit))
{
output << "3 ";
for (int i = 0 ; i < 4 ; ++i)
{
if (!tr.is_infinite(cit->vertex(i)))
output << index_of_vertex[cit->vertex(i)] << " ";
}
output << std::endl;
++number_of_triangles;
}
}
}
else
{
for (Finite_cells_iterator cit = tr.finite_cells_begin() ;
cit != tr.finite_cells_end() ; ++cit)
{
output << "3 "
<< index_of_vertex[cit->vertex(0)] << " "
<< index_of_vertex[cit->vertex(1)] << " "
<< index_of_vertex[cit->vertex(2)]
<< std::endl;
output << "3 "
<< index_of_vertex[cit->vertex(0)] << " "
<< index_of_vertex[cit->vertex(2)] << " "
<< index_of_vertex[cit->vertex(3)]
<< std::endl;
output << "3 "
<< index_of_vertex[cit->vertex(1)] << " "
<< index_of_vertex[cit->vertex(2)] << " "
<< index_of_vertex[cit->vertex(3)]
<< std::endl;
output << "3 "
<< index_of_vertex[cit->vertex(0)] << " "
<< index_of_vertex[cit->vertex(1)] << " "
<< index_of_vertex[cit->vertex(3)]
<< std::endl;
number_of_triangles += 4;
}
}
os << "OFF \n"
<< n << " "
<< number_of_triangles << " 0\n"
<< output.str();
return os;
}
} //namespace CGAL
#endif // CGAL_TRIANGULATION_OFF_OSTREAM_3_H