DGtal 2.0.0
Loading...
Searching...
No Matches
shortcuts-geometry.cpp File Reference
#include <iostream>
#include "ConfigExamples.h"
#include "DGtal/helpers/StdDefs.h"
#include "DGtal/helpers/Shortcuts.h"
#include "DGtal/helpers/ShortcutsGeometry.h"
#include "DGtal/base/Common.h"
Include dependency graph for shortcuts-geometry.cpp:

Go to the source code of this file.

Functions

int main (int, char **)

Detailed Description

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Author
Jacques-Olivier Lachaud (jacqu.nosp@m.es-o.nosp@m.livie.nosp@m.r.la.nosp@m.chaud.nosp@m.@uni.nosp@m.v-sav.nosp@m.oie..nosp@m.fr ) Laboratory of Mathematics (CNRS, UMR 5127), University of Savoie, France
Date
2018/06/26

An example file named shortcuts.

This file is part of the DGtal library.

Definition in file shortcuts-geometry.cpp.

Function Documentation

◆ main()

int main ( int ,
char **  )

[dgtal_shortcuts_ssec2_1_6s]

[dgtal_shortcuts_ssec2_1_6s]

[dgtal_shortcuts_ssec2_2_5s]

[dgtal_shortcuts_ssec2_2_5s]

[dgtal_shortcuts_ssec2_2_6s]

[dgtal_shortcuts_ssec2_2_6s]

[dgtal_shortcuts_ssec2_2_7s]

[dgtal_shortcuts_ssec2_2_7s]

[dgtal_shortcuts_ssec2_2_8s]

[dgtal_shortcuts_ssec2_2_8s]

[dgtal_shortcuts_ssec2_2_9s]

[dgtal_shortcuts_ssec2_2_9s]

[dgtal_shortcuts_ssec2_2_10s]

[dgtal_shortcuts_ssec2_2_10s]

[dgtal_shortcuts_ssec2_2_11s]

[dgtal_shortcuts_ssec2_2_11s]

[dgtal_shortcuts_ssec2_2_13s]

[dgtal_shortcuts_ssec2_2_13s]

[dgtal_shortcuts_ssec2_1_14s]

[dgtal_shortcuts_ssec2_1_14s]

Definition at line 48 of file shortcuts-geometry.cpp.

49{
50 unsigned int nb = 0, nbok = 0;
51 // 3d tests
54
55 trace.beginBlock ( "Load vol file -> build digital surface -> estimate mean curvature -> save OBJ." );
56 {
59 params( "colormap", "Tics" );
60 auto bimage = SH3::makeBinaryImage( examplesPath + "samples/Al.100.vol", params );
61 auto K = SH3::getKSpace( bimage, params );
62 auto surface = SH3::makeDigitalSurface( bimage, K, params );
63 auto surfels = SH3::getSurfelRange( surface, params );
64 auto curv = SHG3::getIIMeanCurvatures( bimage, surfels, params );
65 // To get Gauss curvatures, write instead:
66 // auto curv = SHG3::getIIGaussianCurvatures( bimage, surfels, params );
67 auto cmap = SH3::getColorMap( -0.5, 0.5, params );
68 auto colors = SH3::Colors( surfels.size() );
69 std::transform( curv.cbegin(), curv.cend(), colors.begin(), cmap );
70 bool ok = SH3::saveOBJ( surface, SH3::RealVectors(), colors,
71 "al-H-II.obj" );
73 ++nb; nbok += ok ? 1 : 0;
74 }
75 trace.endBlock();
76
77 trace.beginBlock ( "Load vol file -> build digital surface -> estimate Gauss curvature -> save OBJ." );
78 {
80 params( "colormap", "Tics" );
81 auto bimage = SH3::makeBinaryImage( examplesPath + "samples/Al.100.vol", params );
82 auto K = SH3::getKSpace( bimage, params );
83 auto surface = SH3::makeDigitalSurface( bimage, K, params );
84 auto surfels = SH3::getSurfelRange( surface, params );
85 auto curv = SHG3::getIIGaussianCurvatures( bimage, surfels, params );
86 auto cmap = SH3::getColorMap( -0.25, 0.25, params );
87 auto colors = SH3::Colors( surfels.size() );
88 std::transform( curv.cbegin(), curv.cend(), colors.begin(), cmap );
89 bool ok = SH3::saveOBJ( surface, SH3::RealVectors(), colors,
90 "al-G-II.obj" );
91 ++nb; nbok += ok ? 1 : 0;
92 }
93 trace.endBlock();
94
95 trace.beginBlock ( "Build polynomial shape -> digitize -> extract ground-truth geometry." );
96 {
99 params( "polynomial", "3*x^2+2*y^2+z^2-90" )( "gridstep", 0.25 );
100 auto implicit_shape = SH3::makeImplicitShape3D ( params );
101 auto digitized_shape = SH3::makeDigitizedImplicitShape3D( implicit_shape, params );
102 auto binary_image = SH3::makeBinaryImage ( digitized_shape, params );
103 auto K = SH3::getKSpace( params );
105 auto surfels = SH3::getSurfelRange( surface, params );
106 auto positions = SHG3::getPositions( implicit_shape, K, surfels, params );
107 auto normals = SHG3::getNormalVectors( implicit_shape, K, surfels, params );
108 auto mean_curvs = SHG3::getMeanCurvatures( implicit_shape, K, surfels, params );
109 auto gauss_curvs = SHG3::getGaussianCurvatures( implicit_shape, K, surfels, params );
111 auto stat_mean = SHG3::getStatistic( mean_curvs );
112 auto stat_gauss = SHG3::getStatistic( gauss_curvs );
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;
125 }
126 trace.endBlock();
127
128 trace.beginBlock ( "Build polynomial shape -> digitize -> get pointels -> save projected quadrangulated surface." );
129 {
132 const double h = 0.25;
133 params( "polynomial", "goursat" )( "gridstep", h );
134 auto implicit_shape = SH3::makeImplicitShape3D ( params );
135 auto digitized_shape = SH3::makeDigitizedImplicitShape3D( implicit_shape, params );
136 auto binary_image = SH3::makeBinaryImage ( digitized_shape, params );
137 auto K = SH3::getKSpace( params );
138 auto embedder = SH3::getCellEmbedder( K );
140 SH3::Cell2Index c2i;
141 auto pointels = SH3::getPointelRange( c2i, surface );
142 SH3::RealPoints pos( pointels.size() );
143 std::transform( pointels.cbegin(), pointels.cend(), pos.begin(),
144 [&] (const SH3::Cell& c) { return h * embedder( c ); } );
145 auto ppos = SHG3::getPositions( implicit_shape, pos, params );
146 bool ok = SH3::saveOBJ( surface,
147 [&] (const SH3::Cell& c){ return ppos[ c2i[ c ] ];},
149 "goursat-quad-proj.obj" );
151 ++nb; nbok += ok ? 1 : 0;
152 }
153 trace.endBlock();
154
155 trace.beginBlock ( "Build polynomial shape -> digitize -> extract mean curvature -> save as OBJ with colors." );
156 {
159 params( "polynomial", "goursat" )( "gridstep", 0.25 )( "colormap", "Tics" );
160 auto implicit_shape = SH3::makeImplicitShape3D ( params );
161 auto digitized_shape = SH3::makeDigitizedImplicitShape3D( implicit_shape, params );
162 auto binary_image = SH3::makeBinaryImage ( digitized_shape, params );
163 auto K = SH3::getKSpace( params );
165 auto surfels = SH3::getSurfelRange( surface, params );
166 auto mean_curv = SHG3::getMeanCurvatures( implicit_shape, K, surfels, params );
167 auto cmap = SH3::getColorMap( -0.3, 0.3, params );
168 auto colors = SH3::Colors( surfels.size() );
169 std::transform( mean_curv.cbegin(), mean_curv.cend(), colors.begin(), cmap );
170 bool ok = SH3::saveOBJ( surface, SH3::RealVectors(), colors,
171 "goursat-H.obj" );
173 ++nb; nbok += ok ? 1 : 0;
174 }
175 trace.endBlock();
176
177 trace.beginBlock ( "Build polynomial shape -> digitize -> extract ground-truth and estimated mean curvature -> display errors in OBJ with colors." );
178 {
181 params( "polynomial", "goursat" )( "gridstep", 0.25 )( "colormap", "Tics" )
182 ( "R-radius", 5.0 );
183 auto implicit_shape = SH3::makeImplicitShape3D ( params );
184 auto digitized_shape = SH3::makeDigitizedImplicitShape3D( implicit_shape, params );
185 auto bimage = SH3::makeBinaryImage ( digitized_shape, params );
186 auto K = SH3::getKSpace( params );
187 auto surface = SH3::makeLightDigitalSurface( bimage, K, params );
188 auto surfels = SH3::getSurfelRange( surface, params );
189 auto t_curv = SHG3::getMeanCurvatures( implicit_shape, K, surfels, params );
190 auto ii_curv = SHG3::getIIMeanCurvatures( bimage, surfels, params );
191 auto cmap = SH3::getColorMap( -0.5, 0.5, params );
192 auto colors = SH3::Colors( surfels.size() );
193 std::transform( t_curv.cbegin(), t_curv.cend(), colors.begin(), cmap );
194 bool ok_t = SH3::saveOBJ( surface, SH3::RealVectors(), colors, "goursat-H.obj" );
195 std::transform( ii_curv.cbegin(), ii_curv.cend(), colors.begin(), cmap );
196 bool ok_ii = SH3::saveOBJ( surface, SH3::RealVectors(), colors, "goursat-H-ii.obj" );
197 auto errors = SHG3::getScalarsAbsoluteDifference( t_curv, ii_curv );
198 auto stat_errors = SHG3::getStatistic( errors );
199 auto cmap_errors = SH3::getColorMap( 0.0, stat_errors.max(), params );
200 std::transform( errors.cbegin(), errors.cend(), colors.begin(), cmap_errors );
201 bool ok_err = SH3::saveOBJ( surface, SH3::RealVectors(), colors, "goursat-H-ii-err.obj" );
202 trace.info() << "Error Loo=" << SHG3::getScalarsNormLoo( t_curv, ii_curv )
203 << " L1=" << SHG3::getScalarsNormL1 ( t_curv, ii_curv )
204 << " L2=" << SHG3::getScalarsNormL2 ( t_curv, ii_curv )
205 << std::endl;
207 ++nb; nbok += ( ok_t && ok_ii && ok_err ) ? 1 : 0;
208 }
209 trace.endBlock();
210
211 trace.beginBlock ( "Build polynomial shape -> digitize -> build digital surface -> save primal surface with VCM normals as obj." );
212 {
215 params( "polynomial", "goursat" )( "gridstep", 0.25 )
216 ( "surfaceTraversal", "Default" );
217 auto implicit_shape = SH3::makeImplicitShape3D ( params );
218 auto digitized_shape = SH3::makeDigitizedImplicitShape3D( implicit_shape, params );
219 auto K = SH3::getKSpace( params );
220 auto binary_image = SH3::makeBinaryImage( digitized_shape, params );
222 auto surfels = SH3::getSurfelRange( surface, params );
223 auto vcm_normals = SHG3::getVCMNormalVectors( surface, surfels, params );
224 bool ok = SH3::saveOBJ( surface, vcm_normals, SH3::Colors(),
225 "goursat-primal-vcm.obj" );
227 ++nb; nbok += ok ? 1 : 0;
228 }
229 trace.endBlock();
230
231 trace.beginBlock ( "Build polynomial shape -> digitize implicitly -> estimate II normals and curvature." );
232 {
235 params( "polynomial", "goursat" )( "gridstep", .25 );
236 auto implicit_shape = SH3::makeImplicitShape3D ( params );
237 auto dig_shape = SH3::makeDigitizedImplicitShape3D( implicit_shape, params );
238 auto K = SH3::getKSpace ( params );
239 auto surface = SH3::makeDigitalSurface ( dig_shape, K, params );
240 auto surfels = SH3::getSurfelRange ( surface, params( "surfaceTraversal", "DepthFirst" ) );
241 auto def_surfels = SH3::getSurfelRange ( surface, params( "surfaceTraversal", "Default" ) );
242 auto ii_normals = SHG3::getIINormalVectors ( dig_shape, surfels, params );
243 trace.beginBlock( "II with default traversal (slower)" );
244 auto ii_mean_curv = SHG3::getIIMeanCurvatures ( dig_shape, def_surfels, params );
245 trace.endBlock();
246 trace.beginBlock( "II with depth-first traversal (faster)" );
247 auto ii_mean_curv2 = SHG3::getIIMeanCurvatures ( dig_shape, surfels, params );
248 trace.endBlock();
249 auto cmap = SH3::getColorMap ( -0.5, 0.5, params );
250 auto colors = SH3::Colors ( def_surfels.size() );
251 auto match = SH3::getRangeMatch ( def_surfels, surfels );
252 auto normals = SH3::getMatchedRange ( ii_normals, match );
253 for ( SH3::Idx i = 0; i < colors.size(); i++ )
254 colors[ i ] = cmap( ii_mean_curv[ match[ i ] ] );
255 bool ok_H = SH3::saveOBJ( surface, SH3::RealVectors(), colors, "goursat-imp-H-ii.obj" );
257 ++nb; nbok += ( ok_H && ii_mean_curv.size() == ii_mean_curv2.size() ) ? 1 : 0;
258 }
259 trace.endBlock();
260
261 trace.beginBlock ( "Build polynomial shape -> save several projected quadrangulated surface and digitized boundaries." );
262 {
264 std::vector<double> gridsteps {0.5, 0.25, 0.125};
265 for ( auto h : gridsteps ) {
266 params( "polynomial", "goursat" )( "gridstep", h );
267 auto implicit_shape = SH3::makeImplicitShape3D ( params );
268 auto digitized_shape = SH3::makeDigitizedImplicitShape3D( implicit_shape, params );
269 auto binary_image = SH3::makeBinaryImage ( digitized_shape, params );
270 auto K = SH3::getKSpace( params );
271 auto embedder = SH3::getCellEmbedder( K );
273 SH3::Cell2Index c2i;
274 auto pointels = SH3::getPointelRange( c2i, surface );
275 SH3::RealPoints pos( pointels.size() );
276 std::transform( pointels.cbegin(), pointels.cend(), pos.begin(),
277 [&] (const SH3::Cell& c) { return h * embedder( c ); } );
278 auto ppos = SHG3::getPositions( implicit_shape, pos, params );
279 auto fname = std::string( "goursat-quad-" ) + std::to_string( h ) + std::string( ".obj" );
280 bool ok = SH3::saveOBJ( surface,
281 [&] (const SH3::Cell& c){ return pos[ c2i[ c ] ];},
283 fname );
284 auto proj_fname = std::string( "goursat-quad-proj-" ) + std::to_string( h ) + std::string( ".obj" );
285 bool proj_ok = SH3::saveOBJ( surface,
286 [&] (const SH3::Cell& c){ return ppos[ c2i[ c ] ];},
288 proj_fname );
289 ++nb; nbok += ok ? 1 : 0;
290 ++nb; nbok += proj_ok ? 1 : 0;
291 }
292 }
293 trace.endBlock();
294
295 trace.beginBlock ( "Build polynomial shape -> digitize -> digital surface -> save primal surface and VCM normal field as obj." );
296 {
299 params( "polynomial", "goursat" )( "gridstep", 0.5 )
300 ( "surfaceTraversal", "Default" );
301 auto implicit_shape = SH3::makeImplicitShape3D ( params );
302 auto digitized_shape = SH3::makeDigitizedImplicitShape3D( implicit_shape, params );
303 auto K = SH3::getKSpace( params );
304 auto binary_image = SH3::makeBinaryImage( digitized_shape, params );
306 auto surfels = SH3::getSurfelRange( surface, params );
307 auto vcm_normals = SHG3::getVCMNormalVectors( surface, surfels, params );
308 auto embedder = SH3::getSCellEmbedder( K );
309 SH3::RealPoints positions( surfels.size() );
310 std::transform( surfels.cbegin(), surfels.cend(), positions.begin(),
311 [&] (const SH3::SCell& c) { return embedder( c ); } );
312 bool ok = SH3::saveOBJ( surface, vcm_normals, SH3::Colors(),
313 "goursat-primal-vcm.obj" );
314 bool ok2 = SH3::saveVectorFieldOBJ( positions, vcm_normals, 0.05, SH3::Colors(),
315 "goursat-primal-vcm-normals.obj",
316 SH3::Color( 0, 0, 0 ), SH3::Color::Red );
318 ++nb, nbok += ok ? 1 : 0;
319 ++nb, nbok += ok2 ? 1 : 0;
320 }
321 trace.endBlock();
322
323 trace.beginBlock ( "Build polynomial shape -> digitize -> extract ground-truth curvatures -> display in OBJ." );
324 {
327 params( "polynomial", "goursat" )( "gridstep", 0.25 )( "colormap", "Tics" );
328 auto implicit_shape = SH3::makeImplicitShape3D ( params );
329 auto digitized_shape = SH3::makeDigitizedImplicitShape3D( implicit_shape, params );
330 auto bimage = SH3::makeBinaryImage ( digitized_shape, params );
331 auto K = SH3::getKSpace( params );
332 auto surface = SH3::makeLightDigitalSurface( bimage, K, params );
333 auto surfels = SH3::getSurfelRange( surface, params );
334 auto k1 = SHG3::getFirstPrincipalCurvatures( implicit_shape, K, surfels, params );
335 auto k2 = SHG3::getSecondPrincipalCurvatures( implicit_shape, K, surfels, params );
336 auto d1 = SHG3::getFirstPrincipalDirections( implicit_shape, K, surfels, params );
337 auto d2 = SHG3::getSecondPrincipalDirections( implicit_shape, K, surfels, params );
338 auto embedder = SH3::getSCellEmbedder( K );
339 SH3::RealPoints positions( surfels.size() );
340 std::transform( surfels.cbegin(), surfels.cend(), positions.begin(),
341 [&] (const SH3::SCell& c) { return embedder( c ); } );
343 "goursat-primal.obj" );
344 // output principal curvatures and directions
345 auto cmap = SH3::getColorMap( -0.5, 0.5, params );
346 auto colors= SH3::Colors( surfels.size() );
347 std::transform( k1.cbegin(), k1.cend(), colors.begin(), cmap );
348 bool ok_k1 = SH3::saveOBJ( surface, SH3::RealVectors(), colors, "goursat-primal-k1.obj" );
349 bool ok_d1 = SH3::saveVectorFieldOBJ( positions, d1, 0.05, colors,
350 "goursat-primal-d1.obj", SH3::Color::Black );
351 std::transform( k2.cbegin(), k2.cend(), colors.begin(), cmap );
352 bool ok_k2 = SH3::saveOBJ( surface, SH3::RealVectors(), colors, "goursat-primal-k2.obj" );
353 bool ok_d2 = SH3::saveVectorFieldOBJ( positions, d2, 0.05, colors,
354 "goursat-primal-d2.obj", SH3::Color::Black );
355 ASSERT(ok_k1 && ok_d1 && ok_k2 && ok_d2);
357 }
358 trace.endBlock();
359
360 trace.beginBlock( "Load mesh file -> estimate mean/gaussian/principal curvatures -> display in obj" );
361 {
364 params("r-radius", 0.1);
365
366 auto mesh = SH3::makeSurfaceMesh(examplesPath + "samples/bunnyhead2.obj");
367
368 auto mcurv = SHG3::getCNCMeanCurvatures(mesh, params);
369 auto gcurv = SHG3::getCNCGaussianCurvatures(mesh, params);
370 auto [k1, k2, d1, d2] = SHG3::getCNCPrincipalCurvaturesAndDirections(mesh);
371 auto cmap = SH3::getColorMap( -1, 1, params );
372
373 auto mcolors = SH3::Colors( mcurv.size() );
374 std::transform( mcurv.cbegin(), mcurv.cend(), mcolors.begin(), cmap );
375
376 auto gcolors = SH3::Colors( gcurv.size() );
377 std::transform( gcurv.cbegin(), gcurv.cend(), gcolors.begin(), cmap );
378
379 auto k1colors = SH3::Colors( k1.size() );
380 std::transform( k1.begin(), k1.end(), k1colors.begin(), cmap);
381
382 auto k2colors = SH3::Colors( k2.size() );
383 std::transform( k2.begin(), k2.end(), k2colors.begin(), cmap);
384
385 bool ok_m = SH3::saveOBJ( mesh, SH3::RealVectors(), mcolors, "bunnyhead2-meanCurvature.obj" );
386 bool ok_g = SH3::saveOBJ( mesh, SH3::RealVectors(), gcolors, "bunnyhead2-gaussianCurvature.obj" );
387 bool ok_k1 = SH3::saveOBJ( mesh, SH3::RealVectors(), k1colors, "bunnyhead2-firstPrincipalCurvature.obj" );
388 bool ok_k2 = SH3::saveOBJ( mesh, SH3::RealVectors(), k2colors, "bunnyhead2-secondPrincpalCurvature.obj" );
390
391 ++nb; nbok += ok_m;
392 ++nb; nbok += ok_g;
393 ++nb; nbok += ok_k1;
394 ++nb; nbok += ok_k2;
395 }
396 trace.endBlock();
397
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." );
400 {
403 auto al_capone = SH3::makeBinaryImage( examplesPath + "samples/Al.100.vol", params );
404 auto K = SH3::getKSpace( al_capone );
405 auto surface = SH3::makeLightDigitalSurface( al_capone, K, params );
406 auto surfels = SH3::getSurfelRange( surface, params );
407 auto ii_normals = SHG3::getIINormalVectors( al_capone, surfels, params );
408 auto linels = SH3::getCellRange( surface, 1 );
409 auto uembedder = SH3::getCellEmbedder( K );
410 SH3::Scalars features( linels.size() );
411 auto at_normals = SHG3::getATVectorFieldApproximation( features, linels.cbegin(), linels.cend(),
412 surface, surfels,
413 ii_normals, params );
414 // Output normals as colors depending on directions
415 SH3::Colors colors( surfels.size() );
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 ] ) );
420 bool ok1 = SH3::saveOBJ( surface, SH3::RealVectors(), SH3::Colors(), "al-surface.obj" );
421 bool ok2 = SH3::saveOBJ( surface, at_normals, colors, "al-colored-at-normals.obj" );
422 // Output discontinuities as sticks on linels.
425 for ( size_t i = 0; i < linels.size(); i++ )
426 {
427 if ( features[ i ] < 0.5 )
428 {
429 const SH3::Cell linel = linels[ i ];
430 const Dimension d = * K.uDirs( linel );
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 ) );
435 }
436 }
437 bool ok3 = SH3::saveVectorFieldOBJ( f0, f1, 0.1, SH3::Colors(),
438 "al-features.obj",
439 SH3::Color( 0, 0, 0 ), SH3::Color::Red );
441 ++nb; nbok += ok1 ? 1 : 0;
442 ++nb; nbok += ok2 ? 1 : 0;
443 ++nb; nbok += ok3 ? 1 : 0;
444 }
445 trace.endBlock();
446
447#endif // defined(WITH_EIGEN)
448
449#if DGTAL_WITH_POLYSCOPE
450 trace.beginBlock( "Load vol file -> Compute VoronoiMap -> Display in Viewer" );
451 {
454 auto bimage = SH3::makeBinaryImage( examplesPath + "samples/Al.100.vol", params );
455 auto domain = bimage->domain();
456
457 // Extract points location
458 std::vector<SH3::Point> sites;
459 std::copy_if(domain.begin(),
460 domain.end(),
461 std::back_inserter(sites),
462 *bimage);
463
464 // Compute VoronoiMap and get distances from sites
465 auto vmap1 = SHG3::getDistanceTransformation<1>(bimage->domain(), sites, params);
466 auto vmap2 = SHG3::getDistanceTransformation<2>(bimage->domain(), sites, params);
467
468 PolyscopeViewer<> viewer;
469 viewer.newCubeList("VoronoiMap distance");
470 viewer.allowReuseList = true;
471
472 for (auto it = domain.begin(); it != domain.end(); ++it)
473 {
474 viewer << WithQuantity(
475 WithQuantity(*it,
476 "L1 distance", vmap1(*it)
477 ), "L2 distance", vmap2(*it)
478 );
479 }
480
481 viewer.show();
483 nb ++;
484 nbok ++;
485 }
486 trace.endBlock();
487#endif // DGTAL_WITH_POLYSCOPE
488
489 trace.info() << nbok << "/" << nb << " passed tests." << std::endl;
490 return 0;
491}
std::string newCubeList(const std::string &name)
Definition Display3D.h:529
void show() override
Starts the event loop and display of elements.
static Scalars getIIGaussianCurvatures(CountedPtr< BinaryImage > bimage, const SurfelRange &surfels, const Parameters &params=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 &params=parametersShapeGeometry())
static RealPoints getPositions(CountedPtr< ImplicitShape3D > shape, const KSpace &K, const SurfelRange &surfels, const Parameters &params=parametersShapeGeometry())
static Scalars getCNCGaussianCurvatures(CountedPtr< typename Base::SurfaceMesh > mesh, const typename Base::SurfaceMesh::Faces &faces, const Parameters &params=parametersShapeGeometry())
static RealVectors getIINormalVectors(CountedPtr< BinaryImage > bimage, const SurfelRange &surfels, const Parameters &params=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 &params=parametersShapeGeometry())
static std::tuple< Scalars, Scalars, RealVectors, RealVectors > getCNCPrincipalCurvaturesAndDirections(CountedPtr< typename Base::SurfaceMesh > mesh, const typename Base::SurfaceMesh::Faces &faces, const Parameters &params=parametersShapeGeometry())
static RealVectors getFirstPrincipalDirections(CountedPtr< ImplicitShape3D > shape, const KSpace &K, const SurfelRange &surfels, const Parameters &params=parametersShapeGeometry())
static RealVectors getSecondPrincipalDirections(CountedPtr< ImplicitShape3D > shape, const KSpace &K, const SurfelRange &surfels, const Parameters &params=parametersShapeGeometry())
static DistanceTransformation< Space, VoronoiPointPredicate, ExactPredicateLpSeparableMetric< Space, p > > getDistanceTransformation(Domain domain, const PointRange &sites, const Parameters &params=parametersVoronoiMap())
static Scalars getCNCMeanCurvatures(CountedPtr< typename Base::SurfaceMesh > mesh, const typename Base::SurfaceMesh::Faces faces, const Parameters &params=parametersShapeGeometry())
static Scalars getIIMeanCurvatures(CountedPtr< BinaryImage > bimage, const SurfelRange &surfels, const Parameters &params=parametersGeometryEstimation()|parametersKSpace())
static Scalars getGaussianCurvatures(CountedPtr< ImplicitShape3D > shape, const KSpace &K, const SurfelRange &surfels, const Parameters &params=parametersShapeGeometry())
static Scalar getScalarsNormL2(const Scalars &v1, const Scalars &v2)
static Scalars getFirstPrincipalCurvatures(CountedPtr< ImplicitShape3D > shape, const KSpace &K, const SurfelRange &surfels, const Parameters &params=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 &params=parametersATApproximation()|parametersGeometryEstimation())
static Scalars getSecondPrincipalCurvatures(CountedPtr< ImplicitShape3D > shape, const KSpace &K, const SurfelRange &surfels, const Parameters &params=parametersShapeGeometry())
static RealVectors getVCMNormalVectors(CountedPtr< TAnyDigitalSurface > surface, const SurfelRange &surfels, const Parameters &params=parametersGeometryEstimation())
static KSpace getKSpace(const Point &low, const Point &up, Parameters params=parametersKSpace())
Definition Shortcuts.h:329
static CountedPtr< DigitizedImplicitShape3D > makeDigitizedImplicitShape3D(CountedPtr< ImplicitShape3D > shape, Parameters params=parametersDigitizedImplicitShape3D())
Definition Shortcuts.h:520
static CellRange getCellRange(Cell2Index &c2i, CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > surface, const Dimension k)
Definition Shortcuts.h:1660
static CountedPtr< SurfaceMesh > makeSurfaceMesh(const std::string &path)
Definition Shortcuts.h:2677
std::map< Cell, IdxVertex > Cell2Index
Definition Shortcuts.h:186
static PointelRange getPointelRange(Cell2Index &c2i, CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > surface)
Definition Shortcuts.h:1730
std::vector< Color > Colors
Definition Shortcuts.h:189
static SurfelRange getSurfelRange(CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > surface, const Parameters &params=parametersDigitalSurface())
Definition Shortcuts.h:1808
static CountedPtr< LightDigitalSurface > makeLightDigitalSurface(CountedPtr< BinaryImage > bimage, const KSpace &K, const Parameters &params=parametersDigitalSurface())
Definition Shortcuts.h:1323
static CanonicSCellEmbedder< KSpace > getSCellEmbedder(const KSpace &K)
Definition Shortcuts.h:443
static CountedPtr< DigitalSurface > makeDigitalSurface(CountedPtr< TPointPredicate > bimage, const KSpace &K, const Parameters &params=parametersDigitalSurface())
Definition Shortcuts.h:1470
static IdxRange getRangeMatch(const std::vector< TValue > &s1, const std::vector< TValue > &s2, bool perfect=false)
Definition Shortcuts.h:2961
std::vector< RealPoint > RealPoints
Definition Shortcuts.h:177
std::vector< RealVector > RealVectors
Definition Shortcuts.h:176
std::vector< Scalar > Scalars
Definition Shortcuts.h:175
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)
Definition Shortcuts.h:2200
static Parameters defaultParameters()
Definition Shortcuts.h:200
static ColorMap getColorMap(Scalar min, Scalar max, const Parameters &params=parametersUtilities())
Definition Shortcuts.h:3011
static std::vector< TValue > getMatchedRange(const std::vector< TValue > &range, const IdxRange &match)
Definition Shortcuts.h:2996
LightDigitalSurface::SCell SCell
Definition Shortcuts.h:160
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)
Definition Shortcuts.h:2000
static CountedPtr< BinaryImage > makeBinaryImage(Domain shapeDomain)
Definition Shortcuts.h:558
static CanonicCellEmbedder< KSpace > getCellEmbedder(const KSpace &K)
Definition Shortcuts.h:435
static CountedPtr< ImplicitShape3D > makeImplicitShape3D(const Parameters &params=parametersImplicitShape3D())
Definition Shortcuts.h:279
LightDigitalSurface::Cell Cell
Definition Shortcuts.h:159
CountedPtr< SH3::DigitalSurface > surface
CountedPtr< SH3::BinaryImage > binary_image
DGtal::uint32_t Dimension
Definition Common.h:119
Trace trace
Attach a property to an element.
Definition Display3D.h:327
Shortcuts< KSpace > SH3
KSpace K
ShortcutsGeometry< Z3i::KSpace > SHG3
Domain domain

References DGtal::Display3D< Space, KSpace >::allowReuseList, binary_image, DGtal::Shortcuts< KSpace >::defaultParameters(), DGtal::ShortcutsGeometry< Z3i::KSpace >::defaultParameters(), domain, DGtal::ShortcutsGeometry< Z3i::KSpace >::getATVectorFieldApproximation(), DGtal::Shortcuts< KSpace >::getCellEmbedder(), DGtal::Shortcuts< KSpace >::getCellRange(), DGtal::ShortcutsGeometry< Z3i::KSpace >::getCNCGaussianCurvatures(), DGtal::ShortcutsGeometry< Z3i::KSpace >::getCNCMeanCurvatures(), DGtal::ShortcutsGeometry< Z3i::KSpace >::getCNCPrincipalCurvaturesAndDirections(), DGtal::Shortcuts< KSpace >::getColorMap(), DGtal::ShortcutsGeometry< Z3i::KSpace >::getDistanceTransformation(), DGtal::ShortcutsGeometry< Z3i::KSpace >::getFirstPrincipalCurvatures(), DGtal::ShortcutsGeometry< Z3i::KSpace >::getFirstPrincipalDirections(), DGtal::ShortcutsGeometry< Z3i::KSpace >::getGaussianCurvatures(), DGtal::ShortcutsGeometry< Z3i::KSpace >::getIIGaussianCurvatures(), DGtal::ShortcutsGeometry< Z3i::KSpace >::getIIMeanCurvatures(), DGtal::ShortcutsGeometry< Z3i::KSpace >::getIINormalVectors(), DGtal::Shortcuts< KSpace >::getKSpace(), DGtal::Shortcuts< KSpace >::getMatchedRange(), DGtal::ShortcutsGeometry< Z3i::KSpace >::getMeanCurvatures(), DGtal::ShortcutsGeometry< Z3i::KSpace >::getNormalVectors(), DGtal::Shortcuts< KSpace >::getPointelRange(), DGtal::ShortcutsGeometry< Z3i::KSpace >::getPositions(), DGtal::Shortcuts< KSpace >::getRangeMatch(), DGtal::ShortcutsGeometry< Z3i::KSpace >::getScalarsAbsoluteDifference(), DGtal::ShortcutsGeometry< Z3i::KSpace >::getScalarsNormL1(), DGtal::ShortcutsGeometry< Z3i::KSpace >::getScalarsNormL2(), DGtal::ShortcutsGeometry< Z3i::KSpace >::getScalarsNormLoo(), DGtal::Shortcuts< KSpace >::getSCellEmbedder(), DGtal::ShortcutsGeometry< Z3i::KSpace >::getSecondPrincipalCurvatures(), DGtal::ShortcutsGeometry< Z3i::KSpace >::getSecondPrincipalDirections(), DGtal::ShortcutsGeometry< Z3i::KSpace >::getStatistic(), DGtal::Shortcuts< KSpace >::getSurfelRange(), DGtal::ShortcutsGeometry< Z3i::KSpace >::getVCMNormalVectors(), K, DGtal::Shortcuts< KSpace >::makeBinaryImage(), DGtal::Shortcuts< KSpace >::makeDigitalSurface(), DGtal::Shortcuts< KSpace >::makeDigitizedImplicitShape3D(), DGtal::Shortcuts< KSpace >::makeImplicitShape3D(), DGtal::Shortcuts< KSpace >::makeLightDigitalSurface(), DGtal::Shortcuts< KSpace >::makeSurfaceMesh(), DGtal::Display3D< Space, KSpace >::newCubeList(), DGtal::Shortcuts< KSpace >::saveOBJ(), DGtal::Shortcuts< KSpace >::saveVectorFieldOBJ(), DGtal::PolyscopeViewer< Space, KSpace >::show(), surface, and DGtal::trace.