148{
151 return std::nullopt;
152 }
153
155 if (count == 0) {
157 return std::nullopt;
158 }
159
160 const auto indices = select_indices(*
m_archive, count, options.field_names);
161 if (indices.empty()) {
163 return std::nullopt;
164 }
165
166 glm::ivec3 union_min { 0 };
167 glm::ivec3 union_max { 0 };
168 bool have_any = false;
169
170 for (size_t idx : indices) {
171 const auto summary =
m_archive->grid_summary(idx);
172 if (!summary.has_active) {
173 continue;
174 }
175 if (!have_any) {
176 union_min = summary.active_min;
177 union_max = summary.active_max;
178 have_any = true;
179 } else {
180 union_min = glm::min(union_min, summary.active_min);
181 union_max = glm::max(union_max, summary.active_max);
182 }
183 }
184
185 if (!have_any) {
186 set_error(
"Selected grids have no active voxels");
187 return std::nullopt;
188 }
189
190 const auto first =
m_archive->grid_summary(indices.front());
191
192 Kinesis::Lattice3D lattice;
193 lattice.resolution = glm::uvec3(union_max - union_min);
194 lattice.bounds.min = first.translation + first.voxel_size * (glm::vec3(union_min) - 0.5F);
195 lattice.bounds.max = first.translation + first.voxel_size * (glm::vec3(union_max) - 0.5F);
196
198}
void set_error(std::string msg) const
std::optional< Kakshya::VolumeData > materialize(const std::vector< size_t > &indices, const glm::ivec3 ®ion_min, const Kinesis::Lattice3D &lattice) const
Build VolumeData from selected grids over an explicit region.
std::unique_ptr< Detail::VDBArchive > m_archive
std::vector< double > count(std::span< const double > data, size_t n_windows, uint32_t hop_size, uint32_t window_size)
Sample count per window (as double for pipeline uniformity).