DGtal 2.2.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
52 typedef Shortcuts< Z3i::KSpace > SH3;
54
55 trace.beginBlock ( "Load vol file -> build digital surface -> estimate mean curvature -> save OBJ." );
56 {
59 params( "colormap", "Tics" );
60 // To request the parallel II estimator when DGtal is built with OpenMP:
61 // params( "ii-thread-number", 4 )( "ii-split-axis", 1 );
62 auto bimage = SH3::makeBinaryImage( examplesPath + "samples/Al.100.vol", params );
63 auto K = SH3::getKSpace( bimage, params );
64 auto surface = SH3::makeDigitalSurface( bimage, K, params );
65 auto surfels = SH3::getSurfelRange( surface, params );
66 auto curv = SHG3::getIIMeanCurvatures( bimage, surfels, params );
67 // To get Gauss curvatures, write instead:
68 // auto curv = SHG3::getIIGaussianCurvatures( bimage, surfels, params );
69 auto cmap = SH3::getColorMap( -0.5, 0.5, params );
70 auto colors = SH3::Colors( surfels.size() );
71 std::transform( curv.cbegin(), curv.cend(), colors.begin(), cmap );
72 bool ok = SH3::saveOBJ( surface, SH3::RealVectors(), colors,
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" );
83 auto bimage = SH3::makeBinaryImage( examplesPath + "samples/Al.100.vol", params );
84 auto K = SH3::getKSpace( bimage, params );
85 auto surface = SH3::makeDigitalSurface( bimage, K, params );
86 auto surfels = SH3::getSurfelRange( surface, params );
87 auto curv = SHG3::getIIGaussianCurvatures( bimage, surfels, params );
88 auto cmap = SH3::getColorMap( -0.25, 0.25, params );
89 auto colors = SH3::Colors( surfels.size() );
90 std::transform( curv.cbegin(), curv.cend(), colors.begin(), cmap );
91 bool ok = SH3::saveOBJ( surface, SH3::RealVectors(), colors,
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 );
102 auto implicit_shape = SH3::makeImplicitShape3D ( params );
103 auto digitized_shape = SH3::makeDigitizedImplicitShape3D( implicit_shape, params );
104 auto binary_image = SH3::makeBinaryImage ( digitized_shape, params );
105 auto K = SH3::getKSpace( params );
107 auto surfels = SH3::getSurfelRange( surface, params );
108 auto positions = SHG3::getPositions( implicit_shape, K, surfels, params );
109 auto normals = SHG3::getNormalVectors( implicit_shape, K, surfels, params );
110 auto mean_curvs = SHG3::getMeanCurvatures( implicit_shape, K, surfels, params );
111 auto gauss_curvs = SHG3::getGaussianCurvatures( implicit_shape, K, surfels, params );
113 auto stat_mean = SHG3::getStatistic( mean_curvs );
114 auto stat_gauss = SHG3::getStatistic( gauss_curvs );
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 }
128 trace.endBlock();
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 );
136 auto implicit_shape = SH3::makeImplicitShape3D ( params );
137 auto digitized_shape = SH3::makeDigitizedImplicitShape3D( implicit_shape, params );
138 auto binary_image = SH3::makeBinaryImage ( digitized_shape, params );
139 auto K = SH3::getKSpace( params );
140 auto embedder = SH3::getCellEmbedder( K );
142 SH3::Cell2Index c2i;
143 auto pointels = SH3::getPointelRange( c2i, surface );
144 SH3::RealPoints pos( pointels.size() );
145 std::transform( pointels.cbegin(), pointels.cend(), pos.begin(),
146 [&] (const SH3::Cell& c) { return h * embedder( c ); } );
147 auto ppos = SHG3::getPositions( implicit_shape, pos, params );
148 bool ok = SH3::saveOBJ( surface,
149 [&] (const SH3::Cell& c){ return ppos[ c2i[ c ] ];},
151 "goursat-quad-proj.obj" );
153 ++nb; nbok += ok ? 1 : 0;
154 }
155 trace.endBlock();
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" );
162 auto implicit_shape = SH3::makeImplicitShape3D ( params );
163 auto digitized_shape = SH3::makeDigitizedImplicitShape3D( implicit_shape, params );
164 auto binary_image = SH3::makeBinaryImage ( digitized_shape, params );
165 auto K = SH3::getKSpace( params );
167 auto surfels = SH3::getSurfelRange( surface, params );
168 auto mean_curv = SHG3::getMeanCurvatures( implicit_shape, K, surfels, params );
169 auto cmap = SH3::getColorMap( -0.3, 0.3, params );
170 auto colors = SH3::Colors( surfels.size() );
171 std::transform( mean_curv.cbegin(), mean_curv.cend(), colors.begin(), cmap );
172 bool ok = SH3::saveOBJ( surface, SH3::RealVectors(), colors,
173 "goursat-H.obj" );
175 ++nb; nbok += ok ? 1 : 0;
176 }
177 trace.endBlock();
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 );
185 auto implicit_shape = SH3::makeImplicitShape3D ( params );
186 auto digitized_shape = SH3::makeDigitizedImplicitShape3D( implicit_shape, params );
187 auto bimage = SH3::makeBinaryImage ( digitized_shape, params );
188 auto K = SH3::getKSpace( params );
189 auto surface = SH3::makeLightDigitalSurface( bimage, K, params );
190 auto surfels = SH3::getSurfelRange( surface, params );
191 auto t_curv = SHG3::getMeanCurvatures( implicit_shape, K, surfels, params );
192 auto ii_curv = SHG3::getIIMeanCurvatures( bimage, surfels, params );
193 auto cmap = SH3::getColorMap( -0.5, 0.5, params );
194 auto colors = SH3::Colors( surfels.size() );
195 std::transform( t_curv.cbegin(), t_curv.cend(), colors.begin(), cmap );
196 bool ok_t = SH3::saveOBJ( surface, SH3::RealVectors(), colors, "goursat-H.obj" );
197 std::transform( ii_curv.cbegin(), ii_curv.cend(), colors.begin(), cmap );
198 bool ok_ii = SH3::saveOBJ( surface, SH3::RealVectors(), colors, "goursat-H-ii.obj" );
199 auto errors = SHG3::getScalarsAbsoluteDifference( t_curv, ii_curv );
200 auto stat_errors = SHG3::getStatistic( errors );
201 auto cmap_errors = SH3::getColorMap( 0.0, stat_errors.max(), params );
202 std::transform( errors.cbegin(), errors.cend(), colors.begin(), cmap_errors );
203 bool ok_err = SH3::saveOBJ( surface, SH3::RealVectors(), colors, "goursat-H-ii-err.obj" );
204 trace.info() << "Error Loo=" << SHG3::getScalarsNormLoo( t_curv, ii_curv )
205 << " L1=" << SHG3::getScalarsNormL1 ( t_curv, ii_curv )
206 << " L2=" << SHG3::getScalarsNormL2 ( t_curv, ii_curv )
207 << std::endl;
209 ++nb; nbok += ( ok_t && ok_ii && ok_err ) ? 1 : 0;
210 }
211 trace.endBlock();
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" );
219 auto implicit_shape = SH3::makeImplicitShape3D ( params );
220 auto digitized_shape = SH3::makeDigitizedImplicitShape3D( implicit_shape, params );
221 auto K = SH3::getKSpace( params );
222 auto binary_image = SH3::makeBinaryImage( digitized_shape, params );
224 auto surfels = SH3::getSurfelRange( surface, params );
225 auto vcm_normals = SHG3::getVCMNormalVectors( surface, surfels, params );
226 bool ok = SH3::saveOBJ( surface, vcm_normals, SH3::Colors(),
227 "goursat-primal-vcm.obj" );
229 ++nb; nbok += ok ? 1 : 0;
230 }
231 trace.endBlock();
232
233 trace.beginBlock ( "Build polynomial shape -> digitize implicitly -> estimate II normals and curvature." );
234 {
237 params( "polynomial", "goursat" )( "gridstep", .25 );
238 auto implicit_shape = SH3::makeImplicitShape3D ( params );
239 auto dig_shape = SH3::makeDigitizedImplicitShape3D( implicit_shape, params );
240 auto K = SH3::getKSpace ( params );
241 auto surface = SH3::makeDigitalSurface ( dig_shape, K, params );
242 auto surfels = SH3::getSurfelRange ( surface, params( "surfaceTraversal", "DepthFirst" ) );
243 auto def_surfels = SH3::getSurfelRange ( surface, params( "surfaceTraversal", "Default" ) );
244 auto ii_normals = SHG3::getIINormalVectors ( dig_shape, surfels, params );
245 trace.beginBlock( "II with default traversal (slower)" );
246 auto ii_mean_curv = SHG3::getIIMeanCurvatures ( dig_shape, def_surfels, params );
247 trace.endBlock();
248 trace.beginBlock( "II with depth-first traversal (faster)" );
249 auto ii_mean_curv2 = SHG3::getIIMeanCurvatures ( dig_shape, surfels, params );
250 trace.endBlock();
251 auto cmap = SH3::getColorMap ( -0.5, 0.5, params );
252 auto colors = SH3::Colors ( def_surfels.size() );
253 auto match = SH3::getRangeMatch ( def_surfels, surfels );
254 auto normals = SH3::getMatchedRange ( ii_normals, match );
255 for ( SH3::Idx i = 0; i < colors.size(); i++ )
256 colors[ i ] = cmap( ii_mean_curv[ match[ i ] ] );
257 bool ok_H = SH3::saveOBJ( surface, SH3::RealVectors(), colors, "goursat-imp-H-ii.obj" );
259 ++nb; nbok += ( ok_H && ii_mean_curv.size() == ii_mean_curv2.size() ) ? 1 : 0;
260 }
261 trace.endBlock();
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 );
269 auto implicit_shape = SH3::makeImplicitShape3D ( params );
270 auto digitized_shape = SH3::makeDigitizedImplicitShape3D( implicit_shape, params );
271 auto binary_image = SH3::makeBinaryImage ( digitized_shape, params );
272 auto K = SH3::getKSpace( params );
273 auto embedder = SH3::getCellEmbedder( K );
275 SH3::Cell2Index c2i;
276 auto pointels = SH3::getPointelRange( c2i, surface );
277 SH3::RealPoints pos( pointels.size() );
278 std::transform( pointels.cbegin(), pointels.cend(), pos.begin(),
279 [&] (const SH3::Cell& c) { return h * embedder( c ); } );
280 auto ppos = SHG3::getPositions( implicit_shape, pos, params );
281 auto fname = std::string( "goursat-quad-" ) + std::to_string( h ) + std::string( ".obj" );
282 bool ok = SH3::saveOBJ( surface,
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" );
287 bool proj_ok = SH3::saveOBJ( surface,
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 }
295 trace.endBlock();
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" );
303 auto implicit_shape = SH3::makeImplicitShape3D ( params );
304 auto digitized_shape = SH3::makeDigitizedImplicitShape3D( implicit_shape, params );
305 auto K = SH3::getKSpace( params );
306 auto binary_image = SH3::makeBinaryImage( digitized_shape, params );
308 auto surfels = SH3::getSurfelRange( surface, params );
309 auto vcm_normals = SHG3::getVCMNormalVectors( surface, surfels, params );
310 auto embedder = SH3::getSCellEmbedder( K );
311 SH3::RealPoints positions( surfels.size() );
312 std::transform( surfels.cbegin(), surfels.cend(), positions.begin(),
313 [&] (const SH3::SCell& c) { return embedder( c ); } );
314 bool ok = SH3::saveOBJ( surface, vcm_normals, SH3::Colors(),
315 "goursat-primal-vcm.obj" );
316 bool ok2 = SH3::saveVectorFieldOBJ( positions, vcm_normals, 0.05, SH3::Colors(),
317 "goursat-primal-vcm-normals.obj",
318 SH3::Color( 0, 0, 0 ), SH3::Color::Red );
320 ++nb, nbok += ok ? 1 : 0;
321 ++nb, nbok += ok2 ? 1 : 0;
322 }
323 trace.endBlock();
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" );
330 auto implicit_shape = SH3::makeImplicitShape3D ( params );
331 auto digitized_shape = SH3::makeDigitizedImplicitShape3D( implicit_shape, params );
332 auto bimage = SH3::makeBinaryImage ( digitized_shape, params );
333 auto K = SH3::getKSpace( params );
334 auto surface = SH3::makeLightDigitalSurface( bimage, K, params );
335 auto surfels = SH3::getSurfelRange( surface, params );
336 auto k1 = SHG3::getFirstPrincipalCurvatures( implicit_shape, K, surfels, params );
337 auto k2 = SHG3::getSecondPrincipalCurvatures( implicit_shape, K, surfels, params );
338 auto d1 = SHG3::getFirstPrincipalDirections( implicit_shape, K, surfels, params );
339 auto d2 = SHG3::getSecondPrincipalDirections( implicit_shape, K, surfels, params );
340 auto embedder = SH3::getSCellEmbedder( K );
341 SH3::RealPoints positions( surfels.size() );
342 std::transform( surfels.cbegin(), surfels.cend(), positions.begin(),
343 [&] (const SH3::SCell& c) { return embedder( c ); } );
345 "goursat-primal.obj" );
346 // output principal curvatures and directions
347 auto cmap = SH3::getColorMap( -0.5, 0.5, params );
348 auto colors= SH3::Colors( surfels.size() );
349 std::transform( k1.cbegin(), k1.cend(), colors.begin(), cmap );
350 bool ok_k1 = SH3::saveOBJ( surface, SH3::RealVectors(), colors, "goursat-primal-k1.obj" );
351 bool ok_d1 = SH3::saveVectorFieldOBJ( positions, d1, 0.05, colors,
352 "goursat-primal-d1.obj", SH3::Color::Black );
353 std::transform( k2.cbegin(), k2.cend(), colors.begin(), cmap );
354 bool ok_k2 = SH3::saveOBJ( surface, SH3::RealVectors(), colors, "goursat-primal-k2.obj" );
355 bool ok_d2 = SH3::saveVectorFieldOBJ( positions, d2, 0.05, colors,
356 "goursat-primal-d2.obj", SH3::Color::Black );
357 ASSERT(ok_k1 && ok_d1 && ok_k2 && ok_d2);
359 }
360 trace.endBlock();
361
362 trace.beginBlock( "Load mesh file -> estimate mean/gaussian/principal curvatures -> display in obj" );
363 {
366 params("r-radius", 0.1);
367
368 auto mesh = SH3::makeSurfaceMesh(examplesPath + "samples/bunnyhead2.obj");
369
370 auto mcurv = SHG3::getCNCMeanCurvatures(mesh, params);
371 auto gcurv = SHG3::getCNCGaussianCurvatures(mesh, params);
372 auto [k1, k2, d1, d2] = SHG3::getCNCPrincipalCurvaturesAndDirections(mesh);
373 auto cmap = SH3::getColorMap( -1, 1, params );
374
375 auto mcolors = SH3::Colors( mcurv.size() );
376 std::transform( mcurv.cbegin(), mcurv.cend(), mcolors.begin(), cmap );
377
378 auto gcolors = SH3::Colors( gcurv.size() );
379 std::transform( gcurv.cbegin(), gcurv.cend(), gcolors.begin(), cmap );
380
381 auto k1colors = SH3::Colors( k1.size() );
382 std::transform( k1.begin(), k1.end(), k1colors.begin(), cmap);
383
384 auto k2colors = SH3::Colors( k2.size() );
385 std::transform( k2.begin(), k2.end(), k2colors.begin(), cmap);
386
387 bool ok_m = SH3::saveOBJ( mesh, SH3::RealVectors(), mcolors, "bunnyhead2-meanCurvature.obj" );
388 bool ok_g = SH3::saveOBJ( mesh, SH3::RealVectors(), gcolors, "bunnyhead2-gaussianCurvature.obj" );
389 bool ok_k1 = SH3::saveOBJ( mesh, SH3::RealVectors(), k1colors, "bunnyhead2-firstPrincipalCurvature.obj" );
390 bool ok_k2 = SH3::saveOBJ( mesh, SH3::RealVectors(), k2colors, "bunnyhead2-secondPrincpalCurvature.obj" );
392
393 ++nb; nbok += ok_m;
394 ++nb; nbok += ok_g;
395 ++nb; nbok += ok_k1;
396 ++nb; nbok += ok_k2;
397 }
398 trace.endBlock();
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 {
405 auto al_capone = SH3::makeBinaryImage( examplesPath + "samples/Al.100.vol", params );
406 auto K = SH3::getKSpace( al_capone );
407 auto surface = SH3::makeLightDigitalSurface( al_capone, K, params );
408 auto surfels = SH3::getSurfelRange( surface, params );
409 auto ii_normals = SHG3::getIINormalVectors( al_capone, surfels, params );
410 auto linels = SH3::getCellRange( surface, 1 );
411 auto uembedder = SH3::getCellEmbedder( K );
412 SH3::Scalars features( linels.size() );
413 auto at_normals = SHG3::getATVectorFieldApproximation( features, linels.cbegin(), linels.cend(),
414 surface, surfels,
415 ii_normals, params );
416 // Output normals as colors depending on directions
417 SH3::Colors colors( surfels.size() );
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 ] ) );
422 bool ok1 = SH3::saveOBJ( surface, SH3::RealVectors(), SH3::Colors(), "al-surface.obj" );
423 bool ok2 = SH3::saveOBJ( surface, at_normals, colors, "al-colored-at-normals.obj" );
424 // Output discontinuities as sticks on linels.
427 for ( size_t i = 0; i < linels.size(); i++ )
428 {
429 if ( features[ i ] < 0.5 )
430 {
431 const SH3::Cell linel = linels[ i ];
432 const Dimension d = * K.uDirs( linel );
433 const SH3::Cell p0 = K.uIncident( linel, d, false );
434 const SH3::Cell p1 = K.uIncident( linel, d, true );
435 f0.push_back( uembedder( p0 ) );
436 f1.push_back( uembedder( p1 ) - uembedder( p0 ) );
437 }
438 }
439 bool ok3 = SH3::saveVectorFieldOBJ( f0, f1, 0.1, SH3::Colors(),
440 "al-features.obj",
441 SH3::Color( 0, 0, 0 ), SH3::Color::Red );
443 ++nb; nbok += ok1 ? 1 : 0;
444 ++nb; nbok += ok2 ? 1 : 0;
445 ++nb; nbok += ok3 ? 1 : 0;
446 }
447 trace.endBlock();
448
449#endif // defined(WITH_EIGEN)
450
451#if DGTAL_WITH_POLYSCOPE
452 trace.beginBlock( "Load vol file -> Compute VoronoiMap -> Display in Viewer" );
453 {
456 auto bimage = SH3::makeBinaryImage( examplesPath + "samples/Al.100.vol", params );
457 auto domain = bimage->domain();
458
459 // Extract points location
460 std::vector<SH3::Point> sites;
461 std::copy_if(domain.begin(),
462 domain.end(),
463 std::back_inserter(sites),
464 *bimage);
465
466 // Compute VoronoiMap and get distances from sites (L_1 and L_2 metrics)
467 auto vmap1 = SHG3::getDistanceTransformation<1>(bimage->domain(), sites, params);
468 auto vmap2 = SHG3::getDistanceTransformation<2>(bimage->domain(), sites, params);
469
470 PolyscopeViewer<> viewer;
471 viewer.newCubeList("VoronoiMap distance");
472 viewer.allowReuseList = true;
473
474 for (auto it = domain.begin(); it != domain.end(); ++it)
475 {
476 viewer << WithQuantity(
477 WithQuantity(*it,
478 "L1 distance", vmap1(*it)
479 ), "L2 distance", vmap2(*it)
480 );
481 }
482
483 viewer.show();
485 nb ++;
486 nbok ++;
487 }
488 trace.endBlock();
489#endif // DGTAL_WITH_POLYSCOPE
490
491 trace.info() << nbok << "/" << nb << " passed tests." << std::endl;
492 return 0;
493}
std::string newCubeList(const std::string &name)
Definition Display3D.h:535
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 &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
void beginBlock(const std::string &keyword="")
std::ostream & info()
double endBlock()
const Domain & domain() const
Definition VoronoiMap.h:265
CountedPtr< SH3::DigitalSurface > surface
CountedPtr< SH3::BinaryImage > binary_image
DGtal::uint32_t Dimension
Definition Common.h:119
Trace trace
WithQuantity(const T &_object, const std::string &_name, const Type &value, QuantityScale s=QuantityScale::UNKNOWN)
Definition Display3D.h:332
KSpace K
ShortcutsGeometry< Z3i::KSpace > SHG3
Domain domain

References DGtal::Display3D< Space, KSpace >::allowReuseList, DGtal::Trace::beginBlock(), binary_image, DGtal::Shortcuts< Z3i::KSpace >::defaultParameters(), DGtal::ShortcutsGeometry< Z3i::KSpace >::defaultParameters(), DGtal::VoronoiMap< TSpace, TPointPredicate, TSeparableMetric, TImageContainer >::domain(), domain, DGtal::Trace::endBlock(), DGtal::ShortcutsGeometry< Z3i::KSpace >::getATVectorFieldApproximation(), DGtal::Shortcuts< Z3i::KSpace >::getCellEmbedder(), DGtal::Shortcuts< Z3i::KSpace >::getCellRange(), DGtal::ShortcutsGeometry< Z3i::KSpace >::getCNCGaussianCurvatures(), DGtal::ShortcutsGeometry< Z3i::KSpace >::getCNCMeanCurvatures(), DGtal::ShortcutsGeometry< Z3i::KSpace >::getCNCPrincipalCurvaturesAndDirections(), DGtal::Shortcuts< Z3i::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< Z3i::KSpace >::getKSpace(), DGtal::Shortcuts< Z3i::KSpace >::getMatchedRange(), DGtal::ShortcutsGeometry< Z3i::KSpace >::getMeanCurvatures(), DGtal::ShortcutsGeometry< Z3i::KSpace >::getNormalVectors(), DGtal::Shortcuts< Z3i::KSpace >::getPointelRange(), DGtal::ShortcutsGeometry< Z3i::KSpace >::getPositions(), DGtal::Shortcuts< Z3i::KSpace >::getRangeMatch(), DGtal::ShortcutsGeometry< Z3i::KSpace >::getScalarsAbsoluteDifference(), DGtal::ShortcutsGeometry< Z3i::KSpace >::getScalarsNormL1(), DGtal::ShortcutsGeometry< Z3i::KSpace >::getScalarsNormL2(), DGtal::ShortcutsGeometry< Z3i::KSpace >::getScalarsNormLoo(), DGtal::Shortcuts< Z3i::KSpace >::getSCellEmbedder(), DGtal::ShortcutsGeometry< Z3i::KSpace >::getSecondPrincipalCurvatures(), DGtal::ShortcutsGeometry< Z3i::KSpace >::getSecondPrincipalDirections(), DGtal::ShortcutsGeometry< Z3i::KSpace >::getStatistic(), DGtal::Shortcuts< Z3i::KSpace >::getSurfelRange(), DGtal::ShortcutsGeometry< Z3i::KSpace >::getVCMNormalVectors(), DGtal::Trace::info(), K, main(), DGtal::Shortcuts< Z3i::KSpace >::makeBinaryImage(), DGtal::Shortcuts< Z3i::KSpace >::makeDigitalSurface(), DGtal::Shortcuts< Z3i::KSpace >::makeDigitizedImplicitShape3D(), DGtal::Shortcuts< Z3i::KSpace >::makeImplicitShape3D(), DGtal::Shortcuts< Z3i::KSpace >::makeLightDigitalSurface(), DGtal::Shortcuts< Z3i::KSpace >::makeSurfaceMesh(), DGtal::Display3D< Space, KSpace >::newCubeList(), DGtal::Shortcuts< Z3i::KSpace >::saveOBJ(), DGtal::Shortcuts< Z3i::KSpace >::saveVectorFieldOBJ(), DGtal::PolyscopeViewer< Space, KSpace >::show(), surface, DGtal::trace, DGtal::KhalimskySpaceND< dim, TInteger >::uDirs(), DGtal::KhalimskySpaceND< dim, TInteger >::uIncident(), and DGtal::WithQuantity< T, Type >::WithQuantity().