70#include "DGtal/base/Common.h"
71#include "DGtal/helpers/StdDefs.h"
73#include "DGtal/io/DrawWithDisplay3DModifier.h"
74#include "DGtal/io/viewers/Viewer3D.h"
75#include "DGtal/topology/KhalimskySpaceND.h"
76#include "DGtal/topology/CubicalComplex.h"
90template <
typename CubicalComplex>
91struct DiagonalPriority {
97 DiagonalPriority(
const CubicalComplex& complex ) : myComplex( complex ) {}
98 bool operator()(
const CellMapIterator& it1,
const CellMapIterator& it2 )
const
100 Point k1 = myComplex.
space().uKCoords( it1->first );
101 Point k2 = myComplex.
space().uKCoords( it2->first );
104 RealPoint v1( k1[ 0 ] - d1 * k1[ 0 ], k1[ 1 ] - d1 * k1[ 1 ], k1[ 2 ] - d1 * k1[ 2 ] );
105 RealPoint v2( k2[ 0 ] - d2 * k2[ 0 ], k2[ 1 ] - d2 * k2[ 1 ], k2[ 2 ] - d2 * k2[ 2 ] );
106 double n1 = v1.dot( v1 );
107 double n2 = v2.dot( v2 );
108 return ( n1 < n2 ) || ( ( n1 == n2 ) && ( it1->first < it2->first ) );
115int main(
int argc,
char** argv )
119 typedef std::map<Cell, CubicalCellData>
Map;
129 for (
Integer x = 0; x <= m; ++x )
130 for (
Integer y = 0; y <= m; ++y )
131 for (
Integer z = 0; z <= m; ++z )
134 S.push_back(
K.
uCell( k1 ) );
136 RealPoint v1( k1[ 0 ], k1[ 1 ], k1[ 2 ] );
139 double n1 = v1.norm();
140 bool fixed = ( ( x == 0 ) && ( y == 0 ) && ( z == 0 ) )
141 || ( ( x == 0 ) && ( y == m ) && ( z == 0 ) )
142 || ( ( x == m ) && ( y == 0 ) && ( z == 0 ) )
143 || ( ( x == m ) && ( y == m ) && ( z == 0 ) )
144 || ( ( x == m/3 ) && ( y == 2*m/3 ) && ( z == 2*m/3 ) )
145 || ( ( x == 0 ) && ( y == 0 ) && ( z == m ) )
146 || ( ( x == 0 ) && ( y == m ) && ( z == m ) )
147 || ( ( x == m ) && ( y == 0 ) && ( z == m ) )
148 || ( ( x == m ) && ( y == m ) && ( z == m ) )
149 || ( ( x == 0 ) && ( y == m ) )
150 || ( ( x == m ) && ( y == m ) )
151 || ( ( z == 0 ) && ( y == m ) )
152 || ( ( z == m ) && ( y == m ) );
153 complex.insertCell( S.back(),
159 trace.
info() <<
"After close: " << complex << std::endl;
163 QApplication application(argc,argv);
174 bool fixed = (it->second.data == CC::FIXED);
187 trace.
info() <<
"Collapse removed " << removed <<
" cells." << std::endl;
188 trace.
info() <<
"After collapse: " << complex << std::endl;
199 bool fixed = (it->second.data == CC::FIXED);
205 return application.exec();
Aim: This class represents an arbitrary cubical complex living in some Khalimsky space....
const KSpace & space() const
TKSpace KSpace
Type of the cellular grid space.
CellMap::iterator CellMapIterator
Iterator for visiting type CellMap.
CellMap::const_iterator CellMapConstIterator
Const iterator for visiting type CellMap.
virtual void setFillColor(DGtal::Color aColor)
Aim: This class is a model of CCellularGridSpaceND. It represents the cubical grid as a cell complex,...
bool init(const Point &lower, const Point &upper, bool isClosed)
Specifies the upper and lower bounds for the maximal cells in this space.
Cell uCell(const PreCell &c) const
From an unsigned cell, returns an unsigned cell lying into this Khalismky space.
static const constexpr Dimension dimension
auto dot(const PointVector< dim, OtherComponent, OtherStorage > &v) const -> decltype(DGtal::dotProduct(*this, v))
Dot product with a PointVector.
static Self diagonal(Component val=1)
void beginBlock(const std::string &keyword="")
virtual void show()
Overload QWidget method in order to add a call to updateList() method (to ensure that the lists are w...
Z3i this namespace gathers the standard of types for 3D imagery.
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.
boost::uint32_t uint32_t
unsigned 32-bit integer.
DGtal::uint32_t Dimension
boost::uint64_t uint64_t
unsigned 64-bit integer.
std::unordered_map< Cell, CubicalCellData > Map
CubicalComplex< KSpace, Map > CC
CC::CellMapConstIterator CellMapConstIterator