@@ -183,14 +183,31 @@ namespace {
183
183
auto left_world = ((voxels->bounds ()[0 ].as <long >() + left * szl).as <double >() * sz);
184
184
auto right_world = ((voxels->bounds ()[1 ].as <long >() + left * szl).as <double >() * sz);
185
185
186
- return {
186
+ json_logger::meta_data md = {
187
187
{" count" , (long )voxels->count ()},
188
188
{" grid" , left.format () + " - " + right.format ()},
189
189
{" bounds" , voxels->bounds ()[0 ].format () + " - " + voxels->bounds ()[1 ].format ()},
190
190
{" world" , left_world.format () + " - " + right_world.format ()},
191
191
{" bits" , (long )voxels->value_bits ()},
192
192
{" chunk_size" , (long ) csize}
193
193
};
194
+
195
+ if (voxels->value_bits () == 32 ) {
196
+ uint32_t v, mi = std::numeric_limits<uint32_t >::max (), ma = std::numeric_limits<uint32_t >::min ();
197
+ for (auto & ijk : *(regular_voxel_storage*)voxels) {
198
+ voxels->Get (ijk, &v);
199
+ if (v < mi) {
200
+ mi = v;
201
+ }
202
+ if (v > ma) {
203
+ ma = v;
204
+ }
205
+ }
206
+ md.insert ({ " min_value" , (long )mi });
207
+ md.insert ({ " max_value" , (long )ma });
208
+ }
209
+
210
+ return md;
194
211
}
195
212
return {};
196
213
}
@@ -758,13 +775,12 @@ namespace {
758
775
}
759
776
#else
760
777
template <typename Fn>
761
- void group_by (regular_voxel_storage* groups, abstract_voxel_storage* voxels, Fn fn) {
778
+ void group_by (regular_voxel_storage* groups, abstract_voxel_storage* voxels, Fn fn, bool use_bits= true ) {
762
779
763
780
uint32_t v;
764
781
765
782
std::map<uint32_t , abstract_voxel_storage*> map;
766
783
767
- // @todo this flattens to bits, make this configurable.
768
784
// @todo use regions for multi threading
769
785
for (auto & ijk : *(regular_voxel_storage*)voxels) {
770
786
groups->Get (ijk, &v);
@@ -774,11 +790,21 @@ namespace {
774
790
abstract_voxel_storage* r;
775
791
auto it = map.find (v);
776
792
if (it == map.end ()) {
777
- map.insert ({ v, r = voxels->empty_copy () });
793
+ if (use_bits) {
794
+ static bit_t fmt;
795
+ map.insert ({ v, r = voxels->empty_copy_as (&fmt) });
796
+ } else {
797
+ map.insert ({ v, r = voxels->empty_copy () });
798
+ }
778
799
} else {
779
800
r = it->second ;
780
801
}
781
- r->Set (ijk);
802
+ if (use_bits) {
803
+ r->Set (ijk);
804
+ } else {
805
+ voxels->Get (ijk, &v);
806
+ r->Set (ijk, &v);
807
+ }
782
808
}
783
809
784
810
for (auto & r : map) {
@@ -791,7 +817,7 @@ namespace {
791
817
class op_describe_group_by : public voxel_operation {
792
818
public:
793
819
const std::vector<argument_spec>& arg_names () const {
794
- static std::vector<argument_spec> nm_ = { { true , " output_path" , " string" }, { true , " input" , " voxels" }, { true , " groups" , " voxels" } };
820
+ static std::vector<argument_spec> nm_ = { { true , " output_path" , " string" }, { true , " input" , " voxels" }, { true , " groups" , " voxels" }, { false , " use_bits " , " integer " } };
795
821
return nm_;
796
822
}
797
823
symbol_value invoke (const scope_map& scope) const {
@@ -807,6 +833,8 @@ class op_describe_group_by : public voxel_operation {
807
833
throw std::runtime_error (" Expected a uint stored dataset for groups" );
808
834
}
809
835
836
+ bool use_bits = scope.get_value_or <int >(" use_bits" , 1 ) == 1 ;
837
+
810
838
group_by (groups, voxels, [&ofs, &first](uint32_t id, abstract_voxel_storage* c) {
811
839
if (!first) {
812
840
ofs << " ," ;
@@ -821,6 +849,8 @@ class op_describe_group_by : public voxel_operation {
821
849
}
822
850
#ifdef OLD_GROUP_BY
823
851
,scope.get_value_or <int >(" THREADS" , 1 )
852
+ #else
853
+ , use_bits
824
854
#endif
825
855
);
826
856
0 commit comments