120int main(
int argc,
char* argv[] )
128 using namespace DGtal;
134 std::string input = argv[ 1 ];
135 int m = argc > 2 ? atoi( argv[ 2 ] ) : 20;
136 int n = argc > 3 ? atoi( argv[ 3 ] ) : 20;
137 double R = argc > 4 ? atof( argv[ 4 ] ) : 0.5;
141 double exp_H_min = 0.0;
142 double exp_H_max = 0.0;
143 double exp_G_min = 0.0;
144 double exp_G_max = 0.0;
145 if ( input ==
"torus" )
147 const double big_radius = 3.0;
148 const double small_radius = 1.0;
149 smesh = SMH::makeTorus( big_radius, small_radius,
151 SMH::NormalsType::VERTEX_NORMALS );
152 exp_H_min = ( 0.5 / ( small_radius - big_radius ) + 0.5 / small_radius );
153 exp_H_max = ( 0.5 / ( big_radius + small_radius ) + 0.5 / small_radius );
154 exp_G_min = ( 1.0 / ( small_radius - big_radius ) * 1.0 / small_radius );
155 exp_G_max = ( 1.0 / ( big_radius + small_radius ) * 1.0 / small_radius );
157 else if ( input ==
"sphere" )
159 const double radius = 2.0;
160 smesh = SMH::makeSphere( radius,
RealPoint { 0.0, 0.0, 0.0 }, m, n,
161 SMH::NormalsType::VERTEX_NORMALS );
162 exp_H_min = 1.0 / radius;
163 exp_H_max = 1.0 / radius;
164 exp_G_min = 1.0 / ( radius * radius );
165 exp_G_max = 1.0 / ( radius * radius );
167 else if ( input ==
"lantern" )
169 const double radius = 2.0;
170 smesh = SMH::makeLantern( radius, 1.0,
RealPoint { 0.0, 0.0, 0.0 }, m, n,
171 SMH::NormalsType::VERTEX_NORMALS );
172 exp_H_min = 0.5 / radius;
173 exp_H_max = 0.5 / radius;
183 auto mu0 = nc.computeMu0();
184 auto mu1 = nc.computeMu1();
185 auto mu2 = nc.computeMu2();
190 std::vector< double > H( smesh.nbFaces() );
191 std::vector< double > G( smesh.nbFaces() );
192 for (
auto f = 0; f < smesh.nbFaces(); ++f )
194 const auto b = smesh.faceCentroid( f );
195 const auto area = mu0.measure( b, R, f );
196 H[ f ] = nc.meanCurvature ( area, mu1.measure( b, R, f ) );
197 G[ f ] = nc.GaussianCurvature( area, mu2.measure( b, R, f ) );
202 auto H_min_max = std::minmax_element( H.cbegin(), H.cend() );
203 auto G_min_max = std::minmax_element( G.cbegin(), G.cend() );
204 std::cout <<
"Expected mean curvatures:"
205 <<
" min=" << exp_H_min <<
" max=" << exp_H_max
207 std::cout <<
"Computed mean curvatures:"
208 <<
" min=" << *H_min_max.first <<
" max=" << *H_min_max.second
210 std::cout <<
"Expected Gaussian curvatures:"
211 <<
" min=" << exp_G_min <<
" max=" << exp_G_max
213 std::cout <<
"Computed Gaussian curvatures:"
214 <<
" min=" << *G_min_max.first <<
" max=" << *G_min_max.second
220 const auto colormapH = makeQuantifiedColorMap(
makeColorMap( -0.625, 0.625 ) );
221 const auto colormapG = makeQuantifiedColorMap(
makeColorMap( -0.625, 0.625 ) );
222 auto colorsH = SMW::Colors( smesh.nbFaces() );
223 auto colorsG = SMW::Colors( smesh.nbFaces() );
224 for (
auto i = 0; i < smesh.nbFaces(); i++ )
226 colorsH[ i ] = colormapH( H[ i ] );
227 colorsG[ i ] = colormapG( G[ i ] );
229 SMW::writeOBJ(
"example-nc-H", smesh, colorsH );
230 SMW::writeOBJ(
"example-nc-G", smesh, colorsG );