DGtal  1.1.0
Typedefs | Functions
testHeatLaplace.cpp File Reference
#include "DGtal/helpers/StdDefs.h"
#include "DGtal/math/linalg/EigenSupport.h"
#include "DGtal/dec/DiscreteExteriorCalculus.h"
#include "DGtal/dec/DiscreteExteriorCalculusFactory.h"
#include "DGtal/shapes/parametric/Ball3D.h"
#include "DGtal/shapes/GaussDigitizer.h"
#include "DGtal/topology/DigitalSurface.h"
#include "DGtal/topology/ImplicitDigitalSurface.h"
#include "DGtal/geometry/surfaces/estimation/LocalEstimatorFromSurfelFunctorAdapter.h"
#include "DGtal/geometry/surfaces/estimation/IIGeometricFunctors.h"
#include "DGtal/geometry/surfaces/estimation/IntegralInvariantCovarianceEstimator.h"
#include "DGtalCatch.h"
Include dependency graph for testHeatLaplace.cpp:

Go to the source code of this file.

Typedefs

typedef EigenLinearAlgebraBackend::SparseMatrix SparseMatrix
 
typedef EigenLinearAlgebraBackend::DenseMatrix DenseMatrix
 

Functions

bool test_operator (const DenseMatrix &M)
 
bool laplace_sphere (const double &h)
 
 TEST_CASE ("Operator Test")
 

Detailed Description

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Author
Thomas Caissard (thoma.nosp@m.s.ca.nosp@m.issar.nosp@m.d@li.nosp@m.ris.c.nosp@m.nrs..nosp@m.fr )
Date
2018/02/02

Tests of the heat Laplace operator from DEC

This file is part of the DGtal library.

Definition in file testHeatLaplace.cpp.

Typedef Documentation

◆ DenseMatrix

Definition at line 51 of file testHeatLaplace.cpp.

◆ SparseMatrix

Definition at line 50 of file testHeatLaplace.cpp.

Function Documentation

◆ laplace_sphere()

bool laplace_sphere ( const double &  h)

Definition at line 71 of file testHeatLaplace.cpp.

72 {
73  typedef Z3i::Space Space;
74  typedef Z3i::KSpace KSpace;
75  typedef Z3i::Domain Domain;
76  typedef Z3i::Point Point;
77  typedef Z3i::Vector Vector;
78  typedef Ball3D<Space> Ball;
80  typedef ImplicitDigitalSurface<KSpace, GaussDigitizer> MyImplicitDigitalSurface;
82 
83  Ball ball( Point(0, 0, 0), 1.0 );
84 
85  GaussDigitizer digitizer;
86  digitizer.attach( ball );
87  digitizer.init( ball.getLowerBound() + Vector(-1, -1, -1), ball.getUpperBound() + Vector(1, 1, 1), h );
88 
89  Domain domain = digitizer.getDomain();
90 
91  KSpace kspace;
92  kspace.init( domain.lowerBound(), domain.upperBound(), true );
93 
95  KSpace::Surfel bel = Surfaces<KSpace>::findABel( kspace, digitizer, 10000 );
96  MyImplicitDigitalSurface ImpSurf( kspace, digitizer, SAdj, bel );
97  MyDigitalSurface digSurf( ImpSurf );
98 
99  typedef functors::IINormalDirectionFunctor<Space> MyIINormalFunctor;
101 
102  MyIINormalFunctor normalFunctor;
103  normalFunctor.init( h, 3.5 * pow( h, 1. / 3. ) );
104 
105  MyIINormalEstimator normalEstimator( normalFunctor );
106  normalEstimator.attach( kspace, digitizer );
107  normalEstimator.setParams( 3.5 * pow( h, 1. / 3. ) / h );
108  normalEstimator.init( h, digSurf.begin(), digSurf.end() );
109 
112 
113  const Calculus calculus = CalculusFactory::createFromNSCells<2>( digSurf.begin(), digSurf.end(), normalEstimator, h );
114 
115  const double t = 0.1 * pow( h, 2./3. );
116  const double cut_locus = 3.0;
117  const Calculus::PrimalIdentity0 laplace_primal = calculus.heatLaplace<PRIMAL>( h, t, cut_locus );
118  const Calculus::DualIdentity0 laplace_dual = calculus.heatLaplace<DUAL>( h, t, cut_locus );
119 
120  return test_operator( laplace_primal.myContainer ) && test_operator( laplace_dual.myContainer );
121 }

References DGtal::GaussDigitizer< TSpace, TEuclideanShape >::attach(), DGtal::DigitalSurface< TDigitalSurfaceContainer >::begin(), domain, DGtal::DUAL, DGtal::DigitalSurface< TDigitalSurfaceContainer >::end(), DGtal::Surfaces< TKSpace >::findABel(), DGtal::GaussDigitizer< TSpace, TEuclideanShape >::getDomain(), DGtal::Ball2D< TSpace >::getLowerBound(), DGtal::Ball2D< TSpace >::getUpperBound(), DGtal::IntegralInvariantCovarianceEstimator< TKSpace, TPointPredicate, TCovarianceMatrixFunctor >::init(), DGtal::KhalimskySpaceND< dim, TInteger >::init(), DGtal::GaussDigitizer< TSpace, TEuclideanShape >::init(), DGtal::HyperRectDomain< TSpace >::lowerBound(), DGtal::PRIMAL, test_operator(), and DGtal::HyperRectDomain< TSpace >::upperBound().

Referenced by TEST_CASE().

◆ TEST_CASE()

TEST_CASE ( "Operator Test"  )

Definition at line 123 of file testHeatLaplace.cpp.

124 {
125  SECTION( "Test" )
126  {
127  REQUIRE( laplace_sphere( 1.0 ) );
128  REQUIRE( laplace_sphere( 0.5 ) );
129  REQUIRE( laplace_sphere( 0.2 ) );
130  }
131 }

References laplace_sphere(), REQUIRE(), and SECTION().

◆ test_operator()

bool test_operator ( const DenseMatrix M)

Definition at line 53 of file testHeatLaplace.cpp.

54 {
55  bool test = true;
56 
57  for( int i = 0; i < M.rows(); i++ )
58  {
59  for( int j = 0; j < M.cols(); j++ )
60  {
61  if( i == j && M(i, j) > 0 ) test = false;
62  if( i != j && M(i, j) < 0 ) test = false;
63  }
64 
65  if( M.row(i).sum() >= 1e-10 ) test = false;
66  }
67 
68  return test;
69 }

References test().

Referenced by laplace_sphere().

test_operator
bool test_operator(const DenseMatrix &M)
Definition: testHeatLaplace.cpp:53
Ball
Ball2D< Space > Ball
Definition: testShapeMoveCenter.cpp:58
DGtal::GaussDigitizer
Aim: A class for computing the Gauss digitization of some Euclidean shape, i.e. its intersection with...
Definition: GaussDigitizer.h:80
DGtal::Surfaces
Aim: A utility class for constructing surfaces (i.e. set of (n-1)-cells).
Definition: Surfaces.h:79
DGtal::GaussDigitizer::getDomain
Domain getDomain() const
KSpace
Z3i::KSpace KSpace
Definition: sphereCotangentLaplaceOperator.cpp:70
DGtal::DiscreteExteriorCalculus
Aim: DiscreteExteriorCalculus represents a calculus in the dec package. This is the main structure in...
Definition: DiscreteExteriorCalculus.h:98
DGtal::HyperRectDomain< Space >
DGtal::DigitalSurface
Aim: Represents a set of n-1-cells in a nD space, together with adjacency relation between these cell...
Definition: DigitalSurface.h:140
DGtal::SurfelAdjacency< KSpace::dimension >
DGtal::HyperRectDomain::upperBound
const Point & upperBound() const
DGtal::KhalimskySpaceND::init
bool init(const Point &lower, const Point &upper, bool isClosed)
Specifies the upper and lower bounds for the maximal cells in this space.
DGtal::ImplicitDigitalSurface
Aim: A model of CDigitalSurfaceContainer which defines the digital surface as the boundary of an impl...
Definition: ImplicitDigitalSurface.h:72
DGtal::GaussDigitizer::attach
void attach(ConstAlias< EuclideanShape > shape)
DGtal::IntegralInvariantCovarianceEstimator
Aim: This class implement an Integral Invariant estimator which computes for each surfel the covarian...
Definition: IntegralInvariantCovarianceEstimator.h:116
DGtal::functors::IINormalDirectionFunctor
Aim: A functor Matrix -> RealVector that returns the normal direction by diagonalizing the given cova...
Definition: IIGeometricFunctors.h:68
REQUIRE
REQUIRE(domain.isInside(aPoint))
DGtal::SignedKhalimskyCell
Represents a signed cell in a cellular grid space by its Khalimsky coordinates and a boolean value.
Definition: KhalimskySpaceND.h:209
DGtal::Ball2D
Aim: Model of the concept StarShaped represents any circle in the plane.
Definition: Ball2D.h:61
DGtal::SpaceND
Definition: SpaceND.h:96
DGtal::PRIMAL
@ PRIMAL
Definition: Duality.h:61
DGtal::GaussDigitizer::init
void init(const RealPoint &xLow, const RealPoint &xUp, typename RealVector::Component gridStep)
Domain
HyperRectDomain< Space > Domain
Definition: testSimpleRandomAccessRangeFromPoint.cpp:44
DGtal::DiscreteExteriorCalculusFactory
Aim: This class provides static members to create DEC structures from various other DGtal structures.
Definition: DiscreteExteriorCalculusFactory.h:62
laplace_sphere
bool laplace_sphere(const double &h)
Definition: testHeatLaplace.cpp:71
Vector
FreemanChain< int >::Vector Vector
Definition: testCombinDSS.cpp:60
test
bool test(const I &itb, const I &ite)
Definition: testMostCenteredMSEstimator.cpp:71
domain
Domain domain
Definition: testProjection.cpp:88
DGtal::PointVector< dim, Integer >
SECTION
SECTION("Testing constant forward iterators")
Definition: testSimpleRandomAccessRangeFromPoint.cpp:66
DGtal::DUAL
@ DUAL
Definition: Duality.h:62
Space
SpaceND< 2 > Space
Definition: testSimpleRandomAccessRangeFromPoint.cpp:42
Point
MyPointD Point
Definition: testClone2.cpp:383
DGtal::Ball3D
Aim: Model of the concept StarShaped3D represents any Sphere in the space.
Definition: Ball3D.h:61
DGtal::IntegralInvariantCovarianceEstimator::init
void init(const double _h, SurfelConstIterator itb, SurfelConstIterator ite)
DGtal::HyperRectDomain::lowerBound
const Point & lowerBound() const
MyDigitalSurface
DigitalSurface< MyDigitalSurfaceContainer > MyDigitalSurface
Definition: greedy-plane-segmentation-ex2.cpp:92
DGtal::KhalimskySpaceND
Aim: This class is a model of CCellularGridSpaceND. It represents the cubical grid as a cell complex,...
Definition: KhalimskySpaceND.h:394