31#if defined(Shortcuts_RECURSES)
32#error Recursive header files inclusion detected in Shortcuts.h
35#define Shortcuts_RECURSES
37#if !defined Shortcuts_h
50#include "DGtal/base/Common.h"
51#include "DGtal/base/CountedPtr.h"
52#include "DGtal/kernel/domains/HyperRectDomain.h"
53#include "DGtal/kernel/RegularPointEmbedder.h"
54#include "DGtal/math/MPolynomial.h"
55#include "DGtal/math/Statistic.h"
56#include "DGtal/images/ImageContainerBySTLVector.h"
57#include "DGtal/images/IntervalForegroundPredicate.h"
58#include <DGtal/images/ImageLinearCellEmbedder.h>
59#include "DGtal/shapes/implicit/ImplicitPolynomial3Shape.h"
60#include "DGtal/shapes/GaussDigitizer.h"
61#include "DGtal/shapes/ShapeGeometricFunctors.h"
62#include "DGtal/shapes/MeshHelpers.h"
63#include "DGtal/topology/CCellularGridSpaceND.h"
64#include "DGtal/topology/LightImplicitDigitalSurface.h"
65#include "DGtal/topology/SetOfSurfels.h"
66#include "DGtal/topology/DigitalSurface.h"
67#include "DGtal/topology/IndexedDigitalSurface.h"
68#include "DGtal/topology/SurfelAdjacency.h"
69#include "DGtal/topology/CCellEmbedder.h"
70#include "DGtal/topology/CanonicCellEmbedder.h"
71#include "DGtal/topology/CanonicSCellEmbedder.h"
72#include "DGtal/topology/helpers/Surfaces.h"
73#include "DGtal/geometry/volumes/KanungoNoise.h"
74#include "DGtal/shapes/Mesh.h"
75#include "DGtal/io/Color.h"
76#include "DGtal/io/colormaps/GradientColorMap.h"
77#include "DGtal/io/colormaps/TickedColorMap.h"
78#include "DGtal/io/readers/MPolynomialReader.h"
79#include "DGtal/io/readers/GenericReader.h"
80#include "DGtal/io/writers/GenericWriter.h"
81#include "DGtal/io/writers/MeshWriter.h"
82#include "DGtal/graph/BreadthFirstVisitor.h"
83#include "DGtal/graph/DepthFirstVisitor.h"
84#include "DGtal/graph/GraphVisitorRange.h"
85#include "DGtal/helpers/Parameters.h"
103 template <
typename TKSpace >
184 typedef ::DGtal::Mesh<RealPoint>
Mesh;
235 static std::map< std::string, std::string >
238 std::vector< std::pair< std::string, std::string > >
239 Ps = { {
"sphere1",
"x^2+y^2+z^2-1" },
240 {
"sphere9",
"x^2+y^2+z^2-81" },
241 {
"ellipsoid",
"3*x^2+2*y^2+z^2-90" },
242 {
"cylinder",
"x^2+2*z^2-90" },
243 {
"torus",
"(x^2+y^2+z^2+6*6-2*2)^2-4*6*6*(x^2+y^2)" },
244 {
"rcube",
"x^4+y^4+z^4-6561" },
245 {
"goursat",
"-1*(8-0.03*x^4-0.03*y^4-0.03*z^4+2*x^2+2*y^2+2*z^2)" },
246 {
"goursat-hole",
"x^4+y^4+z^4-2*4*(x^2+y^2+z^2)+2*4*4-2" },
247 {
"distel",
"10000-(x^2+y^2+z^2+1000*(x^2+y^2)*(x^2+z^2)*(y^2+z^2))"},
248 {
"leopold",
"(x^2*y^2*z^2+4*x^2+4*y^2+3*z^2)-100" },
249 {
"diabolo",
"x^2-(y^2+z^2)^2" },
250 {
"heart",
"-1*(x^2+2.25*y^2+z^2-1)^3+x^2*z^3+0.1125*y^2*z^3" },
251 {
"crixxi",
"-0.9*(y^2+z^2-1)^2-(x^2+y^2-1)^3" } };
252 std::map< std::string, std::string > L;
254 L[ p.first ] = p.second;
268 (
"polynomial",
"sphere1" )
269 (
"projectionMaxIter", 20 )
270 (
"projectionAccuracy", 0.0001 )
271 (
"projectionGamma", 0.5 );
285 std::string poly_str = params[
"polynomial" ].as<std::string>();
288 if ( PL[ poly_str ] !=
"" ) poly_str = PL[ poly_str ];
291 std::string::const_iterator iter
292 = reader.
read( poly, poly_str.begin(), poly_str.end() );
293 if ( iter != poly_str.end() )
295 trace.
error() <<
"[Shortcuts::makeImplicitShape3D]"
296 <<
" ERROR reading polynomial: I read only <"
297 << poly_str.substr( 0, iter - poly_str.begin() )
298 <<
">, and I built P=" << poly << std::endl;
317 (
"gridsizez", 1.0 );
335 int closed = params[
"closed" ].as<
int>();
337 if ( !
K.init( low, up, closed ) )
339 <<
" Error building Khalimsky space K=" <<
K << std::endl;
357 int closed = params[
"closed" ].as<
int>();
359 if ( !
K.init( bimage->domain().lowerBound(),
360 bimage->domain().upperBound(),
363 <<
" Error building Khalimsky space K=" <<
K << std::endl;
381 int closed = params[
"closed" ].as<
int>();
383 if ( !
K.init( gimage->domain().lowerBound(),
384 gimage->domain().upperBound(),
387 <<
" Error building Khalimsky space K=" <<
K << std::endl;
394 template <
typename TDigitalSurfaceContainer>
399 return surface->container().space();
405 template <
typename TDigitalSurfaceContainer>
410 return surface->container().space();
416 template <
typename TDigitalSurfaceContainer>
421 return surface->container().space();
427 template <
typename TDigitalSurfaceContainer>
432 return surface->container().space();
493 bool closed = params[
"closed" ].as<
int>();
494 RealPoint p1( min_x - offset * h, min_x - offset * h, min_x - offset * h );
495 RealPoint p2( max_x + offset * h, max_x + offset * h, max_x + offset * h );
497 dshape->init( p1, p2, h );
502 <<
" Error building Khalimsky space K=" <<
K << std::endl
503 <<
"Note: if you use decimal values, check your locale for decimal point '.' or ','."
530 RealPoint p1( min_x - offset * h, min_x - offset * h, min_x - offset * h );
531 RealPoint p2( max_x + offset * h, max_x + offset * h, max_x + offset * h );
533 dshape->attach( shape );
534 dshape->init( p1, p2, h );
551 (
"thresholdMin", 0 )
552 (
"thresholdMax", 255 );
580 shape_digitization->getDomain(),
604 std::transform( shapeDomain.
begin(), shapeDomain.
end(),
606 [&shape_digitization]
607 (
const Point& p ) { return (*shape_digitization)(p); } );
612 KanungoPredicate noisy_dshape( *shape_digitization, shapeDomain, noise );
613 std::transform( shapeDomain.
begin(), shapeDomain.
end(),
615 [&noisy_dshape] (
const Point& p ) { return noisy_dshape(p); } );
632 if ( noise <= 0.0 )
return bimage;
634 const Domain shapeDomain = bimage->domain();
636 KanungoPredicate noisy_dshape( *bimage, shapeDomain, noise );
637 std::transform( shapeDomain.
begin(), shapeDomain.
end(),
639 [&noisy_dshape] (
const Point& p ) { return noisy_dshape(p); } );
659 int thresholdMin = params[
"thresholdMin"].as<
int>();
660 int thresholdMax = params[
"thresholdMax"].as<
int>();
664 ThresholdedImage tImage( image, thresholdMin, thresholdMax );
668 [tImage] (
const Point& p ) { return tImage(p); } );
688 int thresholdMin = params[
"thresholdMin"].as<
int>();
689 int thresholdMax = params[
"thresholdMax"].as<
int>();
692 ThresholdedImage tImage( *gray_scale_image, thresholdMin, thresholdMax );
696 [tImage] (
const Point& p ) { return tImage(p); } );
749 ( std::string input )
764 std::function<
GrayScale(
bool ) >
const & bool2grayscale
765 = [] (
bool v ) {
return v ? (
unsigned char) 255 : (
unsigned char) 0; }
771 std::transform( binary_image->begin(), binary_image->end(),
772 gray_scale_image->begin(),
774 return gray_scale_image;
807 float qShift = params[
"qShift" ].as<
float>();
808 float qSlope = params[
"qSlope" ].as<
float>();
809 std::function<
unsigned char(
float ) > f
810 = [qShift,qSlope] (
float v)
811 {
return (
unsigned char) std::min( 255.0f, std::max( 0.0f, qSlope * v + qShift ) ); };
814 auto it = gimage->begin();
817 float val = (*fimage)( p );
839 double qShift = params[
"qShift" ].as<
double>();
840 double qSlope = params[
"qSlope" ].as<
double>();
841 std::function<
unsigned char(
double ) > f
842 = [qShift,qSlope] (
double v)
843 {
return (
unsigned char) std::min( 255.0, std::max( 0.0, qSlope * v + qShift ) ); };
846 auto it = gimage->begin();
849 double val = (*fimage)( p );
877 ( std::string input )
905 RealPoint p1( min_x - offset * h, min_x - offset * h, min_x - offset * h );
906 RealPoint p2( max_x + offset * h, max_x + offset * h, max_x + offset * h );
908 dshape->attach( shape );
909 dshape->init( p1, p2, h );
912 auto it = fimage->begin();
915 float val = (float) (*shape)( p );
943 ( std::string input )
971 RealPoint p1( min_x - offset * h, min_x - offset * h, min_x - offset * h );
972 RealPoint p2( max_x + offset * h, max_x + offset * h, max_x + offset * h );
974 dshape->attach( shape );
975 dshape->init( p1, p2, h );
978 auto it = fimage->begin();
981 double val = (double) (*shape)( p );
999 (
"surfelAdjacency", 0 )
1000 (
"nbTriesToFindABel", 100000 )
1001 (
"surfaceComponents",
"AnyBig" )
1002 (
"surfaceTraversal",
"Default" );
1008 template <
typename TDigitalSurfaceContainer>
1019 template <
typename TDigitalSurfaceContainer>
1030 template <
typename TDigitalSurfaceContainer>
1041 template <
typename TDigitalSurfaceContainer>
1066 bool surfel_adjacency = params[
"surfelAdjacency" ].as<
int>();
1067 int nb_tries_to_find_a_bel = params[
"nbTriesToFindABel" ].as<
int>();
1073 Scalar minsize = bimage->extent().norm();
1074 unsigned int nb_surfels = 0;
1075 unsigned int tries = 0;
1081 trace.
error() <<
"[Shortcuts::makeLightDigitalSurface]"
1082 <<
" ERROR Unable to find bel. " << e << std::endl;
1090 nb_surfels = ptrSurface->size();
1092 while ( ( nb_surfels < 2 * minsize ) && ( tries++ < 150 ) );
1094 trace.
warning() <<
"[Shortcuts::makeLightDigitalSurface]"
1095 <<
"ERROR cannot find a proper bel in a big enough component."
1117 static std::vector< CountedPtr<LightDigitalSurface> >
1147 static std::vector< CountedPtr<LightDigitalSurface> >
1154 std::vector< CountedPtr<LightDigitalSurface> > result;
1155 std::string component = params[
"surfaceComponents" ].as<std::string>();
1156 if ( component ==
"AnyBig" )
1159 surfel_reps.push_back( *( result[ 0 ]->begin() ) );
1162 bool surfel_adjacency = params[
"surfelAdjacency" ].as<
int>();
1167 K.lowerBound(),
K.upperBound() );
1171 for (
auto bel : all_surfels )
1173 if ( marked_surfels.count( bel ) != 0 )
continue;
1174 surfel_reps.push_back( bel );
1180 marked_surfels.insert( ptrSurface->begin(), ptrSurface->end() );
1182 result.push_back( ptrSurface );
1206 template <
typename TPo
intPredicate>
1214 bool surfel_adjacency = params[
"surfelAdjacency" ].as<
int>();
1218 K.lowerBound(),
K.upperBound() );
1243 bool surfel_adjacency = params[
"surfelAdjacency" ].as<
int>();
1246 auto all_idx_surfels
1248 auto idx2surfel = idx_surface->surfels();
1250 for (
auto idx : all_idx_surfels ) all_surfels.insert( idx2surfel[ idx ] );
1279 std::string component = params[
"surfaceComponents" ].as<std::string>();
1281 if ( component ==
"AnyBig" )
1284 surfels.insert( light_surface->begin(), light_surface->end() );
1286 else if ( component ==
"All" )
1289 K.lowerBound(),
K.upperBound() );
1305 template <
typename TSurfelRange>
1308 (
const TSurfelRange& surfels,
1312 bool surfel_adjacency = params[
"surfelAdjacency" ].as<
int>();
1319 bool ok = ptrSurface->build( ptrSurfContainer );
1321 trace.
warning() <<
"[Shortcuts::makeIdxDigitalSurface]"
1322 <<
" Error building indexed digital surface." << std::endl;
1338 template <
typename TDigitalSurfaceContainer>
1346 surfels.insert( surface->begin(), surface->end() );
1368 const KSpace&
K = surfaces[ 0 ]->container().space();
1370 for ( std::size_t i = 0; i < surfaces.size(); ++i )
1372 const KSpace& Ki = surfaces[ i ]->container().space();
1373 if ( ( Ki.lowerBound() !=
K.lowerBound() )
1374 || ( Ki.upperBound() !=
K.upperBound() ) )
1375 trace.
warning() <<
"[Shortcuts::makeIdxDigitalSurface]"
1376 <<
" Incompatible digital spaces for surface " << i << std::endl;
1377 surfels.insert( surfaces[ i ]->begin(), surfaces[ i ]->end() );
1396 template <
typename TDigitalSurfaceContainer>
1405 result.reserve( 2 * surface->size() + 100 );
1408 for (
auto&& surfel : *surface )
1411 for (
auto&& primal_cell : primal_cells )
1413 if ( ! c2i.count( primal_cell ) )
1415 result.push_back( primal_cell );
1416 c2i[ primal_cell ] = n++;
1435 template <
typename TDigitalSurfaceContainer>
1466 template <
typename TDigitalSurfaceContainer>
1473 result.reserve( surface->size() );
1476 for (
auto&& surfel : *surface )
1479 for (
auto&& primal_vtx : primal_vtcs )
1481 if ( ! c2i.count( primal_vtx ) )
1483 result.push_back( primal_vtx );
1484 c2i[ primal_vtx ] = n++;
1507 template <
typename TDigitalSurfaceContainer>
1544 template <
typename TDigitalSurfaceContainer>
1567 template <
typename TDigitalSurfaceContainer>
1571 const Surfel& start_surfel,
1574 typedef ::DGtal::DigitalSurface<TDigitalSurfaceContainer> AnyDigitalSurface;
1576 std::string traversal = params[
"surfaceTraversal" ].as<std::string>();
1577 if ( traversal ==
"DepthFirst" )
1581 VisitorRange range(
new Visitor( *surface, start_surfel ) );
1582 std::for_each( range.begin(), range.end(),
1583 [&result] (
Surfel s ) { result.push_back( s ); } );
1585 else if ( traversal ==
"BreadthFirst" )
1589 VisitorRange range(
new Visitor( *surface, start_surfel ) );
1590 std::for_each( range.begin(), range.end(),
1591 [&result] (
Surfel s ) { result.push_back( s ); } );
1595 std::for_each( surface->begin(), surface->end(),
1596 [&result] (
Surfel s ) { result.push_back( s ); } );
1637 std::string traversal = params[
"surfaceTraversal" ].as<std::string>();
1638 if ( traversal ==
"DepthFirst" )
1642 VisitorRange range(
new Visitor( *surface, start_surfel ) );
1643 std::for_each( range.begin(), range.end(),
1644 [&result] (
IdxSurfel s ) { result.push_back( s ); } );
1646 else if ( traversal ==
"BreadthFirst" )
1650 VisitorRange range(
new Visitor( *surface, start_surfel ) );
1651 std::for_each( range.begin(), range.end(),
1652 [&result] (
IdxSurfel s ) { result.push_back( s ); } );
1654 else return surface->allVertices();
1669 template <
typename TDigitalSurfaceContainer,
1670 typename TCellEmbedder>
1674 const TCellEmbedder& embedder,
1675 std::string off_file,
1681 std::ofstream output_off( off_file.c_str() );
1682 output_off <<
"OFF" << std::endl;
1683 output_off <<
"# Generated from DGtal::Shortcuts from the DGTal library" << std::endl;
1686 output_off << pointels.size() <<
" " << digsurf->size() <<
" " << 0 <<
" " << std::endl;
1691 for (
auto&& pointel : pointels )
1694 output_off << p[ 0 ] <<
" " << p[ 1 ] <<
" " << p[ 2 ] << std::endl;
1698 for (
auto&& surfel : *digsurf )
1701 output_off << primal_vtcs.size();
1703 for (
auto&& primal_vtx : primal_vtcs )
1704 output_off <<
" " << (c2i[ primal_vtx ]);
1709 output_off << face_color.r() <<
" " << face_color.g()
1710 <<
" " << face_color.b() <<
" " << face_color.a();
1712 output_off << std::endl;
1714 return output_off.good();
1735 template <
typename TDigitalSurfaceContainer,
1736 typename TCellEmbedder>
1740 const TCellEmbedder& embedder,
1742 const Colors& diffuse_colors,
1743 std::string objfile,
1744 const Color& ambient_color =
Color( 32, 32, 32 ),
1745 const Color& diffuse_color =
Color( 200, 200, 255 ),
1749 std::string mtlfile;
1750 auto lastindex = objfile.find_last_of(
".");
1751 if ( lastindex == std::string::npos )
1753 mtlfile = objfile +
".mtl";
1754 objfile = objfile +
".obj";
1758 mtlfile = objfile.substr(0, lastindex) +
".mtl";
1761 std::ofstream output_obj( objfile.c_str() );
1762 output_obj <<
"# OBJ format" << std::endl;
1763 output_obj <<
"# DGtal::MeshHelpers::exportOBJwithFaceNormalAndColor" << std::endl;
1764 output_obj <<
"o anObject" << std::endl;
1766 auto indexpath = objfile.find_last_of(
"/");
1767 output_obj <<
"mtllib " << mtlfile.substr(indexpath+1) << std::endl;
1768 std::ofstream output_mtl( mtlfile.c_str() );
1769 output_mtl <<
"# MTL format"<< std::endl;
1770 output_mtl <<
"# generated from MeshWriter from the DGTal library"<< std::endl;
1775 for (
auto&& pointel : pointels )
1778 output_obj <<
"v " << p[ 0 ] <<
" " << p[ 1 ] <<
" " << p[ 2 ] << std::endl;
1781 Idx nbfaces = digsurf->size();
1782 bool has_normals = ( nbfaces == normals.size() );
1785 for (
Idx f = 0; f < nbfaces; ++f )
1787 const auto& p = normals[ f ];
1788 output_obj <<
"vn " << p[ 0 ] <<
" " << p[ 1 ] <<
" " << p[ 2 ] << std::endl;
1792 bool has_material = ( nbfaces == diffuse_colors.size() );
1793 Idx idxMaterial = 0;
1794 std::map<Color, Idx > mapMaterial;
1797 for (
Idx f = 0; f < nbfaces; ++f )
1799 Color c = diffuse_colors[ f ];
1800 if ( mapMaterial.count( c ) == 0 )
1803 ( output_mtl, idxMaterial, ambient_color, c, specular_color );
1804 mapMaterial[ c ] = idxMaterial++;
1811 ( output_mtl, idxMaterial, ambient_color, diffuse_color, specular_color );
1816 for (
auto&& surfel : *digsurf )
1818 output_obj <<
"usemtl material_"
1819 << ( has_material ? mapMaterial[ diffuse_colors[ f ] ] : idxMaterial )
1826 for (
auto&& primal_vtx : primal_vtcs )
1827 output_obj <<
" " << (c2i[ primal_vtx ]+1) <<
"//" << (f+1);
1831 for (
auto&& primal_vtx : primal_vtcs )
1832 output_obj <<
" " << (c2i[ primal_vtx ]+1);
1834 output_obj << std::endl;
1838 return output_obj.good();
1856 template <
typename TDigitalSurfaceContainer>
1861 const Colors& diffuse_colors,
1862 std::string objfile,
1863 const Color& ambient_color =
Color( 32, 32, 32 ),
1864 const Color& diffuse_color =
Color( 200, 200, 255 ),
1868 return saveOBJ( digsurf, embedder, normals, diffuse_colors, objfile,
1869 ambient_color, diffuse_color, specular_color );
1885 template <
typename TDigitalSurfaceContainer>
1889 std::string off_file,
1890 const Color& face_color =
Color( 32, 32, 32 ))
1893 return saveOFF( digsurf, embedder, off_file, face_color);
1907 template <
typename TDigitalSurfaceContainer>
1911 std::string objfile,
1912 const Color& ambient_color =
Color( 32, 32, 32 ),
1913 const Color& diffuse_color =
Color( 200, 200, 255 ),
1918 ambient_color, diffuse_color, specular_color );
1942 const Colors& diffuse_colors,
1943 std::string objfile,
1944 const Color& ambient_color =
Color( 32, 32, 32 ),
1945 const Color& diffuse_color =
Color( 200, 200, 255 ),
1949 std::string mtlfile;
1950 auto lastindex = objfile.find_last_of(
".");
1951 if ( lastindex == std::string::npos )
1953 mtlfile = objfile +
".mtl";
1954 objfile = objfile +
".obj";
1958 mtlfile = objfile.substr(0, lastindex) +
".mtl";
1960 std::ofstream output_obj( objfile.c_str() );
1961 output_obj <<
"# OBJ format" << std::endl;
1962 output_obj <<
"# DGtal::saveOBJ" << std::endl;
1963 output_obj <<
"o vectors" << std::endl;
1964 output_obj <<
"mtllib " << mtlfile << std::endl;
1965 std::ofstream output_mtl( mtlfile.c_str() );
1966 output_mtl <<
"# MTL format"<< std::endl;
1967 output_mtl <<
"# generated from MeshWriter from the DGTal library"<< std::endl;
1969 auto n = std::min( positions.size(), vf.size() );
1970 for (
unsigned int i = 0; i < n; ++i )
1976 auto mc = std::max_element( absv.
begin(), absv.
end() ) - absv.
begin();
1982 RealPoint t[4] = { thickness * e0, thickness * e1,
1983 -thickness * e0, -thickness * e1 };
1984 for (
unsigned int j = 0; j < 4; ++j ) {
1987 output_obj <<
"v " << pt0[ 0 ] <<
" " << pt0[ 1 ] <<
" " << pt0[ 2 ]
1989 output_obj <<
"v " << pt1[ 0 ] <<
" " << pt1[ 1 ] <<
" " << pt1[ 2 ]
1994 std::map<Color,Idx> map_colors;
1997 for (
auto && c : diffuse_colors )
1998 if ( ! map_colors.count( c ) )
1999 map_colors[ c ] = j++;
2003 bool has_material = ! diffuse_colors.empty();
2005 for (
auto&& pair : map_colors )
2007 ( output_mtl, pair.second, ambient_color, pair.first, specular_color);
2010 ( output_mtl, 0, ambient_color, diffuse_color, specular_color );
2012 for (
Idx i = 0; i < n; ++i )
2014 output_obj <<
"usemtl material_"
2015 << ( has_material ? map_colors[ diffuse_colors[ i ] ] : 0 )
2018 for (
Idx j = 0; j < 8; j += 2 )
2019 output_obj <<
"f " << (b+j) <<
" " << (b+j+1)
2020 <<
" " << (b+(j+3)%8) <<
" " << (b+(j+2)%8) << std::endl;
2021 output_obj <<
"f " << b <<
" " << (b+2)
2022 <<
" " << (b+4) <<
" " << (b+6) << std::endl;
2023 output_obj <<
"f " << (b+1) <<
" " << (b+7)
2024 <<
" " << (b+5) <<
" " << (b+3) << std::endl;
2027 return output_obj.good();
2039 (
"faceSubdivision",
"Centroid" );
2102 template <
typename TContainer >
2111 ( *aSurface, embedder, *pTriSurf, s2i );
2120 template <
typename TContainer >
2149 std::string faceSubdivision = params[
"faceSubdivision" ].as<std::string>();
2150 bool centroid = ( faceSubdivision ==
"Centroid" );
2197 RealVector gh = { params[
"gridsizex" ].as<
double>(),
2198 params[
"gridsizey" ].as<double>(),
2199 params[
"gridsizez" ].as<
double>() };
2200 double threshold = params[
"thresholdMin" ].as<
double>() + 0.5;
2204 PointEmbedder pembedder;
2205 pembedder.init( gh );
2206 ImageCellEmbedder cembedder;
2207 cembedder.init(
K, *gray_scale_image, pembedder, threshold );
2212 ( *digSurf, cembedder, *pPolySurf, s2i );
2240 RealVector gh = { params[
"gridsizex" ].as<
double>(),
2241 params[
"gridsizey" ].as<double>(),
2242 params[
"gridsizez" ].as<
double>() };
2243 double threshold = params[
"thresholdMin" ].as<
double>() + 0.5;
2247 PointEmbedder pembedder;
2248 pembedder.init( gh );
2249 ImageCellEmbedder cembedder;
2250 cembedder.init(
K, *gray_scale_image, pembedder, threshold );
2255 ( *digSurf, cembedder, *pPolySurf, s2i );
2266 template <
typename TContainer >
2276 ( *aSurface, embedder, *pPolySurf, s2i );
2286 template <
typename TContainer >
2300 template <
typename TContainer >
2308 aSurface->positions().storage() ) );
2319 template <
typename TContainer >
2329 ( *aSurface, embedder, *pPolySurf, c2i );
2339 template <
typename TContainer >
2353 template <
typename TContainer >
2370 template <
typename TContainer >
2388 template <
typename TContainer >
2402 template <
typename TContainer >
2417 template <
typename TPo
int>
2421 const std::string& objfile )
2423 std::ofstream output( objfile.c_str() );
2437 template <
typename TPo
int>
2440 std::string off_file,
2446 std::ofstream output( off_file.c_str() );
2447 for (
unsigned int i=0; i< m.nbFaces(); i++)
2449 m.setFaceColor(i, face_color);
2462 template <
typename TPo
int>
2466 const std::string& objfile )
2468 std::ofstream output( objfile.c_str() );
2486 template <
typename TPo
int>
2491 const Colors& diffuse_colors,
2492 std::string objfile,
2493 const Color& ambient_color =
Color( 32, 32, 32 ),
2494 const Color& diffuse_color =
Color( 200, 200, 255 ),
2497 std::string mtlfile;
2498 auto lastindex = objfile.find_last_of(
".");
2499 if ( lastindex == std::string::npos )
2501 mtlfile = objfile +
".mtl";
2502 objfile = objfile +
".obj";
2506 mtlfile = objfile.substr(0, lastindex) +
".mtl";
2508 std::ofstream output( objfile.c_str() );
2510 ( output, mtlfile, *polysurf, normals, diffuse_colors,
2511 ambient_color, diffuse_color, specular_color );
2528 template <
typename TPo
int>
2533 const Colors& diffuse_colors,
2534 std::string objfile,
2535 const Color& ambient_color =
Color( 32, 32, 32 ),
2536 const Color& diffuse_color =
Color( 200, 200, 255 ),
2539 std::string mtlfile;
2540 auto lastindex = objfile.find_last_of(
".");
2541 if ( lastindex == std::string::npos )
2543 mtlfile = objfile +
".mtl";
2544 objfile = objfile +
".obj";
2548 mtlfile = objfile.substr(0, lastindex) +
".mtl";
2550 std::ofstream output( objfile.c_str() );
2552 ( output, mtlfile, *trisurf, normals, diffuse_colors,
2553 ambient_color, diffuse_color, specular_color );
2566 template <
typename TPo
int>
2569 std::string off_file,
2575 std::ofstream output( off_file.c_str() );
2576 for (
unsigned int i=0; i< m.nbFaces(); i++)
2578 m.setFaceColor(i, face_color);
2596 (
"colormap",
"Custom" )
2597 (
"zero-tic", 0.0 );
2616 template <
typename TValue>
2618 getRangeMatch(
const std::vector< TValue >& s1,
const std::vector< TValue >& s2,
2619 bool perfect =
false )
2621 if ( perfect && ( s1.size() != s2.size() ) )
return IdxRange();
2622 std::map<TValue, Idx> M;
2624 for (
auto val : s2 ) M[ val ] = idx++;
2627 for (
auto val : s1 )
2629 auto it = M.find( val );
2630 if ( it != M.end() ) V[ idx++ ] = it->second;
2634 V[ idx++ ] = s2.size();
2651 template <
typename TValue>
2652 static std::vector< TValue >
2655 std::vector< TValue > result( match.size() );
2656 for (
Idx i = 0; i < result.size(); i++ )
2657 result[ i ] = range[ match[ i ] ];
2672 std::string cmap = params[
"colormap" ].as<std::string>();
2681 else if ( cmap ==
"Error" )
2711 auto ztic = params[
"zero-tic" ].as<
double>();
2713 if ( ztic <= 0.0 )
return ztic_cmap;
2714 if ( min <= 0.0 && 0.0 <=
max )
2715 ztic_cmap.addTick( 0.0, ztic );
2716 ztic_cmap.finalize();
2729 template <
typename TCellEmbedder = CanonicCellEmbedder< KSpace > >
2732 ( std::ostream& output,
2734 const TCellEmbedder& embedder )
2736 typedef unsigned long Size;
2739 const KSpace&
K = embedder.space();
2741 std::map< Cell, Size > vtx_numbering;
2743 for (
auto&& s : surfels )
2746 for (
auto&& primal_vtx : primal_vtcs )
2748 if ( ! vtx_numbering.count( primal_vtx ) )
2750 vtx_numbering[ primal_vtx ] = n++;
2753 output <<
"v " << p[ 0 ] <<
" " << p[ 1 ] <<
" " << p[ 2 ] << std::endl;
2758 for (
auto&& s : surfels )
2762 for (
auto&& primal_vtx : primal_vtcs )
2763 output <<
" " << vtx_numbering[ primal_vtx ];
2764 output << std::endl;
2766 return output.good();
2780 template <
typename TAnyDigitalSurface>
2783 ( std::ostream& output,
2807 template <
typename TAnyDigitalSurface,
2811 ( std::ostream& output,
2813 const TCellEmbedder& embedder )
2829 ( std::ostream& output,
2849 template <
typename TCellEmbedder = CanonicCellEmbedder< KSpace > >
2852 ( std::ostream& output,
2854 const TCellEmbedder& embedder )
2857 auto surfelmap = surface->surfels();
2859 for (
auto&& idx : idxsurfels )
2860 surfels.push_back( surfelmap[ idx ] );
2880 template <
typename TDigitalSurfaceContainer>
2883 ( std::ostream& output,
2913 template <
typename TDigitalSurfaceContainer,
2917 ( std::ostream& output,
2919 const TCellEmbedder& embedder,
2922 typedef unsigned long Size;
2925 std::string dualFaceSubdivision = params[
"faceSubdivision" ].as<std::string>();
2927 = dualFaceSubdivision ==
"Naive" ? 1
2928 : dualFaceSubdivision ==
"Centroid" ? 2
2930 const KSpace&
K = embedder.space();
2932 std::map< Vertex, Size > vtx_numbering;
2933 std::map< Face, Size > sub_numbering;
2935 for (
auto && s : *surface )
2937 if ( ! vtx_numbering.count( s ) )
2939 vtx_numbering[ s ] = n++;
2942 output <<
"v " << p[ 0 ] <<
" " << p[ 1 ] <<
" " << p[ 2 ] << std::endl;
2945 auto faces = surface->allClosedFaces();
2947 if ( subdivide == 2 )
2949 for (
auto&& f : faces )
2951 auto vtcs = surface->verticesAroundFace( f );
2952 Size nv = vtcs.size();
2955 sub_numbering[ f ] = n++;
2957 for (
auto&& s : vtcs ) p += embedder(
K.unsigns( s ) );
2959 output <<
"v " << p[ 0 ] <<
" " << p[ 1 ] <<
" " << p[ 2 ] << std::endl;
2964 if ( subdivide == 0 )
2966 for (
auto&& f : faces )
2969 auto vtcs = surface->verticesAroundFace( f );
2970 std::reverse( vtcs.begin(), vtcs.end() );
2971 for (
auto&& s : vtcs )
2972 output <<
" " << vtx_numbering[ s ];
2973 output << std::endl;
2976 else if ( subdivide == 1 )
2978 for (
auto&& f : faces )
2980 auto vtcs = surface->verticesAroundFace( f );
2981 Size nv = vtcs.size();
2982 for (
Size i = 1; i < nv - 1; ++i )
2983 output <<
"f " << vtx_numbering[ vtcs[ 0 ] ]
2984 <<
" " << vtx_numbering[ vtcs[ i+1 ] ]
2985 <<
" " << vtx_numbering[ vtcs[ i ] ] << std::endl;
2988 else if ( subdivide == 2 )
2990 for (
auto&& f : faces )
2992 auto vtcs = surface->verticesAroundFace( f );
2993 Size nv = vtcs.size();
2995 output <<
"f " << vtx_numbering[ vtcs[ 0 ] ]
2996 <<
" " << vtx_numbering[ vtcs[ 2 ] ]
2997 <<
" " << vtx_numbering[ vtcs[ 1 ] ] << std::endl;
2999 Size c = sub_numbering[ f ];
3000 for (
Size i = 0; i < nv; ++i )
3003 <<
" " << vtx_numbering[ vtcs[ (i+1)%nv ] ]
3004 <<
" " << vtx_numbering[ vtcs[ i ] ] << std::endl;
3009 return output.good();
3019 output <<
" " <<
K.sKCoord( cell, d );
3028 return K.uCell( kp );
3035 output <<
" " <<
K.sSign( scell );
3046 return K.sCell( kp, s );
3050 template <
typename Value>
3056 void operator()( std::ostream& output,
const std::vector<Value>& vv )
3058 for (
auto&& v : vv ) output <<
" " << v;
3062 template <
typename Value>
3067 std::getline( input, str );
3069 std::stringstream strstr(str);
3071 std::istream_iterator<std::string> it(strstr);
3072 std::istream_iterator<std::string> end;
3073 std::vector<std::string> results(it, end);
3074 std::stringstream sstr( results[ 0 ] );
3076 return ( results.size() == 1 ) && input.good();
3079 bool operator()( std::istream& input, std::vector<Value>& values )
3082 std::getline( input, str );
3084 std::stringstream strstr(str);
3086 std::istream_iterator<std::string> it(strstr);
3087 std::istream_iterator<std::string> end;
3088 std::vector<std::string> results(it, end);
3089 values.resize( results.size() );
3090 for (
unsigned int i = 0; i < results.size(); ++i ) {
3091 std::stringstream sstr( results[ i ] );
3092 sstr >> values[ i ];
3094 return input.good();
3110 template <
typename TSCellMap,
typename TValueWriter>
3113 ( std::ostream& output,
3115 const TSCellMap& anyMap,
3116 const TValueWriter& writer )
3119 for (
auto&& v : anyMap )
3121 w( output,
K, v.first );
3122 writer( output, v.second );
3123 output << std::endl;
3125 return output.good();
3140 template <
typename TCellMap,
typename TValueWriter>
3143 ( std::ostream& output,
3145 const TCellMap& anyMap,
3146 const TValueWriter& writer )
3149 for (
auto&& v : anyMap )
3151 w( output,
K, v.first );
3152 writer( output, v.second );
3153 output << std::endl;
3155 return output.good();
3166 auto faces =
K.uFaces(
K.unsigns( s ) );
3168 for (
auto&& f : faces )
3170 if (
K.uDim( f ) == k ) primal_cells.push_back( f );
3172 return primal_cells;
3196 std::swap( vtcs[ 2 ], vtcs[ 3 ] );
3197 auto orth_dir =
K.sOrthDir( s );
3198 auto direct =
K.sDirect( s, orth_dir ) ? ccw : ! ccw;
3199 Vector s0s1 =
K.uCoords( vtcs[ 1 ] ) -
K.uCoords( vtcs[ 0 ] );
3200 Vector s0s2 =
K.uCoords( vtcs[ 2 ] ) -
K.uCoords( vtcs[ 0 ] );
3202 if ( ( ( t[ orth_dir ] > 0.0 ) && direct )
3203 || ( ( t[ orth_dir ] < 0.0 ) && ! direct ) )
3204 std::reverse( vtcs.begin(), vtcs.end() );
3257 out <<
"[Shortcuts]";
3290 template <
typename T>
3305#undef Shortcuts_RECURSES
Aim: This class is useful to perform a breadth-first exploration of a graph given a starting point or...
Structure representing an RGB triple with alpha component.
Aim: This class encapsulates its parameter class so that to indicate to the user that the object/poin...
Aim: Smart pointer based on reference counts.
Aim: This class is useful to perform a depth-first exploration of a graph given a starting point or s...
Aim: Represents a set of n-1-cells in a nD space, together with adjacency relation between these cell...
DigitalSurfaceContainer::Surfel Surfel
DigitalSurfaceContainer::Cell Cell
Surfel Vertex
Defines the type for a vertex.
std::vector< Arc > ArcRange
The range of arcs is defined as a vector.
DigitalSurfaceContainer::SCell SCell
Aim: A class for computing the Gauss digitization of some Euclidean shape, i.e. its intersection with...
Aim: This class template may be used to (linearly) convert scalar values in a given range into a colo...
void addColor(const Color &color)
Aim: Transforms a graph visitor into a single pass input range.
Aim: Parallelepidec region of a digital space, model of a 'CDomain'.
const ConstIterator & begin() const
const Point & lowerBound() const
const Point & upperBound() const
const ConstIterator & end() const
Aim: a cellular embedder for images. (default constructible, copy constructible, assignable)....
Aim: model of CEuclideanOrientedShape concepts to create a shape from a polynomial.
Aim: Represents a digital surface with the topology of its dual surface. Its aim is to mimick the sta...
std::vector< Arc > ArcRange
HalfEdgeDataStructure::HalfEdgeIndex Arc
Aim: From a point predicate (model of concepts::CPointPredicate), this class constructs another point...
std::set< SCell > SurfelSet
Preferred type for defining a set of surfels (always signed cells).
SpaceND< dim, Integer > Space
static const constexpr Dimension dimension
Aim: A model of CDigitalSurfaceContainer which defines the digital surface as the boundary of an impl...
Aim: This class converts a string polynomial expression in a multivariate polynomial.
Iterator read(Polynomial &p, Iterator begin, Iterator end)
Aim: Represents a multivariate polynomial, i.e. an element of , where K is some ring or field.
static bool exportOBJ(std::ostream &output, const TriangulatedSurface< Point > &trisurf)
static bool digitalSurface2PrimalSurfaceMesh(const DigitalSurface< DigitalSurfaceContainer > &dsurf, const CellEmbedder &cembedder, SurfaceMesh< typename CellEmbedder::Value, typename CellEmbedder::Value > &polysurf, CellMap &cellmap)
static bool digitalSurface2PrimalPolygonalSurface(const DigitalSurface< DigitalSurfaceContainer > &dsurf, const CellEmbedder &cembedder, PolygonalSurface< typename CellEmbedder::Value > &polysurf, CellMap &cellmap)
static bool mesh2TriangulatedSurface(const Mesh< Point > &mesh, TriangulatedSurface< Point > &trisurf)
static void polygonalSurface2TriangulatedSurface(const PolygonalSurface< Point > &polysurf, TriangulatedSurface< Point > &trisurf, bool centroid=true)
static bool exportMTLNewMaterial(std::ostream &output_mtl, unsigned long idxMaterial, const Color &ambient_color, const Color &diffuse_color, const Color &specular_color)
static void polygonalSurface2Mesh(const PolygonalSurface< Point > &polysurf, Mesh< Point > &mesh)
static void digitalSurface2DualTriangulatedSurface(const DigitalSurface< DigitalSurfaceContainer > &dsurf, const CellEmbedder &cembedder, TriangulatedSurface< typename CellEmbedder::Value > &trisurf, VertexMap &vertexmap)
static bool exportOBJwithFaceNormalAndColor(std::ostream &output_obj, const std::string &mtl_filename, const TTriangulatedOrPolygonalSurface &polysurf, const std::vector< typename TTriangulatedOrPolygonalSurface::Point > &normals, const std::vector< Color > &diffuse_colors, const Color &ambient_color=Color(32, 32, 32), const Color &diffuse_color=Color(200, 200, 255), const Color &specular_color=Color::White)
static void digitalSurface2DualPolygonalSurface(const DigitalSurface< DigitalSurfaceContainer > &dsurf, const CellEmbedder &cembedder, PolygonalSurface< typename CellEmbedder::Value > &polysurf, VertexMap &vertexmap)
static void triangulatedSurface2Mesh(const TriangulatedSurface< Point > &trisurf, Mesh< Point > &mesh)
static bool mesh2PolygonalSurface(const Mesh< Point > &mesh, PolygonalSurface< Point > &polysurf)
Aim: This class is defined to represent a surface mesh through a set of vertices and faces....
auto crossProduct(const PointVector< dim, OtherComponent, OtherStorage > &v) const -> decltype(DGtal::crossProduct(*this, v))
Cross product with a PointVector.
TEuclideanRing Component
Type for Vector elements.
static Self zero
Static const for zero PointVector.
Aim: Represents a polygon mesh, i.e. a 2-dimensional combinatorial surface whose faces are (topologic...
Aim: A simple point embedder where grid steps are given for each axis. Note that the real point (0,...
Aim: A model of CDigitalSurfaceContainer which defines the digital surface as connected surfels....
Aim: This class is used to simplify shape and surface creation. With it, you can create new shapes an...
static Parameters parametersUtilities()
GradientColorMap< Scalar > ColorMap
static CountedPtr< BinaryImage > makeBinaryImage(CountedPtr< BinaryImage > bimage, Parameters params=parametersBinaryImage())
ImageContainerBySTLVector< Domain, bool > BinaryImage
defines a black and white image with (hyper-)rectangular domain.
static bool outputPrimalDigitalSurfaceAsObj(std::ostream &output, CountedPtr< TAnyDigitalSurface > surface, const TCellEmbedder &embedder)
Space::Vector Vector
Vector with integer coordinates.
static bool saveOBJ(CountedPtr< ::DGtal::TriangulatedSurface< TPoint > > trisurf, 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< DoubleImage > makeDoubleImage(Domain aDomain)
LightDigitalSurface::ArcRange ArcRange
static KSpace getKSpace(CountedPtr< BinaryImage > bimage, Parameters params=parametersKSpace())
static std::map< std::string, std::string > getPolynomialList()
static Parameters parametersImplicitShape3D()
static Parameters parametersKSpace()
static CountedPtr< TriangulatedSurface > makeTriangulatedSurface(CountedPtr< ::DGtal::DigitalSurface< TContainer > > aSurface)
static CountedPtr< DoubleImage > makeDoubleImage(std::string input)
LightDigitalSurface::Surfel Surfel
Space::RealPoint RealPoint
Point with floating-point coordinates.
static KSpace getKSpace(const Point &low, const Point &up, Parameters params=parametersKSpace())
SetOfSurfels< KSpace, SurfelSet > ExplicitSurfaceContainer
defines a heavy container that represents any digital surface.
LightDigitalSurface::Vertex Vertex
static KSpace getKSpace(Parameters params=parametersKSpace()|parametersDigitizedImplicitShape3D())
static bool saveOFF(CountedPtr< ::DGtal::PolygonalSurface< TPoint > > polysurf, std::string off_file, const Color &face_color=DGtal::Color::None)
static CountedPtr< DigitizedImplicitShape3D > makeDigitizedImplicitShape3D(CountedPtr< ImplicitShape3D > shape, Parameters params=parametersDigitizedImplicitShape3D())
std::map< Surfel, IdxSurfel > Surfel2Index
static bool outputCellMapAsCSV(std::ostream &output, const KSpace &K, const TCellMap &anyMap, const TValueWriter &writer)
static CountedPtr< DigitalSurface > makeDigitalSurface(CountedPtr< IdxDigitalSurface > idx_surface, const Parameters ¶ms=parametersDigitalSurface())
static bool outputPrimalIdxDigitalSurfaceAsObj(std::ostream &output, CountedPtr< IdxDigitalSurface > surface)
static CellRange getCellRange(Cell2Index &c2i, CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > surface, const Dimension k)
Shortcuts(Shortcuts &&other)=delete
static SurfelRange getSurfelRange(CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > surface, const Surfel &start_surfel, const Parameters ¶ms=parametersDigitalSurface())
RealVector::Component Scalar
Floating-point numbers.
::DGtal::TriangulatedSurface< RealPoint > TriangulatedSurface
std::map< Cell, IdxVertex > Cell2Index
static bool outputDualDigitalSurfaceAsObj(std::ostream &output, CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > surface, const TCellEmbedder &embedder, const Parameters ¶ms=parametersMesh())
static CountedPtr< PolygonalSurface > makePolygonalSurface(CountedPtr< Mesh > aMesh)
ImageContainerBySTLVector< Domain, float > FloatImage
defines a float image with (hyper-)rectangular domain.
static bool saveGrayScaleImage(CountedPtr< GrayScaleImage > gray_scale_image, std::string output)
static PointelRange getPointelRange(Cell2Index &c2i, CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > surface)
static bool saveOFF(CountedPtr< ::DGtal::TriangulatedSurface< TPoint > > trisurf, std::string off_file, const Color &face_color=DGtal::Color::None)
::DGtal::SurfaceMesh< RealPoint, RealPoint > SurfaceMesh
Space::Point Point
Point with integer coordinates.
static CellRange getPrimalVertices(const KSpace &K, const Surfel &s, bool ccw)
static CellRange getPrimalCells(const KSpace &K, const SCell &s, const Dimension k)
static KSpace getKSpace(CountedPtr< GrayScaleImage > gimage, Parameters params=parametersKSpace())
std::vector< Color > Colors
static Parameters parametersMesh()
static CountedPtr< Mesh > makeMesh(CountedPtr< TriangulatedSurface > triSurf, const Color &aColor=Color::White)
static CountedPtr< FloatImage > makeFloatImage(CountedPtr< ImplicitShape3D > shape, Parameters params=parametersDigitizedImplicitShape3D())
static bool saveOBJ(CountedPtr< ::DGtal::TriangulatedSurface< TPoint > > trisurf, const std::string &objfile)
static std::vector< CountedPtr< LightDigitalSurface > > makeLightDigitalSurfaces(SurfelRange &surfel_reps, CountedPtr< BinaryImage > bimage, const KSpace &K, const Parameters ¶ms=parametersDigitalSurface())
static Parameters parametersDigitalSurface()
static CountedPtr< DoubleImage > makeDoubleImage(CountedPtr< ImplicitShape3D > shape, Parameters params=parametersDigitizedImplicitShape3D())
ImplicitPolynomial3Shape< Space > ImplicitShape3D
Shortcuts & operator=(const Shortcuts &other)=delete
Space::Integer Integer
Integer numbers.
static CountedPtr< FloatImage > makeFloatImage(std::string input)
static KSpace getKSpace(CountedPtr< ::DGtal::IndexedDigitalSurface< TDigitalSurfaceContainer > > surface)
LightDigitalSurface::Face Face
::DGtal::Mesh< RealPoint > Mesh
static std::vector< CountedPtr< LightDigitalSurface > > makeLightDigitalSurfaces(CountedPtr< BinaryImage > bimage, const KSpace &K, const Parameters ¶ms=parametersDigitalSurface())
static CountedPtr< TriangulatedSurface > makeTriangulatedSurface(CountedPtr< PolygonalSurface > polySurf, const Parameters ¶ms=parametersMesh())
static bool outputPrimalDigitalSurfaceAsObj(std::ostream &output, CountedPtr< TAnyDigitalSurface > surface)
static bool saveOFF(CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > digsurf, std::string off_file, const Color &face_color=Color(32, 32, 32))
LightImplicitDigitalSurface< KSpace, BinaryImage > LightSurfaceContainer
static CellRange getPrimalVertices(const KSpace &K, const SCell &s)
static CountedPtr< GrayScaleImage > makeGrayScaleImage(Domain aDomain)
MPolynomial< Space::dimension, Scalar > ScalarPolynomial
defines a multi-variate polynomial : RealPoint -> Scalar
static CountedPtr< FloatImage > makeFloatImage(Domain aDomain)
static CountedPtr< SurfaceMesh > makePrimalSurfaceMesh(CountedPtr< ::DGtal::IndexedDigitalSurface< TContainer > > aSurface)
static bool outputPrimalIdxDigitalSurfaceAsObj(std::ostream &output, CountedPtr< IdxDigitalSurface > surface, const TCellEmbedder &embedder)
static SurfelRange getSurfelRange(CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > surface, const Parameters ¶ms=parametersDigitalSurface())
KSpace::SurfelSet SurfelSet
defines a set of surfels
static CountedPtr< LightDigitalSurface > makeLightDigitalSurface(CountedPtr< BinaryImage > bimage, const KSpace &K, const Parameters ¶ms=parametersDigitalSurface())
static CountedPtr< PolygonalSurface > makePrimalPolygonalSurface(CountedPtr< ::DGtal::IndexedDigitalSurface< TContainer > > aSurface)
static CountedPtr< Mesh > makeMesh(CountedPtr< PolygonalSurface > polySurf, const Color &aColor=Color::White)
static const KSpace & refKSpace(CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > surface)
static CanonicSCellEmbedder< KSpace > getSCellEmbedder(const KSpace &K)
static CountedPtr< DigitalSurface > makeDigitalSurface(CountedPtr< TPointPredicate > bimage, const KSpace &K, const Parameters ¶ms=parametersDigitalSurface())
std::vector< Cell > CellRange
static CountedPtr< BinaryImage > makeBinaryImage(CountedPtr< DigitizedImplicitShape3D > shape_digitization, Parameters params=parametersBinaryImage())
static KSpace getKSpace(CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > surface)
static bool outputSurfelsAsObj(std::ostream &output, const SurfelRange &surfels, const TCellEmbedder &embedder)
static CountedPtr< PolygonalSurface > makePrimalPolygonalSurface(Cell2Index &c2i, CountedPtr< ::DGtal::DigitalSurface< TContainer > > aSurface)
static IdxRange getRangeMatch(const std::vector< TValue > &s1, const std::vector< TValue > &s2, bool perfect=false)
ImageContainerBySTLVector< Domain, GrayScale > GrayScaleImage
defines a grey-level image with (hyper-)rectangular domain.
static CanonicSCellEmbedder< KSpace > getSCellEmbedder(CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > surface)
::DGtal::DigitalSurface< ExplicitSurfaceContainer > DigitalSurface
defines an arbitrary digital surface over a binary image.
std::vector< IdxVertex > IdxRange
IdxDigitalSurface::Vertex IdxSurfel
void selfDisplay(std::ostream &out) const
KSpace::Space Space
Digital space.
std::vector< RealPoint > RealPoints
static CountedPtr< PolygonalSurface > makeDualPolygonalSurface(Surfel2Index &s2i, CountedPtr< ::DGtal::DigitalSurface< TContainer > > aSurface)
static CountedPtr< PolygonalSurface > makePolygonalSurface(CountedPtr< GrayScaleImage > gray_scale_image, const Parameters ¶ms=parametersKSpace()|parametersBinaryImage()|parametersDigitalSurface())
static bool saveOBJ(CountedPtr< ::DGtal::PolygonalSurface< TPoint > > polysurf, const std::string &objfile)
static ZeroTickedColorMap getZeroTickedColorMap(Scalar min, Scalar max, const Parameters ¶ms=parametersUtilities())
IdxDigitalSurface::ArcRange IdxArcRange
std::vector< RealVector > RealVectors
static bool saveOBJ(CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > digsurf, 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)
std::vector< Scalar > Scalars
static CountedPtr< BinaryImage > makeBinaryImage(std::string input, Parameters params=parametersBinaryImage())
IndexedDigitalSurface< ExplicitSurfaceContainer > IdxDigitalSurface
defines a connected or not indexed digital surface.
std::vector< SCell > SCellRange
static CountedPtr< GrayScaleImage > makeGrayScaleImage(std::string input)
static CountedPtr< IdxDigitalSurface > makeIdxDigitalSurface(const std::vector< CountedPtr< LightDigitalSurface > > &surfaces, const Parameters ¶ms=parametersDigitalSurface())
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)
::DGtal::PolygonalSurface< RealPoint > PolygonalSurface
static CanonicSCellEmbedder< KSpace > getSCellEmbedder(CountedPtr< ::DGtal::IndexedDigitalSurface< TDigitalSurfaceContainer > > surface)
Shortcuts(const Shortcuts &other)=delete
BOOST_CONCEPT_ASSERT((concepts::CCellularGridSpaceND< TKSpace >))
static const KSpace & refKSpace(CountedPtr< ::DGtal::IndexedDigitalSurface< TDigitalSurfaceContainer > > surface)
GaussDigitizer< Space, ImplicitShape3D > DigitizedImplicitShape3D
defines the digitization of an implicit shape.
static bool saveBinaryImage(CountedPtr< BinaryImage > bimage, std::string output)
std::vector< IdxSurfel > IdxSurfelRange
static Parameters parametersBinaryImage()
static CountedPtr< BinaryImage > makeBinaryImage(CountedPtr< GrayScaleImage > gray_scale_image, Parameters params=parametersBinaryImage())
IdxDigitalSurface::Arc IdxArc
static Parameters defaultParameters()
static CountedPtr< IdxDigitalSurface > makeIdxDigitalSurface(CountedPtr< BinaryImage > bimage, const KSpace &K, const Parameters ¶ms=parametersDigitalSurface())
static CountedPtr< GrayScaleImage > makeGrayScaleImage(CountedPtr< BinaryImage > binary_image, std::function< GrayScale(bool) > const &bool2grayscale=[](bool v) { return v ?(unsigned char) 255 :(unsigned char) 0;})
Space::RealVector RealVector
Vector with floating-point coordinates.
static bool saveOBJ(CountedPtr< ::DGtal::PolygonalSurface< TPoint > > polysurf, 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< TriangulatedSurface > makeTriangulatedSurface(CountedPtr< GrayScaleImage > gray_scale_image, const Parameters ¶ms=parametersKSpace()|parametersBinaryImage()|parametersDigitalSurface())
static bool outputDualDigitalSurfaceAsObj(std::ostream &output, CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > surface, const Parameters ¶ms=parametersMesh())
static Parameters parametersDigitizedImplicitShape3D()
LightDigitalSurface::Arc Arc
ImageContainerBySTLVector< Domain, double > DoubleImage
defines a double image with (hyper-)rectangular domain.
static CountedPtr< GrayScaleImage > makeGrayScaleImage(CountedPtr< FloatImage > fimage, Parameters params=parametersGrayScaleImage())
static CountedPtr< IdxDigitalSurface > makeIdxDigitalSurface(const TSurfelRange &surfels, ConstAlias< KSpace > K, const Parameters ¶ms=parametersDigitalSurface())
IdxDigitalSurface::Vertex IdxVertex
unsigned char GrayScale
The type for 8-bits gray-scale elements.
static PointelRange getCellRange(CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > surface, const Dimension k)
static CountedPtr< TriangulatedSurface > makeTriangulatedSurface(Surfel2Index &s2i, CountedPtr< ::DGtal::DigitalSurface< TContainer > > aSurface)
static CountedPtr< SurfaceMesh > makePrimalSurfaceMesh(CountedPtr< ::DGtal::DigitalSurface< TContainer > > aSurface)
static CountedPtr< PolygonalSurface > makeDualPolygonalSurface(CountedPtr< ::DGtal::DigitalSurface< TContainer > > aSurface)
static CountedPtr< SurfaceMesh > makePrimalSurfaceMesh(Cell2Index &c2i, CountedPtr< ::DGtal::DigitalSurface< TContainer > > aSurface)
static ColorMap getColorMap(Scalar min, Scalar max, const Parameters ¶ms=parametersUtilities())
static PointelRange getPointelRange(const KSpace &K, const SCell &surfel)
std::set< IdxSurfel > IdxSurfelSet
HyperRectDomain< Space > Domain
An (hyper-)rectangular domain.
static PointelRange getPointelRange(CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > surface)
static CanonicCellEmbedder< KSpace > getCellEmbedder(CountedPtr< ::DGtal::IndexedDigitalSurface< TDigitalSurfaceContainer > > surface)
static bool outputSCellMapAsCSV(std::ostream &output, const KSpace &K, const TSCellMap &anyMap, const TValueWriter &writer)
static IdxSurfelRange getIdxSurfelRange(CountedPtr< IdxDigitalSurface > surface, const IdxSurfel &start_surfel, const Parameters ¶ms=parametersDigitalSurface())
static bool saveOBJ(CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > digsurf, 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 std::vector< TValue > getMatchedRange(const std::vector< TValue > &range, const IdxRange &match)
TKSpace KSpace
Digital cellular space.
LightDigitalSurface::SCell SCell
static IdxSurfelRange getIdxSurfelRange(CountedPtr< IdxDigitalSurface > surface, const Parameters ¶ms=parametersDigitalSurface())
static CountedPtr< BinaryImage > makeBinaryImage(CountedPtr< DigitizedImplicitShape3D > shape_digitization, Domain shapeDomain, Parameters params=parametersBinaryImage())
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 bool saveOFF(CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > digsurf, const TCellEmbedder &embedder, std::string off_file, const Color &face_color=DGtal::Color::None)
TickedColorMap< Scalar, ColorMap > ZeroTickedColorMap
::DGtal::DigitalSurface< LightSurfaceContainer > LightDigitalSurface
defines a connected digital surface over a binary image.
static Parameters parametersGrayScaleImage()
static CountedPtr< BinaryImage > makeBinaryImage(Domain shapeDomain)
static CanonicCellEmbedder< KSpace > getCellEmbedder(const KSpace &K)
static CountedPtr< IdxDigitalSurface > makeIdxDigitalSurface(CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > surface, const Parameters ¶ms=parametersDigitalSurface())
static CountedPtr< PolygonalSurface > makePrimalPolygonalSurface(CountedPtr< ::DGtal::DigitalSurface< TContainer > > aSurface)
static CountedPtr< ImplicitShape3D > makeImplicitShape3D(const Parameters ¶ms=parametersImplicitShape3D())
static CountedPtr< GrayScaleImage > makeGrayScaleImage(CountedPtr< DoubleImage > fimage, Parameters params=parametersGrayScaleImage())
static CanonicCellEmbedder< KSpace > getCellEmbedder(CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > surface)
static CountedPtr< PolygonalSurface > makeDualPolygonalSurface(CountedPtr< ::DGtal::IndexedDigitalSurface< TContainer > > aSurface)
static CountedPtr< TriangulatedSurface > makeTriangulatedSurface(CountedPtr< Mesh > aMesh)
LightDigitalSurface::Cell Cell
TInteger Integer
Arithmetic ring induced by (+,-,*) and Integer numbers.
PointVector< dim, Integer > Point
Points in DGtal::SpaceND.
static SCell findABel(const KSpace &K, const PointPredicate &pp, unsigned int nbtries=1000)
static void sMakeBoundary(SCellSet &aBoundary, const KSpace &aKSpace, const PointPredicate &pp, const Point &aLowerBound, const Point &aUpperBound)
Aim: This class adapts any colormap to add "ticks" in the colormap colors.
Aim: Represents a triangulated surface. The topology is stored with a half-edge data structure....
Aim: Define a simple Foreground predicate thresholding image values between two constant values (the ...
BreadthFirstVisitor< MyDigitalSurface > Visitor
DGtal is the top-level namespace which contains all DGtal functions and types.
std::ostream & operator<<(std::ostream &out, const ClosedIntegerHalfPlane< TSpace > &object)
DGtal::uint32_t Dimension
Aim: A trivial embedder for signed and unsigned cell, which corresponds to the canonic injection of c...
Aim: A trivial embedder for signed cell, which corresponds to the canonic injection of cell centroids...
static TContainer import(const std::string &filename, std::vector< unsigned int > dimSpace=std::vector< unsigned int >())
Aim: Provide a mechanism to save image (2D or 3D) into file with the best saver loader according to a...
static bool export2OFF(std::ostream &out, const Mesh< TPoint > &aMesh, bool exportColor=true)
Cell operator()(std::istream &input, const KSpace &K)
void operator()(std::ostream &output, const KSpace &K, const Cell &cell)
SCell operator()(std::istream &input, const KSpace &K)
void operator()(std::ostream &output, const KSpace &K, const SCell &scell)
bool operator()(std::istream &input, Value &value)
bool operator()(std::istream &input, std::vector< Value > &values)
void operator()(std::ostream &output, const Value &v)
void operator()(std::ostream &output, const std::vector< Value > &vv)
Aim: Represents an embedded mesh as faces and a list of vertices. Vertices may be shared among faces ...
Aim: A cell embedder is a mapping from unsigned cells to Euclidean points. It adds inner types to fun...
Aim: This concept describes a cellular grid space in nD. In these spaces obtained by cartesian produc...
HalfEdgeDataStructure::Size Size
HyperRectDomain< Space > Domain