DGtal 1.3.0
Loading...
Searching...
No Matches
Functions
testShroudsRegularization.cpp File Reference
#include <iostream>
#include "DGtal/base/Common.h"
#include "ConfigTest.h"
#include "DGtalCatch.h"
#include "DGtal/helpers/StdDefs.h"
#include "DGtal/helpers/Shortcuts.h"
#include "DGtal/geometry/surfaces/ShroudsRegularization.h"

Go to the source code of this file.

Functions

 TEST_CASE ("Testing ShroudsRegularization")
 

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
Jacques-Olivier Lachaud (jacqu.nosp@m.es-o.nosp@m.livie.nosp@m.r.la.nosp@m.chaud.nosp@m.@uni.nosp@m.v-sav.nosp@m.oie..nosp@m.fr ) Laboratory of Mathematics (CNRS, UMR 5807), University of Savoie, France
Date
2020/06/11

Functions for testing class ShroudsRegularization

This file is part of the DGtal library.

Definition in file testShroudsRegularization.cpp.

Function Documentation

◆ TEST_CASE()

TEST_CASE ( "Testing ShroudsRegularization"  )

[ShroudsRegInit]

[ShroudsRegInit]

[ShroudsRegUsage]

[ShroudsRegUsage]

[ShroudsRegK2]

[ShroudsRegK2]

[ShroudsRegSaveObj]

[ShroudsRegSaveObj]

[ShroudsRegArea]

[ShroudsRegArea]

[ShroudsRegSnake]

[ShroudsRegSnake]

Definition at line 46 of file testShroudsRegularization.cpp.

47{
50 typedef SH3::ExplicitSurfaceContainer Container;
52
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 );
60
62 auto idxsurface = SH3::makeIdxDigitalSurface( surface, params );
63 ShroudsRegularization< Container > shrouds_reg( idxsurface );
64 auto originalPos = shrouds_reg.positions();
66 {
67 auto polySurf = SH3::makeDualPolygonalSurface( idxsurface );
68 SH3::saveOBJ( polySurf, "goursat-shrouds-init.obj" );
69 }
70
72 double loo = 0.0;
73 double l2 = 0.0;
74 double energyInitK2 = shrouds_reg.energy ( RegType::SQUARED_CURVATURE );
75 std::tie( loo, l2 ) = shrouds_reg.regularize( RegType::SQUARED_CURVATURE,
76 0.5, 0.0001, 100 );
77 double energyRegK2 = shrouds_reg.energy ( RegType::SQUARED_CURVATURE );
79
80 REQUIRE( loo < 0.1 );
81 REQUIRE( l2 <= loo );
82 REQUIRE( energyRegK2 < energyInitK2 );
83
84 {
86 auto regularizedPos = shrouds_reg.positions();
87 auto polySurf = SH3::makeDualPolygonalSurface( idxsurface );
88 auto polySurfPos = polySurf->positions();
89 for ( auto i = 0; i < regularizedPos.size(); i++ )
90 polySurfPos[ i ] = regularizedPos[ i ];
91 SH3::saveOBJ( polySurf, "goursat-shrouds-reg-k2.obj" );
93 }
94
96 shrouds_reg.init();
97 double energyInitArea= shrouds_reg.energy ( RegType::AREA );
98 std::tie( loo, l2 ) = shrouds_reg.regularize( RegType::AREA,
99 0.5, 0.0001, 100 );
100 double energyRegArea = shrouds_reg.energy ( RegType::AREA );
102
103 REQUIRE( energyRegArea < energyInitArea );
104
106 shrouds_reg.init();
107 double energyInitSnk= shrouds_reg.energy ( RegType::SNAKE );
108 std::tie( loo, l2 ) = shrouds_reg.regularize( RegType::SNAKE,
109 0.5, 0.0001, 100 );
110 double energyRegSnk = shrouds_reg.energy ( RegType::SNAKE );
112
113 REQUIRE( energyRegSnk < energyInitSnk );
114}
Aim: A model of CDigitalSurfaceContainer which defines the digital surface as connected surfels....
Definition: SetOfSurfels.h:74
Aim: This class is used to simplify shape and surface creation. With it, you can create new shapes an...
Definition: Shortcuts.h:105
static KSpace getKSpace(const Point &low, const Point &up, Parameters params=parametersKSpace())
Definition: Shortcuts.h:332
static CountedPtr< DigitizedImplicitShape3D > makeDigitizedImplicitShape3D(CountedPtr< ImplicitShape3D > shape, Parameters params=parametersDigitizedImplicitShape3D())
Definition: Shortcuts.h:523
static CountedPtr< DigitalSurface > makeDigitalSurface(CountedPtr< TPointPredicate > bimage, const KSpace &K, const Parameters &params=parametersDigitalSurface())
Definition: Shortcuts.h:1209
static CountedPtr< PolygonalSurface > makeDualPolygonalSurface(Surfel2Index &s2i, CountedPtr< ::DGtal::DigitalSurface< TContainer > > aSurface)
Definition: Shortcuts.h:2268
static Parameters defaultParameters()
Definition: Shortcuts.h:203
static CountedPtr< IdxDigitalSurface > makeIdxDigitalSurface(CountedPtr< BinaryImage > bimage, const KSpace &K, const Parameters &params=parametersDigitalSurface())
Definition: Shortcuts.h:1275
static bool saveOBJ(CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > digsurf, const TCellEmbedder &embedder, const RealVectors &normals, const Colors &diffuse_colors, std::string objfile, const Color &ambient_color=Color(32, 32, 32), const Color &diffuse_color=Color(200, 200, 255), const Color &specular_color=Color::White)
Definition: Shortcuts.h:1739
static CountedPtr< ImplicitShape3D > makeImplicitShape3D(const Parameters &params=parametersImplicitShape3D())
Definition: Shortcuts.h:282
Aim: Implements the Shrouds Regularization algorithm of Nielson et al .
Regularization
The enum class specifying the possible shrouds regularization.
Shortcuts< KSpace > SH3
KSpace K
REQUIRE(domain.isInside(aPoint))

References DGtal::Shortcuts< TKSpace >::defaultParameters(), DGtal::ShroudsRegularization< TDigitalSurfaceContainer >::energy(), DGtal::Shortcuts< TKSpace >::getKSpace(), DGtal::ShroudsRegularization< TDigitalSurfaceContainer >::init(), K, DGtal::Shortcuts< TKSpace >::makeDigitalSurface(), DGtal::Shortcuts< TKSpace >::makeDigitizedImplicitShape3D(), DGtal::Shortcuts< TKSpace >::makeDualPolygonalSurface(), DGtal::Shortcuts< TKSpace >::makeIdxDigitalSurface(), DGtal::Shortcuts< TKSpace >::makeImplicitShape3D(), DGtal::ShroudsRegularization< TDigitalSurfaceContainer >::positions(), DGtal::ShroudsRegularization< TDigitalSurfaceContainer >::regularize(), REQUIRE(), and DGtal::Shortcuts< TKSpace >::saveOBJ().