MCPcopy Create free account
hub / github.com/PointCloudLibrary/pcl / writeASCII

Method writeASCII

io/src/ply_io.cpp:925–969  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

923////////////////////////////////////////////////////////////////////////////////////////
924
925int
926pcl::PLYWriter::writeASCII (const std::string &file_name,
927 const pcl::PCLPointCloud2 &cloud,
928 const Eigen::Vector4f &origin,
929 const Eigen::Quaternionf &orientation,
930 int precision,
931 bool use_camera)
932{
933 if (cloud.data.empty ())
934 {
935 PCL_ERROR ("[pcl::PLYWriter::writeASCII] Input point cloud has no data!\n");
936 return (-1);
937 }
938
939 std::ofstream fs;
940 fs.precision (precision);
941 // Open file
942 fs.open (file_name.c_str ());
943 if (!fs)
944 {
945 PCL_ERROR ("[pcl::PLYWriter::writeASCII] Error during opening (%s)!\n", file_name.c_str ());
946 return (-1);
947 }
948
949 unsigned int nr_points = cloud.width * cloud.height;
950
951 // Write the header information if available
952 if (use_camera)
953 {
954 fs << generateHeader (cloud, origin, orientation, false, use_camera, nr_points);
955 writeContentWithCameraASCII (nr_points, cloud, origin, orientation, fs);
956 }
957 else
958 {
959 std::ostringstream os;
960 int nr_valid_points;
961 writeContentWithRangeGridASCII (nr_points, cloud, os, nr_valid_points);
962 fs << generateHeader (cloud, origin, orientation, false, use_camera, nr_valid_points);
963 fs << os.str ();
964 }
965
966 // Close file
967 fs.close ();
968 return (0);
969}
970
971void
972pcl::PLYWriter::writeContentWithCameraASCII (int nr_points,

Callers 4

mainFunction · 0.45
saveCloudFunction · 0.45
savePointCloudFunction · 0.45
TESTFunction · 0.45

Calls 4

strMethod · 0.80
emptyMethod · 0.45
openMethod · 0.45
closeMethod · 0.45

Tested by 1

TESTFunction · 0.36