33#include "DGtal/helpers/StdDefs.h"
34#include "DGtal/kernel/sets/DigitalSetByOctree.h"
35#include "DGtalCatch.h"
37#include "DGtal/io/writers/VolWriter.h"
38#include "DGtal/io/readers/VolReader.h"
39#include "DGtal/io/writers/SVOWriter.h"
40#include "DGtal/io/readers/SVOReader.h"
84 using namespace DGtal;
98 for (
int i = 0; i < testPointCount; ++i)
99 octree.
insert(testPoints[i]);
104 SECTION(
"Testing if points exists")
107 for (
int i = 0; i < testPointCount; ++i)
108 octree.
insert(testPoints[i]);
110 for (
int i = 0; i <
sizeof(testPoints) /
sizeof(
Z3i::Point); ++i)
111 REQUIRE(testPointsValid[i] == octree(testPoints[i]));
114 SECTION(
"Testing iterating over octree")
117 for (
int i = 0; i < testPointCount; ++i)
118 octree.
insert(testPoints[i]);
121 for (
auto it = octree.
begin(); it != octree.
end(); ++it, ++i)
123 if (i >= validPointCount)
128 REQUIRE(*it == validPoints[i]);
132 SECTION(
"Testing erasing points")
135 for (
int i = 0; i < testPointCount; ++i)
136 octree.
insert(testPoints[i]);
138 octree.
erase(testPoints[0]);
141 for (
auto it = octree.
begin(); it != octree.
end(); ++it)
147 SECTION(
"Test DAG on simple case")
149 const unsigned int lvl = 4;
150 const int size = (1 << lvl);
153 std::vector<size_t> expectedRslt(size, 3);
154 expectedRslt.front() = 2;
155 expectedRslt.back() = 2;
163 for (
size_t i = 0; i < size; ++i)
164 octree.insert(
Z3i::Point{(int)i, (int)i, (int)i});
166 octree.convertToDAG();
168 auto lmbd = [](
Z3i::Point,
const std::vector<Z3i::Point>& neighborhood)
170 return neighborhood.size();
172 auto rslt = octree.computeFunction(octree.begin(), octree.end(), 1, lmbd);
174 REQUIRE(octree.memoryFootprint() == expectedMemory);
180 const unsigned int start = 5;
181 const unsigned int end = 10;
183 for (
unsigned int i = 0; i < (end - start); ++i)
185 const int c = (int)start + (
int)i;
193 auto it1 = octree1.begin();
194 auto it2 = octree2.begin();
196 for (; it1 != octree1.end() && it2 != octree2.end(); ++it1, ++it2)
A DigitalSet that stores voxels as an octree, or a DAG.
void insert(const Point &p)
Inserts a new point in the octree.
size_t erase(const Iterator &it)
Remove a voxel from the octree.
size_t size() const
Returns the number of voxel in the set.
void convertToDAG()
Converts the octree to DAG.
Iterator end()
Returns an iterator to the end of the octree.
const Domain & domain() const
Returns the domain of the digital set.
Iterator begin() const
Returns an iterator to the begining of the octree.
const Point & lowerBound() const
const Point & upperBound() const
static Octree importSVO(const std::string &filename)
Imports an octree from a file.
static bool exportSVO(const std::string &filename, const DigitalSetByOctree< Space > &octree, const bool compressed=true)
Exports an octree to a file.
HyperRectDomain< Space > Domain
DGtal is the top-level namespace which contains all DGtal functions and types.
Aim: Represents a set of points within the given domain. This set of points is modifiable by the user...
static const Z3i::Point validPoints[5]
static const Z3i::Domain expectedDomain
static const bool testPointsValid[8]
static const Z3i::Domain domain
static const size_t validPointCount
static const size_t testPointCount
static const Z3i::Point testPoints[8]
TEST_CASE_METHOD(TestFixture, "Testing DigitalSetByOctree using Catch2", "[catch]")
SECTION("Testing constant forward iterators")
REQUIRE(domain.isInside(aPoint))