MeVisLab Toolbox Reference
mlPCLSupportTools.h
Go to the documentation of this file.
1// Copyright (c) Fraunhofer MEVIS, Germany. All rights reserved.
2// **InsertLicense** code author="Wolf Spindler"
3//----------------------------------------------------------------------------------
5
12//----------------------------------------------------------------------------------
13#pragma once
14
15#include "MLPCLSupportSystem.h"
16#include <mlPCLTypes.h>
17#include <mlModuleIncludes.h>
19
21
22class SubImage;
23class PagedImage;
24
26namespace PCLSupportTools {
27
28//----------------------------------------------------------------------------------
31//----------------------------------------------------------------------------------
33
34//----------------------------------------------------------------------------------
37//----------------------------------------------------------------------------------
39
40//----------------------------------------------------------------------------------
42//----------------------------------------------------------------------------------
43inline Eigen::Vector3f castToEigenVector3f(const Vector3 &mlVec)
44{
45 return Eigen::Vector3f(static_cast<float>(mlVec[0]),
46 static_cast<float>(mlVec[1]),
47 static_cast<float>(mlVec[2]));
48}
49
50//----------------------------------------------------------------------------------
52//----------------------------------------------------------------------------------
53inline Eigen::Vector4f castToEigenVector4f(const Vector4 &mlVec)
54{
55 return Eigen::Vector4f(static_cast<float>(mlVec[0]),
56 static_cast<float>(mlVec[1]),
57 static_cast<float>(mlVec[2]),
58 static_cast<float>(mlVec[3]));
59}
60
61//----------------------------------------------------------------------------------
64//----------------------------------------------------------------------------------
65MLPCLSUPPORT_EXPORT void castToStdVector(const Eigen::VectorXf& eigenVec, std::vector<MLfloat>& stdVec);
66
67//----------------------------------------------------------------------------------
71//----------------------------------------------------------------------------------
72// Adapt this if a new PCL point type is integrated in the MeVisLab binding.
73MLPCLSUPPORT_EXPORT std::string getPCLPointAsString(const pcl::PointXYZ &point, int numDecimalPlaces=-1);
74MLPCLSUPPORT_EXPORT std::string getPCLPointAsString(const pcl::PointXYZLNormal &point, int numDecimalPlaces=-1);
75MLPCLSUPPORT_EXPORT std::string getPCLPointAsString(const pcl::PointXYZRGBNormal &point, int numDecimalPlaces=-1);
76MLPCLSUPPORT_EXPORT std::string getPCLPointAsString(const pcl::PointXYZINormal &point, int numDecimalPlaces=-1);
78
79//----------------------------------------------------------------------------------
83// Adapt this if a new PCL point type is integrated in the MeVisLab binding.
84//----------------------------------------------------------------------------------
85MLPCLSUPPORT_EXPORT std::string getScalarMemberNameAsString(const pcl::PointXYZ &, size_t memberIdx);
86MLPCLSUPPORT_EXPORT std::string getScalarMemberNameAsString(const pcl::PointXYZLNormal &, size_t memberIdx);
87MLPCLSUPPORT_EXPORT std::string getScalarMemberNameAsString(const pcl::PointXYZRGBNormal &, size_t memberIdx);
88MLPCLSUPPORT_EXPORT std::string getScalarMemberNameAsString(const pcl::PointXYZINormal &, size_t memberIdx);
90
91
92//----------------------------------------------------------------------------------
95// Adapt this if a new PCL point type is integrated in the MeVisLab binding.
96//----------------------------------------------------------------------------------
97inline size_t getNumberOfScalarPointMembers(const pcl::PointXYZ &) { return 4; }
98inline size_t getNumberOfScalarPointMembers(const MLPointCloudXYZ &) { return 4; }
99inline size_t getNumberOfScalarPointMembers(const MLPointCloudXYZPtr &) { return 4; }
100
101inline size_t getNumberOfScalarPointMembers(const pcl::PointXYZLNormal &) { return 10; }
102inline size_t getNumberOfScalarPointMembers(const MLPointCloudXYZLNormal &) { return 10; }
103inline size_t getNumberOfScalarPointMembers(const MLPointCloudXYZLNormalPtr &) { return 10; }
104
105inline size_t getNumberOfScalarPointMembers(const pcl::PointXYZRGBNormal &) { return 10; }
106inline size_t getNumberOfScalarPointMembers(const MLPointCloudXYZRGBNormal &) { return 10; }
108
109inline size_t getNumberOfScalarPointMembers(const pcl::PointXYZINormal &) { return 10; }
110inline size_t getNumberOfScalarPointMembers(const MLPointCloudXYZINormal &) { return 10; }
111inline size_t getNumberOfScalarPointMembers(const MLPointCloudXYZINormalPtr &) { return 10; }
113
114//----------------------------------------------------------------------------------
116// Adapt this if a new PCL point type is integrated in the MeVisLab binding.
117//----------------------------------------------------------------------------------
118inline bool hasNormals(const pcl::PointXYZ &) { return false; }
119inline bool hasNormals(const MLPointCloudXYZ &) { return false; }
120inline bool hasNormals(const MLPointCloudXYZPtr &) { return false; }
121inline bool hasNormals(const pcl::PointXYZLNormal &) { return true; }
122inline bool hasNormals(const MLPointCloudXYZLNormal &) { return true; }
123inline bool hasNormals(const MLPointCloudXYZLNormalPtr &) { return true; }
124inline bool hasNormals(const pcl::PointXYZRGBNormal &) { return true; }
125inline bool hasNormals(const MLPointCloudXYZRGBNormal &) { return true; }
126inline bool hasNormals(const MLPointCloudXYZRGBNormalPtr&) { return true; }
127inline bool hasNormals(const pcl::PointXYZINormal &) { return true; }
128inline bool hasNormals(const MLPointCloudXYZINormal &) { return true; }
129inline bool hasNormals(const MLPointCloudXYZINormalPtr &) { return true; }
131
132//----------------------------------------------------------------------------------
136// Adapt this if a new PCL point type is integrated in the MeVisLab binding.
137//----------------------------------------------------------------------------------
138inline size_t getMaximumNumberOfScalarPointMembers() { return 10; }
139
140//----------------------------------------------------------------------------------
146// Adapt this if a new PCL point type is integrated in the MeVisLab binding.
147//----------------------------------------------------------------------------------
148MLPCLSUPPORT_EXPORT std::string getScalarMemberValueAsString(const pcl::PointXYZ &p,
149 size_t memberIdx,
150 int numDecimalPlaces=-1);
151MLPCLSUPPORT_EXPORT std::string getScalarMemberValueAsString(const pcl::PointXYZLNormal &p,
152 size_t memberIdx,
153 int numDecimalPlaces=-1);
154MLPCLSUPPORT_EXPORT std::string getScalarMemberValueAsString(const pcl::PointXYZRGBNormal &p,
155 size_t memberIdx,
156 int numDecimalPlaces=-1);
157MLPCLSUPPORT_EXPORT std::string getScalarMemberValueAsString(const pcl::PointXYZINormal &p,
158 size_t memberIdx,
159 int numDecimalPlaces=-1);
161
162//----------------------------------------------------------------------------------
168// Adapt this if a new PCL point type is integrated in the MeVisLab binding.
169//----------------------------------------------------------------------------------
171inline void setPointFromFields(pcl::PointXYZ &pnt, const std::vector<DoubleField*> &constantFields)
172{
173 pnt.x = static_cast<float>(constantFields[0]->getDoubleValue());
174 pnt.y = static_cast<float>(constantFields[1]->getDoubleValue());
175 pnt.z = static_cast<float>(constantFields[2]->getDoubleValue());
176 pnt.data[3] = static_cast<float>(constantFields[3]->getDoubleValue());
177}
178inline void setPointFromFields(pcl::PointXYZLNormal &pnt, const std::vector<DoubleField*> &constantFields)
179{
180 pnt.x = static_cast<float>(constantFields[0]->getDoubleValue());
181 pnt.y = static_cast<float>(constantFields[1]->getDoubleValue());
182 pnt.z = static_cast<float>(constantFields[2]->getDoubleValue());
183 pnt.data[3] = static_cast<float>(constantFields[3]->getDoubleValue());
184 pnt.normal_x = static_cast<float>(constantFields[4]->getDoubleValue());
185 pnt.normal_y = static_cast<float>(constantFields[5]->getDoubleValue());
186 pnt.normal_z = static_cast<float>(constantFields[6]->getDoubleValue());
187 pnt.data_n[3] = static_cast<float>(constantFields[7]->getDoubleValue());
188 pnt.curvature = static_cast<float>(constantFields[8]->getDoubleValue());
189 pnt.label = static_cast<std::uint32_t>(MLAbs(constantFields[9]->getDoubleValue())); // cast of neg float -> int is undefined.
190}
191inline void setPointFromFields(pcl::PointXYZRGBNormal &pnt, const std::vector<DoubleField*> &constantFields)
192{
193 pnt.x = static_cast<float>(constantFields[0]->getDoubleValue());
194 pnt.y = static_cast<float>(constantFields[1]->getDoubleValue());
195 pnt.z = static_cast<float>(constantFields[2]->getDoubleValue());
196 pnt.data[3] = static_cast<float>(constantFields[3]->getDoubleValue());
197 pnt.normal_x = static_cast<float>(constantFields[4]->getDoubleValue());
198 pnt.normal_y = static_cast<float>(constantFields[5]->getDoubleValue());
199 pnt.normal_z = static_cast<float>(constantFields[6]->getDoubleValue());
200 pnt.data_n[3] = static_cast<float>(constantFields[7]->getDoubleValue());
201 pnt.curvature = static_cast<float>(constantFields[8]->getDoubleValue());
202 pnt.rgb = static_cast<float>(constantFields[9]->getDoubleValue());
203}
204inline void setPointFromFields(pcl::PointXYZINormal &pnt, const std::vector<DoubleField*> &constantFields)
205{
206 pnt.x = static_cast<float>(constantFields[0]->getDoubleValue());
207 pnt.y = static_cast<float>(constantFields[1]->getDoubleValue());
208 pnt.z = static_cast<float>(constantFields[2]->getDoubleValue());
209 pnt.data[3] = static_cast<float>(constantFields[3]->getDoubleValue());
210 pnt.normal_x = static_cast<float>(constantFields[4]->getDoubleValue());
211 pnt.normal_y = static_cast<float>(constantFields[5]->getDoubleValue());
212 pnt.normal_z = static_cast<float>(constantFields[6]->getDoubleValue());
213 pnt.data_n[3] = static_cast<float>(constantFields[7]->getDoubleValue());
214 pnt.curvature = static_cast<float>(constantFields[8]->getDoubleValue());
215 pnt.intensity = static_cast<float>(constantFields[9]->getDoubleValue());
216}
218
219//----------------------------------------------------------------------------------
223// Adapt this if a new PCL point type is integrated in the MeVisLab binding.
224//----------------------------------------------------------------------------------
226inline void setPointFromScalar(pcl::PointXYZ &pnt, const float val)
227{
228 pnt.x = val;
229 pnt.y = val;
230 pnt.z = val;
231 pnt.data[3] = val;
232}
233inline void setPointFromScalar(pcl::PointXYZLNormal &pnt, const float val)
234{
235 pnt.x = val;
236 pnt.y = val;
237 pnt.z = val;
238 pnt.data[3] = val;
239 pnt.normal_x = val;
240 pnt.normal_y = val;
241 pnt.normal_z = val;
242 pnt.data_n[3] = val;
243 pnt.curvature = val;
244 pnt.label = static_cast<std::uint32_t>(MLAbs(val)); // Note: neg float -> uint is undefined.
245}
246inline void setPointFromScalar(pcl::PointXYZRGBNormal &pnt, const float val)
247{
248 pnt.x = val;
249 pnt.y = val;
250 pnt.z = val;
251 pnt.data[3] = val;
252 pnt.normal_x = val;
253 pnt.normal_y = val;
254 pnt.normal_z = val;
255 pnt.data_n[3] = val;
256 pnt.curvature = val;
257 pnt.rgb = val;
258}
259inline void setPointFromScalar(pcl::PointXYZINormal &pnt, const float val)
260{
261 pnt.x = val;
262 pnt.y = val;
263 pnt.z = val;
264 pnt.data[3] = val;
265 pnt.normal_x = val;
266 pnt.normal_y = val;
267 pnt.normal_z = val;
268 pnt.data_n[3] = val;
269 pnt.curvature = val;
270 pnt.intensity = val;
271}
273
274//----------------------------------------------------------------------------------
278// Adapt this if a new PCL point type is integrated in the MeVisLab binding.
279//----------------------------------------------------------------------------------
281inline void setFieldsFromPoint(const pcl::PointXYZ &pnt, std::vector<DoubleField*> &resultFields)
282{
283 resultFields[0]->setDoubleValue(pnt.x );
284 resultFields[1]->setDoubleValue(pnt.y );
285 resultFields[2]->setDoubleValue(pnt.z );
286 resultFields[3]->setDoubleValue(pnt.data[3]);
287}
288inline void setFieldsFromPoint(const pcl::PointXYZLNormal &pnt, std::vector<DoubleField*> &resultFields)
289{
290 resultFields[0]->setDoubleValue(pnt.x );
291 resultFields[1]->setDoubleValue(pnt.y );
292 resultFields[2]->setDoubleValue(pnt.z );
293 resultFields[3]->setDoubleValue(pnt.data[3] );
294 resultFields[4]->setDoubleValue(pnt.normal_x );
295 resultFields[5]->setDoubleValue(pnt.normal_y );
296 resultFields[6]->setDoubleValue(pnt.normal_z );
297 resultFields[7]->setDoubleValue(pnt.data_n[3]);
298 resultFields[8]->setDoubleValue(pnt.curvature);
299 resultFields[9]->setDoubleValue(static_cast<double>(pnt.label));
300}
301inline void setFieldsFromPoint(const pcl::PointXYZRGBNormal &pnt, std::vector<DoubleField*> &resultFields)
302{
303 resultFields[0]->setDoubleValue(pnt.x );
304 resultFields[1]->setDoubleValue(pnt.y );
305 resultFields[2]->setDoubleValue(pnt.z );
306 resultFields[3]->setDoubleValue(pnt.data[3] );
307 resultFields[4]->setDoubleValue(pnt.normal_x );
308 resultFields[5]->setDoubleValue(pnt.normal_y );
309 resultFields[6]->setDoubleValue(pnt.normal_z );
310 resultFields[7]->setDoubleValue(pnt.data_n[3]);
311 resultFields[8]->setDoubleValue(pnt.curvature);
312 resultFields[9]->setDoubleValue(pnt.rgb );
313}
314inline void setFieldsFromPoint(const pcl::PointXYZINormal &pnt, std::vector<DoubleField*> &resultFields)
315{
316 resultFields[0]->setDoubleValue(pnt.x );
317 resultFields[1]->setDoubleValue(pnt.y );
318 resultFields[2]->setDoubleValue(pnt.z );
319 resultFields[3]->setDoubleValue(pnt.data[3] );
320 resultFields[4]->setDoubleValue(pnt.normal_x );
321 resultFields[5]->setDoubleValue(pnt.normal_y );
322 resultFields[6]->setDoubleValue(pnt.normal_z );
323 resultFields[7]->setDoubleValue(pnt.data_n[3]);
324 resultFields[8]->setDoubleValue(pnt.curvature);
325 resultFields[9]->setDoubleValue(pnt.intensity);
326}
328
329//----------------------------------------------------------------------------------
331//----------------------------------------------------------------------------------
332template <typename PCL_OBJECT_PTR_TYPE>
334{
335 typedef typename PCL_OBJECT_PTR_TYPE::element_type PCL_OBJECT_TYPE;
337}
338
339// Adapt this if a new PCL point type is integrated in the MeVisLab binding.
341//----------------------------------------------------------------------------------
343//----------------------------------------------------------------------------------
350//----------------------------------------------------------------------------------
352//----------------------------------------------------------------------------------
359//----------------------------------------------------------------------------------
361//----------------------------------------------------------------------------------
368//----------------------------------------------------------------------------------
370//----------------------------------------------------------------------------------
377//----------------------------------------------------------------------------------
379//----------------------------------------------------------------------------------
387
388//----------------------------------------------------------------------------------
390//----------------------------------------------------------------------------------
392 Empty = 0, //<! An empty point cloud.
393 OriginPoint, //<! A point cloud with one point at (0,0,0).
394 Triangle, //<! A point cloud with the points (0,0,0), (1,0,0), (0,1,0).
395 Square, //<! A point cloud with the points (0,0,0), (1,0,0), (0,1,0), (1,1,0).
396 Cube //<! A point cloud with the points (0,0,0), (1,0,0), (0,1,0), (1,1,0),
397 //<! (0,0,1), (1,0,1), (0,1,1), (1,1,1).
399//----------------------------------------------------------------------------------
401//----------------------------------------------------------------------------------
402enum {
403 NumberOfPointCloudDefaultPatterns = 5
405
406//----------------------------------------------------------------------------------
408//----------------------------------------------------------------------------------
410 Fill = 0, //<! Fill with a given default value.
411 Indexed //<! Each point gets its index at data[3].
413//----------------------------------------------------------------------------------
415//----------------------------------------------------------------------------------
416enum {
417 NumberOfPointCloudFillPatterns = 2
419
420//----------------------------------------------------------------------------------
423//----------------------------------------------------------------------------------
424template <typename POINT_CLOUD_TYPE>
426 const Vector3f &pos,
427 float fillValue)
428{
429 typedef typename POINT_CLOUD_TYPE::PointType POINT_TYPE;
431 newPoint.x = pos.x;
432 newPoint.y = pos.y;
433 newPoint.z = pos.z;
434 newPoint.data[3] = fillValue;
435 pc.push_back(newPoint);
436}
437
438//----------------------------------------------------------------------------------
441//----------------------------------------------------------------------------------
442template <typename POINT_CLOUD_TYPE>
446 float fillValue=0.f)
447{
448 // Counter for added points.
449 float index = 0;
450 bool useFillVal=false;
451 switch(fillMode){
452 case Fill: useFillVal=true; break;
453 case Indexed: useFillVal=false; break;
454 default:
455 ML_PRINT_ERROR("mlPCLMLTools.cpp: appendFillPattern", ML_BAD_PARAMETER,
456 "Bad fill mode, using fillMode 'Fill'.");
457 break;
458 }
459
460 switch (pattern){
461 case Empty: break;
462 case OriginPoint:
463 appendPoint(pc, Vector3f(0,0,0), useFillVal ? fillValue : index); index+=1.f;
464 break;
465 case Triangle:
466 appendPoint(pc, Vector3f(0,0,0), useFillVal ? fillValue : index); index+=1.f;
467 appendPoint(pc, Vector3f(1,0,0), useFillVal ? fillValue : index); index+=1.f;
468 appendPoint(pc, Vector3f(0,1,0), useFillVal ? fillValue : index); index+=1.f;
469 break;
470 case Square:
471 appendPoint(pc, Vector3f(0,0,0), useFillVal ? fillValue : index); index+=1.f;
472 appendPoint(pc, Vector3f(1,0,0), useFillVal ? fillValue : index); index+=1.f;
473 appendPoint(pc, Vector3f(0,1,0), useFillVal ? fillValue : index); index+=1.f;
474 appendPoint(pc, Vector3f(1,1,0), useFillVal ? fillValue : index); index+=1.f;
475 break;
476 case Cube:
477 appendPoint(pc, Vector3f(0,0,0), useFillVal ? fillValue : index); index+=1.f;
478 appendPoint(pc, Vector3f(1,0,0), useFillVal ? fillValue : index); index+=1.f;
479 appendPoint(pc, Vector3f(0,1,0), useFillVal ? fillValue : index); index+=1.f;
480 appendPoint(pc, Vector3f(1,1,0), useFillVal ? fillValue : index); index+=1.f;
481 appendPoint(pc, Vector3f(0,0,1), useFillVal ? fillValue : index); index+=1.f;
482 appendPoint(pc, Vector3f(1,0,1), useFillVal ? fillValue : index); index+=1.f;
483 appendPoint(pc, Vector3f(0,1,1), useFillVal ? fillValue : index); index+=1.f;
484 appendPoint(pc, Vector3f(1,1,1), useFillVal ? fillValue : index); index+=1.f;
485 break;
486 default:
487 ML_PRINT_ERROR("mlPCLMLTools.cpp: appendFillPattern", ML_BAD_PARAMETER,
488 "Bad fill pattern, could not add points to point cloud.");
489 break;
490 }
491}
492
493//----------------------------------------------------------------------------------
495//----------------------------------------------------------------------------------
496inline bool fourFloatsDiffer(const float data1[4],
497 const float data2[4],
498 double epsilon=FLT_EPSILON)
499{
500 return ((MLAbs(data1[0] - data2[0]) >= epsilon) ||
501 (MLAbs(data1[1] - data2[1]) >= epsilon) ||
502 (MLAbs(data1[2] - data2[2]) >= epsilon) ||
503 (MLAbs(data1[3] - data2[3]) >= epsilon) );
504}
505
507// Adapt this if a new PCL point type is integrated in the MeVisLab binding.
508
509//----------------------------------------------------------------------------------
514//----------------------------------------------------------------------------------
515template <typename POINT_TYPE1, typename POINT_TYPE2>
516inline bool doPCLPointNonDataMembersDiffer(const POINT_TYPE1 &/*point1*/,
517 const POINT_TYPE2 &/*point2*/,
518 double /*epsilon*/=FLT_EPSILON)
519{
520 return true;
521}
522
523//----------------------------------------------------------------------------------
526//----------------------------------------------------------------------------------
527inline bool doPCLPointNonDataMembersDiffer(const pcl::PointXYZ &/*point1*/,
528 const pcl::PointXYZ &/*point2*/,
529 double /*epsilon*/=FLT_EPSILON)
530{
531 return false;
532}
533
534//----------------------------------------------------------------------------------
537//----------------------------------------------------------------------------------
538inline bool doPCLPointNonDataMembersDiffer(const pcl::PointXYZLNormal &point1,
539 const pcl::PointXYZLNormal &point2,
540 double epsilon=FLT_EPSILON)
541{
542 return fourFloatsDiffer(point1.data_n, point2.data_n, epsilon) ||
543 (point1.label != point2.label) ||
544 (MLAbs(point1.curvature - point2.curvature) >= epsilon);
545}
546
547//----------------------------------------------------------------------------------
550//----------------------------------------------------------------------------------
551inline bool doPCLPointNonDataMembersDiffer(const pcl::PointXYZRGBNormal &point1,
552 const pcl::PointXYZRGBNormal &point2,
553 double epsilon=FLT_EPSILON)
554{
555 return fourFloatsDiffer(point1.data_n, point2.data_n, epsilon) ||
556 (point1.rgba != point2.rgba) ||
557 (MLAbs(point1.curvature - point2.curvature) >= epsilon);
558}
559
560//----------------------------------------------------------------------------------
563//----------------------------------------------------------------------------------
564inline bool doPCLPointNonDataMembersDiffer(const pcl::PointXYZINormal &point1,
565 const pcl::PointXYZINormal &point2,
566 double epsilon=FLT_EPSILON)
567{
568 return fourFloatsDiffer(point1.data_n, point2.data_n, epsilon) ||
569 (MLAbs(point1.intensity - point2.intensity) >= epsilon) ||
570 (MLAbs(point1.curvature - point2.curvature) >= epsilon);
571}
573
574//----------------------------------------------------------------------------------
582// Adapt this if a new PCL point type is integrated in the MeVisLab binding.
583//----------------------------------------------------------------------------------
585inline void setIntensityReplacement(pcl::PointXYZ & /*p*/, float /*value*/=1.f, MLuint8 /*opacity*/=0xff)
586{
587 // There is no member which could be used for the intensity.
588}
589inline void setIntensityReplacement(pcl::PointXYZLNormal &p, float value=1.f, MLuint8 /*opacity*/=0xff)
590{
591 p.curvature = value;
592}
593inline void setIntensityReplacement(pcl::PointXYZRGBNormal &p, float value=1.f, MLuint8 opacity=0xff /*opaque*/)
594{
595 p.curvature = value;
596 p.r = p.g = p.b = static_cast<MLuint8>(value * 255.9999f);
597 p.a = opacity;
598}
599inline void setIntensityReplacement(pcl::PointXYZINormal &p, float value=1.f, MLuint8 /*opacity*/=0xff)
600{
601 p.intensity = value;
602}
604
605//----------------------------------------------------------------------------------
609// Adapt this if a new PCL point type is integrated in the MeVisLab binding.
610//----------------------------------------------------------------------------------
612inline float getIntensityReplacement(const pcl::PointXYZ & /*p*/)
613{
614 // There is no member which could be used for the intensity.
615 return 0.f;
616}
617inline float getIntensityReplacement(const pcl::PointXYZLNormal &p)
618{
619 return p.curvature;
620}
621inline float getIntensityReplacement(const pcl::PointXYZRGBNormal &p)
622{
623 return p.curvature;
624}
625inline float getIntensityReplacement(const pcl::PointXYZINormal &p)
626{
627 return p.intensity;
628}
630
631//----------------------------------------------------------------------------------
634// Adapt this if a new PCL point type is integrated in the MeVisLab binding.
635//----------------------------------------------------------------------------------
637inline float getCurvature(const pcl::PointXYZ & /*p*/)
638{
639 // There is no member which could be used as curvature.
640 return 0.f;
641}
642inline float getCurvature(const pcl::PointXYZLNormal &p)
643{
644 return p.curvature;
645}
646inline float getCurvature(const pcl::PointXYZRGBNormal &p)
647{
648 return p.curvature;
649}
650inline float getCurvature(const pcl::PointXYZINormal &p)
651{
652 return p.curvature;
653}
654inline void setCurvature(pcl::PointXYZ & /*p*/, float /*curvature*/)
655{
656 // This point type has no curvature which could be set.
657}
658inline void setCurvature(pcl::PointXYZLNormal &p, float curvature)
659{
660 p.curvature = curvature;
661}
662inline void setCurvature(pcl::PointXYZRGBNormal &p, float curvature)
663{
664 p.curvature = curvature;
665}
666inline void setCurvature(pcl::PointXYZINormal &p, float curvature)
667{
668 p.curvature = curvature;
669}
671
672//----------------------------------------------------------------------------------
675// NOTE: Implement all types explicitly, because VC14-32 compiler will
676// matches RGBA type to default template version otherwise (which reads
677// 0u or sets nothing).
678// Adapt this if a new PCL point type is integrated in the MeVisLab binding.
679//----------------------------------------------------------------------------------
681inline unsigned int getPointRGBA(const pcl::PointXYZ & /*rgbaPnt*/)
682{
683 return 0u;
684}
685inline unsigned int getPointRGBA(const pcl::PointXYZINormal & /*rgbaPnt*/)
686{
687 return 0u;
688}
689inline unsigned int getPointRGBA(const pcl::PointXYZRGBNormal &rgbaPnt)
690{
691 return rgbaPnt.rgba;
692}
693inline unsigned int getPointRGBA(const pcl::PointXYZLNormal & /*rgbaPnt*/)
694{
695 return 0u;
696}
697inline void setPointRGBA(pcl::PointXYZ &/*rgbaPnt*/,
698 MLuint32 /*srcVal*/)
699{
700}
701inline void setPointRGBA(pcl::PointXYZINormal &/*rgbaPnt*/,
702 MLuint32 /*srcVal*/)
703{
704}
705inline void setPointRGBA(pcl::PointXYZRGBNormal &rgbaPnt,
707{
708 rgbaPnt.rgba = srcVal;
709}
710inline void setPointRGBA(pcl::PointXYZLNormal &/*rgbaPnt*/,
711 MLuint32 /*srcVal*/)
712{
713}
715
716//----------------------------------------------------------------------------------
720// Adapt this if a new PCL point type is integrated in the MeVisLab binding.
721//----------------------------------------------------------------------------------
723inline void setPointNormal(pcl::PointXYZ &/*p*/, float /*nx*/, float /*ny*/, float /*nz*/)
724{
725 // There is no member which could be used for the intensity.
726}
727inline void setPointNormal(pcl::PointXYZLNormal &p, float nx, float ny, float nz)
728{
729 p.normal_x = nx;
730 p.normal_y = ny;
731 p.normal_z = nz;
732}
733inline void setPointNormal(pcl::PointXYZRGBNormal &p, float nx, float ny, float nz)
734{
735 p.normal_x = nx;
736 p.normal_y = ny;
737 p.normal_z = nz;
738}
739inline void setPointNormal(pcl::PointXYZINormal &p, float nx, float ny, float nz)
740{
741 p.normal_x = nx;
742 p.normal_y = ny;
743 p.normal_z = nz;
744}
746
747//----------------------------------------------------------------------------------
751// Adapt this if a new PCL point type is integrated in the MeVisLab binding.
752//----------------------------------------------------------------------------------
754inline void getPointNormal(const pcl::PointXYZ & /*p*/, float &nx, float &ny, float &nz)
755{
756 nx = 0.f;
757 ny = 0.f;
758 nz = 0.f;
759}
760inline void getPointNormal(const pcl::PointXYZLNormal &p, float &nx, float &ny, float &nz)
761{
762 nx = p.normal_x;
763 ny = p.normal_y;
764 nz = p.normal_z;
765}
766inline void getPointNormal(const pcl::PointXYZRGBNormal &p, float &nx, float &ny, float &nz)
767{
768 nx = p.normal_x;
769 ny = p.normal_y;
770 nz = p.normal_z;
771}
772inline void getPointNormal(const pcl::PointXYZINormal &p, float &nx, float &ny, float &nz)
773{
774 nx = p.normal_x;
775 ny = p.normal_y;
776 nz = p.normal_z;
777}
779
780//----------------------------------------------------------------------------------
782// Adapt this if a new PCL point type is integrated in the MeVisLab binding.
783//----------------------------------------------------------------------------------
785inline bool hasNormal (const pcl::PointXYZ &){ return false;}
786inline bool hasNormal (const pcl::PointXYZLNormal &){ return true ;}
787inline bool hasNormal (const pcl::PointXYZRGBNormal &){ return true ;}
788inline bool hasNormal (const pcl::PointXYZINormal &){ return true ;}
790
791//----------------------------------------------------------------------------------
793// Adapt this if a new PCL point type is integrated in the MeVisLab binding.
794//----------------------------------------------------------------------------------
796inline bool hasLabel (const pcl::PointXYZ &){ return false;}
797inline bool hasLabel (const pcl::PointXYZLNormal &){ return true ;}
798inline bool hasLabel (const pcl::PointXYZRGBNormal &){ return false;}
799inline bool hasLabel (const pcl::PointXYZINormal &){ return false;}
801
802//----------------------------------------------------------------------------------
804// Adapt this if a new PCL point type is integrated in the MeVisLab binding.
805//----------------------------------------------------------------------------------
807inline bool hasRGBA (const pcl::PointXYZ &){ return false;}
808inline bool hasRGBA (const pcl::PointXYZLNormal &){ return false;}
809inline bool hasRGBA (const pcl::PointXYZRGBNormal &){ return true ;}
810inline bool hasRGBA (const pcl::PointXYZINormal &){ return false;}
812
813//----------------------------------------------------------------------------------
815// Adapt this if a new PCL point type is integrated in the MeVisLab binding.
816//----------------------------------------------------------------------------------
818inline bool hasIntensity(const pcl::PointXYZ &){ return false;}
819inline bool hasIntensity(const pcl::PointXYZLNormal &){ return false;}
820inline bool hasIntensity(const pcl::PointXYZRGBNormal &){ return false;}
821inline bool hasIntensity(const pcl::PointXYZINormal &){ return true ;}
823
824//----------------------------------------------------------------------------------
826// Adapt this if a new PCL point type is integrated in the MeVisLab binding.
827//----------------------------------------------------------------------------------
829inline bool hasCurvature(const pcl::PointXYZ &){ return false;}
830inline bool hasCurvature(const pcl::PointXYZLNormal &){ return true ;}
831inline bool hasCurvature(const pcl::PointXYZRGBNormal &){ return true ;}
832inline bool hasCurvature(const pcl::PointXYZINormal &){ return true ;}
834
835//----------------------------------------------------------------------------------
837// Adapt this if a new PCL point type is integrated in the MeVisLab binding.
838//----------------------------------------------------------------------------------
840inline bool hasIntensityReplacement(const pcl::PointXYZ &){ return false;}
841inline bool hasIntensityReplacement(const pcl::PointXYZLNormal &){ return true ;}
842inline bool hasIntensityReplacement(const pcl::PointXYZRGBNormal &){ return true ;}
843inline bool hasIntensityReplacement(const pcl::PointXYZINormal &){ return true ;}
845
846//----------------------------------------------------------------------------------
868// Adapt this if a new PCL point type is integrated in the MeVisLab binding.
869//----------------------------------------------------------------------------------
870template <typename POINT_TYPE>
872 std::string &formatStr,
874 size_t pointIndex)
875{
876 // For performance reasons call the replace functions and the calculations for its parameters only if the corresponding
877 // replace value is available.
878 if (std::string::npos != formatStr.find("$(x)")){
879 formatStr = ReleaseToolsString::replaceAllStr1ByStr2(formatStr, "$(x)", getScalarMemberValueAsString(point, 0, numDecimalPlaces));
880 }
881 if (std::string::npos != formatStr.find("$(data[0])")){
882 formatStr = ReleaseToolsString::replaceAllStr1ByStr2(formatStr, "$(data[0])", getScalarMemberValueAsString(point, 0, numDecimalPlaces));
883 }
884 if (std::string::npos != formatStr.find("$(y)")){
885 formatStr = ReleaseToolsString::replaceAllStr1ByStr2(formatStr, "$(y)", getScalarMemberValueAsString(point, 1, numDecimalPlaces));
886 }
887 if (std::string::npos != formatStr.find("$(data[1])")){
888 formatStr = ReleaseToolsString::replaceAllStr1ByStr2(formatStr, "$(data[1])", getScalarMemberValueAsString(point, 1, numDecimalPlaces));
889 }
890 if (std::string::npos != formatStr.find("$(z)")){
891 formatStr = ReleaseToolsString::replaceAllStr1ByStr2(formatStr, "$(z)", getScalarMemberValueAsString(point, 2, numDecimalPlaces));
892 }
893 if (std::string::npos != formatStr.find("$(data[2])")){
894 formatStr = ReleaseToolsString::replaceAllStr1ByStr2(formatStr, "$(data[2])", getScalarMemberValueAsString(point, 2, numDecimalPlaces));
895 }
896 if (std::string::npos != formatStr.find("$(data[3])")){
897 formatStr = ReleaseToolsString::replaceAllStr1ByStr2(formatStr, "$(data[3])", getScalarMemberValueAsString(point, 3, numDecimalPlaces));
898 }
899
900 if (std::string::npos != formatStr.find("$(nx)")){
901 formatStr = ReleaseToolsString::replaceAllStr1ByStr2(formatStr, "$(nx)", getScalarMemberValueAsString(point, 4, numDecimalPlaces));
902 }
903 if (std::string::npos != formatStr.find("$(data_n[0])")){
904 formatStr = ReleaseToolsString::replaceAllStr1ByStr2(formatStr, "$(data_n[0])", getScalarMemberValueAsString(point, 4, numDecimalPlaces));
905 }
906 if (std::string::npos != formatStr.find("$(ny)")){
907 formatStr = ReleaseToolsString::replaceAllStr1ByStr2(formatStr, "$(ny)", getScalarMemberValueAsString(point, 5, numDecimalPlaces));
908 }
909 if (std::string::npos != formatStr.find("$(data_n[1])")){
910 formatStr = ReleaseToolsString::replaceAllStr1ByStr2(formatStr, "$(data_n[1])", getScalarMemberValueAsString(point, 5, numDecimalPlaces));
911 }
912 if (std::string::npos != formatStr.find("$(nz)")){
913 formatStr = ReleaseToolsString::replaceAllStr1ByStr2(formatStr, "$(nz)", getScalarMemberValueAsString(point, 6, numDecimalPlaces));
914 }
915 if (std::string::npos != formatStr.find("$(data_n[2])")){
916 formatStr = ReleaseToolsString::replaceAllStr1ByStr2(formatStr, "$(data_n[2])", getScalarMemberValueAsString(point, 6, numDecimalPlaces));
917 }
918 if (std::string::npos != formatStr.find("$(data_n[3])")){
919 formatStr = ReleaseToolsString::replaceAllStr1ByStr2(formatStr, "$(data_n[3])", getScalarMemberValueAsString(point, 7, numDecimalPlaces));
920 }
921
922 if (std::string::npos != formatStr.find("$(ir)")){
923 const float ir = getIntensityReplacement(point);
924 formatStr = ReleaseToolsString::replaceAllStr1ByStr2(formatStr, "$(ir)", hasIntensityReplacement(point) ?
925 ReleaseToolsString::toDblStr(ir, -1, static_cast<signed char>(numDecimalPlaces), false, true):
926 std::string());
927 }
928 if (std::string::npos != formatStr.find("$(curvature)")){
929 formatStr = ReleaseToolsString::replaceAllStr1ByStr2(formatStr, "$(curvature)", getScalarMemberValueAsString(point, 8, numDecimalPlaces));
930 }
931 if (std::string::npos != formatStr.find("$(rgba)")){
932 formatStr = ReleaseToolsString::replaceAllStr1ByStr2(formatStr, "$(rgba)", hasRGBA(point) ?
934 std::string());
935 }
936 if (std::string::npos != formatStr.find("$(intensity)")){
937 formatStr = ReleaseToolsString::replaceAllStr1ByStr2(formatStr, "$(intensity)", hasIntensity(point) ?
939 std::string());
940 }
941 if (std::string::npos != formatStr.find("$(label)")){
942 formatStr = ReleaseToolsString::replaceAllStr1ByStr2(formatStr, "$(label)", hasLabel(point) ?
944 std::string());
945 }
946 if (std::string::npos != formatStr.find("$(index)")){
947 formatStr = ReleaseToolsString::replaceAllStr1ByStr2(formatStr, "$(index)", ReleaseToolsString::toSize_tStr(pointIndex));
948 }
949}
950
951//----------------------------------------------------------------------------------
969//----------------------------------------------------------------------------------
970template <typename POINT_CLOUD_TYPE>
974 bool showIndices=true,
975 const std::string &lineSeparator="\n",
976 int numDecimalPlaces = -1,
977 const std::string &pointsPrintFormatStr="")
978{
979 std::string retString;
980 const MLuint64 numPoints = pointCloud.points.size();
981 if ( (maxNumShownPoints>0) && (numPoints > 0) && (indexOfFirstPoint < mlrange_cast<MLint64>(numPoints)) ){
982
983 // Correct input parameters if necessary.
984 if (indexOfFirstPoint < 0){ indexOfFirstPoint = 0; }
985 if (indexOfFirstPoint >= mlrange_cast<MLint64>(numPoints)){
987 }
990 }
993 if (endPointIdx > numPoints){ endPointIdx = numPoints; } // endPointIdx itself is already excluded
994
995 std::string idxPrefix = "";
996 const std::string colonStr = ":";
997
998 // Use size_t for indices to avoid indexing warnings on 32 bit systems.
1000 const size_t endIdx = mlrange_cast<size_t>(endPointIdx);
1001
1002 // Guess to avoid too many resizes.
1003 retString.reserve((endIdx-firstIdx)*20);
1004
1005 // Empty? Then use normal print, otherwise use formatted one.
1006 const bool isFormatted = !pointsPrintFormatStr.empty();
1007
1008 // Print points into string (reserve to avoid expensive reallocations).
1009 std::string lineStr;
1010 lineStr.reserve(512);
1011 for (size_t c=firstIdx; c < endIdx; ++c){
1012 if (showIndices){
1013 idxPrefix = ReleaseToolsString::toMLUIntStr(c) + colonStr;
1014 }
1015 if (isFormatted){
1018 }
1019 else{
1021 }
1023 }
1024 }
1025 return retString;
1026}
1027
1028//----------------------------------------------------------------------------------
1031//----------------------------------------------------------------------------------
1032template <typename POINT_CLOUD_TYPE>
1034{
1035 std::string retStr;
1036 if (pointCloud.points.size() > 0){
1037 const size_t numMembers = PCLSupportTools::getNumberOfScalarPointMembers(pointCloud);
1038 for (size_t c=0; c < numMembers; ++c){
1039 if (c > 0){
1040 retStr += ", ";
1041 }
1042 retStr += PCLSupportTools::getScalarMemberNameAsString(pointCloud.points[0], c);
1043 }
1044 }
1045 return retStr;
1046}
1047
1050#define _PCLSupportTools_NewLineDefaultArgumentString "\n"
1051
1052//----------------------------------------------------------------------------------
1064//----------------------------------------------------------------------------------
1065MLPCLSUPPORT_EXPORT std::string getPCLVerticesAsString(const std::vector<pcl::Vertices> &vertices,
1068 bool showIndices=true,
1070
1071//----------------------------------------------------------------------------------
1082// See python PCLInfoTest for a test testing this functionality indirectly.
1083//----------------------------------------------------------------------------------
1084MLPCLSUPPORT_EXPORT std::string getPCLIndicesAsString(const std::vector<int> &indices,
1087 bool showIndices,
1089
1090//----------------------------------------------------------------------------------
1097//----------------------------------------------------------------------------------
1099 std::vector<int> &indices);
1100
1101//----------------------------------------------------------------------------------
1111//----------------------------------------------------------------------------------
1113 const std::uint8_t *dataPtr,
1114 int numDecimalPlaces = -1);
1115
1116//----------------------------------------------------------------------------------
1122//----------------------------------------------------------------------------------
1124 bool aligned);
1125
1126//----------------------------------------------------------------------------------
1137//----------------------------------------------------------------------------------
1141 bool showIndices=true,
1143 int numDecimalPlaces=-1);
1144
1145#if 0
1146// Still untested. To be activated when needed.
1147//----------------------------------------------------------------------------------
1154//----------------------------------------------------------------------------------
1156 const pcl::uint8_t *dataPtr);
1157
1158//----------------------------------------------------------------------------------
1160//----------------------------------------------------------------------------------
1162 const pcl::uint8_t *dataPtr);
1163
1164//----------------------------------------------------------------------------------
1166//----------------------------------------------------------------------------------
1168 // Initializes all members to 0.
1169 inline XYZNormalAndValue():px(0.f),py(0.f),pz(0.f), nx(0.f),ny(0.f),nz(0.f), intensity(0.f), rgba(0), isRGBA(false){}
1170 // Initializes all members to 0.
1171 inline void clear(){ px=0.f; py=0.f; pz=0.f; nx=0.f; ny=0.f; nz=0.f; intensity=0.f; rgba=0; isRGBA=false; }
1172
1174 float px,py,pz;
1176 float nx,ny,nz;
1178 float intensity;
1180 MLuint32 rgba;
1182 bool isRGBA;
1183};
1184
1185//----------------------------------------------------------------------------------
1191//----------------------------------------------------------------------------------
1192MLPCLSUPPORT_EXPORT void getCloudDataGeometry(const MLPolygonMesh &polygonMesh,
1193 std::vector<XYZNormalAndValue> &geometry);
1194#endif
1195
1196//----------------------------------------------------------------------------------
1198//----------------------------------------------------------------------------------
1199MLPCLSUPPORT_EXPORT std::string getCloudFieldsString(const std::vector<pcl::PCLPointField> &fields);
1200
1201//----------------------------------------------------------------------------------
1205//----------------------------------------------------------------------------------
1206template <typename POINT_CLOUD_TYPE>
1208{
1209 // Create empty return box.
1211 retBox.v1[0] = ML_FLOAT_MAX;
1212 retBox.v1[1] = ML_FLOAT_MAX;
1213 retBox.v1[2] = ML_FLOAT_MAX;
1214 retBox.v1[3] = 0.;
1215 retBox.v1[4] = 0.;
1216 retBox.v1[5] = 0.;
1217 retBox.v2[0] = -ML_FLOAT_MAX;
1218 retBox.v2[1] = -ML_FLOAT_MAX;
1219 retBox.v2[2] = -ML_FLOAT_MAX;
1220 retBox.v2[3] = 0.;
1221 retBox.v2[4] = 0.;
1222 retBox.v2[5] = 0.;
1223
1224 const size_t numPoints = inputPointCloud.points.size();
1225 for (size_t c=0; c < numPoints; ++c){
1226 typedef typename POINT_CLOUD_TYPE::PointType PointType;
1227 const PointType &pnt = inputPointCloud.points[c];
1228 if (pnt.x < retBox.v1[0]){ retBox.v1[0] = pnt.x; }
1229 if (pnt.y < retBox.v1[1]){ retBox.v1[1] = pnt.y; }
1230 if (pnt.z < retBox.v1[2]){ retBox.v1[2] = pnt.z; }
1231
1232 if (pnt.x > retBox.v2[0]){ retBox.v2[0] = pnt.x; }
1233 if (pnt.y > retBox.v2[1]){ retBox.v2[1] = pnt.y; }
1234 if (pnt.z > retBox.v2[2]){ retBox.v2[2] = pnt.z; }
1235 }
1236 return retBox;
1237}
1238
1239//----------------------------------------------------------------------------------
1251//----------------------------------------------------------------------------------
1252template <typename POINT_CLOUD_TYPE>
1255 bool includeAll)
1256{
1257 pointCloudOrigin.assign(0,0,0);
1260 if (!doubleBox.isEmpty()){
1261 pointCloudOrigin.assign(static_cast<float>(doubleBox.v1[0]),
1262 static_cast<float>(doubleBox.v1[1]),
1263 static_cast<float>(doubleBox.v1[2]));
1264 if (!includeAll){
1265 retBox.v1.x = static_cast<MLint>(doubleBox.v1[0]);
1266 retBox.v1.y = static_cast<MLint>(doubleBox.v1[1]);
1267 retBox.v1.z = static_cast<MLint>(doubleBox.v1[2]);
1268 retBox.v2.x = static_cast<MLint>(doubleBox.v2[0]);
1269 retBox.v2.y = static_cast<MLint>(doubleBox.v2[1]);
1270 retBox.v2.z = static_cast<MLint>(doubleBox.v2[2]);
1271 }
1272 else{
1273 retBox.v1.x = static_cast<MLint>(std::floor(doubleBox.v1[0]));
1274 retBox.v1.y = static_cast<MLint>(std::floor(doubleBox.v1[1]));
1275 retBox.v1.z = static_cast<MLint>(std::floor(doubleBox.v1[2]));
1276 retBox.v2.x = static_cast<MLint>(std::ceil (doubleBox.v2[0]));
1277 retBox.v2.y = static_cast<MLint>(std::ceil (doubleBox.v2[1]));
1278 retBox.v2.z = static_cast<MLint>(std::ceil (doubleBox.v2[2]));
1279 }
1280 retBox.v1.c = 0;
1281 retBox.v1.t = 0;
1282 retBox.v1.u = 0;
1283 retBox.v2.c = 0;
1284 retBox.v2.t = 0;
1285 retBox.v2.u = 0;
1286 }
1287 return retBox;
1288}
1289
1290//----------------------------------------------------------------------------------
1293// Adapt this if a new PCL point type is integrated in the MeVisLab binding.
1294//----------------------------------------------------------------------------------
1296
1297//----------------------------------------------------------------------------------
1299// Adapt this if a new PCL point type is integrated in the MeVisLab binding.
1300//----------------------------------------------------------------------------------
1301extern MLPCLSUPPORT_EXPORT const char * const PointMemberNames[ML_PCL_NUMBER_OF_POINT_MEMBER_NAMES];
1302
1303//----------------------------------------------------------------------------------
1306// Adapt this if a new PCL point type is integrated in the MeVisLab binding.
1307//----------------------------------------------------------------------------------
1309
1310//----------------------------------------------------------------------------------
1312// Adapt this if a new PCL point type is integrated in the MeVisLab binding.
1313//----------------------------------------------------------------------------------
1314extern MLPCLSUPPORT_EXPORT const char * const FloatPointMemberNames[ML_PCL_NUMBER_OF_FLOAT_POINT_MEMBER_NAMES];
1315
1316//----------------------------------------------------------------------------------
1319// Adapt this if a new PCL point type is integrated in the MeVisLab binding.
1320//----------------------------------------------------------------------------------
1321MLPCLSUPPORT_EXPORT size_t getByteOffset(const pcl::PointXYZ &pnt,
1322 const std::string &pointMemberName);
1323
1324//----------------------------------------------------------------------------------
1327// Adapt this if a new PCL point type is integrated in the MeVisLab binding.
1328//----------------------------------------------------------------------------------
1329MLPCLSUPPORT_EXPORT size_t getByteOffset(const pcl::PointXYZLNormal &pnt,
1330 const std::string &pointMemberName);
1331
1332//----------------------------------------------------------------------------------
1335// Adapt this if a new PCL point type is integrated in the MeVisLab binding.
1336//----------------------------------------------------------------------------------
1337MLPCLSUPPORT_EXPORT size_t getByteOffset(const pcl::PointXYZRGBNormal &pnt,
1338 const std::string &pointMemberName);
1339
1340//----------------------------------------------------------------------------------
1343// Adapt this if a new PCL point type is integrated in the MeVisLab binding.
1344//----------------------------------------------------------------------------------
1345MLPCLSUPPORT_EXPORT size_t getByteOffset(const pcl::PointXYZINormal &pnt,
1346 const std::string &pointMemberName);
1347
1348};
1349
1351
Project global and OS specific declarations.
#define MLPCLSUPPORT_EXPORT
If included by external modules, exported symbols are declared as import symbols.
SubImageBoxd - SubImageBox with coordinates of float data type.
Vector6 v1
Corner v1 of the box region.
DT x
X-component of the vector, same as _buffer[0].
Definition mlVector3.h:39
DT z
Z-component of the vector, same as _buffer[2].
Definition mlVector3.h:43
DT y
Y-component of the vector, same as _buffer[1].
Definition mlVector3.h:41
DT MLAbs(const DT val)
Defines templated MLAbs version to circumvent fabs ambiguities on different platforms.
#define ML_BAD_PARAMETER
A bad/invalid parameter (or even an inappropriate image) has been passed to a module or an algorithm;...
Definition mlTypeDefs.h:823
#define ML_PRINT_ERROR(FUNC_NAME, REASON, HANDLING)
Like ML_PRINT_ERROR_DUMP(FUNC_NAME, REASON, HANDLING, RT_OBJ) without a runtime object to be dumped.
#define _PCLSupportTools_NewLineDefaultArgumentString
A default argument used in some functions for strings and which describes a newline,...
Basic types used in the MeVislab binding of the Point Cloud Library(PCL).
Target mlrange_cast(Source arg)
Generic version of checked ML casts.
Tool class for some string operations.
#define ML_FLOAT_MAX
Definition mlTypeDefs.h:204
UINT64 MLuint64
Introduce platform independent 64 bit unsigned integer type.
Definition mlTypeDefs.h:425
#define ML_INT64_MAX
Definition mlTypeDefs.h:467
unsigned int MLuint32
Definition mlTypeDefs.h:185
unsigned char MLuint8
Definition mlTypeDefs.h:109
MLint64 MLint
A signed ML integer type with at least 64 bits used for index calculations on very large images even ...
Definition mlTypeDefs.h:490
PointCloudDefaultPatterns
An enumerator defining some basic default patterns for point clouds.
bool hasLabel(const pcl::PointXYZ &)
Returns true if the passed point has a label field, otherwise false.
void getPointNormal(const pcl::PointXYZ &, float &nx, float &ny, float &nz)
Returns the normal field members normal_x, normal_y, normal_z of a point p in nx, ny,...
void setPointRGBA(pcl::PointXYZ &, MLuint32)
MLPCLSUPPORT_EXPORT MLuint64 getUnsigned32BitMaximumLimit()
Returns the maximum number of entries allowed in data structured with 32 bit unsigned indexing,...
bool hasNormals(const pcl::PointXYZ &)
Returns true if the point or point type contains normal fields/members, otherwise false,...
unsigned int getPointRGBA(const pcl::PointXYZ &)
Get the rgba value from PCL point if it has that member otherwise get 0u; for set functionality set t...
MLPCLSUPPORT_EXPORT std::string getCloudFieldsString(const std::vector< pcl::PCLPointField > &fields)
Converts the pointField vector fields to a human readable string.
bool doPCLPointNonDataMembersDiffer(const POINT_TYPE1 &, const POINT_TYPE2 &, double=FLT_EPSILON)
Compare all non data members of all supported point types with each other.
bool fourFloatsDiffer(const float data1[4], const float data2[4], double epsilon=FLT_EPSILON)
Returns true if differences between corresponding data1 and data2 entries are >= epsilon,...
SubImageBoxd getBoxForPointCloud(const POINT_CLOUD_TYPE &inputPointCloud)
Returns an ML SubImageBoxd whose extents are sufficient in that way that all points of inputPointClou...
void setPointNormal(pcl::PointXYZ &, float, float, float)
Sets the normal fields normal_x, normal_y, normal_z of a point from nx, ny, nz if the point contains ...
Eigen::Vector4f castToEigenVector4f(const Vector4 &mlVec)
Convenience function to convert an ML Vector4f to an Eigen::Vector4f.
MLPCLSUPPORT_EXPORT void castToStdVector(const Eigen::VectorXf &eigenVec, std::vector< MLfloat > &stdVec)
Convenience function to convert an Eigen::VectorXf to a std::vector<MLfloat>, e.g.
MLPCLSUPPORT_EXPORT std::string getCloudDataString(const MLPolygonMesh &polygonMesh, MLint maxNumShownVertices=ML_INT64_MAX, MLint indexOfFirstVertex=0, bool showIndices=true, const std::string &lineSeparator=_PCLSupportTools_NewLineDefaultArgumentString, int numDecimalPlaces=-1)
Converts the cloud data of polygonMesh to a human readable string.
MLPCLSUPPORT_EXPORT void PCLExtractSubIndices(const std::vector< int > &subIndices, std::vector< int > &indices)
Extract all indices from indices if they are listed in subIndices in the order as given in subIndices...
std::string getPointStructureT(const POINT_CLOUD_TYPE &pointCloud)
Returns an empty string if pointCloud.points are empty, otherwise a concatenated, comma separated str...
void createEmptyPCLObject(PCL_OBJECT_PTR_TYPE &retPCLObjectPtr)
Creates an empty point cloud of type POINT_CLOUD_PTR_TYPE.
MLPointCloudXYZINormalPtr createEmptyXYZINormalPointCloud()
Creates an empty PointCloudXYZLNormal point cloud.
MLPCLSUPPORT_EXPORT std::string getPCLIndicesAsString(const std::vector< int > &indices, MLint maxNumShownIndices, MLint indexOfFirstIndex, bool showIndices, const std::string &lineSeparator=_PCLSupportTools_NewLineDefaultArgumentString)
Converts at most maxNumShownIndices indices from indices starting at position indexOfFirstIndex into ...
PointCloudFillPatterns
An enumerator defining some basic value fill patterns for point clouds.
MLPCLSUPPORT_EXPORT MLuint64 getSigned32BitMaximumLimit()
Returns the maximum number of entries allowed in data structured with 32 bit signed indexing,...
Eigen::Vector3f castToEigenVector3f(const Vector3 &mlVec)
Convenience function to convert an ML Vector3f to an Eigen::Vector3f.
void setIntensityReplacement(pcl::PointXYZ &, float=1.f, MLuint8=0xff)
Sets a scalar value in a member which can be used as storage for an additional value,...
MLPCLSUPPORT_EXPORT std::string getPCLVerticesAsString(const std::vector< pcl::Vertices > &vertices, MLint maxNumShownVertices=ML_INT64_MAX, MLint indexOfFirstVertex=0, bool showIndices=true, const std::string &lineSeparator=_PCLSupportTools_NewLineDefaultArgumentString)
Converts at most maxNumShownVertices vertices from vertices starting at position indexOfFirstVertex i...
void setPointFromFields(pcl::PointXYZ &pnt, const std::vector< DoubleField * > &constantFields)
Copy states of constantFields to the corresponding member of pnt; the contantFields vector must have ...
MLPCLSUPPORT_EXPORT std::string getScalarMemberNameAsString(const pcl::PointXYZ &, size_t memberIdx)
MLPolygonMeshPtr createEmptyPolygonMesh()
Creates an empty pcl::PolygonMesh object.
bool hasIntensity(const pcl::PointXYZ &)
Returns true if the passed point has an intensity field, otherwise false.
void appendFillPattern(POINT_CLOUD_TYPE &pc, PointCloudDefaultPatterns pattern, PointCloudFillPatterns fillMode, float fillValue=0.f)
Creates a PointCloud point cloud filled with a set of points defined by pattern and fillMode; does no...
MLPCLSUPPORT_EXPORT size_t getByteOffset(const pcl::PointXYZ &pnt, const std::string &pointMemberName)
Returns the offset in bytes between the given member described as string and the first member in the ...
bool hasIntensityReplacement(const pcl::PointXYZ &)
Returns true if the passed point has any field which can be interpreted as an intensity replacement f...
void setFieldsFromPoint(const pcl::PointXYZ &pnt, std::vector< DoubleField * > &resultFields)
Set resultFields to the corresponding member states of pnt; the resultFields vector must have a suffi...
size_t getMaximumNumberOfScalarPointMembers()
From the point cloud type with the largest number of scalar members returns the number of scalar valu...
MLPCLSUPPORT_EXPORT std::string getPointFieldValueAsString(std::uint8_t fd, const std::uint8_t *dataPtr, int numDecimalPlaces=-1)
Reinterprets the data at position dataPtr as a pcl::PointField::PointFieldTypes enumerator given by f...
bool hasRGBA(const pcl::PointXYZ &)
Returns true if the passed point has an rgba field, otherwise false.
void setPointFromScalar(pcl::PointXYZ &pnt, const float val)
Copy a scalar value into all point fields.
MLPCLSUPPORT_EXPORT std::string getPointFieldDataTypeString(std::uint8_t fd, bool aligned)
Returns a human readable string for a pcl::PCLPointField::PointFieldTypes enumerator.
MLPCLSUPPORT_EXPORT std::string getScalarMemberValueAsString(const pcl::PointXYZ &p, size_t memberIdx, int numDecimalPlaces=-1)
MLPointCloudXYZLNormalPtr createEmptyXYZLNormalPointCloud()
Creates an empty PointCloudXYZLNormal point cloud.
float getIntensityReplacement(const pcl::PointXYZ &)
Gets the scalar value in a member which is considered as storage for an additional value,...
void appendPoint(POINT_CLOUD_TYPE &pc, const Vector3f &pos, float fillValue)
Appends a new point to pc with data[0-2] given by pos and data[3] by fillValue; does nothing if pc is...
bool hasNormal(const pcl::PointXYZ &)
Returns true if the passed point has a normal, otherwise false.
MLPointCloudXYZPtr createEmptyXYZPointCloud()
Creates an empty PointCloudXYZ point cloud.
float getCurvature(const pcl::PointXYZ &)
Gets/sets the curvature value as float if the point has one, otherwise return 0 (for example in the c...
std::string getPCLPointListAsString(const POINT_CLOUD_TYPE &pointCloud, MLint maxNumShownPoints=ML_INT64_MAX, MLint indexOfFirstPoint=0, bool showIndices=true, const std::string &lineSeparator="\n", int numDecimalPlaces=-1, const std::string &pointsPrintFormatStr="")
Converts at most maxNumShownPoints from pointCloud starting at position indexOfFirstPoint into a stri...
MLPointCloudXYZRGBNormalPtr createEmptyXYZRGBNormalPointCloud()
Creates an empty PointCloudXYZRGBNormal point cloud.
void setCurvature(pcl::PointXYZ &, float)
bool hasCurvature(const pcl::PointXYZ &)
Returns true if the passed point has a curvature field, otherwise false.
size_t getNumberOfScalarPointMembers(const pcl::PointXYZ &)
MLPCLSUPPORT_EXPORT std::string getPCLPointAsString(const pcl::PointXYZ &point, int numDecimalPlaces=-1)
void getPCLPointAsFormattedString(const POINT_TYPE &point, std::string &formatStr, int numDecimalPlaces, size_t pointIndex)
Replaces placeholders in formatStr with values from the given point.
pcl::PointCloud< pcl::PointXYZRGBNormal >::Ptr MLPointCloudXYZRGBNormalPtr
The basic pointer type of a point cloud type used in the PCL MeVisLab binding.
Definition mlPCLTypes.h:100
pcl::PointCloud< pcl::PointXYZLNormal >::Ptr MLPointCloudXYZLNormalPtr
The basic pointer type of a point cloud type used in the PCL MeVisLab binding.
Definition mlPCLTypes.h:93
pcl::PointCloud< pcl::PointXYZ >::Ptr MLPointCloudXYZPtr
The basic pointer type of a point cloud type used in the PCL MeVisLab binding.
Definition mlPCLTypes.h:86
pcl::PointCloud< pcl::PointXYZ > MLPointCloudXYZ
The basic point cloud type used in the PCL MeVisLab binding.
Definition mlPCLTypes.h:83
pcl::PointCloud< pcl::PointXYZRGBNormal > MLPointCloudXYZRGBNormal
The basic point cloud type used in the PCL MeVisLab binding.
Definition mlPCLTypes.h:97
pcl::PointCloud< pcl::PointXYZLNormal > MLPointCloudXYZLNormal
The basic point cloud type used in the PCL MeVisLab binding.
Definition mlPCLTypes.h:90
pcl::PolygonMesh::Ptr MLPolygonMeshPtr
The basic pointer type of a pcl::PolygonMesh in the PCL MeVisLab binding.
Definition mlPCLTypes.h:114
pcl::PolygonMesh MLPolygonMesh
The basic polygon type of a pcl::PolygonMesh used in the PCL MeVisLab binding.
Definition mlPCLTypes.h:111
pcl::PointCloud< pcl::PointXYZINormal >::Ptr MLPointCloudXYZINormalPtr
The basic pointer type of a point cloud type used in the PCL MeVisLab binding.
Definition mlPCLTypes.h:107
pcl::PointCloud< pcl::PointXYZINormal > MLPointCloudXYZINormal
The basic point cloud type used in the PCL MeVisLab binding.
Definition mlPCLTypes.h:104