67 #include "DGtal/base/Common.h" 68 #include "DGtal/base/CountedPtr.h" 69 #include "DGtal/helpers/StdDefs.h" 70 #include "DGtal/kernel/PointVector.h" 71 #include "DGtal/graph/CUndirectedSimpleGraph.h" 72 #include "DGtal/graph/BreadthFirstVisitor.h" 73 #include "DGtal/topology/DigitalSetBoundary.h" 74 #include "DGtal/topology/IndexedDigitalSurface.h" 75 #include "DGtal/shapes/Shapes.h" 80 using namespace DGtal;
83 int main(
int argc,
char** argv )
85 const double R = argc >= 2 ? atof( argv[ 1 ] ) : 13.0;
86 const unsigned int KN = argc >= 3 ? atoi( argv[ 2 ] ) : 6;
87 const int M = (int) ceil( R + 2.0 );
90 <<
", " << KN <<
"-ring neighborhood" << std::endl;
94 Point p1( -M, -M, -M );
97 K.
init( p1, p2,
true );
101 DigSurface dsurf( dsc );
103 <<
" Sphere has " << dsurf.size() <<
" vertices/surfels" 104 <<
" with euler " << dsurf.Euler() << std::endl;
108 auto v2n = dsurf.makeVertexMap(
RealPoint() );
109 for (
auto v : dsurf )
113 BFSVisitor bfv( dsurf, v );
114 while( ! bfv.finished() )
116 auto node = bfv.current();
117 if ( KN < node.second )
break;
118 auto surfel = dsurf.surfel( node.first );
121 nv[ k ] =
K.
sDirect( surfel, k ) ? 1.0 : -1.0;
132 const double area_true = 4.0 * M_PI * R * R;
133 double area_averaged = 0.0;
134 double area_corrected = 0.0;
135 for (
auto v : dsurf )
137 auto surfel = dsurf.surfel( v );
139 area_corrected += fabs( v2n[ v ][ k ] );
142 trace.
info() <<
"- true area = " << area_true << std::endl;
143 trace.
info() <<
"- corrected area = " << area_corrected << std::endl;
144 trace.
info() <<
"- averaged area = " << area_averaged << std::endl;
void beginBlock(const std::string &keyword="")
HyperRectDomain< Space > Domain
Z3i this namespace gathers the standard of types for 3D imagery.
bool sDirect(const SCell &p, Dimension k) const
DGtal::uint32_t Dimension
PointVector< dim, double, std::array< double, dim > > getNormalized() const
Aim: A model of CDigitalSurfaceContainer which defines the digital surface as the boundary of a given...
PointVector< 3, double > RealPoint
Dimension sOrthDir(const SCell &s) const
bool init(const Point &lower, const Point &upper, bool isClosed)
DGtal is the top-level namespace which contains all DGtal functions and types.
Aim: A wrapper class around a STL associative container for storing sets of digital points within som...
Aim: Represents a digital surface with the topology of its dual surface. Its aim is to mimick the sta...
Aim: This class is useful to perform a breadth-first exploration of a graph given a starting point or...
static Self zero
Static const for zero PointVector.
Aim: A utility class for constructing different shapes (balls, diamonds, and others).
int main(int argc, char **argv)
Aim: This class is a model of CCellularGridSpaceND. It represents the cubical grid as a cell complex...