Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DGtal for dummies #1357

Merged
merged 120 commits into from
Nov 17, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
120 commits
Select commit Hold shift + click to select a range
0d6df9d
First version of parameters
JacquesOlivierLachaud Jun 26, 2018
57eff33
Creating shortcuts example with ImplicitShape
JacquesOlivierLachaud Jun 26, 2018
6d83ef3
Add KSpace shortcuts
JacquesOlivierLachaud Jun 26, 2018
12769bd
Starting doc
JacquesOlivierLachaud Jun 26, 2018
64e58a1
Starting doc
JacquesOlivierLachaud Jun 26, 2018
1a30d4b
Add noise
JacquesOlivierLachaud Jun 26, 2018
272f46c
Add vol reader
JacquesOlivierLachaud Jun 26, 2018
4c611a7
Add save binary image
JacquesOlivierLachaud Jun 26, 2018
0606bf9
Update doc
JacquesOlivierLachaud Jun 26, 2018
652ed0c
Fix doc
JacquesOlivierLachaud Jun 26, 2018
591905f
Fix naming conventions
JacquesOlivierLachaud Jun 27, 2018
fed1c75
Add gray scale images methods and docs
JacquesOlivierLachaud Jun 27, 2018
1427403
Fix names of (digitized) implicit shape since they are 3d
JacquesOlivierLachaud Jun 27, 2018
fbb5b34
Add simple digital surfaces
JacquesOlivierLachaud Jun 27, 2018
9ee75f8
fix doc
JacquesOlivierLachaud Jun 27, 2018
b7611b8
digital surfaces (work in progress)
JacquesOlivierLachaud Jun 28, 2018
bdfd6b2
digital surfaces (work in progress)
JacquesOlivierLachaud Jun 28, 2018
1b01196
Adding true normals
JacquesOlivierLachaud Jun 28, 2018
07e436e
Adding true positions and mean curvatures
JacquesOlivierLachaud Jun 28, 2018
ccd38b1
Fix doc
JacquesOlivierLachaud Jun 28, 2018
a03f7e5
Add Gaussian curvature
JacquesOlivierLachaud Jun 30, 2018
a365d9a
Add primal and dual OBJ export to digital surfaces
JacquesOlivierLachaud Jul 3, 2018
24187c6
Manage two kinds of digital surfaces.
JacquesOlivierLachaud Jul 4, 2018
6f59596
Finishing OBJ output services
JacquesOlivierLachaud Jul 4, 2018
b0fc79f
Fix parameter order
JacquesOlivierLachaud Jul 4, 2018
64e5295
Add trivial and convolved trivial normals
JacquesOlivierLachaud Jul 4, 2018
f1f7afa
Add Convolved and VCM normal estimators + statistics
JacquesOlivierLachaud Jul 5, 2018
5130096
Add II normals and check values
JacquesOlivierLachaud Jul 5, 2018
5ae55f1
Fix doc and name
JacquesOlivierLachaud Jul 6, 2018
de81d35
Fix names
JacquesOlivierLachaud Jul 11, 2018
98ae36f
Working on Meshes in shortcuts
JacquesOlivierLachaud Oct 29, 2018
4816522
Fix bug
JacquesOlivierLachaud Oct 29, 2018
a059bdc
Working on mesh services
JacquesOlivierLachaud Oct 29, 2018
f9576ac
Working on mesh in shortcuts
JacquesOlivierLachaud Oct 30, 2018
6a3129a
Fix bug in conversion from polygonal MC surface to tri surf
JacquesOlivierLachaud Oct 31, 2018
8da244b
Fix bug in ImageLinearCellEmbedder
JacquesOlivierLachaud Oct 31, 2018
a2636cf
Fix default parameters
JacquesOlivierLachaud Oct 31, 2018
12b5284
Update doc
JacquesOlivierLachaud Oct 31, 2018
bdd235d
Update shortcuts.cpp
JacquesOlivierLachaud Oct 31, 2018
79db449
Update doc
JacquesOlivierLachaud Nov 1, 2018
9c79cd2
Fix several bugs in makePrimal* and extend it to IdxDigitalSurface
JacquesOlivierLachaud Nov 2, 2018
b0a99e8
Update doc
JacquesOlivierLachaud Nov 2, 2018
d501f32
Splitting shortcuts into modules
JacquesOlivierLachaud Nov 2, 2018
5322717
Secure ShortcutsGeometry functions and add warning and tests
JacquesOlivierLachaud Nov 2, 2018
86fb5f4
Fixtypo
JacquesOlivierLachaud Nov 2, 2018
fa40b1c
Fix doc
JacquesOlivierLachaud Nov 2, 2018
b3c3e8b
Fix doc
JacquesOlivierLachaud Nov 3, 2018
795031d
Export OBJ with normals and colors
JacquesOlivierLachaud Nov 3, 2018
d5d9fef
Update Statistic and display surfaces with colormaps
JacquesOlivierLachaud Nov 3, 2018
088e4d2
Fix big in export normals in OBJ file format
JacquesOlivierLachaud Nov 3, 2018
026d86e
Fix error in value display (sort in statistic.terminate())
JacquesOlivierLachaud Nov 3, 2018
65f322e
Update match and fix doc
JacquesOlivierLachaud Nov 4, 2018
638522e
Fix bug in GradientColorMap: no min and max test
JacquesOlivierLachaud Nov 4, 2018
bf42855
Finishing saveOBJ for primal digital surfaces
JacquesOlivierLachaud Nov 4, 2018
f698f18
Update doc
JacquesOlivierLachaud Nov 4, 2018
4bc5c9d
Fix doc
JacquesOlivierLachaud Nov 4, 2018
a3e94ae
Fix doc
JacquesOlivierLachaud Nov 4, 2018
bd17620
Update doc
JacquesOlivierLachaud Nov 4, 2018
ba56154
Fix for windows
JacquesOlivierLachaud Nov 4, 2018
8c394bd
Add final keyword to parametric shapes so that they can be const-alia…
JacquesOlivierLachaud Nov 4, 2018
a412611
Fix changes meaning error with g++
JacquesOlivierLachaud Nov 4, 2018
3004ac3
Fixes for confusing names for g++ and removing outputDualIdxSurface
JacquesOlivierLachaud Nov 4, 2018
a82bbd7
Small fixes to remove warnings
JacquesOlivierLachaud Nov 4, 2018
de82509
Fix stupid warning
JacquesOlivierLachaud Nov 4, 2018
1c8f603
Fix stupid doc warnings
JacquesOlivierLachaud Nov 4, 2018
86311b3
Fix doc errors and typos
JacquesOlivierLachaud Nov 5, 2018
373fd02
Working on shortcuts.cpp and doc
JacquesOlivierLachaud Nov 5, 2018
8fb39df
Updating doc with examples
JacquesOlivierLachaud Nov 5, 2018
82ecc4d
Fix unused variables in examples
JacquesOlivierLachaud Nov 5, 2018
7c8f691
Working on shortcuts and doc
JacquesOlivierLachaud Nov 5, 2018
621c6e9
Add image
JacquesOlivierLachaud Nov 6, 2018
c3e04d5
Add getPointelRange + fix canonic embedder
JacquesOlivierLachaud Nov 7, 2018
5cc8c5d
Add getKSpace and refKSpace and some types
JacquesOlivierLachaud Nov 7, 2018
7570a61
Add canonic cell and signed cell embedders
JacquesOlivierLachaud Nov 7, 2018
4d439ea
Update embedders to shorten code
JacquesOlivierLachaud Nov 7, 2018
4e9ca03
Update exporters
JacquesOlivierLachaud Nov 7, 2018
6e9ea68
Working on doc and examples
JacquesOlivierLachaud Nov 7, 2018
3248453
Small fixes
JacquesOlivierLachaud Nov 7, 2018
c8b2c3d
Add example for II curvature estimation
JacquesOlivierLachaud Nov 7, 2018
4aff835
Add Gauss curv and update doc
JacquesOlivierLachaud Nov 8, 2018
60a6e54
Small update in colormap to process NaN or Infinite numbers
JacquesOlivierLachaud Nov 8, 2018
0dceae7
Tentative fix for weird windows/appveyor error
JacquesOlivierLachaud Nov 8, 2018
52bb0b2
Fix for codacy
JacquesOlivierLachaud Nov 8, 2018
a084c83
Fix for checking that PValue is floating point number
JacquesOlivierLachaud Nov 8, 2018
65a0590
Update doc with another example
JacquesOlivierLachaud Nov 8, 2018
3ee6dcc
Update doc
JacquesOlivierLachaud Nov 8, 2018
d640db6
Merge branch 'master' of github.com:DGtal-team/DGtal into DGtalForDum…
JacquesOlivierLachaud Nov 8, 2018
8f46bb1
Update ChangeLog
JacquesOlivierLachaud Nov 8, 2018
1dfbd0d
Add possibility to create a digital surface from a digitized implicit…
JacquesOlivierLachaud Nov 9, 2018
0e605a2
Update ShortcutsGeometry to compute II normal, mean and Gaussian curv…
JacquesOlivierLachaud Nov 9, 2018
0890529
Update example
JacquesOlivierLachaud Nov 9, 2018
b7b5e9e
Fix positions in ground-truth geometry + fix images
JacquesOlivierLachaud Nov 10, 2018
1177e7b
Update doc
JacquesOlivierLachaud Nov 10, 2018
11d1d0a
Update src/DGtal/doc/tutorials/moduleShortcuts.dox
dcoeurjo Nov 13, 2018
ad7b209
Update src/DGtal/doc/tutorials/moduleShortcuts.dox
dcoeurjo Nov 13, 2018
9a73dc3
Update src/DGtal/doc/tutorials/moduleShortcuts.dox
dcoeurjo Nov 13, 2018
015c09e
Update src/DGtal/doc/tutorials/moduleShortcuts.dox
dcoeurjo Nov 13, 2018
373c173
Update src/DGtal/doc/tutorials/moduleShortcuts.dox
dcoeurjo Nov 13, 2018
df95d03
Update src/DGtal/doc/tutorials/moduleShortcuts.dox
dcoeurjo Nov 13, 2018
703f148
Update src/DGtal/doc/tutorials/moduleShortcuts.dox
dcoeurjo Nov 13, 2018
3da3713
Update src/DGtal/doc/tutorials/moduleShortcuts.dox
dcoeurjo Nov 13, 2018
a542e59
Update src/DGtal/doc/tutorials/moduleShortcuts.dox
dcoeurjo Nov 13, 2018
efb768c
Update src/DGtal/helpers/Parameters.h
dcoeurjo Nov 13, 2018
6267b3f
Update src/DGtal/helpers/Parameters.h
dcoeurjo Nov 13, 2018
0bd0504
Update src/DGtal/helpers/Shortcuts.h
dcoeurjo Nov 13, 2018
d441fef
Update src/DGtal/helpers/Shortcuts.h
dcoeurjo Nov 13, 2018
45093a5
Update src/DGtal/helpers/Shortcuts.h
dcoeurjo Nov 13, 2018
92dbb44
Update src/DGtal/helpers/Shortcuts.h
dcoeurjo Nov 13, 2018
c2b7f5e
Put Parameters in detail and change name of data members
JacquesOlivierLachaud Nov 14, 2018
a138d0f
Minor fixes
JacquesOlivierLachaud Nov 14, 2018
9ea8014
Fix coding style
JacquesOlivierLachaud Nov 14, 2018
523b079
Fix coding style ShortcutsGeometry
JacquesOlivierLachaud Nov 14, 2018
52f63b3
Fix example
JacquesOlivierLachaud Nov 14, 2018
a8df467
Remove shortcuts's dependency with QGLViewer
JacquesOlivierLachaud Nov 15, 2018
c77d6d1
Fix bad include
JacquesOlivierLachaud Nov 15, 2018
62a22b7
Clean-up dead code
JacquesOlivierLachaud Nov 15, 2018
123b7fb
Update doc of related modules
JacquesOlivierLachaud Nov 16, 2018
6f8184c
Conservative build for half-edge data structure (if a problem occur, …
JacquesOlivierLachaud Nov 16, 2018
89f268c
Merge branch 'DGtalForDummies' of github.com:JacquesOlivierLachaud/DG…
JacquesOlivierLachaud Nov 16, 2018
df792d8
Fix weird doxygen ref bug
JacquesOlivierLachaud Nov 16, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@

# DGtal 1.0

## New Features / Critical Changes

- *Helpers*
- Classes Shortcuts and ShortcutsGeometry to simplify coding with DGtal. Integrate a lot of volume, digital surfaces, mesh, surface, geometry, estimators functions, with many conversion and input/output tools. (Jacques-Olivier Lachaud, [#1357](https://github.com/DGtal-team/DGtal/pull/1357))


## Bug Fixes
- *Configuration/General*
- Continuous integration AppVeyor fix
Expand Down
2 changes: 2 additions & 0 deletions examples/tutorial-examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ SET(DGTAL_TUTO_EXAMPLES_SRC
freemanChainFromImage
FMMErosion
2DSliceImageFromVol
shortcuts
shortcuts-geometry
)


Expand Down
261 changes: 261 additions & 0 deletions examples/tutorial-examples/shortcuts-geometry.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,261 @@
/**
* 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/>.
*
**/

/**
* @file
* @ingroup Examples
* @author Jacques-Olivier Lachaud (\c jacques-olivier.lachaud@univ-savoie.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.
*/

///////////////////////////////////////////////////////////////////////////////
#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"
///////////////////////////////////////////////////////////////////////////////

using namespace std;
using namespace DGtal;

///////////////////////////////////////////////////////////////////////////////

int main( int /* argc */, char** /* argv */ )
{
unsigned int nb = 0, nbok = 0;
// 3d tests
typedef Shortcuts< Z3i::KSpace > SH3;
typedef ShortcutsGeometry< Z3i::KSpace > SHG3;

trace.beginBlock ( "Load vol file -> build digital surface -> estimate mean curvature -> save OBJ." );
{
//! [dgtal_shortcuts_ssec2_1_6s]
auto params = SH3::defaultParameters() | SHG3::defaultParameters();
params( "colormap", "Tics" );
auto bimage = SH3::makeBinaryImage( examplesPath + "samples/Al.100.vol", params );
auto K = SH3::getKSpace( bimage, params );
auto surface = SH3::makeDigitalSurface( bimage, K, params );
auto surfels = SH3::getSurfelRange( surface, params );
auto curv = SHG3::getIIMeanCurvatures( bimage, surfels, params );
// To get Gauss curvatures, write instead:
// auto curv = SHG3::getIIGaussianCurvatures( bimage, surfels, params );
auto cmap = SH3::getColorMap( -0.5, 0.5, params );
auto colors = SH3::Colors( surfels.size() );
std::transform( curv.cbegin(), curv.cend(), colors.begin(), cmap );
bool ok = SH3::saveOBJ( surface, SH3::RealVectors(), colors,
"al-H-II.obj" );
//! [dgtal_shortcuts_ssec2_1_6s]
++nb, nbok += ok ? 1 : 0;
}
trace.endBlock();

trace.beginBlock ( "Load vol file -> build digital surface -> estimate Gauss curvature -> save OBJ." );
{
auto params = SH3::defaultParameters() | SHG3::defaultParameters();
params( "colormap", "Tics" );
auto bimage = SH3::makeBinaryImage( examplesPath + "samples/Al.100.vol", params );
auto K = SH3::getKSpace( bimage, params );
auto surface = SH3::makeDigitalSurface( bimage, K, params );
auto surfels = SH3::getSurfelRange( surface, params );
auto curv = SHG3::getIIGaussianCurvatures( bimage, surfels, params );
auto cmap = SH3::getColorMap( -0.25, 0.25, params );
auto colors = SH3::Colors( surfels.size() );
std::transform( curv.cbegin(), curv.cend(), colors.begin(), cmap );
bool ok = SH3::saveOBJ( surface, SH3::RealVectors(), colors,
"al-G-II.obj" );
++nb, nbok += ok ? 1 : 0;
}
trace.endBlock();

trace.beginBlock ( "Build polynomial shape -> digitize -> extract ground-truth geometry." );
{
auto params = SH3::defaultParameters() | SHG3::defaultParameters();
//! [dgtal_shortcuts_ssec2_2_5s]
params( "polynomial", "3*x^2+2*y^2+z^2-90" )( "gridstep", 0.25 );
auto implicit_shape = SH3::makeImplicitShape3D ( params );
auto digitized_shape = SH3::makeDigitizedImplicitShape3D( implicit_shape, params );
auto binary_image = SH3::makeBinaryImage ( digitized_shape, params );
auto K = SH3::getKSpace( params );
auto surface = SH3::makeLightDigitalSurface( binary_image, K, params );
auto surfels = SH3::getSurfelRange( surface, params );
auto positions = SHG3::getPositions( implicit_shape, K, surfels, params );
auto normals = SHG3::getNormalVectors( implicit_shape, K, surfels, params );
auto mean_curvs = SHG3::getMeanCurvatures( implicit_shape, K, surfels, params );
auto gauss_curvs = SHG3::getGaussianCurvatures( implicit_shape, K, surfels, params );
//! [dgtal_shortcuts_ssec2_2_5s]
auto stat_mean = SHG3::getStatistic( mean_curvs );
auto stat_gauss = SHG3::getStatistic( gauss_curvs );
trace.info() << " min(H)=" << stat_mean.min()
<< " avg(H)=" << stat_mean.mean()
<< " max(H)=" << stat_mean.max() << std::endl;
trace.info() << " min(G)=" << stat_gauss.min()
<< " avg(G)=" << stat_gauss.mean()
<< " max(G)=" << stat_gauss.max() << std::endl;
++nb, nbok += positions.size() == surfels.size() ? 1 : 0;
++nb, nbok += normals.size() == surfels.size() ? 1 : 0;
++nb, nbok += mean_curvs.size() == surfels.size() ? 1 : 0;
++nb, nbok += gauss_curvs.size() == surfels.size() ? 1 : 0;
++nb, nbok += stat_mean.min() > 0.08 ? 1 : 0;
++nb, nbok += stat_gauss.min() > 0.0064 ? 1 : 0;
}
trace.endBlock();

trace.beginBlock ( "Build polynomial shape -> digitize -> get pointels -> save projected quadrangulated surface." );
{
auto params = SH3::defaultParameters() | SHG3::defaultParameters();
//! [dgtal_shortcuts_ssec2_2_6s]
const double h = 0.25;
params( "polynomial", "goursat" )( "gridstep", h );
auto implicit_shape = SH3::makeImplicitShape3D ( params );
auto digitized_shape = SH3::makeDigitizedImplicitShape3D( implicit_shape, params );
auto binary_image = SH3::makeBinaryImage ( digitized_shape, params );
auto K = SH3::getKSpace( params );
auto embedder = SH3::getCellEmbedder( K );
auto surface = SH3::makeLightDigitalSurface( binary_image, K, params );
SH3::Cell2Index c2i;
auto pointels = SH3::getPointelRange( c2i, surface );
SH3::RealPoints pos( pointels.size() );
std::transform( pointels.cbegin(), pointels.cend(), pos.begin(),
[&] (const SH3::Cell& c) { return h * embedder( c ); } );
auto ppos = SHG3::getPositions( implicit_shape, pos, params );
bool ok = SH3::saveOBJ( surface,
[&] (const SH3::Cell& c){ return ppos[ c2i[ c ] ];},
SH3::RealVectors(), SH3::Colors(),
"goursat-quad-proj.obj" );
//! [dgtal_shortcuts_ssec2_2_6s]
++nb, nbok += ok ? 1 : 0;
}
trace.endBlock();

trace.beginBlock ( "Build polynomial shape -> digitize -> extract mean curvature -> save as OBJ with colors." );
{
auto params = SH3::defaultParameters() | SHG3::defaultParameters();
//! [dgtal_shortcuts_ssec2_2_7s]
params( "polynomial", "goursat" )( "gridstep", 0.25 )( "colormap", "Tics" );
auto implicit_shape = SH3::makeImplicitShape3D ( params );
auto digitized_shape = SH3::makeDigitizedImplicitShape3D( implicit_shape, params );
auto binary_image = SH3::makeBinaryImage ( digitized_shape, params );
auto K = SH3::getKSpace( params );
auto surface = SH3::makeLightDigitalSurface( binary_image, K, params );
auto surfels = SH3::getSurfelRange( surface, params );
auto mean_curv = SHG3::getMeanCurvatures( implicit_shape, K, surfels, params );
auto cmap = SH3::getColorMap( -0.3, 0.3, params );
auto colors = SH3::Colors( surfels.size() );
std::transform( mean_curv.cbegin(), mean_curv.cend(), colors.begin(), cmap );
bool ok = SH3::saveOBJ( surface, SH3::RealVectors(), colors,
"goursat-H.obj" );
//! [dgtal_shortcuts_ssec2_2_7s]
++nb, nbok += ok ? 1 : 0;
}
trace.endBlock();

trace.beginBlock ( "Build polynomial shape -> digitize -> extract ground-truth and estimated mean curvature -> display errors in OBJ with colors." );
{
auto params = SH3::defaultParameters() | SHG3::defaultParameters();
//! [dgtal_shortcuts_ssec2_2_8s]
params( "polynomial", "goursat" )( "gridstep", 0.25 )( "colormap", "Tics" )
( "R-radius", 5.0 );
auto implicit_shape = SH3::makeImplicitShape3D ( params );
auto digitized_shape = SH3::makeDigitizedImplicitShape3D( implicit_shape, params );
auto bimage = SH3::makeBinaryImage ( digitized_shape, params );
auto K = SH3::getKSpace( params );
auto surface = SH3::makeLightDigitalSurface( bimage, K, params );
auto surfels = SH3::getSurfelRange( surface, params );
auto t_curv = SHG3::getMeanCurvatures( implicit_shape, K, surfels, params );
auto ii_curv = SHG3::getIIMeanCurvatures( bimage, surfels, params );
auto cmap = SH3::getColorMap( -0.5, 0.5, params );
auto colors = SH3::Colors( surfels.size() );
std::transform( t_curv.cbegin(), t_curv.cend(), colors.begin(), cmap );
bool ok_t = SH3::saveOBJ( surface, SH3::RealVectors(), colors, "goursat-H.obj" );
std::transform( ii_curv.cbegin(), ii_curv.cend(), colors.begin(), cmap );
bool ok_ii = SH3::saveOBJ( surface, SH3::RealVectors(), colors, "goursat-H-ii.obj" );
auto errors = SHG3::getScalarsAbsoluteDifference( t_curv, ii_curv );
auto stat_errors = SHG3::getStatistic( errors );
auto cmap_errors = SH3::getColorMap( 0.0, stat_errors.max(), params );
std::transform( errors.cbegin(), errors.cend(), colors.begin(), cmap_errors );
bool ok_err = SH3::saveOBJ( surface, SH3::RealVectors(), colors, "goursat-H-ii-err.obj" );
trace.info() << "Error Loo=" << SHG3::getScalarsNormLoo( t_curv, ii_curv )
<< " L1=" << SHG3::getScalarsNormL1 ( t_curv, ii_curv )
<< " L2=" << SHG3::getScalarsNormL2 ( t_curv, ii_curv )
<< std::endl;
//! [dgtal_shortcuts_ssec2_2_8s]
++nb, nbok += ( ok_t && ok_ii && ok_err ) ? 1 : 0;
}
trace.endBlock();

trace.beginBlock ( "Build polynomial shape -> digitize -> build digital surface -> save primal surface with VCM normals as obj." );
{
auto params = SH3::defaultParameters() | SHG3::defaultParameters();
//! [dgtal_shortcuts_ssec2_2_9s]
params( "polynomial", "goursat" )( "gridstep", 0.25 )
( "Traversal", "Default" );
auto implicit_shape = SH3::makeImplicitShape3D ( params );
auto digitized_shape = SH3::makeDigitizedImplicitShape3D( implicit_shape, params );
auto K = SH3::getKSpace( params );
auto binary_image = SH3::makeBinaryImage( digitized_shape, params );
auto surface = SH3::makeDigitalSurface( binary_image, K, params );
auto surfels = SH3::getSurfelRange( surface, params );
auto vcm_normals = SHG3::getVCMNormalVectors( surface, surfels, params );
bool ok = SH3::saveOBJ( surface, vcm_normals, SH3::Colors(),
"goursat-primal-vcm.obj" );
//! [dgtal_shortcuts_ssec2_2_9s]
++nb, nbok += ok ? 1 : 0;
}
trace.endBlock();

trace.beginBlock ( "Build polynomial shape -> digitize implicitly -> estimate II normals and curvature." );
{
auto params = SH3::defaultParameters() | SHG3::defaultParameters();
//! [dgtal_shortcuts_ssec2_2_10s]
params( "polynomial", "goursat" )( "gridstep", .25 );
auto implicit_shape = SH3::makeImplicitShape3D ( params );
auto dig_shape = SH3::makeDigitizedImplicitShape3D( implicit_shape, params );
auto K = SH3::getKSpace ( params );
auto surface = SH3::makeDigitalSurface ( dig_shape, K, params );
auto surfels = SH3::getSurfelRange ( surface, params( "surfaceTraversal", "DepthFirst" ) );
auto def_surfels = SH3::getSurfelRange ( surface, params( "surfaceTraversal", "Default" ) );
auto ii_normals = SHG3::getIINormalVectors ( dig_shape, surfels, params );
trace.beginBlock( "II with default traversal (slower)" );
auto ii_mean_curv = SHG3::getIIMeanCurvatures ( dig_shape, def_surfels, params );
trace.endBlock();
trace.beginBlock( "II with depth-first traversal (faster)" );
auto ii_mean_curv2 = SHG3::getIIMeanCurvatures ( dig_shape, surfels, params );
trace.endBlock();
auto cmap = SH3::getColorMap ( -0.5, 0.5, params );
auto colors = SH3::Colors ( def_surfels.size() );
auto match = SH3::getRangeMatch ( def_surfels, surfels );
auto normals = SH3::getMatchedRange ( ii_normals, match );
for ( SH3::Idx i = 0; i < colors.size(); i++ )
colors[ i ] = cmap( ii_mean_curv[ match[ i ] ] );
bool ok_H = SH3::saveOBJ( surface, SH3::RealVectors(), colors, "goursat-imp-H-ii.obj" );
//! [dgtal_shortcuts_ssec2_2_10s]
++nb, nbok += ( ok_H && ii_mean_curv.size() == ii_mean_curv2.size() ) ? 1 : 0;
}
trace.endBlock();

trace.info() << nbok << "/" << nb << " passed tests." << std::endl;
return 0;
}
// //
///////////////////////////////////////////////////////////////////////////////
Loading