33 #include "DGtal/helpers/StdDefs.h"
34 #include "DGtal/topology/helpers/Surfaces.h"
35 #include "DGtal/topology/DigitalSurface.h"
36 #include "DGtal/topology/SetOfSurfels.h"
37 #include "DGtal/math/MPolynomial.h"
38 #include "DGtal/shapes/GaussDigitizer.h"
39 #include "DGtal/shapes/implicit/ImplicitPolynomial3Shape.h"
40 #include "DGtal/shapes/implicit/ImplicitFunctionDiff1LinearCellEmbedder.h"
41 #include "DGtal/io/readers/MPolynomialReader.h"
42 #include "DGtal/topology/SCellsFunctors.h"
43 #include "DGtal/topology/helpers/BoundaryPredicate.h"
44 #include "DGtal/topology/SetOfSurfels.h"
45 #include "DGtal/io/viewers/Viewer3D.h"
46 #include "DGtal/io/colormaps/GradientColorMap.h"
47 #include <boost/math/special_functions/fpclassify.hpp>
52 using namespace DGtal;
58 void usage(
int ,
char** argv )
60 std::cerr <<
"Usage: " << argv[ 0 ] <<
" <Polynomial> <Px> <Py> <Pz> <Qx> <Qy> <Qz> <step>" << std::endl;
61 std::cerr <<
"\t - displays the boundary of a shape defined implicitly by a 3-polynomial <Polynomial>." << std::endl;
62 std::cerr <<
"\t - P and Q defines the bounding box." << std::endl;
63 std::cerr <<
"\t - step is the grid step." << std::endl;
64 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;
65 std::cerr <<
"\t - See http://www.freigeist.cc/gallery.html" << std::endl;
78 int main(
int argc,
char** argv )
87 for (
unsigned int i = 0; i < 3; ++i )
89 p1[ i ] = atof( argv[ 2 + i ] );
90 p2[ i ] = atof( argv[ 5 + i ] );
92 double step = atof( argv[ 8 ] );
97 std::string poly_str = argv[ 1 ];
98 std::string::const_iterator iter
99 = reader.
read( P, poly_str.begin(), poly_str.end() );
100 if ( iter != poly_str.end() )
102 std::cerr <<
"ERROR: I read only <"
103 << poly_str.substr( 0, iter - poly_str.begin() )
104 <<
">, and I built P=" << P << std::endl;
123 trace.
error() <<
"Error in the Khamisky space construction." << std::endl;
128 MySurfelAdjacency surfAdj(
true );
135 MySetOfSurfels theSetOfSurfels(
K, surfAdj );
144 QApplication application( argc, argv );
158 for ( std::set< SCell >::iterator it = theSetOfSurfels.begin(), it_end = theSetOfSurfels.end();
163 A = ishape.nearestPoint (A,0.01,200,0.1*step);
164 double a = ishape.meanCurvature( A );
166 if ( !boost::math::isnan( a ))
180 trace.
info() <<
" Min = " << minCurv << std::endl;
181 trace.
info() <<
" Max = " << maxCurv << std::endl;
188 cmap_grad.addColor(
Color( 50, 50, 255 ) );
189 cmap_grad.addColor(
Color( 255, 0, 0 ) );
190 cmap_grad.addColor(
Color( 255, 255, 10 ) );
194 unsigned int nbSurfels = 0;
196 for ( std::set<SCell>::iterator it = theSetOfSurfels.begin(),
197 it_end = theSetOfSurfels.end();
198 it != it_end; ++it, ++nbSurfels )
203 A = ishape.nearestPoint (A,0.01,200,0.1*step);
205 double a = ishape.meanCurvature( A );
206 if ( boost::math::isnan( a ))
215 viewer << Viewer3D<>::updateDisplay;
217 return application.exec();
void usage(int, char **argv)
Structure representing an RGB triple with alpha component.
Aim: A class for computing the Gauss digitization of some Euclidean shape, i.e. its intersection with...
void attach(ConstAlias< EuclideanShape > shape)
void init(const RealPoint &xLow, const RealPoint &xUp, typename RealVector::Component gridStep)
Aim: This class template may be used to (linearly) convert scalar values in a given range into a colo...
const Point & lowerBound() const
const Point & upperBound() const
std::string className() const
Aim: model of CEuclideanOrientedShape concepts to create a shape from a polynomial.
Aim: This class is a model of CCellularGridSpaceND. It represents the cubical grid as a cell complex,...
std::set< SCell > SurfelSet
Preferred type for defining a set of surfels (always signed cells).
bool init(const Point &lower, const Point &upper, bool isClosed)
Specifies the upper and lower bounds for the maximal cells in this space.
Aim: This class converts a string polynomial expression in a multivariate polynomial.
Iterator read(Polynomial &p, Iterator begin, Iterator end)
Aim: Implements basic operations that will be used in Point and Vector classes.
Component Coordinate
Type for Point elements.
Aim: A model of CDigitalSurfaceContainer which defines the digital surface as connected surfels....
Aim: A utility class for constructing surfaces (i.e. set of (n-1)-cells).
virtual void show()
Overload QWidget method in order to add a call to updateList() method (to ensure that the lists are w...
MyDigitalSurface::SurfelSet SurfelSet
DGtal is the top-level namespace which contains all DGtal functions and types.
Modifier class in a Display3D stream. Useful to choose your own mode for a given class....
Represents a signed cell in a cellular grid space by its Khalimsky coordinates and a boolean value.
int main(int argc, char **argv)