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/readers/SurfaceMeshReader.h"
81#include "DGtal/io/writers/GenericWriter.h"
82#include "DGtal/io/writers/MeshWriter.h"
83#include "DGtal/graph/BreadthFirstVisitor.h"
84#include "DGtal/graph/DepthFirstVisitor.h"
85#include "DGtal/graph/GraphVisitorRange.h"
86#include "DGtal/helpers/Parameters.h"
104 template <
typename TKSpace >
166 typedef typename LightDigitalSurface::Arc
Arc;
167 typedef typename LightDigitalSurface::Face
Face;
185 typedef ::DGtal::Mesh<RealPoint>
Mesh;
236 static std::map< std::string, std::string >
239 std::vector< std::pair< std::string, std::string > >
240 Ps = { {
"sphere1",
"x^2+y^2+z^2-1" },
241 {
"sphere9",
"x^2+y^2+z^2-81" },
242 {
"ellipsoid",
"3*x^2+2*y^2+z^2-90" },
243 {
"cylinder",
"x^2+2*z^2-90" },
244 {
"torus",
"(x^2+y^2+z^2+6*6-2*2)^2-4*6*6*(x^2+y^2)" },
245 {
"rcube",
"x^4+y^4+z^4-6561" },
246 {
"goursat",
"-1*(8-0.03*x^4-0.03*y^4-0.03*z^4+2*x^2+2*y^2+2*z^2)" },
247 {
"goursat-hole",
"x^4+y^4+z^4-2*4*(x^2+y^2+z^2)+2*4*4-2" },
248 {
"distel",
"10000-(x^2+y^2+z^2+1000*(x^2+y^2)*(x^2+z^2)*(y^2+z^2))"},
249 {
"leopold",
"(x^2*y^2*z^2+4*x^2+4*y^2+3*z^2)-100" },
250 {
"diabolo",
"x^2-(y^2+z^2)^2" },
251 {
"heart",
"-1*(x^2+2.25*y^2+z^2-1)^3+x^2*z^3+0.1125*y^2*z^3" },
252 {
"crixxi",
"-0.9*(y^2+z^2-1)^2-(x^2+y^2-1)^3" } };
253 std::map< std::string, std::string >
L;
255 L[ p.first ] = p.second;
269 (
"polynomial",
"sphere1" )
270 (
"projectionMaxIter", 20 )
271 (
"projectionAccuracy", 0.0001 )
272 (
"projectionGamma", 0.5 );
286 std::string poly_str = params[
"polynomial" ].as<std::string>();
289 if ( PL[ poly_str ] !=
"" ) poly_str = PL[ poly_str ];
292 std::string::const_iterator iter
293 = reader.
read( poly, poly_str.begin(), poly_str.end() );
294 if ( iter != poly_str.end() )
296 trace.error() <<
"[Shortcuts::makeImplicitShape3D]"
297 <<
" ERROR reading polynomial: I read only <"
298 << poly_str.substr( 0, iter - poly_str.begin() )
299 <<
">, and I built P=" << poly << std::endl;
318 (
"gridsizez", 1.0 );
336 int closed = params[
"closed" ].as<
int>();
338 if ( !
K.init( low, up, closed ) )
339 trace.error() <<
"[Shortcuts::getKSpace]"
340 <<
" Error building Khalimsky space K=" <<
K << std::endl;
358 int closed = params[
"closed" ].as<
int>();
360 if ( !
K.init( bimage->domain().lowerBound(),
361 bimage->domain().upperBound(),
363 trace.error() <<
"[Shortcuts::getKSpace]"
364 <<
" Error building Khalimsky space K=" <<
K << std::endl;
382 int closed = params[
"closed" ].as<
int>();
384 if ( !
K.init( gimage->domain().lowerBound(),
385 gimage->domain().upperBound(),
387 trace.error() <<
"[Shortcuts::getKSpace]"
388 <<
" Error building Khalimsky space K=" <<
K << std::endl;
395 template <
typename TDigitalSurfaceContainer>
400 return surface->container().space();
406 template <
typename TDigitalSurfaceContainer>
411 return surface->container().space();
417 template <
typename TDigitalSurfaceContainer>
422 return surface->container().space();
428 template <
typename TDigitalSurfaceContainer>
433 return surface->container().space();
494 bool closed = params[
"closed" ].as<
int>();
495 RealPoint p1( min_x - offset * h, min_x - offset * h, min_x - offset * h );
496 RealPoint p2( max_x + offset * h, max_x + offset * h, max_x + offset * h );
498 dshape->init( p1, p2, h );
501 if ( !
K.init(
domain.lowerBound(),
domain.upperBound(), closed ) )
502 trace.error() <<
"[Shortcuts::getKSpace]"
503 <<
" Error building Khalimsky space K=" <<
K << std::endl
504 <<
"Note: if you use decimal values, check your locale for decimal point '.' or ','."
531 RealPoint p1( min_x - offset * h, min_x - offset * h, min_x - offset * h );
532 RealPoint p2( max_x + offset * h, max_x + offset * h, max_x + offset * h );
534 dshape->attach( shape );
535 dshape->init( p1, p2, h );
552 (
"thresholdMin", 0 )
553 (
"thresholdMax", 255 );
581 shape_digitization->getDomain(),
605 std::transform( shapeDomain.
begin(), shapeDomain.
end(),
607 [&shape_digitization]
608 (
const Point& p ) { return (*shape_digitization)(p); } );
613 KanungoPredicate noisy_dshape( *shape_digitization, shapeDomain, noise );
614 std::transform( shapeDomain.
begin(), shapeDomain.
end(),
616 [&noisy_dshape] (
const Point& p ) { return noisy_dshape(p); } );
633 if ( noise <= 0.0 )
return bimage;
635 const Domain shapeDomain = bimage->domain();
637 KanungoPredicate noisy_dshape( *bimage, shapeDomain, noise );
638 std::transform( shapeDomain.
begin(), shapeDomain.
end(),
640 [&noisy_dshape] (
const Point& p ) { return noisy_dshape(p); } );
660 int thresholdMin = params[
"thresholdMin"].as<
int>();
661 int thresholdMax = params[
"thresholdMax"].as<
int>();
665 ThresholdedImage tImage(
image, thresholdMin, thresholdMax );
669 [tImage] (
const Point& p ) { return tImage(p); } );
689 int thresholdMin = params[
"thresholdMin"].as<
int>();
690 int thresholdMax = params[
"thresholdMax"].as<
int>();
693 ThresholdedImage tImage( *gray_scale_image, thresholdMin, thresholdMax );
697 [tImage] (
const Point& p ) { return tImage(p); } );
750 ( std::string input )
765 std::function<
GrayScale(
bool ) >
const & bool2grayscale
766 = [] (
bool v ) {
return v ? (
unsigned char) 255 : (
unsigned char) 0; }
773 gray_scale_image->begin(),
775 return gray_scale_image;
808 float qShift = params[
"qShift" ].as<
float>();
809 float qSlope = params[
"qSlope" ].as<
float>();
810 std::function<
unsigned char(
float ) > f
811 = [qShift,qSlope] (
float v)
812 {
return (
unsigned char) std::min( 255.0f, std::max( 0.0f, qSlope * v + qShift ) ); };
815 auto it = gimage->begin();
818 float val = (*fimage)( p );
840 double qShift = params[
"qShift" ].as<
double>();
841 double qSlope = params[
"qSlope" ].as<
double>();
842 std::function<
unsigned char(
double ) > f
843 = [qShift,qSlope] (
double v)
844 {
return (
unsigned char) std::min( 255.0, std::max( 0.0, qSlope * v + qShift ) ); };
847 auto it = gimage->begin();
850 double val = (*fimage)( p );
878 ( std::string input )
906 RealPoint p1( min_x - offset * h, min_x - offset * h, min_x - offset * h );
907 RealPoint p2( max_x + offset * h, max_x + offset * h, max_x + offset * h );
909 dshape->attach( shape );
910 dshape->init( p1, p2, h );
913 auto it = fimage->begin();
916 float val = (float) (*shape)( p );
944 ( std::string input )
972 RealPoint p1( min_x - offset * h, min_x - offset * h, min_x - offset * h );
973 RealPoint p2( max_x + offset * h, max_x + offset * h, max_x + offset * h );
975 dshape->attach( shape );
976 dshape->init( p1, p2, h );
979 auto it = fimage->begin();
982 double val = (double) (*shape)( p );
1000 (
"surfelAdjacency", 0 )
1001 (
"nbTriesToFindABel", 100000 )
1002 (
"surfaceComponents",
"AnyBig" )
1003 (
"surfaceTraversal",
"Default" );
1009 template <
typename TDigitalSurfaceContainer>
1020 template <
typename TDigitalSurfaceContainer>
1031 template <
typename TDigitalSurfaceContainer>
1042 template <
typename TDigitalSurfaceContainer>
1067 bool surfel_adjacency = params[
"surfelAdjacency" ].as<
int>();
1068 int nb_tries_to_find_a_bel = params[
"nbTriesToFindABel" ].as<
int>();
1074 Scalar minsize = bimage->extent().norm();
1075 unsigned int nb_surfels = 0;
1076 unsigned int tries = 0;
1082 trace.error() <<
"[Shortcuts::makeLightDigitalSurface]"
1083 <<
" ERROR Unable to find bel. " << e << std::endl;
1091 nb_surfels = ptrSurface->size();
1093 while ( ( nb_surfels < 2 * minsize ) && ( tries++ < 150 ) );
1095 trace.warning() <<
"[Shortcuts::makeLightDigitalSurface]"
1096 <<
"ERROR cannot find a proper bel in a big enough component."
1118 static std::vector< CountedPtr<LightDigitalSurface> >
1148 static std::vector< CountedPtr<LightDigitalSurface> >
1155 std::vector< CountedPtr<LightDigitalSurface> > result;
1156 std::string component = params[
"surfaceComponents" ].as<std::string>();
1157 if ( component ==
"AnyBig" )
1160 surfel_reps.push_back( *( result[ 0 ]->begin() ) );
1163 bool surfel_adjacency = params[
"surfelAdjacency" ].as<
int>();
1168 K.lowerBound(),
K.upperBound() );
1172 for (
auto bel : all_surfels )
1174 if ( marked_surfels.count( bel ) != 0 )
continue;
1175 surfel_reps.push_back( bel );
1181 marked_surfels.insert( ptrSurface->begin(), ptrSurface->end() );
1183 result.push_back( ptrSurface );
1207 template <
typename TPo
intPredicate>
1215 bool surfel_adjacency = params[
"surfelAdjacency" ].as<
int>();
1219 K.lowerBound(),
K.upperBound() );
1244 bool surfel_adjacency = params[
"surfelAdjacency" ].as<
int>();
1247 auto all_idx_surfels
1249 auto idx2surfel = idx_surface->surfels();
1251 for (
auto idx : all_idx_surfels ) all_surfels.insert( idx2surfel[ idx ] );
1280 std::string component = params[
"surfaceComponents" ].as<std::string>();
1282 if ( component ==
"AnyBig" )
1285 surfels.insert( light_surface->begin(), light_surface->end() );
1287 else if ( component ==
"All" )
1290 K.lowerBound(),
K.upperBound() );
1306 template <
typename TSurfelRange>
1309 (
const TSurfelRange& surfels,
1313 bool surfel_adjacency = params[
"surfelAdjacency" ].as<
int>();
1320 bool ok = ptrSurface->build( ptrSurfContainer );
1322 trace.warning() <<
"[Shortcuts::makeIdxDigitalSurface]"
1323 <<
" Error building indexed digital surface." << std::endl;
1339 template <
typename TDigitalSurfaceContainer>
1369 const KSpace&
K = surfaces[ 0 ]->container().space();
1371 for ( std::size_t i = 0; i < surfaces.size(); ++i )
1373 const KSpace& Ki = surfaces[ i ]->container().space();
1376 trace.warning() <<
"[Shortcuts::makeIdxDigitalSurface]"
1377 <<
" Incompatible digital spaces for surface " << i << std::endl;
1378 surfels.insert( surfaces[ i ]->begin(), surfaces[ i ]->end() );
1397 template <
typename TDigitalSurfaceContainer>
1406 result.reserve( 2 *
surface->size() + 100 );
1409 for (
auto&& surfel : *
surface )
1412 for (
auto&& primal_cell : primal_cells )
1414 if ( ! c2i.count( primal_cell ) )
1416 result.push_back( primal_cell );
1417 c2i[ primal_cell ] = n++;
1436 template <
typename TDigitalSurfaceContainer>
1467 template <
typename TDigitalSurfaceContainer>
1474 result.reserve(
surface->size() );
1477 for (
auto&& surfel : *
surface )
1480 for (
auto&& primal_vtx : primal_vtcs )
1482 if ( ! c2i.count( primal_vtx ) )
1484 result.push_back( primal_vtx );
1485 c2i[ primal_vtx ] = n++;
1508 template <
typename TDigitalSurfaceContainer>
1545 template <
typename TDigitalSurfaceContainer>
1568 template <
typename TDigitalSurfaceContainer>
1572 const Surfel& start_surfel,
1575 typedef ::DGtal::DigitalSurface<TDigitalSurfaceContainer> AnyDigitalSurface;
1577 std::string traversal = params[
"surfaceTraversal" ].as<std::string>();
1578 if ( traversal ==
"DepthFirst" )
1583 std::for_each( range.begin(), range.end(),
1584 [&result] (
Surfel s ) { result.push_back( s ); } );
1586 else if ( traversal ==
"BreadthFirst" )
1591 std::for_each( range.begin(), range.end(),
1592 [&result] (
Surfel s ) { result.push_back( s ); } );
1597 [&result] (
Surfel s ) { result.push_back( s ); } );
1638 std::string traversal = params[
"surfaceTraversal" ].as<std::string>();
1639 if ( traversal ==
"DepthFirst" )
1644 std::for_each( range.begin(), range.end(),
1645 [&result] (
IdxSurfel s ) { result.push_back( s ); } );
1647 else if ( traversal ==
"BreadthFirst" )
1652 std::for_each( range.begin(), range.end(),
1653 [&result] (
IdxSurfel s ) { result.push_back( s ); } );
1655 else return surface->allVertices();
1670 template <
typename TDigitalSurfaceContainer,
1671 typename TCellEmbedder>
1675 const TCellEmbedder& embedder,
1676 std::string off_file,
1682 std::ofstream output_off( off_file.c_str() );
1683 output_off <<
"OFF" << std::endl;
1684 output_off <<
"# Generated from DGtal::Shortcuts from the DGTal library" << std::endl;
1687 output_off << pointels.size() <<
" " << digsurf->size() <<
" " << 0 <<
" " << std::endl;
1692 for (
auto&& pointel : pointels )
1695 output_off << p[ 0 ] <<
" " << p[ 1 ] <<
" " << p[ 2 ] << std::endl;
1699 for (
auto&& surfel : *digsurf )
1702 output_off << primal_vtcs.size();
1704 for (
auto&& primal_vtx : primal_vtcs )
1705 output_off <<
" " << (c2i[ primal_vtx ]);
1710 output_off << face_color.r() <<
" " << face_color.g()
1711 <<
" " << face_color.b() <<
" " << face_color.a();
1713 output_off << std::endl;
1715 return output_off.good();
1736 template <
typename TDigitalSurfaceContainer,
1737 typename TCellEmbedder>
1741 const TCellEmbedder& embedder,
1743 const Colors& diffuse_colors,
1744 std::string objfile,
1745 const Color& ambient_color =
Color( 32, 32, 32 ),
1746 const Color& diffuse_color =
Color( 200, 200, 255 ),
1750 std::string mtlfile;
1751 auto lastindex = objfile.find_last_of(
".");
1752 if ( lastindex == std::string::npos )
1754 mtlfile = objfile +
".mtl";
1755 objfile = objfile +
".obj";
1759 mtlfile = objfile.substr(0, lastindex) +
".mtl";
1762 std::ofstream output_obj( objfile.c_str() );
1763 output_obj <<
"# OBJ format" << std::endl;
1764 output_obj <<
"# DGtal::MeshHelpers::exportOBJwithFaceNormalAndColor" << std::endl;
1765 output_obj <<
"o anObject" << std::endl;
1767 auto indexpath = objfile.find_last_of(
"/");
1768 output_obj <<
"mtllib " << mtlfile.substr(indexpath+1) << std::endl;
1769 std::ofstream output_mtl( mtlfile.c_str() );
1770 output_mtl <<
"# MTL format"<< std::endl;
1771 output_mtl <<
"# generated from MeshWriter from the DGTal library"<< std::endl;
1776 for (
auto&& pointel : pointels )
1779 output_obj <<
"v " << p[ 0 ] <<
" " << p[ 1 ] <<
" " << p[ 2 ] << std::endl;
1782 Idx nbfaces = digsurf->size();
1783 bool has_normals = ( nbfaces == normals.size() );
1786 for (
Idx f = 0; f < nbfaces; ++f )
1788 const auto& p = normals[ f ];
1789 output_obj <<
"vn " << p[ 0 ] <<
" " << p[ 1 ] <<
" " << p[ 2 ] << std::endl;
1793 bool has_material = ( nbfaces == diffuse_colors.size() );
1794 Idx idxMaterial = 0;
1795 std::map<Color, Idx > mapMaterial;
1798 for (
Idx f = 0; f < nbfaces; ++f )
1800 Color c = diffuse_colors[ f ];
1801 if ( mapMaterial.count( c ) == 0 )
1804 ( output_mtl, idxMaterial, ambient_color, c, specular_color );
1805 mapMaterial[ c ] = idxMaterial++;
1812 ( output_mtl, idxMaterial, ambient_color, diffuse_color, specular_color );
1817 for (
auto&& surfel : *digsurf )
1819 output_obj <<
"usemtl material_"
1820 << ( has_material ? mapMaterial[ diffuse_colors[ f ] ] : idxMaterial )
1827 for (
auto&& primal_vtx : primal_vtcs )
1828 output_obj <<
" " << (c2i[ primal_vtx ]+1) <<
"//" << (f+1);
1832 for (
auto&& primal_vtx : primal_vtcs )
1833 output_obj <<
" " << (c2i[ primal_vtx ]+1);
1835 output_obj << std::endl;
1839 return output_obj.good();
1857 template <
typename TDigitalSurfaceContainer>
1862 const Colors& diffuse_colors,
1863 std::string objfile,
1864 const Color& ambient_color =
Color( 32, 32, 32 ),
1865 const Color& diffuse_color =
Color( 200, 200, 255 ),
1869 return saveOBJ( digsurf, embedder, normals, diffuse_colors, objfile,
1870 ambient_color, diffuse_color, specular_color );
1886 template <
typename TDigitalSurfaceContainer>
1890 std::string off_file,
1891 const Color& face_color =
Color( 32, 32, 32 ))
1894 return saveOFF( digsurf, embedder, off_file, face_color);
1908 template <
typename TDigitalSurfaceContainer>
1912 std::string objfile,
1913 const Color& ambient_color =
Color( 32, 32, 32 ),
1914 const Color& diffuse_color =
Color( 200, 200, 255 ),
1919 ambient_color, diffuse_color, specular_color );
1943 const Colors& diffuse_colors,
1944 std::string objfile,
1945 const Color& ambient_color =
Color( 32, 32, 32 ),
1946 const Color& diffuse_color =
Color( 200, 200, 255 ),
1950 std::string mtlfile;
1951 auto lastindex = objfile.find_last_of(
".");
1952 if ( lastindex == std::string::npos )
1954 mtlfile = objfile +
".mtl";
1955 objfile = objfile +
".obj";
1959 mtlfile = objfile.substr(0, lastindex) +
".mtl";
1961 std::ofstream output_obj( objfile.c_str() );
1962 output_obj <<
"# OBJ format" << std::endl;
1963 output_obj <<
"# DGtal::saveOBJ" << std::endl;
1964 output_obj <<
"o vectors" << std::endl;
1965 output_obj <<
"mtllib " << mtlfile << std::endl;
1966 std::ofstream output_mtl( mtlfile.c_str() );
1967 output_mtl <<
"# MTL format"<< std::endl;
1968 output_mtl <<
"# generated from MeshWriter from the DGTal library"<< std::endl;
1970 auto n = std::min( positions.size(), vf.size() );
1971 for (
unsigned int i = 0; i < n; ++i )
1977 auto mc = std::max_element( absv.
begin(), absv.
end() ) - absv.
begin();
1983 RealPoint t[4] = { thickness * e0, thickness * e1,
1984 -thickness * e0, -thickness * e1 };
1985 for (
unsigned int j = 0; j < 4; ++j ) {
1988 output_obj <<
"v " << pt0[ 0 ] <<
" " << pt0[ 1 ] <<
" " << pt0[ 2 ]
1990 output_obj <<
"v " << pt1[ 0 ] <<
" " << pt1[ 1 ] <<
" " << pt1[ 2 ]
1995 std::map<Color,Idx> map_colors;
1998 for (
auto && c : diffuse_colors )
1999 if ( ! map_colors.count( c ) )
2000 map_colors[ c ] = j++;
2004 bool has_material = ! diffuse_colors.empty();
2006 for (
auto&& pair : map_colors )
2008 ( output_mtl, pair.second, ambient_color, pair.first, specular_color);
2011 ( output_mtl, 0, ambient_color, diffuse_color, specular_color );
2013 for (
Idx i = 0; i < n; ++i )
2015 output_obj <<
"usemtl material_"
2016 << ( has_material ? map_colors[ diffuse_colors[ i ] ] : 0 )
2019 for (
Idx j = 0; j < 8; j += 2 )
2020 output_obj <<
"f " << (b+j) <<
" " << (b+j+1)
2021 <<
" " << (b+(j+3)%8) <<
" " << (b+(j+2)%8) << std::endl;
2022 output_obj <<
"f " << b <<
" " << (b+2)
2023 <<
" " << (b+4) <<
" " << (b+6) << std::endl;
2024 output_obj <<
"f " << (b+1) <<
" " << (b+7)
2025 <<
" " << (b+5) <<
" " << (b+3) << std::endl;
2028 return output_obj.good();
2040 (
"faceSubdivision",
"Centroid" );
2103 template <
typename TContainer >
2112 ( *aSurface, embedder, *pTriSurf, s2i );
2121 template <
typename TContainer >
2150 std::string faceSubdivision = params[
"faceSubdivision" ].as<std::string>();
2151 bool centroid = ( faceSubdivision ==
"Centroid" );
2198 RealVector gh = { params[
"gridsizex" ].as<
double>(),
2199 params[
"gridsizey" ].as<double>(),
2200 params[
"gridsizez" ].as<
double>() };
2201 double threshold = params[
"thresholdMin" ].as<
double>() + 0.5;
2205 PointEmbedder pembedder;
2206 pembedder.init( gh );
2207 ImageCellEmbedder cembedder;
2208 cembedder.init(
K, *gray_scale_image, pembedder, threshold );
2213 ( *digSurf, cembedder, *pPolySurf, s2i );
2241 RealVector gh = { params[
"gridsizex" ].as<
double>(),
2242 params[
"gridsizey" ].as<double>(),
2243 params[
"gridsizez" ].as<
double>() };
2244 double threshold = params[
"thresholdMin" ].as<
double>() + 0.5;
2248 PointEmbedder pembedder;
2249 pembedder.init( gh );
2250 ImageCellEmbedder cembedder;
2251 cembedder.init(
K, *gray_scale_image, pembedder, threshold );
2256 ( *digSurf, cembedder, *pPolySurf, s2i );
2267 template <
typename TContainer >
2277 ( *aSurface, embedder, *pPolySurf, s2i );
2287 template <
typename TContainer >
2301 template <
typename TContainer >
2309 aSurface->positions().storage() ) );
2320 template <
typename TContainer >
2330 ( *aSurface, embedder, *pPolySurf, c2i );
2340 template <
typename TContainer >
2354 template <
typename TContainer >
2371 template <
typename TContainer >
2389 template <
typename TContainer >
2403 template <
typename TContainer >
2419 std::ifstream file(path);
2439 template <
typename TPo
int,
typename TVector>
2443 const std::string& objfile )
2445 std::ofstream output( objfile.c_str() );
2457 template <
typename TPo
int>
2461 const std::string& objfile )
2463 std::ofstream output( objfile.c_str() );
2477 template <
typename TPo
int>
2480 std::string off_file,
2486 std::ofstream output( off_file.c_str() );
2487 for (
unsigned int i=0; i< m.
nbFaces(); i++)
2502 template <
typename TPo
int>
2506 const std::string& objfile )
2508 std::ofstream output( objfile.c_str() );
2526 template <
typename TPo
int>
2531 const Colors& diffuse_colors,
2532 std::string objfile,
2533 const Color& ambient_color =
Color( 32, 32, 32 ),
2534 const Color& diffuse_color =
Color( 200, 200, 255 ),
2537 std::string mtlfile;
2538 auto lastindex = objfile.find_last_of(
".");
2539 if ( lastindex == std::string::npos )
2541 mtlfile = objfile +
".mtl";
2542 objfile = objfile +
".obj";
2546 mtlfile = objfile.substr(0, lastindex) +
".mtl";
2548 std::ofstream output( objfile.c_str() );
2550 ( output, mtlfile, *polysurf, normals, diffuse_colors,
2551 ambient_color, diffuse_color, specular_color );
2568 template <
typename TPo
int>
2573 const Colors& diffuse_colors,
2574 std::string objfile,
2575 const Color& ambient_color =
Color( 32, 32, 32 ),
2576 const Color& diffuse_color =
Color( 200, 200, 255 ),
2579 std::string mtlfile;
2580 auto lastindex = objfile.find_last_of(
".");
2581 if ( lastindex == std::string::npos )
2583 mtlfile = objfile +
".mtl";
2584 objfile = objfile +
".obj";
2588 mtlfile = objfile.substr(0, lastindex) +
".mtl";
2590 std::ofstream output( objfile.c_str() );
2592 ( output, mtlfile, *trisurf, normals, diffuse_colors,
2593 ambient_color, diffuse_color, specular_color );
2611 template <
typename TPo
int,
typename TVector>
2616 const Colors& diffuse_colors,
2617 std::string objfile,
2618 const Color& ambient_color =
Color( 32, 32, 32 ),
2619 const Color& diffuse_color =
Color( 200, 200, 255 ),
2622 std::string mtlfile;
2623 auto lastindex = objfile.find_last_of(
".");
2624 if ( lastindex == std::string::npos )
2626 mtlfile = objfile +
".mtl";
2627 objfile = objfile +
".obj";
2631 mtlfile = objfile.substr(0, lastindex) +
".mtl";
2633 std::ofstream output( objfile.c_str() );
2635 ( output, mtlfile, *surf, normals, diffuse_colors,
2636 ambient_color, diffuse_color, specular_color );
2649 template <
typename TPo
int>
2652 std::string off_file,
2658 std::ofstream output( off_file.c_str() );
2659 for (
unsigned int i=0; i< m.
nbFaces(); i++)
2679 (
"colormap",
"Custom" )
2680 (
"zero-tic", 0.0 );
2699 template <
typename TValue>
2701 getRangeMatch(
const std::vector< TValue >& s1,
const std::vector< TValue >& s2,
2702 bool perfect =
false )
2704 if ( perfect && ( s1.size() != s2.size() ) )
return IdxRange();
2705 std::map<TValue, Idx> M;
2707 for (
auto val : s2 ) M[ val ] = idx++;
2710 for (
auto val : s1 )
2712 auto it = M.find( val );
2713 if ( it != M.end() ) V[ idx++ ] = it->second;
2717 V[ idx++ ] = s2.size();
2734 template <
typename TValue>
2735 static std::vector< TValue >
2738 std::vector< TValue > result( match.size() );
2739 for (
Idx i = 0; i < result.size(); i++ )
2740 result[ i ] = range[ match[ i ] ];
2755 std::string cmap = params[
"colormap" ].as<std::string>();
2764 else if ( cmap ==
"Error" )
2794 auto ztic = params[
"zero-tic" ].as<
double>();
2796 if ( ztic <= 0.0 )
return ztic_cmap;
2797 if ( min <= 0.0 && 0.0 <=
max )
2798 ztic_cmap.addTick( 0.0, ztic );
2799 ztic_cmap.finalize();
2812 template <
typename TCellEmbedder = CanonicCellEmbedder< KSpace > >
2815 ( std::ostream& output,
2817 const TCellEmbedder& embedder )
2819 typedef unsigned long Size;
2822 const KSpace&
K = embedder.space();
2824 std::map< Cell, Size > vtx_numbering;
2826 for (
auto&& s : surfels )
2829 for (
auto&& primal_vtx : primal_vtcs )
2831 if ( ! vtx_numbering.count( primal_vtx ) )
2833 vtx_numbering[ primal_vtx ] = n++;
2836 output <<
"v " << p[ 0 ] <<
" " << p[ 1 ] <<
" " << p[ 2 ] << std::endl;
2841 for (
auto&& s : surfels )
2845 for (
auto&& primal_vtx : primal_vtcs )
2846 output <<
" " << vtx_numbering[ primal_vtx ];
2847 output << std::endl;
2849 return output.good();
2863 template <
typename TAnyDigitalSurface>
2866 ( std::ostream& output,
2890 template <
typename TAnyDigitalSurface,
2894 ( std::ostream& output,
2896 const TCellEmbedder& embedder )
2912 ( std::ostream& output,
2932 template <
typename TCellEmbedder = CanonicCellEmbedder< KSpace > >
2935 ( std::ostream& output,
2937 const TCellEmbedder& embedder )
2940 auto surfelmap =
surface->surfels();
2942 for (
auto&& idx : idxsurfels )
2943 surfels.push_back( surfelmap[ idx ] );
2963 template <
typename TDigitalSurfaceContainer>
2966 ( std::ostream& output,
2996 template <
typename TDigitalSurfaceContainer,
3000 ( std::ostream& output,
3002 const TCellEmbedder& embedder,
3005 typedef unsigned long Size;
3008 std::string dualFaceSubdivision = params[
"faceSubdivision" ].as<std::string>();
3010 = dualFaceSubdivision ==
"Naive" ? 1
3011 : dualFaceSubdivision ==
"Centroid" ? 2
3013 const KSpace&
K = embedder.space();
3015 std::map< Vertex, Size > vtx_numbering;
3016 std::map< Face, Size > sub_numbering;
3020 if ( ! vtx_numbering.count( s ) )
3022 vtx_numbering[ s ] = n++;
3025 output <<
"v " << p[ 0 ] <<
" " << p[ 1 ] <<
" " << p[ 2 ] << std::endl;
3028 auto faces =
surface->allClosedFaces();
3030 if ( subdivide == 2 )
3032 for (
auto&& f : faces )
3034 auto vtcs =
surface->verticesAroundFace( f );
3035 Size nv = vtcs.size();
3038 sub_numbering[ f ] = n++;
3040 for (
auto&& s : vtcs ) p += embedder(
K.unsigns( s ) );
3042 output <<
"v " << p[ 0 ] <<
" " << p[ 1 ] <<
" " << p[ 2 ] << std::endl;
3047 if ( subdivide == 0 )
3049 for (
auto&& f : faces )
3052 auto vtcs =
surface->verticesAroundFace( f );
3053 std::reverse( vtcs.begin(), vtcs.end() );
3054 for (
auto&& s : vtcs )
3055 output <<
" " << vtx_numbering[ s ];
3056 output << std::endl;
3059 else if ( subdivide == 1 )
3061 for (
auto&& f : faces )
3063 auto vtcs =
surface->verticesAroundFace( f );
3064 Size nv = vtcs.size();
3065 for (
Size i = 1; i < nv - 1; ++i )
3066 output <<
"f " << vtx_numbering[ vtcs[ 0 ] ]
3067 <<
" " << vtx_numbering[ vtcs[ i+1 ] ]
3068 <<
" " << vtx_numbering[ vtcs[ i ] ] << std::endl;
3071 else if ( subdivide == 2 )
3073 for (
auto&& f : faces )
3075 auto vtcs =
surface->verticesAroundFace( f );
3076 Size nv = vtcs.size();
3078 output <<
"f " << vtx_numbering[ vtcs[ 0 ] ]
3079 <<
" " << vtx_numbering[ vtcs[ 2 ] ]
3080 <<
" " << vtx_numbering[ vtcs[ 1 ] ] << std::endl;
3082 Size c = sub_numbering[ f ];
3083 for (
Size i = 0; i < nv; ++i )
3086 <<
" " << vtx_numbering[ vtcs[ (i+1)%nv ] ]
3087 <<
" " << vtx_numbering[ vtcs[ i ] ] << std::endl;
3092 return output.good();
3102 output <<
" " <<
K.sKCoord( cell, d );
3111 return K.uCell( kp );
3118 output <<
" " <<
K.sSign( scell );
3129 return K.sCell( kp, s );
3133 template <
typename Value>
3139 void operator()( std::ostream& output,
const std::vector<Value>& vv )
3141 for (
auto&& v : vv ) output <<
" " << v;
3139 void operator()( std::ostream& output,
const std::vector<Value>& vv ) {
…}
3145 template <
typename Value>
3150 std::getline( input, str );
3152 std::stringstream strstr(str);
3154 std::istream_iterator<std::string> it(strstr);
3155 std::istream_iterator<std::string> end;
3156 std::vector<std::string> results(it, end);
3157 std::stringstream sstr( results[ 0 ] );
3159 return ( results.size() == 1 ) && input.good();
3162 bool operator()( std::istream& input, std::vector<Value>& values )
3165 std::getline( input, str );
3167 std::stringstream strstr(str);
3169 std::istream_iterator<std::string> it(strstr);
3170 std::istream_iterator<std::string> end;
3171 std::vector<std::string> results(it, end);
3172 values.resize( results.size() );
3173 for (
unsigned int i = 0; i < results.size(); ++i ) {
3174 std::stringstream sstr( results[ i ] );
3175 sstr >> values[ i ];
3177 return input.good();
3162 bool operator()( std::istream& input, std::vector<Value>& values ) {
…}
3193 template <
typename TSCellMap,
typename TValueWriter>
3196 ( std::ostream& output,
3198 const TSCellMap& anyMap,
3199 const TValueWriter& writer )
3202 for (
auto&& v : anyMap )
3204 w( output,
K, v.first );
3205 writer( output, v.second );
3206 output << std::endl;
3208 return output.good();
3223 template <
typename TCellMap,
typename TValueWriter>
3226 ( std::ostream& output,
3228 const TCellMap& anyMap,
3229 const TValueWriter& writer )
3232 for (
auto&& v : anyMap )
3234 w( output,
K, v.first );
3235 writer( output, v.second );
3236 output << std::endl;
3238 return output.good();
3249 auto faces =
K.uFaces(
K.unsigns( s ) );
3251 for (
auto&& f : faces )
3253 if (
K.uDim( f ) == k ) primal_cells.push_back( f );
3255 return primal_cells;
3279 std::swap( vtcs[ 2 ], vtcs[ 3 ] );
3280 auto orth_dir =
K.sOrthDir( s );
3281 auto direct =
K.sDirect( s, orth_dir ) ? ccw : ! ccw;
3282 Vector s0s1 =
K.uCoords( vtcs[ 1 ] ) -
K.uCoords( vtcs[ 0 ] );
3283 Vector s0s2 =
K.uCoords( vtcs[ 2 ] ) -
K.uCoords( vtcs[ 0 ] );
3285 if ( ( ( t[ orth_dir ] > 0.0 ) && direct )
3286 || ( ( t[ orth_dir ] < 0.0 ) && ! direct ) )
3287 std::reverse( vtcs.begin(), vtcs.end() );
3340 out <<
"[Shortcuts]";
3373 template <
typename T>
3388#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
std::vector< Arc > ArcRange
DigitalSurfaceContainer::SCell SCell
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 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.
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
const Point & lowerBound() const
Return the lower bound for digital points in this space.
const Point & upperBound() const
Return the upper bound for digital points in this space.
SpaceND< dim, Integer > Space
static const constexpr Dimension dimension
Aim: This class converts a string polynomial expression in a multivariate polynomial.
Iterator read(Polynomial &p, Iterator begin, Iterator end)
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 bool exportOBJwithFaceNormalAndColor(std::ostream &output_obj, const std::string &mtl_filename, const SurfaceMesh &surf, const std::vector< typename SurfaceMesh::RealPoint > &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 digitalSurface2DualTriangulatedSurface(const DigitalSurface< DigitalSurfaceContainer > &dsurf, const CellEmbedder &cembedder, TriangulatedSurface< typename CellEmbedder::Value > &trisurf, VertexMap &vertexmap)
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....
void setFaceColor(Index i, const DGtal::Color &aColor)
auto crossProduct(const PointVector< dim, OtherComponent, OtherStorage > &v) const -> decltype(DGtal::crossProduct(*this, v))
Cross product with a 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: 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
static bool outputPrimalDigitalSurfaceAsObj(std::ostream &output, CountedPtr< TAnyDigitalSurface > surface, const TCellEmbedder &embedder)
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
static KSpace getKSpace(const Point &low, const Point &up, Parameters params=parametersKSpace())
SetOfSurfels< KSpace, SurfelSet > ExplicitSurfaceContainer
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)
static CountedPtr< SurfaceMesh > makeSurfaceMesh(const std::string &path)
Shortcuts(Shortcuts &&other)=delete
static bool saveOBJ(CountedPtr< ::DGtal::SurfaceMesh< TPoint, TVector > > surf, 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 SurfelRange getSurfelRange(CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > surface, const Surfel &start_surfel, const Parameters ¶ms=parametersDigitalSurface())
RealVector::Component Scalar
::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
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
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
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
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
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
static CanonicSCellEmbedder< KSpace > getSCellEmbedder(CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > surface)
::DGtal::DigitalSurface< ExplicitSurfaceContainer > DigitalSurface
std::vector< IdxVertex > IdxRange
IdxDigitalSurface::Vertex IdxSurfel
void selfDisplay(std::ostream &out) const
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::SurfaceMesh< TPoint, TVector > > surf, const std::string &objfile)
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
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
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
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
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
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
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)
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
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
PointVector< dim, Integer > Point
PointVector< dim, double > RealPoint
PointVector< dim, double > RealVector
PointVector< dim, Integer > Vector
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 ...
CountedPtr< SH3::DigitalSurface > surface
CountedPtr< SH3::BinaryImage > binary_image
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)
static bool readOBJ(std::istream &input, SurfaceMesh &smesh)
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
MPolynomialReader< 3, Ring > Polynomial3Reader