@@ -231,6 +231,45 @@ TEST (PCL, IterativeClosestPoint)
231231 EXPECT_EQ (transformation (3 , 3 ), 1 );
232232}
233233
234+ TEST (PCL, IterativeClosestPoint_setIndices)
235+ {
236+ pcl::IndicesPtr indices (new pcl::Indices);
237+ for (std::size_t i = 0 ; i < cloud_source.size (); i += 2 )
238+ indices->push_back (i);
239+
240+ IterativeClosestPoint<PointXYZ, PointXYZ> reg_indices;
241+ PointCloud<PointXYZ>::ConstPtr source (cloud_source.makeShared ());
242+ reg_indices.setInputSource (source);
243+ reg_indices.setInputTarget (cloud_target.makeShared ());
244+ reg_indices.setIndices (indices);
245+ reg_indices.setMaximumIterations (50 );
246+ reg_indices.setTransformationEpsilon (1e-8 );
247+ reg_indices.setMaxCorrespondenceDistance (0.05 );
248+
249+ PointCloud<PointXYZ> cloud_reg_indices;
250+ reg_indices.align (cloud_reg_indices);
251+
252+ PointCloud<PointXYZ>::Ptr source_cropped (new PointCloud<PointXYZ>);
253+ pcl::copyPointCloud (*source, *indices, *source_cropped);
254+
255+ IterativeClosestPoint<PointXYZ, PointXYZ> reg_cropped;
256+ reg_cropped.setInputSource (source_cropped);
257+ reg_cropped.setInputTarget (cloud_target.makeShared ());
258+ reg_cropped.setMaximumIterations (50 );
259+ reg_cropped.setTransformationEpsilon (1e-8 );
260+ reg_cropped.setMaxCorrespondenceDistance (0.05 );
261+
262+ PointCloud<PointXYZ> cloud_reg_cropped;
263+ reg_cropped.align (cloud_reg_cropped);
264+
265+ Eigen::Matrix4f trans_indices = reg_indices.getFinalTransformation ();
266+ Eigen::Matrix4f trans_cropped = reg_cropped.getFinalTransformation ();
267+
268+ for (int y = 0 ; y < 4 ; y++)
269+ for (int x = 0 ; x < 4 ; x++)
270+ EXPECT_NEAR (trans_indices (y, x), trans_cropped (y, x), 1e-5 );
271+ }
272+
234273TEST (PCL, IterativeClosestPointWithNormals)
235274{
236275 IterativeClosestPointWithNormals<PointNormal, PointNormal, float > reg_float;
0 commit comments