File: poolseries.cpp

package info (click to toggle)
aeskulap 0.2.2b1%2Bgit20161206-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 3,840 kB
  • ctags: 1,302
  • sloc: cpp: 8,894; sh: 5,551; ansic: 685; makefile: 317; xml: 25
file content (111 lines) | stat: -rw-r--r-- 2,461 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
/*
    Aeskulap ImagePool - DICOM abstraction library
    Copyright (C) 2005  Alexander Pipelka

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Library General Public License for more details.

    You should have received a copy of the GNU Library General Public
    License along with this library; if not, write to the Free
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA

    Alexander Pipelka
*/

#include "poolseries.h"
#include "imagepool.h"
#include <cmath>

namespace ImagePool {

Series::Series() :
m_instancecount(-1)
{
}

Series::~Series() {
	for(iterator i = begin(); i != end(); i++) {
		i->second.clear();
	}
	m_list.clear();
}

const std::string& Series::seriesinstanceuid() {
	return m_seriesinstanceuid;
}

const std::string& Series::institutionname() {
	return m_institutionname;
}

const std::string& Series::description() {
	return m_description;
}

const std::string& Series::modality() {
	return m_modality;
}

const std::string& Series::seriestime() {
	return m_seriestime;
}

const std::string& Series::stationname() {
	return m_stationname;
}

int Series::instancecount() {
	if(m_instancecount != -1) {
		return m_instancecount;
	}
	
	return m_list.size();
}

bool Series::has_3d_information() {
	if(m_list.size() == 0) {
		return false;
	}
	
	return begin()->second->has_3d_information();
}

Glib::RefPtr<ImagePool::Instance> Series::find_nearest_instance(const Instance::Point& p) {
	Instance::Point v;
	Instance::Point r;
	double min = 1000000;
	Glib::RefPtr<ImagePool::Instance> result;
	
	for(iterator i = begin(); i != end(); i++) {
		
		// transform world point p into viewport coordinate v
		if(!i->second->transform_to_viewport(p, v)) {
			continue;
		}
		
		// transform viewport coord. to world
		if(!i->second->transform_to_world(v, r)) {
			continue;
		}

		// get distance p - r
		double d = sqrt(pow(p.x - r.x, 2) + pow(p.y - r.y, 2) + pow(p.z - r.z, 2));
		
		// new minimum =
		if(d < min) {
			min = d;
			result = i->second;
		}
	}

	return result;
}

}