-
Notifications
You must be signed in to change notification settings - Fork 0
/
SegmentedObject.cpp
113 lines (77 loc) · 2.01 KB
/
SegmentedObject.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
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
#include "SegmentedObject.h"
using namespace VirtualRobot;
namespace SimoxCGAL {
SegmentedObject::SegmentedObject()
{
}
SegmentedObject::~SegmentedObject()
{
}
void SegmentedObject::addObjectPart(ObjectPartPtr part)
{
parts.push_back(part);
}
void SegmentedObject::addObjectParts(std::vector<ObjectPartPtr> parts)
{
for (auto p:parts)
{
this->parts.push_back(p);
}
}
std::vector<ObjectPartPtr> SegmentedObject::getObjectParts()
{
return parts;
}
void SegmentedObject::addParameterDouble(const std::string &key, double value)
{
parametersDouble[key] = value;
}
bool SegmentedObject::hasParamterDouble(const std::string &key)
{
return parametersDouble.find(key) != parametersDouble.end();
}
bool SegmentedObject::getParameterDouble(const std::string &key, double &storeValue)
{
if (!hasParamterDouble(key))
return false;
storeValue = parametersDouble[key];
return true;
}
void SegmentedObject::addParameterString(const std::string &key, const std::string &value)
{
parametersString[key] = value;
}
bool SegmentedObject::hasParamterString(const std::string &key)
{
return parametersString.find(key) != parametersString.end();
}
bool SegmentedObject::getParameterString(const std::string &key, std::string &storeValue)
{
if (!hasParamterString(key))
return false;
storeValue = parametersString[key];
return true;
}
std::string SegmentedObject::toXML(int nrTabs)
{
std::string t;
std::string ta = "\t";
for (int i=0;i<nrTabs;i++)
t += "\t";
std::stringstream ss;
ss << t << "<SimoxCGAL-SegmentedObject>\n";
std::string key = "method";
std::string method;
if (!getParameterString(key, method))
{
VR_ERROR << "No segmentation method found." << endl;
}
ss << t << ta << "<Method method='" << method << "'/>\n";
for (size_t i = 0; i < parts.size(); i++)
{
ss << parts.at(i)->toXML(nrTabs + 1);
}
ss << t << "</SimoxCGAL-SegmentedObject>\n";
return ss.str();
}
}