49{
50 unsigned int nb = 0, nbok = 0;
51
54
55 trace.
beginBlock (
"Load vol file -> build digital surface -> estimate mean curvature -> save OBJ." );
56 {
59 params( "colormap", "Tics" );
60
61
67
68
71 std::transform( curv.cbegin(), curv.cend(), colors.begin(), cmap );
73 "al-H-II.obj" );
75 ++nb; nbok += ok ? 1 : 0;
76 }
78
79 trace.
beginBlock (
"Load vol file -> build digital surface -> estimate Gauss curvature -> save OBJ." );
80 {
82 params( "colormap", "Tics" );
90 std::transform( curv.cbegin(), curv.cend(), colors.begin(), cmap );
92 "al-G-II.obj" );
93 ++nb; nbok += ok ? 1 : 0;
94 }
96
97 trace.
beginBlock (
"Build polynomial shape -> digitize -> extract ground-truth geometry." );
98 {
101 params( "polynomial", "3*x^2+2*y^2+z^2-90" )( "gridstep", 0.25 );
115 trace.
info() <<
" min(H)=" << stat_mean.min()
116 << " avg(H)=" << stat_mean.mean()
117 << " max(H)=" << stat_mean.max() << std::endl;
118 trace.
info() <<
" min(G)=" << stat_gauss.min()
119 << " avg(G)=" << stat_gauss.mean()
120 << " max(G)=" << stat_gauss.max() << std::endl;
121 ++nb; nbok += positions.size() == surfels.size() ? 1 : 0;
122 ++nb; nbok += normals.size() == surfels.size() ? 1 : 0;
123 ++nb; nbok += mean_curvs.size() == surfels.size() ? 1 : 0;
124 ++nb; nbok += gauss_curvs.size() == surfels.size() ? 1 : 0;
125 ++nb; nbok += stat_mean.min() > 0.08 ? 1 : 0;
126 ++nb; nbok += stat_gauss.min() > 0.0064 ? 1 : 0;
127 }
129
130 trace.
beginBlock (
"Build polynomial shape -> digitize -> get pointels -> save projected quadrangulated surface." );
131 {
134 const double h = 0.25;
135 params( "polynomial", "goursat" )( "gridstep", h );
145 std::transform( pointels.cbegin(), pointels.cend(), pos.begin(),
146 [&] (
const SH3::Cell& c) { return h * embedder( c ); } );
149 [&] (
const SH3::Cell& c){
return ppos[ c2i[ c ] ];},
151 "goursat-quad-proj.obj" );
153 ++nb; nbok += ok ? 1 : 0;
154 }
156
157 trace.
beginBlock (
"Build polynomial shape -> digitize -> extract mean curvature -> save as OBJ with colors." );
158 {
161 params( "polynomial", "goursat" )( "gridstep", 0.25 )( "colormap", "Tics" );
171 std::transform( mean_curv.cbegin(), mean_curv.cend(), colors.begin(), cmap );
173 "goursat-H.obj" );
175 ++nb; nbok += ok ? 1 : 0;
176 }
178
179 trace.
beginBlock (
"Build polynomial shape -> digitize -> extract ground-truth and estimated mean curvature -> display errors in OBJ with colors." );
180 {
183 params( "polynomial", "goursat" )( "gridstep", 0.25 )( "colormap", "Tics" )
184 ( "R-radius", 5.0 );
195 std::transform( t_curv.cbegin(), t_curv.cend(), colors.begin(), cmap );
197 std::transform( ii_curv.cbegin(), ii_curv.cend(), colors.begin(), cmap );
202 std::transform( errors.cbegin(), errors.cend(), colors.begin(), cmap_errors );
207 << std::endl;
209 ++nb; nbok += ( ok_t && ok_ii && ok_err ) ? 1 : 0;
210 }
212
213 trace.
beginBlock (
"Build polynomial shape -> digitize -> build digital surface -> save primal surface with VCM normals as obj." );
214 {
217 params( "polynomial", "goursat" )( "gridstep", 0.25 )
218 ( "surfaceTraversal", "Default" );
227 "goursat-primal-vcm.obj" );
229 ++nb; nbok += ok ? 1 : 0;
230 }
232
233 trace.
beginBlock (
"Build polynomial shape -> digitize implicitly -> estimate II normals and curvature." );
234 {
237 params( "polynomial", "goursat" )( "gridstep", .25 );
255 for (
SH3::Idx i = 0; i < colors.size(); i++ )
256 colors[ i ] = cmap( ii_mean_curv[ match[ i ] ] );
259 ++nb; nbok += ( ok_H && ii_mean_curv.size() == ii_mean_curv2.size() ) ? 1 : 0;
260 }
262
263 trace.
beginBlock (
"Build polynomial shape -> save several projected quadrangulated surface and digitized boundaries." );
264 {
266 std::vector<double> gridsteps {0.5, 0.25, 0.125};
267 for ( auto h : gridsteps ) {
268 params( "polynomial", "goursat" )( "gridstep", h );
278 std::transform( pointels.cbegin(), pointels.cend(), pos.begin(),
279 [&] (
const SH3::Cell& c) { return h * embedder( c ); } );
281 auto fname = std::string( "goursat-quad-" ) + std::to_string( h ) + std::string( ".obj" );
283 [&] (
const SH3::Cell& c){
return pos[ c2i[ c ] ];},
285 fname );
286 auto proj_fname = std::string( "goursat-quad-proj-" ) + std::to_string( h ) + std::string( ".obj" );
288 [&] (
const SH3::Cell& c){
return ppos[ c2i[ c ] ];},
290 proj_fname );
291 ++nb; nbok += ok ? 1 : 0;
292 ++nb; nbok += proj_ok ? 1 : 0;
293 }
294 }
296
297 trace.
beginBlock (
"Build polynomial shape -> digitize -> digital surface -> save primal surface and VCM normal field as obj." );
298 {
301 params( "polynomial", "goursat" )( "gridstep", 0.5 )
302 ( "surfaceTraversal", "Default" );
312 std::transform( surfels.cbegin(), surfels.cend(), positions.begin(),
313 [&] (
const SH3::SCell& c) { return embedder( c ); } );
315 "goursat-primal-vcm.obj" );
317 "goursat-primal-vcm-normals.obj",
320 ++nb, nbok += ok ? 1 : 0;
321 ++nb, nbok += ok2 ? 1 : 0;
322 }
324
325 trace.
beginBlock (
"Build polynomial shape -> digitize -> extract ground-truth curvatures -> display in OBJ." );
326 {
329 params( "polynomial", "goursat" )( "gridstep", 0.25 )( "colormap", "Tics" );
342 std::transform( surfels.cbegin(), surfels.cend(), positions.begin(),
343 [&] (
const SH3::SCell& c) { return embedder( c ); } );
345 "goursat-primal.obj" );
346
349 std::transform( k1.cbegin(), k1.cend(), colors.begin(), cmap );
352 "goursat-primal-d1.obj", SH3::Color::Black );
353 std::transform( k2.cbegin(), k2.cend(), colors.begin(), cmap );
356 "goursat-primal-d2.obj", SH3::Color::Black );
357 ASSERT(ok_k1 && ok_d1 && ok_k2 && ok_d2);
359 }
361
362 trace.
beginBlock(
"Load mesh file -> estimate mean/gaussian/principal curvatures -> display in obj" );
363 {
366 params("r-radius", 0.1);
367
369
374
376 std::transform( mcurv.cbegin(), mcurv.cend(), mcolors.begin(), cmap );
377
379 std::transform( gcurv.cbegin(), gcurv.cend(), gcolors.begin(), cmap );
380
382 std::transform( k1.begin(), k1.end(), k1colors.begin(), cmap);
383
385 std::transform( k2.begin(), k2.end(), k2colors.begin(), cmap);
386
392
393 ++nb; nbok += ok_m;
394 ++nb; nbok += ok_g;
395 ++nb; nbok += ok_k1;
396 ++nb; nbok += ok_k2;
397 }
399
400#if defined(DGTAL_WITH_EIGEN)
401 trace.
beginBlock (
"Load vol file -> build main digital surface -> II normals -> AT regularization -> save OBJ with colored normals." );
402 {
415 ii_normals, params );
416
418 for ( size_t i = 0; i < surfels.size(); i++ )
419 colors[ i ] =
SH3::Color( (
unsigned char) 255.0*fabs( at_normals[ i ][ 0 ] ),
420 (unsigned char) 255.0*fabs( at_normals[ i ][ 1 ] ),
421 (unsigned char) 255.0*fabs( at_normals[ i ][ 2 ] ) );
424
427 for ( size_t i = 0; i < linels.size(); i++ )
428 {
429 if ( features[ i ] < 0.5 )
430 {
435 f0.push_back( uembedder( p0 ) );
436 f1.push_back( uembedder( p1 ) - uembedder( p0 ) );
437 }
438 }
440 "al-features.obj",
443 ++nb; nbok += ok1 ? 1 : 0;
444 ++nb; nbok += ok2 ? 1 : 0;
445 ++nb; nbok += ok3 ? 1 : 0;
446 }
448
449#endif
450
451#if DGTAL_WITH_POLYSCOPE
452 trace.
beginBlock(
"Load vol file -> Compute VoronoiMap -> Display in Viewer" );
453 {
458
459
460 std::vector<SH3::Point> sites;
461 std::copy_if(
domain.begin(),
463 std::back_inserter(sites),
464 *bimage);
465
466
469
473
474 for (
auto it =
domain.begin(); it !=
domain.end(); ++it)
475 {
478 "L1 distance", vmap1(*it)
479 ), "L2 distance", vmap2(*it)
480 );
481 }
482
485 nb ++;
486 nbok ++;
487 }
489#endif
490
491 trace.
info() << nbok <<
"/" << nb <<
" passed tests." << std::endl;
492 return 0;
493}
std::string newCubeList(const std::string &name)
Cell uIncident(const Cell &c, Dimension k, bool up) const
Return the forward or backward unsigned cell incident to [c] along axis [k], depending on [up].
DirIterator uDirs(const Cell &p) const
Given an unsigned cell [p], returns an iterator to iterate over each coordinate the cell spans.
void show() override
Starts the event loop and display of elements.
static Scalars getIIGaussianCurvatures(CountedPtr< BinaryImage > bimage, const SurfelRange &surfels, const Parameters ¶ms=parametersGeometryEstimation()|parametersKSpace())
static Scalar getScalarsNormL1(const Scalars &v1, const Scalars &v2)
static Scalars getMeanCurvatures(CountedPtr< ImplicitShape3D > shape, const KSpace &K, const SurfelRange &surfels, const Parameters ¶ms=parametersShapeGeometry())
static RealPoints getPositions(CountedPtr< ImplicitShape3D > shape, const KSpace &K, const SurfelRange &surfels, const Parameters ¶ms=parametersShapeGeometry())
static Scalars getCNCGaussianCurvatures(CountedPtr< typename Base::SurfaceMesh > mesh, const typename Base::SurfaceMesh::Faces &faces, const Parameters ¶ms=parametersShapeGeometry())
static RealVectors getIINormalVectors(CountedPtr< BinaryImage > bimage, const SurfelRange &surfels, const Parameters ¶ms=parametersGeometryEstimation()|parametersKSpace())
static Scalars getScalarsAbsoluteDifference(const Scalars &v1, const Scalars &v2)
static RealVectors getNormalVectors(CountedPtr< ImplicitShape3D > shape, const KSpace &K, const SurfelRange &surfels, const Parameters ¶ms=parametersShapeGeometry())
static std::tuple< Scalars, Scalars, RealVectors, RealVectors > getCNCPrincipalCurvaturesAndDirections(CountedPtr< typename Base::SurfaceMesh > mesh, const typename Base::SurfaceMesh::Faces &faces, const Parameters ¶ms=parametersShapeGeometry())
static RealVectors getFirstPrincipalDirections(CountedPtr< ImplicitShape3D > shape, const KSpace &K, const SurfelRange &surfels, const Parameters ¶ms=parametersShapeGeometry())
static RealVectors getSecondPrincipalDirections(CountedPtr< ImplicitShape3D > shape, const KSpace &K, const SurfelRange &surfels, const Parameters ¶ms=parametersShapeGeometry())
static DistanceTransformation< Space, VoronoiPointPredicate, ExactPredicateLpSeparableMetric< Space, p > > getDistanceTransformation(Domain domain, const PointRange &sites, const Parameters ¶ms=parametersVoronoiMap())
static Scalars getCNCMeanCurvatures(CountedPtr< typename Base::SurfaceMesh > mesh, const typename Base::SurfaceMesh::Faces faces, const Parameters ¶ms=parametersShapeGeometry())
static Scalars getIIMeanCurvatures(CountedPtr< BinaryImage > bimage, const SurfelRange &surfels, const Parameters ¶ms=parametersGeometryEstimation()|parametersKSpace())
static Parameters defaultParameters()
static Scalars getGaussianCurvatures(CountedPtr< ImplicitShape3D > shape, const KSpace &K, const SurfelRange &surfels, const Parameters ¶ms=parametersShapeGeometry())
static Scalar getScalarsNormL2(const Scalars &v1, const Scalars &v2)
static Scalars getFirstPrincipalCurvatures(CountedPtr< ImplicitShape3D > shape, const KSpace &K, const SurfelRange &surfels, const Parameters ¶ms=parametersShapeGeometry())
static Scalar getScalarsNormLoo(const Scalars &v1, const Scalars &v2)
static ScalarStatistic getStatistic(const Scalars &v)
static VectorFieldInput getATVectorFieldApproximation(CountedPtr< TAnyDigitalSurface > surface, const SurfelRange &surfels, const VectorFieldInput &input, const Parameters ¶ms=parametersATApproximation()|parametersGeometryEstimation())
static Scalars getSecondPrincipalCurvatures(CountedPtr< ImplicitShape3D > shape, const KSpace &K, const SurfelRange &surfels, const Parameters ¶ms=parametersShapeGeometry())
static RealVectors getVCMNormalVectors(CountedPtr< TAnyDigitalSurface > surface, const SurfelRange &surfels, const Parameters ¶ms=parametersGeometryEstimation())
static KSpace getKSpace(const Point &low, const Point &up, Parameters params=parametersKSpace())
static CountedPtr< DigitizedImplicitShape3D > makeDigitizedImplicitShape3D(CountedPtr< ImplicitShape3D > shape, Parameters params=parametersDigitizedImplicitShape3D())
static CellRange getCellRange(Cell2Index &c2i, CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > surface, const Dimension k)
static CountedPtr< SurfaceMesh > makeSurfaceMesh(const std::string &path)
std::map< Cell, IdxVertex > Cell2Index
static PointelRange getPointelRange(Cell2Index &c2i, CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > surface)
std::vector< Color > Colors
static SurfelRange getSurfelRange(CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > surface, const Parameters ¶ms=parametersDigitalSurface())
static CountedPtr< LightDigitalSurface > makeLightDigitalSurface(CountedPtr< BinaryImage > bimage, const KSpace &K, const Parameters ¶ms=parametersDigitalSurface())
static CanonicSCellEmbedder< KSpace > getSCellEmbedder(const KSpace &K)
static CountedPtr< DigitalSurface > makeDigitalSurface(CountedPtr< TPointPredicate > bimage, const KSpace &K, const Parameters ¶ms=parametersDigitalSurface())
static IdxRange getRangeMatch(const std::vector< TValue > &s1, const std::vector< TValue > &s2, bool perfect=false)
std::vector< RealPoint > RealPoints
std::vector< RealVector > RealVectors
std::vector< Scalar > Scalars
static bool saveVectorFieldOBJ(const RealPoints &positions, const RealVectors &vf, double thickness, const Colors &diffuse_colors, std::string objfile, const Color &ambient_color=Color(32, 32, 32), const Color &diffuse_color=Color(200, 200, 255), const Color &specular_color=Color::White)
static Parameters defaultParameters()
static ColorMap getColorMap(Scalar min, Scalar max, const Parameters ¶ms=parametersUtilities())
static std::vector< TValue > getMatchedRange(const std::vector< TValue > &range, const IdxRange &match)
LightDigitalSurface::SCell SCell
static bool saveOBJ(CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > digsurf, const TCellEmbedder &embedder, const RealVectors &normals, const Colors &diffuse_colors, std::string objfile, const Color &ambient_color=Color(32, 32, 32), const Color &diffuse_color=Color(200, 200, 255), const Color &specular_color=Color::White)
static CountedPtr< BinaryImage > makeBinaryImage(Domain shapeDomain)
static CanonicCellEmbedder< KSpace > getCellEmbedder(const KSpace &K)
static CountedPtr< ImplicitShape3D > makeImplicitShape3D(const Parameters ¶ms=parametersImplicitShape3D())
LightDigitalSurface::Cell Cell
void beginBlock(const std::string &keyword="")
const Domain & domain() const
CountedPtr< SH3::DigitalSurface > surface
CountedPtr< SH3::BinaryImage > binary_image
DGtal::uint32_t Dimension
WithQuantity(const T &_object, const std::string &_name, const Type &value, QuantityScale s=QuantityScale::UNKNOWN)
ShortcutsGeometry< Z3i::KSpace > SHG3