122int main(
int argc,
char* argv[] )
126 typedef Space::Point Point4;
128 std::cout <<
"Usage: " << argv[ 0 ] <<
" [R=30] [N=30] [D=2]\n";
129 std::cout <<
"Computes the convex hull of N 4D points within a ball of radius R, these points belonging to a lattice of chosen dimension 0<=D<=3. The output is projected along the 4 canonic projections onto 3D space. You cannot choose D=4 since we cannot diplay the result in 3D.\n";
130 double radius = argc > 1 ? atof( argv[ 1 ] ) : 30.0;
131 int nb = argc > 2 ? atoi( argv[ 2 ] ) : 30;
132 int adim = argc > 3 ? atoi( argv[ 3 ] ) : 2;
133 if ( nb < 0 )
return 1;
134 if ( adim < 0 || adim > 3 )
return 1;
137 std::vector< Point4 >
L = { Point4{ 4, 1, -3, 1 },
138 Point4{ 0, 2, 5, -1 },
139 Point4{ -1, -3, 5, 0 },
140 Point4{ 2, 0, 3, -3 } };
141 std::vector< Point4 > X
145 int( round( radius+0.5 ) ),
150 bool ok = hull.compute( X );
151 std:: cout << ( ok ?
"[PASSED]" :
"[FAILED]" ) <<
" hull=" << hull <<
"\n";
154 std::string proj[ 4 ] = {
"(yzw)",
"(xzw)",
"(xyw)",
"(xyz)" };
157 group [k] = polyscope::createGroup( proj[k] );
158 psPoints [k] = polyscope::registerPointCloud( proj[k]+
" Points",
160 psVertices[k] = polyscope::registerPointCloud( proj[k]+
" Vertices",
161 project( k, hull.positions ) );
162 psPoints [k]->addToGroup( proj[k] );
165 if ( hull.affine_dimension <= 1 )
168 psBoundary0[k] = polyscope::registerPointCloud( proj[k]+
" Convex hull bdy dim=0",
169 project( k, hull.positions ) );
172 else if ( hull.affine_dimension == 2 )
175 psBoundary1[k] = polyscope::registerCurveNetwork( proj[k]+
" Convex hull bdy dim=1",
180 else if ( hull.affine_dimension == 3 )
183 psBoundary2[k] = polyscope::registerSurfaceMesh( proj[k]+
" Convex hull bdy dim=2",
static DGtal::PointVector< dim-1, TComponent, TContainer > project(Dimension k, const DGtal::PointVector< dim, TComponent, TContainer > &p)