58#include "DGtal/helpers/StdDefs.h"
59#include "DGtal/topology/helpers/Surfaces.h"
60#include "DGtal/topology/DigitalSurface.h"
61#include "DGtal/topology/SetOfSurfels.h"
62#include "DGtal/math/MPolynomial.h"
63#include "DGtal/shapes/GaussDigitizer.h"
64#include "DGtal/shapes/implicit/ImplicitPolynomial3Shape.h"
65#include "DGtal/shapes/implicit/ImplicitFunctionDiff1LinearCellEmbedder.h"
66#include "DGtal/io/readers/MPolynomialReader.h"
78void usage(
int ,
char** argv )
80 std::cerr <<
"Usage: " << argv[ 0 ] <<
" <Polynomial> <Px> <Py> <Pz> <Qx> <Qy> <Qz> <step>" << std::endl;
81 std::cerr <<
"\t - displays the boundary of a shape defined implicitly by a 3-polynomial <Polynomial>." << std::endl;
82 std::cerr <<
"\t - P and Q defines the bounding box." << std::endl;
83 std::cerr <<
"\t - step is the grid step." << std::endl;
84 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;
85 std::cerr <<
"\t - See http://www.freigeist.cc/gallery.html" << std::endl;
88int main(
int argc,
char** argv )
97 for (
unsigned int i = 0; i < 3; ++i )
99 p1[ i ] = atof( argv[ 2+i ] );
100 p2[ i ] = atof( argv[ 5+i ] );
102 double step = atof( argv[ 8 ] );
117 std::string poly_str = argv[ 1 ];
118 std::string::const_iterator iter
119 = reader.
read( P, poly_str.begin(), poly_str.end() );
120 if ( iter != poly_str.end() )
122 std::cerr <<
"ERROR: I read only <"
123 << poly_str.substr( 0, iter - poly_str.begin() )
124 <<
">, and I built P=" << P << std::endl;
150 trace.
info() <<
"P( X_0, X_1, X_2 ) = " << P << std::endl;
170 trace.
error() <<
"Error in the Khamisky space construction."<<std::endl;
177 MySurfelAdjacency surfAdj(
true );
189 MySetOfSurfels theSetOfSurfels(
K, surfAdj );
200 trace.
info() <<
"Digital surface has " << digSurf.
size() <<
" surfels."
209 CellEmbedder cellEmbedder;
211 ofstream out(
"marching-cube.off" );
218 ofstream out2(
"marching-cube.noff" );
Aim: Represents a set of n-1-cells in a nD space, together with adjacency relation between these cell...
void exportEmbeddedSurfaceAs3DOFF(std::ostream &out, const CellEmbedder &cembedder) const
void exportEmbeddedSurfaceAs3DNOFF(std::ostream &out, const CellEmbedder &cembedder) const
Aim: A class for computing the Gauss digitization of some Euclidean shape, i.e. its intersection with...
void attach(ConstAlias< EuclideanShape > shape)
const PointEmbedder & pointEmbedder() const
void init(const RealPoint &xLow, const RealPoint &xUp, typename RealVector::Component gridStep)
const Point & lowerBound() const
const Point & upperBound() const
Aim: a cellular embedder for implicit functions, (default constructible, copy constructible,...
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: 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 init(typename RealVector::Component gridStep)
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)
Aim: Represent adjacencies between surfel elements, telling if it follows an interior to exterior ord...
void beginBlock(const std::string &keyword="")
DigitalSurface< MyDigitalSurfaceContainer > MyDigitalSurface
MyDigitalSurface::SurfelSet SurfelSet
KhalimskySpaceND< 3, Integer > KSpace
Space::RealPoint RealPoint
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.