Skip to content
Snippets Groups Projects
Commit b8d85c36 authored by Martin Valgur's avatar Martin Valgur Committed by Martin Valgur
Browse files

fix a parallelism bug in transformPointCloud()

Unintentionally sharing a pointer between OMP threads caused the transformed cloud to become partially corrupted.
parent 8145bada
No related branches found
No related tags found
No related merge requests found
...@@ -278,8 +278,6 @@ public: ...@@ -278,8 +278,6 @@ public:
{ {
pcl::PointCloud<PointType>::Ptr cloudOut(new pcl::PointCloud<PointType>()); pcl::PointCloud<PointType>::Ptr cloudOut(new pcl::PointCloud<PointType>());
PointType *pointFrom;
int cloudSize = cloudIn->size(); int cloudSize = cloudIn->size();
cloudOut->resize(cloudSize); cloudOut->resize(cloudSize);
...@@ -288,11 +286,11 @@ public: ...@@ -288,11 +286,11 @@ public:
#pragma omp parallel for num_threads(numberOfCores) #pragma omp parallel for num_threads(numberOfCores)
for (int i = 0; i < cloudSize; ++i) for (int i = 0; i < cloudSize; ++i)
{ {
pointFrom = &cloudIn->points[i]; const auto &pointFrom = cloudIn->points[i];
cloudOut->points[i].x = transCur(0,0) * pointFrom->x + transCur(0,1) * pointFrom->y + transCur(0,2) * pointFrom->z + transCur(0,3); cloudOut->points[i].x = transCur(0,0) * pointFrom.x + transCur(0,1) * pointFrom.y + transCur(0,2) * pointFrom.z + transCur(0,3);
cloudOut->points[i].y = transCur(1,0) * pointFrom->x + transCur(1,1) * pointFrom->y + transCur(1,2) * pointFrom->z + transCur(1,3); cloudOut->points[i].y = transCur(1,0) * pointFrom.x + transCur(1,1) * pointFrom.y + transCur(1,2) * pointFrom.z + transCur(1,3);
cloudOut->points[i].z = transCur(2,0) * pointFrom->x + transCur(2,1) * pointFrom->y + transCur(2,2) * pointFrom->z + transCur(2,3); cloudOut->points[i].z = transCur(2,0) * pointFrom.x + transCur(2,1) * pointFrom.y + transCur(2,2) * pointFrom.z + transCur(2,3);
cloudOut->points[i].intensity = pointFrom->intensity; cloudOut->points[i].intensity = pointFrom.intensity;
} }
return cloudOut; return cloudOut;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment