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;
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) {
38 params(
"polynomial", poly.second )
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());
53 for (
auto it =
domain.begin(); it !=
domain.end(); ++it) {
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;
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.
void convertToDAG()
Converts the octree to DAG.
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...
static std::map< std::string, std::string > getPolynomialList()
static CountedPtr< DigitizedImplicitShape3D > makeDigitizedImplicitShape3D(CountedPtr< ImplicitShape3D > shape, Parameters params=parametersDigitizedImplicitShape3D())
static Parameters defaultParameters()
static CountedPtr< BinaryImage > makeBinaryImage(Domain shapeDomain)
static CountedPtr< ImplicitShape3D > makeImplicitShape3D(const Parameters ¶ms=parametersImplicitShape3D())
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)