DGtal  1.3.beta
Functions
testDigitalConvexity.cpp File Reference
#include <iostream>
#include <vector>
#include <algorithm>
#include "DGtal/base/Common.h"
#include "DGtal/kernel/SpaceND.h"
#include "DGtal/topology/KhalimskySpaceND.h"
#include "DGtal/geometry/volumes/CellGeometry.h"
#include "DGtal/geometry/volumes/DigitalConvexity.h"
#include "DGtalCatch.h"
Include dependency graph for testDigitalConvexity.cpp:

Go to the source code of this file.

Functions

 SCENARIO ("DigitalConvexity< Z2 > unit tests", "[digital_convexity][2d]")
 
 SCENARIO ("DigitalConvexity< Z2 > fully convex triangles", "[convex_simplices][2d]")
 
 SCENARIO ("DigitalConvexity< Z3 > fully convex tetrahedra", "[convex_simplices][3d]")
 
 SCENARIO ("DigitalConvexity< Z3 > rational fully convex tetrahedra", "[convex_simplices][3d][rational]")
 
 SCENARIO ("DigitalConvexity< Z2 > rational fully convex tetrahedra", "[convex_simplices][2d][rational]")
 
 SCENARIO ("DigitalConvexity< Z3 > full subconvexity of segments and triangles", "[subconvexity][3d]")
 

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 5127), University of Savoie, France
Date
2020/02/01

Functions for testing class DigitalConvexity.

This file is part of the DGtal library.

Definition in file testDigitalConvexity.cpp.

Function Documentation

◆ SCENARIO() [1/6]

SCENARIO ( "DigitalConvexity< Z2 > fully convex triangles"  ,
""  [convex_simplices][2d] 
)

Definition at line 113 of file testDigitalConvexity.cpp.

114 {
116  typedef KSpace::Point Point;
117  typedef KSpace::Space Space;
119  typedef DigitalConvexity< KSpace > DConvexity;
120 
121  Domain domain( Point( 0, 0 ), Point( 4, 4 ) );
122  DConvexity dconv( Point( -1, -1 ), Point( 5, 5 ) );
123 
124  WHEN( "Computing all triangles in domain (0,0)-(4,4)." ) {
125  unsigned int nb_notsimplex = 0;
126  unsigned int nb_invalid = 0;
127  unsigned int nb_degenerated= 0;
128  unsigned int nb_common = 0;
129  unsigned int nb_unitary = 0;
130  for ( auto a : domain )
131  for ( auto b : domain )
132  for ( auto c : domain )
133  {
134  nb_notsimplex += ! dconv.isSimplexFullDimensional( { a, b, c } ) ? 1 : 0;
135  auto tri_type = dconv.simplexType( { a, b, c } );
136  nb_degenerated += tri_type == DConvexity::SimplexType::DEGENERATED ? 1 : 0;
137  nb_invalid += tri_type == DConvexity::SimplexType::INVALID ? 1 : 0;
138  nb_unitary += tri_type == DConvexity::SimplexType::UNITARY ? 1 : 0;
139  nb_common += tri_type == DConvexity::SimplexType::COMMON ? 1 : 0;
140  }
141  THEN( "All 2737 invalid triangles are degenerated " ) {
142  REQUIRE( nb_invalid == 0 );
143  REQUIRE( nb_notsimplex == nb_degenerated );
144  REQUIRE( nb_degenerated == 2737 );
145  }
146  THEN( "There are 12888 valid triangles" ) {
147  REQUIRE( nb_unitary + nb_common == 12888 );
148  }
149  THEN( "There are fewer (1920) unitary triangles than common triangles (10968)" ) {
150  REQUIRE( nb_unitary == 1920 );
151  REQUIRE( nb_common == 10968 );
152  REQUIRE( nb_unitary < nb_common );
153  }
154  THEN( "The total number of triangles (unitary, common, degenerated) is (domain size)^3, i.e. 5^6" ) {
155  REQUIRE( nb_unitary + nb_common + nb_degenerated == 5*5*5*5*5*5 );
156  }
157  }
158  WHEN( "Computing all triangles in domain (0,0)-(4,4)." ) {
159  unsigned int nbsimplex= 0;
160  unsigned int nb0 = 0;
161  unsigned int nb1 = 0;
162  unsigned int nb2 = 0;
163  unsigned int nb01_not2 = 0;
164  for ( auto a : domain )
165  for ( auto b : domain )
166  for ( auto c : domain )
167  {
168  if ( ! ( ( a < b ) && ( b < c ) ) ) continue;
169  if ( ! dconv.isSimplexFullDimensional( { a, b, c } ) ) continue;
170  auto triangle = dconv.makeSimplex( { a, b, c } );
171  bool cvx0 = dconv.isKConvex( triangle, 0 );
172  bool cvx1 = dconv.isKConvex( triangle, 1 );
173  bool cvx2 = dconv.isKConvex( triangle, 2 );
174  nbsimplex += 1;
175  nb0 += cvx0 ? 1 : 0;
176  nb1 += cvx1 ? 1 : 0;
177  nb2 += cvx2 ? 1 : 0;
178  nb01_not2 += ( cvx0 && cvx1 && ! cvx2 ) ? 1 : 0;
179  }
180  THEN( "All valid triangles are 0-convex." ) {
181  REQUIRE( nb0 == nbsimplex );
182  }
183  THEN( "There are less 1-convex and 2-convex than 0-convex." ) {
184  REQUIRE( nb1 < nb0 );
185  REQUIRE( nb2 < nb0 );
186  }
187  THEN( "When the triangle is 0-convex and 1-convex, then it is 2-convex." ) {
188  REQUIRE( nb1 <= nb2 );
189  REQUIRE( nb01_not2 == 0 );
190  }
191  }
192 }

References domain, and REQUIRE().

◆ SCENARIO() [2/6]

SCENARIO ( "DigitalConvexity< Z2 > rational fully convex tetrahedra"  ,
""  [convex_simplices][2d][rational] 
)

Definition at line 365 of file testDigitalConvexity.cpp.

366 {
368  typedef KSpace::Point Point;
369  typedef KSpace::Space Space;
370  typedef DigitalConvexity< KSpace > DConvexity;
371 
372  DConvexity dconv( Point( -1, -1 ), Point( 10, 10 ) );
373  WHEN( "Computing many triangle in domain (0,0)-(9,9)." ) {
374  const unsigned int nb = 100;
375  unsigned int nbsimplex= 0;
376  unsigned int nb0 = 0;
377  unsigned int nb1 = 0;
378  unsigned int nb2 = 0;
379  unsigned int nb01_not2 = 0;
380  unsigned int nbf = 0;
381  unsigned int nb012 = 0;
382  for ( unsigned int i = 0; i < nb; ++i )
383  {
384  Point a( 2*(rand() % 10), rand() % 20 );
385  Point b( rand() % 20 , 2*(rand() % 10) );
386  Point c( 2*(rand() % 10), 2*(rand() % 10) );
387  if ( ! dconv.isSimplexFullDimensional( { a, b, c } ) ) continue;
388  auto tetra = dconv.makeRationalSimplex( { Point(2,2), a, b, c } );
389  bool cvx0 = dconv.isKConvex( tetra, 0 );
390  bool cvx1 = dconv.isKConvex( tetra, 1 );
391  bool cvx2 = dconv.isKConvex( tetra, 2 );
392  bool cvxf = dconv.isFullyConvex( tetra );
393  nbsimplex += 1;
394  nb0 += cvx0 ? 1 : 0;
395  nb1 += cvx1 ? 1 : 0;
396  nb2 += cvx2 ? 1 : 0;
397  nbf += cvxf ? 1 : 0;
398  nb012 += ( cvx0 && cvx1 && cvx2 ) ? 1 : 0;
399  nb01_not2 += ( cvx0 && cvx1 && ! cvx2 ) ? 1 : 0;
400  }
401  THEN( "All valid tetrahedra are 0-convex." ) {
402  REQUIRE( nb0 == nbsimplex );
403  }
404  THEN( "There are less 1-convex, 2-convex than 0-convex." ) {
405  REQUIRE( nb1 < nb0 );
406  REQUIRE( nb2 < nb0 );
407  }
408  THEN( "When the tetrahedron is 0-convex, and 1-convex, then it is 2-convex." ) {
409  CAPTURE( nb0 );
410  CAPTURE( nb1 );
411  CAPTURE( nb2 );
412  CAPTURE( nb01_not2 );
413  CAPTURE( nbf );
414  REQUIRE( nb1 <= nb2 );
415  REQUIRE( nb01_not2 == 0 );
416  REQUIRE( nbf == nb012 );
417  }
418  }
419 }

References CAPTURE(), and REQUIRE().

◆ SCENARIO() [3/6]

SCENARIO ( "DigitalConvexity< Z2 > unit tests"  ,
""  [digital_convexity][2d] 
)

Definition at line 50 of file testDigitalConvexity.cpp.

51 {
53  typedef KSpace::Point Point;
54  typedef DigitalConvexity< KSpace > DConvexity;
55 
56  DConvexity dconv( Point( -5, -5 ), Point( 10, 10 ) );
57 
58  GIVEN( "Given a fat simplex { (0,0), (4,-1), (2,5) } " ) {
59  std::vector<Point> V = { Point(0,0), Point(4,-1), Point(2,5) };
60  auto vertex_cover = dconv.makeCellCover( V.begin(), V.end() );
61  auto fat_simplex = dconv.makeSimplex ( V.begin(), V.end() );
62  auto inside_pts = dconv.insidePoints ( fat_simplex );
63  auto simplex_cover = dconv.makeCellCover( fat_simplex );
64  auto point_cover = dconv.makeCellCover( inside_pts.begin(), inside_pts.end() );
65  THEN( "The fat simplex is not degenerated." ) {
66  REQUIRE( dconv.isSimplexFullDimensional( V.begin(), V.end() ) );
67  }
68  THEN( "Its vertex cover contains 3 0-cells, 12 1-cells, 12 2-cells" ) {
69  REQUIRE( vertex_cover.computeNbCells( 0 ) == 3 );
70  REQUIRE( vertex_cover.computeNbCells( 1 ) == 12 );
71  REQUIRE( vertex_cover.computeNbCells( 2 ) == 12 );
72  }
73  THEN( "Its vertex cover is a subset of its point cover" ) {
74  REQUIRE( vertex_cover.subset( point_cover ) );
75  }
76  THEN( "Its point cover is a subset of its simplex cover" ) {
77  REQUIRE( point_cover.subset( simplex_cover ) );
78  }
79  THEN( "Being fat, its simplex cover is equal to its point cover" ) {
80  REQUIRE( simplex_cover.subset( point_cover ) );
81  }
82  }
83  GIVEN( "Given a thin simplex { (0,0), (4,3), (7,5) } " ) {
84  std::vector<Point> V = { Point(0,0), Point(4,3), Point(7,5) };
85  auto vertex_cover = dconv.makeCellCover( V.begin(), V.end() );
86  auto thin_simplex = dconv.makeSimplex ( V.begin(), V.end() );
87  auto inside_pts = dconv.insidePoints ( thin_simplex );
88  auto simplex_cover = dconv.makeCellCover( thin_simplex );
89  auto point_cover = dconv.makeCellCover( inside_pts.begin(), inside_pts.end() );
90  THEN( "The thin simplex is not degenerated." ) {
91  REQUIRE( dconv.isSimplexFullDimensional( V.begin(), V.end() ) );
92  }
93  THEN( "Its vertex cover contains 3 0-cells, 12 1-cells, 12 2-cells" ) {
94  REQUIRE( vertex_cover.computeNbCells( 0 ) == 3 );
95  REQUIRE( vertex_cover.computeNbCells( 1 ) == 12 );
96  REQUIRE( vertex_cover.computeNbCells( 2 ) == 12 );
97  }
98  THEN( "Its vertex cover is a subset of its point cover" ) {
99  REQUIRE( vertex_cover.subset( point_cover ) );
100  }
101  THEN( "Its point cover is a subset of its simplex cover" ) {
102  REQUIRE( point_cover.subset( simplex_cover ) );
103  }
104  THEN( "Being thin, its simplex cover is not equal to its point cover for 1<=dim<=2" ) {
105  REQUIRE( ! simplex_cover.subset( point_cover ) );
106  REQUIRE( simplex_cover.subset( point_cover, 0 ) );
107  REQUIRE( ! simplex_cover.subset( point_cover, 1 ) );
108  REQUIRE( ! simplex_cover.subset( point_cover, 2 ) );
109  }
110  }
111 }

References GIVEN(), and REQUIRE().

◆ SCENARIO() [4/6]

SCENARIO ( "DigitalConvexity< Z3 > full subconvexity of segments and triangles"  ,
""  [subconvexity][3d] 
)

Definition at line 421 of file testDigitalConvexity.cpp.

422 {
424  typedef KSpace::Point Point;
425  typedef KSpace::Space Space;
427  typedef DigitalConvexity< KSpace > DConvexity;
428 
429  Domain domain( Point( -5, -5, -5 ), Point( 5, 5, 5 ) );
430  DConvexity dconv( Point( -6, -6, -6 ), Point( 6, 6, 6 ) );
431 
432  WHEN( "Computing many tetrahedra" ) {
433  const unsigned int nb = 100;
434  unsigned int nb_fulldim = 0;
435  unsigned int nb_ok_seg = 0;
436  unsigned int nb_ok_tri = 0;
437  for ( unsigned int l = 0; l < nb; ++l )
438  {
439  const Point a { (rand() % 10 - 5), (rand() % 10 - 5), (rand() % 10 - 5) };
440  const Point b { (rand() % 10 - 5), (rand() % 10 - 5), (rand() % 10 - 5) };
441  const Point c { (rand() % 10 - 5), (rand() % 10 - 5), (rand() % 10 - 5) };
442  const Point d { (rand() % 10 - 5), (rand() % 10 - 5), (rand() % 10 - 5) };
443  const std::vector<Point> pts = { a, b, c, d };
444  const bool fulldim = dconv.isSimplexFullDimensional(pts.cbegin(), pts.cend());
445  nb_fulldim += fulldim ? 1 : 0;
446  if ( ! fulldim ) continue;
447  auto simplex = dconv.makeSimplex( pts.cbegin(), pts.cend() );
448  auto cover = dconv.makeCellCover( simplex, 0, 3 );
449  {
450  unsigned int nb_subconvex = 0;
451  unsigned int nb_total = 0;
452  for ( unsigned int i = 0; i < 4; i++ )
453  for ( unsigned int j = i+1; j < 4; j++ )
454  {
455  auto segment = dconv.makeSimplex( { pts[ i ], pts[ j ] } );
456  bool ok = dconv.isFullySubconvex( segment, cover );
457  nb_subconvex += ok ? 1 : 0;
458  nb_total += 1;
459  if ( ! ok ) {
460  trace.info() << "****** SEGMENT NOT SUBCONVEX ******" << std::endl;
461  trace.info() << "splx v =" << a << b << c << d << std::endl;
462  trace.info() << "simplex=" << simplex << std::endl;
463  trace.info() << "seg v =" << pts[ i ] << pts[ j ] << std::endl;
464  trace.info() << "segment=" << segment << std::endl;
465  }
466  }
467  nb_ok_seg += ( nb_subconvex == nb_total ) ? 1 : 0;
468  }
469  {
470  unsigned int nb_subconvex = 0;
471  unsigned int nb_total = 0;
472  for ( unsigned int i = 0; i < 4; i++ )
473  for ( unsigned int j = i+1; j < 4; j++ )
474  for ( unsigned int k = j+1; k < 4; k++ )
475  {
476  auto triangle = dconv.makeSimplex({ pts[ i ], pts[ j ], pts[ k ] });
477  bool ok = dconv.isFullySubconvex( triangle, cover );
478  nb_subconvex += ok ? 1 : 0;
479  nb_total += 1;
480  if ( ! ok ) {
481  trace.info() << "****** TRIANGLE NOT SUBCONVEX ****" << std::endl;
482  trace.info() << "splx v =" << a << b << c << d << std::endl;
483  trace.info() << "simplex=" << simplex << std::endl;
484  trace.info() << "tri v =" << pts[ i ] << pts[ j ]
485  << pts[ k ] << std::endl;
486  trace.info() << "triangle=" << triangle << std::endl;
487  }
488  }
489  nb_ok_tri += ( nb_subconvex == nb_total ) ? 1 : 0;
490  }
491  }
492  THEN( "At least half the tetrahedra are full dimensional." ) {
493  REQUIRE( nb_fulldim >= nb / 2 );
494  }
495  THEN( "All segments of a tetrahedron should be subconvex to it." ) {
496  REQUIRE( nb_ok_seg == nb_fulldim );
497  }
498  THEN( "All triangles of a tetrahedron should be subconvex to it." ) {
499  REQUIRE( nb_ok_tri == nb_fulldim );
500  }
501  }
502 }

References domain, DGtal::Trace::info(), REQUIRE(), and DGtal::trace.

◆ SCENARIO() [5/6]

SCENARIO ( "DigitalConvexity< Z3 > fully convex tetrahedra"  ,
""  [convex_simplices][3d] 
)

Definition at line 193 of file testDigitalConvexity.cpp.

194 {
196  typedef KSpace::Point Point;
197  typedef KSpace::Space Space;
199  typedef DigitalConvexity< KSpace > DConvexity;
200 
201  Domain domain( Point( 0, 0, 0 ), Point( 3, 3, 3 ) );
202  DConvexity dconv( Point( -1, -1, -1 ), Point( 4, 4, 4 ) );
203 
204  WHEN( "Computing all lexicographically ordered tetrahedra anchored at (0,0,0) in domain (0,0,0)-(3,3,3)." ) {
205  unsigned int nb_notsimplex = 0;
206  unsigned int nb_invalid = 0;
207  unsigned int nb_degenerated= 0;
208  unsigned int nb_common = 0;
209  unsigned int nb_unitary = 0;
210  Point a(0,0,0);
211  for ( auto b : domain )
212  for ( auto c : domain )
213  for ( auto d : domain )
214  {
215  if ( ! ( ( a < b ) && ( b < c ) && ( c < d ) ) ) continue;
216  nb_notsimplex += ! dconv.isSimplexFullDimensional( {a,b,c,d} ) ? 1 : 0;
217  auto tri_type = dconv.simplexType( { a, b, c, d } );
218  nb_degenerated += tri_type == DConvexity::SimplexType::DEGENERATED ? 1 : 0;
219  nb_invalid += tri_type == DConvexity::SimplexType::INVALID ? 1 : 0;
220  nb_unitary += tri_type == DConvexity::SimplexType::UNITARY ? 1 : 0;
221  nb_common += tri_type == DConvexity::SimplexType::COMMON ? 1 : 0;
222  }
223  THEN( "All 4228 invalid tetrahedra are degenerated " ) {
224  REQUIRE( nb_invalid == 0 );
225  REQUIRE( nb_notsimplex == nb_degenerated );
226  REQUIRE( nb_degenerated == 4228 );
227  }
228  THEN( "There are 35483 valid tetrahedra" ) {
229  REQUIRE( nb_unitary + nb_common == 35483 );
230  }
231  THEN( "There are fewer (2515) unitary triangles than common triangles (32968)" ) {
232  REQUIRE( nb_unitary == 2515 );
233  REQUIRE( nb_common == 32968 );
234  REQUIRE( nb_unitary < nb_common );
235  }
236  THEN( "The total number of triangles (unitary, common, degenerated) is 39711" ) {
237  REQUIRE( nb_unitary + nb_common + nb_degenerated == 39711 );
238  }
239  }
240  WHEN( "Computing many tetrahedra in domain (0,0,0)-(4,4,4)." ) {
241  const unsigned int nb = 100;
242  unsigned int nbsimplex= 0;
243  unsigned int nb0 = 0;
244  unsigned int nb1 = 0;
245  unsigned int nb2 = 0;
246  unsigned int nb3 = 0;
247  unsigned int nb012_not3 = 0;
248  unsigned int nbf = 0;
249  unsigned int nbfg = 0;
250  unsigned int nb0123 = 0;
251  for ( unsigned int i = 0; i < nb; ++i )
252  {
253  Point a( rand() % 5, rand() % 5, rand() % 5 );
254  Point b( rand() % 5, rand() % 5, rand() % 5 );
255  Point c( rand() % 5, rand() % 5, rand() % 5 );
256  Point d( rand() % 5, rand() % 5, rand() % 5 );
257  if ( ! dconv.isSimplexFullDimensional( { a, b, c, d } ) ) continue;
258  auto tetra = dconv.makeSimplex( { a, b, c, d } );
259  std::vector< Point > X;
260  tetra.getPoints( X );
261  bool cvx0 = dconv.isKConvex( tetra, 0 );
262  bool cvx1 = dconv.isKConvex( tetra, 1 );
263  bool cvx2 = dconv.isKConvex( tetra, 2 );
264  bool cvx3 = dconv.isKConvex( tetra, 3 );
265  bool cvxf = dconv.isFullyConvex( tetra );
266  bool cvxfg = dconv.isFullyConvex( X, false );
267  if ( cvxf != cvxfg ) {
268  std::cout << "[" << cvx0 << cvx1 << cvx2 << cvx3 << "] "
269  << "[" << cvxf << "] [" << cvxfg << "]"
270  << a << b << c << d << std::endl;
271  }
272  nbsimplex += 1;
273  nb0 += cvx0 ? 1 : 0;
274  nb1 += cvx1 ? 1 : 0;
275  nb2 += cvx2 ? 1 : 0;
276  nb3 += cvx3 ? 1 : 0;
277  nbf += cvxf ? 1 : 0;
278  nbfg += cvxfg ? 1 : 0;
279  nb0123 += ( cvx0 && cvx1 && cvx2 && cvx3 ) ? 1 : 0;
280  nb012_not3+= ( cvx0 && cvx1 && cvx2 && ! cvx3 ) ? 1 : 0;
281  }
282  THEN( "All valid tetrahedra are 0-convex." ) {
283  REQUIRE( nb0 == nbsimplex );
284  }
285  THEN( "There are less 1-convex, 2-convex and 3-convex than 0-convex." ) {
286  REQUIRE( nb1 < nb0 );
287  REQUIRE( nb2 < nb0 );
288  REQUIRE( nb3 < nb0 );
289  }
290  THEN( "When the tetrahedron is 0-convex, 1-convex and 2-convex, then it is 3-convex." ) {
291  REQUIRE( nb1 <= nb3 );
292  REQUIRE( nb2 <= nb3 );
293  REQUIRE( nb012_not3 == 0 );
294  REQUIRE( nbf == nb0123 );
295  }
296  THEN( "Both methods for computing full convexity agree." ) {
297  REQUIRE( nbf == nbfg );
298  }
299  }
300 }

References domain, and REQUIRE().

◆ SCENARIO() [6/6]

SCENARIO ( "DigitalConvexity< Z3 > rational fully convex tetrahedra"  ,
""  [convex_simplices][3d][rational] 
)

Definition at line 302 of file testDigitalConvexity.cpp.

303 {
305  typedef KSpace::Point Point;
306  typedef KSpace::Space Space;
307  typedef DigitalConvexity< KSpace > DConvexity;
308 
309  DConvexity dconv( Point( -1, -1, -1 ), Point( 10, 10, 10 ) );
310  WHEN( "Computing many tetrahedra in domain (0,0,0)-(4,4,4)." ) {
311  const unsigned int nb = 100;
312  unsigned int nbsimplex= 0;
313  unsigned int nb0 = 0;
314  unsigned int nb1 = 0;
315  unsigned int nb2 = 0;
316  unsigned int nb3 = 0;
317  unsigned int nb012_not3 = 0;
318  unsigned int nbf = 0;
319  unsigned int nb0123 = 0;
320  for ( unsigned int i = 0; i < nb; ++i )
321  {
322  Point a( 2*(rand() % 10), rand() % 20, 2*(rand() % 10) );
323  Point b( rand() % 20, 2*(rand() % 10), 2*(rand() % 10) );
324  Point c( 2*(rand() % 10), 2*(rand() % 10), rand() % 20 );
325  Point d( 2*(rand() % 10), 2*(rand() % 10), 2*(rand() % 10) );
326  if ( ! dconv.isSimplexFullDimensional( { a, b, c, d } ) ) continue;
327  auto tetra = dconv.makeRationalSimplex( { Point(2,2,2), a, b, c, d } );
328  bool cvx0 = dconv.isKConvex( tetra, 0 );
329  bool cvx1 = dconv.isKConvex( tetra, 1 );
330  bool cvx2 = dconv.isKConvex( tetra, 2 );
331  bool cvx3 = dconv.isKConvex( tetra, 3 );
332  bool cvxf = dconv.isFullyConvex( tetra );
333  nbsimplex += 1;
334  nb0 += cvx0 ? 1 : 0;
335  nb1 += cvx1 ? 1 : 0;
336  nb2 += cvx2 ? 1 : 0;
337  nb3 += cvx3 ? 1 : 0;
338  nbf += cvxf ? 1 : 0;
339  nb0123 += ( cvx0 && cvx1 && cvx2 && cvx3 ) ? 1 : 0;
340  nb012_not3+= ( cvx0 && cvx1 && cvx2 && ! cvx3 ) ? 1 : 0;
341  }
342  THEN( "All valid tetrahedra are 0-convex." ) {
343  REQUIRE( nb0 == nbsimplex );
344  }
345  THEN( "There are less 1-convex, 2-convex and 3-convex than 0-convex." ) {
346  REQUIRE( nb1 < nb0 );
347  REQUIRE( nb2 < nb0 );
348  REQUIRE( nb3 < nb0 );
349  }
350  THEN( "When the tetrahedron is 0-convex, 1-convex and 2-convex, then it is 3-convex." ) {
351  CAPTURE( nb0 );
352  CAPTURE( nb1 );
353  CAPTURE( nb2 );
354  CAPTURE( nb3 );
355  CAPTURE( nb012_not3 );
356  CAPTURE( nbf );
357  REQUIRE( nb2 <= nb3 );
358  REQUIRE( nb012_not3 == 0 );
359  REQUIRE( nbf == nb0123 );
360  }
361  }
362 }

References CAPTURE(), and REQUIRE().

DGtal::HyperRectDomain< Space >
DGtal::trace
Trace trace
Definition: Common.h:154
REQUIRE
REQUIRE(domain.isInside(aPoint))
DGtal::SpaceND
Definition: SpaceND.h:95
KSpace
Z3i::KSpace KSpace
Definition: testArithmeticalDSSComputerOnSurfels.cpp:48
CAPTURE
CAPTURE(thicknessHV)
DGtal::Trace::info
std::ostream & info()
Domain
HyperRectDomain< Space > Domain
Definition: testSimpleRandomAccessRangeFromPoint.cpp:44
domain
Domain domain
Definition: testProjection.cpp:88
DGtal::PointVector< dim, Integer >
Space
SpaceND< 2 > Space
Definition: testSimpleRandomAccessRangeFromPoint.cpp:42
DGtal::DigitalConvexity< KSpace >
GIVEN
GIVEN("A cubical complex with random 3-cells")
Definition: testCubicalComplex.cpp:70
Point
MyPointD Point
Definition: testClone2.cpp:383
DGtal::KhalimskySpaceND
Aim: This class is a model of CCellularGridSpaceND. It represents the cubical grid as a cell complex,...
Definition: KhalimskySpaceND.h:64