Improved Interpolation readability (no real changes)

-- Removed trailing whitespace
-- Fixed (some) includes
-- Fixed indentation
-- Fixed some remaining french
This commit is contained in:
Mael Rouxel-Labbé 2017-04-18 13:59:18 +02:00
parent 8842cc9f54
commit b39201ab5c
24 changed files with 886 additions and 955 deletions

View File

@ -1,4 +1,4 @@
// compares the result of several interpolation methods
// Compares the result of several interpolation methods
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
@ -53,11 +53,9 @@ int main()
Delaunay_triangulation T;
Point_value_map values;
Point_vector_map gradients;
//parameters for quadratic function:
Coord_type alpha = Coord_type(1.0),
beta1 = Coord_type(2.0),
@ -130,8 +128,7 @@ int main()
error = CGAL_NTS abs(res.first - exact_value);
f_total += error;
if (error > f_max) f_max = error;
}else ++failure;
} else ++failure;
//quadratic interpolant:
res = CGAL::quadratic_interpolation(coords.begin(), coords.end(),
@ -145,7 +142,7 @@ int main()
error = CGAL_NTS abs(res.first - exact_value);
q_total += error;
if (error > q_max) q_max = error;
}else ++failure;
} else ++failure;
//Sibson interpolant: version without sqrt:
res = CGAL::sibson_c1_interpolation_square(coords.begin(),

View File

@ -20,12 +20,14 @@ int main()
Coord_type a(0.25), bx(1.3), by(-0.7);
for (int y=0 ; y<3 ; y++)
for (int y=0 ; y<3 ; y++){
for (int x=0 ; x<3 ; x++){
K::Point_2 p(x,y);
T.insert(p);
function_values.insert(std::make_pair(p,a + bx* x+ by*y));
}
}
//coordinate computation
K::Point_2 p(1.3,0.34);
std::vector< std::pair< Point, Coord_type > > coords;
@ -37,7 +39,7 @@ int main()
norm,
Value_access(function_values));
std::cout << " Tested interpolation on " << p << " interpolation: "
std::cout << "Tested interpolation on " << p << " interpolation: "
<< res << " exact: " << a + bx* p.x()+ by* p.y()<< std::endl;
std::cout << "done" << std::endl;

View File

@ -4,8 +4,7 @@
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::Delaunay_triangulation_2<K> Delaunay_triangulation;
typedef std::vector< std::pair< K::Point_2, K::FT > >
Point_coordinate_vector;
typedef std::vector< std::pair< K::Point_2, K::FT > > Point_coordinate_vector;
int main()
{
@ -18,17 +17,17 @@ int main()
//coordinate computation
K::Point_2 p(1.2, 0.7);
Point_coordinate_vector coords;
CGAL::Triple<
std::back_insert_iterator<Point_coordinate_vector>,
CGAL::Triple<std::back_insert_iterator<Point_coordinate_vector>,
K::FT, bool> result =
CGAL::natural_neighbor_coordinates_2(dt, p,
std::back_inserter(coords));
CGAL::natural_neighbor_coordinates_2(dt, p, std::back_inserter(coords));
if(!result.third){
std::cout << "The coordinate computation was not successful."
<< std::endl;
std::cout << "The point (" <<p << ") lies outside the convex hull."
<< std::endl;
}
K::FT norm = result.second;
std::cout << "Coordinate computation successful." << std::endl;
std::cout << "Normalization factor: " <<norm << std::endl;

View File

@ -42,7 +42,7 @@ int main()
pp[2]=Point3(0,0,0); //outside data/points3 convex hull
std::cout << "P2 is outside the convex hull" << std::endl;
for(int ii=0;ii<3;ii++)
for(int ii=0; ii<3; ++ii)
{
std::vector< std::pair< Vertex_handle,NT> > coor_laplace;
std::vector< std::pair< Vertex_handle,NT> > coor_sibson;

View File

@ -9,8 +9,7 @@ typedef CGAL::Regular_triangulation_euclidean_traits_2<K> Gt;
typedef CGAL::Regular_triangulation_2<Gt> Regular_triangulation;
typedef Regular_triangulation::Bare_point Bare_point;
typedef Regular_triangulation::Weighted_point Weighted_point;
typedef std::vector< std::pair< Weighted_point, K::FT > >
Point_coordinate_vector;
typedef std::vector< std::pair< Weighted_point, K::FT > > Point_coordinate_vector;
int main()
{
@ -23,17 +22,17 @@ int main()
//coordinate computation
Weighted_point wp(Bare_point(1.2, 0.7),2);
Point_coordinate_vector coords;
CGAL::Triple<
std::back_insert_iterator<Point_coordinate_vector>,
CGAL::Triple<std::back_insert_iterator<Point_coordinate_vector>,
K::FT, bool> result =
CGAL::regular_neighbor_coordinates_2(rt, wp,
std::back_inserter(coords));
CGAL::regular_neighbor_coordinates_2(rt, wp, std::back_inserter(coords));
if(!result.third){
std::cout << "The coordinate computation was not successful."
<< std::endl;
std::cout << "The point (" <<wp.point() << ") lies outside the convex hull."
<< std::endl;
}
K::FT norm = result.second;
std::cout << "Coordinate computation successful." << std::endl;
std::cout << "Normalization factor: " <<norm << std::endl;

View File

@ -24,37 +24,37 @@ int main()
//parameters for spherical function:
Coord_type a(0.25), bx(1.3), by(-0.7), c(0.2);
for (int y=0 ; y<4 ; y++)
for (int y=0 ; y<4 ; y++){
for (int x=0 ; x<4 ; x++){
K::Point_2 p(x,y);
T.insert(p);
function_values.insert(std::make_pair(p,a + bx* x+ by*y + c*(x*x+y*y)));
}
}
sibson_gradient_fitting_nn_2(T,std::inserter(function_gradients,
function_gradients.begin()),
CGAL::Data_access<Point_value_map>
(function_values),
CGAL::Data_access<Point_value_map>(function_values),
Traits());
//coordiante computation
K::Point_2 p(1.6,1.4);
std::vector< std::pair< Point, Coord_type > > coords;
Coord_type norm =
CGAL::natural_neighbor_coordinates_2(T, p,std::back_inserter
Coord_type norm = CGAL::natural_neighbor_coordinates_2(T, p, std::back_inserter
(coords)).second;
//Sibson interpolant: version without sqrt:
std::pair<Coord_type, bool> res =
CGAL::sibson_c1_interpolation_square
(coords.begin(),
CGAL::sibson_c1_interpolation_square(
coords.begin(),
coords.end(),norm,p,
CGAL::Data_access<Point_value_map>(function_values),
CGAL::Data_access<Point_vector_map>(function_gradients),
Traits());
if(res.second)
std::cout << " Tested interpolation on " << p
std::cout << "Tested interpolation on " << p
<< " interpolation: " << res.first << " exact: "
<< a + bx * p.x()+ by * p.y()+ c*(p.x()*p.x()+p.y()*p.y())
<< std::endl;

View File

@ -8,31 +8,31 @@
#include <CGAL/surface_neighbor_coordinates_3.h>
#include <iostream>
#include <iterator>
#include <vector>
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef K::FT Coord_type;
typedef K::Point_3 Point_3;
typedef K::Vector_3 Vector_3;
typedef std::vector< std::pair< Point_3, K::FT > >
Point_coordinate_vector;
typedef std::vector< std::pair< Point_3, K::FT > > Point_coordinate_vector;
int main()
{
int n=100;
std::vector< Point_3> points;
points.reserve(n);
std::cout << "Generate " << n << " random points on a sphere."
<< std::endl;
std::cout << "Generate " << n << " random points on a sphere." << std::endl;
CGAL::Random_points_on_sphere_3<Point_3> g(1);
CGAL::cpp11::copy_n( g, n, std::back_inserter(points));
CGAL::cpp11::copy_n(g, n, std::back_inserter(points));
Point_3 p(1, 0,0);
Vector_3 normal(p-CGAL::ORIGIN);
std::cout << "Compute surface neighbor coordinates for "
<< p << std::endl;
Vector_3 normal(p - CGAL::ORIGIN);
std::cout << "Compute surface neighbor coordinates for " << p << std::endl;
Point_coordinate_vector coords;
CGAL::Triple< std::back_insert_iterator<Point_coordinate_vector>,
CGAL::Triple<std::back_insert_iterator<Point_coordinate_vector>,
K::FT, bool> result =
CGAL::surface_neighbor_coordinates_3(points.begin(), points.end(),
p, normal,
@ -40,21 +40,19 @@ int main()
K());
if(!result.third){
//Undersampling:
std::cout << "The coordinate computation was not successful."
<< std::endl;
std::cout << "The coordinate computation was not successful." << std::endl;
return 0;
}
K::FT norm = result.second;
std::cout << "Testing the barycentric property " << std::endl;
Point_3 b(0, 0,0);
Point_3 b(0, 0, 0);
for(std::vector< std::pair< Point_3, Coord_type > >::const_iterator
it = coords.begin(); it!=coords.end(); ++it)
b = b + (it->second/norm)* (it->first - CGAL::ORIGIN);
std::cout <<" weighted barycenter: " << b <<std::endl;
std::cout << " squared distance: " <<
CGAL::squared_distance(p,b) <<std::endl;
std::cout << " weighted barycenter: " << b <<std::endl;
std::cout << " squared distance: " << CGAL::squared_distance(p,b) << std::endl;
std::cout << "done" << std::endl;
return 0;

View File

@ -12,10 +12,6 @@
// 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) : Julia Floetotto
#ifndef CGAL_INTERPOLATION_GRADIENT_FITTING_TRAITS_2_H
@ -23,7 +19,6 @@
#include <CGAL/license/Interpolation.h>
#include <CGAL/aff_transformation_tags.h>
namespace CGAL {
@ -91,7 +86,8 @@ public:
Aff_transformation_2
operator()(const Vector_2& v) const
{
return Aff_transformation_2(v.x()*v.x(),v.x()*v.y(),v.x()*v.y(),
return Aff_transformation_2(v.x()*v.x(),
v.x()*v.y(), v.x()*v.y(),
v.y()*v.y());
}
};

View File

@ -12,10 +12,6 @@
// 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) : Julia Floetotto
#ifndef CGAL_INTERPOLATION_TRAITS_2_H
@ -23,7 +19,6 @@
#include <CGAL/license/Interpolation.h>
namespace CGAL {
//-----------------------------------------------------------------------//

View File

@ -1,4 +1,4 @@
// Copyright (c) 2003 INRIA Sophia-Antipolis (France).
// Copyright (c) 2003, 2017 INRIA Sophia-Antipolis (France).
// All rights reserved.
//
// This file is part of CGAL (www.cgal.org).
@ -19,7 +19,6 @@
#include <CGAL/license/Interpolation.h>
#include <CGAL/Origin.h>
#include <CGAL/tags.h>
#include <CGAL/number_utils_classes.h>
@ -116,7 +115,6 @@ private:
const Vector& normal;
};
template < typename K >
class Construct_plane_intersected_bisector_3
{
@ -142,7 +140,6 @@ private:
const Vector& normal;
};
template < typename K >
class Compare_first_projection_3
{

View File

@ -12,10 +12,6 @@
// 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) : Julia Floetotto
#ifndef CGAL_INTERPOLATION_FUNCTIONS_H
@ -23,24 +19,25 @@
#include <CGAL/license/Interpolation.h>
#include <utility>
#include <CGAL/double.h>
#include <CGAL/use.h>
#include <iterator>
#include <utility>
#include <vector>
namespace CGAL {
//Functor class for accessing the function values/gradients
template< class Map >
struct Data_access : public std::unary_function< typename Map::key_type,
struct Data_access
: public std::unary_function< typename Map::key_type,
std::pair< typename Map::mapped_type, bool> >
{
typedef typename Map::mapped_type Data_type;
typedef typename Map::key_type Key_type;
Data_access< Map >(const Map& m): map(m){};
Data_access< Map >(const Map& m): map(m){}
std::pair< Data_type, bool>
operator()(const Key_type& p) const {
@ -48,7 +45,7 @@ struct Data_access : public std::unary_function< typename Map::key_type,
if(mit!= map.end())
return std::make_pair(mit->second, true);
return std::make_pair(Data_type(), false);
};
}
const Map& map;
};
@ -59,7 +56,8 @@ typename Functor::result_type::first_type
linear_interpolation(ForwardIterator first, ForwardIterator beyond,
const typename
std::iterator_traits<ForwardIterator>::value_type::
second_type& norm, Functor function_value)
second_type& norm,
Functor function_value)
{
CGAL_precondition(norm>0);
typedef typename Functor::result_type::first_type Value_type;
@ -74,15 +72,16 @@ linear_interpolation(ForwardIterator first, ForwardIterator beyond,
}
template < class ForwardIterator, class Functor, class GradFunctor,
class Traits>
template < class ForwardIterator, class Functor, class GradFunctor, class Traits>
std::pair< typename Functor::result_type::first_type, bool>
quadratic_interpolation(ForwardIterator first, ForwardIterator beyond,
const typename
std::iterator_traits<ForwardIterator>::
value_type::second_type& norm, const typename
value_type::second_type& norm,
const typename
std::iterator_traits<ForwardIterator>::value_type::
first_type& p, Functor function_value,
first_type& p,
Functor function_value,
GradFunctor function_gradient,
const Traits& traits)
{
@ -107,14 +106,13 @@ quadratic_interpolation(ForwardIterator first, ForwardIterator beyond,
}
template < class ForwardIterator, class Functor, class GradFunctor,
class Traits>
template < class ForwardIterator, class Functor, class GradFunctor, class Traits>
std::pair< typename Functor::result_type::first_type, bool>
sibson_c1_interpolation(ForwardIterator first, ForwardIterator beyond,
const typename
std::iterator_traits<ForwardIterator>::
value_type::second_type&
norm, const typename
value_type::second_type& norm,
const typename
std::iterator_traits<ForwardIterator>::value_type::
first_type& p,
Functor function_value,
@ -151,7 +149,7 @@ sibson_c1_interpolation(ForwardIterator first, ForwardIterator beyond,
}
//three different terms to mix linear and gradient
//interpolation
term1 += coeff/dist;
term1 += coeff / dist;
term2 += coeff * squared_dist;
term3 += coeff * dist;
@ -182,11 +180,10 @@ sibson_c1_interpolation(ForwardIterator first, ForwardIterator beyond,
// (vh->get_value()+ vh->get_gradient()
// *(p - vh->point()));
template < class ForwardIterator, class Functor, class GradFunctor,
class Traits>
template < class ForwardIterator, class Functor, class GradFunctor, class Traits>
std::pair< typename Functor::result_type::first_type, bool>
sibson_c1_interpolation_square(ForwardIterator first, ForwardIterator
beyond, const typename
sibson_c1_interpolation_square(ForwardIterator first, ForwardIterator beyond,
const typename
std::iterator_traits<ForwardIterator>::
value_type::second_type& norm,
const typename
@ -205,7 +202,7 @@ sibson_c1_interpolation_square(ForwardIterator first, ForwardIterator
typename Functor::result_type f;
typename GradFunctor::result_type grad;
for(; first !=beyond; ++first){
for(; first!=beyond; ++first){
f = function_value(first->first);
grad = function_gradient(first->first);
CGAL_assertion(f.second);
@ -225,33 +222,33 @@ sibson_c1_interpolation_square(ForwardIterator first, ForwardIterator
}
//three different terms to mix linear and gradient
//interpolation
term1 += coeff/squared_dist;
term1 += coeff / squared_dist;
term2 += coeff * squared_dist;
term3 += coeff;
linear_int += coeff * f.first;
gradient_int += (coeff/squared_dist)
*(f.first + grad.first*
gradient_int += (coeff/squared_dist) * (f.first + grad.first *
traits.construct_vector_d_object()(first->first, p));
}
term4 = term3/ term1;
gradient_int = gradient_int / term1;
return std::make_pair((term4* linear_int + term2 * gradient_int)/
return std::make_pair((term4 * linear_int + term2 * gradient_int)/
(term4 + term2), true);
}
template < class RandomAccessIterator, class Functor, class
GradFunctor, class Traits>
GradFunctor, class Traits>
std::pair< typename Functor::result_type::first_type, bool>
farin_c1_interpolation(RandomAccessIterator first,
RandomAccessIterator beyond,
const typename
std::iterator_traits<RandomAccessIterator>::
value_type::second_type& norm, const typename
value_type::second_type& norm,
const typename
std::iterator_traits<RandomAccessIterator>::
value_type::first_type& /*p*/,
Functor function_value, GradFunctor

View File

@ -12,10 +12,6 @@
// 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) : Frank Da, Julia Floetotto
#ifndef CGAL_NATURAL_NEIGHBOR_COORDINATES_2_H
@ -23,13 +19,14 @@
#include <CGAL/license/Interpolation.h>
#include <utility>
#include <CGAL/Iterator_project.h>
#include <CGAL/Polygon_2.h>
#include <CGAL/number_utils_classes.h>
#include <CGAL/utility.h>
#include <list>
#include <utility>
namespace CGAL {
// the struct "Project_vertex_output_iterator"
@ -79,25 +76,23 @@ struct Project_vertex_output_iterator
// OutputIterator out, const Traits& traits,
// typename Dt::Face_handle start
// = typename Dt::Face_handle())
//
//template <class Dt, class OutputIterator, class Traits>
//Triple< OutputIterator, typename Traits::FT, bool >
//natural_neighbor_coordinates_2(const Dt& dt,
// typename Dt::Vertex_handle vh,
// OutputIterator out, const Traits& traits)
//the following two functions suppose that
// OutputIterator has value type
// std::pair<Dt::Vertex_handle, Dt::Geom_traits::FT>
//!!!they are not documented!!!
template <class Dt, class OutputIterator>
template < class Dt, class OutputIterator >
Triple< OutputIterator, typename Dt::Geom_traits::FT, bool >
natural_neighbor_coordinates_vertex_2(const Dt& dt,
const typename Dt::Geom_traits::Point_2& p,
OutputIterator out, typename Dt::Face_handle start
= typename Dt::Face_handle())
{
typedef typename Dt::Geom_traits Traits;
typedef typename Traits::FT Coord_type;
@ -114,37 +109,33 @@ natural_neighbor_coordinates_vertex_2(const Dt& dt,
int li;
Face_handle fh = dt.locate(p, lt, li, start);
if (lt == Dt::OUTSIDE_AFFINE_HULL
|| lt == Dt::OUTSIDE_CONVEX_HULL)
if (lt == Dt::OUTSIDE_AFFINE_HULL || lt == Dt::OUTSIDE_CONVEX_HULL)
{
return make_triple(out, Coord_type(1), false);
}
if ((lt == Dt::EDGE &&
(dt.is_infinite(fh) ||
dt.is_infinite(fh->neighbor(li)))))
(dt.is_infinite(fh) || dt.is_infinite(fh->neighbor(li)))))
{
Vertex_handle v1 = fh->vertex(dt.cw(li));
Vertex_handle v2 = fh->vertex(dt.ccw(li));
Point_2 p1(v1->point()),p2(v2->point());
Point_2 p1(v1->point()), p2(v2->point());
Coord_type coef1(0);
Coord_type coef2(0);
Equal_x_2 equal_x_2;
if(!equal_x_2(p1,p2))
{
coef1 = (p.x() - p2.x())/(p1.x() - p2.x()) ;
coef1 = (p.x() - p2.x()) / (p1.x() - p2.x());
coef2 = 1 - coef1;
*out++ = std::make_pair(v1,coef1);
*out++ = std::make_pair(v2,coef2);
} else {
coef1 = (p.y() - p2.y()) / (p1.y() - p2.y());
coef2 = 1-coef1;
*out++= std::make_pair(v1,coef1);
*out++= std::make_pair(v2,coef2);
}else{
coef1 = (p.y() - p2.y())/(p1.y() - p2.y()) ;
coef2 = 1-coef1;
*out++= std::make_pair(v1,coef1);
*out++= std::make_pair(v2,coef2);
*out++ = std::make_pair(v1,coef1);
*out++ = std::make_pair(v2,coef2);
}
return make_triple(out, coef1+coef2, true);
@ -157,7 +148,6 @@ natural_neighbor_coordinates_vertex_2(const Dt& dt,
}
std::list<Edge> hole;
dt.get_boundary_of_conflicts(p, std::back_inserter(hole), fh, false);
return natural_neighbor_coordinates_vertex_2
@ -167,7 +157,7 @@ natural_neighbor_coordinates_vertex_2(const Dt& dt,
//function call if the conflict zone is known:
// OutputIterator has value type
// std::pair<Dt::Vertex_handle, Dt::Geom_traits::FT>
template <class Dt, class OutputIterator, class EdgeIterator >
template < class Dt, class OutputIterator, class EdgeIterator >
Triple< OutputIterator, typename Dt::Geom_traits::FT, bool >
natural_neighbor_coordinates_vertex_2(const Dt& dt,
const typename Dt::Geom_traits::Point_2& p,
@ -184,7 +174,6 @@ natural_neighbor_coordinates_vertex_2(const Dt& dt,
typedef typename Dt::Vertex_handle Vertex_handle;
typedef typename Dt::Face_circulator Face_circulator;
std::vector<Point_2> vor(3);
Coord_type area_sum(0);
@ -200,8 +189,8 @@ natural_neighbor_coordinates_vertex_2(const Dt& dt,
Coord_type area(0);
Vertex_handle current = hit->first->vertex(dt.cw(hit->second));
vor[0] = dt.geom_traits().construct_circumcenter_2_object()
(current->point(),
vor[0] = dt.geom_traits().construct_circumcenter_2_object()(
current->point(),
hit->first->vertex(dt.ccw(hit->second))->point(),
p);
@ -213,23 +202,20 @@ natural_neighbor_coordinates_vertex_2(const Dt& dt,
{
++fc;
vor[2] = dt.dual(fc);
area += polygon_area_2(vor.begin(), vor.end(), dt.geom_traits());
vor[1] = vor[2];
};
vor[2] =
dt.geom_traits().construct_circumcenter_2_object()(prev->point(),
current->point(),p);
}
vor[2] = dt.geom_traits().construct_circumcenter_2_object()(prev->point(),
current->point(),
p);
area += polygon_area_2(vor.begin(), vor.end(), dt.geom_traits());
*out++= std::make_pair(current,area);
*out++ = std::make_pair(current,area);
area_sum += area;
//update prev and hit:
prev= current;
prev = current;
++hit;
}
return make_triple(out, area_sum, true);
@ -242,7 +228,7 @@ natural_neighbor_coordinates_vertex_2(const Dt& dt,
//=> OutputIterator has value type
// std::pair< Dt::Geom_traits::Point_2, Dt::Geom_traits::FT>
/////////////////////////////////////////////////////////////
template <class Dt, class OutputIterator>
template < class Dt, class OutputIterator >
Triple< OutputIterator, typename Dt::Geom_traits::FT, bool >
natural_neighbor_coordinates_2(const Dt& dt,
const typename Dt::Geom_traits::Point_2& p,
@ -255,10 +241,9 @@ natural_neighbor_coordinates_2(const Dt& dt,
Project_vertex_output_iterator<OutputIterator> op(out);
Triple< Project_vertex_output_iterator<OutputIterator>,
Triple<Project_vertex_output_iterator<OutputIterator>,
typename Dt::Geom_traits::FT, bool > result =
natural_neighbor_coordinates_vertex_2
(dt, p, op, start);
natural_neighbor_coordinates_vertex_2(dt, p, op, start);
return make_triple(result.first.base(), result.second, result.third);
}
@ -266,7 +251,7 @@ natural_neighbor_coordinates_2(const Dt& dt,
//OutputIterator has value type
// std::pair< Dt::Geom_traits::Point_2, Dt::Geom_traits::FT>
//function call if the conflict zone is known:
template <class Dt, class OutputIterator, class EdgeIterator >
template < class Dt, class OutputIterator, class EdgeIterator >
Triple< OutputIterator, typename Dt::Geom_traits::FT, bool >
natural_neighbor_coordinates_2(const Dt& dt,
const typename Dt::Geom_traits::Point_2& p,
@ -277,10 +262,9 @@ natural_neighbor_coordinates_2(const Dt& dt,
Project_vertex_output_iterator<OutputIterator> op(out);
Triple< Project_vertex_output_iterator<OutputIterator>,
Triple<Project_vertex_output_iterator<OutputIterator>,
typename Dt::Geom_traits::FT, bool > result =
natural_neighbor_coordinates_vertex_2
(dt, p, op, hole_begin,hole_end);
natural_neighbor_coordinates_vertex_2(dt, p, op, hole_begin,hole_end);
return make_triple(result.first.base(), result.second, result.third);
}
@ -312,12 +296,12 @@ natural_neighbor_coordinates_2(const Dt& dt,
}
while(++vc!=done);
return natural_neighbor_coordinates_2(t2, vh->point(), out);
}
}
//class providing a function object:
//OutputIterator has value type
// std::pair< Dt::Geom_traits::Point_2, Dt::Geom_traits::FT>
template <class Dt, class OutputIterator>
template < class Dt, class OutputIterator >
class natural_neighbor_coordinates_2_object
{
public:

View File

@ -23,16 +23,18 @@
#include <CGAL/license/Interpolation.h>
#include <set>
#include <vector>
#include <CGAL/tags.h>
#include <CGAL/iterator.h>
#include <CGAL/utility.h>
#include <CGAL/triangulation_assertions.h>
#include <CGAL/number_utils.h>
#include <algorithm>
#include <iostream> //TO DO : to remove
#include <map>
#include <set>
#include <utility>
#include <vector>
namespace CGAL {
@ -73,7 +75,8 @@ Triple< OutputIterator, // iterator with value type std::pair<Dt::Vertex_handle
bool >
laplace_natural_neighbor_coordinates_3(const Dt& dt,
const typename Dt::Geom_traits::Point_3& Q,
OutputIterator nn_out, typename Dt::Geom_traits::FT & norm_coeff,
OutputIterator nn_out,
typename Dt::Geom_traits::FT& norm_coeff,
const typename Dt::Cell_handle start = CGAL_TYPENAME_DEFAULT_ARG Dt::Cell_handle())
{
typedef typename Dt::Geom_traits Gt;
@ -84,19 +87,22 @@ laplace_natural_neighbor_coordinates_3(const Dt& dt,
typedef typename Dt::Locate_type Locate_type;
typedef typename Gt::FT Coord_type;
CGAL_triangulation_precondition (dt.dimension()== 3);
Locate_type lt; int li, lj;
CGAL_triangulation_precondition (dt.dimension() == 3);
Locate_type lt;
int li, lj;
Cell_handle c = dt.locate( Q, lt, li, lj, start);
if ( lt == Dt::VERTEX )
{
*nn_out++= std::make_pair(c->vertex(li),Coord_type(1));
return make_triple(nn_out,norm_coeff=Coord_type(1),true);
*nn_out++= std::make_pair(c->vertex(li), Coord_type(1));
return make_triple(nn_out, norm_coeff = Coord_type(1),true);
}
else if (dt.is_infinite(c))
return make_triple(nn_out, Coord_type(1), false);//point outside the convex-hull
{
//point outside the convex-hull
return make_triple(nn_out, Coord_type(1), false);
}
std::set<Cell_handle> cells;
// To replace the forbidden access to the "in conflict" flag :
@ -169,7 +175,8 @@ Triple< OutputIterator, // iterator with value type std::pair<Dt::Vertex_handle
bool >
sibson_natural_neighbor_coordinates_3(const Dt& dt,
const typename Dt::Geom_traits::Point_3& Q,
OutputIterator nn_out, typename Dt::Geom_traits::FT & norm_coeff,
OutputIterator nn_out,
typename Dt::Geom_traits::FT& norm_coeff,
const typename Dt::Cell_handle start = CGAL_TYPENAME_DEFAULT_ARG Dt::Cell_handle())
{
typedef typename Dt::Geom_traits Gt;
@ -182,17 +189,20 @@ sibson_natural_neighbor_coordinates_3(const Dt& dt,
CGAL_triangulation_precondition (dt.dimension()== 3);
Locate_type lt; int li, lj;
Locate_type lt;
int li, lj;
Cell_handle c = dt.locate( Q, lt, li, lj, start);
if ( lt == Dt::VERTEX )
{
*nn_out++= std::make_pair(c->vertex(li),Coord_type(1));
*nn_out++ = std::make_pair(c->vertex(li),Coord_type(1));
return make_triple(nn_out,norm_coeff=Coord_type(1),true);
}
else if (dt.is_infinite(c))
return make_triple(nn_out, Coord_type(1), false);//point outside the convex-hull
{
//point outside the convex-hull
return make_triple(nn_out, Coord_type(1), false);
}
std::set<Cell_handle> cells;
typename std::set<Cell_handle>::iterator cit;
@ -299,9 +309,9 @@ sibson_natural_neighbor_coordinates_3(const Dt& dt,
template <typename Dt, typename InputIterator>
bool is_correct_natural_neighborhood(const Dt& /*dt*/,
const typename Dt::Geom_traits::Point_3 & Q,
const typename Dt::Geom_traits::Point_3& Q,
InputIterator it_begin, InputIterator it_end,
const typename Dt::Geom_traits::FT & norm_coeff)
const typename Dt::Geom_traits::FT& norm_coeff)
{
typedef typename Dt::Geom_traits Gt;
typedef typename Gt::FT Coord_type;
@ -320,8 +330,8 @@ bool is_correct_natural_neighborhood(const Dt& /*dt*/,
std::cout << sum_x/norm_coeff << " "
<< sum_y/norm_coeff << " "
<< sum_z/norm_coeff << std::endl;
return ((sum_x==norm_coeff*Q.x())&&(sum_y==norm_coeff*Q.y())
&&(sum_z==norm_coeff*Q.z()));
return ((sum_x == norm_coeff*Q.x()) && (sum_y == norm_coeff*Q.y())
&& (sum_z == norm_coeff*Q.z()));
}
// ====================== Geometric Traits utilities =========================================

View File

@ -12,10 +12,6 @@
// 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) : Julia Floetotto
#ifndef CGAL_REGULAR_NEIGHBOR_COORDINATES_2_H
@ -23,23 +19,22 @@
#include <CGAL/license/Interpolation.h>
#include <utility>
#include <CGAL/Polygon_2.h>
#include <CGAL/iterator.h>
//for definition of class Project_vertex_output_iterator
#include <CGAL/natural_neighbor_coordinates_2.h>
#include <list>
#include <utility>
#include <vector>
namespace CGAL {
// in this functions, the traits class is defined via the regular
// triangulation
// see natural_neighbor_coordinates_2 for a proposal for signatures
// that allow to pass the traits class as argument
// In these functions, the traits class is defined via the regular triangulation.
// See natural_neighbor_coordinates_2 for a proposal for signatures
// that allow to pass the traits class as argument.
//the following two functions suppose that
// The following two functions assume that
// OutputIterator has value type
// std::pair<Rt::Vertex_handle, Rt::Geom_traits::FT>
//!!!they are not documented!!!
@ -56,7 +51,7 @@ regular_neighbor_coordinates_vertex_2(const Rt& rt,
typename Rt::Face_handle());
}
//Face_handle start is known:
// Face_handle start is known:
// OutputIterator has value type
// std::pair<Rt::Vertex_handle, Rt::Geom_traits::FT>
template <class Rt, class OutputIterator>
@ -70,7 +65,7 @@ regular_neighbor_coordinates_vertex_2(const Rt& rt,
Emptyset_iterator(), start);
}
//the Voronoi vertices of the power cell are known:
// The Voronoi vertices of the power cell are known:
// OutputIterator has value type
// std::pair<Rt::Vertex_handle, Rt::Geom_traits::FT>
template <class Rt, class OutputIterator, class OutputIteratorVorVertices>
@ -81,9 +76,8 @@ regular_neighbor_coordinates_vertex_2(const Rt& rt,
OutputIteratorVorVertices vor_vertices,
typename Rt::Face_handle start)
{
//out: the result of the coordinate computation
//vor_vertices: the vertices of the power cell (to avoid
// recomputation)
// out: the result of the coordinate computation
// vor_vertices: the vertices of the power cell (to avoid recomputation)
typedef typename Rt::Geom_traits Traits;
typedef typename Traits::FT Coord_type;
@ -98,19 +92,16 @@ regular_neighbor_coordinates_vertex_2(const Rt& rt,
int li;
Face_handle fh = rt.locate(p, lt, li, start);
//the point must lie inside the convex hull
// sinon return false:
if(lt == Rt::OUTSIDE_AFFINE_HULL || lt ==
Rt::OUTSIDE_CONVEX_HULL
|| (lt == Rt::EDGE && (rt.is_infinite(fh)
|| rt.is_infinite(fh->neighbor(li)))))
// the point must lie inside the convex hull otherwisereturn false:
if(lt == Rt::OUTSIDE_AFFINE_HULL || lt == Rt::OUTSIDE_CONVEX_HULL
|| (lt == Rt::EDGE
&& (rt.is_infinite(fh) || rt.is_infinite(fh->neighbor(li)))))
return make_triple(out, Coord_type(1), false);
if (lt == Rt::VERTEX)
{
//the point must be in conflict:
CGAL_precondition(rt.power_test(fh->vertex(li)->point(), p) !=
ON_NEGATIVE_SIDE);
CGAL_precondition(rt.power_test(fh->vertex(li)->point(), p) != ON_NEGATIVE_SIDE);
if (rt.power_test(fh->vertex(li)->point(), p) ==ON_ORIENTED_BOUNDARY)
{
*out++= std::make_pair(fh->vertex(li),Coord_type(1));
@ -119,16 +110,17 @@ regular_neighbor_coordinates_vertex_2(const Rt& rt,
}
std::list<Edge> hole;
std::list< Vertex_handle > hidden_vertices;
std::list<Vertex_handle> hidden_vertices;
rt.get_boundary_of_conflicts_and_hidden_vertices(p,
std::back_inserter(hole),
std::back_inserter
(hidden_vertices),
fh);
return regular_neighbor_coordinates_vertex_2
(rt, p, out, vor_vertices, hole.begin(),hole.end(),
hidden_vertices.begin(), hidden_vertices.end());
return regular_neighbor_coordinates_vertex_2(rt, p, out, vor_vertices,
hole.begin(),hole.end(),
hidden_vertices.begin(),
hidden_vertices.end());
}
@ -139,19 +131,17 @@ template <class Rt, class OutputIterator, class EdgeIterator,
Triple< OutputIterator, typename Rt::Geom_traits::FT, bool >
regular_neighbor_coordinates_vertex_2(const Rt& rt,
const typename Rt::Weighted_point& p,
OutputIterator out, EdgeIterator
hole_begin, EdgeIterator hole_end,
OutputIterator out,
EdgeIterator hole_begin, EdgeIterator hole_end,
VertexIterator hidden_vertices_begin,
VertexIterator hidden_vertices_end)
{
return regular_neighbor_coordinates_vertex_2(rt, p,
out,Emptyset_iterator(),
return regular_neighbor_coordinates_vertex_2(rt, p, out, Emptyset_iterator(),
hole_begin, hole_end,
hidden_vertices_begin,
hidden_vertices_end);
}
// OutputIterator has value type
// std::pair<Rt::Vertex_handle, Rt::Geom_traits::FT>
template <class Rt, class OutputIterator, class EdgeIterator,
@ -161,8 +151,7 @@ regular_neighbor_coordinates_vertex_2(const Rt& rt,
const typename Rt::Weighted_point& p,
OutputIterator out,
OutputIteratorVorVertices vor_vertices,
EdgeIterator
hole_begin, EdgeIterator hole_end,
EdgeIterator hole_begin, EdgeIterator hole_end,
VertexIterator hidden_vertices_begin,
VertexIterator hidden_vertices_end)
{
@ -282,8 +271,7 @@ regular_neighbor_coordinates_2(const Rt& rt,
const typename Rt::Weighted_point& p,
OutputIterator out)
{
return regular_neighbor_coordinates_2(rt, p, out,
typename Rt::Face_handle());
return regular_neighbor_coordinates_2(rt, p, out, typename Rt::Face_handle());
}
//OutputIterator has value type
@ -296,8 +284,7 @@ regular_neighbor_coordinates_2(const Rt& rt,
OutputIterator out,
typename Rt::Face_handle start)
{
return regular_neighbor_coordinates_2(rt, p, out,
Emptyset_iterator(), start);
return regular_neighbor_coordinates_2(rt, p, out, Emptyset_iterator(), start);
}
//OutputIterator has value type
@ -320,12 +307,11 @@ regular_neighbor_coordinates_2(const Rt& rt,
Triple< Project_vertex_output_iterator<OutputIterator>,
typename Rt::Geom_traits::FT, bool > result =
regular_neighbor_coordinates_vertex_2
(rt, p, op , vor_vertices, start);
regular_neighbor_coordinates_vertex_2(rt, p, op, vor_vertices, start);
return make_triple(result.first.base(), result.second, result.third);
}
//OutputIterator has value type
// std::pair< Rt::Geom_traits::Point_2, Rt::Geom_traits::FT>
template <class Rt, class OutputIterator, class EdgeIterator,
@ -338,14 +324,12 @@ regular_neighbor_coordinates_2(const Rt& rt,
VertexIterator hidden_vertices_begin,
VertexIterator hidden_vertices_end)
{
return regular_neighbor_coordinates_2(rt, p,
out,Emptyset_iterator(),
return regular_neighbor_coordinates_2(rt, p, out, Emptyset_iterator(),
hole_begin, hole_end,
hidden_vertices_begin,
hidden_vertices_end);
}
//OutputIterator has value type
// std::pair< Rt::Geom_traits::Point_2, Rt::Geom_traits::FT>
template <class Rt, class OutputIterator, class EdgeIterator,
@ -368,9 +352,10 @@ regular_neighbor_coordinates_2(const Rt& rt,
Triple< Project_vertex_output_iterator<OutputIterator>,
typename Rt::Geom_traits::FT, bool > result =
regular_neighbor_coordinates_vertex_2
(rt, p, op , vor_vertices, hole_begin,hole_end,
hidden_vertices_begin, hidden_vertices_end);
regular_neighbor_coordinates_vertex_2(rt, p, op , vor_vertices,
hole_begin, hole_end,
hidden_vertices_begin,
hidden_vertices_end);
return make_triple(result.first.base(), result.second, result.third);
}
@ -393,8 +378,7 @@ regular_neighbor_coordinates_2(const Rt& rt,
CGAL_precondition(rt.dimension() == 2);
Rt t2;
Vertex_circulator vc = rt.incident_vertices(vh),
done(vc);
Vertex_circulator vc = rt.incident_vertices(vh), done(vc);
do{
CGAL_assertion(!rt.is_infinite(vc));
t2.insert(vc->point());
@ -404,7 +388,6 @@ regular_neighbor_coordinates_2(const Rt& rt,
return regular_neighbor_coordinates_2(t2, vh->point(), out);
}
//class providing a function object:
//OutputIterator has value type
// std::pair< Rt::Geom_traits::Point_2, Rt::Geom_traits::FT>

View File

@ -23,12 +23,13 @@
#include <CGAL/license/Interpolation.h>
#include <utility>
#include <CGAL/Origin.h>
#include <CGAL/natural_neighbor_coordinates_2.h>
#include <CGAL/regular_neighbor_coordinates_2.h>
#include <iterator>
#include <utility>
namespace CGAL {
template < class ForwardIterator, class Functor, class Traits>
@ -36,10 +37,11 @@ typename Traits::Vector_d
sibson_gradient_fitting(ForwardIterator first, ForwardIterator beyond,
const typename
std::iterator_traits<ForwardIterator>::
value_type::second_type&
norm, const typename
value_type::second_type& norm,
const typename
std::iterator_traits<ForwardIterator>::value_type
::first_type& p, Functor function_value,
::first_type& p,
Functor function_value,
const Traits& traits)
{
CGAL_precondition( first!=beyond && norm!=0);
@ -58,8 +60,8 @@ sibson_gradient_fitting(ForwardIterator first, ForwardIterator beyond,
Coord_type square_dist = traits.compute_squared_distance_d_object()
(first->first, p);
CGAL_assertion(square_dist != 0);
Coord_type scale = first->second/(norm*square_dist);
typename Traits::Vector_d d=
Coord_type scale = first->second / (norm*square_dist);
typename Traits::Vector_d d =
traits.construct_vector_d_object()(p, first->first);
//compute the vector pn:
@ -93,11 +95,9 @@ sibson_gradient_fitting(const Triangul& tr,
std::vector< std::pair< Point, Coord_type > > coords;
Coord_type norm;
typename Triangul::Finite_vertices_iterator
vit = tr.finite_vertices_begin();
typename Triangul::Finite_vertices_iterator vit = tr.finite_vertices_begin();
for(; vit != tr.finite_vertices_end(); ++vit){
//test if vit is a convex hull vertex:
//otherwise do nothing
//test if vit is a convex hull vertex, otherwise do nothing
if (!tr.is_edge(vit, tr.infinite_vertex()))
{
norm = compute_coordinates(tr, vit, std::back_inserter(coords)).second;
@ -108,7 +108,6 @@ sibson_gradient_fitting(const Triangul& tr,
function_value,
traits));
coords.clear();
}
}
return out;
@ -126,12 +125,14 @@ sibson_gradient_fitting_nn_2(const Dt& dt,
Functor function_value,
const Traits& traits)
{
typedef typename std::back_insert_iterator< std::vector< std::pair<
typename Traits::Point_d,typename Traits::FT > > > CoordInserter;
typedef typename std::back_insert_iterator<
std::vector<
std::pair< typename Traits::Point_d,
typename Traits::FT > > > CoordInserter;
return sibson_gradient_fitting
(dt, out, function_value,
natural_neighbor_coordinates_2_object< Dt, CoordInserter >(),
return sibson_gradient_fitting(dt, out, function_value,
natural_neighbor_coordinates_2_object< Dt,
CoordInserter >(),
traits);
}
@ -142,12 +143,14 @@ sibson_gradient_fitting_rn_2(const Rt& rt,
Functor function_value,
const Traits& traits)
{
typedef typename std::back_insert_iterator< std::vector< std::pair<
typename Traits::Point_d,typename Traits::FT > > > CoordInserter;
typedef typename std::back_insert_iterator<
std::vector<
std::pair< typename Traits::Point_d,
typename Traits::FT > > > CoordInserter;
return sibson_gradient_fitting
(rt, out, function_value,
regular_neighbor_coordinates_2_object< Rt, CoordInserter >(),
return sibson_gradient_fitting(rt, out, function_value,
regular_neighbor_coordinates_2_object< Rt,
CoordInserter >(),
traits);
}

View File

@ -12,10 +12,6 @@
// 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) : Julia Floetotto
// ATTENTION : the surface is supposed to be a closed surface
@ -25,40 +21,43 @@
#include <CGAL/license/Interpolation.h>
#include <utility>
#include <CGAL/Iterator_project.h>
#include <CGAL/Voronoi_intersection_2_traits_3.h>
#include <CGAL/Regular_triangulation_2.h>
#include <CGAL/regular_neighbor_coordinates_2.h>
#include <algorithm>
#include <functional>
#include <iterator>
#include <list>
#include <utility>
#include <vector>
namespace CGAL {
template <class OutputIterator, class InputIterator, class Kernel>
inline
Triple< OutputIterator, typename Kernel::FT, bool >
surface_neighbor_coordinates_3(InputIterator
first, InputIterator beyond,
surface_neighbor_coordinates_3(InputIterator first, InputIterator beyond,
const typename Kernel::Point_3& p,
const typename Kernel::Vector_3& normal,
OutputIterator out,
const Kernel&)
{
typedef Voronoi_intersection_2_traits_3<Kernel> I_gt;
return surface_neighbor_coordinates_3(first, beyond, p, out, I_gt(p,normal));
return surface_neighbor_coordinates_3(first, beyond, p, out, I_gt(p, normal));
}
template <class OutputIterator, class InputIterator, class ITraits>
Triple< OutputIterator, typename ITraits::FT, bool >
surface_neighbor_coordinates_3(InputIterator
first, InputIterator beyond,
surface_neighbor_coordinates_3(InputIterator first, InputIterator beyond,
const typename ITraits::Point_2& p,
OutputIterator out,
const ITraits& traits)
{
//definition of the Voronoi intersection triangulation:
typedef Regular_triangulation_2< ITraits> I_triangulation;
typedef Regular_triangulation_2<ITraits> I_triangulation;
//build Voronoi intersection triangulation:
I_triangulation it(traits);
@ -106,8 +105,8 @@ surface_neighbor_coordinates_certified_3(InputIterator
const Kernel& )
{
typedef Voronoi_intersection_2_traits_3<Kernel> I_gt;
return surface_neighbor_coordinates_certified_3
(first, beyond, p, out, I_gt(p,normal));
return surface_neighbor_coordinates_certified_3(first, beyond, p, out,
I_gt(p,normal));
}
//this function takes the radius of the sphere centered on p
@ -116,29 +115,28 @@ surface_neighbor_coordinates_certified_3(InputIterator
template <class OutputIterator, class InputIterator, class Kernel>
inline
Quadruple< OutputIterator, typename Kernel::FT, bool, bool >
surface_neighbor_coordinates_certified_3(
InputIterator first, InputIterator beyond,
surface_neighbor_coordinates_certified_3(InputIterator first, InputIterator beyond,
const typename Kernel::Point_3& p,
const typename Kernel::Vector_3& normal,
const typename Kernel::FT& radius,
OutputIterator out, const Kernel& )
{
typedef Voronoi_intersection_2_traits_3<Kernel> I_gt;
return surface_neighbor_coordinates_certified_3
(first, beyond, p, radius, out, I_gt(p,normal));
return surface_neighbor_coordinates_certified_3(first, beyond, p, radius, out,
I_gt(p,normal));
}
// FIXME : this should probably be replaced by some kernel functor.
//struct necessary to sort the points by distance to p:
//also used in surface_neighbors_3.h
template <class Traits >
template <class Traits>
struct closer_to_point
: public std::less<typename Traits::Point_2>
{
typedef typename Traits::Point_2 Point_2;
closer_to_point(const Point_2& _p, const Traits& t)
: p(_p), traits(t) {}
: p(_p), traits(t) { }
bool operator()(const Point_2& q, const Point_2& r) const
{
@ -153,8 +151,8 @@ private:
// Versions with instantiated traits class:
template <class OutputIterator, class InputIterator, class ITraits>
Quadruple< OutputIterator, typename ITraits::FT, bool, bool >
surface_neighbor_coordinates_certified_3(InputIterator
first, InputIterator beyond,
surface_neighbor_coordinates_certified_3(InputIterator first,
InputIterator beyond,
const typename ITraits::Point_2& p,
OutputIterator out,
const ITraits& traits)
@ -163,8 +161,7 @@ surface_neighbor_coordinates_certified_3(InputIterator
InputIterator furthest = std::max_element(first, beyond,
closer_to_point<ITraits>(p, traits));
return surface_neighbor_coordinates_certified_3
(first, beyond, p,
return surface_neighbor_coordinates_certified_3(first, beyond, p,
traits.compute_squared_distance_2_object()(p,*furthest),
out, traits);
}
@ -173,12 +170,10 @@ surface_neighbor_coordinates_certified_3(InputIterator
// add. parameter:
template <class OutputIterator, class InputIterator, class ITraits>
Quadruple< OutputIterator, typename ITraits::FT, bool, bool >
surface_neighbor_coordinates_certified_3(InputIterator
first, InputIterator beyond,
const typename
ITraits::Point_2& p,
const typename ITraits::FT&
radius,
surface_neighbor_coordinates_certified_3(InputIterator first,
InputIterator beyond,
const typename ITraits::Point_2& p,
const typename ITraits::FT& radius,
OutputIterator out,
const ITraits& traits)
{
@ -265,8 +260,7 @@ surface_neighbor_coordinates_3(const Dt& dt,
const typename Dt::Geom_traits::Point_3& p,
const typename Dt::Geom_traits::Vector_3& normal,
OutputIterator out,
typename Dt::Cell_handle start
= typename Dt::Cell_handle())
typename Dt::Cell_handle start = typename Dt::Cell_handle())
{
typedef Voronoi_intersection_2_traits_3<typename Dt::Geom_traits> I_gt;
return surface_neighbor_coordinates_3(dt, p, out, I_gt(p,normal), start);
@ -277,8 +271,7 @@ Triple< OutputIterator, typename ITraits::FT, bool >
surface_neighbor_coordinates_3(const Dt& dt,
const typename ITraits::Point_2& p,
OutputIterator out, const ITraits& traits,
typename Dt::Cell_handle start
= typename Dt::Cell_handle())
typename Dt::Cell_handle start = typename Dt::Cell_handle())
{
typedef typename ITraits::FT Coord_type;
typedef typename ITraits::Point_2 Point_3;
@ -289,8 +282,7 @@ surface_neighbor_coordinates_3(const Dt& dt,
//the Vertex_handle is, in fact, an iterator over vertex:
typedef Project_vertex_iterator_to_point< Vertex_handle> Proj_point;
typedef Iterator_project<
typename std::list< Vertex_handle >::iterator,
typedef Iterator_project<typename std::list< Vertex_handle >::iterator,
Proj_point,
const Point_3&,
const Point_3*,
@ -303,15 +295,13 @@ surface_neighbor_coordinates_3(const Dt& dt,
//if p is located on a vertex: the only neighbor is found
if(lt == Dt::VERTEX){
*out++= std::make_pair(c->vertex(li)->point(),
Coord_type(1));
*out++= std::make_pair(c->vertex(li)->point(), Coord_type(1));
return make_triple(out, Coord_type(1), true);
}
//the candidate points are the points of dt in conflict with p:
typename std::list< Vertex_handle > conflict_vertices;
dt.vertices_on_conflict_zone_boundary(p,c,
std::back_inserter(conflict_vertices));
dt.vertices_on_conflict_zone_boundary(p, c, std::back_inserter(conflict_vertices));
for (typename std::list< Vertex_handle >::iterator it = conflict_vertices.begin();
it != conflict_vertices.end();){
@ -323,8 +313,7 @@ surface_neighbor_coordinates_3(const Dt& dt,
it++;
}
}
return surface_neighbor_coordinates_3
(Point_iterator(conflict_vertices.begin()),
return surface_neighbor_coordinates_3(Point_iterator(conflict_vertices.begin()),
Point_iterator(conflict_vertices.end()),
p, out, traits);
}

View File

@ -12,10 +12,6 @@
// 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) : Julia Floetotto
#ifndef CGAL_SURFACE_NEIGHBORS_3_H
@ -23,8 +19,6 @@
#include <CGAL/license/Interpolation.h>
#include <utility>
#include <CGAL/Voronoi_intersection_2_traits_3.h>
#include <CGAL/Regular_triangulation_2.h>
#include <CGAL/Iterator_project.h>
@ -33,6 +27,10 @@
// the function object Project_vertex_iterator_to_point
#include <CGAL/surface_neighbor_coordinates_3.h>
#include <iterator>
#include <list>
#include <utility>
namespace CGAL {
//without Delaunay filtering
@ -42,7 +40,7 @@ OutputIterator
surface_neighbors_3(InputIterator first, InputIterator beyond,
const typename Kernel::Point_3& p,
const typename Kernel::Vector_3& normal,
OutputIterator out, const Kernel& )
OutputIterator out, const Kernel&)
{
typedef Voronoi_intersection_2_traits_3<Kernel> I_gt;
return surface_neighbors_3(first, beyond, p, out, I_gt(p,normal));
@ -79,20 +77,19 @@ surface_neighbors_3(InputIterator first, InputIterator beyond,
Face_handle fh = it.locate(wp, lt, li);
if(lt == I_triangulation::VERTEX){
*out++ =p;
*out++ = p;
return out;
}
Vertex_handle vh = it.insert(wp, fh);
typename I_triangulation::Vertex_circulator
vc(it.incident_vertices(vh)),
typename I_triangulation::Vertex_circulator vc(it.incident_vertices(vh)),
done(vc);
do{
*out++= wp2p(vc->point());
CGAL_assertion(! it.is_infinite(vc));
}
while(vc++!=done);
while(vc++ != done);
return out;
}
@ -108,7 +105,7 @@ surface_neighbors_certified_3(InputIterator first,
InputIterator beyond,
const typename Kernel::Point_3& p,
const typename Kernel::Vector_3& normal,
OutputIterator out, const Kernel& )
OutputIterator out, const Kernel&)
{
typedef Voronoi_intersection_2_traits_3<Kernel> I_gt;
return surface_neighbors_certified_3(first, beyond, p, out, I_gt(p,normal));
@ -188,7 +185,7 @@ surface_neighbors_certified_3(InputIterator first,
Face_handle fh = it.locate(wp, lt, li);
if(lt == I_triangulation::VERTEX){
*out++ =p;
*out++ = p;
return std::make_pair(out,true);
}
Vertex_handle vh = it.insert(wp, fh);
@ -197,11 +194,11 @@ surface_neighbors_certified_3(InputIterator first,
//determine the furthest distance from p to a vertex of its cell
bool valid(false);
Face_circulator fc(it.incident_faces(vh)), fdone(fc);
do
do{
valid = (!it.is_infinite(fc) &&
(4*radius > traits.compute_squared_distance_2_object()
(p, it.dual(fc))));
while(!valid && ++fc!=fdone);
}while(!valid && ++fc!=fdone);
//get the neighbor points:
Vertex_circulator vc(it.incident_vertices(vh)), vdone(vc);
@ -212,7 +209,6 @@ surface_neighbors_certified_3(InputIterator first,
return std::make_pair(out, valid);
}
//using Delaunay triangulation for candidate point filtering:
// => no certification is necessary
template <class Dt, class OutputIterator>
@ -233,8 +229,7 @@ OutputIterator
surface_neighbors_3(const Dt& dt,
const typename ITraits::Point_2& p,
OutputIterator out, const ITraits& traits,
typename Dt::Cell_handle start
= typename Dt::Cell_handle())
typename Dt::Cell_handle start = typename Dt::Cell_handle())
{
typedef typename ITraits::Point_2 Point_3;
@ -244,8 +239,7 @@ surface_neighbors_3(const Dt& dt,
//the Vertex_handle is, in fact, an iterator over vertex:
typedef Project_vertex_iterator_to_point< Vertex_handle> Proj_point;
typedef Iterator_project<
typename std::list< Vertex_handle >::iterator,
typedef Iterator_project<typename std::list< Vertex_handle >::iterator,
Proj_point,
const Point_3&,
const Point_3*,

View File

@ -12,10 +12,6 @@
// 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) : Julia Floetotto
#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
@ -24,6 +20,8 @@
#include <CGAL/_test_interpolation_functions_2.cpp>
#include <iostream>
typedef CGAL::Exact_predicates_exact_constructions_kernel K;
typedef CGAL::Delaunay_triangulation_2<K> Dt;
@ -36,13 +34,13 @@ int main()
<< std::endl;
std::cout << " using Exact_predicates_exact_constructions_kernel: "
<< std::endl ;
_test_interpolation_functions_2_delaunay( Dt(), K::FT(1e-10));
_test_interpolation_functions_2_delaunay(Dt(), K::FT(1e-10));
std::cout << "Testing interpolation functions with 2D NN neighbors "
<< std::endl;
std::cout << " using Exact_predicates_inexact_constructions_kernel: "
<< std::endl ;
_test_interpolation_functions_2_delaunay( Dt2(), K2::FT(1e-10));
_test_interpolation_functions_2_delaunay(Dt2(), K2::FT(1e-10));
std::cout << "test_interpolation_functions_2 is finished" << std::endl;
return 0;

View File

@ -12,10 +12,6 @@
// 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) : Naceur MESKINI.
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
@ -23,11 +19,11 @@
#include <CGAL/_test_natural_neighbors_2.cpp>
#include <iostream>
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::Delaunay_triangulation_2<K> Dt;
int main()
{
std::cout << "Testing NN_neighbors_2 " << std::endl;

View File

@ -12,10 +12,6 @@
// 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) : Julia Floetotto
#include <CGAL/basic.h>
@ -26,6 +22,7 @@
#include <CGAL/_test_regular_neighbors_2.cpp>
#include <iostream>
typedef CGAL::Exact_predicates_exact_constructions_kernel K;

View File

@ -12,10 +12,6 @@
// 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) : Julia Floetotto
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
@ -25,6 +21,7 @@
#include <CGAL/_test_surface_neighbors_3.cpp>
#include <iostream>
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::Delaunay_triangulation_3<K> Dt;
@ -35,7 +32,6 @@ typedef CGAL::Delaunay_triangulation_3<K2> Dt2;
// Fast_location with exact pred exact const. kernel:
typedef CGAL::Delaunay_triangulation_3<K2, CGAL::Fast_location> Dh;
// Aff_transformation:
typedef CGAL::Aff_transformation_3<K2> Transformation;
@ -46,7 +42,6 @@ int main()
_test_surface_neighbors_3_sphere( Dt() );
std::cout << " done." << std::endl << std::endl;
std::cout << "Using Exact_predicates_exact_constructions_kernel: "
<< std::endl;
@ -57,6 +52,7 @@ int main()
<< identity(K2::Vector_3(0,1,0))<< ", "
<< identity(K2::Vector_3(1,0,0))
<< std::endl;
std::cout << " with grid sample points";
_test_surface_neighbors_3_cube(Dt2(),identity, 75, K2::FT(1e-29));
std::cout << " done." << std::endl;
@ -69,20 +65,21 @@ int main()
Transformation rotate(K2::RT(1),K2::RT(0),K2::RT(0),K2::RT(0),
K2::RT(0),K2::RT(0.9063),K2::RT(-0.42261826),K2::RT(0),
K2::RT(0),K2::RT(0.42261826),K2::RT(0.9063),K2::RT(0));
std::cout << "Testing surface_neighbors_3 on a ROTATED cube "<< std::endl;
std::cout << " with grid sample points";
_test_surface_neighbors_3_cube(Dh(),rotate, 75, K2::FT(1e-2), true);
std::cout << " done." << std::endl << std::endl;
// //undersampled rotated cube
// Transformation rotate3(K2::RT(0.1),K2::RT(0.4),K2::RT(0.6),K2::RT(0),
// K2::RT(0.3),K2::RT(0.5),K2::RT(0.1),K2::RT(0),
// K2::RT(0.5),K2::RT(0.9),K2::RT(0.8),K2::RT(0));
// std::cout << "Testing surface_neighbors_3 on an undersampled ROTATED cube "
// << std::endl;
// std::cout << " with grid sample points";
// _test_surface_neighbors_3_cube(Dh(),rotate3,75, K2::FT(9), true);
// std::cout << " done." << std::endl << std::endl;
// //undersampled rotated cube
// Transformation rotate3(K2::RT(0.1),K2::RT(0.4),K2::RT(0.6),K2::RT(0),
// K2::RT(0.3),K2::RT(0.5),K2::RT(0.1),K2::RT(0),
// K2::RT(0.5),K2::RT(0.9),K2::RT(0.8),K2::RT(0));
// std::cout << "Testing surface_neighbors_3 on an undersampled ROTATED cube "
// << std::endl;
// std::cout << " with grid sample points";
// _test_surface_neighbors_3_cube(Dh(),rotate3,75, K2::FT(9), true);
// std::cout << " done." << std::endl << std::endl;
return 0;
}