void PlyWriter::writePoint(PointRef& point, PointLayoutPtr layout) { for (auto it = m_dims.begin(); it != m_dims.end();) { Dimension::Id dim = *it; writeValue(point, dim, layout->dimType(dim)); ++it; if (m_format == Format::Ascii && it != m_dims.end()) *m_stream << " "; } if (m_format == Format::Ascii) *m_stream << std::endl; }
void FerryFilter::addDimensions(PointLayoutPtr layout) { for (auto& info : m_dims) { const Dimension::Id fromId = layout->findDim(info.m_fromName); // Dimensions being created with the "=>Dim" syntax won't // be in the layout, so we have to assign a default type. Dimension::Type fromType = layout->dimType(fromId); if (fromType == Dimension::Type::None) fromType = Dimension::Type::Double; info.m_toId = layout->registerOrAssignDim(info.m_toName, fromType); } }
inline MetadataNode toMetadata(PointTableRef table) { const PointLayoutPtr layout(table.layout()); MetadataNode root; for (const auto& id : layout->dims()) { MetadataNode dim("dimensions"); dim.add("name", layout->dimName(id)); Dimension::Type::Enum t = layout->dimType(id); dim.add("type", Dimension::toName(Dimension::base(t))); dim.add("size", layout->dimSize(id)); root.addList(dim); } return root; }
void PlyWriter::writeHeader(PointLayoutPtr layout) const { *m_stream << "ply" << std::endl; *m_stream << "format " << m_format << " 1.0" << std::endl; *m_stream << "comment Generated by PDAL" << std::endl; *m_stream << "element vertex " << pointCount() << std::endl; auto ni = m_dimNames.begin(); for (auto dim : m_dims) { std::string name = *ni++; std::string typeString = getType(layout->dimType(dim)); *m_stream << "property " << typeString << " " << name << std::endl; } if (m_faces) { *m_stream << "element face " << faceCount() << std::endl; *m_stream << "property list uint8 uint32 vertex_indices" << std::endl; } *m_stream << "end_header" << std::endl; }