Fishnet 2.0.1
Framework for Graph-Based Analysis of GIS Vector Data
Loading...
Searching...
No Matches
IRay.hpp
Go to the documentation of this file.
1#pragma once
2#include "GeometryBase.hpp"
3#include "IPoint.hpp"
4#include "ILine.hpp"
5
6namespace fishnet::geometry::__impl{
7template<typename T>
8class RayStub{
9public:
10 using numeric_type = T;
11 constexpr static GeometryType type = GeometryType::RAY;
12 PointStub<T> origin() const{
13 return PointStub<T>(0,0);
14 }
15 PointStub<T> direction() const{
16 return PointStub<T>(1,1);
17 }
18 RayStub(PointStub<T> origin, PointStub<T> direction){}
19 bool operator==(const RayStub & other) const noexcept{
20 return true;
21 }
22 RayStub<T> oppositeRay() const{
23 return RayStub(origin(), -direction());
24 }
25 RayStub<T> operator-() const{
26 return oppositeRay();
27 }
28 bool isParallel(LineStub<T> line) const{
29 return true;
30 }
31 bool isParallel(RayStub<T> ray) const{
32 return true;
33 }
34 bool intersects(LineStub<T> line) const{
35 return true;
36 }
37 bool intersects(RayStub<T> ray) const{
38 return true;
39 }
40 bool contains(PointStub<T> point) const{
41 return true;
42 }
43 fishnet::Option<PointStub<double>> intersection(LineStub<T> line) const{
44 return {};
45 }
46 fishnet::Option<PointStub<double>> intersection(RayStub ray) const{
47 return {};
48 }
49 LineStub<T> toLine() const{
50 return LineStub(origin(), origin()+direction());
51 }
52 size_t hash() const noexcept {
53 return 0;
54 }
55 std::string toString() const{
56 return {};
57 }
58};
59} // namespace fishnet::geometry::__impl
60
61namespace fishnet::geometry{
62
68template<typename R>
69concept IRay = GeometryBase<R> && requires(
70 const std::remove_cvref_t<R> & ray,
71 const __impl::RayStub<typename std::remove_cvref_t<R>::numeric_type> & otherRay,
72 const __impl::PointStub<typename std::remove_cvref_t<R>::numeric_type> & point,
73 const __impl::LineStub<typename std::remove_cvref_t<R>::numeric_type> & line
74){
75 {ray.origin()} -> IPoint;
76 {ray.direction()} -> IPoint;
77 {ray.oppositeRay()} -> std::same_as<std::remove_cvref_t<R>>; // returns new ray with the direction vector flipped
78 {-ray} -> std::same_as<std::remove_cvref_t<R>>; // returns new ray with the direction vector flipped
79 {ray.isParallel(line)} -> std::same_as<bool>;
80 {ray.isParallel(otherRay)} -> std::same_as<bool>;
81 {ray.intersects(line)} -> std::same_as<bool>;
82 {ray.intersects(otherRay)} -> std::same_as<bool>;
83 {ray.contains(point)} -> std::same_as<bool>;
84 {ray.intersection(line)} -> IPointOptional;
85 {ray.intersection(otherRay)} -> IPointOptional;
86 {ray.toLine()} -> ILine;
87};
88
89static_assert(IRay<__impl::RayStub<double>>);
90static_assert(IRay<__impl::RayStub<int>>);
91} // namespace fishnet::geometry
Definition Option.hpp:13
IPolygon implementation backed by an OGRPolygon.
Definition OGRPolygonAdapter.hpp:22
Definition GeometryBase.hpp:11
Interface for a line A line is defined through two points p and q, defining a direction vector.
Definition ILine.hpp:76
Definition IPoint.hpp:135
Interface for a point.
Definition IPoint.hpp:92
Interface for a ray A ray is defined through its origin and a direction.
Definition IRay.hpp:69
Definition BoundingBoxWrapper.hpp:5