File: bbox_diagonal.h

package info (click to toggle)
cgal 6.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 144,912 kB
  • sloc: cpp: 810,858; ansic: 208,477; sh: 493; python: 411; makefile: 286; javascript: 174
file content (59 lines) | stat: -rw-r--r-- 2,254 bytes parent folder | download
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// Copyright (c) 2020 GeometryFactory (France).
// All rights reserved.
//
// This file is part of CGAL (www.cgal.org).
//
// $URL: https://github.com/CGAL/cgal/blob/v6.1/Point_set_processing_3/include/CGAL/Point_set_processing_3/internal/bbox_diagonal.h $
// $Id: include/CGAL/Point_set_processing_3/internal/bbox_diagonal.h b26b07a1242 $
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial
//
// Author(s) : Simon Giraudot

#ifndef CGAL_PSP_INTERNAL_BBOX_DIAGONAL_H
#define CGAL_PSP_INTERNAL_BBOX_DIAGONAL_H

#include <CGAL/license/Point_set_processing_3.h>

namespace CGAL
{
namespace Point_set_processing_3
{
namespace internal
{

template <typename Kernel, typename PointRange, typename PointMap>
double bbox_diagonal (const PointRange& points, PointMap point_map, const typename Kernel::Point_2&)
{
  CGAL::Bbox_2 bbox = CGAL::bbox_2 (CGAL::make_transform_iterator_from_property_map (points.begin(), point_map),
                                    CGAL::make_transform_iterator_from_property_map (points.end(), point_map));

  return CGAL::approximate_sqrt
    ((bbox.xmax() - bbox.xmin()) * (bbox.xmax() - bbox.xmin())
     + (bbox.ymax() - bbox.ymin()) * (bbox.ymax() - bbox.ymin()));
}

template <typename Kernel, typename PointRange, typename PointMap>
double bbox_diagonal (const PointRange& points, PointMap point_map, const typename Kernel::Point_3&)
{
  CGAL::Bbox_3 bbox = CGAL::bbox_3 (CGAL::make_transform_iterator_from_property_map (points.begin(), point_map),
                                    CGAL::make_transform_iterator_from_property_map (points.end(), point_map));

  return CGAL::approximate_sqrt
    ((bbox.xmax() - bbox.xmin()) * (bbox.xmax() - bbox.xmin())
     + (bbox.ymax() - bbox.ymin()) * (bbox.ymax() - bbox.ymin())
     + (bbox.zmax() - bbox.zmin()) * (bbox.zmax() - bbox.zmin()));
}

template <typename PointRange, typename PointMap>
double bbox_diagonal (const PointRange& points, PointMap point_map)
{
  typedef typename boost::property_traits<PointMap>::value_type Point;
  return bbox_diagonal<typename Kernel_traits<Point>::Kernel> (points, point_map, Point());
}

} // namespace internal
} // namespace Point_set_processing_3
} // namespace CGAL


#endif // CGAL_PSP_INTERNAL_BBOX_DIAGONAL_H