109int main(
int argc,
char* argv[] )
113 typedef Space::Point
Point;
115 std::cout <<
"Usage: " << argv[ 0 ] <<
" [R=30] [N=30] [D=2]\n";
116 std::cout <<
"Computes the convex hull of N points within a ball of radius R, these points belonging to a lattice of chosen dimension D.\n";
117 double radius = argc > 1 ? atof( argv[ 1 ] ) : 30.0;
118 int nb = argc > 2 ? atoi( argv[ 2 ] ) : 30;
119 int adim = argc > 3 ? atoi( argv[ 3 ] ) : 2;
120 if ( nb < 0 )
return 1;
121 if ( adim < 0 || adim > 3 )
return 1;
124 std::vector< Point >
L = {
Point{ 4, 1, -3 },
Point{ 0, 2, 5 },
Point{ -1, -3, 5 } };
125 std::vector< Point > X
129 int( round( radius+0.5 ) ),
134 bool ok = hull.compute( X );
135 std:: cout << ( ok ?
"[PASSED]" :
"[FAILED]" ) <<
" hull=" << hull <<
"\n";
138 psPoints = polyscope::registerPointCloud(
"Points", X );
139 psVertices = polyscope::registerPointCloud(
"Vertices", hull.positions );
140 if ( hull.affine_dimension <= 1 )
143 psBoundary0 = polyscope::registerPointCloud(
"Convex hull bdy dim=0",
146 else if ( hull.affine_dimension == 2 )
149 psBoundary1 = polyscope::registerCurveNetwork(
"Convex hull bdy dim=1",
150 hull.positions, hull.facets );
151 psBoundary0 = polyscope::registerPointCloud(
"Projected points",
152 hull.projected_points );
153 std::set<Point> S( hull.projected_points.cbegin(),
154 hull.projected_points.cend() );
155 std::cout <<
"Projection basis=[ " << hull.affine_basis.basis()[0]
156 <<
"," << hull.affine_basis.basis()[1] <<
" ]"
157 <<
" d=" << hull.projected_dilation <<
"\n";
159 else if ( hull.affine_dimension == 3 )
162 psBoundary2 = polyscope::registerSurfaceMesh(
"Convex hull bdy dim=2",
163 hull.positions, hull.facets );
165 std::cout <<
" dilation=" << hull.projected_dilation
166 <<
" => counting of lattice points is "
167 << (hull.projected_dilation == 1 ?
"correct" :
"INCORRECT") <<
".\n";
168 std::cout <<
" #(P ∩ Z3)=" << hull.count() <<
"\n";
169 std::cout <<
"#(Int(P) ∩ Z3)=" << hull.countInterior() <<
"\n";
170 std::cout <<
" #(Bd(P) ∩ Z3)=" << hull.countBoundary() <<
"\n";