124int main( 
int argc, 
char* argv[] )
 
  132  using namespace DGtal;
 
  139  std::string input = argv[ 1 ];
 
  140  int    m = argc > 2 ? atoi( argv[ 2 ] ) : 20;  
 
  141  int    n = argc > 3 ? atoi( argv[ 3 ] ) : 20;  
 
  142  double R = argc > 4 ? atof( argv[ 4 ] ) : 0.5; 
 
  146  double exp_H_min = 0.0;
 
  147  double exp_H_max = 0.0;
 
  148  double exp_G_min = 0.0;
 
  149  double exp_G_max = 0.0;
 
  150  if ( input == 
"torus" )
 
  152      const double big_radius   = 3.0;
 
  153      const double small_radius = 1.0;
 
  154      smesh = SMH::makeTorus( big_radius, small_radius,
 
  156                              SMH::NormalsType::VERTEX_NORMALS );
 
  157      exp_H_min = ( 0.5 / ( small_radius - big_radius ) + 0.5 / small_radius );
 
  158      exp_H_max = ( 0.5 / ( big_radius + small_radius ) + 0.5 / small_radius );
 
  159      exp_G_min = ( 1.0 / ( small_radius - big_radius ) * 1.0 / small_radius );
 
  160      exp_G_max = ( 1.0 / ( big_radius + small_radius ) * 1.0 / small_radius );
 
  162  else if ( input == 
"sphere" )
 
  164      const double radius = 2.0;
 
  165      smesh = SMH::makeSphere( radius, 
RealPoint { 0.0, 0.0, 0.0 }, m, n,
 
  166                               SMH::NormalsType::VERTEX_NORMALS );
 
  167      exp_H_min = 1.0 / radius;
 
  168      exp_H_max = 1.0 / radius;
 
  169      exp_G_min = 1.0 / ( radius * radius );
 
  170      exp_G_max = 1.0 / ( radius * radius );
 
  172  else if ( input == 
"lantern" )
 
  174      const double radius = 2.0;
 
  175      smesh = SMH::makeLantern( radius, 1.0, 
RealPoint { 0.0, 0.0, 0.0 }, m, n,
 
  176                                SMH::NormalsType::VERTEX_NORMALS );
 
  177      exp_H_min = 0.5 / radius;
 
  178      exp_H_max = 0.5 / radius;
 
  188  auto mu0 = cnc.computeMu0();
 
  189  auto mu1 = cnc.computeMu1();
 
  190  auto mu2 = cnc.computeMu2();
 
  195  std::vector< double > 
H( smesh.nbFaces() );
 
  196  std::vector< double > G( smesh.nbFaces() );
 
  197  for ( 
auto f = 0; f < smesh.nbFaces(); ++f )
 
  199      const auto b    = smesh.faceCentroid( f );
 
  200      const auto area = mu0.measure( b, R, f );
 
  201      H[ f ] = cnc.meanCurvature    ( area, mu1.measure( b, R, f ) );
 
  202      G[ f ] = cnc.GaussianCurvature( area, mu2.measure( b, R, f ) );
 
  207  auto H_min_max = std::minmax_element( 
H.cbegin(), 
H.cend() );
 
  208  auto G_min_max = std::minmax_element( G.cbegin(), G.cend() );
 
  209  std::cout << 
"Expected mean curvatures:" 
  210            << 
" min=" << exp_H_min << 
" max=" << exp_H_max
 
  212  std::cout << 
"Computed mean curvatures:" 
  213            << 
" min=" << *H_min_max.first << 
" max=" << *H_min_max.second
 
  215  std::cout << 
"Expected Gaussian curvatures:" 
  216            << 
" min=" << exp_G_min << 
" max=" << exp_G_max
 
  218  std::cout << 
"Computed Gaussian curvatures:" 
  219            << 
" min=" << *G_min_max.first << 
" max=" << *G_min_max.second
 
  227  auto colorsH = SMW::Colors( smesh.nbFaces() );
 
  228  auto colorsG = SMW::Colors( smesh.nbFaces() );
 
  229  for ( 
auto i = 0; i < smesh.nbFaces(); i++ )
 
  231      colorsH[ i ] = colormapH( 
H[ i ] );
 
  232      colorsG[ i ] = colormapG( G[ i ] );
 
  234  SMW::writeOBJ( 
"example-cnc-H", smesh, colorsH );
 
  235  SMW::writeOBJ( 
"example-cnc-G", smesh, colorsG );