void BinaryVtkFile::writeFile(const std::string & baseFileName) { const std::string nl("\n"); const boost::regex pattern("\n"); const std::string replaceFormat = nl + std::string(indent_l3); std::string pointData = concatenateFields(); char buffer[50]; sprintf(buffer, "%s_node%05d.vtr", baseFileName.c_str(), Ippl::myNode()); std::string headerFileName = baseFileName + std::string(".pvtr"); std::ofstream out(buffer); out << indent_l0 << _header << indent_l1 << "<RectilinearGrid WholeExtent=" << _localGridExtent << ">" << "\n" << indent_l2 << "<Piece Extent=" << _localGridExtent << ">\n" << indent_l3 << boost::regex_replace(pointData, pattern, replaceFormat) << "\n" << indent_l3 << boost::regex_replace(_coordinates, pattern, replaceFormat) << "\n" << indent_l2 << "</Piece>\n" << indent_l1 << "</RectilinearGrid>\n" << indent_l1 << "<AppendedData encoding=\"raw\">\n" << indent_l2 << "_"; out.write(&(_data[0]), _data.size()); out << nl << indent_l1 << "</AppendedData>\n" << indent_l0 << "</VTKFile>" << std::endl; out.close(); writeHeaderFile(baseFileName); }
/** Scanner */ PointCloud<PointNormal>::Ptr Scanner::getCloud(Scan scan, Model &model) { PointCloud<PointNormal>::Ptr cloud (new PointCloud<PointNormal>()); vtkSmartPointer<vtkTransform> transform = compute_transform(scan, model); PointCloud<PointXYZ>::Ptr pcxyz = compute_pcxyz(model, transform); float v[3]; transform->GetPosition(v); PointCloud<Normal>::Ptr pcn = compute_pcn(pcxyz, v[0], v[1], v[2]); concatenateFields(*pcxyz, *pcn, *cloud); return cloud; }
/** * Finalizing the calculation while feeding the cloud with the * normals information. */ PointCloud<PointNormal>::Ptr NormalCalculator::mergeCloudWithNormals() { PointCloud<PointNormal>::Ptr cloud_with_normals (new PointCloud<PointNormal>); concatenateFields(*_cloud, *_normals, *cloud_with_normals); return cloud_with_normals; }