File: custom_traits.cpp

package info (click to toggle)
cgal 6.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 144,912 kB
  • sloc: cpp: 810,858; ansic: 208,477; sh: 493; python: 411; makefile: 286; javascript: 174
file content (41 lines) | stat: -rw-r--r-- 1,136 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include <CGAL/Simple_cartesian.h>
#include <CGAL/Weights/inverse_distance_weights.h>

// Typedefs.
using Kernel  = CGAL::Simple_cartesian<double>;
using Point_2 = typename Kernel::Point_2;
using Point_3 = typename Kernel::Point_3;

// Custom traits class that has only two objects.
struct Custom_traits {
  using FT = typename Kernel::FT;
  using Point_2 = typename Kernel::Point_2;
  using Point_3 = typename Kernel::Point_3;

  decltype(auto) compute_squared_distance_2_object() const {
    return Kernel::Compute_squared_distance_2();
  }
  decltype(auto) compute_squared_distance_3_object() const {
    return Kernel::Compute_squared_distance_3();
  }
};

int main() {

  // 2D configuration.
  const Point_2 p2(0, 0);
  const Point_2 q2(0, 1);

  // 3D configuration.
  const Point_3 p3(0, 0, 1);
  const Point_3 q3(0, 1, 1);

  // Create custom traits.
  const Custom_traits ctraits;

  // Compute weights.
  std::cout << "2D/3D weight: ";
  std::cout << CGAL::Weights::inverse_distance_weight(p2, q2, ctraits) << "/";
  std::cout << CGAL::Weights::inverse_distance_weight(p3, q3, ctraits) << std::endl;
  return EXIT_SUCCESS;
}