-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathResourceLoader.h
152 lines (125 loc) · 4.19 KB
/
ResourceLoader.h
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
/*
File: ResourceLoader.h
Created on: 11/05/2017
Author: Felix de las Pozas Alvarez
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef RESOURCELOADER_H_
#define RESOURCELOADER_H_
// VTK
#include <vtkSmartPointer.h>
// Qt
#include <QThread>
#include <QString>
#include <QList>
class vtkActor;
class vtkActor2D;
class vtkImageData;
class vtkVolume;
class vtkPlane;
class vtkPolyData;
/** \brief Loads the resources from disk and creates the actors. This class must be modified depending on
* the scene being rendered. Just loads resources, it's meant to separate loading from executing. And return
* only the objects meant not to be created mid-execution (permanent vtk pipelines).
*
*/
class ResourceLoaderThread
: public QThread
{
Q_OBJECT
public:
/** \brief ResourceLoaderThread class constructor.
* \param[in] parent raw pointer of the QObject owner of this one.
*
*/
explicit ResourceLoaderThread(QObject *parent = nullptr)
: m_abort{false}
{}
/** \brief ResourceLoaderThread class virtual destructor.
*
*/
virtual ~ResourceLoaderThread()
{}
/** \brief Returns the list of raw vtkImageData.
*
*/
const QList<vtkSmartPointer<vtkImageData>> images() const
{ return m_images; };
/** \brief Returns the list of vtk volumes.
*
*/
const QList<vtkSmartPointer<vtkVolume>> volumes() const
{ return m_volumes; }
/** \brief Returns the list of logos (2D actors).
*
*/
const QList<vtkSmartPointer<vtkActor2D>> logos() const
{ return m_logos; }
/** \brief Returns the list of 3D actors.
*
*/
const QList<vtkSmartPointer<vtkActor>> actors() const
{ return m_actors; }
/** \brief Returns the list of polydatas.
*
*/
const QList<vtkSmartPointer<vtkPolyData>> polyDatas() const
{ return m_polyDatas; }
/** \brief Returns the list of planes.
*
*/
const QList<vtkSmartPointer<vtkPlane>> planes() const
{ return m_planes; }
/** \brief Returns the error string.
*
*/
const QString getError() const
{ return m_error; }
/** \brief Aborts the loading and frees resources.
*
*/
void abort()
{ m_abort = true; }
const bool isAborted() const
{ return m_abort; }
protected:
virtual void run() override;
signals:
void finishedLoading();
private:
/** \brief Frees allocated resources.
*
*/
void freeResources();
/** \brief Modifies the error string.
* \param[in] message error message.
*
*/
void error(const QString &message)
{ m_error = message; }
/** \brief Helper method to load some resources. To be able to specify the resources to load.
*
*/
void volumeLoaderUCHAR();
void volumeLoaderUSHORT();
void meshLoader();
void imagePreprocessing();
QList<vtkSmartPointer<vtkImageData>> m_images; /** list of vtkImageData. */
QList<vtkSmartPointer<vtkPolyData>> m_polyDatas; /** list of mesh objects. */
QList<vtkSmartPointer<vtkVolume>> m_volumes; /** list of vtkVolume. */
QList<vtkSmartPointer<vtkActor2D>> m_logos; /** list of 2D actors. */
QList<vtkSmartPointer<vtkActor>> m_actors; /** list of 3D actors. */
QList<vtkSmartPointer<vtkPlane>> m_planes; /** list of planes. */
QString m_error; /** error message or empty if successful. */
bool m_abort; /** true if aborted, false otherwise. */
};
#endif // RESOURCELOADER_H_