libspatialindex API Reference  (git-trunk)
Region.h
Go to the documentation of this file.
1 /******************************************************************************
2  * Project: libspatialindex - A C++ library for spatial indexing
3  * Author: Marios Hadjieleftheriou, mhadji@gmail.com
4  ******************************************************************************
5  * Copyright (c) 2004, Marios Hadjieleftheriou
6  *
7  * All rights reserved.
8  *
9  * Permission is hereby granted, free of charge, to any person obtaining a
10  * copy of this software and associated documentation files (the "Software"),
11  * to deal in the Software without restriction, including without limitation
12  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
13  * and/or sell copies of the Software, and to permit persons to whom the
14  * Software is furnished to do so, subject to the following conditions:
15  *
16  * The above copyright notice and this permission notice shall be included
17  * in all copies or substantial portions of the Software.
18  *
19  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25  * DEALINGS IN THE SOFTWARE.
26 ******************************************************************************/
27 
28 #pragma once
29 
30 namespace SpatialIndex
31 {
32  class SIDX_DLL Region : public Tools::IObject, public virtual IShape
33  {
34  public:
35  Region();
36  Region(const double* pLow, const double* pHigh, uint32_t dimension);
37  Region(const Point& low, const Point& high);
38  Region(const Region& in);
39  ~Region() override;
40 
41  virtual Region& operator=(const Region& r);
42  virtual bool operator==(const Region&) const;
43 
44  //
45  // IObject interface
46  //
47  Region* clone() override;
48 
49  //
50  // ISerializable interface
51  //
52  uint32_t getByteArraySize() override;
53  void loadFromByteArray(const uint8_t* data) override;
54  void storeToByteArray(uint8_t** data, uint32_t& length) override;
55 
56  //
57  // IShape interface
58  //
59  bool intersectsShape(const IShape& in) const override;
60  bool containsShape(const IShape& in) const override;
61  bool touchesShape(const IShape& in) const override;
62  void getCenter(Point& out) const override;
63  uint32_t getDimension() const override;
64  void getMBR(Region& out) const override;
65  double getArea() const override;
66  double getMinimumDistance(const IShape& in) const override;
67 
68  virtual bool intersectsRegion(const Region& in) const;
69  virtual bool containsRegion(const Region& in) const;
70  virtual bool touchesRegion(const Region& in) const;
71  virtual double getMinimumDistance(const Region& in) const;
72 
73  virtual bool intersectsLineSegment(const LineSegment& in) const;
74 
75  virtual bool containsPoint(const Point& in) const;
76  virtual bool touchesPoint(const Point& in) const;
77  virtual double getMinimumDistance(const Point& in) const;
78 
79  virtual Region getIntersectingRegion(const Region& r) const;
80  virtual double getIntersectingArea(const Region& in) const;
81  virtual double getMargin() const;
82 
83  virtual void combineRegion(const Region& in);
84  virtual void combinePoint(const Point& in);
85  virtual void getCombinedRegion(Region& out, const Region& in) const;
86 
87  virtual double getLow(uint32_t index) const;
88  virtual double getHigh(uint32_t index) const;
89 
90  virtual void makeInfinite(uint32_t dimension);
91  virtual void makeDimension(uint32_t dimension);
92 
93  private:
94  void initialize(const double* pLow, const double* pHigh, uint32_t dimension);
95 
96  public:
97  uint32_t m_dimension{0};
98  double* m_pLow{nullptr};
99  double* m_pHigh{nullptr};
100 
101  friend SIDX_DLL std::ostream& operator<<(std::ostream& os, const Region& r);
102  }; // Region
103 
105  SIDX_DLL std::ostream& operator<<(std::ostream& os, const Region& r);
106 }
Tools::PoolPointer< Region > RegionPtr
Definition: Region.h:104
SIDX_DLL std::ostream & operator<<(std::ostream &os, const Ball &ball)
Definition: Ball.cc:215
#define SIDX_DLL
Definition: sidx_export.h:41