File: common.hpp

package info (click to toggle)
liblas 1.8.0-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 7,888 kB
  • ctags: 4,614
  • sloc: cpp: 31,630; xml: 4,195; python: 2,928; ansic: 2,439; cs: 2,411; sh: 143; makefile: 37
file content (99 lines) | stat: -rwxr-xr-x 2,937 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
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
// $Id$
//
// (C) Copyright Mateusz Loskot 2008, mateusz@loskot.net
// Distributed under the BSD License
// (See accompanying file LICENSE.txt or copy at
// http://www.opensource.org/licenses/bsd-license.php)
//
#include <liblas/liblas.hpp>

#include <iostream>

namespace tut
{

// Predicate testing LASPoint against given XY coordinates
// and tolerance.
struct is_xy
{
    is_xy(double x, double y, double tolerance)
        : x(x), y(y), t(tolerance)
    {}

    bool operator()(liblas::Point const& p)
    {
        double const dx = x - p.GetX();
        double const dy = y - p.GetY();

        return ((dx <= t && dx >= -t) && (dy <= t && dy >= -t));
    }

    double x;
    double y;
    double t;
};

// Functor to calculate bounding box of a set of points
struct bbox_calculator
{
    bbox_calculator(liblas::Bounds<double>& bbox) : bbox(&bbox), empty(true) {}

    void operator()(liblas::Point const& p)
    {
        if (0 == bbox)
            throw std::invalid_argument("bbox is null");

        // Box initialization during first iteration only
        if (empty)
        {
            (bbox->min)(0, p.GetX());
            (bbox->max)(0, p.GetX());
            (bbox->min)(1, p.GetY());
            (bbox->max)(1, p.GetY());
            (bbox->min)(2, p.GetZ());
            (bbox->max)(2, p.GetZ());
            empty = false;
        }

        // Expand bounding box to include given point
        (bbox->min)(0, (std::min)((bbox->min)(0), p.GetX()));
        (bbox->min)(1, (std::min)((bbox->min)(1), p.GetY()));
        (bbox->min)(2, (std::min)((bbox->min)(2), p.GetZ()));
        (bbox->max)(0, (std::max)((bbox->max)(0), p.GetX()));
        (bbox->max)(1, (std::max)((bbox->max)(1), p.GetY()));
        (bbox->max)(2, (std::max)((bbox->max)(2), p.GetZ()));
    }

private:
    liblas::Bounds<double>* bbox;
    bool empty;
};

// Common test procedure for default constructed point data.
void test_default_point(liblas::Point const& p);

// Common test procedure for default constructed header data.
void test_default_header(liblas::Header const& h);

// Test of header data in trunk/test/data/TO_core_last_clip.las file
void test_file10_header(liblas::Header const& h);

// Test of 1st point record in trunk/test/data/TO_core_last_clip.las file
void test_file10_point1(liblas::Point const& p);

// Test of 2nd point record in trunk/test/data/TO_core_last_clip.las file
void test_file10_point2(liblas::Point const& p);

// Test of 4th point record in trunk/test/data/TO_core_last_clip.las file
void test_file10_point4(liblas::Point const& p);

// Test of 1st, 2nd, 3rd point record in trunk/test/data/1.2-with-color.laz file
void test_file_12Color_point0(liblas::Point const& p);
void test_file_12Color_point1(liblas::Point const& p);
void test_file_12Color_point2(liblas::Point const& p);

// make sure we have a valid laszip VLR block
void test_laszip_vlr(liblas::Header const& header);

} // namespace tut