31#if defined(Shortcuts_RECURSES)
32#error Recursive header files inclusion detected in Shortcuts.h
35#define Shortcuts_RECURSES
37#if !defined Shortcuts_h
46#include "DGtal/base/Common.h"
47#include "DGtal/base/CountedPtr.h"
48#include "DGtal/kernel/domains/HyperRectDomain.h"
49#include "DGtal/kernel/RegularPointEmbedder.h"
50#include "DGtal/math/MPolynomial.h"
51#include "DGtal/math/Statistic.h"
52#include "DGtal/images/ImageContainerBySTLVector.h"
53#include "DGtal/images/IntervalForegroundPredicate.h"
54#include "DGtal/images/ImageLinearCellEmbedder.h"
55#include "DGtal/shapes/implicit/ImplicitPolynomial3Shape.h"
56#include "DGtal/shapes/GaussDigitizer.h"
57#include "DGtal/shapes/ShapeGeometricFunctors.h"
58#include "DGtal/shapes/MeshHelpers.h"
59#include "DGtal/topology/CCellularGridSpaceND.h"
60#include "DGtal/topology/LightImplicitDigitalSurface.h"
61#include "DGtal/topology/SetOfSurfels.h"
62#include "DGtal/topology/DigitalSurface.h"
63#include "DGtal/topology/IndexedDigitalSurface.h"
64#include "DGtal/topology/SurfelAdjacency.h"
65#include "DGtal/topology/CCellEmbedder.h"
66#include "DGtal/topology/CanonicCellEmbedder.h"
67#include "DGtal/topology/CanonicSCellEmbedder.h"
68#include "DGtal/topology/helpers/Surfaces.h"
69#include "DGtal/geometry/volumes/KanungoNoise.h"
70#include "DGtal/shapes/Mesh.h"
71#include "DGtal/io/Color.h"
72#include "DGtal/io/colormaps/GradientColorMap.h"
73#include "DGtal/io/colormaps/TickedColorMap.h"
74#include "DGtal/io/readers/MPolynomialReader.h"
75#include "DGtal/io/readers/GenericReader.h"
76#include "DGtal/io/readers/SurfaceMeshReader.h"
77#include "DGtal/io/writers/GenericWriter.h"
78#include "DGtal/io/writers/MeshWriter.h"
79#include "DGtal/graph/BreadthFirstVisitor.h"
80#include "DGtal/graph/DepthFirstVisitor.h"
81#include "DGtal/graph/GraphVisitorRange.h"
82#include "DGtal/helpers/Parameters.h"
100 template <
typename TKSpace >
181 typedef ::DGtal::Mesh<RealPoint>
Mesh;
232 static std::map< std::string, std::string >
235 std::vector< std::pair< std::string, std::string > >
236 Ps = { {
"sphere1",
"x^2+y^2+z^2-1" },
237 {
"sphere9",
"x^2+y^2+z^2-81" },
238 {
"ellipsoid",
"3*x^2+2*y^2+z^2-90" },
239 {
"cylinder",
"x^2+2*z^2-90" },
240 {
"torus",
"(x^2+y^2+z^2+6*6-2*2)^2-4*6*6*(x^2+y^2)" },
241 {
"rcube",
"x^4+y^4+z^4-6561" },
242 {
"goursat",
"-1*(8-0.03*x^4-0.03*y^4-0.03*z^4+2*x^2+2*y^2+2*z^2)" },
243 {
"goursat-hole",
"x^4+y^4+z^4-2*4*(x^2+y^2+z^2)+2*4*4-2" },
244 {
"distel",
"10000-(x^2+y^2+z^2+1000*(x^2+y^2)*(x^2+z^2)*(y^2+z^2))"},
245 {
"leopold",
"(x^2*y^2*z^2+4*x^2+4*y^2+3*z^2)-100" },
246 {
"diabolo",
"x^2-(y^2+z^2)^2" },
247 {
"heart",
"-1*(x^2+2.25*y^2+z^2-1)^3+x^2*z^3+0.1125*y^2*z^3" },
248 {
"crixxi",
"-0.9*(y^2+z^2-1)^2-(x^2+y^2-1)^3" } };
249 std::map< std::string, std::string >
L;
251 L[ p.first ] = p.second;
265 (
"polynomial",
"sphere1" )
266 (
"projectionMaxIter", 20 )
267 (
"projectionAccuracy", 0.0001 )
268 (
"projectionGamma", 0.5 );
282 std::string poly_str = params[
"polynomial" ].as<std::string>();
285 if ( PL[ poly_str ] !=
"" ) poly_str = PL[ poly_str ];
288 std::string::const_iterator iter
289 = reader.read( poly, poly_str.begin(), poly_str.end() );
290 if ( iter != poly_str.end() )
292 trace.
error() <<
"[Shortcuts::makeImplicitShape3D]"
293 <<
" ERROR reading polynomial: I read only <"
294 << poly_str.substr( 0, iter - poly_str.begin() )
295 <<
">, and I built P=" << poly << std::endl;
314 (
"gridsizez", 1.0 );
332 int closed = params[
"closed" ].as<
int>();
334 if ( !
K.init( low, up, closed ) )
336 <<
" Error building Khalimsky space K=" <<
K << std::endl;
354 int closed = params[
"closed" ].as<
int>();
356 if ( !
K.init( bimage->domain().lowerBound(),
357 bimage->domain().upperBound(),
360 <<
" Error building Khalimsky space K=" <<
K << std::endl;
378 int closed = params[
"closed" ].as<
int>();
380 if ( !
K.init( gimage->domain().lowerBound(),
381 gimage->domain().upperBound(),
384 <<
" Error building Khalimsky space K=" <<
K << std::endl;
391 template <
typename TDigitalSurfaceContainer>
396 return surface->container().space();
402 template <
typename TDigitalSurfaceContainer>
407 return surface->container().space();
413 template <
typename TDigitalSurfaceContainer>
418 return surface->container().space();
424 template <
typename TDigitalSurfaceContainer>
429 return surface->container().space();
490 bool closed = params[
"closed" ].as<
int>();
491 RealPoint p1( min_x - offset * h, min_x - offset * h, min_x - offset * h );
492 RealPoint p2( max_x + offset * h, max_x + offset * h, max_x + offset * h );
494 dshape->init( p1, p2, h );
499 <<
" Error building Khalimsky space K=" <<
K << std::endl
500 <<
"Note: if you use decimal values, check your locale for decimal point '.' or ','."
527 RealPoint p1( min_x - offset * h, min_x - offset * h, min_x - offset * h );
528 RealPoint p2( max_x + offset * h, max_x + offset * h, max_x + offset * h );
530 dshape->attach( shape );
531 dshape->init( p1, p2, h );
548 (
"thresholdMin", 0 )
549 (
"thresholdMax", 255 );
577 shape_digitization->getDomain(),
601 std::transform( shapeDomain.
begin(), shapeDomain.
end(),
603 [&shape_digitization]
604 (
const Point& p ) { return (*shape_digitization)(p); } );
609 KanungoPredicate noisy_dshape( *shape_digitization, shapeDomain, noise );
610 std::transform( shapeDomain.
begin(), shapeDomain.
end(),
612 [&noisy_dshape] (
const Point& p ) { return noisy_dshape(p); } );
629 if ( noise <= 0.0 )
return bimage;
631 const Domain shapeDomain = bimage->domain();
633 KanungoPredicate noisy_dshape( *bimage, shapeDomain, noise );
634 std::transform( shapeDomain.
begin(), shapeDomain.
end(),
636 [&noisy_dshape] (
const Point& p ) { return noisy_dshape(p); } );
656 int thresholdMin = params[
"thresholdMin"].as<
int>();
657 int thresholdMax = params[
"thresholdMax"].as<
int>();
661 ThresholdedImage tImage(
image, thresholdMin, thresholdMax );
665 [tImage] (
const Point& p ) { return tImage(p); } );
675 template<
typename T,
template<
class...>
class C,
template<
class...>
class D>
688 template<
typename T,
typename __U = std::enable_if_t<std::is_arithmetic_v<T>>>
691 (
const std::vector<T>& values,
697 for (
auto it = d.
begin(); it != d.
end(); ++i, ++it)
699 image->setValue(*it,
static_cast<bool>(values[i]));
716 template<
class...>
class C1,
717 template<
class...>
class C2,
718 template<
class...>
class C3>
721 (
const C1<C2<C3<T>>>& values,
722 std::optional<Domain> override_domain = std::nullopt)
725 if (override_domain.has_value())
727 d = override_domain.value();
729 else if (values.size() != 0)
731 if (values[0].size() != 0)
733 if (values[0][0].size() != 0)
735 d =
Domain(
Point(0, 0, 0),
Point(values.size(), values[0].size(), values[0][0].size()));
742 for (
size_t i = 0; i < values.size(); ++i)
744 for (
size_t j = 0; j < values[i].size(); ++j)
746 for (
size_t k = 0; k < values[i][j].size(); ++k)
749 image->setValue(p,
static_cast<bool>(values[i][j][k]));
765 template<typename T, std::enable_if_t<!is_double_nested_container<T>::value,
int> = 0>
768 (
const std::vector<T>& positions,
769 std::optional<Domain> override_domain = std::nullopt)
772 if (override_domain.has_value())
774 d = override_domain.value();
776 else if (positions.size() != 0)
778 Point lb(positions[0][0], positions[0][1], positions[0][2]);
779 Point ub(positions[0][0], positions[0][1], positions[0][2]);
781 for (
size_t i = 0; i < positions.size(); ++i)
783 lb[0] = std::min(lb[0],
static_cast<typename
Point::Component>(positions[i][0]));
784 lb[1] = std::min(lb[1],
static_cast<typename
Point::Component>(positions[i][1]));
785 lb[2] = std::min(lb[2],
static_cast<typename
Point::Component>(positions[i][2]));
787 ub[0] = std::max(ub[0],
static_cast<typename
Point::Component>(positions[i][0]));
788 ub[1] = std::max(ub[1],
static_cast<typename
Point::Component>(positions[i][1]));
789 ub[2] = std::max(ub[2],
static_cast<typename
Point::Component>(positions[i][2]));
796 for (
size_t i = 0; i < positions.size(); ++i)
799 Point p({positions[i][0], positions[i][1], positions[i][2]});
800 image->setValue(p,
true);
821 int thresholdMin = params[
"thresholdMin"].as<
int>();
822 int thresholdMax = params[
"thresholdMax"].as<
int>();
825 ThresholdedImage tImage( *gray_scale_image, thresholdMin, thresholdMax );
829 [tImage] (
const Point& p ) { return tImage(p); } );
882 ( std::string input )
897 std::function<
GrayScale(
bool ) >
const & bool2grayscale
898 = [] (
bool v ) {
return v ? (
unsigned char) 255 : (
unsigned char) 0; }
905 gray_scale_image->begin(),
907 return gray_scale_image;
940 float qShift = params[
"qShift" ].as<
float>();
941 float qSlope = params[
"qSlope" ].as<
float>();
942 std::function<
unsigned char(
float ) > f
943 = [qShift,qSlope] (
float v)
944 {
return (
unsigned char) std::min( 255.0f, std::max( 0.0f, qSlope * v + qShift ) ); };
947 auto it = gimage->begin();
950 float val = (*fimage)( p );
972 double qShift = params[
"qShift" ].as<
double>();
973 double qSlope = params[
"qSlope" ].as<
double>();
974 std::function<
unsigned char(
double ) > f
975 = [qShift,qSlope] (
double v)
976 {
return (
unsigned char) std::min( 255.0, std::max( 0.0, qSlope * v + qShift ) ); };
979 auto it = gimage->begin();
982 double val = (*fimage)( p );
997 template<
typename T,
typename __U = std::enable_if_t<std::is_arithmetic_v<T>>>
1000 (
const std::vector<T>& values,
1006 for (
auto it = d.
begin(); it != d.
end(); ++i, ++it)
1024 template<
class...>
class C1,
1025 template<
class...>
class C2,
1026 template<
class...>
class C3>
1029 (
const C1<C2<C3<T>>>& values,
1030 std::optional<Domain> override_domain = std::nullopt)
1033 if (override_domain.has_value())
1035 d = override_domain.value();
1037 else if (values.size() != 0)
1039 if (values[0].size() != 0)
1041 if (values[0][0].size() != 0)
1043 d =
Domain(
Point(0, 0, 0),
Point(values.size(), values[0].size(), values[0][0].size()));
1050 for (
size_t i = 0; i < values.size(); ++i)
1052 for (
size_t j = 0; j < values[i].size(); ++j)
1054 for (
size_t k = 0; k < values[i][j].size(); ++k)
1074 template<typename T, typename U, std::enable_if_t<!is_double_nested_container<T>::value,
int> = 0>
1077 (
const std::vector<T>& positions,
1078 const std::vector<U>& values,
1079 std::optional<Domain> override_domain = std::nullopt)
1082 if (override_domain.has_value())
1084 d = override_domain.value();
1086 else if (positions.size() != 0)
1088 Point lb(positions[0][0], positions[0][1], positions[0][2]);
1089 Point ub(positions[0][0], positions[0][1], positions[0][2]);
1091 for (
size_t i = 0; i < positions.size(); ++i)
1093 lb[0] = std::min(lb[0],
static_cast<typename
Point::Component>(positions[i][0]));
1094 lb[1] = std::min(lb[1],
static_cast<typename
Point::Component>(positions[i][1]));
1095 lb[2] = std::min(lb[2],
static_cast<typename
Point::Component>(positions[i][2]));
1097 ub[0] = std::max(ub[0],
static_cast<typename
Point::Component>(positions[i][0]));
1098 ub[1] = std::max(ub[1],
static_cast<typename
Point::Component>(positions[i][1]));
1099 ub[2] = std::max(ub[2],
static_cast<typename
Point::Component>(positions[i][2]));
1106 for (
size_t i = 0; i < positions.size(); ++i)
1109 Point p({positions[i][0], positions[i][1], positions[i][2]});
1138 ( std::string input )
1166 RealPoint p1( min_x - offset * h, min_x - offset * h, min_x - offset * h );
1167 RealPoint p2( max_x + offset * h, max_x + offset * h, max_x + offset * h );
1169 dshape->attach( shape );
1170 dshape->init( p1, p2, h );
1173 auto it = fimage->begin();
1176 float val = (float) (*shape)( p );
1204 ( std::string input )
1232 RealPoint p1( min_x - offset * h, min_x - offset * h, min_x - offset * h );
1233 RealPoint p2( max_x + offset * h, max_x + offset * h, max_x + offset * h );
1235 dshape->attach( shape );
1236 dshape->init( p1, p2, h );
1239 auto it = fimage->begin();
1242 double val = (double) (*shape)( p );
1260 (
"surfelAdjacency", 0 )
1261 (
"nbTriesToFindABel", 100000 )
1262 (
"surfaceComponents",
"AnyBig" )
1263 (
"surfaceTraversal",
"Default" );
1269 template <
typename TDigitalSurfaceContainer>
1280 template <
typename TDigitalSurfaceContainer>
1291 template <
typename TDigitalSurfaceContainer>
1302 template <
typename TDigitalSurfaceContainer>
1327 bool surfel_adjacency = params[
"surfelAdjacency" ].as<
int>();
1328 int nb_tries_to_find_a_bel = params[
"nbTriesToFindABel" ].as<
int>();
1334 Scalar minsize = bimage->extent().norm();
1335 unsigned int nb_surfels = 0;
1336 unsigned int tries = 0;
1342 trace.
error() <<
"[Shortcuts::makeLightDigitalSurface]"
1343 <<
" ERROR Unable to find bel. " << e << std::endl;
1351 nb_surfels = ptrSurface->size();
1353 while ( ( nb_surfels < 2 * minsize ) && ( tries++ < 150 ) );
1355 trace.
warning() <<
"[Shortcuts::makeLightDigitalSurface]"
1356 <<
"ERROR cannot find a proper bel in a big enough component."
1378 static std::vector< CountedPtr<LightDigitalSurface> >
1408 static std::vector< CountedPtr<LightDigitalSurface> >
1415 std::vector< CountedPtr<LightDigitalSurface> > result;
1416 std::string component = params[
"surfaceComponents" ].as<std::string>();
1417 if ( component ==
"AnyBig" )
1420 surfel_reps.push_back( *( result[ 0 ]->begin() ) );
1423 bool surfel_adjacency = params[
"surfelAdjacency" ].as<
int>();
1428 K.lowerBound(),
K.upperBound() );
1432 for (
auto bel : all_surfels )
1434 if ( marked_surfels.count( bel ) != 0 )
continue;
1435 surfel_reps.push_back( bel );
1441 marked_surfels.insert( ptrSurface->begin(), ptrSurface->end() );
1443 result.push_back( ptrSurface );
1467 template <
typename TPo
intPredicate>
1475 bool surfel_adjacency = params[
"surfelAdjacency" ].as<
int>();
1479 K.lowerBound(),
K.upperBound() );
1504 bool surfel_adjacency = params[
"surfelAdjacency" ].as<
int>();
1507 auto all_idx_surfels
1509 auto idx2surfel = idx_surface->surfels();
1511 for (
auto idx : all_idx_surfels ) all_surfels.insert( idx2surfel[ idx ] );
1540 std::string component = params[
"surfaceComponents" ].as<std::string>();
1542 if ( component ==
"AnyBig" )
1545 surfels.insert( light_surface->begin(), light_surface->end() );
1547 else if ( component ==
"All" )
1550 K.lowerBound(),
K.upperBound() );
1566 template <
typename TSurfelRange>
1569 (
const TSurfelRange& surfels,
1573 bool surfel_adjacency = params[
"surfelAdjacency" ].as<
int>();
1580 bool ok = ptrSurface->build( ptrSurfContainer );
1582 trace.
warning() <<
"[Shortcuts::makeIdxDigitalSurface]"
1583 <<
" Error building indexed digital surface." << std::endl;
1599 template <
typename TDigitalSurfaceContainer>
1629 const KSpace&
K = surfaces[ 0 ]->container().space();
1631 for ( std::size_t i = 0; i < surfaces.size(); ++i )
1633 const KSpace& Ki = surfaces[ i ]->container().space();
1634 if ( ( Ki.lowerBound() !=
K.lowerBound() )
1635 || ( Ki.upperBound() !=
K.upperBound() ) )
1636 trace.
warning() <<
"[Shortcuts::makeIdxDigitalSurface]"
1637 <<
" Incompatible digital spaces for surface " << i << std::endl;
1638 surfels.insert( surfaces[ i ]->begin(), surfaces[ i ]->end() );
1657 template <
typename TDigitalSurfaceContainer>
1666 result.reserve( 2 *
surface->size() + 100 );
1669 for (
auto&& surfel : *
surface )
1672 for (
auto&& primal_cell : primal_cells )
1674 if ( ! c2i.count( primal_cell ) )
1676 result.push_back( primal_cell );
1677 c2i[ primal_cell ] = n++;
1696 template <
typename TDigitalSurfaceContainer>
1727 template <
typename TDigitalSurfaceContainer>
1734 result.reserve(
surface->size() );
1737 for (
auto&& surfel : *
surface )
1740 for (
auto&& primal_vtx : primal_vtcs )
1742 if ( ! c2i.count( primal_vtx ) )
1744 result.push_back( primal_vtx );
1745 c2i[ primal_vtx ] = n++;
1768 template <
typename TDigitalSurfaceContainer>
1805 template <
typename TDigitalSurfaceContainer>
1828 template <
typename TDigitalSurfaceContainer>
1832 const Surfel& start_surfel,
1835 typedef ::DGtal::DigitalSurface<TDigitalSurfaceContainer> AnyDigitalSurface;
1837 std::string traversal = params[
"surfaceTraversal" ].as<std::string>();
1838 if ( traversal ==
"DepthFirst" )
1843 std::for_each( range.begin(), range.end(),
1844 [&result] (
Surfel s ) { result.push_back( s ); } );
1846 else if ( traversal ==
"BreadthFirst" )
1851 std::for_each( range.begin(), range.end(),
1852 [&result] (
Surfel s ) { result.push_back( s ); } );
1857 [&result] (
Surfel s ) { result.push_back( s ); } );
1898 std::string traversal = params[
"surfaceTraversal" ].as<std::string>();
1899 if ( traversal ==
"DepthFirst" )
1904 std::for_each( range.begin(), range.end(),
1905 [&result] (
IdxSurfel s ) { result.push_back( s ); } );
1907 else if ( traversal ==
"BreadthFirst" )
1912 std::for_each( range.begin(), range.end(),
1913 [&result] (
IdxSurfel s ) { result.push_back( s ); } );
1915 else return surface->allVertices();
1930 template <
typename TDigitalSurfaceContainer,
1931 typename TCellEmbedder>
1935 const TCellEmbedder& embedder,
1936 std::string off_file,
1942 std::ofstream output_off( off_file.c_str() );
1943 output_off <<
"OFF" << std::endl;
1944 output_off <<
"# Generated from DGtal::Shortcuts from the DGTal library" << std::endl;
1947 output_off << pointels.size() <<
" " << digsurf->size() <<
" " << 0 <<
" " << std::endl;
1952 for (
auto&& pointel : pointels )
1955 output_off << p[ 0 ] <<
" " << p[ 1 ] <<
" " << p[ 2 ] << std::endl;
1959 for (
auto&& surfel : *digsurf )
1962 output_off << primal_vtcs.size();
1964 for (
auto&& primal_vtx : primal_vtcs )
1965 output_off <<
" " << (c2i[ primal_vtx ]);
1970 output_off << face_color.r() <<
" " << face_color.g()
1971 <<
" " << face_color.b() <<
" " << face_color.a();
1973 output_off << std::endl;
1975 return output_off.good();
1996 template <
typename TDigitalSurfaceContainer,
1997 typename TCellEmbedder>
2001 const TCellEmbedder& embedder,
2003 const Colors& diffuse_colors,
2004 std::string objfile,
2005 const Color& ambient_color =
Color( 32, 32, 32 ),
2006 const Color& diffuse_color =
Color( 200, 200, 255 ),
2010 std::string mtlfile;
2011 auto lastindex = objfile.find_last_of(
".");
2012 if ( lastindex == std::string::npos )
2014 mtlfile = objfile +
".mtl";
2015 objfile = objfile +
".obj";
2019 mtlfile = objfile.substr(0, lastindex) +
".mtl";
2022 std::ofstream output_obj( objfile.c_str() );
2023 output_obj <<
"# OBJ format" << std::endl;
2024 output_obj <<
"# DGtal::MeshHelpers::exportOBJwithFaceNormalAndColor" << std::endl;
2025 output_obj <<
"o anObject" << std::endl;
2027 auto indexpath = objfile.find_last_of(
"/");
2028 output_obj <<
"mtllib " << mtlfile.substr(indexpath+1) << std::endl;
2029 std::ofstream output_mtl( mtlfile.c_str() );
2030 output_mtl <<
"# MTL format"<< std::endl;
2031 output_mtl <<
"# generated from MeshWriter from the DGTal library"<< std::endl;
2036 for (
auto&& pointel : pointels )
2039 output_obj <<
"v " << p[ 0 ] <<
" " << p[ 1 ] <<
" " << p[ 2 ] << std::endl;
2042 Idx nbfaces = digsurf->
size();
2043 bool has_normals = ( nbfaces == normals.size() );
2046 for (
Idx f = 0; f < nbfaces; ++f )
2048 const auto& p = normals[ f ];
2049 output_obj <<
"vn " << p[ 0 ] <<
" " << p[ 1 ] <<
" " << p[ 2 ] << std::endl;
2053 bool has_material = ( nbfaces == diffuse_colors.size() );
2054 Idx idxMaterial = 0;
2055 std::map<Color, Idx > mapMaterial;
2058 for (
Idx f = 0; f < nbfaces; ++f )
2060 Color c = diffuse_colors[ f ];
2061 if ( mapMaterial.count( c ) == 0 )
2064 ( output_mtl, idxMaterial, ambient_color, c, specular_color );
2065 mapMaterial[ c ] = idxMaterial++;
2072 ( output_mtl, idxMaterial, ambient_color, diffuse_color, specular_color );
2077 for (
auto&& surfel : *digsurf )
2079 output_obj <<
"usemtl material_"
2080 << ( has_material ? mapMaterial[ diffuse_colors[ f ] ] : idxMaterial )
2087 for (
auto&& primal_vtx : primal_vtcs )
2088 output_obj <<
" " << (c2i[ primal_vtx ]+1) <<
"//" << (f+1);
2092 for (
auto&& primal_vtx : primal_vtcs )
2093 output_obj <<
" " << (c2i[ primal_vtx ]+1);
2095 output_obj << std::endl;
2099 return output_obj.good();
2117 template <
typename TDigitalSurfaceContainer>
2122 const Colors& diffuse_colors,
2123 std::string objfile,
2124 const Color& ambient_color =
Color( 32, 32, 32 ),
2125 const Color& diffuse_color =
Color( 200, 200, 255 ),
2129 return saveOBJ( digsurf, embedder, normals, diffuse_colors, objfile,
2130 ambient_color, diffuse_color, specular_color );
2146 template <
typename TDigitalSurfaceContainer>
2150 std::string off_file,
2151 const Color& face_color =
Color( 32, 32, 32 ))
2154 return saveOFF( digsurf, embedder, off_file, face_color);
2168 template <
typename TDigitalSurfaceContainer>
2172 std::string objfile,
2173 const Color& ambient_color =
Color( 32, 32, 32 ),
2174 const Color& diffuse_color =
Color( 200, 200, 255 ),
2179 ambient_color, diffuse_color, specular_color );
2203 const Colors& diffuse_colors,
2204 std::string objfile,
2205 const Color& ambient_color =
Color( 32, 32, 32 ),
2206 const Color& diffuse_color =
Color( 200, 200, 255 ),
2210 std::string mtlfile;
2211 auto lastindex = objfile.find_last_of(
".");
2212 if ( lastindex == std::string::npos )
2214 mtlfile = objfile +
".mtl";
2215 objfile = objfile +
".obj";
2219 mtlfile = objfile.substr(0, lastindex) +
".mtl";
2221 std::ofstream output_obj( objfile.c_str() );
2222 output_obj <<
"# OBJ format" << std::endl;
2223 output_obj <<
"# DGtal::saveOBJ" << std::endl;
2224 output_obj <<
"o vectors" << std::endl;
2225 output_obj <<
"mtllib " << mtlfile << std::endl;
2226 std::ofstream output_mtl( mtlfile.c_str() );
2227 output_mtl <<
"# MTL format"<< std::endl;
2228 output_mtl <<
"# generated from MeshWriter from the DGTal library"<< std::endl;
2230 auto n = std::min( positions.size(), vf.size() );
2231 for (
unsigned int i = 0; i < n; ++i )
2237 auto mc = std::max_element( absv.
begin(), absv.
end() ) - absv.
begin();
2243 RealPoint t[4] = { thickness * e0, thickness * e1,
2244 -thickness * e0, -thickness * e1 };
2245 for (
unsigned int j = 0; j < 4; ++j ) {
2248 output_obj <<
"v " << pt0[ 0 ] <<
" " << pt0[ 1 ] <<
" " << pt0[ 2 ]
2250 output_obj <<
"v " << pt1[ 0 ] <<
" " << pt1[ 1 ] <<
" " << pt1[ 2 ]
2255 std::map<Color,Idx> map_colors;
2258 for (
auto && c : diffuse_colors )
2259 if ( ! map_colors.count( c ) )
2260 map_colors[ c ] = j++;
2264 bool has_material = ! diffuse_colors.empty();
2266 for (
auto&& pair : map_colors )
2268 ( output_mtl, pair.second, ambient_color, pair.first, specular_color);
2271 ( output_mtl, 0, ambient_color, diffuse_color, specular_color );
2273 for (
Idx i = 0; i < n; ++i )
2275 output_obj <<
"usemtl material_"
2276 << ( has_material ? map_colors[ diffuse_colors[ i ] ] : 0 )
2279 for (
Idx j = 0; j < 8; j += 2 )
2280 output_obj <<
"f " << (b+j) <<
" " << (b+j+1)
2281 <<
" " << (b+(j+3)%8) <<
" " << (b+(j+2)%8) << std::endl;
2282 output_obj <<
"f " << b <<
" " << (b+2)
2283 <<
" " << (b+4) <<
" " << (b+6) << std::endl;
2284 output_obj <<
"f " << (b+1) <<
" " << (b+7)
2285 <<
" " << (b+5) <<
" " << (b+3) << std::endl;
2288 return output_obj.good();
2300 (
"faceSubdivision",
"Centroid" );
2363 template <
typename TContainer >
2372 ( *aSurface, embedder, *pTriSurf, s2i );
2381 template <
typename TContainer >
2410 std::string faceSubdivision = params[
"faceSubdivision" ].as<std::string>();
2411 bool centroid = ( faceSubdivision ==
"Centroid" );
2458 RealVector gh = { params[
"gridsizex" ].as<
double>(),
2459 params[
"gridsizey" ].as<double>(),
2460 params[
"gridsizez" ].as<
double>() };
2461 double threshold = params[
"thresholdMin" ].as<
double>() + 0.5;
2465 PointEmbedder pembedder;
2466 pembedder.
init( gh );
2467 ImageCellEmbedder cembedder;
2468 cembedder.init(
K, *gray_scale_image, pembedder, threshold );
2473 ( *digSurf, cembedder, *pPolySurf, s2i );
2501 RealVector gh = { params[
"gridsizex" ].as<
double>(),
2502 params[
"gridsizey" ].as<double>(),
2503 params[
"gridsizez" ].as<
double>() };
2504 double threshold = params[
"thresholdMin" ].as<
double>() + 0.5;
2508 PointEmbedder pembedder;
2509 pembedder.
init( gh );
2510 ImageCellEmbedder cembedder;
2511 cembedder.init(
K, *gray_scale_image, pembedder, threshold );
2516 ( *digSurf, cembedder, *pPolySurf, s2i );
2527 template <
typename TContainer >
2537 ( *aSurface, embedder, *pPolySurf, s2i );
2547 template <
typename TContainer >
2561 template <
typename TContainer >
2569 aSurface->positions().storage() ) );
2580 template <
typename TContainer >
2590 ( *aSurface, embedder, *pPolySurf, c2i );
2600 template <
typename TContainer >
2614 template <
typename TContainer >
2631 template <
typename TContainer >
2649 template <
typename TContainer >
2663 template <
typename TContainer >
2679 std::ifstream file(path);
2699 template <
typename TPo
int,
typename TVector>
2703 const std::string& objfile )
2705 std::ofstream output( objfile.c_str() );
2717 template <
typename TPo
int>
2721 const std::string& objfile )
2723 std::ofstream output( objfile.c_str() );
2737 template <
typename TPo
int>
2740 std::string off_file,
2746 std::ofstream output( off_file.c_str() );
2747 for (
unsigned int i=0; i< m.
nbFaces(); i++)
2762 template <
typename TPo
int>
2766 const std::string& objfile )
2768 std::ofstream output( objfile.c_str() );
2786 template <
typename TPo
int>
2791 const Colors& diffuse_colors,
2792 std::string objfile,
2793 const Color& ambient_color =
Color( 32, 32, 32 ),
2794 const Color& diffuse_color =
Color( 200, 200, 255 ),
2797 std::string mtlfile;
2798 auto lastindex = objfile.find_last_of(
".");
2799 if ( lastindex == std::string::npos )
2801 mtlfile = objfile +
".mtl";
2802 objfile = objfile +
".obj";
2806 mtlfile = objfile.substr(0, lastindex) +
".mtl";
2808 std::ofstream output( objfile.c_str() );
2810 ( output, mtlfile, *polysurf, normals, diffuse_colors,
2811 ambient_color, diffuse_color, specular_color );
2828 template <
typename TPo
int>
2833 const Colors& diffuse_colors,
2834 std::string objfile,
2835 const Color& ambient_color =
Color( 32, 32, 32 ),
2836 const Color& diffuse_color =
Color( 200, 200, 255 ),
2839 std::string mtlfile;
2840 auto lastindex = objfile.find_last_of(
".");
2841 if ( lastindex == std::string::npos )
2843 mtlfile = objfile +
".mtl";
2844 objfile = objfile +
".obj";
2848 mtlfile = objfile.substr(0, lastindex) +
".mtl";
2850 std::ofstream output( objfile.c_str() );
2852 ( output, mtlfile, *trisurf, normals, diffuse_colors,
2853 ambient_color, diffuse_color, specular_color );
2871 template <
typename TPo
int,
typename TVector>
2876 const Colors& diffuse_colors,
2877 std::string objfile,
2878 const Color& ambient_color =
Color( 32, 32, 32 ),
2879 const Color& diffuse_color =
Color( 200, 200, 255 ),
2882 std::string mtlfile;
2883 auto lastindex = objfile.find_last_of(
".");
2884 if ( lastindex == std::string::npos )
2886 mtlfile = objfile +
".mtl";
2887 objfile = objfile +
".obj";
2891 mtlfile = objfile.substr(0, lastindex) +
".mtl";
2893 std::ofstream output( objfile.c_str() );
2895 ( output, mtlfile, *surf, normals, diffuse_colors,
2896 ambient_color, diffuse_color, specular_color );
2909 template <
typename TPo
int>
2912 std::string off_file,
2918 std::ofstream output( off_file.c_str() );
2919 for (
unsigned int i=0; i< m.
nbFaces(); i++)
2939 (
"colormap",
"Custom" )
2940 (
"zero-tic", 0.0 );
2959 template <
typename TValue>
2961 getRangeMatch(
const std::vector< TValue >& s1,
const std::vector< TValue >& s2,
2962 bool perfect =
false )
2964 if ( perfect && ( s1.size() != s2.size() ) )
return IdxRange();
2965 std::map<TValue, Idx> M;
2967 for (
auto val : s2 ) M[ val ] = idx++;
2970 for (
auto val : s1 )
2972 auto it = M.find( val );
2973 if ( it != M.end() ) V[ idx++ ] = it->second;
2977 V[ idx++ ] = s2.size();
2994 template <
typename TValue>
2995 static std::vector< TValue >
2998 std::vector< TValue > result( match.size() );
2999 for (
Idx i = 0; i < result.size(); i++ )
3000 result[ i ] = range[ match[ i ] ];
3015 std::string cmap = params[
"colormap" ].as<std::string>();
3024 else if ( cmap ==
"Error" )
3054 auto ztic = params[
"zero-tic" ].as<
double>();
3056 if ( ztic <= 0.0 )
return ztic_cmap;
3057 if ( min <= 0.0 && 0.0 <=
max )
3058 ztic_cmap.addTick( 0.0, ztic );
3059 ztic_cmap.finalize();
3072 template <
typename TCellEmbedder = CanonicCellEmbedder< KSpace > >
3075 ( std::ostream& output,
3077 const TCellEmbedder& embedder )
3079 typedef unsigned long Size;
3082 const KSpace&
K = embedder.space();
3084 std::map< Cell, Size > vtx_numbering;
3086 for (
auto&& s : surfels )
3089 for (
auto&& primal_vtx : primal_vtcs )
3091 if ( ! vtx_numbering.count( primal_vtx ) )
3093 vtx_numbering[ primal_vtx ] = n++;
3096 output <<
"v " << p[ 0 ] <<
" " << p[ 1 ] <<
" " << p[ 2 ] << std::endl;
3101 for (
auto&& s : surfels )
3105 for (
auto&& primal_vtx : primal_vtcs )
3106 output <<
" " << vtx_numbering[ primal_vtx ];
3107 output << std::endl;
3109 return output.good();
3123 template <
typename TAnyDigitalSurface>
3126 ( std::ostream& output,
3150 template <
typename TAnyDigitalSurface,
3154 ( std::ostream& output,
3156 const TCellEmbedder& embedder )
3172 ( std::ostream& output,
3192 template <
typename TCellEmbedder = CanonicCellEmbedder< KSpace > >
3195 ( std::ostream& output,
3197 const TCellEmbedder& embedder )
3200 auto surfelmap =
surface->surfels();
3202 for (
auto&& idx : idxsurfels )
3203 surfels.push_back( surfelmap[ idx ] );
3223 template <
typename TDigitalSurfaceContainer>
3226 ( std::ostream& output,
3256 template <
typename TDigitalSurfaceContainer,
3260 ( std::ostream& output,
3262 const TCellEmbedder& embedder,
3265 typedef unsigned long Size;
3268 std::string dualFaceSubdivision = params[
"faceSubdivision" ].as<std::string>();
3270 = dualFaceSubdivision ==
"Naive" ? 1
3271 : dualFaceSubdivision ==
"Centroid" ? 2
3273 const KSpace&
K = embedder.space();
3275 std::map< Vertex, Size > vtx_numbering;
3276 std::map< Face, Size > sub_numbering;
3280 if ( ! vtx_numbering.count( s ) )
3282 vtx_numbering[ s ] = n++;
3285 output <<
"v " << p[ 0 ] <<
" " << p[ 1 ] <<
" " << p[ 2 ] << std::endl;
3288 auto faces =
surface->allClosedFaces();
3290 if ( subdivide == 2 )
3292 for (
auto&& f : faces )
3294 auto vtcs =
surface->verticesAroundFace( f );
3295 Size nv = vtcs.size();
3298 sub_numbering[ f ] = n++;
3300 for (
auto&& s : vtcs ) p += embedder(
K.unsigns( s ) );
3302 output <<
"v " << p[ 0 ] <<
" " << p[ 1 ] <<
" " << p[ 2 ] << std::endl;
3307 if ( subdivide == 0 )
3309 for (
auto&& f : faces )
3312 auto vtcs =
surface->verticesAroundFace( f );
3313 std::reverse( vtcs.begin(), vtcs.end() );
3314 for (
auto&& s : vtcs )
3315 output <<
" " << vtx_numbering[ s ];
3316 output << std::endl;
3319 else if ( subdivide == 1 )
3321 for (
auto&& f : faces )
3323 auto vtcs =
surface->verticesAroundFace( f );
3324 Size nv = vtcs.size();
3325 for (
Size i = 1; i < nv - 1; ++i )
3326 output <<
"f " << vtx_numbering[ vtcs[ 0 ] ]
3327 <<
" " << vtx_numbering[ vtcs[ i+1 ] ]
3328 <<
" " << vtx_numbering[ vtcs[ i ] ] << std::endl;
3331 else if ( subdivide == 2 )
3333 for (
auto&& f : faces )
3335 auto vtcs =
surface->verticesAroundFace( f );
3336 Size nv = vtcs.size();
3338 output <<
"f " << vtx_numbering[ vtcs[ 0 ] ]
3339 <<
" " << vtx_numbering[ vtcs[ 2 ] ]
3340 <<
" " << vtx_numbering[ vtcs[ 1 ] ] << std::endl;
3342 Size c = sub_numbering[ f ];
3343 for (
Size i = 0; i < nv; ++i )
3346 <<
" " << vtx_numbering[ vtcs[ (i+1)%nv ] ]
3347 <<
" " << vtx_numbering[ vtcs[ i ] ] << std::endl;
3352 return output.good();
3362 output <<
" " <<
K.sKCoord( cell, d );
3371 return K.uCell( kp );
3378 output <<
" " <<
K.sSign( scell );
3389 return K.sCell( kp, s );
3393 template <
typename Value>
3399 void operator()( std::ostream& output,
const std::vector<Value>& vv )
3401 for (
auto&& v : vv ) output <<
" " << v;
3405 template <
typename Value>
3410 std::getline( input, str );
3412 std::stringstream strstr(str);
3414 std::istream_iterator<std::string> it(strstr);
3415 std::istream_iterator<std::string> end;
3416 std::vector<std::string> results(it, end);
3417 std::stringstream sstr( results[ 0 ] );
3419 return ( results.size() == 1 ) && input.good();
3422 bool operator()( std::istream& input, std::vector<Value>& values )
3425 std::getline( input, str );
3427 std::stringstream strstr(str);
3429 std::istream_iterator<std::string> it(strstr);
3430 std::istream_iterator<std::string> end;
3431 std::vector<std::string> results(it, end);
3432 values.resize( results.size() );
3433 for (
unsigned int i = 0; i < results.size(); ++i ) {
3434 std::stringstream sstr( results[ i ] );
3435 sstr >> values[ i ];
3437 return input.good();
3453 template <
typename TSCellMap,
typename TValueWriter>
3456 ( std::ostream& output,
3458 const TSCellMap& anyMap,
3459 const TValueWriter& writer )
3462 for (
auto&& v : anyMap )
3464 w( output,
K, v.first );
3465 writer( output, v.second );
3466 output << std::endl;
3468 return output.good();
3483 template <
typename TCellMap,
typename TValueWriter>
3486 ( std::ostream& output,
3488 const TCellMap& anyMap,
3489 const TValueWriter& writer )
3492 for (
auto&& v : anyMap )
3494 w( output,
K, v.first );
3495 writer( output, v.second );
3496 output << std::endl;
3498 return output.good();
3509 auto faces =
K.uFaces(
K.unsigns( s ) );
3511 for (
auto&& f : faces )
3513 if (
K.uDim( f ) == k ) primal_cells.push_back( f );
3515 return primal_cells;
3539 std::swap( vtcs[ 2 ], vtcs[ 3 ] );
3540 auto orth_dir =
K.sOrthDir( s );
3541 auto direct =
K.sDirect( s, orth_dir ) ? ccw : ! ccw;
3542 Vector s0s1 =
K.uCoords( vtcs[ 1 ] ) -
K.uCoords( vtcs[ 0 ] );
3543 Vector s0s2 =
K.uCoords( vtcs[ 2 ] ) -
K.uCoords( vtcs[ 0 ] );
3545 if ( ( ( t[ orth_dir ] > 0.0 ) && direct )
3546 || ( ( t[ orth_dir ] < 0.0 ) && ! direct ) )
3547 std::reverse( vtcs.begin(), vtcs.end() );
3600 out <<
"[Shortcuts]";
3633 template <
typename T>
3648#undef Shortcuts_RECURSES
Aim: This class is useful to perform a breadth-first exploration of a graph given a starting point or...
Structure representing an RGB triple with alpha component.
Aim: This class encapsulates its parameter class so that to indicate to the user that the object/poin...
Aim: Smart pointer based on reference counts.
Aim: This class is useful to perform a depth-first exploration of a graph given a starting point or s...
Aim: Represents a set of n-1-cells in a nD space, together with adjacency relation between these cell...
DigitalSurfaceContainer::Surfel Surfel
DigitalSurfaceContainer::Cell Cell
Surfel Vertex
Defines the type for a vertex.
std::vector< Arc > ArcRange
The range of arcs is defined as a vector.
DigitalSurfaceContainer::SCell SCell
Aim: A class for computing the Gauss digitization of some Euclidean shape, i.e. its intersection with...
Aim: This class template may be used to (linearly) convert scalar values in a given range into a colo...
void addColor(const Color &color)
Aim: Transforms a graph visitor into a single pass input range.
Aim: Parallelepidec region of a digital space, model of a 'CDomain'.
const ConstIterator & begin() const
const Point & lowerBound() const
const Point & upperBound() const
const ConstIterator & end() const
Aim: a cellular embedder for images. (default constructible, copy constructible, assignable)....
void init(ConstAlias< KSpace > K, ConstAlias< Image > f, ConstAlias< Embedder > e, double iso_value)
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).
static const constexpr Dimension dimension
Aim: A model of CDigitalSurfaceContainer which defines the digital surface as the boundary of an impl...
Aim: This class converts a string polynomial expression in a multivariate polynomial.
Aim: Represents a multivariate polynomial, i.e. an element of , where K is some ring or field.
static bool exportOBJ(std::ostream &output, const TriangulatedSurface< Point > &trisurf)
static bool digitalSurface2PrimalSurfaceMesh(const DigitalSurface< DigitalSurfaceContainer > &dsurf, const CellEmbedder &cembedder, SurfaceMesh< typename CellEmbedder::Value, typename CellEmbedder::Value > &polysurf, CellMap &cellmap)
static bool digitalSurface2PrimalPolygonalSurface(const DigitalSurface< DigitalSurfaceContainer > &dsurf, const CellEmbedder &cembedder, PolygonalSurface< typename CellEmbedder::Value > &polysurf, CellMap &cellmap)
static bool mesh2TriangulatedSurface(const Mesh< Point > &mesh, TriangulatedSurface< Point > &trisurf)
static void polygonalSurface2TriangulatedSurface(const PolygonalSurface< Point > &polysurf, TriangulatedSurface< Point > &trisurf, bool centroid=true)
static bool exportMTLNewMaterial(std::ostream &output_mtl, unsigned long idxMaterial, const Color &ambient_color, const Color &diffuse_color, const Color &specular_color)
static void polygonalSurface2Mesh(const PolygonalSurface< Point > &polysurf, Mesh< Point > &mesh)
static 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.
TEuclideanRing Component
Type for Vector elements.
static Self zero
Static const for zero PointVector.
Aim: Represents a polygon mesh, i.e. a 2-dimensional combinatorial surface whose faces are (topologic...
Aim: A simple point embedder where grid steps are given for each axis. Note that the real point (0,...
Aim: A model of CDigitalSurfaceContainer which defines the digital surface as connected surfels....
Aim: This class is used to simplify shape and surface creation. With it, you can create new shapes an...
static Parameters parametersUtilities()
GradientColorMap< Scalar > ColorMap
static CountedPtr< BinaryImage > makeBinaryImage(CountedPtr< BinaryImage > bimage, Parameters params=parametersBinaryImage())
ImageContainerBySTLVector< Domain, bool > BinaryImage
defines a black and white image with (hyper-)rectangular domain.
static bool outputPrimalDigitalSurfaceAsObj(std::ostream &output, CountedPtr< TAnyDigitalSurface > surface, const TCellEmbedder &embedder)
Space::Vector Vector
Vector with integer coordinates.
static bool saveOBJ(CountedPtr< ::DGtal::TriangulatedSurface< TPoint > > trisurf, const RealVectors &normals, const Colors &diffuse_colors, std::string objfile, const Color &ambient_color=Color(32, 32, 32), const Color &diffuse_color=Color(200, 200, 255), const Color &specular_color=Color::White)
static CountedPtr< DoubleImage > makeDoubleImage(Domain aDomain)
LightDigitalSurface::ArcRange ArcRange
static KSpace getKSpace(CountedPtr< BinaryImage > bimage, Parameters params=parametersKSpace())
static std::map< std::string, std::string > getPolynomialList()
static Parameters parametersImplicitShape3D()
static Parameters parametersKSpace()
static CountedPtr< TriangulatedSurface > makeTriangulatedSurface(CountedPtr< ::DGtal::DigitalSurface< TContainer > > aSurface)
static CountedPtr< DoubleImage > makeDoubleImage(std::string input)
LightDigitalSurface::Surfel Surfel
Space::RealPoint RealPoint
Point with floating-point coordinates.
static KSpace getKSpace(const Point &low, const Point &up, Parameters params=parametersKSpace())
SetOfSurfels< KSpace, SurfelSet > ExplicitSurfaceContainer
defines a heavy container that represents any digital surface.
LightDigitalSurface::Vertex Vertex
static KSpace getKSpace(Parameters params=parametersKSpace()|parametersDigitizedImplicitShape3D())
static bool saveOFF(CountedPtr< ::DGtal::PolygonalSurface< TPoint > > polysurf, std::string off_file, const Color &face_color=DGtal::Color::None)
static CountedPtr< DigitizedImplicitShape3D > makeDigitizedImplicitShape3D(CountedPtr< ImplicitShape3D > shape, Parameters params=parametersDigitizedImplicitShape3D())
std::map< Surfel, IdxSurfel > Surfel2Index
static bool outputCellMapAsCSV(std::ostream &output, const KSpace &K, const TCellMap &anyMap, const TValueWriter &writer)
static CountedPtr< DigitalSurface > makeDigitalSurface(CountedPtr< IdxDigitalSurface > idx_surface, const Parameters ¶ms=parametersDigitalSurface())
static bool outputPrimalIdxDigitalSurfaceAsObj(std::ostream &output, CountedPtr< IdxDigitalSurface > surface)
static CellRange getCellRange(Cell2Index &c2i, CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > surface, const Dimension k)
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
Floating-point numbers.
::DGtal::TriangulatedSurface< RealPoint > TriangulatedSurface
std::map< Cell, IdxVertex > Cell2Index
static bool outputDualDigitalSurfaceAsObj(std::ostream &output, CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > surface, const TCellEmbedder &embedder, const Parameters ¶ms=parametersMesh())
static CountedPtr< PolygonalSurface > makePolygonalSurface(CountedPtr< Mesh > aMesh)
ImageContainerBySTLVector< Domain, float > FloatImage
defines a float image with (hyper-)rectangular domain.
static bool saveGrayScaleImage(CountedPtr< GrayScaleImage > gray_scale_image, std::string output)
static PointelRange getPointelRange(Cell2Index &c2i, CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > surface)
static bool saveOFF(CountedPtr< ::DGtal::TriangulatedSurface< TPoint > > trisurf, std::string off_file, const Color &face_color=DGtal::Color::None)
::DGtal::SurfaceMesh< RealPoint, RealPoint > SurfaceMesh
Space::Point Point
Point with integer coordinates.
static CellRange getPrimalVertices(const KSpace &K, const Surfel &s, bool ccw)
static CellRange getPrimalCells(const KSpace &K, const SCell &s, const Dimension k)
static KSpace getKSpace(CountedPtr< GrayScaleImage > gimage, Parameters params=parametersKSpace())
static CountedPtr< BinaryImage > makeBinaryImage(const C1< C2< C3< T > > > &values, std::optional< Domain > override_domain=std::nullopt)
std::vector< Color > Colors
static Parameters parametersMesh()
static CountedPtr< Mesh > makeMesh(CountedPtr< TriangulatedSurface > triSurf, const Color &aColor=Color::White)
static CountedPtr< FloatImage > makeFloatImage(CountedPtr< ImplicitShape3D > shape, Parameters params=parametersDigitizedImplicitShape3D())
static bool saveOBJ(CountedPtr< ::DGtal::TriangulatedSurface< TPoint > > trisurf, const std::string &objfile)
static std::vector< CountedPtr< LightDigitalSurface > > makeLightDigitalSurfaces(SurfelRange &surfel_reps, CountedPtr< BinaryImage > bimage, const KSpace &K, const Parameters ¶ms=parametersDigitalSurface())
static Parameters parametersDigitalSurface()
static CountedPtr< DoubleImage > makeDoubleImage(CountedPtr< ImplicitShape3D > shape, Parameters params=parametersDigitizedImplicitShape3D())
ImplicitPolynomial3Shape< Space > ImplicitShape3D
Shortcuts & operator=(const Shortcuts &other)=delete
Space::Integer Integer
Integer numbers.
static CountedPtr< FloatImage > makeFloatImage(std::string input)
static KSpace getKSpace(CountedPtr< ::DGtal::IndexedDigitalSurface< TDigitalSurfaceContainer > > surface)
LightDigitalSurface::Face Face
::DGtal::Mesh< RealPoint > Mesh
static std::vector< CountedPtr< LightDigitalSurface > > makeLightDigitalSurfaces(CountedPtr< BinaryImage > bimage, const KSpace &K, const Parameters ¶ms=parametersDigitalSurface())
static CountedPtr< TriangulatedSurface > makeTriangulatedSurface(CountedPtr< PolygonalSurface > polySurf, const Parameters ¶ms=parametersMesh())
static bool outputPrimalDigitalSurfaceAsObj(std::ostream &output, CountedPtr< TAnyDigitalSurface > surface)
static bool saveOFF(CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > digsurf, std::string off_file, const Color &face_color=Color(32, 32, 32))
LightImplicitDigitalSurface< KSpace, BinaryImage > LightSurfaceContainer
static CellRange getPrimalVertices(const KSpace &K, const SCell &s)
static CountedPtr< GrayScaleImage > makeGrayScaleImage(Domain aDomain)
MPolynomial< Space::dimension, Scalar > ScalarPolynomial
defines a multi-variate polynomial : RealPoint -> Scalar
static CountedPtr< FloatImage > makeFloatImage(Domain aDomain)
static CountedPtr< BinaryImage > makeBinaryImage(const std::vector< T > &positions, std::optional< Domain > override_domain=std::nullopt)
static CountedPtr< SurfaceMesh > makePrimalSurfaceMesh(CountedPtr< ::DGtal::IndexedDigitalSurface< TContainer > > aSurface)
static bool outputPrimalIdxDigitalSurfaceAsObj(std::ostream &output, CountedPtr< IdxDigitalSurface > surface, const TCellEmbedder &embedder)
static SurfelRange getSurfelRange(CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > surface, const Parameters ¶ms=parametersDigitalSurface())
KSpace::SurfelSet SurfelSet
defines a set of surfels
static CountedPtr< LightDigitalSurface > makeLightDigitalSurface(CountedPtr< BinaryImage > bimage, const KSpace &K, const Parameters ¶ms=parametersDigitalSurface())
static CountedPtr< PolygonalSurface > makePrimalPolygonalSurface(CountedPtr< ::DGtal::IndexedDigitalSurface< TContainer > > aSurface)
static CountedPtr< Mesh > makeMesh(CountedPtr< PolygonalSurface > polySurf, const Color &aColor=Color::White)
static const KSpace & refKSpace(CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > surface)
static CanonicSCellEmbedder< KSpace > getSCellEmbedder(const KSpace &K)
static CountedPtr< DigitalSurface > makeDigitalSurface(CountedPtr< TPointPredicate > bimage, const KSpace &K, const Parameters ¶ms=parametersDigitalSurface())
std::vector< Cell > CellRange
static CountedPtr< BinaryImage > makeBinaryImage(CountedPtr< DigitizedImplicitShape3D > shape_digitization, Parameters params=parametersBinaryImage())
static KSpace getKSpace(CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > surface)
static bool outputSurfelsAsObj(std::ostream &output, const SurfelRange &surfels, const TCellEmbedder &embedder)
static CountedPtr< PolygonalSurface > makePrimalPolygonalSurface(Cell2Index &c2i, CountedPtr< ::DGtal::DigitalSurface< TContainer > > aSurface)
static IdxRange getRangeMatch(const std::vector< TValue > &s1, const std::vector< TValue > &s2, bool perfect=false)
ImageContainerBySTLVector< Domain, GrayScale > GrayScaleImage
defines a grey-level image with (hyper-)rectangular domain.
static CanonicSCellEmbedder< KSpace > getSCellEmbedder(CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > surface)
::DGtal::DigitalSurface< ExplicitSurfaceContainer > DigitalSurface
defines an arbitrary digital surface over a binary image.
static CountedPtr< GrayScaleImage > makeGrayScaleImage(const std::vector< T > &values, const Domain &d)
std::vector< IdxVertex > IdxRange
IdxDigitalSurface::Vertex IdxSurfel
void selfDisplay(std::ostream &out) const
KSpace::Space Space
Digital space.
std::vector< RealPoint > RealPoints
static CountedPtr< PolygonalSurface > makeDualPolygonalSurface(Surfel2Index &s2i, CountedPtr< ::DGtal::DigitalSurface< TContainer > > aSurface)
static CountedPtr< PolygonalSurface > makePolygonalSurface(CountedPtr< GrayScaleImage > gray_scale_image, const Parameters ¶ms=parametersKSpace()|parametersBinaryImage()|parametersDigitalSurface())
static bool saveOBJ(CountedPtr< ::DGtal::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
defines a connected or not indexed digital surface.
std::vector< SCell > SCellRange
static CountedPtr< GrayScaleImage > makeGrayScaleImage(std::string input)
static CountedPtr< BinaryImage > makeBinaryImage(const std::vector< T > &values, const Domain &d)
static CountedPtr< IdxDigitalSurface > makeIdxDigitalSurface(const std::vector< CountedPtr< LightDigitalSurface > > &surfaces, const Parameters ¶ms=parametersDigitalSurface())
static bool saveVectorFieldOBJ(const RealPoints &positions, const RealVectors &vf, double thickness, const Colors &diffuse_colors, std::string objfile, const Color &ambient_color=Color(32, 32, 32), const Color &diffuse_color=Color(200, 200, 255), const Color &specular_color=Color::White)
::DGtal::PolygonalSurface< RealPoint > PolygonalSurface
static CanonicSCellEmbedder< KSpace > getSCellEmbedder(CountedPtr< ::DGtal::IndexedDigitalSurface< TDigitalSurfaceContainer > > surface)
Shortcuts(const Shortcuts &other)=delete
BOOST_CONCEPT_ASSERT((concepts::CCellularGridSpaceND< TKSpace >))
static const KSpace & refKSpace(CountedPtr< ::DGtal::IndexedDigitalSurface< TDigitalSurfaceContainer > > surface)
GaussDigitizer< Space, ImplicitShape3D > DigitizedImplicitShape3D
defines the digitization of an implicit shape.
static bool saveBinaryImage(CountedPtr< BinaryImage > bimage, std::string output)
std::vector< IdxSurfel > IdxSurfelRange
static Parameters parametersBinaryImage()
static CountedPtr< GrayScaleImage > makeGrayScaleImage(const std::vector< T > &positions, const std::vector< U > &values, std::optional< Domain > override_domain=std::nullopt)
static CountedPtr< GrayScaleImage > makeGrayScaleImage(const C1< C2< C3< T > > > &values, std::optional< Domain > override_domain=std::nullopt)
static CountedPtr< BinaryImage > makeBinaryImage(CountedPtr< GrayScaleImage > gray_scale_image, Parameters params=parametersBinaryImage())
IdxDigitalSurface::Arc IdxArc
static Parameters defaultParameters()
static CountedPtr< IdxDigitalSurface > makeIdxDigitalSurface(CountedPtr< BinaryImage > bimage, const KSpace &K, const Parameters ¶ms=parametersDigitalSurface())
static CountedPtr< GrayScaleImage > makeGrayScaleImage(CountedPtr< BinaryImage > binary_image, std::function< GrayScale(bool) > const &bool2grayscale=[](bool v) { return v ?(unsigned char) 255 :(unsigned char) 0;})
Space::RealVector RealVector
Vector with floating-point coordinates.
static bool saveOBJ(CountedPtr< ::DGtal::PolygonalSurface< TPoint > > polysurf, const RealVectors &normals, const Colors &diffuse_colors, std::string objfile, const Color &ambient_color=Color(32, 32, 32), const Color &diffuse_color=Color(200, 200, 255), const Color &specular_color=Color::White)
static CountedPtr< TriangulatedSurface > makeTriangulatedSurface(CountedPtr< GrayScaleImage > gray_scale_image, const Parameters ¶ms=parametersKSpace()|parametersBinaryImage()|parametersDigitalSurface())
static bool outputDualDigitalSurfaceAsObj(std::ostream &output, CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > surface, const Parameters ¶ms=parametersMesh())
static Parameters parametersDigitizedImplicitShape3D()
LightDigitalSurface::Arc Arc
ImageContainerBySTLVector< Domain, double > DoubleImage
defines a double image with (hyper-)rectangular domain.
static CountedPtr< GrayScaleImage > makeGrayScaleImage(CountedPtr< FloatImage > fimage, Parameters params=parametersGrayScaleImage())
static CountedPtr< IdxDigitalSurface > makeIdxDigitalSurface(const TSurfelRange &surfels, ConstAlias< KSpace > K, const Parameters ¶ms=parametersDigitalSurface())
IdxDigitalSurface::Vertex IdxVertex
unsigned char GrayScale
The type for 8-bits gray-scale elements.
static PointelRange getCellRange(CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > surface, const Dimension k)
static CountedPtr< TriangulatedSurface > makeTriangulatedSurface(Surfel2Index &s2i, CountedPtr< ::DGtal::DigitalSurface< TContainer > > aSurface)
static CountedPtr< SurfaceMesh > makePrimalSurfaceMesh(CountedPtr< ::DGtal::DigitalSurface< TContainer > > aSurface)
static CountedPtr< PolygonalSurface > makeDualPolygonalSurface(CountedPtr< ::DGtal::DigitalSurface< TContainer > > aSurface)
static CountedPtr< SurfaceMesh > makePrimalSurfaceMesh(Cell2Index &c2i, CountedPtr< ::DGtal::DigitalSurface< TContainer > > aSurface)
static ColorMap getColorMap(Scalar min, Scalar max, const Parameters ¶ms=parametersUtilities())
static PointelRange getPointelRange(const KSpace &K, const SCell &surfel)
std::set< IdxSurfel > IdxSurfelSet
HyperRectDomain< Space > Domain
An (hyper-)rectangular domain.
static PointelRange getPointelRange(CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > surface)
static CanonicCellEmbedder< KSpace > getCellEmbedder(CountedPtr< ::DGtal::IndexedDigitalSurface< TDigitalSurfaceContainer > > surface)
static bool outputSCellMapAsCSV(std::ostream &output, const KSpace &K, const TSCellMap &anyMap, const TValueWriter &writer)
static IdxSurfelRange getIdxSurfelRange(CountedPtr< IdxDigitalSurface > surface, const IdxSurfel &start_surfel, const Parameters ¶ms=parametersDigitalSurface())
static bool saveOBJ(CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > digsurf, const RealVectors &normals, const Colors &diffuse_colors, std::string objfile, const Color &ambient_color=Color(32, 32, 32), const Color &diffuse_color=Color(200, 200, 255), const Color &specular_color=Color::White)
static std::vector< TValue > getMatchedRange(const std::vector< TValue > &range, const IdxRange &match)
TKSpace KSpace
Digital cellular space.
LightDigitalSurface::SCell SCell
static IdxSurfelRange getIdxSurfelRange(CountedPtr< IdxDigitalSurface > surface, const Parameters ¶ms=parametersDigitalSurface())
static CountedPtr< BinaryImage > makeBinaryImage(CountedPtr< DigitizedImplicitShape3D > shape_digitization, Domain shapeDomain, Parameters params=parametersBinaryImage())
static bool saveOBJ(CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > digsurf, const TCellEmbedder &embedder, const RealVectors &normals, const Colors &diffuse_colors, std::string objfile, const Color &ambient_color=Color(32, 32, 32), const Color &diffuse_color=Color(200, 200, 255), const Color &specular_color=Color::White)
static bool saveOFF(CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > digsurf, const TCellEmbedder &embedder, std::string off_file, const Color &face_color=DGtal::Color::None)
TickedColorMap< Scalar, ColorMap > ZeroTickedColorMap
::DGtal::DigitalSurface< LightSurfaceContainer > LightDigitalSurface
defines a connected digital surface over a binary image.
static Parameters parametersGrayScaleImage()
static CountedPtr< BinaryImage > makeBinaryImage(Domain shapeDomain)
static CanonicCellEmbedder< KSpace > getCellEmbedder(const KSpace &K)
static CountedPtr< IdxDigitalSurface > makeIdxDigitalSurface(CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > surface, const Parameters ¶ms=parametersDigitalSurface())
static CountedPtr< PolygonalSurface > makePrimalPolygonalSurface(CountedPtr< ::DGtal::DigitalSurface< TContainer > > aSurface)
static CountedPtr< ImplicitShape3D > makeImplicitShape3D(const Parameters ¶ms=parametersImplicitShape3D())
static CountedPtr< GrayScaleImage > makeGrayScaleImage(CountedPtr< DoubleImage > fimage, Parameters params=parametersGrayScaleImage())
static CanonicCellEmbedder< KSpace > getCellEmbedder(CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > surface)
static CountedPtr< PolygonalSurface > makeDualPolygonalSurface(CountedPtr< ::DGtal::IndexedDigitalSurface< TContainer > > aSurface)
static CountedPtr< TriangulatedSurface > makeTriangulatedSurface(CountedPtr< Mesh > aMesh)
LightDigitalSurface::Cell Cell
TInteger Integer
Arithmetic ring induced by (+,-,*) and Integer numbers.
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
HyperRectDomain< Space > Domain