-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLandscape_image_2.h
80 lines (67 loc) · 2.19 KB
/
Landscape_image_2.h
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/*
* Copyright (C) 2012
* Helmholtz Centre for Environmental Research (UFZ)
*
* This file is part of "GeoMeshCo." "GeoMeshCo" is free
* software: 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.
*
* "GeoMeshCo" is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* "GeoMeshCo". If not, see <http://www.gnu.org/licenses/>.
*
* As a special exception, you have permission to link this program
* with the Computational Geometry Algorithms Library (CGAL,
* <http://www.cgal.org>) and distribute executables, as long as you
* follow the requirements of the GNU GPL in regard to all of
* the software in the executable aside from CGAL.
*
*
* Author: Dmitrij Yu. Naumov
*
*/
#ifndef CGAL_EXTENSION_LANDSCAPE_IMAGE_2
#define CGAL_EXTENSION_LANDSCAPE_IMAGE_2
#include <CGAL/basic.h>
#include "Image_2.h"
namespace CGAL_Extension
{
template <typename FT, typename Point_3>
class Landscape_image_2
{
public:
Landscape_image_2(
const Image_2<short, FT>& image,
const FT& bottom = -1,
const FT& z_scale = 1,
const FT& outside_value = 1)
: _image(image), _bottom(bottom), _z_scale(z_scale),
_out_value(outside_value)
{ }
FT
operator()(const Point_3& p) const
{
if (p.z() <= _bottom)
return _out_value;
typedef typename Image_2<short, FT>::Value Value;
const Value f = _image.interpolate(
CGAL::to_double(p.x()), CGAL::to_double(p.y()));
if (f)
{
return p.z() - *f/_z_scale;
}
return _out_value; // outside image;
}
private:
const Image_2<short, FT>& _image;
const FT& _bottom;
const FT& _z_scale;
const FT& _out_value;
};
} // namespace CGAL_Extension
#endif // CGAL_EXTENSION_LANDSCAPE_IMAGE_2