diff --git a/src/DGtal/base/Bits.cpp b/src/DGtal/base/Bits.cpp deleted file mode 100644 index 2272366473..0000000000 --- a/src/DGtal/base/Bits.cpp +++ /dev/null @@ -1,505 +0,0 @@ -/** - * 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 . - * - **/ - -/** - * @file Bits.cpp - * @author Jacques-Olivier Lachaud (\c jacques-olivier.lachaud@univ-savoie.fr ) - * Laboratory of Mathematics (CNRS, UMR 5807), University of Savoie, France - * - * @date 2009/12/10 - * - * Implementation of methods defined in Bits.h - * - * This file is part of the DGtal library. - */ - -/////////////////////////////////////////////////////////////////////////////// -#include "DGtal/base/Bits.h" -/////////////////////////////////////////////////////////////////////////////// - -#include - - -/////////////////////////////////////////////////////////////////////////////// -// class Bits -/////////////////////////////////////////////////////////////////////////////// - -/** DGtal Global variables - * - **/ -namespace DGtal -{ - // Lookup tables for find and count operations. - /** - Lookup table for counting the number of bits set to 1 in a byte. - ( Taken from STL \ ) - */ - const DGtal::uint8_t Bits::myBitCount[] = { - 0, /* 0 */ 1, /* 1 */ 1, /* 2 */ 2, /* 3 */ 1, /* 4 */ - 2, /* 5 */ 2, /* 6 */ 3, /* 7 */ 1, /* 8 */ 2, /* 9 */ - 2, /* 10 */ 3, /* 11 */ 2, /* 12 */ 3, /* 13 */ 3, /* 14 */ - 4, /* 15 */ 1, /* 16 */ 2, /* 17 */ 2, /* 18 */ 3, /* 19 */ - 2, /* 20 */ 3, /* 21 */ 3, /* 22 */ 4, /* 23 */ 2, /* 24 */ - 3, /* 25 */ 3, /* 26 */ 4, /* 27 */ 3, /* 28 */ 4, /* 29 */ - 4, /* 30 */ 5, /* 31 */ 1, /* 32 */ 2, /* 33 */ 2, /* 34 */ - 3, /* 35 */ 2, /* 36 */ 3, /* 37 */ 3, /* 38 */ 4, /* 39 */ - 2, /* 40 */ 3, /* 41 */ 3, /* 42 */ 4, /* 43 */ 3, /* 44 */ - 4, /* 45 */ 4, /* 46 */ 5, /* 47 */ 2, /* 48 */ 3, /* 49 */ - 3, /* 50 */ 4, /* 51 */ 3, /* 52 */ 4, /* 53 */ 4, /* 54 */ - 5, /* 55 */ 3, /* 56 */ 4, /* 57 */ 4, /* 58 */ 5, /* 59 */ - 4, /* 60 */ 5, /* 61 */ 5, /* 62 */ 6, /* 63 */ 1, /* 64 */ - 2, /* 65 */ 2, /* 66 */ 3, /* 67 */ 2, /* 68 */ 3, /* 69 */ - 3, /* 70 */ 4, /* 71 */ 2, /* 72 */ 3, /* 73 */ 3, /* 74 */ - 4, /* 75 */ 3, /* 76 */ 4, /* 77 */ 4, /* 78 */ 5, /* 79 */ - 2, /* 80 */ 3, /* 81 */ 3, /* 82 */ 4, /* 83 */ 3, /* 84 */ - 4, /* 85 */ 4, /* 86 */ 5, /* 87 */ 3, /* 88 */ 4, /* 89 */ - 4, /* 90 */ 5, /* 91 */ 4, /* 92 */ 5, /* 93 */ 5, /* 94 */ - 6, /* 95 */ 2, /* 96 */ 3, /* 97 */ 3, /* 98 */ 4, /* 99 */ - 3, /* 100 */ 4, /* 101 */ 4, /* 102 */ 5, /* 103 */ 3, /* 104 */ - 4, /* 105 */ 4, /* 106 */ 5, /* 107 */ 4, /* 108 */ 5, /* 109 */ - 5, /* 110 */ 6, /* 111 */ 3, /* 112 */ 4, /* 113 */ 4, /* 114 */ - 5, /* 115 */ 4, /* 116 */ 5, /* 117 */ 5, /* 118 */ 6, /* 119 */ - 4, /* 120 */ 5, /* 121 */ 5, /* 122 */ 6, /* 123 */ 5, /* 124 */ - 6, /* 125 */ 6, /* 126 */ 7, /* 127 */ 1, /* 128 */ 2, /* 129 */ - 2, /* 130 */ 3, /* 131 */ 2, /* 132 */ 3, /* 133 */ 3, /* 134 */ - 4, /* 135 */ 2, /* 136 */ 3, /* 137 */ 3, /* 138 */ 4, /* 139 */ - 3, /* 140 */ 4, /* 141 */ 4, /* 142 */ 5, /* 143 */ 2, /* 144 */ - 3, /* 145 */ 3, /* 146 */ 4, /* 147 */ 3, /* 148 */ 4, /* 149 */ - 4, /* 150 */ 5, /* 151 */ 3, /* 152 */ 4, /* 153 */ 4, /* 154 */ - 5, /* 155 */ 4, /* 156 */ 5, /* 157 */ 5, /* 158 */ 6, /* 159 */ - 2, /* 160 */ 3, /* 161 */ 3, /* 162 */ 4, /* 163 */ 3, /* 164 */ - 4, /* 165 */ 4, /* 166 */ 5, /* 167 */ 3, /* 168 */ 4, /* 169 */ - 4, /* 170 */ 5, /* 171 */ 4, /* 172 */ 5, /* 173 */ 5, /* 174 */ - 6, /* 175 */ 3, /* 176 */ 4, /* 177 */ 4, /* 178 */ 5, /* 179 */ - 4, /* 180 */ 5, /* 181 */ 5, /* 182 */ 6, /* 183 */ 4, /* 184 */ - 5, /* 185 */ 5, /* 186 */ 6, /* 187 */ 5, /* 188 */ 6, /* 189 */ - 6, /* 190 */ 7, /* 191 */ 2, /* 192 */ 3, /* 193 */ 3, /* 194 */ - 4, /* 195 */ 3, /* 196 */ 4, /* 197 */ 4, /* 198 */ 5, /* 199 */ - 3, /* 200 */ 4, /* 201 */ 4, /* 202 */ 5, /* 203 */ 4, /* 204 */ - 5, /* 205 */ 5, /* 206 */ 6, /* 207 */ 3, /* 208 */ 4, /* 209 */ - 4, /* 210 */ 5, /* 211 */ 4, /* 212 */ 5, /* 213 */ 5, /* 214 */ - 6, /* 215 */ 4, /* 216 */ 5, /* 217 */ 5, /* 218 */ 6, /* 219 */ - 5, /* 220 */ 6, /* 221 */ 6, /* 222 */ 7, /* 223 */ 3, /* 224 */ - 4, /* 225 */ 4, /* 226 */ 5, /* 227 */ 4, /* 228 */ 5, /* 229 */ - 5, /* 230 */ 6, /* 231 */ 4, /* 232 */ 5, /* 233 */ 5, /* 234 */ - 6, /* 235 */ 5, /* 236 */ 6, /* 237 */ 6, /* 238 */ 7, /* 239 */ - 4, /* 240 */ 5, /* 241 */ 5, /* 242 */ 6, /* 243 */ 5, /* 244 */ - 6, /* 245 */ 6, /* 246 */ 7, /* 247 */ 5, /* 248 */ 6, /* 249 */ - 6, /* 250 */ 7, /* 251 */ 6, /* 252 */ 7, /* 253 */ 7, /* 254 */ - 8 /* 255 */ - }; // end _Bit_count - - /** - * Lookup table for finding the least significant bit. - *

- * NB: Can also be obtained with:

-   * 
- */ - const DGtal::uint8_t Bits::myLSB[] = { - 0, /* 0 */ 0, /* 1 */ 1, /* 2 */ 0, /* 3 */ 2, /* 4 */ - 0, /* 5 */ 1, /* 6 */ 0, /* 7 */ 3, /* 8 */ 0, /* 9 */ - 1, /* 10 */ 0, /* 11 */ 2, /* 12 */ 0, /* 13 */ 1, /* 14 */ - 0, /* 15 */ 4, /* 16 */ 0, /* 17 */ 1, /* 18 */ 0, /* 19 */ - 2, /* 20 */ 0, /* 21 */ 1, /* 22 */ 0, /* 23 */ 3, /* 24 */ - 0, /* 25 */ 1, /* 26 */ 0, /* 27 */ 2, /* 28 */ 0, /* 29 */ - 1, /* 30 */ 0, /* 31 */ 5, /* 32 */ 0, /* 33 */ 1, /* 34 */ - 0, /* 35 */ 2, /* 36 */ 0, /* 37 */ 1, /* 38 */ 0, /* 39 */ - 3, /* 40 */ 0, /* 41 */ 1, /* 42 */ 0, /* 43 */ 2, /* 44 */ - 0, /* 45 */ 1, /* 46 */ 0, /* 47 */ 4, /* 48 */ 0, /* 49 */ - 1, /* 50 */ 0, /* 51 */ 2, /* 52 */ 0, /* 53 */ 1, /* 54 */ - 0, /* 55 */ 3, /* 56 */ 0, /* 57 */ 1, /* 58 */ 0, /* 59 */ - 2, /* 60 */ 0, /* 61 */ 1, /* 62 */ 0, /* 63 */ 6, /* 64 */ - 0, /* 65 */ 1, /* 66 */ 0, /* 67 */ 2, /* 68 */ 0, /* 69 */ - 1, /* 70 */ 0, /* 71 */ 3, /* 72 */ 0, /* 73 */ 1, /* 74 */ - 0, /* 75 */ 2, /* 76 */ 0, /* 77 */ 1, /* 78 */ 0, /* 79 */ - 4, /* 80 */ 0, /* 81 */ 1, /* 82 */ 0, /* 83 */ 2, /* 84 */ - 0, /* 85 */ 1, /* 86 */ 0, /* 87 */ 3, /* 88 */ 0, /* 89 */ - 1, /* 90 */ 0, /* 91 */ 2, /* 92 */ 0, /* 93 */ 1, /* 94 */ - 0, /* 95 */ 5, /* 96 */ 0, /* 97 */ 1, /* 98 */ 0, /* 99 */ - 2, /* 100 */ 0, /* 101 */ 1, /* 102 */ 0, /* 103 */ 3, /* 104 */ - 0, /* 105 */ 1, /* 106 */ 0, /* 107 */ 2, /* 108 */ 0, /* 109 */ - 1, /* 110 */ 0, /* 111 */ 4, /* 112 */ 0, /* 113 */ 1, /* 114 */ - 0, /* 115 */ 2, /* 116 */ 0, /* 117 */ 1, /* 118 */ 0, /* 119 */ - 3, /* 120 */ 0, /* 121 */ 1, /* 122 */ 0, /* 123 */ 2, /* 124 */ - 0, /* 125 */ 1, /* 126 */ 0, /* 127 */ 7, /* 128 */ 0, /* 129 */ - 1, /* 130 */ 0, /* 131 */ 2, /* 132 */ 0, /* 133 */ 1, /* 134 */ - 0, /* 135 */ 3, /* 136 */ 0, /* 137 */ 1, /* 138 */ 0, /* 139 */ - 2, /* 140 */ 0, /* 141 */ 1, /* 142 */ 0, /* 143 */ 4, /* 144 */ - 0, /* 145 */ 1, /* 146 */ 0, /* 147 */ 2, /* 148 */ 0, /* 149 */ - 1, /* 150 */ 0, /* 151 */ 3, /* 152 */ 0, /* 153 */ 1, /* 154 */ - 0, /* 155 */ 2, /* 156 */ 0, /* 157 */ 1, /* 158 */ 0, /* 159 */ - 5, /* 160 */ 0, /* 161 */ 1, /* 162 */ 0, /* 163 */ 2, /* 164 */ - 0, /* 165 */ 1, /* 166 */ 0, /* 167 */ 3, /* 168 */ 0, /* 169 */ - 1, /* 170 */ 0, /* 171 */ 2, /* 172 */ 0, /* 173 */ 1, /* 174 */ - 0, /* 175 */ 4, /* 176 */ 0, /* 177 */ 1, /* 178 */ 0, /* 179 */ - 2, /* 180 */ 0, /* 181 */ 1, /* 182 */ 0, /* 183 */ 3, /* 184 */ - 0, /* 185 */ 1, /* 186 */ 0, /* 187 */ 2, /* 188 */ 0, /* 189 */ - 1, /* 190 */ 0, /* 191 */ 6, /* 192 */ 0, /* 193 */ 1, /* 194 */ - 0, /* 195 */ 2, /* 196 */ 0, /* 197 */ 1, /* 198 */ 0, /* 199 */ - 3, /* 200 */ 0, /* 201 */ 1, /* 202 */ 0, /* 203 */ 2, /* 204 */ - 0, /* 205 */ 1, /* 206 */ 0, /* 207 */ 4, /* 208 */ 0, /* 209 */ - 1, /* 210 */ 0, /* 211 */ 2, /* 212 */ 0, /* 213 */ 1, /* 214 */ - 0, /* 215 */ 3, /* 216 */ 0, /* 217 */ 1, /* 218 */ 0, /* 219 */ - 2, /* 220 */ 0, /* 221 */ 1, /* 222 */ 0, /* 223 */ 5, /* 224 */ - 0, /* 225 */ 1, /* 226 */ 0, /* 227 */ 2, /* 228 */ 0, /* 229 */ - 1, /* 230 */ 0, /* 231 */ 3, /* 232 */ 0, /* 233 */ 1, /* 234 */ - 0, /* 235 */ 2, /* 236 */ 0, /* 237 */ 1, /* 238 */ 0, /* 239 */ - 4, /* 240 */ 0, /* 241 */ 1, /* 242 */ 0, /* 243 */ 2, /* 244 */ - 0, /* 245 */ 1, /* 246 */ 0, /* 247 */ 3, /* 248 */ 0, /* 249 */ - 1, /* 250 */ 0, /* 251 */ 2, /* 252 */ 0, /* 253 */ 1, /* 254 */ - 0, /* 255 */ - }; // end _First_one - - -/** - * Lookup table for finding the least significant bit. - *

- * NB: Can also be obtained with:

-   * 
- */ - const DGtal::uint8_t Bits::myMSB[] = { -0 /* 0*/ , -0 /* 1*/ ,1 /* 2*/ ,1 /* 3*/ ,2 /* 4*/ ,2 /* 5*/ , -2 /* 6*/ ,2 /* 7*/ ,3 /* 8*/ ,3 /* 9*/ ,3 /* 10*/ , -3 /* 11*/ ,3 /* 12*/ ,3 /* 13*/ ,3 /* 14*/ ,3 /* 15*/ , -4 /* 16*/ ,4 /* 17*/ ,4 /* 18*/ ,4 /* 19*/ ,4 /* 20*/ , -4 /* 21*/ ,4 /* 22*/ ,4 /* 23*/ ,4 /* 24*/ ,4 /* 25*/ , -4 /* 26*/ ,4 /* 27*/ ,4 /* 28*/ ,4 /* 29*/ ,4 /* 30*/ , -4 /* 31*/ ,5 /* 32*/ ,5 /* 33*/ ,5 /* 34*/ ,5 /* 35*/ , -5 /* 36*/ ,5 /* 37*/ ,5 /* 38*/ ,5 /* 39*/ ,5 /* 40*/ , -5 /* 41*/ ,5 /* 42*/ ,5 /* 43*/ ,5 /* 44*/ ,5 /* 45*/ , -5 /* 46*/ ,5 /* 47*/ ,5 /* 48*/ ,5 /* 49*/ ,5 /* 50*/ , -5 /* 51*/ ,5 /* 52*/ ,5 /* 53*/ ,5 /* 54*/ ,5 /* 55*/ , -5 /* 56*/ ,5 /* 57*/ ,5 /* 58*/ ,5 /* 59*/ ,5 /* 60*/ , -5 /* 61*/ ,5 /* 62*/ ,5 /* 63*/ ,6 /* 64*/ ,6 /* 65*/ , -6 /* 66*/ ,6 /* 67*/ ,6 /* 68*/ ,6 /* 69*/ ,6 /* 70*/ , -6 /* 71*/ ,6 /* 72*/ ,6 /* 73*/ ,6 /* 74*/ ,6 /* 75*/ , -6 /* 76*/ ,6 /* 77*/ ,6 /* 78*/ ,6 /* 79*/ ,6 /* 80*/ , -6 /* 81*/ ,6 /* 82*/ ,6 /* 83*/ ,6 /* 84*/ ,6 /* 85*/ , -6 /* 86*/ ,6 /* 87*/ ,6 /* 88*/ ,6 /* 89*/ ,6 /* 90*/ , -6 /* 91*/ ,6 /* 92*/ ,6 /* 93*/ ,6 /* 94*/ ,6 /* 95*/ , -6 /* 96*/ ,6 /* 97*/ ,6 /* 98*/ ,6 /* 99*/ ,6 /* 100*/ , -6 /* 101*/ ,6 /* 102*/ ,6 /* 103*/ ,6 /* 104*/ ,6 /* 105*/ , -6 /* 106*/ ,6 /* 107*/ ,6 /* 108*/ ,6 /* 109*/ ,6 /* 110*/ , -6 /* 111*/ ,6 /* 112*/ ,6 /* 113*/ ,6 /* 114*/ ,6 /* 115*/ , -6 /* 116*/ ,6 /* 117*/ ,6 /* 118*/ ,6 /* 119*/ ,6 /* 120*/ , -6 /* 121*/ ,6 /* 122*/ ,6 /* 123*/ ,6 /* 124*/ ,6 /* 125*/ , -6 /* 126*/ ,6 /* 127*/ ,7 /* 128*/ ,7 /* 129*/ ,7 /* 130*/ , -7 /* 131*/ ,7 /* 132*/ ,7 /* 133*/ ,7 /* 134*/ ,7 /* 135*/ , -7 /* 136*/ ,7 /* 137*/ ,7 /* 138*/ ,7 /* 139*/ ,7 /* 140*/ , -7 /* 141*/ ,7 /* 142*/ ,7 /* 143*/ ,7 /* 144*/ ,7 /* 145*/ , -7 /* 146*/ ,7 /* 147*/ ,7 /* 148*/ ,7 /* 149*/ ,7 /* 150*/ , -7 /* 151*/ ,7 /* 152*/ ,7 /* 153*/ ,7 /* 154*/ ,7 /* 155*/ , -7 /* 156*/ ,7 /* 157*/ ,7 /* 158*/ ,7 /* 159*/ ,7 /* 160*/ , -7 /* 161*/ ,7 /* 162*/ ,7 /* 163*/ ,7 /* 164*/ ,7 /* 165*/ , -7 /* 166*/ ,7 /* 167*/ ,7 /* 168*/ ,7 /* 169*/ ,7 /* 170*/ , -7 /* 171*/ ,7 /* 172*/ ,7 /* 173*/ ,7 /* 174*/ ,7 /* 175*/ , -7 /* 176*/ ,7 /* 177*/ ,7 /* 178*/ ,7 /* 179*/ ,7 /* 180*/ , -7 /* 181*/ ,7 /* 182*/ ,7 /* 183*/ ,7 /* 184*/ ,7 /* 185*/ , -7 /* 186*/ ,7 /* 187*/ ,7 /* 188*/ ,7 /* 189*/ ,7 /* 190*/ , -7 /* 191*/ ,7 /* 192*/ ,7 /* 193*/ ,7 /* 194*/ ,7 /* 195*/ , -7 /* 196*/ ,7 /* 197*/ ,7 /* 198*/ ,7 /* 199*/ ,7 /* 200*/ , -7 /* 201*/ ,7 /* 202*/ ,7 /* 203*/ ,7 /* 204*/ ,7 /* 205*/ , -7 /* 206*/ ,7 /* 207*/ ,7 /* 208*/ ,7 /* 209*/ ,7 /* 210*/ , -7 /* 211*/ ,7 /* 212*/ ,7 /* 213*/ ,7 /* 214*/ ,7 /* 215*/ , -7 /* 216*/ ,7 /* 217*/ ,7 /* 218*/ ,7 /* 219*/ ,7 /* 220*/ , -7 /* 221*/ ,7 /* 222*/ ,7 /* 223*/ ,7 /* 224*/ ,7 /* 225*/ , -7 /* 226*/ ,7 /* 227*/ ,7 /* 228*/ ,7 /* 229*/ ,7 /* 230*/ , -7 /* 231*/ ,7 /* 232*/ ,7 /* 233*/ ,7 /* 234*/ ,7 /* 235*/ , -7 /* 236*/ ,7 /* 237*/ ,7 /* 238*/ ,7 /* 239*/ ,7 /* 240*/ , -7 /* 241*/ ,7 /* 242*/ ,7 /* 243*/ ,7 /* 244*/ ,7 /* 245*/ , -7 /* 246*/ ,7 /* 247*/ ,7 /* 248*/ ,7 /* 249*/ ,7 /* 250*/ , -7 /* 251*/ ,7 /* 252*/ ,7 /* 253*/ ,7 /* 254*/ ,7 /* 255*/ }; // end _First_one - - /** - Usage: myIndexInSetBits[ b ][ n ] - - \a b in 0..7 - - \a n in 0..255 - Set bits are numbered from 1 to x when reading the word from the - least significant to the most significant bit. This number is the - index of bit \a b in the number \a n. - return this index or 0 if the bit is not set. - */ - const DGtal::uint8_t Bits::myIndexInSetBits[ 8 ][ 256 ] = { - // Table for bit 0. - { 0 /*0*/, 1 /*1*/, 0 /*2*/, 1 /*3*/, 0 /*4*/, 1 /*5*/, 0 /*6*/, 1 /*7*/, - 0 /*8*/, 1 /*9*/, 0 /*10*/, 1 /*11*/, 0 /*12*/, 1 /*13*/, 0 /*14*/, 1 /*15*/, - 0 /*16*/, 1 /*17*/, 0 /*18*/, 1 /*19*/, 0 /*20*/, 1 /*21*/, 0 /*22*/, 1 /*23*/, - 0 /*24*/, 1 /*25*/, 0 /*26*/, 1 /*27*/, 0 /*28*/, 1 /*29*/, 0 /*30*/, 1 /*31*/, - 0 /*32*/, 1 /*33*/, 0 /*34*/, 1 /*35*/, 0 /*36*/, 1 /*37*/, 0 /*38*/, 1 /*39*/, - 0 /*40*/, 1 /*41*/, 0 /*42*/, 1 /*43*/, 0 /*44*/, 1 /*45*/, 0 /*46*/, 1 /*47*/, - 0 /*48*/, 1 /*49*/, 0 /*50*/, 1 /*51*/, 0 /*52*/, 1 /*53*/, 0 /*54*/, 1 /*55*/, - 0 /*56*/, 1 /*57*/, 0 /*58*/, 1 /*59*/, 0 /*60*/, 1 /*61*/, 0 /*62*/, 1 /*63*/, - 0 /*64*/, 1 /*65*/, 0 /*66*/, 1 /*67*/, 0 /*68*/, 1 /*69*/, 0 /*70*/, 1 /*71*/, - 0 /*72*/, 1 /*73*/, 0 /*74*/, 1 /*75*/, 0 /*76*/, 1 /*77*/, 0 /*78*/, 1 /*79*/, - 0 /*80*/, 1 /*81*/, 0 /*82*/, 1 /*83*/, 0 /*84*/, 1 /*85*/, 0 /*86*/, 1 /*87*/, - 0 /*88*/, 1 /*89*/, 0 /*90*/, 1 /*91*/, 0 /*92*/, 1 /*93*/, 0 /*94*/, 1 /*95*/, - 0 /*96*/, 1 /*97*/, 0 /*98*/, 1 /*99*/, 0 /*100*/, 1 /*101*/, 0 /*102*/, 1 /*103*/, - 0 /*104*/, 1 /*105*/, 0 /*106*/, 1 /*107*/, 0 /*108*/, 1 /*109*/, 0 /*110*/, 1 /*111*/, - 0 /*112*/, 1 /*113*/, 0 /*114*/, 1 /*115*/, 0 /*116*/, 1 /*117*/, 0 /*118*/, 1 /*119*/, - 0 /*120*/, 1 /*121*/, 0 /*122*/, 1 /*123*/, 0 /*124*/, 1 /*125*/, 0 /*126*/, 1 /*127*/, - 0 /*128*/, 1 /*129*/, 0 /*130*/, 1 /*131*/, 0 /*132*/, 1 /*133*/, 0 /*134*/, 1 /*135*/, - 0 /*136*/, 1 /*137*/, 0 /*138*/, 1 /*139*/, 0 /*140*/, 1 /*141*/, 0 /*142*/, 1 /*143*/, - 0 /*144*/, 1 /*145*/, 0 /*146*/, 1 /*147*/, 0 /*148*/, 1 /*149*/, 0 /*150*/, 1 /*151*/, - 0 /*152*/, 1 /*153*/, 0 /*154*/, 1 /*155*/, 0 /*156*/, 1 /*157*/, 0 /*158*/, 1 /*159*/, - 0 /*160*/, 1 /*161*/, 0 /*162*/, 1 /*163*/, 0 /*164*/, 1 /*165*/, 0 /*166*/, 1 /*167*/, - 0 /*168*/, 1 /*169*/, 0 /*170*/, 1 /*171*/, 0 /*172*/, 1 /*173*/, 0 /*174*/, 1 /*175*/, - 0 /*176*/, 1 /*177*/, 0 /*178*/, 1 /*179*/, 0 /*180*/, 1 /*181*/, 0 /*182*/, 1 /*183*/, - 0 /*184*/, 1 /*185*/, 0 /*186*/, 1 /*187*/, 0 /*188*/, 1 /*189*/, 0 /*190*/, 1 /*191*/, - 0 /*192*/, 1 /*193*/, 0 /*194*/, 1 /*195*/, 0 /*196*/, 1 /*197*/, 0 /*198*/, 1 /*199*/, - 0 /*200*/, 1 /*201*/, 0 /*202*/, 1 /*203*/, 0 /*204*/, 1 /*205*/, 0 /*206*/, 1 /*207*/, - 0 /*208*/, 1 /*209*/, 0 /*210*/, 1 /*211*/, 0 /*212*/, 1 /*213*/, 0 /*214*/, 1 /*215*/, - 0 /*216*/, 1 /*217*/, 0 /*218*/, 1 /*219*/, 0 /*220*/, 1 /*221*/, 0 /*222*/, 1 /*223*/, - 0 /*224*/, 1 /*225*/, 0 /*226*/, 1 /*227*/, 0 /*228*/, 1 /*229*/, 0 /*230*/, 1 /*231*/, - 0 /*232*/, 1 /*233*/, 0 /*234*/, 1 /*235*/, 0 /*236*/, 1 /*237*/, 0 /*238*/, 1 /*239*/, - 0 /*240*/, 1 /*241*/, 0 /*242*/, 1 /*243*/, 0 /*244*/, 1 /*245*/, 0 /*246*/, 1 /*247*/, - 0 /*248*/, 1 /*249*/, 0 /*250*/, 1 /*251*/, 0 /*252*/, 1 /*253*/, 0 /*254*/, 1 /*255*/ }, - // Table for bit 1. - { 0 /*0*/, 0 /*1*/, 1 /*2*/, 2 /*3*/, 0 /*4*/, 0 /*5*/, 1 /*6*/, 2 /*7*/, - 0 /*8*/, 0 /*9*/, 1 /*10*/, 2 /*11*/, 0 /*12*/, 0 /*13*/, 1 /*14*/, 2 /*15*/, - 0 /*16*/, 0 /*17*/, 1 /*18*/, 2 /*19*/, 0 /*20*/, 0 /*21*/, 1 /*22*/, 2 /*23*/, - 0 /*24*/, 0 /*25*/, 1 /*26*/, 2 /*27*/, 0 /*28*/, 0 /*29*/, 1 /*30*/, 2 /*31*/, - 0 /*32*/, 0 /*33*/, 1 /*34*/, 2 /*35*/, 0 /*36*/, 0 /*37*/, 1 /*38*/, 2 /*39*/, - 0 /*40*/, 0 /*41*/, 1 /*42*/, 2 /*43*/, 0 /*44*/, 0 /*45*/, 1 /*46*/, 2 /*47*/, - 0 /*48*/, 0 /*49*/, 1 /*50*/, 2 /*51*/, 0 /*52*/, 0 /*53*/, 1 /*54*/, 2 /*55*/, - 0 /*56*/, 0 /*57*/, 1 /*58*/, 2 /*59*/, 0 /*60*/, 0 /*61*/, 1 /*62*/, 2 /*63*/, - 0 /*64*/, 0 /*65*/, 1 /*66*/, 2 /*67*/, 0 /*68*/, 0 /*69*/, 1 /*70*/, 2 /*71*/, - 0 /*72*/, 0 /*73*/, 1 /*74*/, 2 /*75*/, 0 /*76*/, 0 /*77*/, 1 /*78*/, 2 /*79*/, - 0 /*80*/, 0 /*81*/, 1 /*82*/, 2 /*83*/, 0 /*84*/, 0 /*85*/, 1 /*86*/, 2 /*87*/, - 0 /*88*/, 0 /*89*/, 1 /*90*/, 2 /*91*/, 0 /*92*/, 0 /*93*/, 1 /*94*/, 2 /*95*/, - 0 /*96*/, 0 /*97*/, 1 /*98*/, 2 /*99*/, 0 /*100*/, 0 /*101*/, 1 /*102*/, 2 /*103*/, - 0 /*104*/, 0 /*105*/, 1 /*106*/, 2 /*107*/, 0 /*108*/, 0 /*109*/, 1 /*110*/, 2 /*111*/, - 0 /*112*/, 0 /*113*/, 1 /*114*/, 2 /*115*/, 0 /*116*/, 0 /*117*/, 1 /*118*/, 2 /*119*/, - 0 /*120*/, 0 /*121*/, 1 /*122*/, 2 /*123*/, 0 /*124*/, 0 /*125*/, 1 /*126*/, 2 /*127*/, - 0 /*128*/, 0 /*129*/, 1 /*130*/, 2 /*131*/, 0 /*132*/, 0 /*133*/, 1 /*134*/, 2 /*135*/, - 0 /*136*/, 0 /*137*/, 1 /*138*/, 2 /*139*/, 0 /*140*/, 0 /*141*/, 1 /*142*/, 2 /*143*/, - 0 /*144*/, 0 /*145*/, 1 /*146*/, 2 /*147*/, 0 /*148*/, 0 /*149*/, 1 /*150*/, 2 /*151*/, - 0 /*152*/, 0 /*153*/, 1 /*154*/, 2 /*155*/, 0 /*156*/, 0 /*157*/, 1 /*158*/, 2 /*159*/, - 0 /*160*/, 0 /*161*/, 1 /*162*/, 2 /*163*/, 0 /*164*/, 0 /*165*/, 1 /*166*/, 2 /*167*/, - 0 /*168*/, 0 /*169*/, 1 /*170*/, 2 /*171*/, 0 /*172*/, 0 /*173*/, 1 /*174*/, 2 /*175*/, - 0 /*176*/, 0 /*177*/, 1 /*178*/, 2 /*179*/, 0 /*180*/, 0 /*181*/, 1 /*182*/, 2 /*183*/, - 0 /*184*/, 0 /*185*/, 1 /*186*/, 2 /*187*/, 0 /*188*/, 0 /*189*/, 1 /*190*/, 2 /*191*/, - 0 /*192*/, 0 /*193*/, 1 /*194*/, 2 /*195*/, 0 /*196*/, 0 /*197*/, 1 /*198*/, 2 /*199*/, - 0 /*200*/, 0 /*201*/, 1 /*202*/, 2 /*203*/, 0 /*204*/, 0 /*205*/, 1 /*206*/, 2 /*207*/, - 0 /*208*/, 0 /*209*/, 1 /*210*/, 2 /*211*/, 0 /*212*/, 0 /*213*/, 1 /*214*/, 2 /*215*/, - 0 /*216*/, 0 /*217*/, 1 /*218*/, 2 /*219*/, 0 /*220*/, 0 /*221*/, 1 /*222*/, 2 /*223*/, - 0 /*224*/, 0 /*225*/, 1 /*226*/, 2 /*227*/, 0 /*228*/, 0 /*229*/, 1 /*230*/, 2 /*231*/, - 0 /*232*/, 0 /*233*/, 1 /*234*/, 2 /*235*/, 0 /*236*/, 0 /*237*/, 1 /*238*/, 2 /*239*/, - 0 /*240*/, 0 /*241*/, 1 /*242*/, 2 /*243*/, 0 /*244*/, 0 /*245*/, 1 /*246*/, 2 /*247*/, - 0 /*248*/, 0 /*249*/, 1 /*250*/, 2 /*251*/, 0 /*252*/, 0 /*253*/, 1 /*254*/, 2 /*255*/}, - // Table for bit 2. - { 0 /*0*/, 0 /*1*/, 0 /*2*/, 0 /*3*/, 1 /*4*/, 2 /*5*/, 2 /*6*/, 3 /*7*/, - 0 /*8*/, 0 /*9*/, 0 /*10*/, 0 /*11*/, 1 /*12*/, 2 /*13*/, 2 /*14*/, 3 /*15*/, - 0 /*16*/, 0 /*17*/, 0 /*18*/, 0 /*19*/, 1 /*20*/, 2 /*21*/, 2 /*22*/, 3 /*23*/, - 0 /*24*/, 0 /*25*/, 0 /*26*/, 0 /*27*/, 1 /*28*/, 2 /*29*/, 2 /*30*/, 3 /*31*/, - 0 /*32*/, 0 /*33*/, 0 /*34*/, 0 /*35*/, 1 /*36*/, 2 /*37*/, 2 /*38*/, 3 /*39*/, - 0 /*40*/, 0 /*41*/, 0 /*42*/, 0 /*43*/, 1 /*44*/, 2 /*45*/, 2 /*46*/, 3 /*47*/, - 0 /*48*/, 0 /*49*/, 0 /*50*/, 0 /*51*/, 1 /*52*/, 2 /*53*/, 2 /*54*/, 3 /*55*/, - 0 /*56*/, 0 /*57*/, 0 /*58*/, 0 /*59*/, 1 /*60*/, 2 /*61*/, 2 /*62*/, 3 /*63*/, - 0 /*64*/, 0 /*65*/, 0 /*66*/, 0 /*67*/, 1 /*68*/, 2 /*69*/, 2 /*70*/, 3 /*71*/, - 0 /*72*/, 0 /*73*/, 0 /*74*/, 0 /*75*/, 1 /*76*/, 2 /*77*/, 2 /*78*/, 3 /*79*/, - 0 /*80*/, 0 /*81*/, 0 /*82*/, 0 /*83*/, 1 /*84*/, 2 /*85*/, 2 /*86*/, 3 /*87*/, - 0 /*88*/, 0 /*89*/, 0 /*90*/, 0 /*91*/, 1 /*92*/, 2 /*93*/, 2 /*94*/, 3 /*95*/, - 0 /*96*/, 0 /*97*/, 0 /*98*/, 0 /*99*/, 1 /*100*/, 2 /*101*/, 2 /*102*/, 3 /*103*/, - 0 /*104*/, 0 /*105*/, 0 /*106*/, 0 /*107*/, 1 /*108*/, 2 /*109*/, 2 /*110*/, 3 /*111*/, - 0 /*112*/, 0 /*113*/, 0 /*114*/, 0 /*115*/, 1 /*116*/, 2 /*117*/, 2 /*118*/, 3 /*119*/, - 0 /*120*/, 0 /*121*/, 0 /*122*/, 0 /*123*/, 1 /*124*/, 2 /*125*/, 2 /*126*/, 3 /*127*/, - 0 /*128*/, 0 /*129*/, 0 /*130*/, 0 /*131*/, 1 /*132*/, 2 /*133*/, 2 /*134*/, 3 /*135*/, - 0 /*136*/, 0 /*137*/, 0 /*138*/, 0 /*139*/, 1 /*140*/, 2 /*141*/, 2 /*142*/, 3 /*143*/, - 0 /*144*/, 0 /*145*/, 0 /*146*/, 0 /*147*/, 1 /*148*/, 2 /*149*/, 2 /*150*/, 3 /*151*/, - 0 /*152*/, 0 /*153*/, 0 /*154*/, 0 /*155*/, 1 /*156*/, 2 /*157*/, 2 /*158*/, 3 /*159*/, - 0 /*160*/, 0 /*161*/, 0 /*162*/, 0 /*163*/, 1 /*164*/, 2 /*165*/, 2 /*166*/, 3 /*167*/, - 0 /*168*/, 0 /*169*/, 0 /*170*/, 0 /*171*/, 1 /*172*/, 2 /*173*/, 2 /*174*/, 3 /*175*/, - 0 /*176*/, 0 /*177*/, 0 /*178*/, 0 /*179*/, 1 /*180*/, 2 /*181*/, 2 /*182*/, 3 /*183*/, - 0 /*184*/, 0 /*185*/, 0 /*186*/, 0 /*187*/, 1 /*188*/, 2 /*189*/, 2 /*190*/, 3 /*191*/, - 0 /*192*/, 0 /*193*/, 0 /*194*/, 0 /*195*/, 1 /*196*/, 2 /*197*/, 2 /*198*/, 3 /*199*/, - 0 /*200*/, 0 /*201*/, 0 /*202*/, 0 /*203*/, 1 /*204*/, 2 /*205*/, 2 /*206*/, 3 /*207*/, - 0 /*208*/, 0 /*209*/, 0 /*210*/, 0 /*211*/, 1 /*212*/, 2 /*213*/, 2 /*214*/, 3 /*215*/, - 0 /*216*/, 0 /*217*/, 0 /*218*/, 0 /*219*/, 1 /*220*/, 2 /*221*/, 2 /*222*/, 3 /*223*/, - 0 /*224*/, 0 /*225*/, 0 /*226*/, 0 /*227*/, 1 /*228*/, 2 /*229*/, 2 /*230*/, 3 /*231*/, - 0 /*232*/, 0 /*233*/, 0 /*234*/, 0 /*235*/, 1 /*236*/, 2 /*237*/, 2 /*238*/, 3 /*239*/, - 0 /*240*/, 0 /*241*/, 0 /*242*/, 0 /*243*/, 1 /*244*/, 2 /*245*/, 2 /*246*/, 3 /*247*/, - 0 /*248*/, 0 /*249*/, 0 /*250*/, 0 /*251*/, 1 /*252*/, 2 /*253*/, 2 /*254*/, 3 /*255*/}, - // Table for bit 3. - { 0 /*0*/, 0 /*1*/, 0 /*2*/, 0 /*3*/, 0 /*4*/, 0 /*5*/, 0 /*6*/, 0 /*7*/, - 1 /*8*/, 2 /*9*/, 2 /*10*/, 3 /*11*/, 2 /*12*/, 3 /*13*/, 3 /*14*/, 4 /*15*/, - 0 /*16*/, 0 /*17*/, 0 /*18*/, 0 /*19*/, 0 /*20*/, 0 /*21*/, 0 /*22*/, 0 /*23*/, - 1 /*24*/, 2 /*25*/, 2 /*26*/, 3 /*27*/, 2 /*28*/, 3 /*29*/, 3 /*30*/, 4 /*31*/, - 0 /*32*/, 0 /*33*/, 0 /*34*/, 0 /*35*/, 0 /*36*/, 0 /*37*/, 0 /*38*/, 0 /*39*/, - 1 /*40*/, 2 /*41*/, 2 /*42*/, 3 /*43*/, 2 /*44*/, 3 /*45*/, 3 /*46*/, 4 /*47*/, - 0 /*48*/, 0 /*49*/, 0 /*50*/, 0 /*51*/, 0 /*52*/, 0 /*53*/, 0 /*54*/, 0 /*55*/, - 1 /*56*/, 2 /*57*/, 2 /*58*/, 3 /*59*/, 2 /*60*/, 3 /*61*/, 3 /*62*/, 4 /*63*/, - 0 /*64*/, 0 /*65*/, 0 /*66*/, 0 /*67*/, 0 /*68*/, 0 /*69*/, 0 /*70*/, 0 /*71*/, - 1 /*72*/, 2 /*73*/, 2 /*74*/, 3 /*75*/, 2 /*76*/, 3 /*77*/, 3 /*78*/, 4 /*79*/, - 0 /*80*/, 0 /*81*/, 0 /*82*/, 0 /*83*/, 0 /*84*/, 0 /*85*/, 0 /*86*/, 0 /*87*/, - 1 /*88*/, 2 /*89*/, 2 /*90*/, 3 /*91*/, 2 /*92*/, 3 /*93*/, 3 /*94*/, 4 /*95*/, - 0 /*96*/, 0 /*97*/, 0 /*98*/, 0 /*99*/, 0 /*100*/, 0 /*101*/, 0 /*102*/, 0 /*103*/, - 1 /*104*/, 2 /*105*/, 2 /*106*/, 3 /*107*/, 2 /*108*/, 3 /*109*/, 3 /*110*/, 4 /*111*/, - 0 /*112*/, 0 /*113*/, 0 /*114*/, 0 /*115*/, 0 /*116*/, 0 /*117*/, 0 /*118*/, 0 /*119*/, - 1 /*120*/, 2 /*121*/, 2 /*122*/, 3 /*123*/, 2 /*124*/, 3 /*125*/, 3 /*126*/, 4 /*127*/, - 0 /*128*/, 0 /*129*/, 0 /*130*/, 0 /*131*/, 0 /*132*/, 0 /*133*/, 0 /*134*/, 0 /*135*/, - 1 /*136*/, 2 /*137*/, 2 /*138*/, 3 /*139*/, 2 /*140*/, 3 /*141*/, 3 /*142*/, 4 /*143*/, - 0 /*144*/, 0 /*145*/, 0 /*146*/, 0 /*147*/, 0 /*148*/, 0 /*149*/, 0 /*150*/, 0 /*151*/, - 1 /*152*/, 2 /*153*/, 2 /*154*/, 3 /*155*/, 2 /*156*/, 3 /*157*/, 3 /*158*/, 4 /*159*/, - 0 /*160*/, 0 /*161*/, 0 /*162*/, 0 /*163*/, 0 /*164*/, 0 /*165*/, 0 /*166*/, 0 /*167*/, - 1 /*168*/, 2 /*169*/, 2 /*170*/, 3 /*171*/, 2 /*172*/, 3 /*173*/, 3 /*174*/, 4 /*175*/, - 0 /*176*/, 0 /*177*/, 0 /*178*/, 0 /*179*/, 0 /*180*/, 0 /*181*/, 0 /*182*/, 0 /*183*/, - 1 /*184*/, 2 /*185*/, 2 /*186*/, 3 /*187*/, 2 /*188*/, 3 /*189*/, 3 /*190*/, 4 /*191*/, - 0 /*192*/, 0 /*193*/, 0 /*194*/, 0 /*195*/, 0 /*196*/, 0 /*197*/, 0 /*198*/, 0 /*199*/, - 1 /*200*/, 2 /*201*/, 2 /*202*/, 3 /*203*/, 2 /*204*/, 3 /*205*/, 3 /*206*/, 4 /*207*/, - 0 /*208*/, 0 /*209*/, 0 /*210*/, 0 /*211*/, 0 /*212*/, 0 /*213*/, 0 /*214*/, 0 /*215*/, - 1 /*216*/, 2 /*217*/, 2 /*218*/, 3 /*219*/, 2 /*220*/, 3 /*221*/, 3 /*222*/, 4 /*223*/, - 0 /*224*/, 0 /*225*/, 0 /*226*/, 0 /*227*/, 0 /*228*/, 0 /*229*/, 0 /*230*/, 0 /*231*/, - 1 /*232*/, 2 /*233*/, 2 /*234*/, 3 /*235*/, 2 /*236*/, 3 /*237*/, 3 /*238*/, 4 /*239*/, - 0 /*240*/, 0 /*241*/, 0 /*242*/, 0 /*243*/, 0 /*244*/, 0 /*245*/, 0 /*246*/, 0 /*247*/, - 1 /*248*/, 2 /*249*/, 2 /*250*/, 3 /*251*/, 2 /*252*/, 3 /*253*/, 3 /*254*/, 4 /*255*/}, - // Table for bit 4. - { 0 /*0*/, 0 /*1*/, 0 /*2*/, 0 /*3*/, 0 /*4*/, 0 /*5*/, 0 /*6*/, 0 /*7*/, - 0 /*8*/, 0 /*9*/, 0 /*10*/, 0 /*11*/, 0 /*12*/, 0 /*13*/, 0 /*14*/, 0 /*15*/, - 1 /*16*/, 2 /*17*/, 2 /*18*/, 3 /*19*/, 2 /*20*/, 3 /*21*/, 3 /*22*/, 4 /*23*/, - 2 /*24*/, 3 /*25*/, 3 /*26*/, 4 /*27*/, 3 /*28*/, 4 /*29*/, 4 /*30*/, 5 /*31*/, - 0 /*32*/, 0 /*33*/, 0 /*34*/, 0 /*35*/, 0 /*36*/, 0 /*37*/, 0 /*38*/, 0 /*39*/, - 0 /*40*/, 0 /*41*/, 0 /*42*/, 0 /*43*/, 0 /*44*/, 0 /*45*/, 0 /*46*/, 0 /*47*/, - 1 /*48*/, 2 /*49*/, 2 /*50*/, 3 /*51*/, 2 /*52*/, 3 /*53*/, 3 /*54*/, 4 /*55*/, - 2 /*56*/, 3 /*57*/, 3 /*58*/, 4 /*59*/, 3 /*60*/, 4 /*61*/, 4 /*62*/, 5 /*63*/, - 0 /*64*/, 0 /*65*/, 0 /*66*/, 0 /*67*/, 0 /*68*/, 0 /*69*/, 0 /*70*/, 0 /*71*/, - 0 /*72*/, 0 /*73*/, 0 /*74*/, 0 /*75*/, 0 /*76*/, 0 /*77*/, 0 /*78*/, 0 /*79*/, - 1 /*80*/, 2 /*81*/, 2 /*82*/, 3 /*83*/, 2 /*84*/, 3 /*85*/, 3 /*86*/, 4 /*87*/, - 2 /*88*/, 3 /*89*/, 3 /*90*/, 4 /*91*/, 3 /*92*/, 4 /*93*/, 4 /*94*/, 5 /*95*/, - 0 /*96*/, 0 /*97*/, 0 /*98*/, 0 /*99*/, 0 /*100*/, 0 /*101*/, 0 /*102*/, 0 /*103*/, - 0 /*104*/, 0 /*105*/, 0 /*106*/, 0 /*107*/, 0 /*108*/, 0 /*109*/, 0 /*110*/, 0 /*111*/, - 1 /*112*/, 2 /*113*/, 2 /*114*/, 3 /*115*/, 2 /*116*/, 3 /*117*/, 3 /*118*/, 4 /*119*/, - 2 /*120*/, 3 /*121*/, 3 /*122*/, 4 /*123*/, 3 /*124*/, 4 /*125*/, 4 /*126*/, 5 /*127*/, - 0 /*128*/, 0 /*129*/, 0 /*130*/, 0 /*131*/, 0 /*132*/, 0 /*133*/, 0 /*134*/, 0 /*135*/, - 0 /*136*/, 0 /*137*/, 0 /*138*/, 0 /*139*/, 0 /*140*/, 0 /*141*/, 0 /*142*/, 0 /*143*/, - 1 /*144*/, 2 /*145*/, 2 /*146*/, 3 /*147*/, 2 /*148*/, 3 /*149*/, 3 /*150*/, 4 /*151*/, - 2 /*152*/, 3 /*153*/, 3 /*154*/, 4 /*155*/, 3 /*156*/, 4 /*157*/, 4 /*158*/, 5 /*159*/, - 0 /*160*/, 0 /*161*/, 0 /*162*/, 0 /*163*/, 0 /*164*/, 0 /*165*/, 0 /*166*/, 0 /*167*/, - 0 /*168*/, 0 /*169*/, 0 /*170*/, 0 /*171*/, 0 /*172*/, 0 /*173*/, 0 /*174*/, 0 /*175*/, - 1 /*176*/, 2 /*177*/, 2 /*178*/, 3 /*179*/, 2 /*180*/, 3 /*181*/, 3 /*182*/, 4 /*183*/, - 2 /*184*/, 3 /*185*/, 3 /*186*/, 4 /*187*/, 3 /*188*/, 4 /*189*/, 4 /*190*/, 5 /*191*/, - 0 /*192*/, 0 /*193*/, 0 /*194*/, 0 /*195*/, 0 /*196*/, 0 /*197*/, 0 /*198*/, 0 /*199*/, - 0 /*200*/, 0 /*201*/, 0 /*202*/, 0 /*203*/, 0 /*204*/, 0 /*205*/, 0 /*206*/, 0 /*207*/, - 1 /*208*/, 2 /*209*/, 2 /*210*/, 3 /*211*/, 2 /*212*/, 3 /*213*/, 3 /*214*/, 4 /*215*/, - 2 /*216*/, 3 /*217*/, 3 /*218*/, 4 /*219*/, 3 /*220*/, 4 /*221*/, 4 /*222*/, 5 /*223*/, - 0 /*224*/, 0 /*225*/, 0 /*226*/, 0 /*227*/, 0 /*228*/, 0 /*229*/, 0 /*230*/, 0 /*231*/, - 0 /*232*/, 0 /*233*/, 0 /*234*/, 0 /*235*/, 0 /*236*/, 0 /*237*/, 0 /*238*/, 0 /*239*/, - 1 /*240*/, 2 /*241*/, 2 /*242*/, 3 /*243*/, 2 /*244*/, 3 /*245*/, 3 /*246*/, 4 /*247*/, - 2 /*248*/, 3 /*249*/, 3 /*250*/, 4 /*251*/, 3 /*252*/, 4 /*253*/, 4 /*254*/, 5 /*255*/ }, - // Table for bit 5. - { 0 /*0*/, 0 /*1*/, 0 /*2*/, 0 /*3*/, 0 /*4*/, 0 /*5*/, 0 /*6*/, 0 /*7*/, - 0 /*8*/, 0 /*9*/, 0 /*10*/, 0 /*11*/, 0 /*12*/, 0 /*13*/, 0 /*14*/, 0 /*15*/, - 0 /*16*/, 0 /*17*/, 0 /*18*/, 0 /*19*/, 0 /*20*/, 0 /*21*/, 0 /*22*/, 0 /*23*/, - 0 /*24*/, 0 /*25*/, 0 /*26*/, 0 /*27*/, 0 /*28*/, 0 /*29*/, 0 /*30*/, 0 /*31*/, - 1 /*32*/, 2 /*33*/, 2 /*34*/, 3 /*35*/, 2 /*36*/, 3 /*37*/, 3 /*38*/, 4 /*39*/, - 2 /*40*/, 3 /*41*/, 3 /*42*/, 4 /*43*/, 3 /*44*/, 4 /*45*/, 4 /*46*/, 5 /*47*/, - 2 /*48*/, 3 /*49*/, 3 /*50*/, 4 /*51*/, 3 /*52*/, 4 /*53*/, 4 /*54*/, 5 /*55*/, - 3 /*56*/, 4 /*57*/, 4 /*58*/, 5 /*59*/, 4 /*60*/, 5 /*61*/, 5 /*62*/, 6 /*63*/, - 0 /*64*/, 0 /*65*/, 0 /*66*/, 0 /*67*/, 0 /*68*/, 0 /*69*/, 0 /*70*/, 0 /*71*/, - 0 /*72*/, 0 /*73*/, 0 /*74*/, 0 /*75*/, 0 /*76*/, 0 /*77*/, 0 /*78*/, 0 /*79*/, - 0 /*80*/, 0 /*81*/, 0 /*82*/, 0 /*83*/, 0 /*84*/, 0 /*85*/, 0 /*86*/, 0 /*87*/, - 0 /*88*/, 0 /*89*/, 0 /*90*/, 0 /*91*/, 0 /*92*/, 0 /*93*/, 0 /*94*/, 0 /*95*/, - 1 /*96*/, 2 /*97*/, 2 /*98*/, 3 /*99*/, 2 /*100*/, 3 /*101*/, 3 /*102*/, 4 /*103*/, - 2 /*104*/, 3 /*105*/, 3 /*106*/, 4 /*107*/, 3 /*108*/, 4 /*109*/, 4 /*110*/, 5 /*111*/, - 2 /*112*/, 3 /*113*/, 3 /*114*/, 4 /*115*/, 3 /*116*/, 4 /*117*/, 4 /*118*/, 5 /*119*/, - 3 /*120*/, 4 /*121*/, 4 /*122*/, 5 /*123*/, 4 /*124*/, 5 /*125*/, 5 /*126*/, 6 /*127*/, - 0 /*128*/, 0 /*129*/, 0 /*130*/, 0 /*131*/, 0 /*132*/, 0 /*133*/, 0 /*134*/, 0 /*135*/, - 0 /*136*/, 0 /*137*/, 0 /*138*/, 0 /*139*/, 0 /*140*/, 0 /*141*/, 0 /*142*/, 0 /*143*/, - 0 /*144*/, 0 /*145*/, 0 /*146*/, 0 /*147*/, 0 /*148*/, 0 /*149*/, 0 /*150*/, 0 /*151*/, - 0 /*152*/, 0 /*153*/, 0 /*154*/, 0 /*155*/, 0 /*156*/, 0 /*157*/, 0 /*158*/, 0 /*159*/, - 1 /*160*/, 2 /*161*/, 2 /*162*/, 3 /*163*/, 2 /*164*/, 3 /*165*/, 3 /*166*/, 4 /*167*/, - 2 /*168*/, 3 /*169*/, 3 /*170*/, 4 /*171*/, 3 /*172*/, 4 /*173*/, 4 /*174*/, 5 /*175*/, - 2 /*176*/, 3 /*177*/, 3 /*178*/, 4 /*179*/, 3 /*180*/, 4 /*181*/, 4 /*182*/, 5 /*183*/, - 3 /*184*/, 4 /*185*/, 4 /*186*/, 5 /*187*/, 4 /*188*/, 5 /*189*/, 5 /*190*/, 6 /*191*/, - 0 /*192*/, 0 /*193*/, 0 /*194*/, 0 /*195*/, 0 /*196*/, 0 /*197*/, 0 /*198*/, 0 /*199*/, - 0 /*200*/, 0 /*201*/, 0 /*202*/, 0 /*203*/, 0 /*204*/, 0 /*205*/, 0 /*206*/, 0 /*207*/, - 0 /*208*/, 0 /*209*/, 0 /*210*/, 0 /*211*/, 0 /*212*/, 0 /*213*/, 0 /*214*/, 0 /*215*/, - 0 /*216*/, 0 /*217*/, 0 /*218*/, 0 /*219*/, 0 /*220*/, 0 /*221*/, 0 /*222*/, 0 /*223*/, - 1 /*224*/, 2 /*225*/, 2 /*226*/, 3 /*227*/, 2 /*228*/, 3 /*229*/, 3 /*230*/, 4 /*231*/, - 2 /*232*/, 3 /*233*/, 3 /*234*/, 4 /*235*/, 3 /*236*/, 4 /*237*/, 4 /*238*/, 5 /*239*/, - 2 /*240*/, 3 /*241*/, 3 /*242*/, 4 /*243*/, 3 /*244*/, 4 /*245*/, 4 /*246*/, 5 /*247*/, - 3 /*248*/, 4 /*249*/, 4 /*250*/, 5 /*251*/, 4 /*252*/, 5 /*253*/, 5 /*254*/, 6 /*255*/}, - // Table for bit 6. - { 0 /*0*/, 0 /*1*/, 0 /*2*/, 0 /*3*/, 0 /*4*/, 0 /*5*/, 0 /*6*/, 0 /*7*/, - 0 /*8*/, 0 /*9*/, 0 /*10*/, 0 /*11*/, 0 /*12*/, 0 /*13*/, 0 /*14*/, 0 /*15*/, - 0 /*16*/, 0 /*17*/, 0 /*18*/, 0 /*19*/, 0 /*20*/, 0 /*21*/, 0 /*22*/, 0 /*23*/, - 0 /*24*/, 0 /*25*/, 0 /*26*/, 0 /*27*/, 0 /*28*/, 0 /*29*/, 0 /*30*/, 0 /*31*/, - 0 /*32*/, 0 /*33*/, 0 /*34*/, 0 /*35*/, 0 /*36*/, 0 /*37*/, 0 /*38*/, 0 /*39*/, - 0 /*40*/, 0 /*41*/, 0 /*42*/, 0 /*43*/, 0 /*44*/, 0 /*45*/, 0 /*46*/, 0 /*47*/, - 0 /*48*/, 0 /*49*/, 0 /*50*/, 0 /*51*/, 0 /*52*/, 0 /*53*/, 0 /*54*/, 0 /*55*/, - 0 /*56*/, 0 /*57*/, 0 /*58*/, 0 /*59*/, 0 /*60*/, 0 /*61*/, 0 /*62*/, 0 /*63*/, - 1 /*64*/, 2 /*65*/, 2 /*66*/, 3 /*67*/, 2 /*68*/, 3 /*69*/, 3 /*70*/, 4 /*71*/, - 2 /*72*/, 3 /*73*/, 3 /*74*/, 4 /*75*/, 3 /*76*/, 4 /*77*/, 4 /*78*/, 5 /*79*/, - 2 /*80*/, 3 /*81*/, 3 /*82*/, 4 /*83*/, 3 /*84*/, 4 /*85*/, 4 /*86*/, 5 /*87*/, - 3 /*88*/, 4 /*89*/, 4 /*90*/, 5 /*91*/, 4 /*92*/, 5 /*93*/, 5 /*94*/, 6 /*95*/, - 2 /*96*/, 3 /*97*/, 3 /*98*/, 4 /*99*/, 3 /*100*/, 4 /*101*/, 4 /*102*/, 5 /*103*/, - 3 /*104*/, 4 /*105*/, 4 /*106*/, 5 /*107*/, 4 /*108*/, 5 /*109*/, 5 /*110*/, 6 /*111*/, - 3 /*112*/, 4 /*113*/, 4 /*114*/, 5 /*115*/, 4 /*116*/, 5 /*117*/, 5 /*118*/, 6 /*119*/, - 4 /*120*/, 5 /*121*/, 5 /*122*/, 6 /*123*/, 5 /*124*/, 6 /*125*/, 6 /*126*/, 7 /*127*/, - 0 /*128*/, 0 /*129*/, 0 /*130*/, 0 /*131*/, 0 /*132*/, 0 /*133*/, 0 /*134*/, 0 /*135*/, - 0 /*136*/, 0 /*137*/, 0 /*138*/, 0 /*139*/, 0 /*140*/, 0 /*141*/, 0 /*142*/, 0 /*143*/, - 0 /*144*/, 0 /*145*/, 0 /*146*/, 0 /*147*/, 0 /*148*/, 0 /*149*/, 0 /*150*/, 0 /*151*/, - 0 /*152*/, 0 /*153*/, 0 /*154*/, 0 /*155*/, 0 /*156*/, 0 /*157*/, 0 /*158*/, 0 /*159*/, - 0 /*160*/, 0 /*161*/, 0 /*162*/, 0 /*163*/, 0 /*164*/, 0 /*165*/, 0 /*166*/, 0 /*167*/, - 0 /*168*/, 0 /*169*/, 0 /*170*/, 0 /*171*/, 0 /*172*/, 0 /*173*/, 0 /*174*/, 0 /*175*/, - 0 /*176*/, 0 /*177*/, 0 /*178*/, 0 /*179*/, 0 /*180*/, 0 /*181*/, 0 /*182*/, 0 /*183*/, - 0 /*184*/, 0 /*185*/, 0 /*186*/, 0 /*187*/, 0 /*188*/, 0 /*189*/, 0 /*190*/, 0 /*191*/, - 1 /*192*/, 2 /*193*/, 2 /*194*/, 3 /*195*/, 2 /*196*/, 3 /*197*/, 3 /*198*/, 4 /*199*/, - 2 /*200*/, 3 /*201*/, 3 /*202*/, 4 /*203*/, 3 /*204*/, 4 /*205*/, 4 /*206*/, 5 /*207*/, - 2 /*208*/, 3 /*209*/, 3 /*210*/, 4 /*211*/, 3 /*212*/, 4 /*213*/, 4 /*214*/, 5 /*215*/, - 3 /*216*/, 4 /*217*/, 4 /*218*/, 5 /*219*/, 4 /*220*/, 5 /*221*/, 5 /*222*/, 6 /*223*/, - 2 /*224*/, 3 /*225*/, 3 /*226*/, 4 /*227*/, 3 /*228*/, 4 /*229*/, 4 /*230*/, 5 /*231*/, - 3 /*232*/, 4 /*233*/, 4 /*234*/, 5 /*235*/, 4 /*236*/, 5 /*237*/, 5 /*238*/, 6 /*239*/, - 3 /*240*/, 4 /*241*/, 4 /*242*/, 5 /*243*/, 4 /*244*/, 5 /*245*/, 5 /*246*/, 6 /*247*/, - 4 /*248*/, 5 /*249*/, 5 /*250*/, 6 /*251*/, 5 /*252*/, 6 /*253*/, 6 /*254*/, 7 /*255*/ }, - // Table for bit 7. - { 0 /*0*/, 0 /*1*/, 0 /*2*/, 0 /*3*/, 0 /*4*/, 0 /*5*/, 0 /*6*/, 0 /*7*/, - 0 /*8*/, 0 /*9*/, 0 /*10*/, 0 /*11*/, 0 /*12*/, 0 /*13*/, 0 /*14*/, 0 /*15*/, - 0 /*16*/, 0 /*17*/, 0 /*18*/, 0 /*19*/, 0 /*20*/, 0 /*21*/, 0 /*22*/, 0 /*23*/, - 0 /*24*/, 0 /*25*/, 0 /*26*/, 0 /*27*/, 0 /*28*/, 0 /*29*/, 0 /*30*/, 0 /*31*/, - 0 /*32*/, 0 /*33*/, 0 /*34*/, 0 /*35*/, 0 /*36*/, 0 /*37*/, 0 /*38*/, 0 /*39*/, - 0 /*40*/, 0 /*41*/, 0 /*42*/, 0 /*43*/, 0 /*44*/, 0 /*45*/, 0 /*46*/, 0 /*47*/, - 0 /*48*/, 0 /*49*/, 0 /*50*/, 0 /*51*/, 0 /*52*/, 0 /*53*/, 0 /*54*/, 0 /*55*/, - 0 /*56*/, 0 /*57*/, 0 /*58*/, 0 /*59*/, 0 /*60*/, 0 /*61*/, 0 /*62*/, 0 /*63*/, - 0 /*64*/, 0 /*65*/, 0 /*66*/, 0 /*67*/, 0 /*68*/, 0 /*69*/, 0 /*70*/, 0 /*71*/, - 0 /*72*/, 0 /*73*/, 0 /*74*/, 0 /*75*/, 0 /*76*/, 0 /*77*/, 0 /*78*/, 0 /*79*/, - 0 /*80*/, 0 /*81*/, 0 /*82*/, 0 /*83*/, 0 /*84*/, 0 /*85*/, 0 /*86*/, 0 /*87*/, - 0 /*88*/, 0 /*89*/, 0 /*90*/, 0 /*91*/, 0 /*92*/, 0 /*93*/, 0 /*94*/, 0 /*95*/, - 0 /*96*/, 0 /*97*/, 0 /*98*/, 0 /*99*/, 0 /*100*/, 0 /*101*/, 0 /*102*/, 0 /*103*/, - 0 /*104*/, 0 /*105*/, 0 /*106*/, 0 /*107*/, 0 /*108*/, 0 /*109*/, 0 /*110*/, 0 /*111*/, - 0 /*112*/, 0 /*113*/, 0 /*114*/, 0 /*115*/, 0 /*116*/, 0 /*117*/, 0 /*118*/, 0 /*119*/, - 0 /*120*/, 0 /*121*/, 0 /*122*/, 0 /*123*/, 0 /*124*/, 0 /*125*/, 0 /*126*/, 0 /*127*/, - 1 /*128*/, 2 /*129*/, 2 /*130*/, 3 /*131*/, 2 /*132*/, 3 /*133*/, 3 /*134*/, 4 /*135*/, - 2 /*136*/, 3 /*137*/, 3 /*138*/, 4 /*139*/, 3 /*140*/, 4 /*141*/, 4 /*142*/, 5 /*143*/, - 2 /*144*/, 3 /*145*/, 3 /*146*/, 4 /*147*/, 3 /*148*/, 4 /*149*/, 4 /*150*/, 5 /*151*/, - 3 /*152*/, 4 /*153*/, 4 /*154*/, 5 /*155*/, 4 /*156*/, 5 /*157*/, 5 /*158*/, 6 /*159*/, - 2 /*160*/, 3 /*161*/, 3 /*162*/, 4 /*163*/, 3 /*164*/, 4 /*165*/, 4 /*166*/, 5 /*167*/, - 3 /*168*/, 4 /*169*/, 4 /*170*/, 5 /*171*/, 4 /*172*/, 5 /*173*/, 5 /*174*/, 6 /*175*/, - 3 /*176*/, 4 /*177*/, 4 /*178*/, 5 /*179*/, 4 /*180*/, 5 /*181*/, 5 /*182*/, 6 /*183*/, - 4 /*184*/, 5 /*185*/, 5 /*186*/, 6 /*187*/, 5 /*188*/, 6 /*189*/, 6 /*190*/, 7 /*191*/, - 2 /*192*/, 3 /*193*/, 3 /*194*/, 4 /*195*/, 3 /*196*/, 4 /*197*/, 4 /*198*/, 5 /*199*/, - 3 /*200*/, 4 /*201*/, 4 /*202*/, 5 /*203*/, 4 /*204*/, 5 /*205*/, 5 /*206*/, 6 /*207*/, - 3 /*208*/, 4 /*209*/, 4 /*210*/, 5 /*211*/, 4 /*212*/, 5 /*213*/, 5 /*214*/, 6 /*215*/, - 4 /*216*/, 5 /*217*/, 5 /*218*/, 6 /*219*/, 5 /*220*/, 6 /*221*/, 6 /*222*/, 7 /*223*/, - 3 /*224*/, 4 /*225*/, 4 /*226*/, 5 /*227*/, 4 /*228*/, 5 /*229*/, 5 /*230*/, 6 /*231*/, - 4 /*232*/, 5 /*233*/, 5 /*234*/, 6 /*235*/, 5 /*236*/, 6 /*237*/, 6 /*238*/, 7 /*239*/, - 4 /*240*/, 5 /*241*/, 5 /*242*/, 6 /*243*/, 5 /*244*/, 6 /*245*/, 6 /*246*/, 7 /*247*/, - 5 /*248*/, 6 /*249*/, 6 /*250*/, 7 /*251*/, 6 /*252*/, 7 /*253*/, 7 /*254*/, 8 /*255*/ } - }; - -} -// // -/////////////////////////////////////////////////////////////////////////////// diff --git a/src/DGtal/base/Bits.h b/src/DGtal/base/Bits.h index 44ed59c359..8899c0a33a 100644 --- a/src/DGtal/base/Bits.h +++ b/src/DGtal/base/Bits.h @@ -412,5 +412,464 @@ namespace DGtal };//struct + + // Lookup tables for find and count operations. + /** + Lookup table for counting the number of bits set to 1 in a byte. + ( Taken from STL \ ) + */ + const DGtal::uint8_t Bits::myBitCount[] = { + 0, /* 0 */ 1, /* 1 */ 1, /* 2 */ 2, /* 3 */ 1, /* 4 */ + 2, /* 5 */ 2, /* 6 */ 3, /* 7 */ 1, /* 8 */ 2, /* 9 */ + 2, /* 10 */ 3, /* 11 */ 2, /* 12 */ 3, /* 13 */ 3, /* 14 */ + 4, /* 15 */ 1, /* 16 */ 2, /* 17 */ 2, /* 18 */ 3, /* 19 */ + 2, /* 20 */ 3, /* 21 */ 3, /* 22 */ 4, /* 23 */ 2, /* 24 */ + 3, /* 25 */ 3, /* 26 */ 4, /* 27 */ 3, /* 28 */ 4, /* 29 */ + 4, /* 30 */ 5, /* 31 */ 1, /* 32 */ 2, /* 33 */ 2, /* 34 */ + 3, /* 35 */ 2, /* 36 */ 3, /* 37 */ 3, /* 38 */ 4, /* 39 */ + 2, /* 40 */ 3, /* 41 */ 3, /* 42 */ 4, /* 43 */ 3, /* 44 */ + 4, /* 45 */ 4, /* 46 */ 5, /* 47 */ 2, /* 48 */ 3, /* 49 */ + 3, /* 50 */ 4, /* 51 */ 3, /* 52 */ 4, /* 53 */ 4, /* 54 */ + 5, /* 55 */ 3, /* 56 */ 4, /* 57 */ 4, /* 58 */ 5, /* 59 */ + 4, /* 60 */ 5, /* 61 */ 5, /* 62 */ 6, /* 63 */ 1, /* 64 */ + 2, /* 65 */ 2, /* 66 */ 3, /* 67 */ 2, /* 68 */ 3, /* 69 */ + 3, /* 70 */ 4, /* 71 */ 2, /* 72 */ 3, /* 73 */ 3, /* 74 */ + 4, /* 75 */ 3, /* 76 */ 4, /* 77 */ 4, /* 78 */ 5, /* 79 */ + 2, /* 80 */ 3, /* 81 */ 3, /* 82 */ 4, /* 83 */ 3, /* 84 */ + 4, /* 85 */ 4, /* 86 */ 5, /* 87 */ 3, /* 88 */ 4, /* 89 */ + 4, /* 90 */ 5, /* 91 */ 4, /* 92 */ 5, /* 93 */ 5, /* 94 */ + 6, /* 95 */ 2, /* 96 */ 3, /* 97 */ 3, /* 98 */ 4, /* 99 */ + 3, /* 100 */ 4, /* 101 */ 4, /* 102 */ 5, /* 103 */ 3, /* 104 */ + 4, /* 105 */ 4, /* 106 */ 5, /* 107 */ 4, /* 108 */ 5, /* 109 */ + 5, /* 110 */ 6, /* 111 */ 3, /* 112 */ 4, /* 113 */ 4, /* 114 */ + 5, /* 115 */ 4, /* 116 */ 5, /* 117 */ 5, /* 118 */ 6, /* 119 */ + 4, /* 120 */ 5, /* 121 */ 5, /* 122 */ 6, /* 123 */ 5, /* 124 */ + 6, /* 125 */ 6, /* 126 */ 7, /* 127 */ 1, /* 128 */ 2, /* 129 */ + 2, /* 130 */ 3, /* 131 */ 2, /* 132 */ 3, /* 133 */ 3, /* 134 */ + 4, /* 135 */ 2, /* 136 */ 3, /* 137 */ 3, /* 138 */ 4, /* 139 */ + 3, /* 140 */ 4, /* 141 */ 4, /* 142 */ 5, /* 143 */ 2, /* 144 */ + 3, /* 145 */ 3, /* 146 */ 4, /* 147 */ 3, /* 148 */ 4, /* 149 */ + 4, /* 150 */ 5, /* 151 */ 3, /* 152 */ 4, /* 153 */ 4, /* 154 */ + 5, /* 155 */ 4, /* 156 */ 5, /* 157 */ 5, /* 158 */ 6, /* 159 */ + 2, /* 160 */ 3, /* 161 */ 3, /* 162 */ 4, /* 163 */ 3, /* 164 */ + 4, /* 165 */ 4, /* 166 */ 5, /* 167 */ 3, /* 168 */ 4, /* 169 */ + 4, /* 170 */ 5, /* 171 */ 4, /* 172 */ 5, /* 173 */ 5, /* 174 */ + 6, /* 175 */ 3, /* 176 */ 4, /* 177 */ 4, /* 178 */ 5, /* 179 */ + 4, /* 180 */ 5, /* 181 */ 5, /* 182 */ 6, /* 183 */ 4, /* 184 */ + 5, /* 185 */ 5, /* 186 */ 6, /* 187 */ 5, /* 188 */ 6, /* 189 */ + 6, /* 190 */ 7, /* 191 */ 2, /* 192 */ 3, /* 193 */ 3, /* 194 */ + 4, /* 195 */ 3, /* 196 */ 4, /* 197 */ 4, /* 198 */ 5, /* 199 */ + 3, /* 200 */ 4, /* 201 */ 4, /* 202 */ 5, /* 203 */ 4, /* 204 */ + 5, /* 205 */ 5, /* 206 */ 6, /* 207 */ 3, /* 208 */ 4, /* 209 */ + 4, /* 210 */ 5, /* 211 */ 4, /* 212 */ 5, /* 213 */ 5, /* 214 */ + 6, /* 215 */ 4, /* 216 */ 5, /* 217 */ 5, /* 218 */ 6, /* 219 */ + 5, /* 220 */ 6, /* 221 */ 6, /* 222 */ 7, /* 223 */ 3, /* 224 */ + 4, /* 225 */ 4, /* 226 */ 5, /* 227 */ 4, /* 228 */ 5, /* 229 */ + 5, /* 230 */ 6, /* 231 */ 4, /* 232 */ 5, /* 233 */ 5, /* 234 */ + 6, /* 235 */ 5, /* 236 */ 6, /* 237 */ 6, /* 238 */ 7, /* 239 */ + 4, /* 240 */ 5, /* 241 */ 5, /* 242 */ 6, /* 243 */ 5, /* 244 */ + 6, /* 245 */ 6, /* 246 */ 7, /* 247 */ 5, /* 248 */ 6, /* 249 */ + 6, /* 250 */ 7, /* 251 */ 6, /* 252 */ 7, /* 253 */ 7, /* 254 */ + 8 /* 255 */ + }; // end _Bit_count + + /** + * Lookup table for finding the least significant bit. + *

+ * NB: Can also be obtained with:

+   * 
+ */ + const DGtal::uint8_t Bits::myLSB[] = { + 0, /* 0 */ 0, /* 1 */ 1, /* 2 */ 0, /* 3 */ 2, /* 4 */ + 0, /* 5 */ 1, /* 6 */ 0, /* 7 */ 3, /* 8 */ 0, /* 9 */ + 1, /* 10 */ 0, /* 11 */ 2, /* 12 */ 0, /* 13 */ 1, /* 14 */ + 0, /* 15 */ 4, /* 16 */ 0, /* 17 */ 1, /* 18 */ 0, /* 19 */ + 2, /* 20 */ 0, /* 21 */ 1, /* 22 */ 0, /* 23 */ 3, /* 24 */ + 0, /* 25 */ 1, /* 26 */ 0, /* 27 */ 2, /* 28 */ 0, /* 29 */ + 1, /* 30 */ 0, /* 31 */ 5, /* 32 */ 0, /* 33 */ 1, /* 34 */ + 0, /* 35 */ 2, /* 36 */ 0, /* 37 */ 1, /* 38 */ 0, /* 39 */ + 3, /* 40 */ 0, /* 41 */ 1, /* 42 */ 0, /* 43 */ 2, /* 44 */ + 0, /* 45 */ 1, /* 46 */ 0, /* 47 */ 4, /* 48 */ 0, /* 49 */ + 1, /* 50 */ 0, /* 51 */ 2, /* 52 */ 0, /* 53 */ 1, /* 54 */ + 0, /* 55 */ 3, /* 56 */ 0, /* 57 */ 1, /* 58 */ 0, /* 59 */ + 2, /* 60 */ 0, /* 61 */ 1, /* 62 */ 0, /* 63 */ 6, /* 64 */ + 0, /* 65 */ 1, /* 66 */ 0, /* 67 */ 2, /* 68 */ 0, /* 69 */ + 1, /* 70 */ 0, /* 71 */ 3, /* 72 */ 0, /* 73 */ 1, /* 74 */ + 0, /* 75 */ 2, /* 76 */ 0, /* 77 */ 1, /* 78 */ 0, /* 79 */ + 4, /* 80 */ 0, /* 81 */ 1, /* 82 */ 0, /* 83 */ 2, /* 84 */ + 0, /* 85 */ 1, /* 86 */ 0, /* 87 */ 3, /* 88 */ 0, /* 89 */ + 1, /* 90 */ 0, /* 91 */ 2, /* 92 */ 0, /* 93 */ 1, /* 94 */ + 0, /* 95 */ 5, /* 96 */ 0, /* 97 */ 1, /* 98 */ 0, /* 99 */ + 2, /* 100 */ 0, /* 101 */ 1, /* 102 */ 0, /* 103 */ 3, /* 104 */ + 0, /* 105 */ 1, /* 106 */ 0, /* 107 */ 2, /* 108 */ 0, /* 109 */ + 1, /* 110 */ 0, /* 111 */ 4, /* 112 */ 0, /* 113 */ 1, /* 114 */ + 0, /* 115 */ 2, /* 116 */ 0, /* 117 */ 1, /* 118 */ 0, /* 119 */ + 3, /* 120 */ 0, /* 121 */ 1, /* 122 */ 0, /* 123 */ 2, /* 124 */ + 0, /* 125 */ 1, /* 126 */ 0, /* 127 */ 7, /* 128 */ 0, /* 129 */ + 1, /* 130 */ 0, /* 131 */ 2, /* 132 */ 0, /* 133 */ 1, /* 134 */ + 0, /* 135 */ 3, /* 136 */ 0, /* 137 */ 1, /* 138 */ 0, /* 139 */ + 2, /* 140 */ 0, /* 141 */ 1, /* 142 */ 0, /* 143 */ 4, /* 144 */ + 0, /* 145 */ 1, /* 146 */ 0, /* 147 */ 2, /* 148 */ 0, /* 149 */ + 1, /* 150 */ 0, /* 151 */ 3, /* 152 */ 0, /* 153 */ 1, /* 154 */ + 0, /* 155 */ 2, /* 156 */ 0, /* 157 */ 1, /* 158 */ 0, /* 159 */ + 5, /* 160 */ 0, /* 161 */ 1, /* 162 */ 0, /* 163 */ 2, /* 164 */ + 0, /* 165 */ 1, /* 166 */ 0, /* 167 */ 3, /* 168 */ 0, /* 169 */ + 1, /* 170 */ 0, /* 171 */ 2, /* 172 */ 0, /* 173 */ 1, /* 174 */ + 0, /* 175 */ 4, /* 176 */ 0, /* 177 */ 1, /* 178 */ 0, /* 179 */ + 2, /* 180 */ 0, /* 181 */ 1, /* 182 */ 0, /* 183 */ 3, /* 184 */ + 0, /* 185 */ 1, /* 186 */ 0, /* 187 */ 2, /* 188 */ 0, /* 189 */ + 1, /* 190 */ 0, /* 191 */ 6, /* 192 */ 0, /* 193 */ 1, /* 194 */ + 0, /* 195 */ 2, /* 196 */ 0, /* 197 */ 1, /* 198 */ 0, /* 199 */ + 3, /* 200 */ 0, /* 201 */ 1, /* 202 */ 0, /* 203 */ 2, /* 204 */ + 0, /* 205 */ 1, /* 206 */ 0, /* 207 */ 4, /* 208 */ 0, /* 209 */ + 1, /* 210 */ 0, /* 211 */ 2, /* 212 */ 0, /* 213 */ 1, /* 214 */ + 0, /* 215 */ 3, /* 216 */ 0, /* 217 */ 1, /* 218 */ 0, /* 219 */ + 2, /* 220 */ 0, /* 221 */ 1, /* 222 */ 0, /* 223 */ 5, /* 224 */ + 0, /* 225 */ 1, /* 226 */ 0, /* 227 */ 2, /* 228 */ 0, /* 229 */ + 1, /* 230 */ 0, /* 231 */ 3, /* 232 */ 0, /* 233 */ 1, /* 234 */ + 0, /* 235 */ 2, /* 236 */ 0, /* 237 */ 1, /* 238 */ 0, /* 239 */ + 4, /* 240 */ 0, /* 241 */ 1, /* 242 */ 0, /* 243 */ 2, /* 244 */ + 0, /* 245 */ 1, /* 246 */ 0, /* 247 */ 3, /* 248 */ 0, /* 249 */ + 1, /* 250 */ 0, /* 251 */ 2, /* 252 */ 0, /* 253 */ 1, /* 254 */ + 0, /* 255 */ + }; // end _First_one + + +/** + * Lookup table for finding the least significant bit. + *

+ * NB: Can also be obtained with:

+   * 
+ */ + const DGtal::uint8_t Bits::myMSB[] = { +0 /* 0*/ , +0 /* 1*/ ,1 /* 2*/ ,1 /* 3*/ ,2 /* 4*/ ,2 /* 5*/ , +2 /* 6*/ ,2 /* 7*/ ,3 /* 8*/ ,3 /* 9*/ ,3 /* 10*/ , +3 /* 11*/ ,3 /* 12*/ ,3 /* 13*/ ,3 /* 14*/ ,3 /* 15*/ , +4 /* 16*/ ,4 /* 17*/ ,4 /* 18*/ ,4 /* 19*/ ,4 /* 20*/ , +4 /* 21*/ ,4 /* 22*/ ,4 /* 23*/ ,4 /* 24*/ ,4 /* 25*/ , +4 /* 26*/ ,4 /* 27*/ ,4 /* 28*/ ,4 /* 29*/ ,4 /* 30*/ , +4 /* 31*/ ,5 /* 32*/ ,5 /* 33*/ ,5 /* 34*/ ,5 /* 35*/ , +5 /* 36*/ ,5 /* 37*/ ,5 /* 38*/ ,5 /* 39*/ ,5 /* 40*/ , +5 /* 41*/ ,5 /* 42*/ ,5 /* 43*/ ,5 /* 44*/ ,5 /* 45*/ , +5 /* 46*/ ,5 /* 47*/ ,5 /* 48*/ ,5 /* 49*/ ,5 /* 50*/ , +5 /* 51*/ ,5 /* 52*/ ,5 /* 53*/ ,5 /* 54*/ ,5 /* 55*/ , +5 /* 56*/ ,5 /* 57*/ ,5 /* 58*/ ,5 /* 59*/ ,5 /* 60*/ , +5 /* 61*/ ,5 /* 62*/ ,5 /* 63*/ ,6 /* 64*/ ,6 /* 65*/ , +6 /* 66*/ ,6 /* 67*/ ,6 /* 68*/ ,6 /* 69*/ ,6 /* 70*/ , +6 /* 71*/ ,6 /* 72*/ ,6 /* 73*/ ,6 /* 74*/ ,6 /* 75*/ , +6 /* 76*/ ,6 /* 77*/ ,6 /* 78*/ ,6 /* 79*/ ,6 /* 80*/ , +6 /* 81*/ ,6 /* 82*/ ,6 /* 83*/ ,6 /* 84*/ ,6 /* 85*/ , +6 /* 86*/ ,6 /* 87*/ ,6 /* 88*/ ,6 /* 89*/ ,6 /* 90*/ , +6 /* 91*/ ,6 /* 92*/ ,6 /* 93*/ ,6 /* 94*/ ,6 /* 95*/ , +6 /* 96*/ ,6 /* 97*/ ,6 /* 98*/ ,6 /* 99*/ ,6 /* 100*/ , +6 /* 101*/ ,6 /* 102*/ ,6 /* 103*/ ,6 /* 104*/ ,6 /* 105*/ , +6 /* 106*/ ,6 /* 107*/ ,6 /* 108*/ ,6 /* 109*/ ,6 /* 110*/ , +6 /* 111*/ ,6 /* 112*/ ,6 /* 113*/ ,6 /* 114*/ ,6 /* 115*/ , +6 /* 116*/ ,6 /* 117*/ ,6 /* 118*/ ,6 /* 119*/ ,6 /* 120*/ , +6 /* 121*/ ,6 /* 122*/ ,6 /* 123*/ ,6 /* 124*/ ,6 /* 125*/ , +6 /* 126*/ ,6 /* 127*/ ,7 /* 128*/ ,7 /* 129*/ ,7 /* 130*/ , +7 /* 131*/ ,7 /* 132*/ ,7 /* 133*/ ,7 /* 134*/ ,7 /* 135*/ , +7 /* 136*/ ,7 /* 137*/ ,7 /* 138*/ ,7 /* 139*/ ,7 /* 140*/ , +7 /* 141*/ ,7 /* 142*/ ,7 /* 143*/ ,7 /* 144*/ ,7 /* 145*/ , +7 /* 146*/ ,7 /* 147*/ ,7 /* 148*/ ,7 /* 149*/ ,7 /* 150*/ , +7 /* 151*/ ,7 /* 152*/ ,7 /* 153*/ ,7 /* 154*/ ,7 /* 155*/ , +7 /* 156*/ ,7 /* 157*/ ,7 /* 158*/ ,7 /* 159*/ ,7 /* 160*/ , +7 /* 161*/ ,7 /* 162*/ ,7 /* 163*/ ,7 /* 164*/ ,7 /* 165*/ , +7 /* 166*/ ,7 /* 167*/ ,7 /* 168*/ ,7 /* 169*/ ,7 /* 170*/ , +7 /* 171*/ ,7 /* 172*/ ,7 /* 173*/ ,7 /* 174*/ ,7 /* 175*/ , +7 /* 176*/ ,7 /* 177*/ ,7 /* 178*/ ,7 /* 179*/ ,7 /* 180*/ , +7 /* 181*/ ,7 /* 182*/ ,7 /* 183*/ ,7 /* 184*/ ,7 /* 185*/ , +7 /* 186*/ ,7 /* 187*/ ,7 /* 188*/ ,7 /* 189*/ ,7 /* 190*/ , +7 /* 191*/ ,7 /* 192*/ ,7 /* 193*/ ,7 /* 194*/ ,7 /* 195*/ , +7 /* 196*/ ,7 /* 197*/ ,7 /* 198*/ ,7 /* 199*/ ,7 /* 200*/ , +7 /* 201*/ ,7 /* 202*/ ,7 /* 203*/ ,7 /* 204*/ ,7 /* 205*/ , +7 /* 206*/ ,7 /* 207*/ ,7 /* 208*/ ,7 /* 209*/ ,7 /* 210*/ , +7 /* 211*/ ,7 /* 212*/ ,7 /* 213*/ ,7 /* 214*/ ,7 /* 215*/ , +7 /* 216*/ ,7 /* 217*/ ,7 /* 218*/ ,7 /* 219*/ ,7 /* 220*/ , +7 /* 221*/ ,7 /* 222*/ ,7 /* 223*/ ,7 /* 224*/ ,7 /* 225*/ , +7 /* 226*/ ,7 /* 227*/ ,7 /* 228*/ ,7 /* 229*/ ,7 /* 230*/ , +7 /* 231*/ ,7 /* 232*/ ,7 /* 233*/ ,7 /* 234*/ ,7 /* 235*/ , +7 /* 236*/ ,7 /* 237*/ ,7 /* 238*/ ,7 /* 239*/ ,7 /* 240*/ , +7 /* 241*/ ,7 /* 242*/ ,7 /* 243*/ ,7 /* 244*/ ,7 /* 245*/ , +7 /* 246*/ ,7 /* 247*/ ,7 /* 248*/ ,7 /* 249*/ ,7 /* 250*/ , +7 /* 251*/ ,7 /* 252*/ ,7 /* 253*/ ,7 /* 254*/ ,7 /* 255*/ }; // end _First_one + + /** + Usage: myIndexInSetBits[ b ][ n ] + - \a b in 0..7 + - \a n in 0..255 + Set bits are numbered from 1 to x when reading the word from the + least significant to the most significant bit. This number is the + index of bit \a b in the number \a n. + return this index or 0 if the bit is not set. + */ + const DGtal::uint8_t Bits::myIndexInSetBits[ 8 ][ 256 ] = { + // Table for bit 0. + { 0 /*0*/, 1 /*1*/, 0 /*2*/, 1 /*3*/, 0 /*4*/, 1 /*5*/, 0 /*6*/, 1 /*7*/, + 0 /*8*/, 1 /*9*/, 0 /*10*/, 1 /*11*/, 0 /*12*/, 1 /*13*/, 0 /*14*/, 1 /*15*/, + 0 /*16*/, 1 /*17*/, 0 /*18*/, 1 /*19*/, 0 /*20*/, 1 /*21*/, 0 /*22*/, 1 /*23*/, + 0 /*24*/, 1 /*25*/, 0 /*26*/, 1 /*27*/, 0 /*28*/, 1 /*29*/, 0 /*30*/, 1 /*31*/, + 0 /*32*/, 1 /*33*/, 0 /*34*/, 1 /*35*/, 0 /*36*/, 1 /*37*/, 0 /*38*/, 1 /*39*/, + 0 /*40*/, 1 /*41*/, 0 /*42*/, 1 /*43*/, 0 /*44*/, 1 /*45*/, 0 /*46*/, 1 /*47*/, + 0 /*48*/, 1 /*49*/, 0 /*50*/, 1 /*51*/, 0 /*52*/, 1 /*53*/, 0 /*54*/, 1 /*55*/, + 0 /*56*/, 1 /*57*/, 0 /*58*/, 1 /*59*/, 0 /*60*/, 1 /*61*/, 0 /*62*/, 1 /*63*/, + 0 /*64*/, 1 /*65*/, 0 /*66*/, 1 /*67*/, 0 /*68*/, 1 /*69*/, 0 /*70*/, 1 /*71*/, + 0 /*72*/, 1 /*73*/, 0 /*74*/, 1 /*75*/, 0 /*76*/, 1 /*77*/, 0 /*78*/, 1 /*79*/, + 0 /*80*/, 1 /*81*/, 0 /*82*/, 1 /*83*/, 0 /*84*/, 1 /*85*/, 0 /*86*/, 1 /*87*/, + 0 /*88*/, 1 /*89*/, 0 /*90*/, 1 /*91*/, 0 /*92*/, 1 /*93*/, 0 /*94*/, 1 /*95*/, + 0 /*96*/, 1 /*97*/, 0 /*98*/, 1 /*99*/, 0 /*100*/, 1 /*101*/, 0 /*102*/, 1 /*103*/, + 0 /*104*/, 1 /*105*/, 0 /*106*/, 1 /*107*/, 0 /*108*/, 1 /*109*/, 0 /*110*/, 1 /*111*/, + 0 /*112*/, 1 /*113*/, 0 /*114*/, 1 /*115*/, 0 /*116*/, 1 /*117*/, 0 /*118*/, 1 /*119*/, + 0 /*120*/, 1 /*121*/, 0 /*122*/, 1 /*123*/, 0 /*124*/, 1 /*125*/, 0 /*126*/, 1 /*127*/, + 0 /*128*/, 1 /*129*/, 0 /*130*/, 1 /*131*/, 0 /*132*/, 1 /*133*/, 0 /*134*/, 1 /*135*/, + 0 /*136*/, 1 /*137*/, 0 /*138*/, 1 /*139*/, 0 /*140*/, 1 /*141*/, 0 /*142*/, 1 /*143*/, + 0 /*144*/, 1 /*145*/, 0 /*146*/, 1 /*147*/, 0 /*148*/, 1 /*149*/, 0 /*150*/, 1 /*151*/, + 0 /*152*/, 1 /*153*/, 0 /*154*/, 1 /*155*/, 0 /*156*/, 1 /*157*/, 0 /*158*/, 1 /*159*/, + 0 /*160*/, 1 /*161*/, 0 /*162*/, 1 /*163*/, 0 /*164*/, 1 /*165*/, 0 /*166*/, 1 /*167*/, + 0 /*168*/, 1 /*169*/, 0 /*170*/, 1 /*171*/, 0 /*172*/, 1 /*173*/, 0 /*174*/, 1 /*175*/, + 0 /*176*/, 1 /*177*/, 0 /*178*/, 1 /*179*/, 0 /*180*/, 1 /*181*/, 0 /*182*/, 1 /*183*/, + 0 /*184*/, 1 /*185*/, 0 /*186*/, 1 /*187*/, 0 /*188*/, 1 /*189*/, 0 /*190*/, 1 /*191*/, + 0 /*192*/, 1 /*193*/, 0 /*194*/, 1 /*195*/, 0 /*196*/, 1 /*197*/, 0 /*198*/, 1 /*199*/, + 0 /*200*/, 1 /*201*/, 0 /*202*/, 1 /*203*/, 0 /*204*/, 1 /*205*/, 0 /*206*/, 1 /*207*/, + 0 /*208*/, 1 /*209*/, 0 /*210*/, 1 /*211*/, 0 /*212*/, 1 /*213*/, 0 /*214*/, 1 /*215*/, + 0 /*216*/, 1 /*217*/, 0 /*218*/, 1 /*219*/, 0 /*220*/, 1 /*221*/, 0 /*222*/, 1 /*223*/, + 0 /*224*/, 1 /*225*/, 0 /*226*/, 1 /*227*/, 0 /*228*/, 1 /*229*/, 0 /*230*/, 1 /*231*/, + 0 /*232*/, 1 /*233*/, 0 /*234*/, 1 /*235*/, 0 /*236*/, 1 /*237*/, 0 /*238*/, 1 /*239*/, + 0 /*240*/, 1 /*241*/, 0 /*242*/, 1 /*243*/, 0 /*244*/, 1 /*245*/, 0 /*246*/, 1 /*247*/, + 0 /*248*/, 1 /*249*/, 0 /*250*/, 1 /*251*/, 0 /*252*/, 1 /*253*/, 0 /*254*/, 1 /*255*/ }, + // Table for bit 1. + { 0 /*0*/, 0 /*1*/, 1 /*2*/, 2 /*3*/, 0 /*4*/, 0 /*5*/, 1 /*6*/, 2 /*7*/, + 0 /*8*/, 0 /*9*/, 1 /*10*/, 2 /*11*/, 0 /*12*/, 0 /*13*/, 1 /*14*/, 2 /*15*/, + 0 /*16*/, 0 /*17*/, 1 /*18*/, 2 /*19*/, 0 /*20*/, 0 /*21*/, 1 /*22*/, 2 /*23*/, + 0 /*24*/, 0 /*25*/, 1 /*26*/, 2 /*27*/, 0 /*28*/, 0 /*29*/, 1 /*30*/, 2 /*31*/, + 0 /*32*/, 0 /*33*/, 1 /*34*/, 2 /*35*/, 0 /*36*/, 0 /*37*/, 1 /*38*/, 2 /*39*/, + 0 /*40*/, 0 /*41*/, 1 /*42*/, 2 /*43*/, 0 /*44*/, 0 /*45*/, 1 /*46*/, 2 /*47*/, + 0 /*48*/, 0 /*49*/, 1 /*50*/, 2 /*51*/, 0 /*52*/, 0 /*53*/, 1 /*54*/, 2 /*55*/, + 0 /*56*/, 0 /*57*/, 1 /*58*/, 2 /*59*/, 0 /*60*/, 0 /*61*/, 1 /*62*/, 2 /*63*/, + 0 /*64*/, 0 /*65*/, 1 /*66*/, 2 /*67*/, 0 /*68*/, 0 /*69*/, 1 /*70*/, 2 /*71*/, + 0 /*72*/, 0 /*73*/, 1 /*74*/, 2 /*75*/, 0 /*76*/, 0 /*77*/, 1 /*78*/, 2 /*79*/, + 0 /*80*/, 0 /*81*/, 1 /*82*/, 2 /*83*/, 0 /*84*/, 0 /*85*/, 1 /*86*/, 2 /*87*/, + 0 /*88*/, 0 /*89*/, 1 /*90*/, 2 /*91*/, 0 /*92*/, 0 /*93*/, 1 /*94*/, 2 /*95*/, + 0 /*96*/, 0 /*97*/, 1 /*98*/, 2 /*99*/, 0 /*100*/, 0 /*101*/, 1 /*102*/, 2 /*103*/, + 0 /*104*/, 0 /*105*/, 1 /*106*/, 2 /*107*/, 0 /*108*/, 0 /*109*/, 1 /*110*/, 2 /*111*/, + 0 /*112*/, 0 /*113*/, 1 /*114*/, 2 /*115*/, 0 /*116*/, 0 /*117*/, 1 /*118*/, 2 /*119*/, + 0 /*120*/, 0 /*121*/, 1 /*122*/, 2 /*123*/, 0 /*124*/, 0 /*125*/, 1 /*126*/, 2 /*127*/, + 0 /*128*/, 0 /*129*/, 1 /*130*/, 2 /*131*/, 0 /*132*/, 0 /*133*/, 1 /*134*/, 2 /*135*/, + 0 /*136*/, 0 /*137*/, 1 /*138*/, 2 /*139*/, 0 /*140*/, 0 /*141*/, 1 /*142*/, 2 /*143*/, + 0 /*144*/, 0 /*145*/, 1 /*146*/, 2 /*147*/, 0 /*148*/, 0 /*149*/, 1 /*150*/, 2 /*151*/, + 0 /*152*/, 0 /*153*/, 1 /*154*/, 2 /*155*/, 0 /*156*/, 0 /*157*/, 1 /*158*/, 2 /*159*/, + 0 /*160*/, 0 /*161*/, 1 /*162*/, 2 /*163*/, 0 /*164*/, 0 /*165*/, 1 /*166*/, 2 /*167*/, + 0 /*168*/, 0 /*169*/, 1 /*170*/, 2 /*171*/, 0 /*172*/, 0 /*173*/, 1 /*174*/, 2 /*175*/, + 0 /*176*/, 0 /*177*/, 1 /*178*/, 2 /*179*/, 0 /*180*/, 0 /*181*/, 1 /*182*/, 2 /*183*/, + 0 /*184*/, 0 /*185*/, 1 /*186*/, 2 /*187*/, 0 /*188*/, 0 /*189*/, 1 /*190*/, 2 /*191*/, + 0 /*192*/, 0 /*193*/, 1 /*194*/, 2 /*195*/, 0 /*196*/, 0 /*197*/, 1 /*198*/, 2 /*199*/, + 0 /*200*/, 0 /*201*/, 1 /*202*/, 2 /*203*/, 0 /*204*/, 0 /*205*/, 1 /*206*/, 2 /*207*/, + 0 /*208*/, 0 /*209*/, 1 /*210*/, 2 /*211*/, 0 /*212*/, 0 /*213*/, 1 /*214*/, 2 /*215*/, + 0 /*216*/, 0 /*217*/, 1 /*218*/, 2 /*219*/, 0 /*220*/, 0 /*221*/, 1 /*222*/, 2 /*223*/, + 0 /*224*/, 0 /*225*/, 1 /*226*/, 2 /*227*/, 0 /*228*/, 0 /*229*/, 1 /*230*/, 2 /*231*/, + 0 /*232*/, 0 /*233*/, 1 /*234*/, 2 /*235*/, 0 /*236*/, 0 /*237*/, 1 /*238*/, 2 /*239*/, + 0 /*240*/, 0 /*241*/, 1 /*242*/, 2 /*243*/, 0 /*244*/, 0 /*245*/, 1 /*246*/, 2 /*247*/, + 0 /*248*/, 0 /*249*/, 1 /*250*/, 2 /*251*/, 0 /*252*/, 0 /*253*/, 1 /*254*/, 2 /*255*/}, + // Table for bit 2. + { 0 /*0*/, 0 /*1*/, 0 /*2*/, 0 /*3*/, 1 /*4*/, 2 /*5*/, 2 /*6*/, 3 /*7*/, + 0 /*8*/, 0 /*9*/, 0 /*10*/, 0 /*11*/, 1 /*12*/, 2 /*13*/, 2 /*14*/, 3 /*15*/, + 0 /*16*/, 0 /*17*/, 0 /*18*/, 0 /*19*/, 1 /*20*/, 2 /*21*/, 2 /*22*/, 3 /*23*/, + 0 /*24*/, 0 /*25*/, 0 /*26*/, 0 /*27*/, 1 /*28*/, 2 /*29*/, 2 /*30*/, 3 /*31*/, + 0 /*32*/, 0 /*33*/, 0 /*34*/, 0 /*35*/, 1 /*36*/, 2 /*37*/, 2 /*38*/, 3 /*39*/, + 0 /*40*/, 0 /*41*/, 0 /*42*/, 0 /*43*/, 1 /*44*/, 2 /*45*/, 2 /*46*/, 3 /*47*/, + 0 /*48*/, 0 /*49*/, 0 /*50*/, 0 /*51*/, 1 /*52*/, 2 /*53*/, 2 /*54*/, 3 /*55*/, + 0 /*56*/, 0 /*57*/, 0 /*58*/, 0 /*59*/, 1 /*60*/, 2 /*61*/, 2 /*62*/, 3 /*63*/, + 0 /*64*/, 0 /*65*/, 0 /*66*/, 0 /*67*/, 1 /*68*/, 2 /*69*/, 2 /*70*/, 3 /*71*/, + 0 /*72*/, 0 /*73*/, 0 /*74*/, 0 /*75*/, 1 /*76*/, 2 /*77*/, 2 /*78*/, 3 /*79*/, + 0 /*80*/, 0 /*81*/, 0 /*82*/, 0 /*83*/, 1 /*84*/, 2 /*85*/, 2 /*86*/, 3 /*87*/, + 0 /*88*/, 0 /*89*/, 0 /*90*/, 0 /*91*/, 1 /*92*/, 2 /*93*/, 2 /*94*/, 3 /*95*/, + 0 /*96*/, 0 /*97*/, 0 /*98*/, 0 /*99*/, 1 /*100*/, 2 /*101*/, 2 /*102*/, 3 /*103*/, + 0 /*104*/, 0 /*105*/, 0 /*106*/, 0 /*107*/, 1 /*108*/, 2 /*109*/, 2 /*110*/, 3 /*111*/, + 0 /*112*/, 0 /*113*/, 0 /*114*/, 0 /*115*/, 1 /*116*/, 2 /*117*/, 2 /*118*/, 3 /*119*/, + 0 /*120*/, 0 /*121*/, 0 /*122*/, 0 /*123*/, 1 /*124*/, 2 /*125*/, 2 /*126*/, 3 /*127*/, + 0 /*128*/, 0 /*129*/, 0 /*130*/, 0 /*131*/, 1 /*132*/, 2 /*133*/, 2 /*134*/, 3 /*135*/, + 0 /*136*/, 0 /*137*/, 0 /*138*/, 0 /*139*/, 1 /*140*/, 2 /*141*/, 2 /*142*/, 3 /*143*/, + 0 /*144*/, 0 /*145*/, 0 /*146*/, 0 /*147*/, 1 /*148*/, 2 /*149*/, 2 /*150*/, 3 /*151*/, + 0 /*152*/, 0 /*153*/, 0 /*154*/, 0 /*155*/, 1 /*156*/, 2 /*157*/, 2 /*158*/, 3 /*159*/, + 0 /*160*/, 0 /*161*/, 0 /*162*/, 0 /*163*/, 1 /*164*/, 2 /*165*/, 2 /*166*/, 3 /*167*/, + 0 /*168*/, 0 /*169*/, 0 /*170*/, 0 /*171*/, 1 /*172*/, 2 /*173*/, 2 /*174*/, 3 /*175*/, + 0 /*176*/, 0 /*177*/, 0 /*178*/, 0 /*179*/, 1 /*180*/, 2 /*181*/, 2 /*182*/, 3 /*183*/, + 0 /*184*/, 0 /*185*/, 0 /*186*/, 0 /*187*/, 1 /*188*/, 2 /*189*/, 2 /*190*/, 3 /*191*/, + 0 /*192*/, 0 /*193*/, 0 /*194*/, 0 /*195*/, 1 /*196*/, 2 /*197*/, 2 /*198*/, 3 /*199*/, + 0 /*200*/, 0 /*201*/, 0 /*202*/, 0 /*203*/, 1 /*204*/, 2 /*205*/, 2 /*206*/, 3 /*207*/, + 0 /*208*/, 0 /*209*/, 0 /*210*/, 0 /*211*/, 1 /*212*/, 2 /*213*/, 2 /*214*/, 3 /*215*/, + 0 /*216*/, 0 /*217*/, 0 /*218*/, 0 /*219*/, 1 /*220*/, 2 /*221*/, 2 /*222*/, 3 /*223*/, + 0 /*224*/, 0 /*225*/, 0 /*226*/, 0 /*227*/, 1 /*228*/, 2 /*229*/, 2 /*230*/, 3 /*231*/, + 0 /*232*/, 0 /*233*/, 0 /*234*/, 0 /*235*/, 1 /*236*/, 2 /*237*/, 2 /*238*/, 3 /*239*/, + 0 /*240*/, 0 /*241*/, 0 /*242*/, 0 /*243*/, 1 /*244*/, 2 /*245*/, 2 /*246*/, 3 /*247*/, + 0 /*248*/, 0 /*249*/, 0 /*250*/, 0 /*251*/, 1 /*252*/, 2 /*253*/, 2 /*254*/, 3 /*255*/}, + // Table for bit 3. + { 0 /*0*/, 0 /*1*/, 0 /*2*/, 0 /*3*/, 0 /*4*/, 0 /*5*/, 0 /*6*/, 0 /*7*/, + 1 /*8*/, 2 /*9*/, 2 /*10*/, 3 /*11*/, 2 /*12*/, 3 /*13*/, 3 /*14*/, 4 /*15*/, + 0 /*16*/, 0 /*17*/, 0 /*18*/, 0 /*19*/, 0 /*20*/, 0 /*21*/, 0 /*22*/, 0 /*23*/, + 1 /*24*/, 2 /*25*/, 2 /*26*/, 3 /*27*/, 2 /*28*/, 3 /*29*/, 3 /*30*/, 4 /*31*/, + 0 /*32*/, 0 /*33*/, 0 /*34*/, 0 /*35*/, 0 /*36*/, 0 /*37*/, 0 /*38*/, 0 /*39*/, + 1 /*40*/, 2 /*41*/, 2 /*42*/, 3 /*43*/, 2 /*44*/, 3 /*45*/, 3 /*46*/, 4 /*47*/, + 0 /*48*/, 0 /*49*/, 0 /*50*/, 0 /*51*/, 0 /*52*/, 0 /*53*/, 0 /*54*/, 0 /*55*/, + 1 /*56*/, 2 /*57*/, 2 /*58*/, 3 /*59*/, 2 /*60*/, 3 /*61*/, 3 /*62*/, 4 /*63*/, + 0 /*64*/, 0 /*65*/, 0 /*66*/, 0 /*67*/, 0 /*68*/, 0 /*69*/, 0 /*70*/, 0 /*71*/, + 1 /*72*/, 2 /*73*/, 2 /*74*/, 3 /*75*/, 2 /*76*/, 3 /*77*/, 3 /*78*/, 4 /*79*/, + 0 /*80*/, 0 /*81*/, 0 /*82*/, 0 /*83*/, 0 /*84*/, 0 /*85*/, 0 /*86*/, 0 /*87*/, + 1 /*88*/, 2 /*89*/, 2 /*90*/, 3 /*91*/, 2 /*92*/, 3 /*93*/, 3 /*94*/, 4 /*95*/, + 0 /*96*/, 0 /*97*/, 0 /*98*/, 0 /*99*/, 0 /*100*/, 0 /*101*/, 0 /*102*/, 0 /*103*/, + 1 /*104*/, 2 /*105*/, 2 /*106*/, 3 /*107*/, 2 /*108*/, 3 /*109*/, 3 /*110*/, 4 /*111*/, + 0 /*112*/, 0 /*113*/, 0 /*114*/, 0 /*115*/, 0 /*116*/, 0 /*117*/, 0 /*118*/, 0 /*119*/, + 1 /*120*/, 2 /*121*/, 2 /*122*/, 3 /*123*/, 2 /*124*/, 3 /*125*/, 3 /*126*/, 4 /*127*/, + 0 /*128*/, 0 /*129*/, 0 /*130*/, 0 /*131*/, 0 /*132*/, 0 /*133*/, 0 /*134*/, 0 /*135*/, + 1 /*136*/, 2 /*137*/, 2 /*138*/, 3 /*139*/, 2 /*140*/, 3 /*141*/, 3 /*142*/, 4 /*143*/, + 0 /*144*/, 0 /*145*/, 0 /*146*/, 0 /*147*/, 0 /*148*/, 0 /*149*/, 0 /*150*/, 0 /*151*/, + 1 /*152*/, 2 /*153*/, 2 /*154*/, 3 /*155*/, 2 /*156*/, 3 /*157*/, 3 /*158*/, 4 /*159*/, + 0 /*160*/, 0 /*161*/, 0 /*162*/, 0 /*163*/, 0 /*164*/, 0 /*165*/, 0 /*166*/, 0 /*167*/, + 1 /*168*/, 2 /*169*/, 2 /*170*/, 3 /*171*/, 2 /*172*/, 3 /*173*/, 3 /*174*/, 4 /*175*/, + 0 /*176*/, 0 /*177*/, 0 /*178*/, 0 /*179*/, 0 /*180*/, 0 /*181*/, 0 /*182*/, 0 /*183*/, + 1 /*184*/, 2 /*185*/, 2 /*186*/, 3 /*187*/, 2 /*188*/, 3 /*189*/, 3 /*190*/, 4 /*191*/, + 0 /*192*/, 0 /*193*/, 0 /*194*/, 0 /*195*/, 0 /*196*/, 0 /*197*/, 0 /*198*/, 0 /*199*/, + 1 /*200*/, 2 /*201*/, 2 /*202*/, 3 /*203*/, 2 /*204*/, 3 /*205*/, 3 /*206*/, 4 /*207*/, + 0 /*208*/, 0 /*209*/, 0 /*210*/, 0 /*211*/, 0 /*212*/, 0 /*213*/, 0 /*214*/, 0 /*215*/, + 1 /*216*/, 2 /*217*/, 2 /*218*/, 3 /*219*/, 2 /*220*/, 3 /*221*/, 3 /*222*/, 4 /*223*/, + 0 /*224*/, 0 /*225*/, 0 /*226*/, 0 /*227*/, 0 /*228*/, 0 /*229*/, 0 /*230*/, 0 /*231*/, + 1 /*232*/, 2 /*233*/, 2 /*234*/, 3 /*235*/, 2 /*236*/, 3 /*237*/, 3 /*238*/, 4 /*239*/, + 0 /*240*/, 0 /*241*/, 0 /*242*/, 0 /*243*/, 0 /*244*/, 0 /*245*/, 0 /*246*/, 0 /*247*/, + 1 /*248*/, 2 /*249*/, 2 /*250*/, 3 /*251*/, 2 /*252*/, 3 /*253*/, 3 /*254*/, 4 /*255*/}, + // Table for bit 4. + { 0 /*0*/, 0 /*1*/, 0 /*2*/, 0 /*3*/, 0 /*4*/, 0 /*5*/, 0 /*6*/, 0 /*7*/, + 0 /*8*/, 0 /*9*/, 0 /*10*/, 0 /*11*/, 0 /*12*/, 0 /*13*/, 0 /*14*/, 0 /*15*/, + 1 /*16*/, 2 /*17*/, 2 /*18*/, 3 /*19*/, 2 /*20*/, 3 /*21*/, 3 /*22*/, 4 /*23*/, + 2 /*24*/, 3 /*25*/, 3 /*26*/, 4 /*27*/, 3 /*28*/, 4 /*29*/, 4 /*30*/, 5 /*31*/, + 0 /*32*/, 0 /*33*/, 0 /*34*/, 0 /*35*/, 0 /*36*/, 0 /*37*/, 0 /*38*/, 0 /*39*/, + 0 /*40*/, 0 /*41*/, 0 /*42*/, 0 /*43*/, 0 /*44*/, 0 /*45*/, 0 /*46*/, 0 /*47*/, + 1 /*48*/, 2 /*49*/, 2 /*50*/, 3 /*51*/, 2 /*52*/, 3 /*53*/, 3 /*54*/, 4 /*55*/, + 2 /*56*/, 3 /*57*/, 3 /*58*/, 4 /*59*/, 3 /*60*/, 4 /*61*/, 4 /*62*/, 5 /*63*/, + 0 /*64*/, 0 /*65*/, 0 /*66*/, 0 /*67*/, 0 /*68*/, 0 /*69*/, 0 /*70*/, 0 /*71*/, + 0 /*72*/, 0 /*73*/, 0 /*74*/, 0 /*75*/, 0 /*76*/, 0 /*77*/, 0 /*78*/, 0 /*79*/, + 1 /*80*/, 2 /*81*/, 2 /*82*/, 3 /*83*/, 2 /*84*/, 3 /*85*/, 3 /*86*/, 4 /*87*/, + 2 /*88*/, 3 /*89*/, 3 /*90*/, 4 /*91*/, 3 /*92*/, 4 /*93*/, 4 /*94*/, 5 /*95*/, + 0 /*96*/, 0 /*97*/, 0 /*98*/, 0 /*99*/, 0 /*100*/, 0 /*101*/, 0 /*102*/, 0 /*103*/, + 0 /*104*/, 0 /*105*/, 0 /*106*/, 0 /*107*/, 0 /*108*/, 0 /*109*/, 0 /*110*/, 0 /*111*/, + 1 /*112*/, 2 /*113*/, 2 /*114*/, 3 /*115*/, 2 /*116*/, 3 /*117*/, 3 /*118*/, 4 /*119*/, + 2 /*120*/, 3 /*121*/, 3 /*122*/, 4 /*123*/, 3 /*124*/, 4 /*125*/, 4 /*126*/, 5 /*127*/, + 0 /*128*/, 0 /*129*/, 0 /*130*/, 0 /*131*/, 0 /*132*/, 0 /*133*/, 0 /*134*/, 0 /*135*/, + 0 /*136*/, 0 /*137*/, 0 /*138*/, 0 /*139*/, 0 /*140*/, 0 /*141*/, 0 /*142*/, 0 /*143*/, + 1 /*144*/, 2 /*145*/, 2 /*146*/, 3 /*147*/, 2 /*148*/, 3 /*149*/, 3 /*150*/, 4 /*151*/, + 2 /*152*/, 3 /*153*/, 3 /*154*/, 4 /*155*/, 3 /*156*/, 4 /*157*/, 4 /*158*/, 5 /*159*/, + 0 /*160*/, 0 /*161*/, 0 /*162*/, 0 /*163*/, 0 /*164*/, 0 /*165*/, 0 /*166*/, 0 /*167*/, + 0 /*168*/, 0 /*169*/, 0 /*170*/, 0 /*171*/, 0 /*172*/, 0 /*173*/, 0 /*174*/, 0 /*175*/, + 1 /*176*/, 2 /*177*/, 2 /*178*/, 3 /*179*/, 2 /*180*/, 3 /*181*/, 3 /*182*/, 4 /*183*/, + 2 /*184*/, 3 /*185*/, 3 /*186*/, 4 /*187*/, 3 /*188*/, 4 /*189*/, 4 /*190*/, 5 /*191*/, + 0 /*192*/, 0 /*193*/, 0 /*194*/, 0 /*195*/, 0 /*196*/, 0 /*197*/, 0 /*198*/, 0 /*199*/, + 0 /*200*/, 0 /*201*/, 0 /*202*/, 0 /*203*/, 0 /*204*/, 0 /*205*/, 0 /*206*/, 0 /*207*/, + 1 /*208*/, 2 /*209*/, 2 /*210*/, 3 /*211*/, 2 /*212*/, 3 /*213*/, 3 /*214*/, 4 /*215*/, + 2 /*216*/, 3 /*217*/, 3 /*218*/, 4 /*219*/, 3 /*220*/, 4 /*221*/, 4 /*222*/, 5 /*223*/, + 0 /*224*/, 0 /*225*/, 0 /*226*/, 0 /*227*/, 0 /*228*/, 0 /*229*/, 0 /*230*/, 0 /*231*/, + 0 /*232*/, 0 /*233*/, 0 /*234*/, 0 /*235*/, 0 /*236*/, 0 /*237*/, 0 /*238*/, 0 /*239*/, + 1 /*240*/, 2 /*241*/, 2 /*242*/, 3 /*243*/, 2 /*244*/, 3 /*245*/, 3 /*246*/, 4 /*247*/, + 2 /*248*/, 3 /*249*/, 3 /*250*/, 4 /*251*/, 3 /*252*/, 4 /*253*/, 4 /*254*/, 5 /*255*/ }, + // Table for bit 5. + { 0 /*0*/, 0 /*1*/, 0 /*2*/, 0 /*3*/, 0 /*4*/, 0 /*5*/, 0 /*6*/, 0 /*7*/, + 0 /*8*/, 0 /*9*/, 0 /*10*/, 0 /*11*/, 0 /*12*/, 0 /*13*/, 0 /*14*/, 0 /*15*/, + 0 /*16*/, 0 /*17*/, 0 /*18*/, 0 /*19*/, 0 /*20*/, 0 /*21*/, 0 /*22*/, 0 /*23*/, + 0 /*24*/, 0 /*25*/, 0 /*26*/, 0 /*27*/, 0 /*28*/, 0 /*29*/, 0 /*30*/, 0 /*31*/, + 1 /*32*/, 2 /*33*/, 2 /*34*/, 3 /*35*/, 2 /*36*/, 3 /*37*/, 3 /*38*/, 4 /*39*/, + 2 /*40*/, 3 /*41*/, 3 /*42*/, 4 /*43*/, 3 /*44*/, 4 /*45*/, 4 /*46*/, 5 /*47*/, + 2 /*48*/, 3 /*49*/, 3 /*50*/, 4 /*51*/, 3 /*52*/, 4 /*53*/, 4 /*54*/, 5 /*55*/, + 3 /*56*/, 4 /*57*/, 4 /*58*/, 5 /*59*/, 4 /*60*/, 5 /*61*/, 5 /*62*/, 6 /*63*/, + 0 /*64*/, 0 /*65*/, 0 /*66*/, 0 /*67*/, 0 /*68*/, 0 /*69*/, 0 /*70*/, 0 /*71*/, + 0 /*72*/, 0 /*73*/, 0 /*74*/, 0 /*75*/, 0 /*76*/, 0 /*77*/, 0 /*78*/, 0 /*79*/, + 0 /*80*/, 0 /*81*/, 0 /*82*/, 0 /*83*/, 0 /*84*/, 0 /*85*/, 0 /*86*/, 0 /*87*/, + 0 /*88*/, 0 /*89*/, 0 /*90*/, 0 /*91*/, 0 /*92*/, 0 /*93*/, 0 /*94*/, 0 /*95*/, + 1 /*96*/, 2 /*97*/, 2 /*98*/, 3 /*99*/, 2 /*100*/, 3 /*101*/, 3 /*102*/, 4 /*103*/, + 2 /*104*/, 3 /*105*/, 3 /*106*/, 4 /*107*/, 3 /*108*/, 4 /*109*/, 4 /*110*/, 5 /*111*/, + 2 /*112*/, 3 /*113*/, 3 /*114*/, 4 /*115*/, 3 /*116*/, 4 /*117*/, 4 /*118*/, 5 /*119*/, + 3 /*120*/, 4 /*121*/, 4 /*122*/, 5 /*123*/, 4 /*124*/, 5 /*125*/, 5 /*126*/, 6 /*127*/, + 0 /*128*/, 0 /*129*/, 0 /*130*/, 0 /*131*/, 0 /*132*/, 0 /*133*/, 0 /*134*/, 0 /*135*/, + 0 /*136*/, 0 /*137*/, 0 /*138*/, 0 /*139*/, 0 /*140*/, 0 /*141*/, 0 /*142*/, 0 /*143*/, + 0 /*144*/, 0 /*145*/, 0 /*146*/, 0 /*147*/, 0 /*148*/, 0 /*149*/, 0 /*150*/, 0 /*151*/, + 0 /*152*/, 0 /*153*/, 0 /*154*/, 0 /*155*/, 0 /*156*/, 0 /*157*/, 0 /*158*/, 0 /*159*/, + 1 /*160*/, 2 /*161*/, 2 /*162*/, 3 /*163*/, 2 /*164*/, 3 /*165*/, 3 /*166*/, 4 /*167*/, + 2 /*168*/, 3 /*169*/, 3 /*170*/, 4 /*171*/, 3 /*172*/, 4 /*173*/, 4 /*174*/, 5 /*175*/, + 2 /*176*/, 3 /*177*/, 3 /*178*/, 4 /*179*/, 3 /*180*/, 4 /*181*/, 4 /*182*/, 5 /*183*/, + 3 /*184*/, 4 /*185*/, 4 /*186*/, 5 /*187*/, 4 /*188*/, 5 /*189*/, 5 /*190*/, 6 /*191*/, + 0 /*192*/, 0 /*193*/, 0 /*194*/, 0 /*195*/, 0 /*196*/, 0 /*197*/, 0 /*198*/, 0 /*199*/, + 0 /*200*/, 0 /*201*/, 0 /*202*/, 0 /*203*/, 0 /*204*/, 0 /*205*/, 0 /*206*/, 0 /*207*/, + 0 /*208*/, 0 /*209*/, 0 /*210*/, 0 /*211*/, 0 /*212*/, 0 /*213*/, 0 /*214*/, 0 /*215*/, + 0 /*216*/, 0 /*217*/, 0 /*218*/, 0 /*219*/, 0 /*220*/, 0 /*221*/, 0 /*222*/, 0 /*223*/, + 1 /*224*/, 2 /*225*/, 2 /*226*/, 3 /*227*/, 2 /*228*/, 3 /*229*/, 3 /*230*/, 4 /*231*/, + 2 /*232*/, 3 /*233*/, 3 /*234*/, 4 /*235*/, 3 /*236*/, 4 /*237*/, 4 /*238*/, 5 /*239*/, + 2 /*240*/, 3 /*241*/, 3 /*242*/, 4 /*243*/, 3 /*244*/, 4 /*245*/, 4 /*246*/, 5 /*247*/, + 3 /*248*/, 4 /*249*/, 4 /*250*/, 5 /*251*/, 4 /*252*/, 5 /*253*/, 5 /*254*/, 6 /*255*/}, + // Table for bit 6. + { 0 /*0*/, 0 /*1*/, 0 /*2*/, 0 /*3*/, 0 /*4*/, 0 /*5*/, 0 /*6*/, 0 /*7*/, + 0 /*8*/, 0 /*9*/, 0 /*10*/, 0 /*11*/, 0 /*12*/, 0 /*13*/, 0 /*14*/, 0 /*15*/, + 0 /*16*/, 0 /*17*/, 0 /*18*/, 0 /*19*/, 0 /*20*/, 0 /*21*/, 0 /*22*/, 0 /*23*/, + 0 /*24*/, 0 /*25*/, 0 /*26*/, 0 /*27*/, 0 /*28*/, 0 /*29*/, 0 /*30*/, 0 /*31*/, + 0 /*32*/, 0 /*33*/, 0 /*34*/, 0 /*35*/, 0 /*36*/, 0 /*37*/, 0 /*38*/, 0 /*39*/, + 0 /*40*/, 0 /*41*/, 0 /*42*/, 0 /*43*/, 0 /*44*/, 0 /*45*/, 0 /*46*/, 0 /*47*/, + 0 /*48*/, 0 /*49*/, 0 /*50*/, 0 /*51*/, 0 /*52*/, 0 /*53*/, 0 /*54*/, 0 /*55*/, + 0 /*56*/, 0 /*57*/, 0 /*58*/, 0 /*59*/, 0 /*60*/, 0 /*61*/, 0 /*62*/, 0 /*63*/, + 1 /*64*/, 2 /*65*/, 2 /*66*/, 3 /*67*/, 2 /*68*/, 3 /*69*/, 3 /*70*/, 4 /*71*/, + 2 /*72*/, 3 /*73*/, 3 /*74*/, 4 /*75*/, 3 /*76*/, 4 /*77*/, 4 /*78*/, 5 /*79*/, + 2 /*80*/, 3 /*81*/, 3 /*82*/, 4 /*83*/, 3 /*84*/, 4 /*85*/, 4 /*86*/, 5 /*87*/, + 3 /*88*/, 4 /*89*/, 4 /*90*/, 5 /*91*/, 4 /*92*/, 5 /*93*/, 5 /*94*/, 6 /*95*/, + 2 /*96*/, 3 /*97*/, 3 /*98*/, 4 /*99*/, 3 /*100*/, 4 /*101*/, 4 /*102*/, 5 /*103*/, + 3 /*104*/, 4 /*105*/, 4 /*106*/, 5 /*107*/, 4 /*108*/, 5 /*109*/, 5 /*110*/, 6 /*111*/, + 3 /*112*/, 4 /*113*/, 4 /*114*/, 5 /*115*/, 4 /*116*/, 5 /*117*/, 5 /*118*/, 6 /*119*/, + 4 /*120*/, 5 /*121*/, 5 /*122*/, 6 /*123*/, 5 /*124*/, 6 /*125*/, 6 /*126*/, 7 /*127*/, + 0 /*128*/, 0 /*129*/, 0 /*130*/, 0 /*131*/, 0 /*132*/, 0 /*133*/, 0 /*134*/, 0 /*135*/, + 0 /*136*/, 0 /*137*/, 0 /*138*/, 0 /*139*/, 0 /*140*/, 0 /*141*/, 0 /*142*/, 0 /*143*/, + 0 /*144*/, 0 /*145*/, 0 /*146*/, 0 /*147*/, 0 /*148*/, 0 /*149*/, 0 /*150*/, 0 /*151*/, + 0 /*152*/, 0 /*153*/, 0 /*154*/, 0 /*155*/, 0 /*156*/, 0 /*157*/, 0 /*158*/, 0 /*159*/, + 0 /*160*/, 0 /*161*/, 0 /*162*/, 0 /*163*/, 0 /*164*/, 0 /*165*/, 0 /*166*/, 0 /*167*/, + 0 /*168*/, 0 /*169*/, 0 /*170*/, 0 /*171*/, 0 /*172*/, 0 /*173*/, 0 /*174*/, 0 /*175*/, + 0 /*176*/, 0 /*177*/, 0 /*178*/, 0 /*179*/, 0 /*180*/, 0 /*181*/, 0 /*182*/, 0 /*183*/, + 0 /*184*/, 0 /*185*/, 0 /*186*/, 0 /*187*/, 0 /*188*/, 0 /*189*/, 0 /*190*/, 0 /*191*/, + 1 /*192*/, 2 /*193*/, 2 /*194*/, 3 /*195*/, 2 /*196*/, 3 /*197*/, 3 /*198*/, 4 /*199*/, + 2 /*200*/, 3 /*201*/, 3 /*202*/, 4 /*203*/, 3 /*204*/, 4 /*205*/, 4 /*206*/, 5 /*207*/, + 2 /*208*/, 3 /*209*/, 3 /*210*/, 4 /*211*/, 3 /*212*/, 4 /*213*/, 4 /*214*/, 5 /*215*/, + 3 /*216*/, 4 /*217*/, 4 /*218*/, 5 /*219*/, 4 /*220*/, 5 /*221*/, 5 /*222*/, 6 /*223*/, + 2 /*224*/, 3 /*225*/, 3 /*226*/, 4 /*227*/, 3 /*228*/, 4 /*229*/, 4 /*230*/, 5 /*231*/, + 3 /*232*/, 4 /*233*/, 4 /*234*/, 5 /*235*/, 4 /*236*/, 5 /*237*/, 5 /*238*/, 6 /*239*/, + 3 /*240*/, 4 /*241*/, 4 /*242*/, 5 /*243*/, 4 /*244*/, 5 /*245*/, 5 /*246*/, 6 /*247*/, + 4 /*248*/, 5 /*249*/, 5 /*250*/, 6 /*251*/, 5 /*252*/, 6 /*253*/, 6 /*254*/, 7 /*255*/ }, + // Table for bit 7. + { 0 /*0*/, 0 /*1*/, 0 /*2*/, 0 /*3*/, 0 /*4*/, 0 /*5*/, 0 /*6*/, 0 /*7*/, + 0 /*8*/, 0 /*9*/, 0 /*10*/, 0 /*11*/, 0 /*12*/, 0 /*13*/, 0 /*14*/, 0 /*15*/, + 0 /*16*/, 0 /*17*/, 0 /*18*/, 0 /*19*/, 0 /*20*/, 0 /*21*/, 0 /*22*/, 0 /*23*/, + 0 /*24*/, 0 /*25*/, 0 /*26*/, 0 /*27*/, 0 /*28*/, 0 /*29*/, 0 /*30*/, 0 /*31*/, + 0 /*32*/, 0 /*33*/, 0 /*34*/, 0 /*35*/, 0 /*36*/, 0 /*37*/, 0 /*38*/, 0 /*39*/, + 0 /*40*/, 0 /*41*/, 0 /*42*/, 0 /*43*/, 0 /*44*/, 0 /*45*/, 0 /*46*/, 0 /*47*/, + 0 /*48*/, 0 /*49*/, 0 /*50*/, 0 /*51*/, 0 /*52*/, 0 /*53*/, 0 /*54*/, 0 /*55*/, + 0 /*56*/, 0 /*57*/, 0 /*58*/, 0 /*59*/, 0 /*60*/, 0 /*61*/, 0 /*62*/, 0 /*63*/, + 0 /*64*/, 0 /*65*/, 0 /*66*/, 0 /*67*/, 0 /*68*/, 0 /*69*/, 0 /*70*/, 0 /*71*/, + 0 /*72*/, 0 /*73*/, 0 /*74*/, 0 /*75*/, 0 /*76*/, 0 /*77*/, 0 /*78*/, 0 /*79*/, + 0 /*80*/, 0 /*81*/, 0 /*82*/, 0 /*83*/, 0 /*84*/, 0 /*85*/, 0 /*86*/, 0 /*87*/, + 0 /*88*/, 0 /*89*/, 0 /*90*/, 0 /*91*/, 0 /*92*/, 0 /*93*/, 0 /*94*/, 0 /*95*/, + 0 /*96*/, 0 /*97*/, 0 /*98*/, 0 /*99*/, 0 /*100*/, 0 /*101*/, 0 /*102*/, 0 /*103*/, + 0 /*104*/, 0 /*105*/, 0 /*106*/, 0 /*107*/, 0 /*108*/, 0 /*109*/, 0 /*110*/, 0 /*111*/, + 0 /*112*/, 0 /*113*/, 0 /*114*/, 0 /*115*/, 0 /*116*/, 0 /*117*/, 0 /*118*/, 0 /*119*/, + 0 /*120*/, 0 /*121*/, 0 /*122*/, 0 /*123*/, 0 /*124*/, 0 /*125*/, 0 /*126*/, 0 /*127*/, + 1 /*128*/, 2 /*129*/, 2 /*130*/, 3 /*131*/, 2 /*132*/, 3 /*133*/, 3 /*134*/, 4 /*135*/, + 2 /*136*/, 3 /*137*/, 3 /*138*/, 4 /*139*/, 3 /*140*/, 4 /*141*/, 4 /*142*/, 5 /*143*/, + 2 /*144*/, 3 /*145*/, 3 /*146*/, 4 /*147*/, 3 /*148*/, 4 /*149*/, 4 /*150*/, 5 /*151*/, + 3 /*152*/, 4 /*153*/, 4 /*154*/, 5 /*155*/, 4 /*156*/, 5 /*157*/, 5 /*158*/, 6 /*159*/, + 2 /*160*/, 3 /*161*/, 3 /*162*/, 4 /*163*/, 3 /*164*/, 4 /*165*/, 4 /*166*/, 5 /*167*/, + 3 /*168*/, 4 /*169*/, 4 /*170*/, 5 /*171*/, 4 /*172*/, 5 /*173*/, 5 /*174*/, 6 /*175*/, + 3 /*176*/, 4 /*177*/, 4 /*178*/, 5 /*179*/, 4 /*180*/, 5 /*181*/, 5 /*182*/, 6 /*183*/, + 4 /*184*/, 5 /*185*/, 5 /*186*/, 6 /*187*/, 5 /*188*/, 6 /*189*/, 6 /*190*/, 7 /*191*/, + 2 /*192*/, 3 /*193*/, 3 /*194*/, 4 /*195*/, 3 /*196*/, 4 /*197*/, 4 /*198*/, 5 /*199*/, + 3 /*200*/, 4 /*201*/, 4 /*202*/, 5 /*203*/, 4 /*204*/, 5 /*205*/, 5 /*206*/, 6 /*207*/, + 3 /*208*/, 4 /*209*/, 4 /*210*/, 5 /*211*/, 4 /*212*/, 5 /*213*/, 5 /*214*/, 6 /*215*/, + 4 /*216*/, 5 /*217*/, 5 /*218*/, 6 /*219*/, 5 /*220*/, 6 /*221*/, 6 /*222*/, 7 /*223*/, + 3 /*224*/, 4 /*225*/, 4 /*226*/, 5 /*227*/, 4 /*228*/, 5 /*229*/, 5 /*230*/, 6 /*231*/, + 4 /*232*/, 5 /*233*/, 5 /*234*/, 6 /*235*/, 5 /*236*/, 6 /*237*/, 6 /*238*/, 7 /*239*/, + 4 /*240*/, 5 /*241*/, 5 /*242*/, 6 /*243*/, 5 /*244*/, 6 /*245*/, 6 /*246*/, 7 /*247*/, + 5 /*248*/, 6 /*249*/, 6 /*250*/, 7 /*251*/, 6 /*252*/, 7 /*253*/, 7 /*254*/, 8 /*255*/ } + }; + } #endif diff --git a/src/DGtal/base/Common.cpp b/src/DGtal/base/Common.cpp index 15691ea3de..3349f9cd29 100644 --- a/src/DGtal/base/Common.cpp +++ b/src/DGtal/base/Common.cpp @@ -42,23 +42,5 @@ /** DGtal Global variables * **/ -namespace DGtal -{ - -#ifndef NDEBUG -#ifdef __linux__ -#ifdef DGTAL_ENABLE_FLOATING_POINT_EXCEPTIONS - void beforeMain (void) __attribute__((constructor)); - void beforeMain (void) - { - feenableexcept ( FE_DIVBYZERO | FE_INVALID | FE_OVERFLOW ); - } -#endif -#endif -#endif - - TraceWriterTerm traceWriterTerm(std::cerr); - Trace trace(traceWriterTerm); -} // // /////////////////////////////////////////////////////////////////////////////// diff --git a/src/DGtal/base/Common.h b/src/DGtal/base/Common.h index 7f6be78d40..e77606d941 100644 --- a/src/DGtal/base/Common.h +++ b/src/DGtal/base/Common.h @@ -228,6 +228,25 @@ void setStyle( Board3DTo2D< S, KS> & ) const {} } // namespace DGtal +namespace DGtal +{ + +#ifndef NDEBUG +#ifdef __linux__ +#ifdef DGTAL_ENABLE_FLOATING_POINT_EXCEPTIONS + inline void beforeMain (void) __attribute__((constructor)); + inline void beforeMain (void) + { + feenableexcept ( FE_DIVBYZERO | FE_INVALID | FE_OVERFLOW ); + } +#endif +#endif +#endif + + TraceWriterTerm traceWriterTerm(std::cerr); + Trace trace(traceWriterTerm); +} + // // /////////////////////////////////////////////////////////////////////////////// diff --git a/src/DGtal/base/ModuleSRC.cmake b/src/DGtal/base/ModuleSRC.cmake index 72d840ba00..3bb439b7e0 100644 --- a/src/DGtal/base/ModuleSRC.cmake +++ b/src/DGtal/base/ModuleSRC.cmake @@ -1,5 +1,5 @@ set(DGTAL_SRC ${DGTAL_SRC} - DGtal/base/Bits.cpp - DGtal/base/Common.cpp) + +) diff --git a/src/DGtal/io/Color.cpp b/src/DGtal/io/Color.cpp deleted file mode 100644 index e737ac6c9a..0000000000 --- a/src/DGtal/io/Color.cpp +++ /dev/null @@ -1,246 +0,0 @@ -/** - * 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 . - * - **/ - -/** - * @file Color.cpp - * @author Bertrand Kerautret (\c kerautre@loria.fr ) - * LORIA (CNRS, UMR 7503), University of Nancy, France - * - * @date 2011/07/17 - * - * Implementation of methods defined in Color.h - * - * This file is part of the DGtal library. - */ - -/////////////////////////////////////////////////////////////////////////////// -#include "DGtal/io/Color.h" -/////////////////////////////////////////////////////////////////////////////// - -using namespace std; - -/////////////////////////////////////////////////////////////////////////////// -// class Color -/////////////////////////////////////////////////////////////////////////////// - - -/////////////////////////////////////////////////////////////////////////////// -// Standard services - public : - - -DGtal::Color::Color( const unsigned int rgb, unsigned char aAlphaValue ) - :myAlpha( aAlphaValue ) -{ - myRed = ( rgb & 0xFF0000u ) >> 16; - myGreen = ( rgb & 0xFF00u ) >> 8; - myBlue = rgb & 0xFF; -} - - -DGtal::Color & -DGtal::Color::setRGBA( const DGtal::uint32_t aRGBA ) -{ - myRed = ( aRGBA & 0xFF000000u ) >> 24; - myGreen = ( aRGBA & 0xFF0000u ) >> 16; - myBlue = ( aRGBA & 0xFF00u ) >> 8; - myAlpha = aRGBA & 0xFF; - return *this; -} - - -DGtal::Color & -DGtal::Color::setRGBf( float aRedValue, - float aGreenValue, - float aBlueValue, - float aAlphaValue ) { - if ( aRedValue > 1.0f ) aRedValue = 1.0f; - if ( aRedValue < 0.0f ) aRedValue = 0.0f; - myRed = static_cast( 255 * aRedValue ); - if ( aGreenValue > 1.0f ) aGreenValue = 1.0f; - if ( aGreenValue < 0.0f ) aGreenValue = 0.0f; - myGreen = static_cast( 255 * aGreenValue ); - if ( aBlueValue > 1.0f ) aBlueValue = 1.0f; - if ( aBlueValue < 0.0f ) aBlueValue = 0.0f; - myBlue = static_cast( 255 * aBlueValue ); - if ( aAlphaValue > 1.0f ) aAlphaValue = 1.0f; - if ( aAlphaValue < 0.0f ) aAlphaValue = 0.0f; - myAlpha = static_cast( 255 * aAlphaValue ); - return *this; -} - - - -bool -DGtal::Color::operator==( const Color & aColor ) const -{ - return myRed == aColor.myRed - && myGreen == aColor.myGreen - && myBlue == aColor.myBlue - && myAlpha == aColor.myAlpha; -} - -bool -DGtal::Color::operator!=( const Color & aColor ) const -{ - return myRed != aColor.myRed - || myGreen != aColor.myGreen - || myBlue != aColor.myBlue - || myAlpha != aColor.myAlpha; -} - -bool -DGtal::Color::operator<( const Color & aColor ) const -{ - if ( myRed < aColor.myRed ) - return true; - if ( myRed == aColor.myRed ) { - if ( myGreen < aColor.myGreen ) - return true; - if ( myGreen == aColor.myGreen ) { - if ( myBlue < aColor.myBlue ) - return true; - if ( myBlue == aColor.myBlue ) - return myAlpha < aColor.myAlpha; - } - } - return false; -} - -bool -DGtal::Color::operator>( const Color & aColor ) const -{ - return !this->operator<(aColor); -} - -bool -DGtal::Color::operator<=( const Color & aColor ) const -{ - return this->operator<(aColor) || this->operator==(aColor); -} - -bool -DGtal::Color::operator>=( const Color & aColor ) const -{ - return this->operator>(aColor) || this->operator==(aColor); -} - - -void -DGtal::Color::flushPostscript( std::ostream & stream ) const -{ - stream << ((double)myRed/255.0) << " " - << ((double)myGreen/255.0) << " " - << ((double)myBlue/255.0) << " srgb\n"; -} - -string -DGtal::Color::postscript() const -{ - char buffer[255]; - secured_sprintf( buffer, 255, "%.4f %.4f %.4f", myRed/255.0, myGreen/255.0, myBlue/255.0 ); - return buffer; -} - -string -DGtal::Color::svg() const -{ - char buffer[255]; - if ( *this == DGtal::Color::None ) return "none"; - secured_sprintf( buffer, 255, "rgb(%d,%d,%d)",myRed, myGreen, myBlue ); - return buffer; -} - -string -DGtal::Color::svgAlpha( const char * prefix ) const -{ - char buffer[255]; - if ( myAlpha == 255 || *this == DGtal::Color::None ) return ""; - secured_sprintf( buffer, 255, " %s-opacity=\"%f\"", prefix, myAlpha/255.0f ); - return buffer; -} - -string -DGtal::Color::tikz() const -{ - // see tex/generic/pgf/utilities/pgfutil-plain.def for color definitions - char buffer[255]; - if ( *this == DGtal::Color::None ) return "none"; - if ( *this == DGtal::Color::Black ) return "black"; - if ( *this == DGtal::Color::Gray ) return "gray"; - if ( *this == DGtal::Color::White ) return "white"; - if ( *this == DGtal::Color::Red ) return "red"; - if ( *this == DGtal::Color::Green ) return "green!50!black"; - if ( *this == DGtal::Color::Lime ) return "green"; - if ( *this == DGtal::Color::Blue ) return "blue"; -// if ( *this == DGtal::Color::Cyan ) return "cyan"; -// if ( *this == DGtal::Color::Magenta ) return "magenta"; -// if ( *this == DGtal::Color::Yellow ) return "yellow"; - if ( *this == DGtal::Color::Silver ) return "white!75!black"; - if ( *this == DGtal::Color::Purple ) return "purple"; - if ( *this == DGtal::Color::Navy ) return "blue!50!black"; -// if ( *this == DGtal::Color::Aqua ) return "cyan"; // ???: Is Color::Aqua meant to be equal to Color::Cyan? - secured_sprintf( buffer, 255, "{rgb,255:red,%d;green,%d;blue,%d}", myRed, myGreen, myBlue ); - return buffer; -} - - -/////////////////////////////////////////////////////////////////////////////// -// Interface - public : - -const DGtal::Color DGtal::Color::None(0,0,0,0); -const DGtal::Color DGtal::Color::Black((unsigned char)0,(unsigned char)0,(unsigned char)0); -const DGtal::Color DGtal::Color::Gray((unsigned char)128,(unsigned char)128,(unsigned char)128); -const DGtal::Color DGtal::Color::White((unsigned char)255,(unsigned char)255,(unsigned char)255); -const DGtal::Color DGtal::Color::Red((unsigned char)255,(unsigned char)0,(unsigned char)0); -const DGtal::Color DGtal::Color::Green((unsigned char)0,(unsigned char)255,(unsigned char)0); -const DGtal::Color DGtal::Color::Lime((unsigned char)0,(unsigned char)255,(unsigned char)0); -const DGtal::Color DGtal::Color::Blue((unsigned char)0,(unsigned char)0,(unsigned char)255); -const DGtal::Color DGtal::Color::Cyan((unsigned char)0,(unsigned char)255,(unsigned char)255); -const DGtal::Color DGtal::Color::Magenta((unsigned char)255,(unsigned char)0,(unsigned char)255); -const DGtal::Color DGtal::Color::Yellow((unsigned char)255,(unsigned char)255,(unsigned char)0); -const DGtal::Color DGtal::Color::Silver((unsigned char)190,(unsigned char)190,(unsigned char)190); -const DGtal::Color DGtal::Color::Purple((unsigned char)128,(unsigned char)0,(unsigned char)128); -const DGtal::Color DGtal::Color::Navy((unsigned char)0,(unsigned char)0,(unsigned char)128); -const DGtal::Color DGtal::Color::Aqua((unsigned char)0,(unsigned char)255,(unsigned char)255); - - -/** - * Writes/Displays the object on an output stream. - * @param out the output stream where the object is written. - */ -void -DGtal::Color::selfDisplay ( std::ostream & out ) const -{ - out << "[Color] RGBA("<<(int)myRed<<","<<(int)myGreen<<","<<(int)myBlue<<","<<(int)myAlpha<<")"; -} - -/** - * Checks the validity/consistency of the object. - * @return 'true' if the object is valid, 'false' otherwise. - */ -bool -DGtal::Color::isValid() const -{ - return true; -} - - - -/////////////////////////////////////////////////////////////////////////////// -// Internals - private : - -// // -/////////////////////////////////////////////////////////////////////////////// diff --git a/src/DGtal/io/Color.h b/src/DGtal/io/Color.h index a3d9a29345..fe11dab492 100644 --- a/src/DGtal/io/Color.h +++ b/src/DGtal/io/Color.h @@ -85,7 +85,13 @@ namespace DGtal */ Color( const unsigned int aRgb, - unsigned char aAlpha = 255 ); + unsigned char aAlpha = 255 ) + :myAlpha( aAlpha ) + { + myRed = ( aRgb & 0xFF0000u ) >> 16; + myGreen = ( aRgb & 0xFF00u ) >> 8; + myBlue = aRgb & 0xFF; + } /** * Copy Constructor. @@ -516,6 +522,24 @@ namespace DGtal std::ostream& operator<< ( std::ostream & out, const Color & aColor ); +/////////////////////////////////////////////////////////////////////////////// +// Interface - public : + +const DGtal::Color DGtal::Color::None(0,0,0,0); +const DGtal::Color DGtal::Color::Black((unsigned char)0,(unsigned char)0,(unsigned char)0); +const DGtal::Color DGtal::Color::Gray((unsigned char)128,(unsigned char)128,(unsigned char)128); +const DGtal::Color DGtal::Color::White((unsigned char)255,(unsigned char)255,(unsigned char)255); +const DGtal::Color DGtal::Color::Red((unsigned char)255,(unsigned char)0,(unsigned char)0); +const DGtal::Color DGtal::Color::Green((unsigned char)0,(unsigned char)255,(unsigned char)0); +const DGtal::Color DGtal::Color::Lime((unsigned char)0,(unsigned char)255,(unsigned char)0); +const DGtal::Color DGtal::Color::Blue((unsigned char)0,(unsigned char)0,(unsigned char)255); +const DGtal::Color DGtal::Color::Cyan((unsigned char)0,(unsigned char)255,(unsigned char)255); +const DGtal::Color DGtal::Color::Magenta((unsigned char)255,(unsigned char)0,(unsigned char)255); +const DGtal::Color DGtal::Color::Yellow((unsigned char)255,(unsigned char)255,(unsigned char)0); +const DGtal::Color DGtal::Color::Silver((unsigned char)190,(unsigned char)190,(unsigned char)190); +const DGtal::Color DGtal::Color::Purple((unsigned char)128,(unsigned char)0,(unsigned char)128); +const DGtal::Color DGtal::Color::Navy((unsigned char)0,(unsigned char)0,(unsigned char)128); +const DGtal::Color DGtal::Color::Aqua((unsigned char)0,(unsigned char)255,(unsigned char)255); } // namespace DGtal diff --git a/src/DGtal/io/Color.ih b/src/DGtal/io/Color.ih index 08066713e6..b1eac3e393 100644 --- a/src/DGtal/io/Color.ih +++ b/src/DGtal/io/Color.ih @@ -43,6 +43,7 @@ /////////////////////////////////////////////////////////////////////////////// // Implementation of inline functions and external operators // + /** * Overloads 'operator<<' for displaying objects of class 'Color'. * @param out the output stream where the object is written. @@ -67,6 +68,41 @@ DGtal::operator*( const double coeff, return c; } + + +inline DGtal::Color & +DGtal::Color::setRGBA( const DGtal::uint32_t aRGBA ) +{ + myRed = ( aRGBA & 0xFF000000u ) >> 24; + myGreen = ( aRGBA & 0xFF0000u ) >> 16; + myBlue = ( aRGBA & 0xFF00u ) >> 8; + myAlpha = aRGBA & 0xFF; + return *this; +} + + +inline DGtal::Color & +DGtal::Color::setRGBf( float aRedValue, + float aGreenValue, + float aBlueValue, + float aAlphaValue ) { + if ( aRedValue > 1.0f ) aRedValue = 1.0f; + if ( aRedValue < 0.0f ) aRedValue = 0.0f; + myRed = static_cast( 255 * aRedValue ); + if ( aGreenValue > 1.0f ) aGreenValue = 1.0f; + if ( aGreenValue < 0.0f ) aGreenValue = 0.0f; + myGreen = static_cast( 255 * aGreenValue ); + if ( aBlueValue > 1.0f ) aBlueValue = 1.0f; + if ( aBlueValue < 0.0f ) aBlueValue = 0.0f; + myBlue = static_cast( 255 * aBlueValue ); + if ( aAlphaValue > 1.0f ) aAlphaValue = 1.0f; + if ( aAlphaValue < 0.0f ) aAlphaValue = 0.0f; + myAlpha = static_cast( 255 * aAlphaValue ); + return *this; +} + + + inline DGtal::Color & DGtal::Color::setRGBi( const unsigned char aRedValue, const unsigned char aGreenValue, @@ -260,6 +296,155 @@ DGtal::Color::RGBtoHSV } } + +inline +bool +DGtal::Color::operator==( const Color & aColor ) const +{ + return myRed == aColor.myRed + && myGreen == aColor.myGreen + && myBlue == aColor.myBlue + && myAlpha == aColor.myAlpha; +} + +inline +bool +DGtal::Color::operator!=( const Color & aColor ) const +{ + return myRed != aColor.myRed + || myGreen != aColor.myGreen + || myBlue != aColor.myBlue + || myAlpha != aColor.myAlpha; +} + +inline +bool +DGtal::Color::operator<( const Color & aColor ) const +{ + if ( myRed < aColor.myRed ) + return true; + if ( myRed == aColor.myRed ) { + if ( myGreen < aColor.myGreen ) + return true; + if ( myGreen == aColor.myGreen ) { + if ( myBlue < aColor.myBlue ) + return true; + if ( myBlue == aColor.myBlue ) + return myAlpha < aColor.myAlpha; + } + } + return false; +} + +inline +bool +DGtal::Color::operator>( const Color & aColor ) const +{ + return !this->operator<(aColor); +} + +inline +bool +DGtal::Color::operator<=( const Color & aColor ) const +{ + return this->operator<(aColor) || this->operator==(aColor); +} + +inline +bool +DGtal::Color::operator>=( const Color & aColor ) const +{ + return this->operator>(aColor) || this->operator==(aColor); +} + + +inline +void +DGtal::Color::flushPostscript( std::ostream & stream ) const +{ + stream << ((double)myRed/255.0) << " " + << ((double)myGreen/255.0) << " " + << ((double)myBlue/255.0) << " srgb\n"; +} + +inline +std::string +DGtal::Color::postscript() const +{ + char buffer[255]; + secured_sprintf( buffer, 255, "%.4f %.4f %.4f", myRed/255.0, myGreen/255.0, myBlue/255.0 ); + return buffer; +} + +inline +std::string +DGtal::Color::svg() const +{ + char buffer[255]; + if ( *this == DGtal::Color::None ) return "none"; + secured_sprintf( buffer, 255, "rgb(%d,%d,%d)",myRed, myGreen, myBlue ); + return buffer; +} + +inline +std::string +DGtal::Color::svgAlpha( const char * prefix ) const +{ + char buffer[255]; + if ( myAlpha == 255 || *this == DGtal::Color::None ) return ""; + secured_sprintf( buffer, 255, " %s-opacity=\"%f\"", prefix, myAlpha/255.0f ); + return buffer; +} + +inline +std::string +DGtal::Color::tikz() const +{ + // see tex/generic/pgf/utilities/pgfutil-plain.def for color definitions + char buffer[255]; + if ( *this == DGtal::Color::None ) return "none"; + if ( *this == DGtal::Color::Black ) return "black"; + if ( *this == DGtal::Color::Gray ) return "gray"; + if ( *this == DGtal::Color::White ) return "white"; + if ( *this == DGtal::Color::Red ) return "red"; + if ( *this == DGtal::Color::Green ) return "green!50!black"; + if ( *this == DGtal::Color::Lime ) return "green"; + if ( *this == DGtal::Color::Blue ) return "blue"; +// if ( *this == DGtal::Color::Cyan ) return "cyan"; +// if ( *this == DGtal::Color::Magenta ) return "magenta"; +// if ( *this == DGtal::Color::Yellow ) return "yellow"; + if ( *this == DGtal::Color::Silver ) return "white!75!black"; + if ( *this == DGtal::Color::Purple ) return "purple"; + if ( *this == DGtal::Color::Navy ) return "blue!50!black"; +// if ( *this == DGtal::Color::Aqua ) return "cyan"; // ???: Is Color::Aqua meant to be equal to Color::Cyan? + secured_sprintf( buffer, 255, "{rgb,255:red,%d;green,%d;blue,%d}", myRed, myGreen, myBlue ); + return buffer; +} + + +/** + * Writes/Displays the object on an output stream. + * @param out the output stream where the object is written. + */ +inline +void +DGtal::Color::selfDisplay ( std::ostream & out ) const +{ + out << "[Color] RGBA("<<(int)myRed<<","<<(int)myGreen<<","<<(int)myBlue<<","<<(int)myAlpha<<")"; +} + +/** + * Checks the validity/consistency of the object. + * @return 'true' if the object is valid, 'false' otherwise. + */ +inline +bool +DGtal::Color::isValid() const +{ + return true; +} + + // // /////////////////////////////////////////////////////////////////////////////// diff --git a/src/DGtal/io/ModuleSRC.cmake b/src/DGtal/io/ModuleSRC.cmake index 915c442c46..ec9da6b077 100644 --- a/src/DGtal/io/ModuleSRC.cmake +++ b/src/DGtal/io/ModuleSRC.cmake @@ -6,15 +6,12 @@ #### boards ########################################## -set(DGTAL_SRC ${DGTAL_SRC} - DGtal/io/Color.cpp) +#set(DGTAL_SRC ${DGTAL_SRC}) -set(DGTALIO_SRC ${DGTALIO_SRC} - DGtal/io/boards/Board2D.cpp - DGtal/io/boards/Board3D.cpp) +#set(DGTALIO_SRC ${DGTALIO_SRC}) -if( WITH_CAIRO ) - set(DGTALIO_SRC ${DGTALIO_SRC} DGtal/io/boards/Board3DTo2D.cpp) -endif() +#if( WITH_CAIRO ) +# set(DGTALIO_SRC ${DGTALIO_SRC} DGtal/io/boards/Board3DTo2D.cpp) +#endif() diff --git a/src/DGtal/io/boards/Board2D.cpp b/src/DGtal/io/boards/Board2D.cpp deleted file mode 100644 index 3537f055d4..0000000000 --- a/src/DGtal/io/boards/Board2D.cpp +++ /dev/null @@ -1,118 +0,0 @@ -/** - * 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 . - * - **/ - -/** - * @file Board2D.cpp - * @author Jacques-Olivier Lachaud (\c jacques-olivier.lachaud@univ-savoie.fr ) - * Laboratory of Mathematics (CNRS, UMR 5807), University of Savoie, France - * - * @date 2010/10/11 - * - * Implementation of methods defined in Board2D.h - * - * This file is part of the DGtal library. - */ - -/////////////////////////////////////////////////////////////////////////////// -#include "DGtal/io/boards/Board2D.h" -/////////////////////////////////////////////////////////////////////////////// - -using namespace std; - -/////////////////////////////////////////////////////////////////////////////// -// class Board2D -/////////////////////////////////////////////////////////////////////////////// - -/////////////////////////////////////////////////////////////////////////////// -// Standard services - public : - -/** - * Destructor. - */ -DGtal::Board2D::~Board2D() -{ -} - -/** - * Constructs a new board and sets the background color, if any. - * - * @param aBackgroundColor A color for the drawing's background. - */ -DGtal::Board2D::Board2D( const Color & aBackgroundColor ) - : LibBoard::Board( aBackgroundColor ), - myStyles() -{ - this->setUnit(LibBoard::Board::UCentimeter); -} - -/** - * Copy constructor. - * - * @param other The object to be copied. - */ -DGtal::Board2D::Board2D( const Board2D & other ) - : LibBoard::Board( other ), - myStyles( other.myStyles ) -{ -} - -/** - * Assignment. - * @param other the object to copy. - * @return a reference on 'this'. - */ -DGtal::Board2D & -DGtal::Board2D::operator= ( const Board2D & other ) -{ - if ( this != &other ) - { - LibBoard::Board::operator=( other ); - myStyles = other.myStyles; - } - return *this; -} - - -/////////////////////////////////////////////////////////////////////////////// -// Interface - public : - -/** - * Writes/Displays the object on an output stream. - * @param out the output stream where the object is written. - */ -void -DGtal::Board2D::selfDisplay ( std::ostream & out ) const -{ - out << "[Board2D]"; -} - -/** - * Checks the validity/consistency of the object. - * @return 'true' if the object is valid, 'false' otherwise. - */ -bool -DGtal::Board2D::isValid() const -{ - return true; -} - - - -/////////////////////////////////////////////////////////////////////////////// -// Internals - private : - -// // -/////////////////////////////////////////////////////////////////////////////// diff --git a/src/DGtal/io/boards/Board2D.h b/src/DGtal/io/boards/Board2D.h index 80f36da6e4..379755b651 100644 --- a/src/DGtal/io/boards/Board2D.h +++ b/src/DGtal/io/boards/Board2D.h @@ -91,28 +91,42 @@ namespace DGtal /** * Destructor. */ - ~Board2D(); + ~Board2D(){}; /** * Constructs a new board and sets the background color, if any. * * @param aBackgroundColor A color for the drawing's background. */ - Board2D( const Color & aBackgroundColor = Color::None ); + Board2D( const Color & aBackgroundColor = Color::None ): LibBoard::Board( aBackgroundColor ), + myStyles() + { + this->setUnit(LibBoard::Board::UCentimeter); + }; /** * Copy constructor. * * @param other The object to be copied. */ - Board2D( const Board2D & other ); + Board2D( const Board2D & other ) : LibBoard::Board( other ), + myStyles( other.myStyles ) + { + }; /** * Assignment. * @param other the object to copy. * @return a reference on 'this'. */ - Board2D & operator= ( const Board2D & other ); + Board2D & operator= ( const Board2D & other ){ + if ( this != &other ) + { + LibBoard::Board::operator=( other ); + myStyles = other.myStyles; + } + return *this; + }; /** * @param objectName the name of the object (generally obtained @@ -142,13 +156,21 @@ namespace DGtal * Writes/Displays the object on an output stream. * @param out the output stream where the object is written. */ - void selfDisplay ( std::ostream & out ) const; + void selfDisplay ( std::ostream & out ) const + { + out << "[Board2D]"; + }; + /** * Checks the validity/consistency of the object. * @return 'true' if the object is valid, 'false' otherwise. */ - bool isValid() const; + bool isValid() const + { + return true; + }; + // ------------------------- Public Datas ------------------------------ public: diff --git a/src/DGtal/io/boards/Board3D.cpp b/src/DGtal/io/boards/Board3D.cpp deleted file mode 100644 index 17c56a3236..0000000000 --- a/src/DGtal/io/boards/Board3D.cpp +++ /dev/null @@ -1,46 +0,0 @@ -/** - * 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; withoutOBJ 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 . - * - **/ - -/** - * @file Board3D.cpp - * @author Aline Martin - * @date vendredi 7 juin 2013 - * - * @brief - * - * Class for OBJ export - * This is the implementation of methods defined in Board3D.h - * - * This file is part of the DGtal library. - */ - -/////////////////////////////////////////////////////////////////////////////// -#include "DGtal/io/boards/Board3D.h" -#include -//#include - - - - -/////////////////////////////////////////////////////////////////////////////// - -using namespace std; -using namespace DGtal; - -/////////////////////////////////////////////////////////////////////////////// -// class Board3D -/////////////////////////////////////////////////////////////////////////////// - diff --git a/src/DGtal/io/boards/Board3DTo2D.cpp b/src/DGtal/io/boards/Board3DTo2D.cpp deleted file mode 100644 index 031ef83fca..0000000000 --- a/src/DGtal/io/boards/Board3DTo2D.cpp +++ /dev/null @@ -1,29 +0,0 @@ -/** -* 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 . -* -**/ - -/** -* @file Board3DTo2D.cpp -* @author Martial Tola -* @date mercredi 22 juin 2011 -* -* @brief -* -* Class for PDF, PNG, PS, EPS, SVG export drawings with Cairo with 3D->2D projection -* This is the implementation of methods defined in Board3DTo2D.h -* -* This file is part of the DGtal library. -*/ -