31 #include "DGtal/base/Common.h"
32 #include "ConfigTest.h"
33 #include "DGtalCatch.h"
34 #include "DGtal/helpers/StdDefs.h"
35 #include "DGtal/helpers/Shortcuts.h"
36 #include "DGtal/geometry/surfaces/ShroudsRegularization.h"
40 using namespace DGtal;
53 auto params = SH3::defaultParameters();
54 params(
"polynomial",
"goursat" )(
"gridstep", 1)(
"verbose", 0);
55 auto implicit_shape = SH3::makeImplicitShape3D ( params );
56 auto digitized_shape = SH3::makeDigitizedImplicitShape3D( implicit_shape, params );
57 auto K = SH3::getKSpace( params );
58 auto surface = SH3::makeDigitalSurface( digitized_shape,
K, params );
62 auto idxsurface = SH3::makeIdxDigitalSurface(
surface, params );
64 auto originalPos = shrouds_reg.
positions();
67 auto polySurf = SH3::makeDualPolygonalSurface( idxsurface );
68 SH3::saveOBJ( polySurf,
"goursat-shrouds-init.obj" );
74 double energyInitK2 = shrouds_reg.
energy ( RegType::SQUARED_CURVATURE );
75 std::tie( loo, l2 ) = shrouds_reg.
regularize( RegType::SQUARED_CURVATURE,
77 double energyRegK2 = shrouds_reg.
energy ( RegType::SQUARED_CURVATURE );
82 REQUIRE( energyRegK2 < energyInitK2 );
86 auto regularizedPos = shrouds_reg.
positions();
87 auto polySurf = SH3::makeDualPolygonalSurface( idxsurface );
88 auto polySurfPos = polySurf->positions();
89 for (
size_t i = 0; i < regularizedPos.size(); i++ )
90 polySurfPos[ i ] = regularizedPos[ i ];
91 SH3::saveOBJ( polySurf,
"goursat-shrouds-reg-k2.obj" );
97 double energyInitArea= shrouds_reg.
energy ( RegType::AREA );
98 std::tie( loo, l2 ) = shrouds_reg.
regularize( RegType::AREA,
100 double energyRegArea = shrouds_reg.
energy ( RegType::AREA );
103 REQUIRE( energyRegArea < energyInitArea );
107 double energyInitSnk= shrouds_reg.
energy ( RegType::SNAKE );
108 std::tie( loo, l2 ) = shrouds_reg.
regularize( RegType::SNAKE,
110 double energyRegSnk = shrouds_reg.
energy ( RegType::SNAKE );
113 REQUIRE( energyRegSnk < energyInitSnk );
Aim: A model of CDigitalSurfaceContainer which defines the digital surface as connected surfels....
Aim: This class is used to simplify shape and surface creation. With it, you can create new shapes an...
Aim: Implements the Shrouds Regularization algorithm of Nielson et al .
Regularization
The enum class specifying the possible shrouds regularization.
double energy(const Regularization reg=Regularization::SQUARED_CURVATURE)
RealPoints positions() const
std::pair< double, double > regularize(const Regularization reg=Regularization::SQUARED_CURVATURE, const double randomization=0.0, const double max_loo=0.0001, const int maxNb=100)
CountedPtr< SH3::DigitalSurface > surface
DGtal is the top-level namespace which contains all DGtal functions and types.
TEST_CASE("Testing ShroudsRegularization")
REQUIRE(domain.isInside(aPoint))