DGtal 2.1.1
Loading...
Searching...
No Matches
ShortcutsGeometry.h
1
17#pragma once
18
31#if defined(ShortcutsGeometry_RECURSES)
32#error Recursive header files inclusion detected in ShortcutsGeometry.h
33#else // defined(ShortcutsGeometry_RECURSES)
35#define ShortcutsGeometry_RECURSES
36
37#if !defined ShortcutsGeometry_h
39#define ShortcutsGeometry_h
40
42#include "DGtal/helpers/Shortcuts.h"
43#include "DGtal/kernel/BasicPointPredicates.h"
44#include "DGtal/geometry/volumes/distance/LpMetric.h"
45#include "DGtal/geometry/volumes/distance/ExactPredicateLpSeparableMetric.h"
46#include "DGtal/geometry/volumes/distance/VoronoiMap.h"
47#include "DGtal/geometry/volumes/distance/DistanceTransformation.h"
48#include "DGtal/geometry/surfaces/estimation/TrueDigitalSurfaceLocalEstimator.h"
49#include "DGtal/geometry/surfaces/estimation/VoronoiCovarianceMeasureOnDigitalSurface.h"
50#include "DGtal/geometry/surfaces/estimation/VCMDigitalSurfaceLocalEstimator.h"
51#include "DGtal/geometry/surfaces/estimation/IIGeometricFunctors.h"
52#include "DGtal/geometry/surfaces/estimation/IntegralInvariantVolumeEstimator.h"
53#include "DGtal/geometry/surfaces/estimation/IntegralInvariantCovarianceEstimator.h"
54#ifdef DGTAL_WITH_OPENMP
55#include "DGtal/geometry/surfaces/estimation/ParallelIIEstimator.h"
56#include "DGtal/kernel/domains/DomainSplitter.h"
57#endif
58#include "DGtal/geometry/meshes/CorrectedNormalCurrentComputer.h"
59
60#include "DGtal/dec/DiscreteExteriorCalculusFactory.h"
61#include "DGtal/dec/ATSolver2D.h"
63
64namespace DGtal
65{
66
67 namespace sgf = ::DGtal::functors::ShapeGeometricFunctors;
68
70 // template class ShortcutsGeometry
81 template < typename TKSpace >
82 class ShortcutsGeometry : public Shortcuts< TKSpace >
83 {
85 public:
89 using Base::getKSpace;
91
92 // ----------------------- Usual space types --------------------------------------
93 public:
94
96 typedef TKSpace KSpace;
98 typedef typename KSpace::Space Space;
100 typedef typename Space::Integer Integer;
102 typedef typename Space::Point Point;
104 typedef typename Space::Vector Vector;
106 typedef typename Space::RealVector RealVector;
108 typedef typename Space::RealPoint RealPoint;
114 typedef unsigned char GrayScale;
115
116 // ----------------------- Shortcut types --------------------------------------
117 public:
134 typedef typename KSpace::SurfelSet SurfelSet;
139 typedef ::DGtal::DigitalSurface< LightSurfaceContainer > LightDigitalSurface;
143 typedef ::DGtal::DigitalSurface< ExplicitSurfaceContainer > DigitalSurface;
157 typedef std::set< IdxSurfel > IdxSurfelSet;
158 typedef std::vector< Surfel > SurfelRange;
159 typedef std::vector< Cell > CellRange;
160 typedef std::vector< IdxSurfel > IdxSurfelRange;
161 typedef std::vector< Scalar > Scalars;
162 typedef std::vector< RealVector > RealVectors;
163 typedef std::vector< RealPoint > RealPoints;
164
165 typedef ::DGtal::Statistic<Scalar> ScalarStatistic;
166
176
178 typedef std::vector< CurvatureTensorQuantity > CurvatureTensorQuantities;
179
181
200
201 typedef ::DGtal::Mesh<RealPoint> Mesh;
202 typedef ::DGtal::TriangulatedSurface<RealPoint> TriangulatedSurface;
203 typedef ::DGtal::PolygonalSurface<RealPoint> PolygonalSurface;
204 typedef std::map<Surfel, IdxSurfel> Surfel2Index;
205 typedef std::map<Cell, IdxVertex> Cell2Index;
206
209
210 // ----------------------- Static services --------------------------------------
211 public:
212
213 // ----------------------- Exact geometry services ------------------------------
216 public:
217
226
234 {
235 return Parameters
236 ( "projectionMaxIter", 20 )
237 ( "projectionAccuracy", 0.0001 )
238 ( "projectionGamma", 0.5 )
239 ( "gridstep", 1.0 );
240 }
241
260 static RealPoints
263 const KSpace& K,
264 const SurfelRange& surfels,
265 const Parameters& params = parametersShapeGeometry() )
266 {
267 RealVectors n_true_estimations;
268 TruePositionEstimator true_estimator;
269 int maxIter = params[ "projectionMaxIter" ].as<int>();
270 double accuracy = params[ "projectionAccuracy" ].as<double>();
271 double gamma = params[ "projectionGamma" ].as<double>();
272 Scalar gridstep = params[ "gridstep" ].as<Scalar>();
273 true_estimator.attach( *shape );
274 true_estimator.setParams( K, PositionFunctor(), maxIter, accuracy, gamma );
275 true_estimator.init( gridstep, surfels.begin(), surfels.end() );
276 true_estimator.eval( surfels.begin(), surfels.end(),
277 std::back_inserter( n_true_estimations ) );
278 return n_true_estimations;
279 }
280
294 static RealPoints
297 const RealPoints& points,
298 const Parameters& params = parametersShapeGeometry() )
299 {
300 RealPoints proj_points( points.size() );
301 int maxIter = params[ "projectionMaxIter" ].as<int>();
302 double accuracy = params[ "projectionAccuracy" ].as<double>();
303 double gamma = params[ "projectionGamma" ].as<double>();
304 for ( unsigned int i = 0; i < points.size(); ++i )
305 proj_points[ i ] = shape->nearestPoint( points[ i ], accuracy,
306 maxIter, gamma );
307 return proj_points;
308 }
309
328 static RealVectors
331 const KSpace& K,
332 const SurfelRange& surfels,
333 const Parameters& params = parametersShapeGeometry() )
334 {
335 RealVectors n_true_estimations;
336 TrueNormalEstimator true_estimator;
337 int maxIter = params[ "projectionMaxIter" ].as<int>();
338 double accuracy = params[ "projectionAccuracy" ].as<double>();
339 double gamma = params[ "projectionGamma" ].as<double>();
340 Scalar gridstep = params[ "gridstep" ].as<Scalar>();
341 true_estimator.attach( *shape );
342 true_estimator.setParams( K, NormalFunctor(), maxIter, accuracy, gamma );
343 true_estimator.init( gridstep, surfels.begin(), surfels.end() );
344 true_estimator.eval( surfels.begin(), surfels.end(),
345 std::back_inserter( n_true_estimations ) );
346 return n_true_estimations;
347 }
348
367 static Scalars
370 const KSpace& K,
371 const SurfelRange& surfels,
372 const Parameters& params = parametersShapeGeometry() )
373 {
374 Scalars n_true_estimations;
375 TrueMeanCurvatureEstimator true_estimator;
376 int maxIter = params[ "projectionMaxIter" ].as<int>();
377 double accuracy = params[ "projectionAccuracy" ].as<double>();
378 double gamma = params[ "projectionGamma" ].as<double>();
379 Scalar gridstep = params[ "gridstep" ].as<Scalar>();
380 true_estimator.attach( *shape );
381 true_estimator.setParams( K, MeanCurvatureFunctor(), maxIter, accuracy, gamma );
382 true_estimator.init( gridstep, surfels.begin(), surfels.end() );
383 true_estimator.eval( surfels.begin(), surfels.end(),
384 std::back_inserter( n_true_estimations ) );
385 return n_true_estimations;
386 }
387
402 static Scalars
405 const typename Base::SurfaceMesh::Faces faces,
406 const Parameters& params = parametersShapeGeometry() )
407 {
408 bool unit_u = params["unit_u"].as<int>();
409 double radius = params["r-radius"].as<double>();
410 double alpha = params["alpha"].as<double>();
411 double h = params["gridstep"].as<double>();
412 if ( alpha != 1.0 ) radius *= pow( h, alpha-1.0 );
413
414 CNCComputer computer(*mesh, unit_u);
415
416 const auto& mu0 = computer.computeMu0();
417 const auto& mu1 = computer.computeMu1();
418
419 Scalars curvatures(faces.size());
420 for (size_t i = 0; i < faces.size(); ++i)
421 {
422 const auto center = mesh->faceCentroid(faces[i]);
423 const auto area = mu0.measure(center, radius, faces[i]);
424 const auto lmu1 = mu1.measure(center, radius, faces[i]);
425 curvatures[i] = CNCComputer::meanCurvature(area, lmu1);
426 }
427
428 return curvatures;
429 }
430
452 const Parameters & params = parametersShapeGeometry() )
453 {
454 std::vector<typename Base::SurfaceMesh::Face> allFaces(mesh->nbFaces());
455 std::iota(allFaces.begin(), allFaces.end(), 0);
456
457 return getCNCMeanCurvatures(mesh, allFaces, params);
458 }
459
478 template <typename T>
480 T & digitalObject, const Parameters & params = parametersShapeGeometry() )
481 {
483 return getCNCMeanCurvatures(mesh, params);
484 }
485
505 static Scalars
508 const KSpace& K,
509 const SurfelRange& surfels,
510 const Parameters& params = parametersShapeGeometry() )
511 {
512 Scalars n_true_estimations;
513 TrueGaussianCurvatureEstimator true_estimator;
514 int maxIter = params[ "projectionMaxIter" ].as<int>();
515 double accuracy = params[ "projectionAccuracy" ].as<double>();
516 double gamma = params[ "projectionGamma" ].as<double>();
517 Scalar gridstep = params[ "gridstep" ].as<Scalar>();
518 true_estimator.attach( *shape );
519 true_estimator.setParams( K, GaussianCurvatureFunctor(), maxIter, accuracy, gamma );
520 true_estimator.init( gridstep, surfels.begin(), surfels.end() );
521 true_estimator.eval( surfels.begin(), surfels.end(),
522 std::back_inserter( n_true_estimations ) );
523 return n_true_estimations;
524 }
525
546 const typename Base::SurfaceMesh::Faces & faces,
547 const Parameters & params = parametersShapeGeometry() )
548 {
549 bool unit_u = params["unit_u"].as<int>();
550 double radius = params["r-radius"].as<double>();
551 double alpha = params["alpha"].as<double>();
552 double h = params["gridstep"].as<double>();
553 if ( alpha != 1.0 ) radius *= pow( h, alpha-1.0 );
554
555 CNCComputer computer(*mesh, unit_u);
556
557 const auto& mu0 = computer.computeMu0();
558 const auto& mu2 = computer.computeMu2();
559
560 Scalars curvatures(faces.size());
561 for (size_t i = 0; i < faces.size(); ++i)
562 {
563 const auto center = mesh->faceCentroid(faces[i]);
564 const auto area = mu0.measure(center, radius, faces[i]);
565 const auto lmu2 = mu2.measure(center, radius, faces[i]);
566 curvatures[i] = CNCComputer::GaussianCurvature(area, lmu2);
567 }
568
569 return curvatures;
570 }
571
593 const Parameters & params = parametersShapeGeometry() )
594 {
595 std::vector<typename Base::SurfaceMesh::Face> allFaces(mesh->nbFaces());
596 std::iota(allFaces.begin(), allFaces.end(), 0);
597
598 return getCNCGaussianCurvatures(mesh, allFaces, params);
599 }
600
619 template <typename T>
621 T & digitalObject, const Parameters & params = parametersShapeGeometry() )
622 {
624 return getCNCGaussianCurvatures(mesh, params);
625 }
626
645 static Scalars
648 const KSpace& K,
649 const SurfelRange& surfels,
650 const Parameters& params = parametersShapeGeometry() )
651 {
652 Scalars n_true_estimations;
654 int maxIter = params[ "projectionMaxIter" ].as<int>();
655 double accuracy = params[ "projectionAccuracy" ].as<double>();
656 double gamma = params[ "projectionGamma" ].as<double>();
657 Scalar gridstep = params[ "gridstep" ].as<Scalar>();
658 true_estimator.attach( *shape );
659 true_estimator.setParams( K, FirstPrincipalCurvatureFunctor(),
660 maxIter, accuracy, gamma );
661 true_estimator.init( gridstep, surfels.begin(), surfels.end() );
662 true_estimator.eval( surfels.begin(), surfels.end(),
663 std::back_inserter( n_true_estimations ) );
664 return n_true_estimations;
665 }
666
687 static Scalars
690 const KSpace& K,
691 const SurfelRange& surfels,
692 const Parameters& params = parametersShapeGeometry() )
693 {
694 Scalars n_true_estimations;
696 int maxIter = params[ "projectionMaxIter" ].as<int>();
697 double accuracy = params[ "projectionAccuracy" ].as<double>();
698 double gamma = params[ "projectionGamma" ].as<double>();
699 Scalar gridstep = params[ "gridstep" ].as<Scalar>();
700 true_estimator.attach( *shape );
702 maxIter, accuracy, gamma );
703 true_estimator.init( gridstep, surfels.begin(), surfels.end() );
704 true_estimator.eval( surfels.begin(), surfels.end(),
705 std::back_inserter( n_true_estimations ) );
706 return n_true_estimations;
707 }
708
729 static RealVectors
732 const KSpace& K,
733 const SurfelRange& surfels,
734 const Parameters& params = parametersShapeGeometry() )
735 {
736 RealVectors n_true_estimations;
738 int maxIter = params[ "projectionMaxIter" ].as<int>();
739 double accuracy = params[ "projectionAccuracy" ].as<double>();
740 double gamma = params[ "projectionGamma" ].as<double>();
741 Scalar gridstep = params[ "gridstep" ].as<Scalar>();
742 true_estimator.attach( *shape );
743 true_estimator.setParams( K, FirstPrincipalDirectionFunctor(),
744 maxIter, accuracy, gamma );
745 true_estimator.init( gridstep, surfels.begin(), surfels.end() );
746 true_estimator.eval( surfels.begin(), surfels.end(),
747 std::back_inserter( n_true_estimations ) );
748 return n_true_estimations;
749 }
750
771 static RealVectors
774 const KSpace& K,
775 const SurfelRange& surfels,
776 const Parameters& params = parametersShapeGeometry() )
777 {
778 RealVectors n_true_estimations;
780 int maxIter = params[ "projectionMaxIter" ].as<int>();
781 double accuracy = params[ "projectionAccuracy" ].as<double>();
782 double gamma = params[ "projectionGamma" ].as<double>();
783 Scalar gridstep = params[ "gridstep" ].as<Scalar>();
784 true_estimator.attach( *shape );
786 maxIter, accuracy, gamma );
787 true_estimator.init( gridstep, surfels.begin(), surfels.end() );
788 true_estimator.eval( surfels.begin(), surfels.end(),
789 std::back_inserter( n_true_estimations ) );
790 return n_true_estimations;
791 }
792
817 const KSpace& K,
818 const SurfelRange& surfels,
819 const Parameters& params = parametersShapeGeometry() )
820 {
821 CurvatureTensorQuantities n_true_estimations;
823 int maxIter = params[ "projectionMaxIter" ].as<int>();
824 double accuracy = params[ "projectionAccuracy" ].as<double>();
825 double gamma = params[ "projectionGamma" ].as<double>();
826 Scalar gridstep = params[ "gridstep" ].as<Scalar>();
827 true_estimator.attach( *shape );
829 maxIter, accuracy, gamma );
830 true_estimator.init( gridstep, surfels.begin(), surfels.end() );
831 true_estimator.eval( surfels.begin(), surfels.end(),
832 std::back_inserter( n_true_estimations ) );
833 return n_true_estimations;
834 }
835
860 static std::tuple<Scalars, Scalars, RealVectors, RealVectors>
863 const typename Base::SurfaceMesh::Faces& faces,
864 const Parameters& params = parametersShapeGeometry() )
865 {
866 bool unit_u = params["unit_u"].as<int>();
867 double radius = params["r-radius"].as<double>();
868 double alpha = params["alpha"].as<double>();
869 double h = params["gridstep"].as<double>();
870 if ( alpha != 1.0 ) radius *= pow( h, alpha-1.0 );
871
872 CNCComputer computer(*mesh, unit_u);
873
874 const auto& mu0 = computer.computeMu0();
875 const auto& muxy = computer.computeMuXY();
876
877 if (mesh->faceNormals().size() == 0)
878 {
879 // Try to use vertex normals if any
880 if (mesh->vertexNormals().size() == 0)
881 mesh->computeFaceNormalsFromPositions();
882 else
883 mesh->computeFaceNormalsFromVertexNormals();
884 }
885
886 const auto& normals = mesh->faceNormals();
887
888 Scalars k1(faces.size()), k2(faces.size());
889 RealVectors d1(faces.size()), d2(faces.size());
890
891 for (size_t i = 0; i < faces.size(); ++i)
892 {
893 const auto center = mesh->faceCentroid(faces[i]);
894 const auto area = mu0 .measure(center, radius, faces[i]);
895 const auto lmuxy = muxy.measure(center, radius, faces[i]);
896 std::tie(k1[i], k2[i], d1[i], d2[i]) =
897 CNCComputer::principalCurvatures(area, lmuxy, normals[faces[i]]);
898 }
899
900 return std::make_tuple(k1, k2, d1, d2);
901 }
902
928 static std::tuple<Scalars, Scalars, RealVectors, RealVectors>
931 const Parameters & params = parametersShapeGeometry() )
932 {
933 std::vector<typename Base::SurfaceMesh::Face> allFaces(mesh->nbFaces());
934 std::iota(allFaces.begin(), allFaces.end(), 0);
935
936 return getCNCPrincipalCurvaturesAndDirections(mesh, allFaces, params);
937 }
938
958 template <typename T>
959 static std::tuple<Scalars, Scalars, RealVectors, RealVectors>
961 T & digitalObject,
962 const Parameters & params = parametersShapeGeometry() )
963 {
965 return getCNCPrincipalCurvaturesAndDirections(mesh, params);
966 }
968
969 // --------------------------- geometry estimation ------------------------------
972 public:
973
991 {
992 return Parameters
993 ( "verbose", 1 )
994 ( "t-ring", 3.0 )
995 ( "kernel", "hat" )
996 ( "R-radius", 10.0 )
997 ( "r-radius", 3.0 )
998 ( "alpha", 0.33 )
999 ( "ii-thread-number", 1 )
1000 ( "ii-split-axis", 0 )
1001 ( "surfelEmbedding", 0 )
1002 ( "unit_u" , 0 );
1003 }
1004
1014 static RealVectors
1016 const SurfelRange& surfels )
1017 {
1018 std::vector< RealVector > result;
1019 for ( auto s : surfels )
1020 {
1021 Dimension k = K.sOrthDir( s );
1022 bool direct = K.sDirect( s, k );
1024 t[ k ] = direct ? -1.0 : 1.0;
1025 result.push_back( t );
1026 }
1027 return result;
1028 }
1029
1045 template <typename TAnyDigitalSurface>
1046 static RealVectors
1049 const SurfelRange& surfels,
1050 const Parameters& params = parametersGeometryEstimation() )
1051 {
1052 int verbose = params[ "verbose" ].as<int>();
1053 Scalar t = params[ "t-ring" ].as<double>();
1054 typedef typename TAnyDigitalSurface::DigitalSurfaceContainer SurfaceContainer;
1055 typedef LpMetric<Space> Metric;
1058 < Surfel, CanonicSCellEmbedder<KSpace> > SurfelFunctor;
1060 < SurfaceContainer, Metric, SurfelFunctor, Functor> NormalEstimator;
1061 if ( verbose > 0 )
1062 trace.info() << "- CTrivial normal t-ring=" << t << " (discrete)" << std::endl;
1063 const Functor fct( 1.0, t );
1064 const KSpace & K = surface->container().space();
1065 Metric aMetric( 2.0 );
1066 CanonicSCellEmbedder<KSpace> canonic_embedder( K );
1067 std::vector< RealVector > n_estimations;
1068 SurfelFunctor surfelFct( canonic_embedder, 1.0 );
1069 NormalEstimator estimator;
1070 estimator.attach( *surface);
1071 estimator.setParams( aMetric, surfelFct, fct, t );
1072 estimator.init( 1.0, surfels.begin(), surfels.end());
1073 estimator.eval( surfels.begin(), surfels.end(),
1074 std::back_inserter( n_estimations ) );
1075 std::transform( n_estimations.cbegin(), n_estimations.cend(), n_estimations.begin(),
1076 [] ( RealVector v ) { return -v; } );
1077 return n_estimations;
1078 }
1079
1101 template <typename TAnyDigitalSurface>
1102 static RealVectors
1105 const SurfelRange& surfels,
1106 const Parameters& params = parametersGeometryEstimation() )
1107 {
1109 typedef typename TAnyDigitalSurface::DigitalSurfaceContainer SurfaceContainer;
1110 RealVectors n_estimations;
1111 int verbose = params[ "verbose" ].as<int>();
1112 std::string kernel = params[ "kernel" ].as<std::string>();
1113 Scalar h = params[ "gridstep" ].as<Scalar>();
1114 Scalar R = params[ "R-radius" ].as<Scalar>();
1115 Scalar r = params[ "r-radius" ].as<Scalar>();
1116 Scalar t = params[ "t-ring" ].as<Scalar>();
1117 Scalar alpha = params[ "alpha" ].as<Scalar>();
1118 int embedding = params[ "embedding" ].as<int>();
1119 // Adjust parameters according to gridstep if specified.
1120 if ( alpha != 1.0 ) R *= pow( h, alpha-1.0 );
1121 if ( alpha != 1.0 ) r *= pow( h, alpha-1.0 );
1122 Surfel2PointEmbedding embType = embedding == 0 ? Pointels :
1123 embedding == 1 ? InnerSpel : OuterSpel;
1124 if ( verbose > 0 )
1125 {
1126 trace.info() << "- VCM normal kernel=" << kernel << " emb=" << embedding
1127 << " alpha=" << alpha << std::endl;
1128 trace.info() << "- VCM normal r=" << (r*h) << " (continuous) "
1129 << r << " (discrete)" << std::endl;
1130 trace.info() << "- VCM normal R=" << (R*h) << " (continuous) "
1131 << R << " (discrete)" << std::endl;
1132 trace.info() << "- VCM normal t=" << t << " (discrete)" << std::endl;
1133 }
1134 if ( kernel == "hat" )
1135 {
1136 typedef functors::HatPointFunction<Point,Scalar> KernelFunction;
1138 < SurfaceContainer, Metric, KernelFunction > VCMOnSurface;
1141 < SurfaceContainer, Metric, KernelFunction, NormalVFunctor> VCMNormalEstimator;
1142 KernelFunction chi_r( 1.0, r );
1143 VCMNormalEstimator estimator;
1144 estimator.attach( *surface );
1145 estimator.setParams( embType, R, r, chi_r, t, Metric(), verbose > 0 );
1146 estimator.init( h, surfels.begin(), surfels.end() );
1147 estimator.eval( surfels.begin(), surfels.end(),
1148 std::back_inserter( n_estimations ) );
1149 }
1150 else if ( kernel == "ball" )
1151 {
1154 < SurfaceContainer, Metric, KernelFunction > VCMOnSurface;
1157 < SurfaceContainer, Metric, KernelFunction, NormalVFunctor> VCMNormalEstimator;
1158 KernelFunction chi_r( 1.0, r );
1159 VCMNormalEstimator estimator;
1160 estimator.attach( *surface );
1161 estimator.setParams( embType, R, r, chi_r, t, Metric(), verbose > 0 );
1162 estimator.init( h, surfels.begin(), surfels.end() );
1163 estimator.eval( surfels.begin(), surfels.end(),
1164 std::back_inserter( n_estimations ) );
1165 }
1166 else
1167 {
1168 trace.warning() << "[ShortcutsGeometry::getVCMNormalVectors] Unknown kernel: "
1169 << kernel << std::endl;
1170 }
1171 return n_estimations;
1172 }
1173
1202 static RealVectors
1204 const SurfelRange& surfels,
1205 const Parameters& params
1207 | parametersKSpace() )
1208 {
1209 auto K = getKSpace( bimage, params );
1210 return getIINormalVectors( *bimage, K, surfels, params );
1211 }
1212
1248 static RealVectors
1250 const SurfelRange& surfels,
1251 const Parameters& params
1255 {
1256 auto K = getKSpace( params );
1257 return getIINormalVectors( *dshape, K, surfels, params );
1258 }
1259
1290 template <typename TPointPredicate>
1291 static RealVectors
1292 getIINormalVectors( const TPointPredicate& shape,
1293 const KSpace& K,
1294 const SurfelRange& surfels,
1295 const Parameters& params
1297 | parametersKSpace() )
1298 {
1299 typedef functors::IINormalDirectionFunctor<Space> IINormalFunctor;
1301 <KSpace, TPointPredicate, IINormalFunctor> IINormalEstimator;
1302
1303 RealVectors n_estimations;
1304 int verbose = params[ "verbose" ].as<int>();
1305 int ii_thread_number = params[ "ii-thread-number" ].as<int>();
1306 auto ii_split_axis = getIIParallelSplitAxis( params );
1307 Scalar h = params[ "gridstep" ].as<Scalar>();
1308 Scalar r = params[ "r-radius" ].as<Scalar>();
1309 Scalar alpha = params[ "alpha" ].as<Scalar>();
1310 if ( alpha != 1.0 ) r *= pow( h, alpha-1.0 );
1311 if ( verbose > 0 )
1312 {
1313 trace.info() << "- II normal alpha=" << alpha << std::endl;
1314 trace.info() << "- II normal r=" << (r*h) << " (continuous) "
1315 << r << " (discrete)" << std::endl;
1316 }
1317 IINormalFunctor functor;
1318 functor.init( h, r*h );
1319 bool use_parallel = false;
1320#ifdef DGTAL_WITH_OPENMP
1321 if ( ii_thread_number != 1 )
1322 {
1323 use_parallel = true;
1324 if ( verbose > 0 )
1325 trace.info() << "- II normal uses ParallelIIEstimator with thread request="
1326 << ii_thread_number << " and split axis="
1327 << ii_split_axis << std::endl;
1329 typedef ParallelIIEstimator<IINormalEstimator, Splitter> ParallelEstimator;
1330 Splitter splitter( ii_split_axis );
1331 ParallelEstimator ii_estimator( splitter, ii_thread_number, functor );
1332 ii_estimator.attach( K, shape );
1333 ii_estimator.setParams( r );
1334 ii_estimator.init( h, surfels.begin(), surfels.end() );
1335 ii_estimator.eval( surfels.begin(), surfels.end(),
1336 std::back_inserter( n_estimations ) );
1337 }
1338#else
1339 if ( ( ii_thread_number != 1 ) && ( verbose > 0 ) )
1340 trace.warning() << "- II normal requested parallel execution but DGtal was built without OpenMP; "
1341 << "falling back to the sequential estimator."
1342 << std::endl;
1343#endif
1344 if ( ! use_parallel )
1345 {
1346 IINormalEstimator ii_estimator( functor );
1347 ii_estimator.attach( K, shape );
1348 ii_estimator.setParams( r );
1349 ii_estimator.init( h, surfels.begin(), surfels.end() );
1350 ii_estimator.eval( surfels.begin(), surfels.end(),
1351 std::back_inserter( n_estimations ) );
1352 }
1353 const RealVectors n_trivial = getTrivialNormalVectors( K, surfels );
1354 orientVectors( n_estimations, n_trivial );
1355 return n_estimations;
1356 }
1357
1358
1383 static Scalars
1385 const SurfelRange& surfels,
1386 const Parameters& params
1388 | parametersKSpace() )
1389 {
1390 auto K = getKSpace( bimage, params );
1391 return getIIMeanCurvatures( *bimage, K, surfels, params );
1392 }
1393
1425 static Scalars
1427 const SurfelRange& surfels,
1428 const Parameters& params
1432 {
1433 auto K = getKSpace( params );
1434 return getIIMeanCurvatures( *dshape, K, surfels, params );
1435 }
1436
1437
1465 template <typename TPointPredicate>
1466 static Scalars
1467 getIIMeanCurvatures( const TPointPredicate& shape,
1468 const KSpace& K,
1469 const SurfelRange& surfels,
1470 const Parameters& params
1472 | parametersKSpace() )
1473 {
1474 typedef functors::IIMeanCurvature3DFunctor<Space> IIMeanCurvFunctor;
1476 <KSpace, TPointPredicate, IIMeanCurvFunctor> IIMeanCurvEstimator;
1477 return getIICurvatureEstimation<IIMeanCurvEstimator, IIMeanCurvFunctor>
1478 ( "mean curvature", shape, K, surfels, params );
1479 }
1480
1505 static Scalars
1507 const SurfelRange& surfels,
1508 const Parameters& params
1510 | parametersKSpace() )
1511 {
1512 auto K = getKSpace( bimage, params );
1513 return getIIGaussianCurvatures( *bimage, K, surfels, params );
1514 }
1515
1547 static Scalars
1549 const SurfelRange& surfels,
1550 const Parameters& params
1554 {
1555 auto K = getKSpace( params );
1556 return getIIGaussianCurvatures( *dshape, K, surfels, params );
1557 }
1558
1559
1581 template <typename TPointPredicate>
1582 static Scalars
1583 getIIGaussianCurvatures( const TPointPredicate& shape,
1584 const KSpace& K,
1585 const SurfelRange& surfels,
1586 const Parameters& params
1588 | parametersKSpace() )
1589 {
1590 typedef functors::IIGaussianCurvature3DFunctor<Space> IIGaussianCurvFunctor;
1592 <KSpace, TPointPredicate, IIGaussianCurvFunctor> IIGaussianCurvEstimator;
1593 return getIICurvatureEstimation<IIGaussianCurvEstimator, IIGaussianCurvFunctor>
1594 ( "Gaussian curvature", shape, K, surfels, params );
1595 }
1596
1624 const SurfelRange& surfels,
1625 const Parameters& params
1627 | parametersKSpace() )
1628 {
1629 auto K = getKSpace( bimage, params );
1630 return getIIPrincipalCurvaturesAndDirections( *bimage, K, surfels, params );
1631 }
1632
1667 const SurfelRange& surfels,
1668 const Parameters& params
1672 {
1673 auto K = getKSpace( params );
1674 return getIIPrincipalCurvaturesAndDirections( *dshape, K, surfels, params );
1675 }
1676
1677
1705 template <typename TPointPredicate>
1707 getIIPrincipalCurvaturesAndDirections( const TPointPredicate& shape,
1708 const KSpace& K,
1709 const SurfelRange& surfels,
1710 const Parameters& params
1712 | parametersKSpace() )
1713 {
1716 return getIICurvatureEstimation<IICurvEstimator, IICurvFunctor>
1717 ( "principal curvatures and directions", shape, K, surfels, params );
1718 }
1719
1721
1722 // --------------------------- AT approximation ------------------------------
1725 public:
1726
1740 {
1741 return Parameters
1742 ( "at-enabled", 1 )
1743 ( "at-alpha", 0.1 )
1744 ( "at-lambda", 0.025 )
1745 ( "at-epsilon", 0.25 )
1746 ( "at-epsilon-start", 2.0 )
1747 ( "at-epsilon-ratio", 2.0 )
1748 ( "at-max-iter", 10 )
1749 ( "at-diff-v-max", 0.0001 )
1750 ( "at-v-policy", "Maximum" );
1751 }
1752
1775 template <typename TAnyDigitalSurface,
1776 typename VectorFieldInput>
1777 static
1778 VectorFieldInput
1780 const SurfelRange& surfels,
1781 const VectorFieldInput& input,
1782 const Parameters& params
1784 {
1785 (void)surface; //param not used. FIXME: JOL
1786
1787 int verbose = params[ "verbose" ].as<int>();
1788 Scalar alpha_at = params[ "at-alpha" ].as<Scalar>();
1789 Scalar lambda_at = params[ "at-lambda" ].as<Scalar>();
1790 Scalar epsilon1 = params[ "at-epsilon-start" ].as<Scalar>();
1791 Scalar epsilon2 = params[ "at-epsilon" ].as<Scalar>();
1792 Scalar epsilonr = params[ "at-epsilon-ratio" ].as<Scalar>();
1793 int max_iter = params[ "at-max-iter" ].as<int>();
1794 Scalar diff_v_max= params[ "at-diff-v-max" ].as<Scalar>();
1796 const auto calculus = CalculusFactory::createFromNSCells<2>( surfels.cbegin(), surfels.cend() );
1797 ATSolver2D< KSpace > at_solver( calculus, verbose );
1798 at_solver.initInputVectorFieldU2( input, surfels.cbegin(), surfels.cend() );
1799 at_solver.setUp( alpha_at, lambda_at );
1800 at_solver.solveGammaConvergence( epsilon1, epsilon2, epsilonr, false, diff_v_max, max_iter );
1801 auto output = input;
1802 at_solver.getOutputVectorFieldU2( output, surfels.cbegin(), surfels.cend() );
1803 return output;
1804 }
1805
1836 template <typename TAnyDigitalSurface,
1837 typename VectorFieldInput,
1838 typename CellRangeConstIterator>
1839 static
1840 VectorFieldInput
1842 CellRangeConstIterator itB,
1843 CellRangeConstIterator itE,
1845 const SurfelRange& surfels,
1846 const VectorFieldInput& input,
1847 const Parameters& params
1849 {
1850 (void)surface; //param not used FIXME: JOL
1851
1852 int verbose = params[ "verbose" ].as<int>();
1853 Scalar alpha_at = params[ "at-alpha" ].as<Scalar>();
1854 Scalar lambda_at = params[ "at-lambda" ].as<Scalar>();
1855 Scalar epsilon1 = params[ "at-epsilon-start" ].as<Scalar>();
1856 Scalar epsilon2 = params[ "at-epsilon" ].as<Scalar>();
1857 Scalar epsilonr = params[ "at-epsilon-ratio" ].as<Scalar>();
1858 int max_iter = params[ "at-max-iter" ].as<int>();
1859 Scalar diff_v_max= params[ "at-diff-v-max" ].as<Scalar>();
1860 std::string policy = params[ "at-v-policy" ].as<std::string>();
1862 const auto calculus = CalculusFactory::createFromNSCells<2>( surfels.cbegin(), surfels.cend() );
1863 ATSolver2D< KSpace > at_solver( calculus, verbose );
1864 at_solver.initInputVectorFieldU2( input, surfels.cbegin(), surfels.cend() );
1865 at_solver.setUp( alpha_at, lambda_at );
1866 at_solver.solveGammaConvergence( epsilon1, epsilon2, epsilonr, false, diff_v_max, max_iter );
1867 auto output = input;
1868 at_solver.getOutputVectorFieldU2( output, surfels.cbegin(), surfels.cend() );
1869 auto p = ( policy == "Average" ) ? at_solver.Average
1870 : ( policy == "Minimum" ) ? at_solver.Minimum
1871 : at_solver.Maximum;
1872 at_solver.getOutputScalarFieldV0( features, itB, itE, p );
1873 return output;
1874 }
1875
1899 template <typename TAnyDigitalSurface>
1900 static
1901 Scalars
1903 const SurfelRange& surfels,
1904 const Scalars& input,
1905 const Parameters& params
1907 {
1908 (void)surface; //param not used FIXME: JOL
1909
1910 int verbose = params[ "verbose" ].as<int>();
1911 Scalar alpha_at = params[ "at-alpha" ].as<Scalar>();
1912 Scalar lambda_at = params[ "at-lambda" ].as<Scalar>();
1913 Scalar epsilon1 = params[ "at-epsilon-start" ].as<Scalar>();
1914 Scalar epsilon2 = params[ "at-epsilon" ].as<Scalar>();
1915 Scalar epsilonr = params[ "at-epsilon-ratio" ].as<Scalar>();
1916 int max_iter = params[ "at-max-iter" ].as<int>();
1917 Scalar diff_v_max= params[ "at-diff-v-max" ].as<Scalar>();
1919 const auto calculus = CalculusFactory::createFromNSCells<2>( surfels.cbegin(), surfels.cend() );
1920 ATSolver2D< KSpace > at_solver( calculus, verbose );
1921 at_solver.initInputScalarFieldU2( input, surfels.cbegin(), surfels.cend() );
1922 at_solver.setUp( alpha_at, lambda_at );
1923 at_solver.solveGammaConvergence( epsilon1, epsilon2, epsilonr, false, diff_v_max, max_iter );
1924 auto output = input;
1925 at_solver.getOutputScalarFieldU2( output, surfels.cbegin(), surfels.cend() );
1926 return output;
1927 }
1928
1963 template <typename TAnyDigitalSurface,
1964 typename CellRangeConstIterator>
1965 static
1966 Scalars
1968 CellRangeConstIterator itB,
1969 CellRangeConstIterator itE,
1971 const SurfelRange& surfels,
1972 const Scalars& input,
1973 const Parameters& params
1975 {
1976 (void)surface; //param not used FIXME: JOL
1977
1978 int verbose = params[ "verbose" ].as<int>();
1979 Scalar alpha_at = params[ "at-alpha" ].as<Scalar>();
1980 Scalar lambda_at = params[ "at-lambda" ].as<Scalar>();
1981 Scalar epsilon1 = params[ "at-epsilon-start" ].as<Scalar>();
1982 Scalar epsilon2 = params[ "at-epsilon" ].as<Scalar>();
1983 Scalar epsilonr = params[ "at-epsilon-ratio" ].as<Scalar>();
1984 int max_iter = params[ "at-max-iter" ].as<int>();
1985 Scalar diff_v_max= params[ "at-diff-v-max" ].as<Scalar>();
1986 std::string policy = params[ "at-v-policy" ].as<std::string>();
1988 const auto calculus = CalculusFactory::createFromNSCells<2>( surfels.cbegin(), surfels.cend() );
1989 ATSolver2D< KSpace > at_solver( calculus, verbose );
1990 at_solver.initInputScalarFieldU2( input, surfels.cbegin(), surfels.cend() );
1991 at_solver.setUp( alpha_at, lambda_at );
1992 at_solver.solveGammaConvergence( epsilon1, epsilon2, epsilonr, false, diff_v_max, max_iter );
1993 auto output = input;
1994 at_solver.getOutputScalarFieldU2( output, surfels.cbegin(), surfels.cend() );
1995 auto p = ( policy == "Average" ) ? at_solver.Average
1996 : ( policy == "Minimum" ) ? at_solver.Minimum
1997 : at_solver.Maximum;
1998 at_solver.getOutputScalarFieldV0( features, itB, itE, p );
1999 return output;
2000 }
2001
2003
2004 // ------------------------- Error measures services -------------------------
2007 public:
2008
2014 static void
2016 const RealVectors& ref_v )
2017 {
2018 std::transform( ref_v.cbegin(), ref_v.cend(), v.cbegin(), v.begin(),
2019 [] ( RealVector rw, RealVector w )
2020 { return rw.dot( w ) >= 0.0 ? w : -w; } );
2021 }
2022
2027 static ScalarStatistic
2029 {
2030 ScalarStatistic stat;
2031 stat.addValues( v.begin(), v.end() );
2032 stat.terminate();
2033 return stat;
2034 }
2035
2042 static Scalars
2044 const RealVectors& v2 )
2045 {
2046 Scalars v( v1.size() );
2047 if ( v1.size() == v2.size() )
2048 {
2049 auto outIt = v.begin();
2050 for ( auto it1 = v1.cbegin(), it2 = v2.cbegin(), itE1 = v1.cend();
2051 it1 != itE1; ++it1, ++it2 )
2052 {
2053 Scalar angle_error = acos( (*it1).dot( *it2 ) );
2054 *outIt++ = angle_error;
2055 }
2056 }
2057 else
2058 {
2059 trace.warning() << "[ShortcutsGeometry::getVectorsAngleDeviation]"
2060 << " v1.size()=" << v1.size() << " should be equal to "
2061 << " v2.size()=" << v2.size() << std::endl;
2062 }
2063 return v;
2064 }
2065
2070 static Scalars
2072 const Scalars & v2 )
2073 {
2074 Scalars result( v1.size() );
2075 std::transform( v2.cbegin(), v2.cend(), v1.cbegin(), result.begin(),
2076 [] ( Scalar val1, Scalar val2 )
2077 { return fabs( val1 - val2 ); } );
2078 return result;
2079 }
2080
2087 static Scalar
2089 const Scalars & v2 )
2090 {
2091 Scalar sum = 0;
2092 for ( unsigned int i = 0; i < v1.size(); i++ )
2093 sum += ( v1[ i ] - v2[ i ] ) * ( v1[ i ] - v2[ i ] );
2094 return sqrt( sum / v1.size() );
2095 }
2096
2103 static Scalar
2105 const Scalars & v2 )
2106 {
2107 Scalar sum = 0;
2108 for ( unsigned int i = 0; i < v1.size(); i++ )
2109 sum += fabs( v1[ i ] - v2[ i ] );
2110 return sum / v1.size();
2111 }
2112
2119 static Scalar
2121 const Scalars & v2 )
2122 {
2123 Scalar loo = 0;
2124 for ( unsigned int i = 0; i < v1.size(); i++ )
2125 loo = std::max( loo, fabs( v1[ i ] - v2[ i ] ) );
2126 return loo;
2127 }
2129
2130 // ----------------------- VoronoiMap services ------------------------------
2131 public:
2134
2137 // - toroidal-x [false]: If the domain is toroidal in the first dimension
2138 // - toroidal-y [false]: If the domain is toroidal in the second dimension
2139 // - toroidal-z [false]: If the domain is toroidal in the third dimension
2141 return Parameters
2142 // Toricity might be moved elsewhere as this is quite a general parameter
2143 ( "toroidal-x" , false )
2144 ( "toroidal-y" , false )
2145 ( "toroidal-z" , false );
2146 }
2147
2148
2149
2158 // - toroidal-x [false]: If the domain is toroidal in the first dimension
2159 // - toroidal-y [false]: If the domain is toroidal in the second dimension
2160 // - toroidal-z [false]: If the domain is toroidal in the third dimension
2163 template<uint32_t p, typename PointRange>
2166 const PointRange& sites,
2167 const Parameters& params = parametersVoronoiMap())
2168 {
2171 DigitalSet set(domain); set.insert(sites.begin(), sites.end());
2172 VoronoiPointPredicate predicate(set);
2173 Metric metric;
2174
2175 typename VoroMap::PeriodicitySpec specs = {false, false, false};
2176 if (params["toroidal-x"].as<int>()) specs[0] = true;
2177 if (params["toroidal-y"].as<int>()) specs[1] = true;
2178 if (params["toroidal-z"].as<int>()) specs[2] = true;
2179
2180
2181 // Do not return a pointer here for two reasons:
2182 // - The distance transform will not be passed anywhere else
2183 // - The operator() is less accessible with pointers.
2184 return VoroMap(domain, predicate, metric, specs);
2185 }
2186
2195 // - toroidal-x [false]: If the domain is toroidal in the first dimension
2196 // - toroidal-y [false]: If the domain is toroidal in the second dimension
2197 // - toroidal-z [false]: If the domain is toroidal in the third dimension
2200 template<uint32_t p, typename PointRange>
2203 const PointRange& sites,
2204 const Parameters& params = parametersVoronoiMap())
2205 {
2208 DigitalSet set(*domain); set.insert(sites.begin(), sites.end());
2209 VoronoiPointPredicate predicate(set);
2210 Metric metric;
2211
2212 typename VoroMap::PeriodicitySpec specs = {false, false, false};
2213 if (params["toroidal-x"].as<int>()) specs[0] = true;
2214 if (params["toroidal-y"].as<int>()) specs[1] = true;
2215 if (params["toroidal-z"].as<int>()) specs[2] = true;
2216
2217 // Do not return a pointer here for two reasons:
2218 // - The distance transform will not be passed anywhere else
2219 // - The operator() is less accessible with pointers.
2220 return VoroMap(*domain, predicate, metric, specs);
2221 }
2222
2234 // - toroidal-x [false]: If the domain is toroidal in the first dimension
2235 // - toroidal-y [false]: If the domain is toroidal in the second dimension
2236 // - toroidal-z [false]: If the domain is toroidal in the third dimension
2239 template<uint32_t p, typename PointRange>
2242 const PointRange& sites,
2243 const Parameters& params = parametersVoronoiMap())
2244 {
2247 DigitalSet set(domain); set.insert(sites.begin(), sites.end());
2248 VoronoiPointPredicate predicate(set);
2249 Metric metric;
2250
2251 typename DTMap::PeriodicitySpec specs = {false, false, false};
2252 if (params["toroidal-x"].as<int>()) specs[0] = true;
2253 if (params["toroidal-y"].as<int>()) specs[1] = true;
2254 if (params["toroidal-z"].as<int>()) specs[2] = true;
2255
2256 // Do not return a pointer here for two reasons:
2257 // - The distance transform will not be passed anywhere else
2258 // - The operator() is less accessible with pointers.
2259 return DTMap(domain, predicate, metric, specs);
2260 }
2261
2262
2272 // - toroidal-x [false]: If the domain is toroidal in the first dimension
2273 // - toroidal-y [false]: If the domain is toroidal in the second dimension
2274 // - toroidal-z [false]: If the domain is toroidal in the third dimension
2277 template<uint32_t p, typename PointRangeSites, typename PointRange>
2278 static std::vector<Vector> getDirectionToClosestSite(
2279 const PointRange& points,
2280 const PointRangeSites& sites,
2281 const Parameters& params = parametersVoronoiMap())
2282 {
2285
2286 // Compute domain of points
2287 Point pmin = *points.begin();
2288 Point pmax = pmin;
2289
2290 size_t pCount = 0;
2291 for (auto it = points.begin(); it != points.end(); ++it)
2292 {
2293 pCount ++;
2294 for (size_t i = 0; i < Space::dimension; ++i)
2295 {
2296 pmin[i] = std::min(pmin[i], (*it)[i] - 1);
2297 pmax[i] = std::max(pmax[i], (*it)[i] + 1);
2298 }
2299 }
2300
2301 for (auto it = sites.begin(); it != sites.end(); ++it)
2302 {
2303 for (size_t i = 0; i < Space::dimension; ++i)
2304 {
2305 pmin[i] = std::min(pmin[i], (*it)[i] - 1);
2306 pmax[i] = std::max(pmax[i], (*it)[i] + 1);
2307 }
2308 }
2309
2310 Domain domain(pmin, pmax);
2311
2312 DigitalSet set(domain); set.insert(sites.begin(), sites.end());
2313 VoronoiPointPredicate predicate(set);
2314 Metric metric;
2315
2316
2317 typename VoroMap::PeriodicitySpec specs = {false, false, false};
2318 if (params["toroidal-x"].as<int>()) specs[0] = true;
2319 if (params["toroidal-y"].as<int>()) specs[1] = true;
2320 if (params["toroidal-z"].as<int>()) specs[2] = true;
2321
2322 auto map = VoroMap(domain, predicate, metric, specs);
2323
2324 std::vector<Vector> directions(pCount);
2325 size_t i = 0;
2326 for (auto it = points.begin(); it != points.end(); ++it)
2327 {
2328 directions[i++] = map(*it);
2329 }
2330 return directions;
2331 }
2332
2342 // - toroidal-x [false]: If the domain is toroidal in the first dimension
2343 // - toroidal-y [false]: If the domain is toroidal in the second dimension
2344 // - toroidal-z [false]: If the domain is toroidal in the third dimension
2347 template<uint32_t p, typename PointRangeSites, typename PointRange>
2348 static std::vector<typename ExactPredicateLpSeparableMetric<Space, p>::Value> getDistanceToClosestSite(
2349 const PointRange& points,
2350 const PointRangeSites& sites,
2351 const Parameters& params = parametersVoronoiMap())
2352 {
2355
2356 // Compute domain of points
2357 Point pmin = *points.begin();
2358 Point pmax = pmin;
2359
2360 size_t pCount = 0;
2361 for (auto it = points.begin(); it != points.end(); ++it)
2362 {
2363 pCount ++;
2364 for (size_t i = 0; i < Space::dimension; ++i)
2365 {
2366 pmin[i] = std::min(pmin[i], (*it)[i] - 1);
2367 pmax[i] = std::max(pmax[i], (*it)[i] + 1);
2368 }
2369 }
2370
2371 for (auto it = sites.begin(); it != sites.end(); ++it)
2372 {
2373 for (size_t i = 0; i < Space::dimension; ++i)
2374 {
2375 pmin[i] = std::min(pmin[i], (*it)[i] - 1);
2376 pmax[i] = std::max(pmax[i], (*it)[i] + 1);
2377 }
2378 }
2379
2380 Domain domain(pmin, pmax);
2381
2382 DigitalSet set(domain); set.insert(sites.begin(), sites.end());
2383 VoronoiPointPredicate predicate(set);
2384 Metric metric;
2385
2386 typename DTMap::PeriodicitySpec specs = {false, false, false};
2387 if (params["toroidal-x"].as<int>()) specs[0] = true;
2388 if (params["toroidal-y"].as<int>()) specs[1] = true;
2389 if (params["toroidal-z"].as<int>()) specs[2] = true;
2390
2391 auto map = DTMap(domain, predicate, metric, specs);
2392
2393 std::vector<typename Metric::Value> directions(pCount);
2394 size_t i = 0;
2395 for (auto it = points.begin(); it != points.end(); ++it)
2396 {
2397 directions[i++] = map(*it);
2398 }
2399 return directions;
2400 }
2401
2414 // - toroidal-x [false]: If the domain is toroidal in the first dimension
2415 // - toroidal-y [false]: If the domain is toroidal in the second dimension
2416 // - toroidal-z [false]: If the domain is toroidal in the third dimension
2419 template<uint32_t p, typename PointRangeSites, typename PointRange>
2420 static std::vector<typename ExactPredicateLpSeparableMetric<Space, p>::Value> getRawDistanceToClosestSite(
2421 const PointRange& points,
2422 const PointRangeSites& sites,
2423 const Parameters& params = parametersVoronoiMap())
2424 {
2427
2428 // Compute domain of points
2429 Point pmin = *points.begin();
2430 Point pmax = pmin;
2431
2432 size_t pCount = 0;
2433 for (auto it = points.begin(); it != points.end(); ++it)
2434 {
2435 pCount ++;
2436 for (size_t i = 0; i < Space::dimension; ++i)
2437 {
2438 pmin[i] = std::min(pmin[i], (*it)[i] - 1);
2439 pmax[i] = std::max(pmax[i], (*it)[i] + 1);
2440 }
2441 }
2442
2443 for (auto it = sites.begin(); it != sites.end(); ++it)
2444 {
2445 for (size_t i = 0; i < Space::dimension; ++i)
2446 {
2447 pmin[i] = std::min(pmin[i], (*it)[i] - 1);
2448 pmax[i] = std::max(pmax[i], (*it)[i] + 1);
2449 }
2450 }
2451
2452 Domain domain(pmin, pmax);
2453
2454 DigitalSet set(domain); set.insert(sites.begin(), sites.end());
2455 VoronoiPointPredicate predicate(set);
2456 Metric metric;
2457
2458 typename DTMap::PeriodicitySpec specs = {false, false, false};
2459 if (params["toroidal-x"].as<int>()) specs[0] = true;
2460 if (params["toroidal-y"].as<int>()) specs[1] = true;
2461 if (params["toroidal-z"].as<int>()) specs[2] = true;
2462
2463 auto map = DTMap(domain, predicate, metric, specs);
2464
2465 std::vector<typename Metric::Value> directions(pCount);
2466 size_t i = 0;
2467 for (auto it = points.begin(); it != points.end(); ++it)
2468 {
2469 directions[i++] = map(*it);
2470 }
2471 return directions;
2472 }
2473
2474
2476
2477 // ----------------------- Standard services ------------------------------
2480 public:
2481
2486
2491
2496 ShortcutsGeometry ( const ShortcutsGeometry & other ) = delete;
2497
2503
2510
2517
2519
2520 // ----------------------- Interface --------------------------------------
2521 public:
2522
2523 // ------------------------- Protected Data ------------------------------
2524 protected:
2525
2526 // ------------------------- Private Data --------------------------------
2527 private:
2528
2529 template <typename TEstimator, typename TFunctor, typename TPointPredicate>
2530 static std::vector<typename TEstimator::Quantity>
2531 getIICurvatureEstimation( const char* description,
2532 const TPointPredicate& shape,
2533 const KSpace& K,
2534 const SurfelRange& surfels,
2535 const Parameters& params )
2536 {
2537 using Quantities = std::vector<typename TEstimator::Quantity>;
2538 Quantities estimations;
2539 int verbose = params[ "verbose" ].as<int>();
2540 int ii_thread_number = params[ "ii-thread-number" ].as<int>();
2541 auto ii_split_axis = getIIParallelSplitAxis( params );
2542 Scalar h = params[ "gridstep" ].as<Scalar>();
2543 Scalar r = params[ "r-radius" ].as<Scalar>();
2544 Scalar alpha = params[ "alpha" ].as<Scalar>();
2545 if ( alpha != 1.0 ) r *= pow( h, alpha-1.0 );
2546 if ( verbose > 0 )
2547 {
2548 trace.info() << "- II " << description << " alpha=" << alpha << std::endl;
2549 trace.info() << "- II " << description << " r=" << (r*h) << " (continuous) "
2550 << r << " (discrete)" << std::endl;
2551 }
2552 TFunctor functor;
2553 functor.init( h, r*h );
2554#ifdef DGTAL_WITH_OPENMP
2555 if ( ii_thread_number != 1 )
2556 {
2557 if ( verbose > 0 )
2558 trace.info() << "- II " << description
2559 << " uses ParallelIIEstimator with thread request="
2560 << ii_thread_number << " and split axis="
2561 << ii_split_axis << std::endl;
2563 typedef ParallelIIEstimator<TEstimator, Splitter> ParallelEstimator;
2564 Splitter splitter( ii_split_axis );
2565 ParallelEstimator ii_estimator( splitter, ii_thread_number, functor );
2566 ii_estimator.attach( K, shape );
2567 ii_estimator.setParams( r );
2568 ii_estimator.init( h, surfels.begin(), surfels.end() );
2569 ii_estimator.eval( surfels.begin(), surfels.end(),
2570 std::back_inserter( estimations ) );
2571 return estimations;
2572 }
2573#else
2574 if ( ( ii_thread_number != 1 ) && ( verbose > 0 ) )
2575 trace.warning() << "- II " << description
2576 << " requested parallel execution but DGtal was built without OpenMP; "
2577 << "falling back to the sequential estimator."
2578 << std::endl;
2579#endif
2580 TEstimator ii_estimator( functor );
2581 ii_estimator.attach( K, shape );
2582 ii_estimator.setParams( r );
2583 ii_estimator.init( h, surfels.begin(), surfels.end() );
2584 ii_estimator.eval( surfels.begin(), surfels.end(),
2585 std::back_inserter( estimations ) );
2586 return estimations;
2587 }
2588
2589 // ------------------------- Hidden services ------------------------------
2590 protected:
2591
2592 // ------------------------- Internals ------------------------------------
2593 private:
2594
2595 static typename Domain::Dimension
2597 {
2598 const auto requested_axis = params[ "ii-split-axis" ].as<int>();
2599 if ( requested_axis <= 0 ) return 0;
2600 if ( requested_axis >= static_cast<int>( Domain::dimension ) )
2601 return static_cast<typename Domain::Dimension>( Domain::dimension - 1 );
2602 return static_cast<typename Domain::Dimension>( requested_axis );
2603 }
2604
2605 }; // end of class ShortcutsGeometry
2606
2607
2608} // namespace DGtal
2609
2610
2612// Includes inline functions.
2613
2614// //
2616
2617#endif // !defined ShortcutsGeometry_h
2618
2619#undef ShortcutsGeometry_RECURSES
2620#endif // else defined(ShortcutsGeometry_RECURSES)
Aim: This class solves Ambrosio-Tortorelli functional on a two-dimensional digital space (a 2D grid o...
Definition ATSolver2D.h:91
void getOutputScalarFieldU2(ScalarFieldOutput &output, SurfelRangeConstIterator itB, SurfelRangeConstIterator itE)
Definition ATSolver2D.h:798
void getOutputScalarFieldV0(ScalarFieldOutput &output, CellRangeConstIterator itB, CellRangeConstIterator itE, CellOutputPolicy policy=CellOutputPolicy::Average)
Definition ATSolver2D.h:824
void initInputScalarFieldU2(const ScalarFieldInput &input, SurfelRangeConstIterator itB, SurfelRangeConstIterator itE)
Definition ATSolver2D.h:330
void setUp(double a, double l)
Definition ATSolver2D.h:444
void initInputVectorFieldU2(const VectorFieldInput &input, SurfelRangeConstIterator itB, SurfelRangeConstIterator itE, bool normalize=false)
Definition ATSolver2D.h:288
bool solveGammaConvergence(double eps1=2.0, double eps2=0.25, double epsr=2.0, bool compute_smallest_epsilon_map=false, double n_oo_max=1e-4, unsigned int iter_max=10)
Definition ATSolver2D.h:657
void getOutputVectorFieldU2(VectorFieldOutput &output, SurfelRangeConstIterator itB, SurfelRangeConstIterator itE)
Definition ATSolver2D.h:772
@ Maximum
compute maximum value at cell vertices
Definition ATSolver2D.h:105
@ Average
compute average values at cell vertices
Definition ATSolver2D.h:103
@ Minimum
compute minimum value at cell vertices,
Definition ATSolver2D.h:104
Aim: Smart pointer based on reference counts.
Definition CountedPtr.h:80
Aim: A wrapper class around a STL associative container for storing sets of digital points within som...
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: This class provides static members to create DEC structures from various other DGtal structures.
Aim: Implementation of the linear in time distance transformation for separable metrics.
Aim: implements separable l_p metrics with exact predicates.
Aim: A class for computing the Gauss digitization of some Euclidean shape, i.e. its intersection with...
Aim: Parallelepidec region of a digital space, model of a 'CDomain'.
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 mimic the stan...
HalfEdgeDataStructure::HalfEdgeIndex Arc
Aim: This class implement an Integral Invariant estimator which computes for each surfel the covarian...
Aim: This class implement an Integral Invariant estimator which computes for each surfel the volume o...
std::set< SCell > SurfelSet
Preferred type for defining a set of surfels (always signed cells).
SpaceND< dim, Integer > Space
Aim: A model of CDigitalSurfaceContainer which defines the digital surface as the boundary of an impl...
Aim: this class adapts any local functor on digital surface element to define a local estimator....
Aim: implements l_p metrics.
Definition LpMetric.h:75
Aim: Represents a multivariate polynomial, i.e. an element of , where K is some ring or field.
Run an Integral Invariant estimator in parallel.
TEuclideanRing Component
Type for Vector elements.
static Self zero
Static const for zero PointVector.
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...
LightDigitalSurface::Vertex Vertex
BOOST_CONCEPT_ASSERT((concepts::CCellularGridSpaceND< TKSpace >))
static Scalars getIIGaussianCurvatures(CountedPtr< BinaryImage > bimage, const SurfelRange &surfels, const Parameters &params=parametersGeometryEstimation()|parametersKSpace())
TKSpace KSpace
Digital cellular space.
static RealVectors getIINormalVectors(CountedPtr< DigitizedImplicitShape3D > dshape, const SurfelRange &surfels, const Parameters &params=parametersGeometryEstimation()|parametersKSpace()|parametersDigitizedImplicitShape3D())
static Scalar getScalarsNormL1(const Scalars &v1, const Scalars &v2)
static RealVectors getTrivialNormalVectors(const KSpace &K, const SurfelRange &surfels)
LightImplicitDigitalSurface< KSpace, BinaryImage > LightSurfaceContainer
MPolynomial< Space::dimension, Scalar > ScalarPolynomial
defines a multi-variate polynomial : RealPoint -> Scalar
static Scalars getIIMeanCurvatures(CountedPtr< DigitizedImplicitShape3D > dshape, const SurfelRange &surfels, const Parameters &params=parametersGeometryEstimation()|parametersKSpace()|parametersDigitizedImplicitShape3D())
std::vector< IdxSurfel > IdxSurfelRange
Space::Point Point
Point with integer coordinates.
static RealPoints getPositions(CountedPtr< ImplicitShape3D > shape, const RealPoints &points, const Parameters &params=parametersShapeGeometry())
RealVector::Component Scalar
Floating-point numbers.
static std::tuple< Scalars, Scalars, RealVectors, RealVectors > getCNCPrincipalCurvaturesAndDirections(CountedPtr< typename Base::SurfaceMesh > mesh, const Parameters &params=parametersShapeGeometry())
::DGtal::Statistic< Scalar > ScalarStatistic
ShortcutsGeometry(const ShortcutsGeometry &other)=delete
static Scalars getATScalarFieldApproximation(Scalars &features, CellRangeConstIterator itB, CellRangeConstIterator itE, CountedPtr< TAnyDigitalSurface > surface, const SurfelRange &surfels, const Scalars &input, const Parameters &params=parametersATApproximation()|parametersGeometryEstimation())
Space::Integer Integer
Integer numbers.
static Parameters parametersGeometryEstimation()
static Scalars getMeanCurvatures(CountedPtr< ImplicitShape3D > shape, const KSpace &K, const SurfelRange &surfels, const Parameters &params=parametersShapeGeometry())
static RealPoints getPositions(CountedPtr< ImplicitShape3D > shape, const KSpace &K, const SurfelRange &surfels, const Parameters &params=parametersShapeGeometry())
std::map< Cell, IdxVertex > Cell2Index
static Parameters parametersKSpace()
Definition Shortcuts.h:308
functors::IIPrincipalCurvaturesAndDirectionsFunctor< Space >::Quantity CurvatureTensorQuantity
TrueDigitalSurfaceLocalEstimator< KSpace, ImplicitShape3D, GaussianCurvatureFunctor > TrueGaussianCurvatureEstimator
static CurvatureTensorQuantities getIIPrincipalCurvaturesAndDirections(const TPointPredicate &shape, const KSpace &K, const SurfelRange &surfels, const Parameters &params=parametersGeometryEstimation()|parametersKSpace())
static KSpace getKSpace(const Point &low, const Point &up, Parameters params=parametersKSpace())
Definition Shortcuts.h:329
ShortcutsGeometry & operator=(const ShortcutsGeometry &other)=delete
LightDigitalSurface::SCell SCell
LightDigitalSurface::ArcRange ArcRange
sgf::ShapeGaussianCurvatureFunctor< ImplicitShape3D > GaussianCurvatureFunctor
static Parameters parametersShapeGeometry()
CorrectedNormalCurrentComputer< RealPoint, RealVector > CNCComputer
KSpace::SurfelSet SurfelSet
defines a set of surfels
static CurvatureTensorQuantities getIIPrincipalCurvaturesAndDirections(CountedPtr< DigitizedImplicitShape3D > dshape, const SurfelRange &surfels, const Parameters &params=parametersGeometryEstimation()|parametersKSpace()|parametersDigitizedImplicitShape3D())
static Scalars getCNCGaussianCurvatures(CountedPtr< typename Base::SurfaceMesh > mesh, const typename Base::SurfaceMesh::Faces &faces, const Parameters &params=parametersShapeGeometry())
DigitalSetByAssociativeContainer< Domain, std::unordered_set< typename Domain::Point > > DigitalSet
sgf::ShapeSecondPrincipalDirectionFunctor< ImplicitShape3D > SecondPrincipalDirectionFunctor
static CurvatureTensorQuantities getIIPrincipalCurvaturesAndDirections(CountedPtr< BinaryImage > bimage, const SurfelRange &surfels, const Parameters &params=parametersGeometryEstimation()|parametersKSpace())
static Scalars getIIGaussianCurvatures(CountedPtr< DigitizedImplicitShape3D > dshape, const SurfelRange &surfels, const Parameters &params=parametersGeometryEstimation()|parametersKSpace()|parametersDigitizedImplicitShape3D())
sgf::ShapePositionFunctor< ImplicitShape3D > PositionFunctor
sgf::ShapeMeanCurvatureFunctor< ImplicitShape3D > MeanCurvatureFunctor
sgf::ShapeSecondPrincipalCurvatureFunctor< ImplicitShape3D > SecondPrincipalCurvatureFunctor
static void orientVectors(RealVectors &v, const RealVectors &ref_v)
Shortcuts< TKSpace > Base
unsigned char GrayScale
The type for 8-bits gray-scale elements.
static RealVectors getIINormalVectors(CountedPtr< BinaryImage > bimage, const SurfelRange &surfels, const Parameters &params=parametersGeometryEstimation()|parametersKSpace())
static Parameters parametersATApproximation()
ShortcutsGeometry(ShortcutsGeometry &&other)=delete
static Scalars getScalarsAbsoluteDifference(const Scalars &v1, const Scalars &v2)
static VoronoiMap< Space, VoronoiPointPredicate, ExactPredicateLpSeparableMetric< Space, p > > getVoronoiMap(CountedPtr< Domain > domain, const PointRange &sites, const Parameters &params=parametersVoronoiMap())
Computes the VoronoiMap on a domain, where sites are given through a range.
std::vector< CurvatureTensorQuantity > CurvatureTensorQuantities
IdxDigitalSurface::Vertex IdxVertex
TrueDigitalSurfaceLocalEstimator< KSpace, ImplicitShape3D, PositionFunctor > TruePositionEstimator
static RealVectors getNormalVectors(CountedPtr< ImplicitShape3D > shape, const KSpace &K, const SurfelRange &surfels, const Parameters &params=parametersShapeGeometry())
::DGtal::Mesh< RealPoint > Mesh
::DGtal::TriangulatedSurface< RealPoint > TriangulatedSurface
static VoronoiMap< Space, VoronoiPointPredicate, ExactPredicateLpSeparableMetric< Space, p > > getVoronoiMap(Domain domain, const PointRange &sites, const Parameters &params=parametersVoronoiMap())
Computes the VoronoiMap on a domain, where sites are given through a range.
TrueDigitalSurfaceLocalEstimator< KSpace, ImplicitShape3D, SecondPrincipalDirectionFunctor > TrueSecondPrincipalDirectionEstimator
static std::tuple< Scalars, Scalars, RealVectors, RealVectors > getCNCPrincipalCurvaturesAndDirections(CountedPtr< typename Base::SurfaceMesh > mesh, const typename Base::SurfaceMesh::Faces &faces, const Parameters &params=parametersShapeGeometry())
TrueDigitalSurfaceLocalEstimator< KSpace, ImplicitShape3D, NormalFunctor > TrueNormalEstimator
LightDigitalSurface::Arc Arc
static RealVectors getFirstPrincipalDirections(CountedPtr< ImplicitShape3D > shape, const KSpace &K, const SurfelRange &surfels, const Parameters &params=parametersShapeGeometry())
static Scalars getCNCGaussianCurvatures(T &digitalObject, const Parameters &params=parametersShapeGeometry())
ImageContainerBySTLVector< Domain, GrayScale > GrayScaleImage
defines a grey-level image with (hyper-)rectangular domain.
static std::vector< Vector > getDirectionToClosestSite(const PointRange &points, const PointRangeSites &sites, const Parameters &params=parametersVoronoiMap())
Computes the vector to the closest site from a range of points.
static std::vector< typename ExactPredicateLpSeparableMetric< Space, p >::Value > getDistanceToClosestSite(const PointRange &points, const PointRangeSites &sites, const Parameters &params=parametersVoronoiMap())
Computes the distances to the closest site from a range of points.
std::vector< Scalar > Scalars
::DGtal::PolygonalSurface< RealPoint > PolygonalSurface
static Scalars getIIMeanCurvatures(const TPointPredicate &shape, const KSpace &K, const SurfelRange &surfels, const Parameters &params=parametersGeometryEstimation()|parametersKSpace())
static RealVectors getSecondPrincipalDirections(CountedPtr< ImplicitShape3D > shape, const KSpace &K, const SurfelRange &surfels, const Parameters &params=parametersShapeGeometry())
ImplicitPolynomial3Shape< Space > ImplicitShape3D
static Domain::Dimension getIIParallelSplitAxis(const Parameters &params)
::DGtal::DigitalSurface< ExplicitSurfaceContainer > DigitalSurface
defines an arbitrary digital surface over a binary image.
static DistanceTransformation< Space, VoronoiPointPredicate, ExactPredicateLpSeparableMetric< Space, p > > getDistanceTransformation(Domain domain, const PointRange &sites, const Parameters &params=parametersVoronoiMap())
Computes the Distance Transformation on a domain, where sites are given through a range.
GaussDigitizer< Space, ImplicitShape3D > DigitizedImplicitShape3D
defines the digitization of an implicit shape.
KSpace::Space Space
Digital space.
std::vector< Cell > CellRange
IdxDigitalSurface::Arc IdxArc
ImageContainerBySTLVector< Domain, float > FloatImage
defines a float image with (hyper-)rectangular domain.
SetOfSurfels< KSpace, SurfelSet > ExplicitSurfaceContainer
defines a heavy container that represents any digital surface.
static RealVectors getCTrivialNormalVectors(CountedPtr< TAnyDigitalSurface > surface, const SurfelRange &surfels, const Parameters &params=parametersGeometryEstimation())
LightDigitalSurface::Face Face
static Scalars getCNCMeanCurvatures(CountedPtr< typename Base::SurfaceMesh > mesh, const typename Base::SurfaceMesh::Faces faces, const Parameters &params=parametersShapeGeometry())
static Scalars getIIMeanCurvatures(CountedPtr< BinaryImage > bimage, const SurfelRange &surfels, const Parameters &params=parametersGeometryEstimation()|parametersKSpace())
ImageContainerBySTLVector< Domain, double > DoubleImage
defines a double image with (hyper-)rectangular domain.
functors::NotPointPredicate< DigitalSet > VoronoiPointPredicate
static std::tuple< Scalars, Scalars, RealVectors, RealVectors > getCNCPrincipalCurvaturesAndDirections(T &digitalObject, const Parameters &params=parametersShapeGeometry())
std::set< IdxSurfel > IdxSurfelSet
TrueDigitalSurfaceLocalEstimator< KSpace, ImplicitShape3D, SecondPrincipalCurvatureFunctor > TrueSecondPrincipalCurvatureEstimator
Space::RealVector RealVector
Vector with floating-point coordinates.
static Parameters parametersVoronoiMap()
TrueDigitalSurfaceLocalEstimator< KSpace, ImplicitShape3D, FirstPrincipalCurvatureFunctor > TrueFirstPrincipalCurvatureEstimator
ShortcutsGeometry< TKSpace > Self
static CurvatureTensorQuantities getPrincipalCurvaturesAndDirections(CountedPtr< ImplicitShape3D > shape, const KSpace &K, const SurfelRange &surfels, const Parameters &params=parametersShapeGeometry())
static std::vector< typename ExactPredicateLpSeparableMetric< Space, p >::Value > getRawDistanceToClosestSite(const PointRange &points, const PointRangeSites &sites, const Parameters &params=parametersVoronoiMap())
Computes the raw distances to the closest site from a range of points.
static Parameters defaultParameters()
static Scalars getCNCMeanCurvatures(T &digitalObject, const Parameters &params=parametersShapeGeometry())
::DGtal::DigitalSurface< LightSurfaceContainer > LightDigitalSurface
defines a connected digital surface over a binary image.
static Scalars getGaussianCurvatures(CountedPtr< ImplicitShape3D > shape, const KSpace &K, const SurfelRange &surfels, const Parameters &params=parametersShapeGeometry())
TrueDigitalSurfaceLocalEstimator< KSpace, ImplicitShape3D, PrincipalCurvaturesAndDirectionsFunctor > TruePrincipalCurvaturesAndDirectionsEstimator
std::vector< Surfel > SurfelRange
static RealVectors getIINormalVectors(const TPointPredicate &shape, const KSpace &K, const SurfelRange &surfels, const Parameters &params=parametersGeometryEstimation()|parametersKSpace())
static Scalars getVectorsAngleDeviation(const RealVectors &v1, const RealVectors &v2)
static Scalars getCNCGaussianCurvatures(CountedPtr< typename Base::SurfaceMesh > mesh, const Parameters &params=parametersShapeGeometry())
static Scalar getScalarsNormL2(const Scalars &v1, const Scalars &v2)
Space::RealPoint RealPoint
Point with floating-point coordinates.
IndexedDigitalSurface< ExplicitSurfaceContainer > IdxDigitalSurface
defines a connected or not indexed digital surface.
TrueDigitalSurfaceLocalEstimator< KSpace, ImplicitShape3D, MeanCurvatureFunctor > TrueMeanCurvatureEstimator
static Scalars getFirstPrincipalCurvatures(CountedPtr< ImplicitShape3D > shape, const KSpace &K, const SurfelRange &surfels, const Parameters &params=parametersShapeGeometry())
sgf::ShapeNormalVectorFunctor< ImplicitShape3D > NormalFunctor
sgf::ShapeFirstPrincipalDirectionFunctor< ImplicitShape3D > FirstPrincipalDirectionFunctor
IdxDigitalSurface::Vertex IdxSurfel
static Scalar getScalarsNormLoo(const Scalars &v1, const Scalars &v2)
static Parameters parametersDigitizedImplicitShape3D()
Definition Shortcuts.h:458
static ScalarStatistic getStatistic(const Scalars &v)
static Scalars getATScalarFieldApproximation(CountedPtr< TAnyDigitalSurface > surface, const SurfelRange &surfels, const Scalars &input, const Parameters &params=parametersATApproximation()|parametersGeometryEstimation())
LightDigitalSurface::Cell Cell
static std::vector< typename TEstimator::Quantity > getIICurvatureEstimation(const char *description, const TPointPredicate &shape, const KSpace &K, const SurfelRange &surfels, const Parameters &params)
LightDigitalSurface::Surfel Surfel
sgf::ShapeFirstPrincipalCurvatureFunctor< ImplicitShape3D > FirstPrincipalCurvatureFunctor
HyperRectDomain< Space > Domain
An (hyper-)rectangular domain.
Space::Vector Vector
Vector with integer coordinates.
static Scalars getIIGaussianCurvatures(const TPointPredicate &shape, const KSpace &K, const SurfelRange &surfels, const Parameters &params=parametersGeometryEstimation()|parametersKSpace())
std::vector< RealPoint > RealPoints
TrueDigitalSurfaceLocalEstimator< KSpace, ImplicitShape3D, FirstPrincipalDirectionFunctor > TrueFirstPrincipalDirectionEstimator
sgf::ShapePrincipalCurvaturesAndDirectionsFunctor< ImplicitShape3D > PrincipalCurvaturesAndDirectionsFunctor
static VectorFieldInput getATVectorFieldApproximation(CountedPtr< TAnyDigitalSurface > surface, const SurfelRange &surfels, const VectorFieldInput &input, const Parameters &params=parametersATApproximation()|parametersGeometryEstimation())
static Scalars getCNCMeanCurvatures(CountedPtr< typename Base::SurfaceMesh > mesh, const Parameters &params=parametersShapeGeometry())
static Scalars getSecondPrincipalCurvatures(CountedPtr< ImplicitShape3D > shape, const KSpace &K, const SurfelRange &surfels, const Parameters &params=parametersShapeGeometry())
static VectorFieldInput getATVectorFieldApproximation(Scalars &features, CellRangeConstIterator itB, CellRangeConstIterator itE, CountedPtr< TAnyDigitalSurface > surface, const SurfelRange &surfels, const VectorFieldInput &input, const Parameters &params=parametersATApproximation()|parametersGeometryEstimation())
std::vector< RealVector > RealVectors
static RealVectors getVCMNormalVectors(CountedPtr< TAnyDigitalSurface > surface, const SurfelRange &surfels, const Parameters &params=parametersGeometryEstimation())
std::map< Surfel, IdxSurfel > Surfel2Index
IdxDigitalSurface::ArcRange IdxArcRange
ImageContainerBySTLVector< Domain, bool > BinaryImage
defines a black and white image with (hyper-)rectangular domain.
Aim: This class is used to simplify shape and surface creation. With it, you can create new shapes an...
Definition Shortcuts.h:102
static Parameters parametersKSpace()
Definition Shortcuts.h:308
static KSpace getKSpace(const Point &low, const Point &up, Parameters params=parametersKSpace())
Definition Shortcuts.h:329
static Parameters parametersDigitizedImplicitShape3D()
Definition Shortcuts.h:458
static CountedPtr< SurfaceMesh > makePrimalSurfaceMesh(Cell2Index &c2i, CountedPtr< ::DGtal::DigitalSurface< TContainer > > aSurface)
Definition Shortcuts.h:2633
Aim: This class processes a set of sample values for one variable and can then compute different stat...
Definition Statistic.h:70
void addValues(Iter b, Iter e)
std::ostream & warning()
std::ostream & info()
Aim: An estimator on digital surfaces that returns the reference local geometric quantity....
void init(const Scalar _h, SurfelConstIterator itb, SurfelConstIterator ite)
Quantity eval(SurfelConstIterator it) const
void setParams(ConstAlias< KSpace > ks, Clone< GeometricFunctor > fct, const int maxIter=20, const Scalar accuracy=0.0001, const Scalar gamma=0.5)
void attach(ConstAlias< Shape > aShape)
Aim: This class adapts a VoronoiCovarianceMeasureOnDigitalSurface to be a model of CDigitalSurfaceLoc...
Aim: This class specializes the Voronoi covariance measure for digital surfaces. It adds notably the ...
Aim: Implementation of the linear in time Voronoi map construction.
Definition VoronoiMap.h:127
Aim: Estimates normal vector by convolution of elementary normal vector to adjacent surfel.
Aim: A functor Matrix -> RealVector that returns the normal direction by diagonalizing the given cova...
Aim: A functor Matrix -> std::pair<RealVector,RealVector> that returns the first and the second princ...
std::tuple< double, double, RealVector, RealVector > Quantity
PolyCalculus * calculus
CountedPtr< SH3::DigitalSurface > surface
std::vector< Point > PointRange
DGtal is the top-level namespace which contains all DGtal functions and types.
DGtal::uint32_t Dimension
Definition Common.h:119
Trace trace
Surfel2PointEmbedding
Possible embeddings for surfel as point(s)
Splits a domain along one of the domain grid axis.
Aim: A trivial embedder for signed cell, which corresponds to the canonic injection of cell centroids...
Aim: Utility class to compute curvature measures induced by (1) a corrected normal current defined by...
static std::tuple< Scalar, Scalar, RealVector, RealVector > principalCurvatures(Scalar mu0, RealTensor muXY, const RealVector &N)
static Scalar meanCurvature(Scalar mu0, Scalar mu1)
static Scalar GaussianCurvature(Scalar mu0, Scalar mu2)
Aim: This concept describes a cellular grid space in nD. In these spaces obtained by cartesian produc...
Aim: A functor Matrix -> Real that returns the Gaussian curvature by diagonalizing the given covarian...
Aim: A functor Real -> Real that returns the 3d mean curvature by transforming the given volume....
Aim: The predicate returns true when the point predicate given at construction return false....
Aim: A functor RealPoint -> Quantity that returns the first principal curvature at given point (i....
Aim: A functor RealPoint -> RealVector that returns the first principal direction at given point (i....
Aim: A functor RealPoint -> Quantity that returns the gaussian curvature at given point.
Aim: A functor RealPoint -> Quantity that returns the mean curvature at given point.
Aim: A functor RealPoint -> Quantity that returns the normal vector at given point.
Aim: A functor RealPoint -> Quantity that returns the position of the point itself.
Aim: A functor RealPoint -> (Scalar,Scalar,RealVector,RealVector that returns the principal curvature...
Aim: A functor RealPoint -> Quantity that returns the second principal curvature at given point (i....
Aim: A functor RealPoint -> RealVector that returns the second principal direction at given point (i....
Aim: A functor Surfel -> Quantity that returns the outer normal vector at given surfel.
KSpace K
AxisDomainSplitter< Domain >::SplitDomainsInfo output
AxisDomainSplitter< Domain > splitter
Domain domain