lsst.sphgeom gb5d12ffc61+ac198e9f13
Region.h
Go to the documentation of this file.
1/*
2 * LSST Data Management System
3 * Copyright 2014-2015 AURA/LSST.
4 *
5 * This product includes software developed by the
6 * LSST Project (http://www.lsst.org/).
7 *
8 * This program is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the LSST License Statement and
19 * the GNU General Public License along with this program. If not,
20 * see <https://www.lsstcorp.org/LegalNotices/>.
21 */
22
23#ifndef LSST_SPHGEOM_REGION_H_
24#define LSST_SPHGEOM_REGION_H_
25
28
29#include <memory>
30#include <vector>
31
32#include "Relationship.h"
33
34
35namespace lsst {
36namespace sphgeom {
37
38// Forward declarations
39class Box;
40class Box3d;
41class Circle;
42class ConvexPolygon;
43class Ellipse;
44class UnitVector3d;
45
79class Region {
80public:
81 virtual ~Region() {}
82
84 virtual std::unique_ptr<Region> clone() const = 0;
85
87 virtual Box getBoundingBox() const = 0;
88
90 virtual Box3d getBoundingBox3d() const = 0;
91
93 virtual Circle getBoundingCircle() const = 0;
94
96 virtual bool contains(UnitVector3d const &) const = 0;
97
100 bool contains(double x, double y, double z) const;
101
104 bool contains(double lon, double lat) const;
105
124 virtual Relationship relate(Region const &) const = 0;
125 virtual Relationship relate(Box const &) const = 0;
126 virtual Relationship relate(Circle const &) const = 0;
127 virtual Relationship relate(ConvexPolygon const &) const = 0;
128 virtual Relationship relate(Ellipse const &) const = 0;
130
133 virtual std::vector<uint8_t> encode() const = 0;
134
137 static std::unique_ptr<Region> decode(std::vector<uint8_t> const & s) {
138 return decode(s.data(), s.size());
139 }
140
141 static std::unique_ptr<Region> decode(uint8_t const * buffer, size_t n);
143};
144
145}} // namespace lsst::sphgeom
146
147#endif // LSST_SPHGEOM_REGION_H_
This file provides a type alias for describing set relationships.
std::bitset< 3 > Relationship
Relationship describes how two sets are related.
Definition: Relationship.h:35
Definition: Box3d.h:42
Definition: Box.h:54
Definition: Circle.h:46
Definition: ConvexPolygon.h:57
Definition: Ellipse.h:170
Definition: Region.h:79
virtual Circle getBoundingCircle() const =0
getBoundingCircle returns a bounding-circle for this region.
virtual Relationship relate(Region const &) const =0
static std::unique_ptr< Region > decode(std::vector< uint8_t > const &s)
Definition: Region.h:137
virtual Box getBoundingBox() const =0
getBoundingBox returns a bounding-box for this region.
virtual bool contains(UnitVector3d const &) const =0
contains tests whether the given unit vector is inside this region.
virtual std::unique_ptr< Region > clone() const =0
clone returns a deep copy of this region.
virtual std::vector< uint8_t > encode() const =0
virtual Box3d getBoundingBox3d() const =0
getBoundingBox3d returns a 3-dimensional bounding-box for this region.
Definition: UnitVector3d.h:55