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/PolyscopeViewer.h"
46#include "DGtal/io/colormaps/GradientColorMap.h"
47#include <boost/math/special_functions/fpclassify.hpp>
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;
78int 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;
111 dshape.attach( ishape );
123 trace.
error() <<
"Error in the Khamisky space construction." << std::endl;
128 MySurfelAdjacency surfAdj(
true );
135 MySetOfSurfels theSetOfSurfels(
K, surfAdj );
154 for ( std::set< SCell >::iterator it = theSetOfSurfels.begin(), it_end = theSetOfSurfels.end();
159 A = ishape.nearestPoint (
A,0.01,200,0.1*step);
160 double a = ishape.meanCurvature(
A );
162 if ( !boost::math::isnan( a ))
176 trace.
info() <<
" Min = " << minCurv << std::endl;
177 trace.
info() <<
" Max = " << maxCurv << std::endl;
181 unsigned int nbSurfels = 0;
183 for ( std::set<SCell>::iterator it = theSetOfSurfels.begin(),
184 it_end = theSetOfSurfels.end();
185 it != it_end; ++it, ++nbSurfels )
190 A = ishape.nearestPoint (
A,0.01,200,0.1*step);
192 double a = ishape.meanCurvature(
A );
193 if ( boost::math::isnan( a ))
Aim: A class for computing the Gauss digitization of some Euclidean shape, i.e. its intersection with...
const Point & lowerBound() const
const Point & upperBound() 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.
Aim: Represents a multivariate polynomial, i.e. an element of , where K is some ring or field.
Aim: Implements basic operations that will be used in Point and Vector classes.
Component Coordinate
Type for Point elements.
void show() override
Starts the event loop and display of elements.
Aim: A model of CDigitalSurfaceContainer which defines the digital surface as connected surfels....
static void trackBoundary(SCellSet &surface, const KSpace &K, const SurfelAdjacency< KSpace::dimension > &surfel_adj, const PointPredicate &pp, const SCell &start_surfel)
static SCell findABel(const KSpace &K, const PointPredicate &pp, unsigned int nbtries=1000)
MyDigitalSurface::SurfelSet SurfelSet
DGtal is the top-level namespace which contains all DGtal functions and types.
Represents a signed cell in a cellular grid space by its Khalimsky coordinates and a boolean value.
Attach a property to an element.
RealPointT::Coordinate Ring
MPolynomialReader< 3, Ring > Polynomial3Reader
GaussDigitizer< Space, ImplicitShape > DigitalShape
Space::RealPoint RealPointT
ImplicitPolynomial3Shape< Space > ImplicitShape
MPolynomial< 3, Ring > Polynomial3
DigitalShape::PointEmbedder DigitalEmbedder