48{
52 auto params = SH3::defaultParameters()
53 | SHG3::defaultParameters();
54
55 params( "polynomial", "goursat" )( "gridstep", 1.0)("verbose", 0);
56 auto implicit_shape = SH3::makeImplicitShape3D ( params );
57 auto digitized_shape = SH3::makeDigitizedImplicitShape3D( implicit_shape, params );
58 auto K = SH3::getKSpace( params );
60
61 SECTION(
"Basic Construction using Trivial Normals and regular/clamped advection")
62 {
64 auto surface = SH3::makeDigitalSurface( digitized_shape,
K, params );
65 auto surfels = SH3::getSurfelRange(
surface, params );
67 regul.init();
68 regul.attachConvolvedTrivialNormalVectors(params);
70 double energy = regul.computeGradient();
72 REQUIRE( energy == Approx(1684.340));
74 auto finalenergy = regul.regularize();
76 REQUIRE( finalenergy == Approx( 4.7763 ) );
78
80 auto regularizedPosition = regul.getRegularizedPositions();
81 auto original = regul.getOriginalPositions();
83 auto normals = regul.getNormalVectors();
84
85 auto cellIndex = regul.getCellIndex();
86 SH3::saveOBJ(
surface, [&] (
const SH3::Cell &c){
return original[ cellIndex[c]];},
87 normals, SH3::Colors(), "originalSurf.obj");
88 SH3::saveOBJ(
surface, [&] (
const SH3::Cell &c){
return regularizedPosition[ cellIndex[c]];},
89 normals, SH3::Colors(), "regularizedSurf.obj");
90
91
92 regul.reset();
93 regularizedPosition = regul.getRegularizedPositions();
94 REQUIRE( original[0] == regularizedPosition[0] );
95 REQUIRE( original[123] == regularizedPosition[123] );
96
97
99 regularizedPosition = regul.getRegularizedPositions();
100 SH3::saveOBJ(
surface, [&] (
const SH3::Cell &c){
return regularizedPosition[ cellIndex[c]];},
101 normals, SH3::Colors(), "regularizedSurfClamped.obj");
102 REQUIRE( finalenergyClamped == Approx(12.1914) );
103 REQUIRE( finalenergy < finalenergyClamped );
104
105
106 auto aPointelIndex = cellIndex.begin();
107 REQUIRE( regularizedPosition[ aPointelIndex->second ] == regul.getRegularizedPosition( aPointelIndex->first) );
108 }
109
110 SECTION(
"Basic Construction with II Normal Vectors")
111 {
112 auto surface = SH3::makeDigitalSurface( digitized_shape,
K, params );
113 auto surfels = SH3::getSurfelRange(
surface, params );
115 auto ii_normals = SHG3::getIINormalVectors(digitized_shape, surfels, params);
117 regul.init();
118 auto surfelIndex = regul.getSurfelIndex();
119 regul.attachNormalVectors([&](SH3::SCell &c){ return ii_normals[ surfelIndex[c] ];} );
121
122 double energy = regul.computeGradient();
124 REQUIRE( energy == Approx(1588.649));
125 regul.regularize();
127
128 auto regularizedPosition = regul.getRegularizedPositions();
129 auto normals = regul.getNormalVectors();
130 auto cellIndex = regul.getCellIndex();
131 SH3::saveOBJ(
surface, [&] (
const SH3::Cell &c){
return regularizedPosition[ cellIndex[c]];},
132 normals, SH3::Colors(), "regularizedSurf-II.obj");
133 }
134
136 {
137 auto surface = SH3::makeDigitalSurface( digitized_shape,
K, params );
138 auto surfels = SH3::getSurfelRange(
surface, params );
140 regul.init();
141 regul.attachConvolvedTrivialNormalVectors(params);
143 auto energy = regul.regularize(10,1.0,0.1);
144 auto secondenergy = regul.regularize(10,1.0,0.1);
145 auto thirdenergy = regul.regularize(10,1.0,0.1);
149
150 REQUIRE( energy > secondenergy );
151 REQUIRE( secondenergy > thirdenergy );
152 }
153
155 {
156 auto surface = SH3::makeDigitalSurface( digitized_shape,
K, params );
157 auto surfels = SH3::getSurfelRange(
surface, params );
159 regul.init();
160 regul.attachConvolvedTrivialNormalVectors(params);
162 auto energy = regul.regularize(10,1.0,0.1);
163
164 auto original = regul.getOriginalPositions();
165 std::vector<double> alphas(original.size(),0.001);
166 std::vector<double> betas(original.size(),1.0);
167 std::vector<double> gammas(original.size(), 0.05);
168
169
171 regul2.init(alphas,betas,gammas);
172 regul2.attachConvolvedTrivialNormalVectors(params);
173 auto energybis = regul2.regularize(10,1.0,0.1);
174 REQUIRE( energy == energybis );
175
176 energybis = regul2.regularize();
177 auto regularizedPosition = regul.getRegularizedPositions();
178 auto normals = regul.getNormalVectors();
179 auto cellIndex = regul.getCellIndex();
180 SH3::saveOBJ(
surface, [&] (
const SH3::Cell &c){
return regularizedPosition[ cellIndex[c]];},
181 normals, SH3::Colors(), "regularizedSurf-local.obj");
182
183
186 for(size_t i = 0 ; i < original.size(); ++i)
187 if (original[i][0]<0.0)
188 {
189 alphas[i] = 4.0;
190 betas[i] = 0.0000001;
191 gammas[i] = 0.0;
192 }
193 regul3.init(alphas,betas,gammas);
194 regul3.attachConvolvedTrivialNormalVectors(params);
195 energybis = regul3.regularize();
197
198 regularizedPosition = regul3.getRegularizedPositions();
199 SH3::saveOBJ(
surface, [&] (
const SH3::Cell &c){
return regularizedPosition[ cellIndex[c]];},
200 normals, SH3::Colors(), "regularizedSurf-localsplit.obj");
201 }
202}
Aim: Implements Digital Surface Regularization as described in .
Aim: This class is used to simplify shape and surface creation. With it, you can create new shapes an...
Aim: This class is used to simplify shape and surface creation. With it, you can create new shapes an...
CountedPtr< SH3::DigitalSurface > surface
ShortcutsGeometry< Z3i::KSpace > SHG3
SECTION("Testing constant forward iterators")
REQUIRE(domain.isInside(aPoint))