openPSTD  2.0
Open source simulation for sound propagation in urban environments
Edges.h
1 // This file is part of openPSTD. //
3 // //
4 // openPSTD is free software: you can redistribute it and/or modify //
5 // it under the terms of the GNU General Public License as published by //
6 // the Free Software Foundation, either version 3 of the License, or //
7 // (at your option) any later version. //
8 // //
9 // openPSTD is distributed in the hope that it will be useful, //
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of //
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
12 // GNU General Public License for more details. //
13 // //
14 // You should have received a copy of the GNU General Public License //
15 // along with openPSTD. If not, see <http://www.gnu.org/licenses/>. //
16 // //
18 
20 //
21 // Date: 24-9-2015
22 //
23 //
24 // Authors: M. R. Fortuin
25 //
26 //
27 // Purpose:
28 //
29 //
31 
32 #ifndef OPENPSTD_EDGES_H
33 #define OPENPSTD_EDGES_H
34 
35 #include <vector>
36 #include <QVector2D>
37 
38 namespace OpenPSTD
39 {
40  namespace GUI
41  {
46  class Edge
47  {
48  private:
49  QVector2D _start, _end;
50  float _absorption;
51  bool _localReacting;
52 
53  float StartInDim() const;
54 
55  float EndInDim() const;
56 
57  Edge CreateInSameDim(float start, float end) const;
58 
59  float PosInDim(int dim) const;
60 
61  public:
62  Edge(float PosInDim, int dim, float start, float end, float absorption, bool localReacting);
63 
64  Edge(QVector2D start, QVector2D end, float absorption, bool localReacting);
65 
66  bool IsOnlyInDim(int dim) const;
67 
68  bool IsVertical() const;
69 
70  bool IsHorizontal() const;
71 
72  QVector2D GetStart() const;
73 
74  QVector2D GetEnd() const;
75 
76  float GetAbsorption() const;
77 
78  float GetLocalReacting() const;
79 
83  bool OnSameLine(const Edge &edge) const;
84 
85  static bool OnSameLine(const Edge &edge1, const Edge &edge2);
86 
87  std::vector<Edge> Substract(const Edge &edge) const;
88 
89  static std::vector<Edge> SubstractEdgeFromList(std::vector<Edge> edges, Edge rhs);
90 
91  static std::vector<Edge> SubstractListFromList(std::vector<Edge> lhs, std::vector<Edge> rhs);
92 
93  static std::vector<Edge> SubstractListFromEdge(Edge lhs, std::vector<Edge> rhs);
94 
95  static std::vector<Edge> SubstractListFromEdge(Edge lhs, std::vector<Edge> rhs,
96  std::vector<int> exceptIndices);
97  };
98 
99  }
100 }
101 
102 #endif //OPENPSTD_EDGES_H
This is the general namespace of the OpenPSTD application.
Definition: Boundary.cpp:33
bool OnSameLine(const Edge &edge) const
Tests if the 2 edges are on the same line.
Definition: Edges.cpp:110
This class is specificaly for horizontal edges and vertical edges.
Definition: Edges.h:46