Mercurial > hg > orthanc-stone
comparison OrthancStone/Sources/Toolbox/Internals/OrientedIntegerLine2D.h @ 1874:08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 11 Jan 2022 18:58:37 +0100 |
parents | |
children | b1f510e601d2 |
comparison
equal
deleted
inserted
replaced
1873:e0966648ebd0 | 1874:08f2476e8f5e |
---|---|
1 /** | |
2 * Stone of Orthanc | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
5 * Copyright (C) 2017-2022 Osimis S.A., Belgium | |
6 * Copyright (C) 2021-2022 Sebastien Jodogne, ICTEAM UCLouvain, Belgium | |
7 * | |
8 * This program is free software: you can redistribute it and/or | |
9 * modify it under the terms of the GNU Lesser General Public License | |
10 * as published by the Free Software Foundation, either version 3 of | |
11 * the License, or (at your option) any later version. | |
12 * | |
13 * This program is distributed in the hope that it will be useful, but | |
14 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
16 * Lesser General Public License for more details. | |
17 * | |
18 * You should have received a copy of the GNU Lesser General Public | |
19 * License along with this program. If not, see | |
20 * <http://www.gnu.org/licenses/>. | |
21 **/ | |
22 | |
23 | |
24 #pragma once | |
25 | |
26 #include <vector> | |
27 #include <list> | |
28 | |
29 | |
30 namespace OrthancStone | |
31 { | |
32 namespace Internals | |
33 { | |
34 /** | |
35 * This is an oriented 2D line with unsigned integer coordinates. | |
36 **/ | |
37 class OrientedIntegerLine2D | |
38 { | |
39 private: | |
40 size_t x1_; | |
41 size_t y1_; | |
42 size_t x2_; | |
43 size_t y2_; | |
44 | |
45 public: | |
46 OrientedIntegerLine2D(size_t x1, | |
47 size_t y1, | |
48 size_t x2, | |
49 size_t y2); | |
50 | |
51 bool IsVertical() const | |
52 { | |
53 return (x1_ == x2_); | |
54 } | |
55 | |
56 bool IsHorizontal() const | |
57 { | |
58 return (y1_ == y2_); | |
59 } | |
60 | |
61 bool IsEmpty() const | |
62 { | |
63 return (x1_ == x2_ && | |
64 y1_ == y2_); | |
65 } | |
66 | |
67 size_t GetX1() const | |
68 { | |
69 return x1_; | |
70 } | |
71 | |
72 size_t GetY1() const | |
73 { | |
74 return y1_; | |
75 } | |
76 | |
77 size_t GetX2() const | |
78 { | |
79 return x2_; | |
80 } | |
81 | |
82 size_t GetY2() const | |
83 { | |
84 return y2_; | |
85 } | |
86 | |
87 bool IsDownward() const | |
88 { | |
89 return (y1_ < y2_); | |
90 } | |
91 | |
92 typedef std::list< std::pair<size_t, size_t> > Chain; | |
93 | |
94 static void ExtractChains(std::list<Chain>& chains, | |
95 const std::vector<OrientedIntegerLine2D>& edges); | |
96 }; | |
97 } | |
98 } |