1#include "DGtal/helpers/StdDefs.h"
2#include "DGtal/helpers/Shortcuts.h"
3#include "DGtal/io/readers/VolReader.h"
4#include "DGtal/kernel/sets/DigitalSetByOctree.h"
15const auto CountingFunction = [](
Z3i::Point,
const std::vector<Z3i::Point>& neighborhood) {
16 return neighborhood.size();
22 inline static std::vector<std::vector<Z3i::Point>>
shapes;
23 inline static std::vector<Z3i::Domain>
domains;
24 inline static std::vector<std::string>
names;
27 if (
shapes.size() != 0)
return;
29 const auto polys = SH3::getPolynomialList();
30 const double steps[] = { 1.00, 0.50, 0.25 };
31 const double noises[] = { 0.00, 0.10 };
33 for (
const auto& poly : polys) {
34 for (
const auto& step : steps) {
35 for (
const auto& noise : noises) {
37 auto params = SH3::defaultParameters();
38 params(
"polynomial", poly.second )
42 auto ishape = SH3::makeImplicitShape3D(params);
43 auto dshape = SH3::makeDigitizedImplicitShape3D(ishape, params);
44 auto nshape = SH3::makeBinaryImage(dshape, params);
46 const std::string name = poly.first +
"_" + std::to_string(step) +
"_" + std::to_string(noise);
47 const auto domain = nshape->domain();
49 names.push_back(name);
50 domains.push_back(nshape->domain());
54 if (nshape->operator()(*it) != 0) {
55 shapes.back().push_back(*it);
62 std::cout <<
"Shapes: " << std::endl;
63 for (
const auto& n :
names) {
64 std::cout <<
"\t -" << n << std::endl;
69TEST_CASE_METHOD(
BenchInfo,
"Benchmarking DigitalSetByOctree using Catch2",
"[catch]")
71 auto i = GENERATE(range(0, (
int)names.size()));
73 const auto& name = names[i];
74 const auto&
domain = domains[i];
75 const auto& pts = shapes[i];
78 for (
const auto& pt : pts) {
86 for (
const auto& pt : pts) {
91 BENCHMARK_ADVANCED(
"Octree To DAG: " + name)(Catch::Benchmark::Chronometer meter)
93 Octree subtree = tree;
96 subtree.convertToDAG();
103 for (
auto it = tree.begin(); it != tree.end(); ++it) {
109 size_t oldMemory = tree.memoryFootprint();
111 size_t count = 0;
for (
auto it = tree.begin(); it != tree.end(); ++it) count++;
113 std::cout <<
"\n\n Stats:\n" << std::endl;
114 std::cout <<
"\t Domain: " << tree.domain() << std::endl;
115 std::cout <<
"\t Memory footprint (octree): " << oldMemory <<
" bytes." << std::endl;
116 std::cout <<
"\t Memory footprint (dag) : " << tree.memoryFootprint() <<
" bytes." << std::endl;
117 std::cout <<
"\t Voxel count (source): " << pts.size() << std::endl;
118 std::cout <<
"\t Voxel count (dag) : " << count << std::endl;
119 std::cout << std::endl;
121 BENCHMARK(
"Counting number of voxel: " + name)
123 tree.computeFunction(tree.begin(), tree.end(), 1, CountingFunction);
A DigitalSet that stores voxels as an octree, or a DAG.
const ConstIterator & begin() const
const ConstIterator & end() const
Aim: implements association bewteen points lying in a digital domain and values.
Aim: This class is used to simplify shape and surface creation. With it, you can create new shapes an...
DGtal is the top-level namespace which contains all DGtal functions and types.
static std::vector< std::vector< Z3i::Point > > shapes
static std::vector< Z3i::Domain > domains
static std::vector< std::string > names
BENCHMARK(BM_StringCreation)