点群内の点の法線ベクトルを推定して表示するための次のコードがあります。
int main(int argc, char* argv[]) {
      pcl::PointCloud<pcl::PointXYZ>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZ>);
      if (pcl::io::loadPCDFile<pcl::PointXYZ> ("coffee_mug_1_1_1.pcd", *cloud) == -1) //* load the file
      {
        PCL_ERROR ("Couldn't read file coffee_mug_1_1_1.pcd \n");
        return (-1);
      }
      std::cout << "Loaded "
                << cloud->width * cloud->height
                << " data points from test_pcd.pcd with the following fields: "
                << std::endl;
      pcl::NormalEstimation<pcl::PointXYZ, pcl::Normal> ne;
      ne.setInputCloud (cloud);
      // Create an empty kdtree representation, and pass it to the normal estimation object.
      // Its content will be filled inside the object, based on the given input dataset (as no other search surface is given).
      pcl::search::KdTree<pcl::PointXYZ>::Ptr tree (new pcl::search::KdTree<pcl::PointXYZ> ());
      ne.setSearchMethod (tree);
      // Output datasets
      pcl::PointCloud<pcl::Normal>::Ptr cloud_normals (new pcl::PointCloud<pcl::Normal>);
      // Use all neighbors in a sphere of radius 3cm
      ne.setRadiusSearch (0.03);
      // Compute the features
      ne.compute (*cloud_normals);
      cout << "Computed normals " << cloud_normals->width * cloud_normals->height << cloud_normals->points[0] << endl;    
      pcl::visualization::PCLVisualizer viewer("PCL Viewer");
      viewer.setBackgroundColor(0.0, 0.0, 0.5);
      viewer.addPointCloud(cloud);
      viewer.addPointCloudNormals<pcl::PointXYZ,pcl::Normal>(cloud, cloud_normals);
      while (!viewer.wasStopped ())
      {
          viewer.spinOnce ();
      }
}
しかし、それを実行すると、PCLVisualizerが画面上で点滅し、プログラムが終了します。なぜ留まらないのか分かりません。CloudViewerを使用して(法線ではなく)点群を表示する場合、これは正常に機能し、画面に表示されたままになります。