From a926aa22cb14fa07995a14e4fad885f3248de432 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Wed, 13 Sep 2017 16:13:04 +0200 Subject: [PATCH 1/5] Fixed weighted point issue in gradient fitting functions --- .../Interpolation_gradient_fitting_traits_2.h | 6 +++++ .../include/CGAL/sibson_gradient_fitting.h | 25 +++++++++++-------- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/Interpolation/include/CGAL/Interpolation_gradient_fitting_traits_2.h b/Interpolation/include/CGAL/Interpolation_gradient_fitting_traits_2.h index 55f416363d3..aaa71d7cc80 100644 --- a/Interpolation/include/CGAL/Interpolation_gradient_fitting_traits_2.h +++ b/Interpolation/include/CGAL/Interpolation_gradient_fitting_traits_2.h @@ -100,8 +100,10 @@ public: typedef typename Rep::FT FT; typedef typename Rep::Point_2 Point_d; + typedef typename Rep::Weighted_point_2 Weighted_point_d; typedef typename Rep::Vector_2 Vector_d; + typedef typename Rep::Construct_point_2 Construct_point_d; typedef typename Rep::Construct_vector_2 Construct_vector_d; typedef typename Rep::Construct_scaled_vector_2 Construct_scaled_vector_d; //only one not needed by gradient fitting: @@ -140,6 +142,10 @@ public: construct_scaled_vector_d_object()const {return Construct_scaled_vector_d();} + Construct_point_d + construct_point_d_object()const + {return Construct_point_d();} + Construct_vector_d construct_vector_d_object()const {return Construct_vector_d();} diff --git a/Interpolation/include/CGAL/sibson_gradient_fitting.h b/Interpolation/include/CGAL/sibson_gradient_fitting.h index fbb49f08cf6..65c97ad638e 100644 --- a/Interpolation/include/CGAL/sibson_gradient_fitting.h +++ b/Interpolation/include/CGAL/sibson_gradient_fitting.h @@ -48,7 +48,9 @@ sibson_gradient_fitting(ForwardIterator first, ForwardIterator beyond, typedef typename Traits::Aff_transformation_d Aff_transformation; typedef typename Traits::FT Coord_type; - typename Functor::result_type fn = function_value(p); + const typename Traits::Point_d& bare_p = traits.construct_point_d_object()(p); + + typename Functor::result_type fn = function_value(bare_p); CGAL_assertion(fn.second); //function value of p is valid typename Traits::Vector_d pn = @@ -56,16 +58,17 @@ sibson_gradient_fitting(ForwardIterator first, ForwardIterator beyond, Aff_transformation scaling, m, Hn(traits.construct_null_matrix_d_object()()); - for(;first!=beyond; ++first){ - Coord_type square_dist = traits.compute_squared_distance_d_object() - (first->first, p); + for(;first!=beyond; ++first) + { + const typename Traits::Point_d& bare_f = traits.construct_point_d_object()(first->first); + + Coord_type square_dist = traits.compute_squared_distance_d_object()(bare_f, bare_p); CGAL_assertion(square_dist != 0); Coord_type scale = first->second / (norm*square_dist); - typename Traits::Vector_d d = - traits.construct_vector_d_object()(p, first->first); + typename Traits::Vector_d d = traits.construct_vector_d_object()(bare_p, bare_f); //compute the vector pn: - typename Functor::result_type f = function_value(first->first); + typename Functor::result_type f = function_value(bare_f); CGAL_assertion(f.second);//function value of first->first is valid pn = pn + traits.construct_scaled_vector_d_object() (d,scale * (f.first - fn.first)); @@ -89,7 +92,7 @@ sibson_gradient_fitting(const Triangul& tr, CoordFunctor compute_coordinates, const Traits& traits) { - typedef typename Traits::Point_d Point; + typedef typename Triangul::Point Point; typedef typename Traits::FT Coord_type; std::vector< std::pair< Point, Coord_type > > coords; @@ -101,7 +104,7 @@ sibson_gradient_fitting(const Triangul& tr, if (!tr.is_edge(vit, tr.infinite_vertex())) { norm = compute_coordinates(tr, vit, std::back_inserter(coords)).second; - *out++ = std::make_pair(vit->point(), + *out++ = std::make_pair(traits.construct_point_d_object()(vit->point()), sibson_gradient_fitting(coords.begin(), coords.end(), norm, vit->point(), @@ -145,8 +148,8 @@ sibson_gradient_fitting_rn_2(const Rt& rt, { typedef typename std::back_insert_iterator< std::vector< - std::pair< typename Traits::Point_d, - typename Traits::FT > > > CoordInserter; + std::pair< typename Traits::Weighted_point_d, + typename Traits::FT > > > CoordInserter; return sibson_gradient_fitting(rt, out, function_value, regular_neighbor_coordinates_2_object< Rt, From 9a5e0f8a644c6ee4e244049ac145b3876a93a414 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Wed, 13 Sep 2017 16:13:28 +0200 Subject: [PATCH 2/5] Modified gradient fitting concept --- .../Concepts/GradientFittingTraits.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Interpolation/doc/Interpolation/Concepts/GradientFittingTraits.h b/Interpolation/doc/Interpolation/Concepts/GradientFittingTraits.h index e6d6d48f2d4..d629a57376b 100644 --- a/Interpolation/doc/Interpolation/Concepts/GradientFittingTraits.h +++ b/Interpolation/doc/Interpolation/Concepts/GradientFittingTraits.h @@ -36,6 +36,11 @@ which the function is defined and interpolated. */ typedef unspecified_type Point_d; +/*! +The weighted point type. +*/ +typedef unspecified_type Weighted_point_d; + /*! The corresponding vector type. */ @@ -55,6 +60,16 @@ multiplication of `tr` with `v`. */ typedef unspecified_type Aff_transformation_d; +/*! +A constructor object for `Point_d`. +Provides : + +`Point_d operator() (Point_d p)` which simply returns `p` + +`Point_d operator() (Weighted_point wp)` which returns the bare point contained in `wp`. +*/ +typedef unspecified_type Construct_point_d; + /*! A constructor object for `Vector_d`. From 58bd2302e0c69c2fbfef294bffac64a38c70192c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Wed, 13 Sep 2017 16:13:47 +0200 Subject: [PATCH 3/5] Added a test to gradient fitting functions --- .../CGAL/_test_regular_neighbors_2.cpp | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/Interpolation/test/Interpolation/include/CGAL/_test_regular_neighbors_2.cpp b/Interpolation/test/Interpolation/include/CGAL/_test_regular_neighbors_2.cpp index 7af484aa9f9..61ab9217bf0 100644 --- a/Interpolation/test/Interpolation/include/CGAL/_test_regular_neighbors_2.cpp +++ b/Interpolation/test/Interpolation/include/CGAL/_test_regular_neighbors_2.cpp @@ -28,6 +28,8 @@ #include #include +#include +#include template < class ForwardIterator > bool test_norm(ForwardIterator first, ForwardIterator beyond, @@ -55,6 +57,33 @@ bool test_barycenter(ForwardIterator first, ForwardIterator beyond, return p==b; } +template +void test_gradient_fitting(const Triangul& rt) +{ + typedef typename Triangul::Geom_traits::Kernel K; + typedef typename Triangul::Geom_traits::FT FT; + typedef typename Triangul::Geom_traits::Vector_2 Vector_2; + typedef typename Triangul::Geom_traits::Point_2 Point; + + struct Functor + { + typedef std::pair result_type; + + result_type operator()(const Point&) { return std::make_pair(0., true); } + }; + + typedef typename std::back_insert_iterator< + std::vector< + std::pair< Point, Vector_2 > > > OutputIterator; + + std::vector > v; + OutputIterator out = std::back_inserter(v); + Functor f; + + CGAL::Interpolation_gradient_fitting_traits_2 traits; + + sibson_gradient_fitting_rn_2(rt, out, f, traits); +} template void @@ -113,6 +142,8 @@ _test_regular_neighbors_2( const Triangul & ) coords.clear(); } + test_gradient_fitting(T); + //TESTING a GRID POINT SET std::cout << "RN2: Testing grid points." << std::endl; From ed5d8311fe06aafa5582f04f5697bb9674a1464a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Wed, 13 Sep 2017 16:21:50 +0200 Subject: [PATCH 4/5] Modified changes.html --- Installation/changes.html | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Installation/changes.html b/Installation/changes.html index 4cd0440e0d5..c88c1eb1975 100644 --- a/Installation/changes.html +++ b/Installation/changes.html @@ -251,6 +251,15 @@ and src/ directories). refines DelaunayTriangulationTraits_2. +

Interpolation

+
    +
  • Breaking change: The concept GradientFittingTraits + now additionally requests a weighted point type Weighted_point_d + and a functor Construct_point_d. The model + CGAL::Interpolation_gradient_fitting_traits_2 has been appropriately + modified to still be a model of the concept GradientFittingTraits. +
  • +

2D and 3D Triangulations

  • Breaking change: Added a new functor From 5e7fba7c1b29a04c405088595ff20e0a153e34f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Thu, 14 Sep 2017 08:15:55 +0200 Subject: [PATCH 5/5] change the scope of the functor --- .../include/CGAL/_test_regular_neighbors_2.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/Interpolation/test/Interpolation/include/CGAL/_test_regular_neighbors_2.cpp b/Interpolation/test/Interpolation/include/CGAL/_test_regular_neighbors_2.cpp index 61ab9217bf0..fdbb6f029f1 100644 --- a/Interpolation/test/Interpolation/include/CGAL/_test_regular_neighbors_2.cpp +++ b/Interpolation/test/Interpolation/include/CGAL/_test_regular_neighbors_2.cpp @@ -57,6 +57,14 @@ bool test_barycenter(ForwardIterator first, ForwardIterator beyond, return p==b; } +template +struct Functor +{ + typedef std::pair result_type; + + result_type operator()(const Point&) { return std::make_pair(0., true); } +}; + template void test_gradient_fitting(const Triangul& rt) { @@ -65,20 +73,13 @@ void test_gradient_fitting(const Triangul& rt) typedef typename Triangul::Geom_traits::Vector_2 Vector_2; typedef typename Triangul::Geom_traits::Point_2 Point; - struct Functor - { - typedef std::pair result_type; - - result_type operator()(const Point&) { return std::make_pair(0., true); } - }; - typedef typename std::back_insert_iterator< std::vector< std::pair< Point, Vector_2 > > > OutputIterator; std::vector > v; OutputIterator out = std::back_inserter(v); - Functor f; + Functor f; CGAL::Interpolation_gradient_fitting_traits_2 traits;