34#include "DGtal/base/Common.h"
35#include "DGtal/kernel/SpaceND.h"
36#include "DGtal/geometry/tools/GenericLatticeConvexHull.h"
37#include "DGtal/geometry/tools/AffineGeometry.h"
38#include "DGtalCatch.h"
47template <
typename Po
int>
51 std::vector< Point > V;
52 Point c = Point::diagonal( R );
53 double R2 = (double) R * (
double) R;
54 for (
int i = 0; i < nb; ) {
57 p[ k ] = rand() % (2*R);
58 if ( ( p - c ).squaredNorm() < R2 ) { V.push_back( p ); i++; }
63template <
typename Po
int >
67 std::uniform_int_distribution<int> U(-10, 10);
72 for (
auto i = 0; i < n; i++ )
75 for (
auto k = 0; k < nb; k++ )
78 for (
auto i = 0; i < m; i++ )
85 std::shuffle( P.begin(), P.end(),
g );
93SCENARIO(
"GenericLatticeConvexHull< ConvexHullIntegralKernel< 2 > > unit tests",
"[genquickhull][integral_kernel][2d]" )
100 GIVEN(
"Given a set { } " ) {
101 std::vector<Point> V = { };
103 bool ok = hull.compute( V );
104 std::cout << hull << std::endl;
105 THEN(
"Everything went fine and dim=-1." ) {
107 REQUIRE( hull.affine_dimension == -1 );
111 GIVEN(
"Given a set { (2,1), (2,1) } " ) {
115 bool ok = hull.compute( V );
116 std::cout << hull << std::endl;
117 THEN(
"Everything went fine and dim=0." ) {
119 REQUIRE( hull.affine_dimension == 0 );
123 GIVEN(
"Given a set { (0,0), (-4,-1), (8, 2), (16,4) } " ) {
127 bool ok = hull.compute( V );
128 std::cout << hull << std::endl;
129 THEN(
"Everything went fine and dim=1." ) {
131 REQUIRE( hull.affine_dimension == 1 );
135 GIVEN(
"Given a set { (0,0), (-4,-1), (-3,5), (7,3), (5, -2), (2, 2) } " ) {
137 = {
Point(0,0),
Point(-4,-1),
Point(-3,5),
Point(7,3),
Point(5, -2),
Point(2,2) };
139 bool ok = hull.compute( V );
140 std::cout << hull << std::endl;
141 THEN(
"Everything went fine and dim=2." ) {
143 REQUIRE( hull.affine_dimension == 2 );
144 REQUIRE( hull.count() > V.size() );
150SCENARIO(
"GenericLatticeConvexHull< ConvexHullIntegralKernel< 3 > > unit tests",
"[genquickhull][integral_kernel][3d]" )
156 std::vector< Point > V1 = {
Point{ 5,-2, 1 } };
158 std::vector< Point > V2 = {
Point{ 5,-2, 1 },
Point{ -3, 4, 2 } };
160 std::vector< Point > V3 = {
Point{ 5,-2, 1 },
Point{ -3, 4, 2 },
Point{ 1, -7, 11 } };
163 GIVEN(
"Given a 1-d lattice set in Z3 " ) {
165 bool ok = hull.compute( X1 );
166 std::cout << hull << std::endl;
167 THEN(
"Everything went fine and dim=1." ) {
170 REQUIRE( hull.affine_dimension == 1 );
174 GIVEN(
"Given a 2-d lattice set in Z3 " ) {
176 bool ok = hull.compute( X2 );
177 std::cout << hull << std::endl;
178 THEN(
"Everything went fine and dim=2." ) {
180 REQUIRE( hull.affine_dimension == 2 );
184 GIVEN(
"Given a 3-d lattice set in Z3 " ) {
186 bool ok = hull.compute( X3 );
187 std::cout << hull << std::endl;
188 THEN(
"Everything went fine and dim=3." ) {
190 REQUIRE( hull.affine_dimension == 3 );
PointVector< dim, Integer > Point
DGtal is the top-level namespace which contains all DGtal functions and types.
DGtal::uint32_t Dimension
Aim: Implements the quickhull algorithm by Barber et al. barber1996, a famous arbitrary dimensional c...
GIVEN("A cubical complex with random 3-cells")
std::vector< Point > randomPointsInBall(int nb, int R)
std::vector< Point > makeRandomLatticePointsFromDirVectors(int nb, const vector< Point > &V)
REQUIRE(domain.isInside(aPoint))
SCENARIO("UnorderedSetByBlock< PointVector< 2, int > unit tests with 32 bits blocks", "[unorderedsetbyblock][2d]")