33 #include <QtGui/QApplication>
34 #include "DGtal/helpers/StdDefs.h"
35 #include "DGtal/topology/helpers/Surfaces.h"
36 #include "DGtal/topology/DigitalSurface.h"
37 #include "DGtal/topology/SetOfSurfels.h"
38 #include "DGtal/math/MPolynomial.h"
39 #include "DGtal/shapes/GaussDigitizer.h"
40 #include "DGtal/shapes/implicit/ImplicitPolynomial3Shape.h"
41 #include "DGtal/shapes/implicit/ImplicitFunctionDiff1LinearCellEmbedder.h"
42 #include "DGtal/io/readers/MPolynomialReader.h"
43 #include "DGtal/io/viewers/Viewer3D.h"
44 #include "DGtal/topology/SCellsFunctors.h"
45 #include "DGtal/topology/helpers/BoundaryPredicate.h"
46 #include "DGtal/io/viewers/Viewer3D.h"
47 #include "DGtal/topology/SetOfSurfels.h"
48 #include "DGtal/io/colormaps/GradientColorMap.h"
49 #include <boost/math/special_functions/fpclassify.hpp>
54 using namespace DGtal;
60 void usage(
int ,
char** argv )
62 std::cerr <<
"Usage: " << argv[ 0 ] <<
" <Polynomial> <Px> <Py> <Pz> <Qx> <Qy> <Qz> <step>" << std::endl;
63 std::cerr <<
"\t - displays the boundary of a shape defined implicitly by a 3-polynomial <Polynomial>." << std::endl;
64 std::cerr <<
"\t - P and Q defines the bounding box." << std::endl;
65 std::cerr <<
"\t - step is the grid step." << std::endl;
66 std::cerr <<
"\t - You may try x^3y+xz^3+y^3z+z^3+5z or (y^2+z^2-1)^2 +(x^2+y^2-1)^3 " << std::endl;
67 std::cerr <<
"\t - See http://www.freigeist.cc/gallery.html" << std::endl;
73 typedef MPolynomialReader<3, Ring> Polynomial3Reader;
80 int main(
int argc,
char** argv )
89 for (
unsigned int i = 0; i < 3; ++i )
91 p1[ i ] = atof( argv[ 2 + i ] );
92 p2[ i ] = atof( argv[ 5 + i ] );
94 double step = atof( argv[ 8 ] );
98 Polynomial3Reader reader;
99 std::string poly_str = argv[ 1 ];
100 std::string::const_iterator iter
101 = reader.read( P, poly_str.begin(), poly_str.end() );
102 if ( iter != poly_str.end() )
104 std::cerr <<
"ERROR: I read only <"
105 << poly_str.substr( 0, iter - poly_str.begin() )
106 <<
">, and I built P=" << P << std::endl;
125 trace.
error() <<
"Error in the Khamisky space construction." << std::endl;
130 MySurfelAdjacency surfAdj(
true );
139 MySetOfSurfels theSetOfSurfels( K, surfAdj );
148 QApplication application( argc, argv );
162 for ( std::set< SCell >::iterator it = theSetOfSurfels.begin(), it_end = theSetOfSurfels.end();
167 A = ishape.nearestPoint (A,0.01,200,0.1);
169 double a=ishape.gaussianCurvature(A);
170 if ( boost::math::isnan( a ))
180 else if ( a < minCurv )
187 trace.
info() <<
" Min = " << minCurv << std::endl;
188 trace.
info() <<
" Max = " << maxCurv << std::endl;
195 cmap_grad.addColor(
Color( 50, 50, 255 ) );
196 cmap_grad.addColor(
Color( 255, 0, 0 ) );
197 cmap_grad.addColor(
Color( 255, 255, 10 ) );
201 unsigned int nbSurfels = 0;
203 for ( std::set<SCell>::iterator it = theSetOfSurfels.begin(),
204 it_end = theSetOfSurfels.end();
205 it != it_end; ++it, ++nbSurfels )
210 A = ishape.nearestPoint (A,0.01,200,0.1);
211 double a=ishape.gaussianCurvature(A);
213 if ( boost::math::isnan( a ))
222 viewer << Viewer3D::updateDisplay;
224 return application.exec();