50 unsigned int nb = 0, nbok = 0;
55 trace.beginBlock (
"Load vol file -> build digital surface -> estimate mean curvature -> save OBJ." );
59 params(
"colormap",
"Tics" );
69 std::transform( curv.cbegin(), curv.cend(), colors.begin(), cmap );
73 ++nb; nbok += ok ? 1 : 0;
77 trace.beginBlock (
"Load vol file -> build digital surface -> estimate Gauss curvature -> save OBJ." );
80 params(
"colormap",
"Tics" );
88 std::transform( curv.cbegin(), curv.cend(), colors.begin(), cmap );
91 ++nb; nbok += ok ? 1 : 0;
95 trace.beginBlock (
"Build polynomial shape -> digitize -> extract ground-truth geometry." );
99 params(
"polynomial",
"3*x^2+2*y^2+z^2-90" )(
"gridstep", 0.25 );
113 trace.info() <<
" min(H)=" << stat_mean.min()
114 <<
" avg(H)=" << stat_mean.mean()
115 <<
" max(H)=" << stat_mean.max() << std::endl;
116 trace.info() <<
" min(G)=" << stat_gauss.min()
117 <<
" avg(G)=" << stat_gauss.mean()
118 <<
" max(G)=" << stat_gauss.max() << std::endl;
119 ++nb; nbok += positions.size() == surfels.size() ? 1 : 0;
120 ++nb; nbok += normals.size() == surfels.size() ? 1 : 0;
121 ++nb; nbok += mean_curvs.size() == surfels.size() ? 1 : 0;
122 ++nb; nbok += gauss_curvs.size() == surfels.size() ? 1 : 0;
123 ++nb; nbok += stat_mean.min() > 0.08 ? 1 : 0;
124 ++nb; nbok += stat_gauss.min() > 0.0064 ? 1 : 0;
128 trace.beginBlock (
"Build polynomial shape -> digitize -> get pointels -> save projected quadrangulated surface." );
132 const double h = 0.25;
133 params(
"polynomial",
"goursat" )(
"gridstep", h );
143 std::transform( pointels.cbegin(), pointels.cend(), pos.begin(),
144 [&] (
const SH3::Cell& c) { return h * embedder( c ); } );
147 [&] (
const SH3::Cell& c){
return ppos[ c2i[ c ] ];},
149 "goursat-quad-proj.obj" );
151 ++nb; nbok += ok ? 1 : 0;
155 trace.beginBlock (
"Build polynomial shape -> digitize -> extract mean curvature -> save as OBJ with colors." );
159 params(
"polynomial",
"goursat" )(
"gridstep", 0.25 )(
"colormap",
"Tics" );
169 std::transform( mean_curv.cbegin(), mean_curv.cend(), colors.begin(), cmap );
173 ++nb; nbok += ok ? 1 : 0;
177 trace.beginBlock (
"Build polynomial shape -> digitize -> extract ground-truth and estimated mean curvature -> display errors in OBJ with colors." );
181 params(
"polynomial",
"goursat" )(
"gridstep", 0.25 )(
"colormap",
"Tics" )
193 std::transform( t_curv.cbegin(), t_curv.cend(), colors.begin(), cmap );
195 std::transform( ii_curv.cbegin(), ii_curv.cend(), colors.begin(), cmap );
200 std::transform( errors.cbegin(), errors.cend(), colors.begin(), cmap_errors );
207 ++nb; nbok += ( ok_t && ok_ii && ok_err ) ? 1 : 0;
211 trace.beginBlock (
"Build polynomial shape -> digitize -> build digital surface -> save primal surface with VCM normals as obj." );
215 params(
"polynomial",
"goursat" )(
"gridstep", 0.25 )
216 (
"surfaceTraversal",
"Default" );
225 "goursat-primal-vcm.obj" );
227 ++nb; nbok += ok ? 1 : 0;
231 trace.beginBlock (
"Build polynomial shape -> digitize implicitly -> estimate II normals and curvature." );
235 params(
"polynomial",
"goursat" )(
"gridstep", .25 );
243 trace.beginBlock(
"II with default traversal (slower)" );
246 trace.beginBlock(
"II with depth-first traversal (faster)" );
253 for (
SH3::Idx i = 0; i < colors.size(); i++ )
254 colors[ i ] = cmap( ii_mean_curv[ match[ i ] ] );
257 ++nb; nbok += ( ok_H && ii_mean_curv.size() == ii_mean_curv2.size() ) ? 1 : 0;
261 trace.beginBlock (
"Build polynomial shape -> save several projected quadrangulated surface and digitized boundaries." );
264 std::vector<double> gridsteps {0.5, 0.25, 0.125};
265 for (
auto h : gridsteps ) {
266 params(
"polynomial",
"goursat" )(
"gridstep", h );
276 std::transform( pointels.cbegin(), pointels.cend(), pos.begin(),
277 [&] (
const SH3::Cell& c) { return h * embedder( c ); } );
279 auto fname = std::string(
"goursat-quad-" ) + std::to_string( h ) + std::string(
".obj" );
281 [&] (
const SH3::Cell& c){
return pos[ c2i[ c ] ];},
284 auto proj_fname = std::string(
"goursat-quad-proj-" ) + std::to_string( h ) + std::string(
".obj" );
286 [&] (
const SH3::Cell& c){
return ppos[ c2i[ c ] ];},
289 ++nb; nbok += ok ? 1 : 0;
290 ++nb; nbok += proj_ok ? 1 : 0;
295 trace.beginBlock (
"Build polynomial shape -> digitize -> digital surface -> save primal surface and VCM normal field as obj." );
299 params(
"polynomial",
"goursat" )(
"gridstep", 0.5 )
300 (
"surfaceTraversal",
"Default" );
310 std::transform( surfels.cbegin(), surfels.cend(), positions.begin(),
311 [&] (
const SH3::SCell& c) { return embedder( c ); } );
313 "goursat-primal-vcm.obj" );
315 "goursat-primal-vcm-normals.obj",
318 ++nb, nbok += ok ? 1 : 0;
319 ++nb, nbok += ok2 ? 1 : 0;
323 trace.beginBlock (
"Build polynomial shape -> digitize -> extract ground-truth curvatures -> display in OBJ." );
327 params(
"polynomial",
"goursat" )(
"gridstep", 0.25 )(
"colormap",
"Tics" );
340 std::transform( surfels.cbegin(), surfels.cend(), positions.begin(),
341 [&] (
const SH3::SCell& c) { return embedder( c ); } );
343 "goursat-primal.obj" );
347 std::transform( k1.cbegin(), k1.cend(), colors.begin(), cmap );
350 "goursat-primal-d1.obj", SH3::Color::Black );
351 std::transform( k2.cbegin(), k2.cend(), colors.begin(), cmap );
354 "goursat-primal-d2.obj", SH3::Color::Black );
355 ASSERT(ok_k1 && ok_d1 && ok_k2 && ok_d2);
360 trace.beginBlock(
"Load mesh file -> estimate mean/gaussian/principal curvatures -> display in obj" );
364 params(
"r-radius", 0.1);
374 std::transform( mcurv.cbegin(), mcurv.cend(), mcolors.begin(), cmap );
377 std::transform( gcurv.cbegin(), gcurv.cend(), gcolors.begin(), cmap );
380 std::transform( k1.begin(), k1.end(), k1colors.begin(), cmap);
383 std::transform( k2.begin(), k2.end(), k2colors.begin(), cmap);
398#if defined(DGTAL_WITH_EIGEN)
399 trace.beginBlock (
"Load vol file -> build main digital surface -> II normals -> AT regularization -> save OBJ with colored normals." );
413 ii_normals, params );
416 for (
size_t i = 0; i < surfels.size(); i++ )
417 colors[ i ] =
SH3::Color( (
unsigned char) 255.0*fabs( at_normals[ i ][ 0 ] ),
418 (
unsigned char) 255.0*fabs( at_normals[ i ][ 1 ] ),
419 (
unsigned char) 255.0*fabs( at_normals[ i ][ 2 ] ) );
425 for (
size_t i = 0; i < linels.size(); i++ )
427 if ( features[ i ] < 0.5 )
431 const SH3::Cell p0 =
K.uIncident( linel, d,
false );
432 const SH3::Cell p1 =
K.uIncident( linel, d,
true );
433 f0.push_back( uembedder( p0 ) );
434 f1.push_back( uembedder( p1 ) - uembedder( p0 ) );
441 ++nb; nbok += ok1 ? 1 : 0;
442 ++nb; nbok += ok2 ? 1 : 0;
443 ++nb; nbok += ok3 ? 1 : 0;
449#if DGTAL_WITH_POLYSCOPE
450 trace.beginBlock(
"Load vol file -> Compute VoronoiMap -> Display in Viewer" );
455 auto domain = bimage->domain();
458 std::vector<SH3::Point> sites;
459 std::copy_if(
domain.begin(),
461 std::back_inserter(sites),
472 for (
auto it =
domain.begin(); it !=
domain.end(); ++it)
476 "L1 distance", vmap1(*it)
477 ),
"L2 distance", vmap2(*it)
489 trace.info() << nbok <<
"/" << nb <<
" passed tests." << std::endl;