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;
234 static std::map< std::string, std::string >
237 std::vector< std::pair< std::string, std::string > >
238 Ps = { {
"sphere1",
"x^2+y^2+z^2-1" },
239 {
"sphere9",
"x^2+y^2+z^2-81" },
240 {
"ellipsoid",
"3*x^2+2*y^2+z^2-90" },
241 {
"cylinder",
"x^2+2*z^2-90" },
242 {
"torus",
"(x^2+y^2+z^2+6*6-2*2)^2-4*6*6*(x^2+y^2)" },
243 {
"rcube",
"x^4+y^4+z^4-6561" },
244 {
"goursat",
"-1*(8-0.03*x^4-0.03*y^4-0.03*z^4+2*x^2+2*y^2+2*z^2)" },
245 {
"goursat-hole",
"x^4+y^4+z^4-2*4*(x^2+y^2+z^2)+2*4*4-2" },
246 {
"distel",
"10000-(x^2+y^2+z^2+1000*(x^2+y^2)*(x^2+z^2)*(y^2+z^2))"},
247 {
"leopold",
"(x^2*y^2*z^2+4*x^2+4*y^2+3*z^2)-100" },
248 {
"diabolo",
"x^2-(y^2+z^2)^2" },
249 {
"heart",
"-1*(x^2+2.25*y^2+z^2-1)^3+x^2*z^3+0.1125*y^2*z^3" },
250 {
"crixxi",
"-0.9*(y^2+z^2-1)^2-(x^2+y^2-1)^3" } };
251 std::map< std::string, std::string > L;
253 L[ p.first ] = p.second;
267 (
"polynomial",
"sphere1" )
268 (
"projectionMaxIter", 20 )
269 (
"projectionAccuracy", 0.0001 )
270 (
"projectionGamma", 0.5 );
284 std::string poly_str = params[
"polynomial" ].as<std::string>();
287 if ( PL[ poly_str ] !=
"" ) poly_str = PL[ poly_str ];
289 Polynomial3Reader reader;
290 std::string::const_iterator iter
291 = reader.read( poly, poly_str.begin(), poly_str.end() );
292 if ( iter != poly_str.end() )
294 trace.
error() <<
"[Shortcuts::makeImplicitShape3D]"
295 <<
" ERROR reading polynomial: I read only <"
296 << poly_str.substr( 0, iter - poly_str.begin() )
297 <<
">, and I built P=" << poly << std::endl;
316 (
"gridsizez", 1.0 );
334 int closed = params[
"closed" ].as<
int>();
336 if ( !
K.init( low, up, closed ) )
338 <<
" Error building Khalimsky space K=" <<
K << std::endl;
356 int closed = params[
"closed" ].as<
int>();
358 if ( !
K.init( bimage->domain().lowerBound(),
359 bimage->domain().upperBound(),
362 <<
" Error building Khalimsky space K=" <<
K << std::endl;
380 int closed = params[
"closed" ].as<
int>();
382 if ( !
K.init( gimage->domain().lowerBound(),
383 gimage->domain().upperBound(),
386 <<
" Error building Khalimsky space K=" <<
K << std::endl;
393 template <
typename TDigitalSurfaceContainer>
398 return surface->container().space();
404 template <
typename TDigitalSurfaceContainer>
409 return surface->container().space();
415 template <
typename TDigitalSurfaceContainer>
420 return surface->container().space();
426 template <
typename TDigitalSurfaceContainer>
431 return surface->container().space();
492 bool closed = params[
"closed" ].as<
int>();
493 RealPoint p1( min_x - offset * h, min_x - offset * h, min_x - offset * h );
494 RealPoint p2( max_x + offset * h, max_x + offset * h, max_x + offset * h );
496 dshape->init( p1, p2, h );
501 <<
" Error building Khalimsky space K=" <<
K << std::endl
502 <<
"Note: if you use decimal values, check your locale for decimal point '.' or ','."
529 RealPoint p1( min_x - offset * h, min_x - offset * h, min_x - offset * h );
530 RealPoint p2( max_x + offset * h, max_x + offset * h, max_x + offset * h );
532 dshape->attach( shape );
533 dshape->init( p1, p2, h );
550 (
"thresholdMin", 0 )
551 (
"thresholdMax", 255 );
579 shape_digitization->getDomain(),
603 std::transform( shapeDomain.
begin(), shapeDomain.
end(),
605 [&shape_digitization]
606 (
const Point& p ) { return (*shape_digitization)(p); } );
611 KanungoPredicate noisy_dshape( *shape_digitization, shapeDomain, noise );
612 std::transform( shapeDomain.
begin(), shapeDomain.
end(),
614 [&noisy_dshape] (
const Point& p ) { return noisy_dshape(p); } );
631 if ( noise <= 0.0 )
return bimage;
633 const Domain shapeDomain = bimage->domain();
635 KanungoPredicate noisy_dshape( *bimage, shapeDomain, noise );
636 std::transform( shapeDomain.
begin(), shapeDomain.
end(),
638 [&noisy_dshape] (
const Point& p ) { return noisy_dshape(p); } );
658 int thresholdMin = params[
"thresholdMin"].as<
int>();
659 int thresholdMax = params[
"thresholdMax"].as<
int>();
663 ThresholdedImage tImage( image, thresholdMin, thresholdMax );
667 [tImage] (
const Point& p ) { return tImage(p); } );
687 int thresholdMin = params[
"thresholdMin"].as<
int>();
688 int thresholdMax = params[
"thresholdMax"].as<
int>();
691 ThresholdedImage tImage( *gray_scale_image, thresholdMin, thresholdMax );
695 [tImage] (
const Point& p ) { return tImage(p); } );
748 ( std::string input )
763 std::function<
GrayScale(
bool ) >
const & bool2grayscale
764 = [] (
bool v ) {
return v ? (
unsigned char) 255 : (
unsigned char) 0; }
770 std::transform( binary_image->begin(), binary_image->end(),
771 gray_scale_image->begin(),
773 return gray_scale_image;
806 float qShift = params[
"qShift" ].as<
float>();
807 float qSlope = params[
"qSlope" ].as<
float>();
808 std::function<
unsigned char(
float ) > f
809 = [qShift,qSlope] (
float v)
810 {
return (
unsigned char) std::min( 255.0f,
std::max( 0.0f, qSlope * v + qShift ) ); };
813 auto it = gimage->begin();
816 float val = (*fimage)( p );
838 double qShift = params[
"qShift" ].as<
double>();
839 double qSlope = params[
"qSlope" ].as<
double>();
840 std::function<
unsigned char(
double ) > f
841 = [qShift,qSlope] (
double v)
842 {
return (
unsigned char) std::min( 255.0,
std::max( 0.0, qSlope * v + qShift ) ); };
845 auto it = gimage->begin();
848 double val = (*fimage)( p );
876 ( std::string input )
904 RealPoint p1( min_x - offset * h, min_x - offset * h, min_x - offset * h );
905 RealPoint p2( max_x + offset * h, max_x + offset * h, max_x + offset * h );
907 dshape->attach( shape );
908 dshape->init( p1, p2, h );
911 auto it = fimage->begin();
914 float val = (float) (*shape)( p );
942 ( std::string input )
970 RealPoint p1( min_x - offset * h, min_x - offset * h, min_x - offset * h );
971 RealPoint p2( max_x + offset * h, max_x + offset * h, max_x + offset * h );
973 dshape->attach( shape );
974 dshape->init( p1, p2, h );
977 auto it = fimage->begin();
980 double val = (double) (*shape)( p );
998 (
"surfelAdjacency", 0 )
999 (
"nbTriesToFindABel", 100000 )
1000 (
"surfaceComponents",
"AnyBig" )
1001 (
"surfaceTraversal",
"Default" );
1007 template <
typename TDigitalSurfaceContainer>
1018 template <
typename TDigitalSurfaceContainer>
1029 template <
typename TDigitalSurfaceContainer>
1040 template <
typename TDigitalSurfaceContainer>
1065 bool surfel_adjacency = params[
"surfelAdjacency" ].as<
int>();
1066 int nb_tries_to_find_a_bel = params[
"nbTriesToFindABel" ].as<
int>();
1072 Scalar minsize = bimage->extent().norm();
1073 unsigned int nb_surfels = 0;
1074 unsigned int tries = 0;
1080 trace.
error() <<
"[Shortcuts::makeLightDigitalSurface]"
1081 <<
" ERROR Unable to find bel. " << e << std::endl;
1089 nb_surfels = ptrSurface->size();
1091 while ( ( nb_surfels < 2 * minsize ) && ( tries++ < 150 ) );
1093 trace.
warning() <<
"[Shortcuts::makeLightDigitalSurface]"
1094 <<
"ERROR cannot find a proper bel in a big enough component."
1116 static std::vector< CountedPtr<LightDigitalSurface> >
1146 static std::vector< CountedPtr<LightDigitalSurface> >
1153 std::vector< CountedPtr<LightDigitalSurface> > result;
1154 std::string component = params[
"surfaceComponents" ].as<std::string>();
1155 if ( component ==
"AnyBig" )
1158 surfel_reps.push_back( *( result[ 0 ]->begin() ) );
1161 bool surfel_adjacency = params[
"surfelAdjacency" ].as<
int>();
1166 K.lowerBound(),
K.upperBound() );
1170 for (
auto bel : all_surfels )
1172 if ( marked_surfels.count( bel ) != 0 )
continue;
1173 surfel_reps.push_back( bel );
1179 marked_surfels.insert( ptrSurface->begin(), ptrSurface->end() );
1181 result.push_back( ptrSurface );
1205 template <
typename TPo
intPredicate>
1213 bool surfel_adjacency = params[
"surfelAdjacency" ].as<
int>();
1217 K.lowerBound(),
K.upperBound() );
1242 bool surfel_adjacency = params[
"surfelAdjacency" ].as<
int>();
1245 auto all_idx_surfels
1247 auto idx2surfel = idx_surface->surfels();
1249 for (
auto idx : all_idx_surfels ) all_surfels.insert( idx2surfel[ idx ] );
1278 std::string component = params[
"surfaceComponents" ].as<std::string>();
1280 if ( component ==
"AnyBig" )
1283 surfels.insert( light_surface->begin(), light_surface->end() );
1285 else if ( component ==
"All" )
1288 K.lowerBound(),
K.upperBound() );
1304 template <
typename TSurfelRange>
1307 (
const TSurfelRange& surfels,
1311 bool surfel_adjacency = params[
"surfelAdjacency" ].as<
int>();
1318 bool ok = ptrSurface->build( ptrSurfContainer );
1320 trace.
warning() <<
"[Shortcuts::makeIdxDigitalSurface]"
1321 <<
" Error building indexed digital surface." << std::endl;
1337 template <
typename TDigitalSurfaceContainer>
1345 surfels.insert( surface->begin(), surface->end() );
1367 const KSpace&
K = surfaces[ 0 ]->container().space();
1369 for ( std::size_t i = 0; i < surfaces.size(); ++i )
1371 const KSpace& Ki = surfaces[ i ]->container().space();
1372 if ( ( Ki.lowerBound() !=
K.lowerBound() )
1373 || ( Ki.upperBound() !=
K.upperBound() ) )
1374 trace.
warning() <<
"[Shortcuts::makeIdxDigitalSurface]"
1375 <<
" Incompatible digital spaces for surface " << i << std::endl;
1376 surfels.insert( surfaces[ i ]->begin(), surfaces[ i ]->end() );
1395 template <
typename TDigitalSurfaceContainer>
1404 result.reserve( 2 * surface->size() + 100 );
1407 for (
auto&& surfel : *surface )
1410 for (
auto&& primal_cell : primal_cells )
1412 if ( ! c2i.count( primal_cell ) )
1414 result.push_back( primal_cell );
1415 c2i[ primal_cell ] = n++;
1434 template <
typename TDigitalSurfaceContainer>
1465 template <
typename TDigitalSurfaceContainer>
1472 result.reserve( surface->size() );
1475 for (
auto&& surfel : *surface )
1478 for (
auto&& primal_vtx : primal_vtcs )
1480 if ( ! c2i.count( primal_vtx ) )
1482 result.push_back( primal_vtx );
1483 c2i[ primal_vtx ] = n++;
1506 template <
typename TDigitalSurfaceContainer>
1527 return KSpace::dimension == 3
1543 template <
typename TDigitalSurfaceContainer>
1566 template <
typename TDigitalSurfaceContainer>
1570 const Surfel& start_surfel,
1573 typedef ::DGtal::DigitalSurface<TDigitalSurfaceContainer> AnyDigitalSurface;
1575 std::string traversal = params[
"surfaceTraversal" ].as<std::string>();
1576 if ( traversal ==
"DepthFirst" )
1580 VisitorRange range(
new Visitor( *surface, start_surfel ) );
1581 std::for_each( range.begin(), range.end(),
1582 [&result] (
Surfel s ) { result.push_back( s ); } );
1584 else if ( traversal ==
"BreadthFirst" )
1588 VisitorRange range(
new Visitor( *surface, start_surfel ) );
1589 std::for_each( range.begin(), range.end(),
1590 [&result] (
Surfel s ) { result.push_back( s ); } );
1594 std::for_each( surface->begin(), surface->end(),
1595 [&result] (
Surfel s ) { result.push_back( s ); } );
1636 std::string traversal = params[
"surfaceTraversal" ].as<std::string>();
1637 if ( traversal ==
"DepthFirst" )
1641 VisitorRange range(
new Visitor( *surface, start_surfel ) );
1642 std::for_each( range.begin(), range.end(),
1643 [&result] (
IdxSurfel s ) { result.push_back( s ); } );
1645 else if ( traversal ==
"BreadthFirst" )
1649 VisitorRange range(
new Visitor( *surface, start_surfel ) );
1650 std::for_each( range.begin(), range.end(),
1651 [&result] (
IdxSurfel s ) { result.push_back( s ); } );
1653 else return surface->allVertices();
1668 template <
typename TDigitalSurfaceContainer,
1669 typename TCellEmbedder>
1673 const TCellEmbedder& embedder,
1674 std::string off_file,
1678 BOOST_STATIC_ASSERT (( KSpace::dimension == 3 ));
1680 std::ofstream output_off( off_file.c_str() );
1681 output_off <<
"OFF" << std::endl;
1682 output_off <<
"# Generated from DGtal::Shortcuts from the DGTal library" << std::endl;
1685 output_off << pointels.size() <<
" " << digsurf->size() <<
" " << 0 <<
" " << std::endl;
1690 for (
auto&& pointel : pointels )
1693 output_off << p[ 0 ] <<
" " << p[ 1 ] <<
" " << p[ 2 ] << std::endl;
1697 for (
auto&& surfel : *digsurf )
1700 output_off << primal_vtcs.size();
1702 for (
auto&& primal_vtx : primal_vtcs )
1703 output_off <<
" " << (c2i[ primal_vtx ]);
1708 output_off << face_color.r() <<
" " << face_color.g()
1709 <<
" " << face_color.b() <<
" " << face_color.a();
1711 output_off << std::endl;
1713 return output_off.good();
1734 template <
typename TDigitalSurfaceContainer,
1735 typename TCellEmbedder>
1739 const TCellEmbedder& embedder,
1741 const Colors& diffuse_colors,
1742 std::string objfile,
1743 const Color& ambient_color =
Color( 32, 32, 32 ),
1744 const Color& diffuse_color =
Color( 200, 200, 255 ),
1747 BOOST_STATIC_ASSERT (( KSpace::dimension == 3 ));
1748 std::string mtlfile;
1749 auto lastindex = objfile.find_last_of(
".");
1750 if ( lastindex == std::string::npos )
1752 mtlfile = objfile +
".mtl";
1753 objfile = objfile +
".obj";
1757 mtlfile = objfile.substr(0, lastindex) +
".mtl";
1760 std::ofstream output_obj( objfile.c_str() );
1761 output_obj <<
"# OBJ format" << std::endl;
1762 output_obj <<
"# DGtal::MeshHelpers::exportOBJwithFaceNormalAndColor" << std::endl;
1763 output_obj <<
"o anObject" << std::endl;
1765 auto indexpath = objfile.find_last_of(
"/");
1766 output_obj <<
"mtllib " << mtlfile.substr(indexpath+1) << std::endl;
1767 std::ofstream output_mtl( mtlfile.c_str() );
1768 output_mtl <<
"# MTL format"<< std::endl;
1769 output_mtl <<
"# generated from MeshWriter from the DGTal library"<< std::endl;
1774 for (
auto&& pointel : pointels )
1777 output_obj <<
"v " << p[ 0 ] <<
" " << p[ 1 ] <<
" " << p[ 2 ] << std::endl;
1780 Idx nbfaces = digsurf->size();
1781 bool has_normals = ( nbfaces == normals.size() );
1784 for (
Idx f = 0; f < nbfaces; ++f )
1786 const auto& p = normals[ f ];
1787 output_obj <<
"vn " << p[ 0 ] <<
" " << p[ 1 ] <<
" " << p[ 2 ] << std::endl;
1791 bool has_material = ( nbfaces == diffuse_colors.size() );
1792 Idx idxMaterial = 0;
1793 std::map<Color, unsigned int > mapMaterial;
1796 for (
Idx f = 0; f < nbfaces; ++f )
1798 Color c = diffuse_colors[ f ];
1799 if ( mapMaterial.count( c ) == 0 )
1802 ( output_mtl, idxMaterial, ambient_color, c, specular_color );
1803 mapMaterial[ c ] = idxMaterial++;
1810 ( output_mtl, idxMaterial, ambient_color, diffuse_color, specular_color );
1815 for (
auto&& surfel : *digsurf )
1817 output_obj <<
"usemtl material_"
1818 << ( has_material ? mapMaterial[ diffuse_colors[ f ] ] : idxMaterial )
1825 for (
auto&& primal_vtx : primal_vtcs )
1826 output_obj <<
" " << (c2i[ primal_vtx ]+1) <<
"//" << (f+1);
1830 for (
auto&& primal_vtx : primal_vtcs )
1831 output_obj <<
" " << (c2i[ primal_vtx ]+1);
1833 output_obj << std::endl;
1837 return output_obj.good();
1855 template <
typename TDigitalSurfaceContainer>
1860 const Colors& diffuse_colors,
1861 std::string objfile,
1862 const Color& ambient_color =
Color( 32, 32, 32 ),
1863 const Color& diffuse_color =
Color( 200, 200, 255 ),
1867 return saveOBJ( digsurf, embedder, normals, diffuse_colors, objfile,
1868 ambient_color, diffuse_color, specular_color );
1884 template <
typename TDigitalSurfaceContainer>
1888 std::string off_file,
1889 const Color& face_color =
Color( 32, 32, 32 ))
1892 return saveOFF( digsurf, embedder, off_file, face_color);
1906 template <
typename TDigitalSurfaceContainer>
1910 std::string objfile,
1911 const Color& ambient_color =
Color( 32, 32, 32 ),
1912 const Color& diffuse_color =
Color( 200, 200, 255 ),
1917 ambient_color, diffuse_color, specular_color );
1941 const Colors& diffuse_colors,
1942 std::string objfile,
1943 const Color& ambient_color =
Color( 32, 32, 32 ),
1944 const Color& diffuse_color =
Color( 200, 200, 255 ),
1947 BOOST_STATIC_ASSERT (( KSpace::dimension == 3 ));
1948 std::string mtlfile;
1949 auto lastindex = objfile.find_last_of(
".");
1950 if ( lastindex == std::string::npos )
1952 mtlfile = objfile +
".mtl";
1953 objfile = objfile +
".obj";
1957 mtlfile = objfile.substr(0, lastindex) +
".mtl";
1959 std::ofstream output_obj( objfile.c_str() );
1960 output_obj <<
"# OBJ format" << std::endl;
1961 output_obj <<
"# DGtal::saveOBJ" << std::endl;
1962 output_obj <<
"o vectors" << std::endl;
1963 output_obj <<
"mtllib " << mtlfile << std::endl;
1964 std::ofstream output_mtl( mtlfile.c_str() );
1965 output_mtl <<
"# MTL format"<< std::endl;
1966 output_mtl <<
"# generated from MeshWriter from the DGTal library"<< std::endl;
1968 unsigned int n = std::min( positions.size(), vf.size() );
1969 for (
unsigned int i = 0; i < n; ++i )
1975 unsigned int mc = std::max_element( absv.
begin(), absv.
end() ) - absv.
begin();
1981 RealPoint t[4] = { thickness * e0, thickness * e1,
1982 -thickness * e0, -thickness * e1 };
1983 for (
unsigned int j = 0; j < 4; ++j ) {
1986 output_obj <<
"v " << pt0[ 0 ] <<
" " << pt0[ 1 ] <<
" " << pt0[ 2 ]
1988 output_obj <<
"v " << pt1[ 0 ] <<
" " << pt1[ 1 ] <<
" " << pt1[ 2 ]
1993 std::map<Color,Idx> map_colors;
1996 for (
auto && c : diffuse_colors )
1997 if ( ! map_colors.count( c ) )
1998 map_colors[ c ] = j++;
2002 bool has_material = ! diffuse_colors.empty();
2004 for (
auto&& pair : map_colors )
2006 ( output_mtl, pair.second, ambient_color, pair.first, specular_color);
2009 ( output_mtl, 0, ambient_color, diffuse_color, specular_color );
2011 for (
Idx i = 0; i < n; ++i )
2013 output_obj <<
"usemtl material_"
2014 << ( has_material ? map_colors[ diffuse_colors[ i ] ] : 0 )
2017 for (
Idx j = 0; j < 8; j += 2 )
2018 output_obj <<
"f " << (b+j) <<
" " << (b+j+1)
2019 <<
" " << (b+(j+3)%8) <<
" " << (b+(j+2)%8) << std::endl;
2020 output_obj <<
"f " << b <<
" " << (b+2)
2021 <<
" " << (b+4) <<
" " << (b+6) << std::endl;
2022 output_obj <<
"f " << (b+1) <<
" " << (b+7)
2023 <<
" " << (b+5) <<
" " << (b+3) << std::endl;
2026 return output_obj.good();
2038 (
"faceSubdivision",
"Centroid" );
2101 template <
typename TContainer >
2110 ( *aSurface, embedder, *pTriSurf, s2i );
2119 template <
typename TContainer >
2148 std::string faceSubdivision = params[
"faceSubdivision" ].as<std::string>();
2149 bool centroid = ( faceSubdivision ==
"Centroid" );
2196 RealVector gh = { params[
"gridsizex" ].as<
double>(),
2197 params[
"gridsizey" ].as<double>(),
2198 params[
"gridsizez" ].as<
double>() };
2199 double threshold = params[
"thresholdMin" ].as<
double>() + 0.5;
2203 PointEmbedder pembedder;
2204 pembedder.init( gh );
2205 ImageCellEmbedder cembedder;
2206 cembedder.init(
K, *gray_scale_image, pembedder, threshold );
2211 ( *digSurf, cembedder, *pPolySurf, s2i );
2239 RealVector gh = { params[
"gridsizex" ].as<
double>(),
2240 params[
"gridsizey" ].as<double>(),
2241 params[
"gridsizez" ].as<
double>() };
2242 double threshold = params[
"thresholdMin" ].as<
double>() + 0.5;
2246 PointEmbedder pembedder;
2247 pembedder.init( gh );
2248 ImageCellEmbedder cembedder;
2249 cembedder.init(
K, *gray_scale_image, pembedder, threshold );
2254 ( *digSurf, cembedder, *pPolySurf, s2i );
2265 template <
typename TContainer >
2270 BOOST_STATIC_ASSERT (( KSpace::dimension == 3 ));
2275 ( *aSurface, embedder, *pPolySurf, s2i );
2285 template <
typename TContainer >
2299 template <
typename TContainer >
2304 BOOST_STATIC_ASSERT (( KSpace::dimension == 3 ));
2307 aSurface->positions().storage() ) );
2318 template <
typename TContainer >
2323 BOOST_STATIC_ASSERT (( KSpace::dimension == 3 ));
2328 ( *aSurface, embedder, *pPolySurf, c2i );
2338 template <
typename TContainer >
2352 template <
typename TContainer >
2368 template <
typename TPo
int>
2372 const std::string& objfile )
2374 std::ofstream output( objfile.c_str() );
2388 template <
typename TPo
int>
2391 std::string off_file,
2397 std::ofstream output( off_file.c_str() );
2398 for (
unsigned int i=0; i< m.nbFaces(); i++)
2400 m.setFaceColor(i, face_color);
2413 template <
typename TPo
int>
2417 const std::string& objfile )
2419 std::ofstream output( objfile.c_str() );
2437 template <
typename TPo
int>
2442 const Colors& diffuse_colors,
2443 std::string objfile,
2444 const Color& ambient_color =
Color( 32, 32, 32 ),
2445 const Color& diffuse_color =
Color( 200, 200, 255 ),
2448 std::string mtlfile;
2449 auto lastindex = objfile.find_last_of(
".");
2450 if ( lastindex == std::string::npos )
2452 mtlfile = objfile +
".mtl";
2453 objfile = objfile +
".obj";
2457 mtlfile = objfile.substr(0, lastindex) +
".mtl";
2459 std::ofstream output( objfile.c_str() );
2461 ( output, mtlfile, *polysurf, normals, diffuse_colors,
2462 ambient_color, diffuse_color, specular_color );
2479 template <
typename TPo
int>
2484 const Colors& diffuse_colors,
2485 std::string objfile,
2486 const Color& ambient_color =
Color( 32, 32, 32 ),
2487 const Color& diffuse_color =
Color( 200, 200, 255 ),
2490 std::string mtlfile;
2491 auto lastindex = objfile.find_last_of(
".");
2492 if ( lastindex == std::string::npos )
2494 mtlfile = objfile +
".mtl";
2495 objfile = objfile +
".obj";
2499 mtlfile = objfile.substr(0, lastindex) +
".mtl";
2501 std::ofstream output( objfile.c_str() );
2503 ( output, mtlfile, *trisurf, normals, diffuse_colors,
2504 ambient_color, diffuse_color, specular_color );
2517 template <
typename TPo
int>
2520 std::string off_file,
2526 std::ofstream output( off_file.c_str() );
2527 for (
unsigned int i=0; i< m.nbFaces(); i++)
2529 m.setFaceColor(i, face_color);
2547 (
"colormap",
"Custom" )
2548 (
"zero-tic", 0.0 );
2567 template <
typename TValue>
2569 getRangeMatch(
const std::vector< TValue >& s1,
const std::vector< TValue >& s2,
2570 bool perfect =
false )
2572 if ( perfect && ( s1.size() != s2.size() ) )
return IdxRange();
2573 std::map<TValue, Idx> M;
2575 for (
auto val : s2 ) M[ val ] = idx++;
2578 for (
auto val : s1 )
2580 auto it = M.find( val );
2581 if ( it != M.end() ) V[ idx++ ] = it->second;
2585 V[ idx++ ] = s2.size();
2602 template <
typename TValue>
2603 static std::vector< TValue >
2606 std::vector< TValue > result( match.size() );
2607 for (
Idx i = 0; i < result.size(); i++ )
2608 result[ i ] = range[ match[ i ] ];
2623 std::string cmap = params[
"colormap" ].as<std::string>();
2632 else if ( cmap ==
"Error" )
2662 auto ztic = params[
"zero-tic" ].as<
double>();
2664 if ( ztic <= 0.0 )
return ztic_cmap;
2665 if ( min <= 0.0 && 0.0 <=
max )
2666 ztic_cmap.addTick( 0.0, ztic );
2667 ztic_cmap.finalize();
2680 template <
typename TCellEmbedder = CanonicCellEmbedder< KSpace > >
2683 ( std::ostream& output,
2685 const TCellEmbedder& embedder )
2687 typedef unsigned long Size;
2688 BOOST_STATIC_ASSERT (( KSpace::dimension == 3 ));
2690 const KSpace&
K = embedder.space();
2692 std::map< Cell, Size > vtx_numbering;
2694 for (
auto&& s : surfels )
2697 for (
auto&& primal_vtx : primal_vtcs )
2699 if ( ! vtx_numbering.count( primal_vtx ) )
2701 vtx_numbering[ primal_vtx ] = n++;
2704 output <<
"v " << p[ 0 ] <<
" " << p[ 1 ] <<
" " << p[ 2 ] << std::endl;
2709 for (
auto&& s : surfels )
2713 for (
auto&& primal_vtx : primal_vtcs )
2714 output <<
" " << vtx_numbering[ primal_vtx ];
2715 output << std::endl;
2717 return output.good();
2731 template <
typename TAnyDigitalSurface>
2734 ( std::ostream& output,
2758 template <
typename TAnyDigitalSurface,
2762 ( std::ostream& output,
2764 const TCellEmbedder& embedder )
2780 ( std::ostream& output,
2800 template <
typename TCellEmbedder = CanonicCellEmbedder< KSpace > >
2803 ( std::ostream& output,
2805 const TCellEmbedder& embedder )
2808 auto surfelmap = surface->surfels();
2810 for (
auto&& idx : idxsurfels )
2811 surfels.push_back( surfelmap[ idx ] );
2831 template <
typename TDigitalSurfaceContainer>
2834 ( std::ostream& output,
2864 template <
typename TDigitalSurfaceContainer,
2868 ( std::ostream& output,
2870 const TCellEmbedder& embedder,
2873 typedef unsigned long Size;
2874 BOOST_STATIC_ASSERT (( KSpace::dimension == 3 ));
2876 std::string dualFaceSubdivision = params[
"faceSubdivision" ].as<std::string>();
2878 = dualFaceSubdivision ==
"Naive" ? 1
2879 : dualFaceSubdivision ==
"Centroid" ? 2
2881 const KSpace&
K = embedder.space();
2883 std::map< Vertex, Size > vtx_numbering;
2884 std::map< Face, Size > sub_numbering;
2886 for (
auto && s : *surface )
2888 if ( ! vtx_numbering.count( s ) )
2890 vtx_numbering[ s ] = n++;
2893 output <<
"v " << p[ 0 ] <<
" " << p[ 1 ] <<
" " << p[ 2 ] << std::endl;
2896 auto faces = surface->allClosedFaces();
2898 if ( subdivide == 2 )
2900 for (
auto&& f : faces )
2902 auto vtcs = surface->verticesAroundFace( f );
2903 Size nv = vtcs.size();
2906 sub_numbering[ f ] = n++;
2908 for (
auto&& s : vtcs ) p += embedder(
K.unsigns( s ) );
2910 output <<
"v " << p[ 0 ] <<
" " << p[ 1 ] <<
" " << p[ 2 ] << std::endl;
2915 if ( subdivide == 0 )
2917 for (
auto&& f : faces )
2920 auto vtcs = surface->verticesAroundFace( f );
2922 for (
auto&& s : vtcs )
2923 output <<
" " << vtx_numbering[ s ];
2924 output << std::endl;
2927 else if ( subdivide == 1 )
2929 for (
auto&& f : faces )
2931 auto vtcs = surface->verticesAroundFace( f );
2932 Size nv = vtcs.size();
2933 for (
Size i = 1; i < nv - 1; ++i )
2934 output <<
"f " << vtx_numbering[ vtcs[ 0 ] ]
2935 <<
" " << vtx_numbering[ vtcs[ i+1 ] ]
2936 <<
" " << vtx_numbering[ vtcs[ i ] ] << std::endl;
2939 else if ( subdivide == 2 )
2941 for (
auto&& f : faces )
2943 auto vtcs = surface->verticesAroundFace( f );
2944 Size nv = vtcs.size();
2946 output <<
"f " << vtx_numbering[ vtcs[ 0 ] ]
2947 <<
" " << vtx_numbering[ vtcs[ 2 ] ]
2948 <<
" " << vtx_numbering[ vtcs[ 1 ] ] << std::endl;
2950 Size c = sub_numbering[ f ];
2951 for (
Size i = 0; i < nv; ++i )
2954 <<
" " << vtx_numbering[ vtcs[ (i+1)%nv ] ]
2955 <<
" " << vtx_numbering[ vtcs[ i ] ] << std::endl;
2960 return output.good();
2969 for (
Dimension d = 0; d < KSpace::dimension; ++d )
2970 output <<
" " <<
K.sKCoord( cell, d );
2977 for (
Dimension d = 0; d < KSpace::dimension; ++d )
2979 return K.uCell( kp );
2986 output <<
" " <<
K.sSign( scell );
2994 for (
Dimension d = 0; d < KSpace::dimension; ++d )
2997 return K.sCell( kp, s );
3001 template <
typename Value>
3007 void operator()( std::ostream& output,
const std::vector<Value>& vv )
3009 for (
auto&& v : vv ) output <<
" " << v;
3013 template <
typename Value>
3018 std::getline( input, str );
3020 std::stringstream strstr(str);
3022 std::istream_iterator<std::string> it(strstr);
3023 std::istream_iterator<std::string> end;
3024 std::vector<std::string> results(it, end);
3025 std::stringstream sstr( results[ 0 ] );
3027 return ( results.size() == 1 ) && input.good();
3030 bool operator()( std::istream& input, std::vector<Value>& values )
3033 std::getline( input, str );
3035 std::stringstream strstr(str);
3037 std::istream_iterator<std::string> it(strstr);
3038 std::istream_iterator<std::string> end;
3039 std::vector<std::string> results(it, end);
3040 values.resize( results.size() );
3041 for (
unsigned int i = 0; i < results.size(); ++i ) {
3042 std::stringstream sstr( results[ i ] );
3043 sstr >> values[ i ];
3045 return input.good();
3061 template <
typename TSCellMap,
typename TValueWriter>
3064 ( std::ostream& output,
3066 const TSCellMap& anyMap,
3067 const TValueWriter& writer )
3070 for (
auto&& v : anyMap )
3072 w( output,
K, v.first );
3073 writer( output, v.second );
3074 output << std::endl;
3076 return output.good();
3091 template <
typename TCellMap,
typename TValueWriter>
3094 ( std::ostream& output,
3096 const TCellMap& anyMap,
3097 const TValueWriter& writer )
3100 for (
auto&& v : anyMap )
3102 w( output,
K, v.first );
3103 writer( output, v.second );
3104 output << std::endl;
3106 return output.good();
3117 auto faces =
K.uFaces(
K.unsigns( s ) );
3119 for (
auto&& f : faces )
3121 if (
K.uDim( f ) == k ) primal_cells.push_back( f );
3123 return primal_cells;
3145 BOOST_STATIC_ASSERT(( KSpace::dimension == 3 ));
3147 std::swap( vtcs[ 2 ], vtcs[ 3 ] );
3148 auto orth_dir =
K.sOrthDir( s );
3149 auto direct =
K.sDirect( s, orth_dir ) ? ccw : ! ccw;
3150 Vector s0s1 =
K.uCoords( vtcs[ 1 ] ) -
K.uCoords( vtcs[ 0 ] );
3151 Vector s0s2 =
K.uCoords( vtcs[ 2 ] ) -
K.uCoords( vtcs[ 0 ] );
3153 if ( ( ( t[ orth_dir ] > 0.0 ) && direct )
3154 || ( ( t[ orth_dir ] < 0.0 ) && ! direct ) )
3208 out <<
"[Shortcuts]";
3241 template <
typename T>
3256 #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.
const ConstIterator & end() const
const ConstIterator & begin() const
const Point & lowerBound() const
const Point & upperBound() 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).
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.
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 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 int 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 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()
static CanonicSCellEmbedder< KSpace > getSCellEmbedder(const KSpace &K)
GradientColorMap< Scalar > ColorMap
ImageContainerBySTLVector< Domain, bool > BinaryImage
defines a black and white image with (hyper-)rectangular domain.
static CountedPtr< GrayScaleImage > makeGrayScaleImage(CountedPtr< DoubleImage > fimage, Parameters params=parametersGrayScaleImage())
static std::vector< CountedPtr< LightDigitalSurface > > makeLightDigitalSurfaces(CountedPtr< BinaryImage > bimage, const KSpace &K, const Parameters ¶ms=parametersDigitalSurface())
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< ImplicitShape3D > makeImplicitShape3D(const Parameters ¶ms=parametersImplicitShape3D())
static CountedPtr< GrayScaleImage > makeGrayScaleImage(CountedPtr< FloatImage > fimage, Parameters params=parametersGrayScaleImage())
LightDigitalSurface::ArcRange ArcRange
static KSpace getKSpace(CountedPtr< BinaryImage > bimage, Parameters params=parametersKSpace())
static std::map< std::string, std::string > getPolynomialList()
static CountedPtr< FloatImage > makeFloatImage(Domain aDomain)
static Parameters parametersImplicitShape3D()
static Parameters parametersKSpace()
static CountedPtr< TriangulatedSurface > makeTriangulatedSurface(CountedPtr< ::DGtal::DigitalSurface< TContainer > > aSurface)
static CountedPtr< BinaryImage > makeBinaryImage(Domain shapeDomain)
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 CountedPtr< GrayScaleImage > makeGrayScaleImage(Domain aDomain)
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)
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)
static const KSpace & refKSpace(CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > surface)
static CountedPtr< DoubleImage > makeDoubleImage(CountedPtr< ImplicitShape3D > shape, Parameters params=parametersDigitizedImplicitShape3D())
Shortcuts(Shortcuts &&other)=delete
static CanonicCellEmbedder< KSpace > getCellEmbedder(CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > surface)
static CanonicSCellEmbedder< KSpace > getSCellEmbedder(CountedPtr< ::DGtal::IndexedDigitalSurface< TDigitalSurfaceContainer > > surface)
static CountedPtr< DigitizedImplicitShape3D > makeDigitizedImplicitShape3D(CountedPtr< ImplicitShape3D > shape, Parameters params=parametersDigitizedImplicitShape3D())
static CanonicSCellEmbedder< KSpace > getSCellEmbedder(CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > surface)
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
static CountedPtr< BinaryImage > makeBinaryImage(CountedPtr< DigitizedImplicitShape3D > shape_digitization, Parameters params=parametersBinaryImage())
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)
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 bool saveOBJ(CountedPtr< ::DGtal::TriangulatedSurface< TPoint > > trisurf, const std::string &objfile)
static CountedPtr< BinaryImage > makeBinaryImage(CountedPtr< BinaryImage > bimage, Parameters params=parametersBinaryImage())
static Parameters parametersDigitalSurface()
ImplicitPolynomial3Shape< Space > ImplicitShape3D
Space::Integer Integer
Integer numbers.
static KSpace getKSpace(CountedPtr< ::DGtal::IndexedDigitalSurface< TDigitalSurfaceContainer > > surface)
LightDigitalSurface::Face Face
::DGtal::Mesh< RealPoint > Mesh
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)
MPolynomial< Space::dimension, Scalar > ScalarPolynomial
defines a multi-variate polynomial : RealPoint -> Scalar
static CountedPtr< IdxDigitalSurface > makeIdxDigitalSurface(CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > surface, 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;})
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< FloatImage > makeFloatImage(CountedPtr< ImplicitShape3D > shape, Parameters params=parametersDigitizedImplicitShape3D())
static CountedPtr< PolygonalSurface > makePrimalPolygonalSurface(CountedPtr< ::DGtal::IndexedDigitalSurface< TContainer > > aSurface)
static CountedPtr< Mesh > makeMesh(CountedPtr< PolygonalSurface > polySurf, const Color &aColor=Color::White)
static CountedPtr< DigitalSurface > makeDigitalSurface(CountedPtr< TPointPredicate > bimage, const KSpace &K, const Parameters ¶ms=parametersDigitalSurface())
std::vector< Cell > CellRange
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)
static CountedPtr< BinaryImage > makeBinaryImage(std::string input, Parameters params=parametersBinaryImage())
ImageContainerBySTLVector< Domain, GrayScale > GrayScaleImage
defines a grey-level image with (hyper-)rectangular domain.
Shortcuts & operator=(const Shortcuts &other)=delete
::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< IdxDigitalSurface > makeIdxDigitalSurface(const TSurfelRange &surfels, ConstAlias< KSpace > K, const Parameters ¶ms=parametersDigitalSurface())
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
IndexedDigitalSurface< ExplicitSurfaceContainer > IdxDigitalSurface
defines a connected or not indexed digital surface.
std::vector< SCell > SCellRange
static CanonicCellEmbedder< KSpace > getCellEmbedder(CountedPtr< ::DGtal::IndexedDigitalSurface< TDigitalSurfaceContainer > > surface)
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
Shortcuts(const Shortcuts &other)=delete
BOOST_CONCEPT_ASSERT((concepts::CCellularGridSpaceND< TKSpace >))
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< IdxDigitalSurface > makeIdxDigitalSurface(CountedPtr< BinaryImage > bimage, const KSpace &K, const Parameters ¶ms=parametersDigitalSurface())
IdxDigitalSurface::Arc IdxArc
static Parameters defaultParameters()
static CountedPtr< DoubleImage > makeDoubleImage(std::string input)
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 CountedPtr< LightDigitalSurface > makeLightDigitalSurface(CountedPtr< BinaryImage > bimage, const KSpace &K, const Parameters ¶ms=parametersDigitalSurface())
static Parameters parametersDigitizedImplicitShape3D()
LightDigitalSurface::Arc Arc
ImageContainerBySTLVector< Domain, double > DoubleImage
defines a double image with (hyper-)rectangular domain.
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 const KSpace & refKSpace(CountedPtr< ::DGtal::IndexedDigitalSurface< TDigitalSurfaceContainer > > surface)
static CountedPtr< TriangulatedSurface > makeTriangulatedSurface(Surfel2Index &s2i, CountedPtr< ::DGtal::DigitalSurface< TContainer > > aSurface)
static CountedPtr< PolygonalSurface > makeDualPolygonalSurface(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 CountedPtr< FloatImage > makeFloatImage(std::string input)
static CanonicCellEmbedder< KSpace > getCellEmbedder(const KSpace &K)
static PointelRange getPointelRange(CountedPtr< ::DGtal::DigitalSurface< 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 CountedPtr< IdxDigitalSurface > makeIdxDigitalSurface(const std::vector< CountedPtr< LightDigitalSurface > > &surfaces, 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)
static CountedPtr< BinaryImage > makeBinaryImage(CountedPtr< DigitizedImplicitShape3D > shape_digitization, Domain shapeDomain, Parameters params=parametersBinaryImage())
static CountedPtr< BinaryImage > makeBinaryImage(CountedPtr< GrayScaleImage > gray_scale_image, Parameters params=parametersBinaryImage())
TKSpace KSpace
Digital cellular space.
LightDigitalSurface::SCell SCell
static IdxSurfelRange getIdxSurfelRange(CountedPtr< IdxDigitalSurface > surface, const Parameters ¶ms=parametersDigitalSurface())
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 std::vector< CountedPtr< LightDigitalSurface > > makeLightDigitalSurfaces(SurfelRange &surfel_reps, CountedPtr< BinaryImage > bimage, const KSpace &K, const Parameters ¶ms=parametersDigitalSurface())
static CountedPtr< DoubleImage > makeDoubleImage(Domain aDomain)
static CountedPtr< PolygonalSurface > makePrimalPolygonalSurface(CountedPtr< ::DGtal::DigitalSurface< TContainer > > aSurface)
static CountedPtr< GrayScaleImage > makeGrayScaleImage(std::string input)
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.
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...
static TContainer import(const std::string &filename, std::vector< unsigned int > dimSpace=std::vector< unsigned int >())
static bool exportFile(const std::string &filename, const TContainer &anImage, const TFunctor &aFunctor=TFunctor())
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: 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