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"
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 ] );
105 trace.beginBlock(
"Making polynomial surface." );
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;
165 bool space_ok =
K.init(
domain.lowerBound(),
170 trace.error() <<
"Error in the Khamisky space construction."<<std::endl;
177 MySurfelAdjacency surfAdj(
true );
181 trace.beginBlock(
"Extracting boundary by tracking the space. " );
189 MySetOfSurfels theSetOfSurfels(
K, surfAdj );
198 trace.beginBlock(
"Making OFF surface <marching-cube.off>. " );
200 trace.info() <<
"Digital surface has " << digSurf.
size() <<
" surfels."
209 CellEmbedder cellEmbedder;
211 ofstream out(
"marching-cube.off" );
217 trace.beginBlock(
"Making NOFF surface <marching-cube.noff>. " );
218 ofstream out2(
"marching-cube.noff" );
88int main(
int argc,
char** argv ) {
…}
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...
RegularPointEmbedder< Space > PointEmbedder
void attach(ConstAlias< EuclideanShape > shape)
const PointEmbedder & pointEmbedder() const
void init(const RealPoint &xLow, const RealPoint &xUp, typename RealVector::Component gridStep)
Aim: a cellular embedder for implicit functions, (default constructible, copy constructible,...
Aim: model of CEuclideanOrientedShape concepts to create a shape from a polynomial.
std::set< SCell > SurfelSet
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.
PointVector< dim, double > RealPoint
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...
DigitalSurface< MyDigitalSurfaceContainer > MyDigitalSurface
MyDigitalSurface::SurfelSet SurfelSet
Z3i this namespace gathers the standard of types for 3D imagery.
KhalimskySpaceND< 3, Integer > KSpace
Space::RealPoint RealPoint
DGtal is the top-level namespace which contains all DGtal functions and types.
RealPointT::Coordinate Ring
MPolynomialReader< 3, Ring > Polynomial3Reader
GaussDigitizer< Space, ImplicitShape > DigitalShape
ImplicitPolynomial3Shape< Space > ImplicitShape
MPolynomial< 3, Ring > Polynomial3
DigitalShape::PointEmbedder DigitalEmbedder