source: experimental/TerrainTest/region.cpp @ 375

Last change on this file since 375 was 272, checked in by Torben Dannhauer, 14 years ago
File size: 1.5 KB
Line 
1/* -*-c++-*- osgVisual - Copyright (C) 2009-2011 Torben Dannhauer
2 *
3 * This library is based on OpenSceneGraph, open source and may be redistributed and/or modified under
4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
5 * (at your option) any later version.  The full license is in LICENSE file
6 * included with this distribution, and on the openscenegraph.org website.
7 *
8 * osgVisual requires for some proprietary modules a license from the correspondig manufacturer.
9 * You have to aquire licenses for all used proprietary modules.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 * OpenSceneGraph Public License for more details.
15*/
16
17#include "region.h"
18
19region::region(osg::HeightField& h)
20{
21        _lat_min = h.getOrigin()[1];
22        _lat_max = _lat_min + h.getNumRows() * h.getYInterval();
23        _lon_min = h.getOrigin()[0];
24        _lon_max = _lon_min + h.getNumColumns() * h.getXInterval();
25}
26
27bool region::isInside(region& outsider)
28{
29        if( outsider._lat_min <= _lat_min && _lat_max <= outsider._lat_max &&
30                outsider._lon_min <= _lon_min && _lon_max <= outsider._lon_max )
31                return true;
32        else
33                return false;
34}
35
36bool region::isFullOrPartiallyInside(region& outsider)
37{
38        if( outsider._lat_min < _lat_max && _lat_min < outsider._lat_max &&
39                outsider._lon_min < _lon_max && _lon_min < outsider._lon_max )
40                return true;
41        else
42                return false;
43}
Note: See TracBrowser for help on using the repository browser.