35 #include "DGtal/base/Common.h"
36 #include "ConfigTest.h"
37 #include "DGtal/kernel/CanonicDigitalSurfaceEmbedder.h"
38 #include "DGtal/topology/DigitalSurface.h"
39 #include "DGtal/topology/DigitalSetBoundary.h"
40 #include "DGtal/topology/ImplicitDigitalSurface.h"
41 #include "DGtal/topology/LightImplicitDigitalSurface.h"
42 #include "DGtal/topology/ExplicitDigitalSurface.h"
43 #include "DGtal/topology/LightExplicitDigitalSurface.h"
44 #include "DGtal/topology/BreadthFirstVisitor.h"
45 #include "DGtal/topology/helpers/FrontierPredicate.h"
46 #include "DGtal/topology/helpers/BoundaryPredicate.h"
47 #include "DGtal/topology/CUndirectedSimpleLocalGraph.h"
48 #include "DGtal/topology/CUndirectedSimpleGraph.h"
50 #include "DGtal/io/readers/VolReader.h"
51 #include "DGtal/images/imagesSetsUtils/SetFromImage.h"
53 #include "DGtal/images/ImageSelector.h"
54 #include "DGtal/shapes/Shapes.h"
55 #include "DGtal/helpers/StdDefs.h"
56 #include "DGtal/kernel/CanonicEmbedder.h"
58 #include "DGtal/geometry/surfaces/estimation/CNormalVectorEstimator.h"
59 #include "DGtal/geometry/surfaces/estimation/BasicConvolutionWeights.h"
60 #include "DGtal/geometry/surfaces/estimation/LocalConvolutionNormalVectorEstimator.h"
61 #include "DGtal/geometry/surfaces/estimation/DigitalSurfaceEmbedderWithNormalVectorEstimator.h"
65 using namespace DGtal;
75 bool testLocalConvolutionNormalVectorEstimator (
int ,
char** )
77 unsigned int nbok = 0;
82 std::string filename = testPath +
"samples/cat10.vol";
93 bool space_ok = ks.init ( image.domain().lowerBound(),
94 image.domain().upperBound(), true );
97 trace.
error() <<
"Error in the Khamisky space construction."<<std::endl;
102 MySurfelAdjacency surfAdj (
true );
109 MyDigitalSurfaceContainer* ptrSurfContainer =
110 new MyDigitalSurfaceContainer ( ks, set3dPredicate, surfAdj, bel );
111 MyDigitalSurface digSurf ( ptrSurfContainer );
115 trace.
beginBlock (
"Compute and output surface <cat10-constant.off> with trivial normals." );
124 MyConstantEstimator myNormalEstimator ( digSurf, kernel );
128 SurfaceEmbedder surfaceEmbedder ( digSurf );
130 < SurfaceEmbedder, MyConstantEstimator > SurfaceEmbedderWithTrivialNormal;
131 SurfaceEmbedderWithTrivialNormal mySurfelEmbedder ( surfaceEmbedder,
135 myNormalEstimator.init ( 1.0, 2 );
137 MyConstantEstimator::Quantity res = myNormalEstimator.eval ( it );
138 trace.
info() <<
"Normal vector at begin() : "<< res << std::endl;
140 ofstream out (
"cat10-constant.off" );
142 digSurf.exportAs3DNOFF ( out,mySurfelEmbedder );
146 trace.
beginBlock (
"Compute and output surface <cat10-gaussian.off> with gaussian convoluted normals." );
155 MyGaussianEstimator myNormalEstimatorG ( digSurf, Gkernel );
159 SurfaceEmbedderWithGaussianNormal mySurfelEmbedderG ( surfaceEmbedder, myNormalEstimatorG );
162 myNormalEstimatorG.init ( 1.0, 5 );
164 MyGaussianEstimator::Quantity res2 = myNormalEstimatorG.eval ( it );
165 trace.
info() <<
"Normal vector at begin() : "<< res2 << std::endl;
166 std::vector<MyGaussianEstimator::Quantity> allNormals;
167 myNormalEstimatorG.evalAll ( std::back_inserter ( allNormals ) );
168 trace.
info() <<
"Normal vector field of size "<< allNormals.size() << std::endl;
170 ofstream out2 (
"cat10-gaussian.off" );
172 digSurf.exportAs3DNOFF ( out2 ,mySurfelEmbedderG );
175 nbok +=
true ? 1 : 0;
177 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
178 <<
"true == true" << std::endl;
187 int main (
int argc,
char** argv )
189 trace.
beginBlock (
"Testing class LocalConvolutionNormalVectorEstimator" );
191 for (
int i = 0; i < argc; ++i )
195 bool res = testLocalConvolutionNormalVectorEstimator ( argc,argv );
196 trace.
emphase() << ( res ?
"Passed." :
"Error." ) << endl;