58#include "DGtal/base/Common.h"
59#include "DGtal/geometry/volumes/ConvexityHelper.h"
60#include "DGtal/geometry/volumes/BoundedLatticePolytope.h"
62int main(
int argc,
char* argv[] )
64 int N = argc > 1 ? atoi( argv[ 1 ] ) : 10;
65 int nb = argc > 2 ? atoi( argv[ 2 ] ) : 10;
66 int R = argc > 3 ? atoi( argv[ 3 ] ) : 50;
71 typedef Helper::LatticePolytope Polytope;
72 typedef Polytope::Point
Point;
75 std::vector< Polytope > polytopes;
76 int sum_nb_facets = 0;
77 for (
int i = 0; i < N; i++ )
79 std::vector< Point > V;
80 for (
int i = 0; i < nb; i++ ) {
81 Point p( rand() % (2*R+1) - R, rand() % (2*R+1) - R,
82 rand() % (2*R+1) - R, rand() % (2*R+1) - R );
85 Polytope P = Helper::computeLatticePolytope( V );
86 sum_nb_facets += P.nbHalfSpaces();
87 polytopes.push_back( P );
91 <<
" 4D polytopes with " << ( sum_nb_facets / (double) N )
92 <<
" facets on average, in " << t1 <<
" ms." << std::endl;
95 std::size_t slow_nb = 0;
96 std::vector< Integer > slow_counts;
97 for (
const auto& P : polytopes )
99 const auto nb = P.countByScanning();
101 slow_counts.push_back( nb );
106 std::size_t fast_nb = 0;
107 std::vector< Integer > fast_counts;
108 for (
const auto& P : polytopes )
110 const auto nb = P.count();
112 fast_counts.push_back( nb );
115 bool ok = std::equal( slow_counts.cbegin(), slow_counts.cend(), fast_counts.cbegin() );
116 DGtal::trace.
info() <<
"Computed inside points is " << ( ok ?
"OK" :
"ERROR" ) << std::endl;
118 <<
" points in " << t2 <<
" ms." << std::endl;
120 <<
" points in " << t3 <<
" ms." << std::endl;
void beginBlock(const std::string &keyword="")
Point::Coordinate Integer
Aim: Provides a set of functions to facilitate the computation of convex hulls and polytopes,...