91 if (!ply_f_dc_0_attr || !ply_f_dc_1_attr || !ply_f_dc_2_attr) {
94 Span<float> ply_f_dc[3] = {*ply_f_dc_0_attr, *ply_f_dc_1_attr, *ply_f_dc_2_attr};
97 if (!ply_opacity_attr) {
106 if (!ply_scale_0_attr || !ply_scale_1_attr || !ply_scale_2_attr) {
109 const Span<float> ply_scale[3] = {*ply_scale_0_attr, *ply_scale_1_attr, *ply_scale_2_attr};
116 if (!ply_rot_0_attr || !ply_rot_1_attr || !ply_rot_2_attr || !ply_rot_3_attr) {
119 Span<float> ply_rot[4] = {*ply_rot_0_attr, *ply_rot_1_attr, *ply_rot_2_attr, *ply_rot_3_attr};
122 data.vertices.size());
124 bool success =
false;
131 point_cloud->positions_for_write().copy_from(
data.vertices);
139 int num_file_coefficients = int(f_rest.
size() / 3);
149 "PLY Importer: Spherical harmonics degree above the supported %d, spherical "
150 "harmonics are not imported",
152 num_file_coefficients = 0;
154 else if (f_rest.
size() % 3 != 0) {
157 "PLY Importer: Unexpected number of f_rest properties %d, spherical harmonics "
160 num_file_coefficients = 0;
167 "PLY Importer: Incomplete spherical harmonics band, importing %d of %d "
170 num_file_coefficients);
182 for (
int i = 0; i <
data.vertices.size(); i++) {
183 radiance_base[i] =
float4(ply_f_dc[0][i], ply_f_dc[1][i], ply_f_dc[2][i], ply_opacity[i]);
184 scale[i] =
float3(ply_scale[0][i], ply_scale[1][i], ply_scale[2][i]);
186 math::Quaternion(ply_rot[0][i], ply_rot[1][i], ply_rot[2][i], ply_rot[3][i]));
191 for (
int dimension = 0; dimension < num_sh_dimensions; dimension++) {
192 sh_attrs[dimension][i] =
float3(f_rest[dimension][i],
193 f_rest[dimension + num_file_coefficients][i],
194 f_rest[dimension + 2 * num_file_coefficients][i]);
212 attributes.
add<
float>(attr.
name,