-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathScanFactory.cc
126 lines (103 loc) · 2.63 KB
/
ScanFactory.cc
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
// ScanFactory.cc Create objects of individual scan classes
// created 11/26/98 Matt Ginzton (magi@cs)
//
// No other file but this one should need to reference any *Scan except
// at the RigidScan level.
#include "Mesh.h"
#include "GenericScan.h"
#include "CyberScan.h"
#include "CyraScan.h"
#include "MMScan.h"
#include "SyntheticScan.h"
#include "GroupScan.h"
#include "ProxyScan.h"
RigidScan*
CreateScanFromGeometry (const vector<Pnt3>& vtx,
const vector<int>& tris,
const crope& name)
{
Mesh* mesh = new Mesh (vtx, tris);
GenericScan* gs = new GenericScan (mesh, name);
return gs;
}
static bool
has_ending(const crope& filename, const crope& ending)
{
int lenf = filename.size();
int lene = ending.size();
if (lenf <= lene)
return FALSE;
return (ending == filename.substr (lenf - lene, lenf));
}
RigidScan*
CreateScanFromFile (const crope& filename)
{
RigidScan *scan = NULL;
if (has_ending(filename, ".ply"))
scan = new GenericScan;
else if (has_ending(filename, ".ply.gz"))
scan = new GenericScan;
else if (has_ending(filename, ".set"))
scan = new GenericScan;
else if (has_ending(filename, ".sd"))
scan = new CyberScan;
else if (has_ending(filename, ".sd.gz"))
scan = new CyberScan;
else if (has_ending(filename, ".cta"))
scan = new MMScan;
else if (has_ending(filename, ".mms"))
scan = new MMScan;
else if (has_ending(filename, ".pts"))
scan = new CyraScan;
else
scan = new GenericScan;
if (scan) {
if (!scan->read (filename)) {
delete scan;
scan = NULL;
}
}
return scan;
}
RigidScan*
CreateScanFromThinAir (float size, int type)
{
// note -- types not supported; just for future options
RigidScan* scan = new SyntheticScan (size);
return scan;
}
RigidScan*
CreateScanGroup (const vector<DisplayableMesh*>& members, const char *nameToUse, bool bDirty)
{
RigidScan* scan = new GroupScan (members, bDirty);
scan->set_name (strdup(nameToUse));
return scan;
}
vector<DisplayableMesh*>
BreakScanGroup (RigidScan* scan)
{
vector<DisplayableMesh*> members;
GroupScan* group = dynamic_cast<GroupScan*> (scan);
if (group) {
if (group->get_children_for_display (members)) {
// STL Update
for (vector<DisplayableMesh*>::iterator mem = members.begin();
mem < members.end(); mem++) {
group->RemoveScan (*mem);
}
}
} else {
members.clear();
}
return members;
}
RigidScan*
CreateScanFromBbox (const crope& name, const Pnt3& min, const Pnt3& max)
{
return new ProxyScan (name, min, max);
}
bool
isScanLoaded (const RigidScan* scan)
{
return dynamic_cast<const ProxyScan*> (scan) == NULL;
}