26namespace PCLSupportTools {
45 return Eigen::Vector3f(
static_cast<float>(mlVec[0]),
46 static_cast<float>(mlVec[1]),
47 static_cast<float>(mlVec[2]));
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]));
118inline bool hasNormals(
const pcl::PointXYZ &) {
return false; }
121inline bool hasNormals(
const pcl::PointXYZLNormal &) {
return true; }
124inline bool hasNormals(
const pcl::PointXYZRGBNormal &) {
return true; }
127inline bool hasNormals(
const pcl::PointXYZINormal &) {
return true; }
150 int numDecimalPlaces=-1);
153 int numDecimalPlaces=-1);
156 int numDecimalPlaces=-1);
159 int numDecimalPlaces=-1);
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());
178inline void setPointFromFields(pcl::PointXYZLNormal &pnt,
const std::vector<DoubleField*> &constantFields)
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()));
191inline void setPointFromFields(pcl::PointXYZRGBNormal &pnt,
const std::vector<DoubleField*> &constantFields)
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());
204inline void setPointFromFields(pcl::PointXYZINormal &pnt,
const std::vector<DoubleField*> &constantFields)
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());
244 pnt.label =
static_cast<std::uint32_t
>(
MLAbs(val));
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]);
288inline void setFieldsFromPoint(
const pcl::PointXYZLNormal &pnt, std::vector<DoubleField*> &resultFields)
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));
301inline void setFieldsFromPoint(
const pcl::PointXYZRGBNormal &pnt, std::vector<DoubleField*> &resultFields)
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 );
314inline void setFieldsFromPoint(
const pcl::PointXYZINormal &pnt, std::vector<DoubleField*> &resultFields)
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);
332template <
typename PCL_OBJECT_PTR_TYPE>
335 typedef typename PCL_OBJECT_PTR_TYPE::element_type PCL_OBJECT_TYPE;
336 retPCLObjectPtr = PCL_OBJECT_PTR_TYPE(
new PCL_OBJECT_TYPE);
348 return retPointCloudPtr;
357 return retPointCloudPtr;
366 return retPointCloudPtr;
375 return retPointCloudPtr;
384 return retPolygonMeshPtr;
403 NumberOfPointCloudDefaultPatterns = 5
417 NumberOfPointCloudFillPatterns = 2
424template <
typename POINT_CLOUD_TYPE>
429 typedef typename POINT_CLOUD_TYPE::PointType POINT_TYPE;
434 newPoint.data[3] = fillValue;
435 pc.push_back(newPoint);
442template <
typename POINT_CLOUD_TYPE>
450 bool useFillVal=
false;
452 case Fill: useFillVal=
true;
break;
453 case Indexed: useFillVal=
false;
break;
456 "Bad fill mode, using fillMode 'Fill'.");
488 "Bad fill pattern, could not add points to point cloud.");
497 const float data2[4],
498 double epsilon=FLT_EPSILON)
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) );
515template <
typename POINT_TYPE1,
typename POINT_TYPE2>
528 const pcl::PointXYZ &,
539 const pcl::PointXYZLNormal &point2,
540 double epsilon=FLT_EPSILON)
543 (point1.label != point2.label) ||
544 (
MLAbs(point1.curvature - point2.curvature) >= epsilon);
552 const pcl::PointXYZRGBNormal &point2,
553 double epsilon=FLT_EPSILON)
556 (point1.rgba != point2.rgba) ||
557 (
MLAbs(point1.curvature - point2.curvature) >= epsilon);
565 const pcl::PointXYZINormal &point2,
566 double epsilon=FLT_EPSILON)
569 (
MLAbs(point1.intensity - point2.intensity) >= epsilon) ||
570 (
MLAbs(point1.curvature - point2.curvature) >= epsilon);
596 p.r = p.g = p.b =
static_cast<MLuint8>(value * 255.9999f);
660 p.curvature = curvature;
664 p.curvature = curvature;
668 p.curvature = curvature;
708 rgbaPnt.rgba = srcVal;
733inline void setPointNormal(pcl::PointXYZRGBNormal &p,
float nx,
float ny,
float nz)
754inline void getPointNormal(
const pcl::PointXYZ & ,
float &nx,
float &ny,
float &nz)
760inline void getPointNormal(
const pcl::PointXYZLNormal &p,
float &nx,
float &ny,
float &nz)
766inline void getPointNormal(
const pcl::PointXYZRGBNormal &p,
float &nx,
float &ny,
float &nz)
772inline void getPointNormal(
const pcl::PointXYZINormal &p,
float &nx,
float &ny,
float &nz)
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 ;}
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;}
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;}
820inline bool hasIntensity(
const pcl::PointXYZRGBNormal &){
return false;}
831inline bool hasCurvature(
const pcl::PointXYZRGBNormal &){
return true ;}
870template <
typename POINT_TYPE>
872 std::string &formatStr,
873 int numDecimalPlaces,
878 if (std::string::npos != formatStr.find(
"$(x)")){
881 if (std::string::npos != formatStr.find(
"$(data[0])")){
882 formatStr = ReleaseToolsString::replaceAllStr1ByStr2(formatStr,
"$(data[0])",
getScalarMemberValueAsString(point, 0, numDecimalPlaces));
884 if (std::string::npos != formatStr.find(
"$(y)")){
887 if (std::string::npos != formatStr.find(
"$(data[1])")){
888 formatStr = ReleaseToolsString::replaceAllStr1ByStr2(formatStr,
"$(data[1])",
getScalarMemberValueAsString(point, 1, numDecimalPlaces));
890 if (std::string::npos != formatStr.find(
"$(z)")){
893 if (std::string::npos != formatStr.find(
"$(data[2])")){
894 formatStr = ReleaseToolsString::replaceAllStr1ByStr2(formatStr,
"$(data[2])",
getScalarMemberValueAsString(point, 2, numDecimalPlaces));
896 if (std::string::npos != formatStr.find(
"$(data[3])")){
897 formatStr = ReleaseToolsString::replaceAllStr1ByStr2(formatStr,
"$(data[3])",
getScalarMemberValueAsString(point, 3, numDecimalPlaces));
900 if (std::string::npos != formatStr.find(
"$(nx)")){
903 if (std::string::npos != formatStr.find(
"$(data_n[0])")){
904 formatStr = ReleaseToolsString::replaceAllStr1ByStr2(formatStr,
"$(data_n[0])",
getScalarMemberValueAsString(point, 4, numDecimalPlaces));
906 if (std::string::npos != formatStr.find(
"$(ny)")){
909 if (std::string::npos != formatStr.find(
"$(data_n[1])")){
910 formatStr = ReleaseToolsString::replaceAllStr1ByStr2(formatStr,
"$(data_n[1])",
getScalarMemberValueAsString(point, 5, numDecimalPlaces));
912 if (std::string::npos != formatStr.find(
"$(nz)")){
915 if (std::string::npos != formatStr.find(
"$(data_n[2])")){
916 formatStr = ReleaseToolsString::replaceAllStr1ByStr2(formatStr,
"$(data_n[2])",
getScalarMemberValueAsString(point, 6, numDecimalPlaces));
918 if (std::string::npos != formatStr.find(
"$(data_n[3])")){
919 formatStr = ReleaseToolsString::replaceAllStr1ByStr2(formatStr,
"$(data_n[3])",
getScalarMemberValueAsString(point, 7, numDecimalPlaces));
922 if (std::string::npos != formatStr.find(
"$(ir)")){
925 ReleaseToolsString::toDblStr(ir, -1,
static_cast<signed char>(numDecimalPlaces),
false,
true):
928 if (std::string::npos != formatStr.find(
"$(curvature)")){
929 formatStr = ReleaseToolsString::replaceAllStr1ByStr2(formatStr,
"$(curvature)",
getScalarMemberValueAsString(point, 8, numDecimalPlaces));
931 if (std::string::npos != formatStr.find(
"$(rgba)")){
932 formatStr = ReleaseToolsString::replaceAllStr1ByStr2(formatStr,
"$(rgba)",
hasRGBA(point) ?
936 if (std::string::npos != formatStr.find(
"$(intensity)")){
937 formatStr = ReleaseToolsString::replaceAllStr1ByStr2(formatStr,
"$(intensity)",
hasIntensity(point) ?
941 if (std::string::npos != formatStr.find(
"$(label)")){
942 formatStr = ReleaseToolsString::replaceAllStr1ByStr2(formatStr,
"$(label)",
hasLabel(point) ?
946 if (std::string::npos != formatStr.find(
"$(index)")){
947 formatStr = ReleaseToolsString::replaceAllStr1ByStr2(formatStr,
"$(index)", ReleaseToolsString::toSize_tStr(pointIndex));
970template <
typename POINT_CLOUD_TYPE>
973 MLint indexOfFirstPoint=0,
974 bool showIndices=
true,
975 const std::string &lineSeparator=
"\n",
976 int numDecimalPlaces = -1,
977 const std::string &pointsPrintFormatStr=
"")
979 std::string retString;
980 const MLuint64 numPoints = pointCloud.points.size();
981 if ( (maxNumShownPoints>0) && (numPoints > 0) && (indexOfFirstPoint < mlrange_cast<MLint64>(numPoints)) ){
984 if (indexOfFirstPoint < 0){ indexOfFirstPoint = 0; }
985 if (indexOfFirstPoint >= mlrange_cast<MLint64>(numPoints)){
986 indexOfFirstPoint = mlrange_cast<MLint>(numPoints)-1;
988 if (maxNumShownPoints > mlrange_cast<MLint64>(numPoints)){
989 maxNumShownPoints = mlrange_cast<MLint>(numPoints);
991 MLuint64 startPointIdx = mlrange_cast<MLuint64>(indexOfFirstPoint);
992 MLuint64 endPointIdx = mlrange_cast<MLuint64>(indexOfFirstPoint + maxNumShownPoints);
993 if (endPointIdx > numPoints){ endPointIdx = numPoints; }
995 std::string idxPrefix =
"";
996 const std::string colonStr =
":";
999 const size_t firstIdx = mlrange_cast<size_t>(startPointIdx);
1000 const size_t endIdx = mlrange_cast<size_t>(endPointIdx);
1003 retString.reserve((endIdx-firstIdx)*20);
1006 const bool isFormatted = !pointsPrintFormatStr.empty();
1009 std::string lineStr;
1010 lineStr.reserve(512);
1011 for (
size_t c=firstIdx; c < endIdx; ++c){
1013 idxPrefix = ReleaseToolsString::toMLUIntStr(c) + colonStr;
1016 lineStr = pointsPrintFormatStr;
1022 retString += idxPrefix + lineStr + lineSeparator;
1032template <
typename POINT_CLOUD_TYPE>
1036 if (pointCloud.points.size() > 0){
1037 const size_t numMembers = PCLSupportTools::getNumberOfScalarPointMembers(pointCloud);
1038 for (
size_t c=0; c < numMembers; ++c){
1042 retStr += PCLSupportTools::getScalarMemberNameAsString(pointCloud.points[0], c);
1050#define _PCLSupportTools_NewLineDefaultArgumentString "\n"
1067 MLint indexOfFirstVertex=0,
1068 bool showIndices=
true,
1085 MLint maxNumShownIndices,
1086 MLint indexOfFirstIndex,
1099 std::vector<int> &indices);
1113 const std::uint8_t *dataPtr,
1114 int numDecimalPlaces = -1);
1140 MLint indexOfFirstVertex=0,
1141 bool showIndices=
true,
1143 int numDecimalPlaces=-1);
1156 const pcl::uint8_t *dataPtr);
1162 const pcl::uint8_t *dataPtr);
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){}
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; }
1193 std::vector<XYZNormalAndValue> &geometry);
1206template <
typename POINT_CLOUD_TYPE>
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; }
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; }
1252template <
typename POINT_CLOUD_TYPE>
1257 pointCloudOrigin.
assign(0,0,0);
1261 pointCloudOrigin.
assign(
static_cast<float>(doubleBox.
v1[0]),
1262 static_cast<float>(doubleBox.
v1[1]),
1263 static_cast<float>(doubleBox.
v1[2]));
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]);
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]));
1301extern MLPCLSUPPORT_EXPORT const char *
const PointMemberNames[ML_PCL_NUMBER_OF_POINT_MEMBER_NAMES];
1314extern MLPCLSUPPORT_EXPORT const char *
const FloatPointMemberNames[ML_PCL_NUMBER_OF_FLOAT_POINT_MEMBER_NAMES];
1322 const std::string &pointMemberName);
1330 const std::string &pointMemberName);
1338 const std::string &pointMemberName);
1346 const std::string &pointMemberName);
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 v2
Corner v2 of the box region.
bool isEmpty() const
Returns true if any component of v1 is greater than the corresponding component of v2 (which is defin...
Vector6 v1
Corner v1 of the box region.
VectorType v1
Corner v1 of the subimage region (included in region).
VectorType v2
Corner v2 of the subimage region (also included in region!).
void assign(const DT px, const DT py, const DT pz)
Sets all components to the passed values.
DT x
X-component of the vector, same as _buffer[0].
DT z
Z-component of the vector, same as _buffer[2].
DT y
Y-component of the vector, same as _buffer[1].
DT MLAbs(const DT val)
Defines a 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,...
#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.
Basic types used in the MeVislab binding of the Point Cloud Library(PCL).
UINT64 MLuint64
Introduce platform-independent 64-bit unsigned integer type.
MLint64 MLint
A signed ML integer type with at least 64 bits used for index calculations on very large images even ...
pcl::PointCloud< pcl::PointXYZRGBNormal >::Ptr MLPointCloudXYZRGBNormalPtr
The basic pointer type of a point cloud type used in the PCL MeVisLab binding.
pcl::PointCloud< pcl::PointXYZLNormal >::Ptr MLPointCloudXYZLNormalPtr
The basic pointer type of a point cloud type used in the PCL MeVisLab binding.
pcl::PointCloud< pcl::PointXYZ >::Ptr MLPointCloudXYZPtr
The basic pointer type of a point cloud type used in the PCL MeVisLab binding.
pcl::PointCloud< pcl::PointXYZ > MLPointCloudXYZ
The basic point cloud type used in the PCL MeVisLab binding.
pcl::PointCloud< pcl::PointXYZRGBNormal > MLPointCloudXYZRGBNormal
The basic point cloud type used in the PCL MeVisLab binding.
pcl::PointCloud< pcl::PointXYZLNormal > MLPointCloudXYZLNormal
The basic point cloud type used in the PCL MeVisLab binding.
pcl::PolygonMesh::Ptr MLPolygonMeshPtr
The basic pointer type of a pcl::PolygonMesh in the PCL MeVisLab binding.
pcl::PolygonMesh MLPolygonMesh
The basic polygon type of a pcl::PolygonMesh used in the PCL MeVisLab binding.
pcl::PointCloud< pcl::PointXYZINormal >::Ptr MLPointCloudXYZINormalPtr
The basic pointer type of a point cloud type used in the PCL MeVisLab binding.
pcl::PointCloud< pcl::PointXYZINormal > MLPointCloudXYZINormal
The basic point cloud type used in the PCL MeVisLab binding.