32 #include "DGtal/base/OrderedAlphabet.h"
33 #include "DGtal/arithmetic/ModuloComputer.h"
61 tbl = (
char *)malloc((myNb + 1)*
sizeof(char));
62 for (
unsigned int i = 0; i < myNb; ++i )
64 tbl[ myOrder[ i ] ] = myFirst + i;
78 unsigned int* p = myOrder;
79 unsigned int* q = myOrder + myNb;
83 *p = ( k == 0 ) ? myNb - 1 : k - 1;
94 unsigned int* p = myOrder;
95 unsigned int* q = myOrder + myNb;
98 unsigned int k = *p + 1;
99 *p = ( k == myNb ) ? 0 : k;
110 unsigned int* p = myOrder;
111 unsigned int* q = myOrder + myNb;
125 unsigned int* p = myOrder;
126 unsigned int* q = myOrder + myNb;
129 *p = ( myNb + 3 - *p ) % myNb;
152 (
size_t & len,
size_t & nb,
153 const std::string & w,
158 while ( ( j < e ) && ( lessOrEqual( w[ i ], w[ j ] ) ) )
160 if ( equal( w[ i ], w[ j ] ) )
167 nb = ( (
size_t) ( j - s ) ) / len;
186 (
size_t & len,
size_t & nb,
187 const std::string & w,
194 while ( ( j != e ) && ( lessOrEqual( w[ i ], w[ j ] ) ) )
196 if ( equal( w[ i ], w[ j ] ) )
202 len = j >= i ? (
size_t) ( j - i )
203 : (
size_t) ( j + modulo - i );
204 nb = ( (
size_t) ( ( j + modulo - s ) % modulo ) ) / len;
221 ASSERT( ( order( w[ s ] ) == 1 ) || ( order( w[ s ] ) == 2 ) );
226 while ( ( j < e ) && ( lessOrEqual( w[ i ], w[ j ] ) ) )
228 if ( equal( w[ i ], w[ j ] ) )
236 if ( ( j != q ) || ( order ( w[ j ] ) != 2 ) )
249 nb = ( (
size_t) (j-s) ) / len;
277 (
size_t & len,
size_t & nb,
278 unsigned int & n1,
unsigned int & n2,
279 unsigned int & lf1,
unsigned int & lf2,
280 const std::string & w,
284 ASSERT( ( order( w[ s ] ) == 1 ) || ( order( w[ s ] ) == 2 ) );
289 unsigned int slope1 = (order( w[ i ] ) == 1) ? 1 : 0;
290 unsigned int slope2 = (order( w[ i ] ) == 2) ? 1 : 0;
298 while ( ( j < e ) && ( lessOrEqual( w[ i ], w[ j ] ) ) ) {
307 if (order( w[ j ] ) == 1)
309 else if (order( w[ j ] ) == 2)
312 if ( equal( w[ i ], w[ j ] ) ) {
318 if ( j == nb * (p-s+1) + p ) {
323 if ( ( j != q ) || ( order ( w[ j ] ) != 2 ) ) {
333 lf1 = lf1 + (nb-1)*n1;
334 lf2 = lf2 + (nb-1)*n2;
347 if ( nb != (
size_t) (j-s) / len)
348 cout <<
"ASSERT(" << nb <<
" == (" << j <<
"-" << s <<
") / "<<len <<
")" << endl;
349 ASSERT( nb == (
size_t) (j-s) / len);
379 const std::string & w,
382 ASSERT( ( order( w[ s ] ) == 1 )
383 || ( order( w[ s ] ) == 2 ) );
390 while ( ( j != e ) && ( lessOrEqual( w[ i ], w[ j ] ) ) )
393 if ( equal( w[ i ], w[ j ] ) )
395 if ( j == mc.
cast( s + q - 1 ) )
401 if ( ( j != mc.
cast( s + q - 1 ) ) || ( order ( w[ j ] ) != 2 ) )
406 unsigned int tmp = p;
413 len = j >= i ? (
size_t) ( j - i )
414 : (
size_t) ( j + modulo - i );
415 nb = ( (
size_t) ( ( j + modulo - s ) % modulo ) ) / len;
430 out <<
"[OrderedAlphabet]";
431 out <<
" " << orderedAlphabet() << endl;
480 bool inC = duvalPPMod( len, nb, w, s, s );
489 w[ s ] = letter( 2 );
490 this->reverseAround12();
493 l = nextEdge( nb_a1, nb_a2, w, s, cvx );
497 else if ( ( len == 1 ) && ( order( w[ s ] ) == 1 ) )
503 s = mc.cast( s + nb );
512 char a2 = letter( 2 );
516 s = mc.cast( s + l );
519 if ( w[ ss ] == a2 ) ++nb_a2;