forked from MedicalUltrasound/Image3dAPI
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.cpp
More file actions
65 lines (48 loc) · 1.67 KB
/
Copy pathMain.cpp
File metadata and controls
65 lines (48 loc) · 1.67 KB
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
#include "../Image3dAPI/ComSupport.hpp"
#include "../Image3dAPI/IImage3d.h"
#include "../Image3dAPI/RegistryCheck.hpp"
void ParseSource (IImage3dSource & source) {
Cart3dGeom geom = {};
CHECK(source.GetBoundingBox(&geom));
unsigned int frame_count = 0;
CHECK(source.GetFrameCount(&frame_count));
CComSafeArray<unsigned int> color_map;
{
SAFEARRAY * tmp = nullptr;
CHECK(source.GetColorMap(&tmp));
color_map.Attach(tmp);
tmp = nullptr;
}
for (unsigned int frame = 0; frame < frame_count; ++frame) {
unsigned short max_res[] = {64, 64, 64};
// retrieve frame data
Image3d data;
CHECK(source.GetFrame(frame, geom, max_res, &data));
}
}
int main () {
ComInitialize com(COINIT_MULTITHREADED);
CComBSTR progid(L"DummyLoader.Image3dFileLoader");
CLSID clsid = {};
CHECK(CLSIDFromProgID(progid, &clsid));
// verify that loader library is compatible
//CHECK(CheckImage3dAPIVersion(clsid)); // disabled, since it's not compatible with reg-free COM
// create loader without accessing the registry (possible since the DummyLoader manifest is linked in)
CComPtr<IImage3dFileLoader> loader;
CHECK(loader.CoCreateInstance(clsid));
{
// load file
CComBSTR filename = L"dummy.dcm";
Image3dError err_type = {};
CComBSTR err_msg;
CHECK(loader->LoadFile(filename, &err_type, &err_msg));
}
CComPtr<IImage3dSource> source;
CHECK(loader->GetImageSource(&source));
ProbeInfo probe;
CHECK(source->GetProbeInfo(&probe));
EcgSeries ecg;
CHECK(source->GetECG(&ecg));
ParseSource(*source);
return 0;
}