comparison OrthancStone/Sources/Toolbox/Windowing.cpp @ 2169:fe5406abd43f

added separate class Windowing
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 21 Oct 2024 15:40:34 +0200
parents
children
comparison
equal deleted inserted replaced
2168:14d6080660e7 2169:fe5406abd43f
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-2023 Osimis S.A., Belgium
6 * Copyright (C) 2021-2024 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 #include "Windowing.h"
25
26 #include "LinearAlgebra.h"
27
28
29 namespace OrthancStone
30 {
31 Windowing::Windowing(double center,
32 double width)
33 {
34 center_ = center;
35 width_ = std::abs(width);
36 }
37
38
39 void Windowing::GetBounds(double& low,
40 double& high) const
41 {
42 low = center_ - width_ / 2.0;
43 high = center_ + width_ / 2.0;
44 }
45
46
47 bool Windowing::IsNear(const Windowing& other) const
48 {
49 return (LinearAlgebra::IsNear(center_, other.center_) &&
50 LinearAlgebra::IsNear(width_, other.width_));
51 }
52 }