70#include "DGtal/base/Common.h"
71#include "DGtal/helpers/StdDefs.h"
73#include "DGtal/io/viewers/PolyscopeViewer.h"
74#include "DGtal/topology/KhalimskySpaceND.h"
75#include "DGtal/topology/CubicalComplex.h"
89template <
typename CubicalComplex>
103 RealPoint v1( k1[ 0 ] - d1 * k1[ 0 ], k1[ 1 ] - d1 * k1[ 1 ], k1[ 2 ] - d1 * k1[ 2 ] );
104 RealPoint v2( k2[ 0 ] - d2 * k2[ 0 ], k2[ 1 ] - d2 * k2[ 1 ], k2[ 2 ] - d2 * k2[ 2 ] );
105 double n1 = v1.
dot( v1 );
106 double n2 = v2.
dot( v2 );
107 return ( n1 < n2 ) || ( ( n1 == n2 ) && ( it1->first < it2->first ) );
114int main(
int argc,
char** argv )
118 typedef std::map<Cell, CubicalCellData>
Map;
122 trace.beginBlock(
"Creating Cubical Complex" );
124 K.init(
Point( 0,0,0 ),
Point( 512,512,512 ),
true );
128 for (
Integer x = 0; x <= m; ++x )
129 for (
Integer y = 0; y <= m; ++y )
130 for (
Integer z = 0; z <= m; ++z )
133 S.push_back(
K.uCell( k1 ) );
135 RealPoint v1( k1[ 0 ], k1[ 1 ], k1[ 2 ] );
138 double n1 = v1.
norm();
139 bool fixed = ( ( x == 0 ) && ( y == 0 ) && ( z == 0 ) )
140 || ( ( x == 0 ) && ( y == m ) && ( z == 0 ) )
141 || ( ( x == m ) && ( y == 0 ) && ( z == 0 ) )
142 || ( ( x == m ) && ( y == m ) && ( z == 0 ) )
143 || ( ( x == m/3 ) && ( y == 2*m/3 ) && ( z == 2*m/3 ) )
144 || ( ( x == 0 ) && ( y == 0 ) && ( z == m ) )
145 || ( ( x == 0 ) && ( y == m ) && ( z == m ) )
146 || ( ( x == m ) && ( y == 0 ) && ( z == m ) )
147 || ( ( x == m ) && ( y == m ) && ( z == m ) )
148 || ( ( x == 0 ) && ( y == m ) )
149 || ( ( x == m ) && ( y == m ) )
150 || ( ( z == 0 ) && ( y == m ) )
151 || ( ( z == m ) && ( y == m ) );
152 complex.insertCell( S.back(),
158 trace.info() <<
"After close: " << complex << std::endl;
171 bool fixed = (it->second.data == CC::FIXED);
179 trace.beginBlock(
"Collapsing complex" );
180 CC::DefaultCellMapIteratorPriority P;
183 trace.info() <<
"Collapse removed " << removed <<
" cells." << std::endl;
184 trace.info() <<
"After collapse: " << complex << std::endl;
194 bool fixed = (it->second.data == CC::FIXED);
114int main(
int argc,
char** argv ) {
…}
Aim: This class represents an arbitrary cubical complex living in some Khalimsky space....
TKSpace KSpace
Type of the cellular grid space.
KSpace::Cell Cell
Type for a cell in the space.
KSpace::Point Point
Type for a point in the digital space.
CellMap::iterator CellMapIterator
Iterator for visiting type CellMap.
CellMap::const_iterator CellMapConstIterator
void drawColor(const DGtal::Color &color)
static const constexpr Dimension dimension
auto dot(const PointVector< dim, OtherComponent, OtherStorage > &v) const -> decltype(DGtal::dotProduct(*this, v))
Dot product with a PointVector.
double norm(const NormType type=L_2) const
static Self diagonal(Component val=1)
void show() override
Starts the event loop and display of elements.
Z3i this namespace gathers the standard of types for 3D imagery.
KhalimskySpaceND< 3, Integer > KSpace
Space::RealPoint RealPoint
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)
DGtal is the top-level namespace which contains all DGtal functions and types.
std::uint64_t uint64_t
unsigned 64-bit integer.
std::uint32_t uint32_t
unsigned 32-bit integer.
DGtal::uint32_t Dimension
CubicalComplex::KSpace KSpace
bool operator()(const CellMapIterator &it1, const CellMapIterator &it2) const
CubicalComplex::Point Point
CubicalComplex::Cell Cell
const CubicalComplex & myComplex
CubicalComplex::CellMapIterator CellMapIterator
DiagonalPriority(const CubicalComplex &complex)
std::unordered_map< Cell, CubicalCellData > Map
CubicalComplex< KSpace, Map > CC
CC::CellMapConstIterator CellMapConstIterator
PolyscopeViewer< Space, KSpace > MyViewer