QCAD
Open Source 2D CAD
Loading...
Searching...
No Matches
LineSegment.h
Go to the documentation of this file.
1/******************************************************************************
2 * Project: libspatialindex - A C++ library for spatial indexing
3 * Author: Marios Hadjieleftheriou, [email protected]
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
30namespace SpatialIndex
31{
32 class SIDX_DLL LineSegment : public Tools::IObject, public virtual IShape
33 {
34 public:
36 LineSegment(const double* startPoint, const double* endPoint, uint32_t dimension);
37 LineSegment(const Point& startPoint, const Point& endPoint);
39 virtual ~LineSegment();
40
41 virtual LineSegment& operator=(const LineSegment& p);
42 virtual bool operator==(const LineSegment& p) const;
43
44 //
45 // IObject interface
46 //
47 virtual LineSegment* clone();
48
49 //
50 // ISerializable interface
51 //
52 virtual uint32_t getByteArraySize();
53 virtual void loadFromByteArray(const byte* data);
54 virtual void storeToByteArray(byte** data, uint32_t& length);
55
56 //
57 // IShape interface
58 //
59 virtual bool intersectsShape(const IShape& in) const;
60 virtual bool containsShape(const IShape& in) const;
61 virtual bool touchesShape(const IShape& in) const;
62 virtual void getCenter(Point& out) const;
63 virtual uint32_t getDimension() const;
64 virtual void getMBR(Region& out) const;
65 virtual double getArea() const;
66 virtual double getMinimumDistance(const IShape& in) const;
67
68 virtual bool intersectsLineSegment(const LineSegment& l) const;
69 virtual bool intersectsRegion(const Region& p) const;
70 virtual double getMinimumDistance(const Point& p) const;
71 //virtual double getMinimumDistance(const Region& r) const;
72 virtual double getRelativeMinimumDistance(const Point& p) const;
73 virtual double getRelativeMaximumDistance(const Region& r) const;
75
76 virtual void makeInfinite(uint32_t dimension);
77 virtual void makeDimension(uint32_t dimension);
78
79 public:
80 uint32_t m_dimension;
82 double* m_pEndPoint;
83
84 friend class Region;
85 friend class Point;
86 friend SIDX_DLL std::ostream& operator<<(std::ostream& os, const LineSegment& pt);
87
88 protected:
89
90 //some helpers for intersects methods
91 static double doubleAreaTriangle(const Point& a, const Point& b, const Point& c);
92 static bool leftOf(const Point& a, const Point& b, const Point& c);
93 static bool collinear(const Point& a, const Point& b, const Point& c);
94 static bool between(const Point& a, const Point& b, const Point& c);
95 static bool between(double a, double b, double c);
96 static bool intersectsProper(const Point& a, const Point& b, const Point& c, const Point& d);
97 static bool intersects(const Point& a, const Point& b, const Point& c, const Point& d);
98
99 }; // LineSegment
100
101 SIDX_DLL std::ostream& operator<<(std::ostream& os, const LineSegment& pt);
102}
103
Definition SpatialIndex.h:68
Definition LineSegment.h:33
double * m_pEndPoint
Definition LineSegment.h:82
virtual double getAngleOfPerpendicularRay()
static bool intersects(const Point &a, const Point &b, const Point &c, const Point &d)
virtual LineSegment * clone()
LineSegment(const Point &startPoint, const Point &endPoint)
virtual bool operator==(const LineSegment &p) const
static double doubleAreaTriangle(const Point &a, const Point &b, const Point &c)
LineSegment(const LineSegment &l)
virtual double getRelativeMaximumDistance(const Region &r) const
static bool intersectsProper(const Point &a, const Point &b, const Point &c, const Point &d)
virtual bool touchesShape(const IShape &in) const
friend SIDX_DLL std::ostream & operator<<(std::ostream &os, const LineSegment &pt)
virtual LineSegment & operator=(const LineSegment &p)
virtual bool intersectsLineSegment(const LineSegment &l) const
static bool collinear(const Point &a, const Point &b, const Point &c)
virtual bool intersectsShape(const IShape &in) const
virtual double getArea() const
virtual void storeToByteArray(byte **data, uint32_t &length)
virtual void makeDimension(uint32_t dimension)
virtual void getCenter(Point &out) const
virtual double getMinimumDistance(const Point &p) const
uint32_t m_dimension
Definition LineSegment.h:80
virtual void makeInfinite(uint32_t dimension)
static bool between(const Point &a, const Point &b, const Point &c)
virtual void getMBR(Region &out) const
double * m_pStartPoint
Definition LineSegment.h:81
static bool between(double a, double b, double c)
static bool leftOf(const Point &a, const Point &b, const Point &c)
virtual double getMinimumDistance(const IShape &in) const
virtual void loadFromByteArray(const byte *data)
LineSegment(const double *startPoint, const double *endPoint, uint32_t dimension)
virtual double getRelativeMinimumDistance(const Point &p) const
virtual uint32_t getDimension() const
virtual uint32_t getByteArraySize()
virtual bool intersectsRegion(const Region &p) const
virtual bool containsShape(const IShape &in) const
Definition Point.h:35
Definition Region.h:33
Definition Tools.h:215
Definition CustomStorage.h:34
SIDX_DLL std::ostream & operator<<(std::ostream &os, const LineSegment &pt)
#define SIDX_DLL
Definition sidx_export.h:41