-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathMain.cpp
82 lines (63 loc) · 2.28 KB
/
Main.cpp
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
#include "../Image3dAPI/ComSupport.hpp"
#include "../Image3dAPI/IImage3d.h"
#include "../Image3dAPI/RegistryCheck.hpp"
#include <iostream>
void ParseSource (IImage3dSource & source) {
CComSafeArray<uint32_t> color_map;
{
SAFEARRAY * tmp = nullptr;
CHECK(source.GetColorMap(&tmp));
color_map.Attach(tmp);
tmp = nullptr;
}
Cart3dGeom bbox = {};
CHECK(source.GetBoundingBox(&bbox));
unsigned int frame_count = 0;
CHECK(source.GetFrameCount(&frame_count));
std::wcout << L"Frame count: " << frame_count << L"\n";
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, bbox, max_res, &data));
}
}
int wmain (int argc, wchar_t *argv[]) {
if (argc < 3) {
std::wcout << L"Usage:\n";
std::wcout << L"RegFreeTest.exe <loader-progid> <filename>" << std::endl;
return -1;
}
CComBSTR progid = argv[1]; // e.g. "DummyLoader.Image3dFileLoader"
CComBSTR filename = argv[2];
ComInitialize com(COINIT_MULTITHREADED);
CLSID clsid = {};
if (FAILED(CLSIDFromProgID(progid, &clsid))) {
std::wcerr << L"ERRORR: Unknown progid " << progid.m_str << L"\n";
return -1;
}
// 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)
std::wcout << L"Creating loader " << progid.m_str << L"...\n";
CComPtr<IImage3dFileLoader> loader;
CHECK(loader.CoCreateInstance(clsid));
{
// load file
Image3dError err_type = {};
CComBSTR err_msg;
HRESULT hr = loader->LoadFile(filename, &err_type, &err_msg);
if (FAILED(hr)) {
std::wcerr << L"LoadFile failed: code=" << err_type << L", message=" << err_msg.m_str << std::endl;
return -1;
}
}
CComPtr<IImage3dSource> source;
CHECK(loader->GetImageSource(&source));
ProbeInfo probe;
CHECK(source->GetProbeInfo(&probe));
EcgSeries ecg;
CHECK(source->GetECG(&ecg));
ParseSource(*source);
return 0;
}