1 /******************************************************************************
2  * Project:  libspatialindex - A C++ library for spatial indexing
3  * Author:   Marios Hadjieleftheriou, mhadji@gmail.com
4  ******************************************************************************
5  * Copyright (c) 2003, 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 TimeRegion : public Region, public ITimeShape
33 	{
34 	public:
35 		TimeRegion();
36 		TimeRegion(const double* pLow, const double* pHigh, const Tools::IInterval& ti, uint32_t dimension);
37 		TimeRegion(const double* pLow, const double* pHigh, double tStart, double tEnd, uint32_t dimension);
38 		TimeRegion(const Point& low, const Point& high, const Tools::IInterval& ti);
39 		TimeRegion(const Point& low, const Point& high, double tStart, double tEnd);
40 		TimeRegion(const Region& in, const Tools::IInterval& ti);
41 		TimeRegion(const Region& in, double tStart, double tEnd);
42 		TimeRegion(const TimePoint& low, const TimePoint& high);
43 		TimeRegion(const TimeRegion& in);
44 		virtual ~TimeRegion();
45 
46 		virtual TimeRegion& operator=(const TimeRegion& r);
47 		virtual bool operator==(const TimeRegion&) const;
48 
49 		virtual bool intersectsRegionInTime(const TimeRegion& in) const;
50 		virtual bool containsRegionInTime(const TimeRegion& in) const;
51 		virtual bool touchesRegionInTime(const TimeRegion& in) const;
52 
53 		virtual bool containsPointInTime(const TimePoint& in) const;
54 		virtual bool touchesPointInTime(const TimePoint& in) const;
55 
56 		virtual void combineRegionInTime(const TimeRegion& in);
57 		virtual void getCombinedRegionInTime(TimeRegion& out, const TimeRegion& in) const;
58 
59 		//
60 		// IObject interface
61 		//
62 		virtual TimeRegion* clone();
63 
64 		//
65 		// ISerializable interface
66 		//
67 		virtual uint32_t getByteArraySize();
68 		virtual void loadFromByteArray(const byte* data);
69 		virtual void storeToByteArray(byte** data, uint32_t& len);
70 
71 		//
72 		// ITimeShape interface
73 		//
74 		virtual bool intersectsShapeInTime(const ITimeShape& in) const;
75 		virtual bool intersectsShapeInTime(const Tools::IInterval& ivI, const ITimeShape& in) const;
76 		virtual bool containsShapeInTime(const ITimeShape& in) const;
77 		virtual bool containsShapeInTime(const Tools::IInterval& ivI, const ITimeShape& in) const;
78 		virtual bool touchesShapeInTime(const ITimeShape& in) const;
79 		virtual bool touchesShapeInTime(const Tools::IInterval& ivI, const ITimeShape& in) const;
80 		virtual double getAreaInTime() const;
81 		virtual double getAreaInTime(const Tools::IInterval& ivI) const;
82 		virtual double getIntersectingAreaInTime(const ITimeShape& r) const;
83 		virtual double getIntersectingAreaInTime(const Tools::IInterval& ivI, const ITimeShape& r) const;
84 
85 		//
86 		// IInterval interface
87 		//
88 		virtual Tools::IInterval& operator=(const Tools::IInterval&);
89 		virtual double getLowerBound() const;
90 		virtual double getUpperBound() const;
91 		virtual void setBounds(double, double);
92 		virtual bool intersectsInterval(const Tools::IInterval& ti) const;
93 		virtual bool intersectsInterval(Tools::IntervalType t, const double start, const double end) const;
94 		virtual bool containsInterval(const Tools::IInterval& ti) const;
95 		virtual Tools::IntervalType getIntervalType() const;
96 
97 		virtual void makeInfinite(uint32_t dimension);
98 		virtual void makeDimension(uint32_t dimension);
99 
100 	public:
101 		double m_startTime;
102 		double m_endTime;
103 
104 		friend SIDX_DLL std::ostream& operator<<(std::ostream& os, const TimeRegion& r);
105 	}; // TimeRegion
106 
107 	typedef Tools::PoolPointer<TimeRegion> TimeRegionPtr;
108 	SIDX_DLL std::ostream& operator<<(std::ostream& os, const TimeRegion& r);
109 }
110