DGtal 1.4.0
Loading...
Searching...
No Matches
testCubicalComplex.cpp File Reference
#include <iostream>
#include <map>
#include <unordered_map>
#include "DGtal/base/Common.h"
#include "DGtal/kernel/domains/HyperRectDomain.h"
#include "DGtal/topology/KhalimskySpaceND.h"
#include "DGtal/topology/KhalimskyCellHashFunctions.h"
#include "DGtal/topology/CubicalComplex.h"
#include "DGtalCatch.h"
Include dependency graph for testCubicalComplex.cpp:

Go to the source code of this file.

Typedefs

typedef KSpace::Point Point
 
typedef KSpace::Cell Cell
 
typedef std::unordered_map< Cell, CubicalCellDataMap
 
typedef CubicalComplex< KSpace, MapCC
 
typedef CC::CellMapConstIterator CellMapConstIterator
 

Functions

 srand (0)
 
K init (Point(0, 0, 0), Point(512, 512, 512), true)
 
std::vector< int > nbCoFaces (4, 0)
 
std::vector< int > nbFaces (6, 0)
 
std::vector< int > nbFaces2 (6, 0)
 
std::vector< int > nbBdry (10, 0)
 
std::vector< int > nbBdry2 (10, 0)
 
 GIVEN ("A cubical complex with random 3-cells")
 
 SCENARIO ("CubicalComplex< K3,std::unordered_map<> > collapse tests", "[cubical_complex][collapse]")
 
 SCENARIO ("CubicalComplex< K3,std::unordered_map<> > link tests", "[cubical_complex][link]")
 
 SCENARIO ("CubicalComplex< K3,std::map<> > collapse tests", "[cubical_complex][collapse]")
 
 SCENARIO ("CubicalComplex< K3,std::map<> > link tests", "[cubical_complex][link]")
 
 SCENARIO ("CubicalComplex< K3,std::map<> > concept check tests", "[cubical_complex][concepts]")
 
 SCENARIO ("CubicalComplex< K2,std::map<> > set operations and relations", "[cubical_complex][ccops]")
 

Variables

static const int NBCELLS = 1000
 
KSpace K
 

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
2015/08/28

Functions for testing class CubicalComplex.

This file is part of the DGtal library.

Definition in file testCubicalComplex.cpp.

Typedef Documentation

◆ CC

◆ Cell

◆ CellMapConstIterator

◆ Map

◆ Point

Initial value:
{
Aim: This class is a model of CCellularGridSpaceND. It represents the cubical grid as a cell complex,...

Definition at line 55 of file testCubicalComplex.cpp.

Function Documentation

◆ GIVEN()

GIVEN ( "A cubical complex with random 3-cells" )

Definition at line 70 of file testCubicalComplex.cpp.

70 {
71 CC complex( K );
72 for ( int n = 0; n < NBCELLS; ++n )
73 {
74 Point p( (rand() % 512) | 0x1, (rand() % 512) | 0x1, (rand() % 512) | 0x1 );
75 Cell cell = K.uCell( p );
76 complex.insertCell( cell );
77 }
78 THEN( "It has only 3-cells and no other type of cells" ) {
79 REQUIRE( complex.nbCells( 0 ) == 0 );
80 REQUIRE( complex.nbCells( 1 ) == 0 );
81 REQUIRE( complex.nbCells( 2 ) == 0 );
82 REQUIRE( complex.nbCells( 3 ) > 0 );
83 }
84
85 WHEN( "Computing proper faces of these 3-cells" ) {
86 std::vector<Cell> faces;
87 std::back_insert_iterator< std::vector<Cell> > outIt( faces );
88 for ( CellMapConstIterator it = complex.begin( 3 ), itE = complex.end( 3 );
89 it != itE; ++it )
90 complex.faces( outIt, it->first );
91 THEN( "There are no proper faces within this complex" ) {
92 REQUIRE( faces.size() == 0 );
93 }
94 }
95
96 WHEN( "Closing the cubical complex" ) {
97 complex.close();
98 THEN( "It has cells of all dimensions." ) {
99 REQUIRE( complex.nbCells( 0 ) > 0 );
100 REQUIRE( complex.nbCells( 1 ) > 0 );
101 REQUIRE( complex.nbCells( 2 ) > 0 );
102 }
103
104 WHEN( "Computing the direct co-faces of 2-cells" ) {
105 for ( CellMapConstIterator it = complex.begin( 2 ), itE = complex.end( 2 );
106 it != itE; ++it )
107 {
108 std::vector<Cell> faces;
109 std::back_insert_iterator< std::vector<Cell> > outIt( faces );
110 complex.directCoFaces( outIt, it->first );
111 int n = static_cast<int>(faces.size());
112 if ( n >= 3 ) n = 3; // should not happen
113 nbCoFaces[ n ]++;
114 }
115 THEN( "None of them are incident to zero 3-cells" ) {
116 REQUIRE( nbCoFaces[ 0 ] == 0 );
117 } AND_THEN ( "Most of them are incident to one 3-cells and some of them to two 3-cells" ) {
118 REQUIRE( nbCoFaces[ 1 ] > 10*nbCoFaces[ 2 ] );
119 } AND_THEN ("None of them are incident to three or more 3-cells" ) {
120 REQUIRE( nbCoFaces[ 3 ] == 0 );
121 }
122 }
123
124 WHEN( "Computing direct faces of 2-cells" ) {
125 for ( CellMapConstIterator it = complex.begin( 2 ), itE = complex.end( 2 );
126 it != itE; ++it )
127 {
128 std::vector<Cell> faces;
129 std::back_insert_iterator< std::vector<Cell> > outIt( faces );
130 complex.directFaces( outIt, it->first, true );
131 auto n = faces.size();
132 if ( n < 4 ) n = 3; // should not happen
133 if ( n > 4 ) n = 5; // should not happen
134 nbFaces[ n ]++;
135 }
136 for ( CellMapConstIterator it = complex.begin( 2 ), itE = complex.end( 2 );
137 it != itE; ++it )
138 {
139 std::vector<Cell> faces;
140 std::back_insert_iterator< std::vector<Cell> > outIt( faces );
141 complex.directFaces( outIt, it->first );
142 auto n = faces.size();
143 if ( n < 4 ) n = 3; // should not happen
144 if ( n > 4 ) n = 5; // should not happen
145 nbFaces2[ n ]++;
146 }
147 THEN( "All of them have exactly 4 incident 1-cells when computed with hint closed" ) {
148 REQUIRE( nbFaces[ 3 ] == 0 );
149 REQUIRE( nbFaces[ 4 ] > 0 );
150 REQUIRE( nbFaces[ 5 ] == 0 );
151 } AND_THEN( "All of them have exactly 4 incident 1-cells when computed without hint" ) {
152 REQUIRE( nbFaces2[ 3 ] == 0 );
153 REQUIRE( nbFaces2[ 4 ] > 0 );
154 REQUIRE( nbFaces2[ 5 ] == 0 );
155 } AND_THEN( "It gives the same number of incident cells with or without hint" ) {
156 REQUIRE( nbFaces[ 4 ] == nbFaces2[ 4 ] );
157 }
158 }
159
160 WHEN( "Computing boundaries of 2-cells" ) {
161 for ( CellMapConstIterator it = complex.begin( 2 ), itE = complex.end( 2 );
162 it != itE; ++it )
163 {
164 CC::Cells faces = complex.cellBoundary( it->first, true );
165 size_t n = faces.size();
166 if ( n < 8 ) n = 7; // should not happen
167 if ( n > 8 ) n = 9; // should not happen
168 nbBdry[ n ]++;
169 }
170 for ( CellMapConstIterator it = complex.begin( 2 ), itE = complex.end( 2 );
171 it != itE; ++it )
172 {
173 CC::Cells faces = complex.cellBoundary( it->first, false );
174 size_t n = faces.size();
175 if ( n < 8 ) n = 7; // should not happen
176 if ( n > 8 ) n = 9; // should not happen
177 nbBdry2[ n ]++;
178 }
179 THEN( "All of them contain exactly 8 cells when computed with hint closed" ) {
180 REQUIRE( nbBdry[ 7 ] == 0 );
181 REQUIRE( nbBdry[ 8 ] > 0 );
182 REQUIRE( nbBdry[ 9 ] == 0 );
183 } AND_THEN( "All of them contain exactly 8 cells when computed without hint" ) {
184 REQUIRE( nbBdry2[ 7 ] == 0 );
185 REQUIRE( nbBdry2[ 8 ] > 0 );
186 REQUIRE( nbBdry2[ 9 ] == 0 );
187 } AND_THEN( "It gives the same number of incident cells with or without hint" ) {
188 REQUIRE( nbBdry[ 8 ] == nbBdry2[ 8 ] );
189 }
190 }
191 } // WHEN( "Closing the cubical complex" ) {
192 }
Aim: This class represents an arbitrary cubical complex living in some Khalimsky space....
KSpace::Cells Cells
Type for a sequence of cells in the space.
Cell uCell(const PreCell &c) const
From an unsigned cell, returns an unsigned cell lying into this Khalismky space.
MyPointD Point
KSpace K
std::vector< int > nbFaces(6, 0)
std::vector< int > nbBdry2(10, 0)
static const int NBCELLS
std::vector< int > nbCoFaces(4, 0)
std::vector< int > nbBdry(10, 0)
CC::CellMapConstIterator CellMapConstIterator
std::vector< int > nbFaces2(6, 0)
REQUIRE(domain.isInside(aPoint))

References K, nbBdry(), nbBdry2(), NBCELLS, nbCoFaces(), nbFaces(), nbFaces2(), REQUIRE(), and DGtal::KhalimskySpaceND< dim, TInteger >::uCell().

Referenced by SCENARIO(), SCENARIO(), SCENARIO(), SCENARIO(), SCENARIO(), SCENARIO(), SCENARIO(), SCENARIO(), SCENARIO(), SCENARIO(), SCENARIO(), SCENARIO(), SCENARIO(), SCENARIO(), SCENARIO(), SCENARIO(), SCENARIO(), SCENARIO(), SCENARIO(), SCENARIO(), SCENARIO(), SCENARIO(), SCENARIO(), SCENARIO(), SCENARIO(), SCENARIO(), SCENARIO(), SCENARIO(), SCENARIO(), SCENARIO(), SCENARIO(), SCENARIO(), SCENARIO(), SCENARIO(), SCENARIO(), SCENARIO(), SCENARIO(), SCENARIO(), SCENARIO(), SCENARIO(), SCENARIO(), SCENARIO(), SCENARIO(), SCENARIO(), SCENARIO(), SCENARIO(), SCENARIO(), SCENARIO(), SCENARIO(), SCENARIO(), SCENARIO(), SCENARIO(), SCENARIO(), TEST_CASE_METHOD(), TEST_CASE_METHOD(), TEST_CASE_METHOD(), TEST_CASE_METHOD(), and TEST_CASE_METHOD().

◆ init()

K init ( Point(0, 0, 0) ,
Point(512, 512, 512) ,
true  )

Referenced by testSegmentationLarger().

◆ nbBdry()

std::vector< int > nbBdry ( 10 ,
0  )

Referenced by GIVEN().

◆ nbBdry2()

std::vector< int > nbBdry2 ( 10 ,
0  )

Referenced by GIVEN().

◆ nbCoFaces()

std::vector< int > nbCoFaces ( 4 ,
0  )

Referenced by GIVEN().

◆ nbFaces()

std::vector< int > nbFaces ( 6 ,
0  )

Referenced by GIVEN().

◆ nbFaces2()

std::vector< int > nbFaces2 ( 6 ,
0  )

Referenced by GIVEN().

◆ SCENARIO() [1/6]

SCENARIO ( "CubicalComplex< K2,std::map<> > set operations and relations" ,
"" [cubical_complex][ccops] )

Definition at line 576 of file testCubicalComplex.cpp.

577{
579 typedef KSpace::Space Space;
581 typedef KSpace::Point Point;
582 typedef KSpace::Cell Cell;
583 typedef std::map<Cell, CubicalCellData> Map;
585
586 KSpace K;
587 K.init( Point( 0,0 ), Point( 5,3 ), true );
588 Domain domain( Point( 0,0 ), Point( 5,3 ) );
589 CC X1( K );
590 X1.insertCell( K.uSpel( Point(1,1) ) );
591 X1.insertCell( K.uSpel( Point(2,1) ) );
592 X1.insertCell( K.uSpel( Point(3,1) ) );
593 X1.insertCell( K.uSpel( Point(2,2) ) );
594 CC X1c = ~ X1;
595
596 CC X2( K );
597 X2.insertCell( K.uSpel( Point(2,2) ) );
598 X2.insertCell( K.uSpel( Point(3,2) ) );
599 X2.insertCell( K.uSpel( Point(4,2) ) );
600 X2.close();
601 CC X2c = ~ X2;
602 REQUIRE( ( X1 & X2 ).size() < X1.size() );
603 bool X1_and_X2_included_in_X1 = ( X1 & X2 ) <= X1;
604 bool X1c_and_X2c_included_in_X1c = ( X1c & X2c ) <= X1c;
605 CC A = ~( X1 & X2 );
606 CC B = ~( *(X1c & X2c) );
607 CAPTURE( A );
608 CAPTURE( B );
609 bool cl_X1_and_X2_equal_to_X1c_and_X2c = A == B;
610
611 REQUIRE( X1_and_X2_included_in_X1 );
612 REQUIRE( X1c_and_X2c_included_in_X1c );
613 REQUIRE( cl_X1_and_X2_equal_to_X1c_and_X2c );
614
615 CC X1bd = X1c - *X1c;
616 CAPTURE( X1bd );
617 CAPTURE( X1.boundary() );
618 bool X1bd_equal_X1boundary = X1bd == X1.boundary();
619 REQUIRE( X1bd_equal_X1boundary );
620}
CubicalComplex boundary(bool hintClosed=false) const
Aim: Parallelepidec region of a digital space, model of a 'CDomain'.
Cell uSpel(Point p) const
From the digital coordinates of a point in Zn, builds the corresponding spel (cell of maximal dimensi...
bool init(const Point &lower, const Point &upper, bool isClosed)
Specifies the upper and lower bounds for the maximal cells in this space.
CAPTURE(thicknessHV)
KSpace::Point Point
std::unordered_map< Cell, CubicalCellData > Map
KSpace::Cell Cell
CubicalComplex< KSpace, Map > CC
Domain domain
HyperRectDomain< Space > Domain

References DGtal::CubicalComplex< TKSpace, TCellContainer >::boundary(), CAPTURE(), DGtal::CubicalComplex< TKSpace, TCellContainer >::close(), domain, DGtal::KhalimskySpaceND< dim, TInteger >::init(), DGtal::CubicalComplex< TKSpace, TCellContainer >::insertCell(), K, REQUIRE(), DGtal::CubicalComplex< TKSpace, TCellContainer >::size(), and DGtal::KhalimskySpaceND< dim, TInteger >::uSpel().

◆ SCENARIO() [2/6]

SCENARIO ( "CubicalComplex< K3,std::map<> > collapse tests" ,
"" [cubical_complex][collapse] )

Definition at line 454 of file testCubicalComplex.cpp.

455{
457 typedef KSpace::Point Point;
458 typedef KSpace::Cell Cell;
459 typedef KSpace::Integer Integer;
460 typedef std::map<Cell, CubicalCellData> Map;
462 typedef CC::CellMapIterator CellMapIterator;
463
464 srand( 0 );
465 KSpace K;
466 K.init( Point( 0,0,0 ), Point( 512,512,512 ), true );
467
468 GIVEN( "A closed cubical complex made of 3x3x3 voxels with their incident cells" ) {
469 CC complex( K );
470 std::vector<Cell> S;
471 for ( Integer x = 0; x < 3; ++x )
472 for ( Integer y = 0; y < 3; ++y )
473 for ( Integer z = 0; z < 3; ++z )
474 {
475 S.push_back( K.uSpel( Point( x, y, z ) ) );
476 complex.insertCell( S.back() );
477 }
478 complex.close();
479 CAPTURE( complex.nbCells( 0 ) );
480 CAPTURE( complex.nbCells( 1 ) );
481 CAPTURE( complex.nbCells( 2 ) );
482 CAPTURE( complex.nbCells( 3 ) );
483
484 THEN( "It has Euler characteristic 1" ) {
485 REQUIRE( complex.euler() == 1 );
486 }
487
488 WHEN( "Fixing two vertices of this big cube and collapsing it" ) {
489 CellMapIterator it1 = complex.findCell( 0, K.uCell( Point( 0, 0, 0 ) ) );
490 CellMapIterator it2 = complex.findCell( 0, K.uCell( Point( 4, 4, 4 ) ) );
491 REQUIRE( it1 != complex.end( 0 ) );
492 REQUIRE( it2 != complex.end( 0 ) );
493 it1->second.data |= CC::FIXED;
494 it2->second.data |= CC::FIXED;
496 functions::collapse( complex, S.begin(), S.end(), P, false, true );
497 CAPTURE( complex.nbCells( 0 ) );
498 CAPTURE( complex.nbCells( 1 ) );
499 CAPTURE( complex.nbCells( 2 ) );
500 CAPTURE( complex.nbCells( 3 ) );
501
502 THEN( "It keeps its topology so its euler characteristic is 1" ) {
503 REQUIRE( complex.euler() == 1 );
504 } AND_THEN( "It has no more 2-cells and 3-cells" ) {
505 REQUIRE( complex.nbCells( 2 ) == 0 );
506 REQUIRE( complex.nbCells( 3 ) == 0 );
507 } AND_THEN( "It has only 0-cells and 1-cells" ) {
508 REQUIRE( complex.nbCells( 0 ) > 0 );
509 REQUIRE( complex.nbCells( 1 ) > 0 );
510 }
511 }
512 }
513}
CellMap::iterator CellMapIterator
Iterator for visiting type CellMap.
TInteger Integer
Arithmetic ring induced by (+,-,*) and Integer numbers.
uint64_t collapse(CubicalComplex< TKSpace, TCellContainer > &K, CellConstIterator S_itB, CellConstIterator S_itE, const CellMapIteratorPriority &priority, bool hintIsSClosed=false, bool hintIsKClosed=false, bool verbose=false)
GIVEN("A cubical complex with random 3-cells")
srand(0)

References CAPTURE(), DGtal::functions::collapse(), GIVEN(), DGtal::KhalimskySpaceND< dim, TInteger >::init(), K, REQUIRE(), srand(), DGtal::KhalimskySpaceND< dim, TInteger >::uCell(), and DGtal::KhalimskySpaceND< dim, TInteger >::uSpel().

◆ SCENARIO() [3/6]

SCENARIO ( "CubicalComplex< K3,std::map<> > concept check tests" ,
"" [cubical_complex][concepts] )

Definition at line 563 of file testCubicalComplex.cpp.

564{
566 typedef KSpace::Cell Cell;
567 typedef std::map<Cell, CubicalCellData> Map;
569
570 BOOST_CONCEPT_ASSERT(( boost::Container<CC> ));
571 BOOST_CONCEPT_ASSERT(( boost::ForwardIterator<CC::Iterator> ));
572 BOOST_CONCEPT_ASSERT(( boost::ForwardIterator<CC::ConstIterator> ));
573}
Go to http://www.sgi.com/tech/stl/Container.html.
Definition Boost.dox:104
Go to http://www.sgi.com/tech/stl/ForwardIterator.html.
Definition Boost.dox:40

◆ SCENARIO() [4/6]

SCENARIO ( "CubicalComplex< K3,std::map<> > link tests" ,
"" [cubical_complex][link] )

Definition at line 515 of file testCubicalComplex.cpp.

516{
518 typedef KSpace::Point Point;
519 typedef KSpace::Cell Cell;
520 typedef KSpace::Integer Integer;
521 typedef std::map<Cell, CubicalCellData> Map;
523
524 srand( 0 );
525 KSpace K;
526 K.init( Point( 0,0,0 ), Point( 512,512,512 ), true );
527
528 GIVEN( "A closed cubical complex made of 10x10x10 voxels with their incident cells" ) {
529 CC X( K );
530 CC S( K );
531 for ( Integer x = 0; x < 10; ++x )
532 for ( Integer y = 0; y < 10; ++y )
533 for ( Integer z = 0; z < 10; ++z )
534 {
535 Cell c = K.uSpel( Point( x, y, z ) );
536 if ( x*y*z != 0 )
537 S.insert( K.uPointel( Point( x, y, z ) ) );
538 X.insertCell( c );
539 }
540 X.close();
541 THEN( "It has Euler characteristic 1" ) {
542 REQUIRE( X.euler() == 1 );
543 }
544
545 WHEN( "Computing the link of its inner pointels without hint" ) {
546 CC link_S_v1 = X.link( S );
547
548 THEN( "This link is homeomorphic to a sphere and has euler characteristic 2" ) {
549 REQUIRE( link_S_v1.euler() == 2 );
550 }
551 }
552
553 WHEN( "Computing the link of its inner pointels with full hints" ) {
554 CC link_S_v2 = X.link( S, true, true );
555
556 THEN( "This link is again homeomorphic to a sphere and has euler characteristic 2" ) {
557 REQUIRE( link_S_v2.euler() == 2 );
558 }
559 }
560 }
561}
CubicalComplex link(const CubicalComplex &S, bool hintClosed=false, bool hintOpen=false) const
Integer euler() const
Cell uPointel(Point p) const
From the digital coordinates of a point in Zn, builds the corresponding pointel (cell of dimension 0)...

References DGtal::CubicalComplex< TKSpace, TCellContainer >::close(), DGtal::CubicalComplex< TKSpace, TCellContainer >::euler(), GIVEN(), DGtal::KhalimskySpaceND< dim, TInteger >::init(), DGtal::CubicalComplex< TKSpace, TCellContainer >::insert(), DGtal::CubicalComplex< TKSpace, TCellContainer >::insertCell(), K, DGtal::CubicalComplex< TKSpace, TCellContainer >::link(), REQUIRE(), srand(), DGtal::KhalimskySpaceND< dim, TInteger >::uPointel(), and DGtal::KhalimskySpaceND< dim, TInteger >::uSpel().

◆ SCENARIO() [5/6]

SCENARIO ( "CubicalComplex< K3,std::unordered_map<> > collapse tests" ,
"" [cubical_complex][collapse] )

Definition at line 195 of file testCubicalComplex.cpp.

196{
198 typedef KSpace::Point Point;
199 typedef KSpace::Cell Cell;
200 typedef KSpace::Integer Integer;
201 typedef std::unordered_map<Cell, CubicalCellData> Map;
203 typedef CC::CellMapIterator CellMapIterator;
204
205 srand( 0 );
206 KSpace K;
207 K.init( Point( 0,0,0 ), Point( 512,512,512 ), true );
208
209 GIVEN( "A closed cubical complex made of 3x3x3 voxels with their incident cells" ) {
210 CC complex( K );
211 std::vector<Cell> S;
212 for ( Integer x = 0; x < 3; ++x )
213 for ( Integer y = 0; y < 3; ++y )
214 for ( Integer z = 0; z < 3; ++z )
215 {
216 S.push_back( K.uSpel( Point( x, y, z ) ) );
217 complex.insertCell( S.back() );
218 }
219 complex.close();
220 CAPTURE( complex.nbCells( 0 ) );
221 CAPTURE( complex.nbCells( 1 ) );
222 CAPTURE( complex.nbCells( 2 ) );
223 CAPTURE( complex.nbCells( 3 ) );
224
225 THEN( "It has Euler characteristic 1" ) {
226 REQUIRE( complex.euler() == 1 );
227 }
228
229 WHEN( "Fixing two vertices of this big cube and collapsing it" ) {
230 CellMapIterator it1 = complex.findCell( 0, K.uCell( Point( 0, 0, 0 ) ) );
231 CellMapIterator it2 = complex.findCell( 0, K.uCell( Point( 4, 4, 4 ) ) );
232 REQUIRE( it1 != complex.end( 0 ) );
233 REQUIRE( it2 != complex.end( 0 ) );
234 it1->second.data |= CC::FIXED;
235 it2->second.data |= CC::FIXED;
237 functions::collapse( complex, S.begin(), S.end(), P, false, true );
238 CAPTURE( complex.nbCells( 0 ) );
239 CAPTURE( complex.nbCells( 1 ) );
240 CAPTURE( complex.nbCells( 2 ) );
241 CAPTURE( complex.nbCells( 3 ) );
242
243 THEN( "It keeps its topology so its euler characteristic is 1" ) {
244 REQUIRE( complex.euler() == 1 );
245 } AND_THEN( "It has no more 2-cells and 3-cells" ) {
246 REQUIRE( complex.nbCells( 2 ) == 0 );
247 REQUIRE( complex.nbCells( 3 ) == 0 );
248 } AND_THEN( "It has only 0-cells and 1-cells" ) {
249 REQUIRE( complex.nbCells( 0 ) > 0 );
250 REQUIRE( complex.nbCells( 1 ) > 0 );
251 }
252 }
253 }
254}

References CAPTURE(), DGtal::functions::collapse(), GIVEN(), DGtal::KhalimskySpaceND< dim, TInteger >::init(), K, REQUIRE(), srand(), DGtal::KhalimskySpaceND< dim, TInteger >::uCell(), and DGtal::KhalimskySpaceND< dim, TInteger >::uSpel().

◆ SCENARIO() [6/6]

SCENARIO ( "CubicalComplex< K3,std::unordered_map<> > link tests" ,
"" [cubical_complex][link] )

Definition at line 256 of file testCubicalComplex.cpp.

257{
259 typedef KSpace::Point Point;
260 typedef KSpace::Cell Cell;
261 typedef KSpace::Integer Integer;
262 typedef std::unordered_map<Cell, CubicalCellData> Map;
264
265 srand( 0 );
266 KSpace K;
267 K.init( Point( 0,0,0 ), Point( 512,512,512 ), true );
268
269 GIVEN( "A closed cubical complex made of 10x10x10 voxels with their incident cells" ) {
270 CC X( K );
271 CC S( K );
272 for ( Integer x = 0; x < 10; ++x )
273 for ( Integer y = 0; y < 10; ++y )
274 for ( Integer z = 0; z < 10; ++z )
275 {
276 Cell c = K.uSpel( Point( x, y, z ) );
277 if ( x*y*z != 0 )
278 S.insert( K.uPointel( Point( x, y, z ) ) );
279 X.insertCell( c );
280 }
281 X.close();
282 THEN( "It has Euler characteristic 1" ) {
283 REQUIRE( X.euler() == 1 );
284 }
285
286 WHEN( "Computing the link of its inner pointels without hint" ) {
287 CC link_S_v1 = X.link( S );
288
289 THEN( "This link is homeomorphic to a sphere and has euler characteristic 2" ) {
290 REQUIRE( link_S_v1.euler() == 2 );
291 }
292 }
293
294 WHEN( "Computing the link of its inner pointels with full hints" ) {
295 CC link_S_v2 = X.link( S, true, true );
296
297 THEN( "This link is again homeomorphic to a sphere and has euler characteristic 2" ) {
298 REQUIRE( link_S_v2.euler() == 2 );
299 }
300 }
301 }
302}

References DGtal::CubicalComplex< TKSpace, TCellContainer >::close(), DGtal::CubicalComplex< TKSpace, TCellContainer >::euler(), GIVEN(), DGtal::KhalimskySpaceND< dim, TInteger >::init(), DGtal::CubicalComplex< TKSpace, TCellContainer >::insert(), DGtal::CubicalComplex< TKSpace, TCellContainer >::insertCell(), K, DGtal::CubicalComplex< TKSpace, TCellContainer >::link(), REQUIRE(), srand(), DGtal::KhalimskySpaceND< dim, TInteger >::uPointel(), and DGtal::KhalimskySpaceND< dim, TInteger >::uSpel().

◆ srand()

Variable Documentation

◆ K

KSpace K
Examples
dec/exampleHeatLaplace.cpp, geometry/curves/estimation/exampleCurvature.cpp, geometry/curves/exampleRationalConvexity.cpp, geometry/meshes/curvature-comparator-ii-cnc-3d.cpp, geometry/meshes/digpoly-curvature-measures-cnc-3d.cpp, geometry/meshes/digpoly-curvature-measures-cnc-XY-3d.cpp, geometry/meshes/vol-curvature-measures-icnc-3d.cpp, geometry/meshes/vol-curvature-measures-icnc-XY-3d.cpp, geometry/volumes/fullConvexityAnalysis3D.cpp, geometry/volumes/fullConvexityLUT2D.cpp, geometry/volumes/fullConvexityShortestPaths3D.cpp, geometry/volumes/fullConvexitySphereGeodesics.cpp, geometry/volumes/fullConvexityThinning3D.cpp, io/boards/dgtalBoard3D-2-ks.cpp, io/boards/dgtalBoard3DTo2D-KSCell.cpp, io/viewDualSurface.cpp, io/viewers/viewer3D-10-interaction.cpp, io/viewers/viewer3D-11-extension.cpp, io/viewers/viewer3D-4bis-illustrationMode.cpp, topology/3dKSSurfaceExtraction.cpp, topology/area-estimation-with-digital-surface.cpp, topology/area-estimation-with-indexed-digital-surface.cpp, topology/ctopo-1-3d.cpp, topology/ctopo-1.cpp, topology/ctopo-1s-3d.cpp, topology/ctopo-fillContours.cpp, topology/cubical-complex-collapse.cpp, topology/cubical-complex-illustrations.cpp, topology/digitalSetToCubicalComplexes2D.cpp, topology/frontierAndBoundary.cpp, topology/khalimskySpaceScanner.cpp, topology/trackImplicitPolynomialSurfaceToOFF.cpp, and topology/volToOFF.cpp.

Definition at line 62 of file testCubicalComplex.cpp.

Referenced by accuracyTest(), ballGenerator(), centerSurfel(), cmpSCellsIfInside(), cmpUCellsIfInside(), DGtal::functions::const_middle(), estimatorOnShapeDigitization(), DGtal::Shortcuts< TKSpace >::getCellEmbedder(), DGtal::Shortcuts< TKSpace >::getCellRange(), getComplex(), DGtal::ShortcutsGeometry< TKSpace >::getCTrivialNormalVectors(), DGtal::ShortcutsGeometry< TKSpace >::getFirstPrincipalCurvatures(), DGtal::ShortcutsGeometry< TKSpace >::getFirstPrincipalDirections(), DGtal::ShortcutsGeometry< TKSpace >::getGaussianCurvatures(), DGtal::ShortcutsGeometry< TKSpace >::getIIGaussianCurvatures(), DGtal::ShortcutsGeometry< TKSpace >::getIIGaussianCurvatures(), DGtal::ShortcutsGeometry< TKSpace >::getIIGaussianCurvatures(), DGtal::ShortcutsGeometry< TKSpace >::getIIMeanCurvatures(), DGtal::ShortcutsGeometry< TKSpace >::getIIMeanCurvatures(), DGtal::ShortcutsGeometry< TKSpace >::getIIMeanCurvatures(), DGtal::ShortcutsGeometry< TKSpace >::getIINormalVectors(), DGtal::ShortcutsGeometry< TKSpace >::getIINormalVectors(), DGtal::ShortcutsGeometry< TKSpace >::getIINormalVectors(), DGtal::ShortcutsGeometry< TKSpace >::getIIPrincipalCurvaturesAndDirections(), DGtal::ShortcutsGeometry< TKSpace >::getIIPrincipalCurvaturesAndDirections(), DGtal::ShortcutsGeometry< TKSpace >::getIIPrincipalCurvaturesAndDirections(), DGtal::CellGeometryFunctions< TKSpace, i, N >::getIncidentCellsToPointels(), DGtal::CellGeometryFunctions< TKSpace, 1, 2 >::getIncidentCellsToPointels(), DGtal::CellGeometryFunctions< TKSpace, 1, 3 >::getIncidentCellsToPointels(), DGtal::CellGeometryFunctions< TKSpace, 2, 2 >::getIncidentCellsToPointels(), DGtal::CellGeometryFunctions< TKSpace, 2, 3 >::getIncidentCellsToPointels(), DGtal::CellGeometryFunctions< TKSpace, 3, 3 >::getIncidentCellsToPointels(), DGtal::CellGeometryFunctions< TKSpace, i, N >::getIncidentCellsToPoints(), DGtal::CellGeometryFunctions< TKSpace, 1, 2 >::getIncidentCellsToPoints(), DGtal::CellGeometryFunctions< TKSpace, 1, 3 >::getIncidentCellsToPoints(), DGtal::CellGeometryFunctions< TKSpace, 2, 2 >::getIncidentCellsToPoints(), DGtal::CellGeometryFunctions< TKSpace, 2, 3 >::getIncidentCellsToPoints(), DGtal::CellGeometryFunctions< TKSpace, 3, 3 >::getIncidentCellsToPoints(), DGtal::CellGeometryFunctions< TKSpace, i, N >::getIncidentKPointsToPoints(), DGtal::CellGeometryFunctions< TKSpace, 1, 2 >::getIncidentKPointsToPoints(), DGtal::CellGeometryFunctions< TKSpace, 1, 3 >::getIncidentKPointsToPoints(), DGtal::CellGeometryFunctions< TKSpace, 2, 2 >::getIncidentKPointsToPoints(), DGtal::CellGeometryFunctions< TKSpace, 2, 3 >::getIncidentKPointsToPoints(), DGtal::CellGeometryFunctions< TKSpace, 3, 3 >::getIncidentKPointsToPoints(), DGtal::Shortcuts< TKSpace >::getKSpace(), DGtal::Shortcuts< TKSpace >::getKSpace(), DGtal::Shortcuts< TKSpace >::getKSpace(), DGtal::Shortcuts< TKSpace >::getKSpace(), DGtal::ShortcutsGeometry< TKSpace >::getMeanCurvatures(), DGtal::ShortcutsGeometry< TKSpace >::getNormalVectors(), DGtal::ATSolver2D< TKSpace, TLinearAlgebra >::getOutputScalarFieldV0(), DGtal::Shortcuts< TKSpace >::getPointelRange(), DGtal::Shortcuts< TKSpace >::getPointelRange(), DGtal::ShortcutsGeometry< TKSpace >::getPositions(), DGtal::Shortcuts< TKSpace >::getPrimalCells(), DGtal::Shortcuts< TKSpace >::getPrimalVertices(), DGtal::Shortcuts< TKSpace >::getPrimalVertices(), DGtal::ShortcutsGeometry< TKSpace >::getPrincipalCurvaturesAndDirections(), DGtal::Shortcuts< TKSpace >::getSCellEmbedder(), DGtal::ShortcutsGeometry< TKSpace >::getSecondPrincipalCurvatures(), DGtal::ShortcutsGeometry< TKSpace >::getSecondPrincipalDirections(), DGtal::ShortcutsGeometry< TKSpace >::getTrivialNormalVectors(), GIVEN(), main(), main(), main(), main(), DGtal::Shortcuts< TKSpace >::makeDigitalSurface(), DGtal::Shortcuts< TKSpace >::makeDigitalSurface(), DGtal::Shortcuts< TKSpace >::makeIdxDigitalSurface(), DGtal::Shortcuts< TKSpace >::makeIdxDigitalSurface(), DGtal::Shortcuts< TKSpace >::makeIdxDigitalSurface(), DGtal::Shortcuts< TKSpace >::makeIdxDigitalSurface(), DGtal::Shortcuts< TKSpace >::makeLightDigitalSurface(), DGtal::Shortcuts< TKSpace >::makeLightDigitalSurfaces(), DGtal::Shortcuts< TKSpace >::makeLightDigitalSurfaces(), DGtal::Shortcuts< TKSpace >::makePolygonalSurface(), DGtal::Shortcuts< TKSpace >::makeTriangulatedSurface(), Object3D(), DGtal::Shortcuts< TKSpace >::CellReader::operator()(), DGtal::Shortcuts< TKSpace >::CellWriter::operator()(), DGtal::Shortcuts< TKSpace >::SCellReader::operator()(), DGtal::Shortcuts< TKSpace >::SCellWriter::operator()(), DGtal::Shortcuts< TKSpace >::outputCellMapAsCSV(), DGtal::Shortcuts< TKSpace >::outputDualDigitalSurfaceAsObj(), DGtal::Shortcuts< TKSpace >::outputSCellMapAsCSV(), DGtal::Shortcuts< TKSpace >::outputSurfelsAsObj(), DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::radius(), DGtal::Shortcuts< TKSpace >::saveOBJ(), DGtal::Shortcuts< TKSpace >::saveOFF(), SCENARIO(), SCENARIO(), SCENARIO(), SCENARIO(), SCENARIO(), SCENARIO(), SCENARIO(), SCENARIO(), SCENARIO(), SCENARIO(), SCENARIO(), SCENARIO(), SCENARIO(), SCENARIO(), SCENARIO(), SCENARIO(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), testBallQuad(), testCellDrawOnBoard(), testCellularGridSpaceNDCoFaces(), testCellularGridSpaceNDFaces(), testCombinatorialSurface(), testCompareEstimator(), testComputeInterior(), testCube(), testCurvature2d(), testDigitalSetBoundary(), testDigitalSurface(), testDigitalSurfaceBoostGraphInterface(), testDigitization(), testDirectIncidence(), testEmbedder(), testEstimatorCache(), testExplicitDigitalSurface(), testFaces(), testFindABel(), testFindABel(), testFitting(), testGaussianCurvature3d(), DGtal::testImplicitDigitalSurface(), testImplicitDigitalSurface(), testIncidence(), testLightExplicitDigitalSurface(), DGtal::testLightImplicitDigitalSurface(), testLightImplicitDigitalSurface(), testLocalEstimatorFromFunctorAdapter(), testMeanCurvature3d(), testNeighborhood(), testObjectGraph(), testOrderingDigitalSurfaceFacesAroundVertex(), testPrincipalCurvatures3d(), testRaySurface(), testScan(), testSurfelAdjacency(), testTrueLocalEstimatorOnShapeDigitization(), testUmbrellaComputer(), and DGtal::ATSolver2D< TKSpace, TLinearAlgebra >::updateSmallestEpsilonMap().

◆ NBCELLS

const int NBCELLS = 1000
static

Definition at line 50 of file testCubicalComplex.cpp.

Referenced by GIVEN().