26 namespace PCLSupportTools {
46 static_cast<float>(mlVec[1]),
47 static_cast<float>(mlVec[2]));
56 static_cast<float>(mlVec[1]),
57 static_cast<float>(mlVec[2]),
58 static_cast<float>(mlVec[3]));
118 inline bool hasNormals(
const pcl::PointXYZ &) {
return false; }
121 inline bool hasNormals(
const pcl::PointXYZLNormal &) {
return true; }
124 inline bool hasNormals(
const pcl::PointXYZRGBNormal &) {
return true; }
127 inline 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());
178 inline 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()));
191 inline 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());
204 inline 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]);
288 inline 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));
301 inline 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 );
314 inline 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);
332 template <
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;
424 template <
typename POINT_CLOUD_TYPE>
429 typedef typename POINT_CLOUD_TYPE::PointType POINT_TYPE;
434 newPoint.data[3] = fillValue;
435 pc.push_back(newPoint);
442 template <
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) );
515 template <
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;
689 inline unsigned int getPointRGBA(
const pcl::PointXYZRGBNormal &rgbaPnt)
708 rgbaPnt.rgba = srcVal;
727 inline void setPointNormal(pcl::PointXYZLNormal &p,
float nx,
float ny,
float nz)
733 inline void setPointNormal(pcl::PointXYZRGBNormal &p,
float nx,
float ny,
float nz)
739 inline void setPointNormal(pcl::PointXYZINormal &p,
float nx,
float ny,
float nz)
754 inline void getPointNormal(
const pcl::PointXYZ & ,
float &nx,
float &ny,
float &nz)
760 inline void getPointNormal(
const pcl::PointXYZLNormal &p,
float &nx,
float &ny,
float &nz)
766 inline void getPointNormal(
const pcl::PointXYZRGBNormal &p,
float &nx,
float &ny,
float &nz)
772 inline void getPointNormal(
const pcl::PointXYZINormal &p,
float &nx,
float &ny,
float &nz)
785 inline bool hasNormal (
const pcl::PointXYZ &){
return false;}
786 inline bool hasNormal (
const pcl::PointXYZLNormal &){
return true ;}
787 inline bool hasNormal (
const pcl::PointXYZRGBNormal &){
return true ;}
788 inline bool hasNormal (
const pcl::PointXYZINormal &){
return true ;}
796 inline bool hasLabel (
const pcl::PointXYZ &){
return false;}
797 inline bool hasLabel (
const pcl::PointXYZLNormal &){
return true ;}
798 inline bool hasLabel (
const pcl::PointXYZRGBNormal &){
return false;}
799 inline bool hasLabel (
const pcl::PointXYZINormal &){
return false;}
807 inline bool hasRGBA (
const pcl::PointXYZ &){
return false;}
808 inline bool hasRGBA (
const pcl::PointXYZLNormal &){
return false;}
809 inline bool hasRGBA (
const pcl::PointXYZRGBNormal &){
return true ;}
810 inline bool hasRGBA (
const pcl::PointXYZINormal &){
return false;}
820 inline bool hasIntensity(
const pcl::PointXYZRGBNormal &){
return false;}
831 inline bool hasCurvature(
const pcl::PointXYZRGBNormal &){
return true ;}
870 template <
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])")){
884 if (std::string::npos != formatStr.find(
"$(y)")){
887 if (std::string::npos != formatStr.find(
"$(data[1])")){
890 if (std::string::npos != formatStr.find(
"$(z)")){
893 if (std::string::npos != formatStr.find(
"$(data[2])")){
896 if (std::string::npos != formatStr.find(
"$(data[3])")){
900 if (std::string::npos != formatStr.find(
"$(nx)")){
903 if (std::string::npos != formatStr.find(
"$(data_n[0])")){
906 if (std::string::npos != formatStr.find(
"$(ny)")){
909 if (std::string::npos != formatStr.find(
"$(data_n[1])")){
912 if (std::string::npos != formatStr.find(
"$(nz)")){
915 if (std::string::npos != formatStr.find(
"$(data_n[2])")){
918 if (std::string::npos != formatStr.find(
"$(data_n[3])")){
922 if (std::string::npos != formatStr.find(
"$(ir)")){
928 if (std::string::npos != formatStr.find(
"$(curvature)")){
931 if (std::string::npos != formatStr.find(
"$(rgba)")){
936 if (std::string::npos != formatStr.find(
"$(intensity)")){
941 if (std::string::npos != formatStr.find(
"$(label)")){
946 if (std::string::npos != formatStr.find(
"$(index)")){
970 template <
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){
1016 lineStr = pointsPrintFormatStr;
1022 retString += idxPrefix + lineStr + lineSeparator;
1032 template <
typename POINT_CLOUD_TYPE>
1036 if (pointCloud.points.size() > 0){
1038 for (
size_t c=0; c < numMembers; ++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);
1206 template <
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; }
1252 template <
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]));
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!).
ComponentType c
Color component of the vector.
ComponentType t
Time component of the vector.
ComponentType u
Unit/Modality/User component of the vector.
ComponentType z
Z component of the vector.
ComponentType x
X component of the vector.
ComponentType y
Y component of the vector.
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 ...
std::pair< boost::graph_traits< ml_graph_ptr >::vertex_iterator, boost::graph_traits< ml_graph_ptr >::vertex_iterator > vertices(ml_graph_ptr g)
Returns an iterator-range providing access to all the vertices in the graph g.
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.
Tvec3< MLfloat > Vector3f
A vector with three components of type float.
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.
Tvec4< MLfloat > Vector4f
A vector with four components of type float.