30 const double r = (double)((cluster_index * 23) % 19) / 18.0;
31 const double g = (double)((cluster_index * 23) % 7) / 6.0;
32 const double b = (double)((cluster_index * 23) % 3) / 2.0;
33 uint8_t r2 = (uint8_t)(r * 255);
34 uint8_t g2 = (uint8_t)(g * 255);
35 uint8_t b2 = (uint8_t)(b * 255);
36 unsigned long rgb_hex = (r2 << 16) | (g2 << 8) | b2;
48 for (std::vector<Point>::const_iterator p = cloud.begin(); p != cloud.end(); ++p) {
51 }
else if (max.
x < p->x) {
56 }
else if (max.
y < p->y) {
61 }
else if (max.
z < p->z) {
78 std::ofstream of(fname);
80 bool is2d = cloud.
is2d();
82 std::cerr <<
"[Error] could not save under '" << fname << std::endl;
93 of <<
"set xrange [" << min.
x <<
":" << max.
x <<
"]\n";
95 of <<
"set xrange [" << (min.
x - 1.0) <<
":" << (max.
x + 1.0) <<
"]\n";
98 of <<
"set yrange [" << min.
y <<
":" << max.
y <<
"]\n";
100 of <<
"set yrange [" << (min.
y - 1.0) <<
":" << (max.
y + 1.0) <<
"]\n";
103 of <<
"set zrange [" << min.
z <<
":" << max.
z <<
"]\n ";
105 of <<
"set zrange [" << (min.
z - 1.0) <<
":" << (max.
z + 1.0) <<
"]\n ";
114 of <<
"'-' with points lc 'black' title 'original', '-' with points lc "
115 "'red' title 'smoothed'\n";
116 for (PointCloud::const_iterator it = cloud.begin(); it != cloud.end(); ++it) {
117 of << it->x <<
" " << it->y;
124 for (PointCloud::const_iterator it = cloud_smooth.begin(); it != cloud_smooth.end(); ++it) {
125 of << it->x <<
" " << it->y;
130 of <<
"e\npause mouse keypress\n";
143 std::ofstream of(fname);
145 bool is2d = cloud.
is2d();
147 std::cerr <<
"[Error] could not save under '" << fname << std::endl;
150 of <<
"# x,y,z" << std::endl;
151 for (PointCloud::const_iterator it = cloud.begin(); it != cloud.end(); ++it) {
152 of << it->x <<
"," << it->y;
154 of <<
"," << it->z << std::endl;
167 std::vector<Point> points = cloud;
168 std::ostringstream pointstream, header, noise, clstream;
169 std::string noiseheader =
"";
170 bool is2d = cloud.
is2d();
172 pointstream << std::fixed;
173 header << std::fixed;
183 header <<
"set xrange [" << min.
x <<
":" << max.
x <<
"]\n";
185 header <<
"set xrange [" << (min.
x - 1.0) <<
":" << (max.
x + 1.0) <<
"]\n";
188 header <<
"set yrange [" << min.
y <<
":" << max.
y <<
"]\n";
190 header <<
"set yrange [" << (min.
y - 1.0) <<
":" << (max.
y + 1.0) <<
"]\n";
194 header <<
"set zrange [" << min.
z <<
":" << max.
z <<
"]\nsplot ";
196 header <<
"set zrange [" << (min.
z - 1.0) <<
":" << (max.
z + 1.0) <<
"]\nsplot ";
205 for (
size_t cluster_index = 0; cluster_index < clusters.size(); ++cluster_index) {
206 const std::vector<size_t> &point_indices = clusters[cluster_index];
209 if (point_indices.size() == 0)
213 clstream <<
" '-' with points lc '#" << std::hex << rgb_hex;
214 std::set<size_t> cluster_ids = cloud[point_indices[0]].cluster_ids;
215 if (cluster_ids.size() > 1) {
216 clstream <<
"' title 'overlap ";
217 for (std::set<size_t>::const_iterator clid = cluster_ids.begin(); clid != cluster_ids.end(); ++clid) {
218 if (clid != cluster_ids.begin())
223 clstream <<
"' title 'curve " << *cluster_ids.begin();
228 for (std::vector<size_t>::const_iterator it = point_indices.begin(); it != point_indices.end(); ++it) {
229 const Point &point = cloud[*it];
232 for (std::vector<Point>::iterator p = points.begin(); p != points.end(); p++) {
238 pointstream << point.
x <<
" " << point.
y;
240 pointstream <<
" " << point.
z;
241 pointstream << std::endl;
243 pointstream <<
"e" << std::endl;
245 clstream << std::endl;
248 if (points.size() > 0) {
249 noiseheader =
" '-' with points lc 'red' title 'noise',";
250 for (std::vector<Point>::iterator it = points.begin(); it != points.end(); ++it) {
251 noise << it->x <<
" " << it->y;
253 noise <<
" " << it->z;
256 noise <<
"e" << std::endl;
259 std::cout << header.str() << noiseheader << clstream.str() << noise.str() << pointstream.str()
260 <<
"pause mouse keypress\n";
272 bool is2d = cloud.
is2d();
273 std::cout << std::fixed <<
"# Comment: curveID -1 represents noise\n# x, y, z, curveID\n";
275 for (PointCloud::const_iterator it = cloud.begin(); it != cloud.end(); ++it) {
276 std::cout << it->x <<
"," << it->y <<
",";
278 std::cout << it->z <<
",";
279 if (it->cluster_ids.empty()) {
283 for (std::set<size_t>::const_iterator it2 = it->cluster_ids.begin(); it2 != it->cluster_ids.end(); ++it2) {
284 if (it2 != it->cluster_ids.begin()) {
289 std::cout << std::endl;