mirror of https://github.com/CGAL/cgal
Merge branch 'Triangulation-add_regular_tri-cjamin_mglisse-old' into Triangulation-add_regular_tri-cjamin_mglisse
This commit is contained in:
commit
2f4bb69e0a
|
|
@ -26,6 +26,7 @@
|
||||||
#include <CGAL/NewKernel_d/Kernel_d_interface.h>
|
#include <CGAL/NewKernel_d/Kernel_d_interface.h>
|
||||||
#include <CGAL/internal/Exact_type_selector.h>
|
#include <CGAL/internal/Exact_type_selector.h>
|
||||||
#include <CGAL/Interval_nt.h>
|
#include <CGAL/Interval_nt.h>
|
||||||
|
#include <CGAL/NewKernel_d/Types/Weighted_point.h>
|
||||||
|
|
||||||
|
|
||||||
namespace CGAL {
|
namespace CGAL {
|
||||||
|
|
|
||||||
|
|
@ -87,6 +87,7 @@ struct Cartesian_LA_base_d : public Dimension_base<Dim_>
|
||||||
::add<Segment_tag>::type
|
::add<Segment_tag>::type
|
||||||
::add<Hyperplane_tag>::type
|
::add<Hyperplane_tag>::type
|
||||||
::add<Sphere_tag>::type
|
::add<Sphere_tag>::type
|
||||||
|
::add<Weighted_point_tag>::type
|
||||||
Object_list;
|
Object_list;
|
||||||
|
|
||||||
typedef typeset< Point_cartesian_const_iterator_tag>::type
|
typedef typeset< Point_cartesian_const_iterator_tag>::type
|
||||||
|
|
|
||||||
|
|
@ -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);
|
std::vector<int>& rest=o.rest; rest.reserve(dim+1);
|
||||||
for(int i=0; i<dim+1; ++i) rest.push_back(i);
|
for(int i=0; i<dim+1; ++i) rest.push_back(i);
|
||||||
for( ; f != e ; ++col, ++f ) {
|
for( ; f != e ; ++col, ++f ) {
|
||||||
|
//std::cerr << "(*f)[0]=" << (*f)[0] << std::endl;
|
||||||
Point const&p=*f;
|
Point const&p=*f;
|
||||||
// use a coordinate iterator instead?
|
// use a coordinate iterator instead?
|
||||||
for(int i=0; i<dim; ++i) coord(col, i) = ccc(p, i);
|
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_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_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_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(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));
|
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));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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, Ray_tag>::type Ray_d;
|
||||||
typedef typename Get_type<Base, Iso_box_tag>::type Iso_box_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, 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, 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, Compare_lexicographically_tag>::type Compare_lexicographically_d;
|
||||||
typedef typename Get_functor<Base, Equal_points_tag>::type Equal_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, 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, 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, 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, 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, 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_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_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, 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, Vector_to_point_tag>::type Vector_to_point_d;
|
||||||
typedef typename Get_functor<Base, Scaled_vector_tag>::type Scaled_vector_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<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<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<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;
|
typedef typename Get_functor<Base, Midpoint_tag>::type Midpoint_d;
|
||||||
struct Component_accessor_d : private Store_kernel<Kernel> {
|
struct Component_accessor_d : private Store_kernel<Kernel> {
|
||||||
typedef Kernel R_; // for the macro
|
typedef Kernel R_; // for the macro
|
||||||
|
|
@ -150,6 +154,9 @@ template <class Base_> struct Kernel_d_interface : public Base_ {
|
||||||
typedef typename Get_functor<Base, Orthogonal_vector_tag>::type Orthogonal_vector_d;
|
typedef typename Get_functor<Base, Orthogonal_vector_tag>::type Orthogonal_vector_d;
|
||||||
typedef typename Get_functor<Base, Linear_base_tag>::type Linear_base_d;
|
typedef typename Get_functor<Base, Linear_base_tag>::type Linear_base_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:
|
//TODO:
|
||||||
//typedef ??? Intersect_d;
|
//typedef ??? Intersect_d;
|
||||||
|
|
||||||
|
|
@ -166,6 +173,7 @@ template <class Base_> struct Kernel_d_interface : public Base_ {
|
||||||
Point_dimension_d point_dimension_d_object()const{ return Point_dimension_d(*this); }
|
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); }
|
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); }
|
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); }
|
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_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); }
|
Contained_in_linear_hull_d contained_in_linear_hull_d_object()const{ return Contained_in_linear_hull_d(*this); }
|
||||||
|
|
@ -173,6 +181,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); }
|
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_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_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); }
|
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); }
|
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); }
|
Scaled_vector_d scaled_vector_d_object()const{ return Scaled_vector_d(*this); }
|
||||||
|
|
@ -203,6 +212,10 @@ template <class Base_> struct Kernel_d_interface : public Base_ {
|
||||||
Construct_ray_d construct_ray_d_object()const{ return Construct_ray_d(*this); }
|
Construct_ray_d construct_ray_d_object()const{ return Construct_ray_d(*this); }
|
||||||
Construct_iso_box_d construct_iso_box_d_object()const{ return Construct_iso_box_d(*this); }
|
Construct_iso_box_d construct_iso_box_d_object()const{ return Construct_iso_box_d(*this); }
|
||||||
Construct_aff_transformation_d construct_aff_transformation_d_object()const{ return Construct_aff_transformation_d(*this); }
|
Construct_aff_transformation_d construct_aff_transformation_d_object()const{ return Construct_aff_transformation_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.
|
// Dummies for those required functors missing a concept.
|
||||||
typedef Null_functor Position_on_line_d;
|
typedef Null_functor Position_on_line_d;
|
||||||
|
|
|
||||||
|
|
@ -117,5 +117,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
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
@ -28,6 +28,7 @@
|
||||||
#include <CGAL/NewKernel_d/Wrapper/Segment_d.h>
|
#include <CGAL/NewKernel_d/Wrapper/Segment_d.h>
|
||||||
#include <CGAL/NewKernel_d/Wrapper/Sphere_d.h>
|
#include <CGAL/NewKernel_d/Wrapper/Sphere_d.h>
|
||||||
#include <CGAL/NewKernel_d/Wrapper/Hyperplane_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>
|
#include <CGAL/NewKernel_d/Wrapper/Ref_count_obj.h>
|
||||||
|
|
||||||
|
|
@ -106,6 +107,7 @@ CGAL_REGISTER_OBJECT_WRAPPER(Vector);
|
||||||
CGAL_REGISTER_OBJECT_WRAPPER(Segment);
|
CGAL_REGISTER_OBJECT_WRAPPER(Segment);
|
||||||
CGAL_REGISTER_OBJECT_WRAPPER(Sphere);
|
CGAL_REGISTER_OBJECT_WRAPPER(Sphere);
|
||||||
CGAL_REGISTER_OBJECT_WRAPPER(Hyperplane);
|
CGAL_REGISTER_OBJECT_WRAPPER(Hyperplane);
|
||||||
|
CGAL_REGISTER_OBJECT_WRAPPER(Weighted_point);
|
||||||
#undef CGAL_REGISTER_OBJECT_WRAPPER
|
#undef CGAL_REGISTER_OBJECT_WRAPPER
|
||||||
|
|
||||||
// Note: this tends to be an all or nothing thing currently, wrapping
|
// Note: this tends to be an all or nothing thing currently, wrapping
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
@ -549,6 +549,60 @@ template<class R_> struct Orientation<R_,false> : private Store_kernel<R_> {
|
||||||
}
|
}
|
||||||
#endif
|
#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 {
|
namespace CartesianDKernelFunctors {
|
||||||
template<class R_> struct Side_of_oriented_sphere : private Store_kernel<R_> {
|
template<class R_> struct Side_of_oriented_sphere : private Store_kernel<R_> {
|
||||||
CGAL_FUNCTOR_INIT_STORE(Side_of_oriented_sphere)
|
CGAL_FUNCTOR_INIT_STORE(Side_of_oriented_sphere)
|
||||||
|
|
|
||||||
|
|
@ -175,6 +175,7 @@ namespace CGAL {
|
||||||
CGAL_DECL_OBJ(Iso_box, Object);
|
CGAL_DECL_OBJ(Iso_box, Object);
|
||||||
CGAL_DECL_OBJ(Bbox, Object);
|
CGAL_DECL_OBJ(Bbox, Object);
|
||||||
CGAL_DECL_OBJ(Aff_transformation, Object);
|
CGAL_DECL_OBJ(Aff_transformation, Object);
|
||||||
|
CGAL_DECL_OBJ(Weighted_point, Object);
|
||||||
#undef CGAL_DECL_OBJ_
|
#undef CGAL_DECL_OBJ_
|
||||||
#undef CGAL_DECL_OBJ
|
#undef CGAL_DECL_OBJ
|
||||||
|
|
||||||
|
|
@ -216,6 +217,7 @@ namespace CGAL {
|
||||||
CGAL_DECL_COMPUTE(Scalar_product);
|
CGAL_DECL_COMPUTE(Scalar_product);
|
||||||
CGAL_DECL_COMPUTE(Hyperplane_translation);
|
CGAL_DECL_COMPUTE(Hyperplane_translation);
|
||||||
CGAL_DECL_COMPUTE(Value_at);
|
CGAL_DECL_COMPUTE(Value_at);
|
||||||
|
CGAL_DECL_COMPUTE(Point_weight);
|
||||||
#undef CGAL_DECL_COMPUTE
|
#undef CGAL_DECL_COMPUTE
|
||||||
|
|
||||||
#define CGAL_DECL_ITER_OBJ(X,Y,Z,C) struct X##_tag {}; \
|
#define CGAL_DECL_ITER_OBJ(X,Y,Z,C) struct X##_tag {}; \
|
||||||
|
|
@ -265,6 +267,7 @@ namespace CGAL {
|
||||||
CGAL_DECL_CONSTRUCT(Translated_point,Point);
|
CGAL_DECL_CONSTRUCT(Translated_point,Point);
|
||||||
CGAL_DECL_CONSTRUCT(Point_to_vector,Vector);
|
CGAL_DECL_CONSTRUCT(Point_to_vector,Vector);
|
||||||
CGAL_DECL_CONSTRUCT(Vector_to_point,Point);
|
CGAL_DECL_CONSTRUCT(Vector_to_point,Point);
|
||||||
|
CGAL_DECL_CONSTRUCT(Point_drop_weight,Point);
|
||||||
#undef CGAL_DECL_CONSTRUCT
|
#undef CGAL_DECL_CONSTRUCT
|
||||||
#if 0
|
#if 0
|
||||||
#define CGAL_DECL_ITER_CONSTRUCT(X,Y) struct X##_tag {}; \
|
#define CGAL_DECL_ITER_CONSTRUCT(X,Y) struct X##_tag {}; \
|
||||||
|
|
@ -304,6 +307,10 @@ namespace CGAL {
|
||||||
CGAL_DECL_PREDICATE(Affinely_independent);
|
CGAL_DECL_PREDICATE(Affinely_independent);
|
||||||
CGAL_DECL_PREDICATE(Contained_in_linear_hull);
|
CGAL_DECL_PREDICATE(Contained_in_linear_hull);
|
||||||
CGAL_DECL_PREDICATE(Contained_in_simplex);
|
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
|
#undef CGAL_DECL_PREDICATE
|
||||||
|
|
||||||
#define CGAL_DECL_MISC(X) struct X##_tag {}; \
|
#define CGAL_DECL_MISC(X) struct X##_tag {}; \
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,10 @@
|
||||||
#include <boost/iterator/iterator_adaptor.hpp>
|
#include <boost/iterator/iterator_adaptor.hpp>
|
||||||
#include <boost/utility/result_of.hpp>
|
#include <boost/utility/result_of.hpp>
|
||||||
#include <boost/type_traits/is_empty.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 <CGAL/Default.h>
|
||||||
#include <utility>
|
#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>
|
template <typename Derived, typename F, typename Iter, typename Ref, typename Val>
|
||||||
class transforming_iterator_helper
|
class transforming_iterator_helper
|
||||||
{
|
{
|
||||||
|
typedef std::iterator_traits<Iter> Iter_traits;
|
||||||
|
typedef typename Iter_traits::reference Iter_ref;
|
||||||
typedef typename Default::Get<Ref,
|
typedef typename Default::Get<Ref,
|
||||||
#ifdef CGAL_CXX11
|
#ifdef CGAL_CXX11
|
||||||
decltype(std::declval<F>()(std::declval<typename std::iterator_traits<Iter>::reference>()))
|
decltype(std::declval<F>()(std::declval<Iter_ref>()))
|
||||||
#else
|
#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
|
// should be reference instead of value_type
|
||||||
#endif
|
#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:
|
public:
|
||||||
typedef boost::iterator_adaptor<
|
typedef boost::iterator_adaptor<
|
||||||
Derived,
|
Derived,
|
||||||
Iter,
|
Iter,
|
||||||
value_type,
|
value_type,
|
||||||
typename std::iterator_traits<Iter>::iterator_category,
|
typename Iter_traits::iterator_category,
|
||||||
reference
|
reference
|
||||||
> type;
|
> type;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@
|
||||||
#include <CGAL/Interval_nt.h>
|
#include <CGAL/Interval_nt.h>
|
||||||
#include <CGAL/use.h>
|
#include <CGAL/use.h>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <CGAL/NewKernel_d/Types/Weighted_point.h>
|
||||||
|
|
||||||
//typedef CGAL::Cartesian_base_d<double,CGAL::Dimension_tag<2> > K0;
|
//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;
|
//typedef CGAL::Cartesian_base_d<CGAL::Interval_nt_advanced,CGAL::Dimension_tag<2> > KA;
|
||||||
|
|
@ -493,6 +494,7 @@ void test3(){
|
||||||
P x4=cp(0,0,1);
|
P x4=cp(0,0,1);
|
||||||
P x5=cp(0,0,0);
|
P x5=cp(0,0,0);
|
||||||
P x6=cp(0,0,-1);
|
P x6=cp(0,0,-1);
|
||||||
|
assert(!ed(x1,x2));
|
||||||
P tab2[]={x1,x2,x3,x4,x5};
|
P tab2[]={x1,x2,x3,x4,x5};
|
||||||
assert(cis(tab2+0,tab2+4,x5));
|
assert(cis(tab2+0,tab2+4,x5));
|
||||||
assert(po(tab2+0,tab2+4)==CGAL::POSITIVE);
|
assert(po(tab2+0,tab2+4)==CGAL::POSITIVE);
|
||||||
|
|
@ -540,6 +542,26 @@ void test3(){
|
||||||
assert(ifsos(fozn, tz+0, tz+3, tz[4]) == CGAL::ON_NEGATIVE_SIDE);
|
assert(ifsos(fozn, tz+0, tz+3, tz[4]) == CGAL::ON_NEGATIVE_SIDE);
|
||||||
assert(ifsos(fozp, tz+0, tz+3, tz[5]) == CGAL::ON_NEGATIVE_SIDE);
|
assert(ifsos(fozp, tz+0, tz+3, tz[5]) == CGAL::ON_NEGATIVE_SIDE);
|
||||||
assert(ifsos(fozn, tz+0, tz+3, tz[5]) == CGAL::ON_POSITIVE_SIDE);
|
assert(ifsos(fozn, tz+0, tz+3, tz[5]) == CGAL::ON_POSITIVE_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<2> >;
|
||||||
template struct CGAL::Epick_d<CGAL::Dimension_tag<3> >;
|
template struct CGAL::Epick_d<CGAL::Dimension_tag<3> >;
|
||||||
|
|
|
||||||
|
|
@ -155,6 +155,17 @@ namespace Eigen {
|
||||||
MulCost = 100
|
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:
|
//since types are included by Gmp_coercion_traits.h:
|
||||||
|
|
|
||||||
|
|
@ -1283,6 +1283,13 @@ namespace Eigen {
|
||||||
MulCost = 10
|
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
|
#endif // CGAL_INTERVAL_NT_H
|
||||||
|
|
|
||||||
|
|
@ -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" )
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -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
|
||||||
|
|
@ -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
|
||||||
|
|
@ -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
|
||||||
|
|
@ -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
|
||||||
|
|
@ -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
|
||||||
|
|
@ -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;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,43 @@
|
||||||
|
#include <CGAL/Epick_d.h>
|
||||||
|
#include <CGAL/Regular_triangulation_euclidean_traits.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_euclidean_traits<K> Traits;
|
||||||
|
typedef CGAL::Regular_triangulation<Traits> 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;
|
||||||
|
}
|
||||||
|
|
@ -65,6 +65,5 @@ int main(int argc, char **argv)
|
||||||
go<7>(N);
|
go<7>(N);
|
||||||
go<8>(N);
|
go<8>(N);
|
||||||
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,2 @@
|
||||||
TODO
|
TODO
|
||||||
include/CGAL/Convex_hull.h
|
include/CGAL/Convex_hull.h
|
||||||
include/CGAL/Regular_triangulation.h
|
|
||||||
|
|
|
||||||
|
|
@ -81,11 +81,15 @@ public: // PUBLIC NESTED TYPES
|
||||||
|
|
||||||
typedef typename Base::Locate_type Locate_type;
|
typedef typename Base::Locate_type Locate_type;
|
||||||
|
|
||||||
|
//Tag to distinguish triangulations with weighted_points
|
||||||
|
typedef Tag_false Weighted_tag;
|
||||||
|
|
||||||
protected: // DATA MEMBERS
|
protected: // DATA MEMBERS
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
using typename Base::Rotor;
|
||||||
using Base::maximal_dimension;
|
using Base::maximal_dimension;
|
||||||
using Base::are_incident_full_cells_valid;
|
using Base::are_incident_full_cells_valid;
|
||||||
using Base::coaffine_orientation_predicate;
|
using Base::coaffine_orientation_predicate;
|
||||||
|
|
@ -95,11 +99,11 @@ public:
|
||||||
//using Base::incident_full_cells;
|
//using Base::incident_full_cells;
|
||||||
using Base::geom_traits;
|
using Base::geom_traits;
|
||||||
using Base::index_of_covertex;
|
using Base::index_of_covertex;
|
||||||
|
//using Base::index_of_second_covertex;
|
||||||
using Base::infinite_vertex;
|
using Base::infinite_vertex;
|
||||||
using Base::insert_in_hole;
|
using Base::insert_in_hole;
|
||||||
using Base::insert_outside_convex_hull_1;
|
using Base::insert_outside_convex_hull_1;
|
||||||
using Base::is_infinite;
|
using Base::is_infinite;
|
||||||
using Base::is_valid;
|
|
||||||
using Base::locate;
|
using Base::locate;
|
||||||
using Base::points_begin;
|
using Base::points_begin;
|
||||||
using Base::set_neighbors;
|
using Base::set_neighbors;
|
||||||
|
|
@ -143,36 +147,9 @@ private:
|
||||||
};
|
};
|
||||||
public:
|
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
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - 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)
|
: Base(dim, k)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
@ -185,7 +162,7 @@ public:
|
||||||
Delaunay_triangulation(
|
Delaunay_triangulation(
|
||||||
int dim,
|
int dim,
|
||||||
const std::pair<int, const Flat_orientation_d *> &preset_flat_orientation,
|
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)
|
: Base(dim, preset_flat_orientation, k)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
@ -341,6 +318,10 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - VALIDITY
|
||||||
|
|
||||||
|
bool is_valid(bool verbose = false, int level = 0) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Some internal types to shorten notation
|
// Some internal types to shorten notation
|
||||||
typedef typename Base::Coaffine_orientation_d Coaffine_orientation_d;
|
typedef typename Base::Coaffine_orientation_d Coaffine_orientation_d;
|
||||||
|
|
@ -353,27 +334,6 @@ private:
|
||||||
Conflict_traversal_pred_in_subspace;
|
Conflict_traversal_pred_in_subspace;
|
||||||
typedef Conflict_traversal_predicate<Conflict_pred_in_fullspace>
|
typedef Conflict_traversal_predicate<Conflict_pred_in_fullspace>
|
||||||
Conflict_traversal_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) );
|
|
||||||
}
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
|
// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
|
||||||
|
|
@ -428,7 +388,7 @@ Delaunay_triangulation<DCTraits, TDS>
|
||||||
|
|
||||||
// THE CASE cur_dim >= 2
|
// THE CASE cur_dim >= 2
|
||||||
// Gather the finite vertices sharing an edge with |v|
|
// 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;
|
Simplices simps;
|
||||||
std::back_insert_iterator<Simplices> out(simps);
|
std::back_insert_iterator<Simplices> out(simps);
|
||||||
tds().incident_full_cells(v, out);
|
tds().incident_full_cells(v, out);
|
||||||
|
|
@ -564,7 +524,7 @@ Delaunay_triangulation<DCTraits, TDS>
|
||||||
Dark_s_handle dark_ret_s = dark_s;
|
Dark_s_handle dark_ret_s = dark_s;
|
||||||
Full_cell_handle ret_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;
|
Dark_full_cells conflict_zone;
|
||||||
std::back_insert_iterator<Dark_full_cells> dark_out(conflict_zone);
|
std::back_insert_iterator<Dark_full_cells> dark_out(conflict_zone);
|
||||||
|
|
||||||
|
|
@ -780,9 +740,8 @@ Delaunay_triangulation<DCTraits, TDS>
|
||||||
::insert_in_conflicting_cell(const Point & p, const Full_cell_handle s)
|
::insert_in_conflicting_cell(const Point & p, const Full_cell_handle s)
|
||||||
{
|
{
|
||||||
typedef std::vector<Full_cell_handle> Full_cell_h_vector;
|
typedef std::vector<Full_cell_handle> Full_cell_h_vector;
|
||||||
static Full_cell_h_vector cs; // for storing conflicting full_cells.
|
Full_cell_h_vector cs; // for storing conflicting full_cells.
|
||||||
cs.clear();
|
cs.reserve(64);
|
||||||
// cs.reserve(64);
|
|
||||||
std::back_insert_iterator<Full_cell_h_vector> out(cs);
|
std::back_insert_iterator<Full_cell_h_vector> out(cs);
|
||||||
Facet ft = compute_conflict_zone(p, s, out);
|
Facet ft = compute_conflict_zone(p, s, out);
|
||||||
return insert_in_hole(p, cs.begin(), cs.end(), ft);
|
return insert_in_hole(p, cs.begin(), cs.end(), ft);
|
||||||
|
|
@ -890,6 +849,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
|
} //namespace CGAL
|
||||||
|
|
||||||
#endif // CGAL_DELAUNAY_COMPLEX_H
|
#endif // CGAL_DELAUNAY_COMPLEX_H
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,255 @@
|
||||||
|
// 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>
|
||||||
|
void
|
||||||
|
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));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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);
|
||||||
|
|
||||||
|
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
|
|
@ -0,0 +1,254 @@
|
||||||
|
// 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 <CGAL/triangulation_assertions.h>
|
||||||
|
#include <CGAL/Weighted_point.h>
|
||||||
|
#include <CGAL/representation_tags.h>
|
||||||
|
#include <CGAL/Kernel_traits.h>
|
||||||
|
|
||||||
|
#include <boost/iterator/transform_iterator.hpp>
|
||||||
|
|
||||||
|
namespace CGAL {
|
||||||
|
|
||||||
|
template < class K, class Weight = typename K::RT >
|
||||||
|
class Regular_triangulation_euclidean_traits
|
||||||
|
: public K
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
typedef K Base;
|
||||||
|
typedef Regular_triangulation_euclidean_traits<K, Weight> Self;
|
||||||
|
|
||||||
|
// Types from K
|
||||||
|
|
||||||
|
typedef K Kernel;
|
||||||
|
typedef typename K::Dimension Dimension;
|
||||||
|
typedef typename K::FT FT;
|
||||||
|
typedef typename K::Point_d Bare_point;
|
||||||
|
typedef typename K::Weighted_point_d Weighted_point;
|
||||||
|
typedef Weighted_point Weighted_point_d;
|
||||||
|
typedef Weighted_point Point_d;
|
||||||
|
|
||||||
|
typedef typename K::Construct_weighted_point_d Construct_weighted_point_d;
|
||||||
|
typedef typename K::Power_test_d Power_test_d;
|
||||||
|
typedef typename K::In_flat_power_test_d In_flat_power_test_d;
|
||||||
|
typedef typename K::Flat_orientation_d Flat_orientation_d;
|
||||||
|
typedef typename K::Point_drop_weight_d Point_drop_weight_d;
|
||||||
|
|
||||||
|
//=============================================================================
|
||||||
|
// Custom types
|
||||||
|
//=============================================================================
|
||||||
|
|
||||||
|
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)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
//=============================================================================
|
||||||
|
|
||||||
|
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)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
//=============================================================================
|
||||||
|
|
||||||
|
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)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
//=============================================================================
|
||||||
|
|
||||||
|
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_d & 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)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
//=============================================================================
|
||||||
|
|
||||||
|
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_d & p, const Weighted_point_d & 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));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
//=============================================================================
|
||||||
|
|
||||||
|
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_d & p, const int i) const
|
||||||
|
{
|
||||||
|
Point_drop_weight_d pdw = m_kernel.point_drop_weight_d_object();
|
||||||
|
m_kernel.compute_coordinate_d_object()(pdw(p), i);
|
||||||
|
return m_kernel.compute_coordinate_d_object()(pdw(p), i);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
//=============================================================================
|
||||||
|
|
||||||
|
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_d & 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
|
||||||
|
//=============================================================================
|
||||||
|
|
||||||
|
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
|
||||||
|
|
@ -227,6 +227,34 @@ public:
|
||||||
return tds().index_of_covertex(f);
|
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
|
// - - - - - - - - - - - - - - - - - - - - - - - - CREATION / CONSTRUCTORS
|
||||||
|
|
||||||
Triangulation(int dim, const Geom_traits k = Geom_traits())
|
Triangulation(int dim, const Geom_traits k = Geom_traits())
|
||||||
|
|
@ -696,7 +724,7 @@ public:
|
||||||
Full_cell_handle n = s->neighbor(i);
|
Full_cell_handle n = s->neighbor(i);
|
||||||
if( ! t_.is_infinite(n) )
|
if( ! t_.is_infinite(n) )
|
||||||
return false;
|
return false;
|
||||||
int inf_v_index = n->index(infinite_vertex());
|
int inf_v_index = n->index(t_.infinite_vertex());
|
||||||
n->vertex(inf_v_index)->set_point(p_);
|
n->vertex(inf_v_index)->set_point(p_);
|
||||||
bool ok = (POSITIVE == ori_(t_.points_begin(n), t_.points_begin(n) + cur_dim_ + 1));
|
bool ok = (POSITIVE == ori_(t_.points_begin(n), t_.points_begin(n) + cur_dim_ + 1));
|
||||||
return ok;
|
return ok;
|
||||||
|
|
@ -706,6 +734,28 @@ public:
|
||||||
// make sure all full_cells have positive orientation
|
// make sure all full_cells have positive orientation
|
||||||
void reorient_full_cells();
|
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) );
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
}; // Triangulation<...>
|
}; // Triangulation<...>
|
||||||
|
|
||||||
// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
|
// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
|
||||||
|
|
|
||||||
|
|
@ -417,7 +417,6 @@ private:
|
||||||
void clear_visited_marks(Full_cell_handle) const;
|
void clear_visited_marks(Full_cell_handle) const;
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - DANGEROUS UPDATE OPERATIONS
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - DANGEROUS UPDATE OPERATIONS
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - DANGEROUS UPDATE OPERATIONS
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|
@ -1523,6 +1522,8 @@ operator>>(std::istream & is, Triangulation_data_structure<Dimen, Vb, Fcb> & tr)
|
||||||
// - the neighbors of each full_cell by their index in the preceding list
|
// - the neighbors of each full_cell by their index in the preceding list
|
||||||
{
|
{
|
||||||
typedef Triangulation_data_structure<Dimen, Vb, Fcb> TDS;
|
typedef Triangulation_data_structure<Dimen, Vb, Fcb> TDS;
|
||||||
|
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;
|
typedef typename TDS::Vertex_handle Vertex_handle;
|
||||||
|
|
||||||
// read current dimension and number of vertices
|
// read current dimension and number of vertices
|
||||||
|
|
@ -1573,6 +1574,8 @@ operator<<(std::ostream & os, const Triangulation_data_structure<Dimen, Vb, Fcb>
|
||||||
// - the neighbors of each full_cell by their index in the preceding list
|
// - the neighbors of each full_cell by their index in the preceding list
|
||||||
{
|
{
|
||||||
typedef Triangulation_data_structure<Dimen, Vb, Fcb> TDS;
|
typedef Triangulation_data_structure<Dimen, Vb, Fcb> TDS;
|
||||||
|
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_handle Vertex_handle;
|
||||||
typedef typename TDS::Vertex_const_iterator Vertex_iterator;
|
typedef typename TDS::Vertex_const_iterator Vertex_iterator;
|
||||||
|
|
||||||
|
|
@ -1594,7 +1597,7 @@ operator<<(std::ostream & os, const Triangulation_data_structure<Dimen, Vb, Fcb>
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for( Vertex_iterator it = tr.vertices_begin(); it != tr.vertices_end(); ++it, ++i )
|
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;
|
index_of_vertex[it] = i;
|
||||||
}
|
}
|
||||||
CGAL_assertion( (std::size_t) i == n );
|
CGAL_assertion( (std::size_t) i == n );
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,6 @@ public:
|
||||||
/// Set 's' as an incident full_cell
|
/// Set 's' as an incident full_cell
|
||||||
void set_full_cell(Full_cell_handle s) /* Concept */
|
void set_full_cell(Full_cell_handle s) /* Concept */
|
||||||
{
|
{
|
||||||
CGAL_precondition( Full_cell_handle() != s );
|
|
||||||
full_cell_ = s;
|
full_cell_ = s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -98,7 +98,7 @@ public:
|
||||||
template< class T >
|
template< class T >
|
||||||
struct Compare_points_for_perturbation
|
struct Compare_points_for_perturbation
|
||||||
{
|
{
|
||||||
typedef typename T::Point_d Point;
|
typedef typename T::Geom_traits::Point_d Point;
|
||||||
|
|
||||||
const T & t_;
|
const T & t_;
|
||||||
|
|
||||||
|
|
@ -119,8 +119,8 @@ public:
|
||||||
template< class T >
|
template< class T >
|
||||||
struct Point_from_pointer
|
struct Point_from_pointer
|
||||||
{
|
{
|
||||||
typedef const typename T::Point_d * argument_type;
|
typedef const typename T::Geom_traits::Point_d * argument_type;
|
||||||
typedef const typename T::Point_d result_type;
|
typedef const typename T::Geom_traits::Point_d result_type;
|
||||||
result_type & operator()(argument_type & x) const
|
result_type & operator()(argument_type & x) const
|
||||||
{
|
{
|
||||||
return (*x);
|
return (*x);
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
# Created by the script cgal_create_cmake_script
|
# Created by the script cgal_create_cmake_script
|
||||||
# This is the CMake script for compiling a CGAL application.
|
# This is the CMake script for compiling a CGAL application.
|
||||||
|
|
||||||
|
|
||||||
project( Triangulation_test )
|
project( Triangulation_test )
|
||||||
|
|
||||||
cmake_minimum_required(VERSION 2.6.2)
|
cmake_minimum_required(VERSION 2.6.2)
|
||||||
|
|
@ -27,18 +26,18 @@ if ( CGAL_FOUND )
|
||||||
include_directories (BEFORE "../../include")
|
include_directories (BEFORE "../../include")
|
||||||
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_delaunay.cpp" )
|
||||||
|
create_single_source_cgal_program( "test_regular.cpp" )
|
||||||
create_single_source_cgal_program( "test_tds.cpp" )
|
create_single_source_cgal_program( "test_tds.cpp" )
|
||||||
create_single_source_cgal_program( "test_torture.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()
|
else()
|
||||||
message(STATUS "NOTICE: Some of the executables in this directory need Eigen 3.1 (or greater) and will not be compiled.")
|
message(STATUS "NOTICE: Some of the executables in this directory need Eigen 3.1 (or greater) and will not be compiled.")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
else()
|
else()
|
||||||
|
|
||||||
message(STATUS "This program requires the CGAL library, and will not be compiled.")
|
message(STATUS "This program requires the CGAL library, and will not be compiled.")
|
||||||
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,79 +24,80 @@ void test(const int d, const string & type, const int N)
|
||||||
|
|
||||||
typedef CGAL::Random_points_in_cube_d<Point> Random_points_iterator;
|
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";
|
cerr << "\nBuilding Delaunay triangulation of (" << type << d << ") dimension with " << N << " points";
|
||||||
assert(pc.empty());
|
assert(dt.empty());
|
||||||
|
|
||||||
vector<Point> points;
|
vector<Point> points;
|
||||||
CGAL::Random rng;
|
//CGAL::Random rng;
|
||||||
Random_points_iterator rand_it(d, 2.0, rng);
|
//Random_points_iterator rand_it(d, 2.0, rng);
|
||||||
//CGAL::cpp11::copy_n(rand_it, N, back_inserter(points));
|
//CGAL::cpp11::copy_n(rand_it, N, back_inserter(points));
|
||||||
|
|
||||||
vector<int> coords(d);
|
srand(10);
|
||||||
for( int i = 0; i < N; ++i )
|
for( int i = 0; i < N; ++i )
|
||||||
{
|
{
|
||||||
|
vector<double> coords(d);
|
||||||
for( int j = 0; j < d; ++j )
|
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()));
|
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...";
|
cerr << "\nChecking topology and geometry...";
|
||||||
assert( pc.is_valid() );
|
assert( dt.is_valid() );
|
||||||
|
|
||||||
cerr << "\nTraversing finite full_cells... ";
|
cerr << "\nTraversing finite full_cells... ";
|
||||||
size_t nbfs(0), nbis(0);
|
size_t nbfs(0), nbis(0);
|
||||||
Finite_full_cell_const_iterator fsit = pc.finite_full_cells_begin();
|
Finite_full_cell_const_iterator fsit = dt.finite_full_cells_begin();
|
||||||
while( fsit != pc.finite_full_cells_end() )
|
while( fsit != dt.finite_full_cells_end() )
|
||||||
++fsit, ++nbfs;
|
++fsit, ++nbfs;
|
||||||
cerr << nbfs << " + ";
|
cerr << nbfs << " + ";
|
||||||
vector<Full_cell_handle> infinite_full_cells;
|
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();
|
nbis = infinite_full_cells.size();
|
||||||
cerr << nbis << " = " << (nbis+nbfs)
|
cerr << nbis << " = " << (nbis+nbfs)
|
||||||
<< " = " << pc.number_of_full_cells();
|
<< " = " << dt.number_of_full_cells();
|
||||||
cerr << "\nThe triangulation has current dimension " << pc.current_dimension();
|
cerr << "\nThe triangulation has current dimension " << dt.current_dimension();
|
||||||
CGAL_assertion( pc.number_of_full_cells() == nbis+nbfs);
|
CGAL_assertion( dt.number_of_full_cells() == nbis+nbfs);
|
||||||
|
|
||||||
cerr << "\nTraversing finite vertices... ";
|
cerr << "\nTraversing finite vertices... ";
|
||||||
size_t nbfv(0);
|
size_t nbfv(0);
|
||||||
Finite_vertex_iterator fvit = pc.finite_vertices_begin();
|
Finite_vertex_iterator fvit = dt.finite_vertices_begin();
|
||||||
while( fvit != pc.finite_vertices_end() )
|
while( fvit != dt.finite_vertices_end() )
|
||||||
++fvit, ++nbfv;
|
++fvit, ++nbfv;
|
||||||
cerr << nbfv <<endl;
|
cerr << nbfv <<endl;
|
||||||
|
|
||||||
// Count convex hull vertices:
|
// Count convex hull vertices:
|
||||||
if( pc.maximal_dimension() > 1 )
|
if( dt.maximal_dimension() > 1 )
|
||||||
{
|
{
|
||||||
typedef vector<Face> Faces;
|
typedef vector<Face> Faces;
|
||||||
Faces edges;
|
Faces edges;
|
||||||
back_insert_iterator<Faces> out(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.";
|
cout << "\nThere are " << edges.size() << " vertices on the convex hull.";
|
||||||
edges.clear();
|
edges.clear();
|
||||||
}
|
}
|
||||||
else // pc.maximal_dimension() == 1
|
else // dt.maximal_dimension() == 1
|
||||||
{
|
{
|
||||||
typedef vector<Full_cell_handle> Cells;
|
typedef vector<Full_cell_handle> Cells;
|
||||||
Cells cells;
|
Cells cells;
|
||||||
back_insert_iterator<Cells> out(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.";
|
cout << "\nThere are " << cells.size() << " vertices on the convex hull.";
|
||||||
cells.clear();
|
cells.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove all !
|
// 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());
|
random_shuffle(points.begin(), points.end());
|
||||||
pc.remove(points.begin(), points.end());
|
dt.remove(points.begin(), points.end());
|
||||||
assert( pc.is_valid() );
|
assert( dt.is_valid() );
|
||||||
cerr << pc.number_of_vertices() << " vertices.";
|
cerr << dt.number_of_vertices() << " vertices.";
|
||||||
// assert( pc.empty() ); NOT YET !
|
// assert( dt.empty() ); NOT YET !
|
||||||
// CLEAR
|
// CLEAR
|
||||||
pc.clear();
|
dt.clear();
|
||||||
assert( -1 == pc.current_dimension() );
|
assert( -1 == dt.current_dimension() );
|
||||||
assert( pc.empty() );
|
assert( dt.empty() );
|
||||||
assert( pc.is_valid() );
|
assert( dt.is_valid() );
|
||||||
}
|
}
|
||||||
|
|
||||||
template< int D >
|
template< int D >
|
||||||
|
|
@ -112,14 +113,14 @@ void go(const int N)
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
srand(static_cast<unsigned int>(time(NULL)));
|
srand(static_cast<unsigned int>(time(NULL)));
|
||||||
int N = 100;
|
int N = 10;
|
||||||
if( argc > 1 )
|
if( argc > 1 )
|
||||||
N = atoi(argv[1]);
|
N = atoi(argv[1]);
|
||||||
go<5>(N);
|
//go<5>(N);
|
||||||
go<4>(N);
|
//go<4>(N);
|
||||||
go<3>(N);
|
//go<3>(N);
|
||||||
go<2>(N);
|
go<2>(N);
|
||||||
go<1>(N);
|
//go<1>(N);
|
||||||
|
|
||||||
cerr << endl;
|
cerr << endl;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,94 @@
|
||||||
|
#include <CGAL/Epick_d.h>
|
||||||
|
#include <CGAL/point_generators_d.h>
|
||||||
|
#include <CGAL/Regular_triangulation.h>
|
||||||
|
#include <CGAL/Regular_triangulation_euclidean_traits.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_euclidean_traits<FK> Traits;
|
||||||
|
typedef CGAL::Regular_triangulation<Traits> Triangulation;
|
||||||
|
//test<Triangulation>(D, "dynamic", N);
|
||||||
|
test<Triangulation>(D, "static", N);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
go<2>(100);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,132 @@
|
||||||
|
#include <CGAL/Epick_d.h>
|
||||||
|
#include <CGAL/point_generators_d.h>
|
||||||
|
#include <CGAL/Regular_triangulation.h>
|
||||||
|
#include <CGAL/Regular_triangulation_euclidean_traits.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;
|
||||||
|
//CGAL::Random rng;
|
||||||
|
//Random_points_iterator rand_it(d, 2.0, rng); // CJTODO: unused
|
||||||
|
|
||||||
|
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*/static_cast<double>(i)/20
|
||||||
|
));
|
||||||
|
}
|
||||||
|
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_euclidean_traits<FK> Traits;
|
||||||
|
typedef CGAL::Regular_triangulation<Traits> 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);
|
||||||
|
|
||||||
|
cerr << endl;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
@ -114,10 +114,10 @@ int main(int argc, char **argv)
|
||||||
int N = 1000;
|
int N = 1000;
|
||||||
if( argc > 1 )
|
if( argc > 1 )
|
||||||
N = atoi(argv[1]);
|
N = atoi(argv[1]);
|
||||||
go<5>(N);
|
//go<5>(N);
|
||||||
go<3>(N);
|
//go<3>(N);
|
||||||
go<2>(N);
|
go<2>(N);
|
||||||
go<1>(N);
|
//go<1>(N);
|
||||||
|
|
||||||
cerr << std::endl;
|
cerr << std::endl;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
@ -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;
|
||||||
|
}
|
||||||
|
|
@ -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
|
||||||
|
|
@ -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
|
||||||
|
|
@ -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
|
||||||
|
|
@ -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
|
||||||
|
|
@ -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;
|
||||||
|
}
|
||||||
|
|
@ -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
|
||||||
Loading…
Reference in New Issue