vigra - vigra/voxelneighborhood.hxx Source File

[ VIGRA Homepage | Function Index | Class Index | Namespaces | File List | Main Page ]

vigra/voxelneighborhood.hxx |

    00001 /************************************************************************/
    00002 /*                                                                      */
    00003 /*     Copyright 2006-2007 by F. Heinrich, B. Seppke, Ullrich Koethe    */
    00004 /*                                                                      */
    00005 /*    This file is part of the VIGRA computer vision library.           */
    00006 /*    The VIGRA Website is                                              */
    00007 /*        http://hci.iwr.uni-heidelberg.de/vigra/                       */
    00008 /*    Please direct questions, bug reports, and contributions to        */
    00009 /*        ullrich.koethe@iwr.uni-heidelberg.de    or                    */
    00010 /*        vigra@informatik.uni-hamburg.de                               */
    00011 /*                                                                      */
    00012 /*    Permission is hereby granted, free of charge, to any person       */
    00013 /*    obtaining a copy of this software and associated documentation    */
    00014 /*    files (the "Software"), to deal in the Software without           */
    00015 /*    restriction, including without limitation the rights to use,      */
    00016 /*    copy, modify, merge, publish, distribute, sublicense, and/or      */
    00017 /*    sell copies of the Software, and to permit persons to whom the    */
    00018 /*    Software is furnished to do so, subject to the following          */
    00019 /*    conditions:                                                       */
    00020 /*                                                                      */
    00021 /*    The above copyright notice and this permission notice shall be    */
    00022 /*    included in all copies or substantial portions of the             */
    00023 /*    Software.                                                         */
    00024 /*                                                                      */
    00025 /*    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND    */
    00026 /*    EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES   */
    00027 /*    OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND          */
    00028 /*    NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT       */
    00029 /*    HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,      */
    00030 /*    WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING      */
    00031 /*    FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR     */
    00032 /*    OTHER DEALINGS IN THE SOFTWARE.                                   */
    00033 /*                                                                      */
    00034 /************************************************************************/
    00035
    00036 #ifndef VIGRA_VOXELNEIGHBORHOOD_HXX
    00037 #define VIGRA_VOXELNEIGHBORHOOD_HXX
    00038
    00039 #include "tinyvector.hxx"
    00040 #include "pixelneighborhood.hxx"
    00041
    00042 namespace vigra {
    00043
    00044 /** \addtogroup VoxelNeighborhood Utilities to manage voxel neighborhoods
    00045
    00046     6- and 26-neighborhood definitions and circulators.
    00047
    00048     <b>\#include</b> <vigra/voxelneighborhood.hxx><br>
    00049
    00050     <b>See also:</b> \ref vigra::NeighborhoodCirculator
    00051  */
    00052 //@{
    00053
    00054     /// 3-dimensional difference vector
    00055     typedef vigra::TinyVector<int, 3> Diff3D;
    00056
    00057 /********************************************************/
    00058 /*                                                      */
    00059 /*                      AtVolumeBorder                  */
    00060 /*                                                      */
    00061 /********************************************************/
    00062
    00063 /** \brief Encode whether a voxel is near the volume border.
    00064
    00065         //    This enum is used with \ref isAtVolumeBorder() and
    00066         //    \ref vigra::RestrictedNeighborhoodCirculator.
    00067
    00068         //<b>\#include</b> <vigra/voxelneighborhood.hxx><br>
    00069         //Namespace: vigra
    00070 */
    00071
    00072 typedef AtImageBorder AtVolumeBorder;
    00073
    00074
    00075 /** \brief Find out whether a voxel is at the volume border.
    00076
    00077     This function checks if \a x == 0 or \a x == \a width - 1 and
    00078     \a y == 0 or \a y == \a height - 1 and so on and returns the appropriate value
    00079     of \ref vigra::AtVolumeBorder, or zero when the voxel is not at te volume border.
    00080     The behavior of the function is undefined if (x,y,z) is not inside the volume.
    00081 */
    00082 inline AtVolumeBorder isAtVolumeBorder(int x, int y, int z, int width, int height, int depth)
    00083 {
    00084     return static_cast<AtVolumeBorder>((x == 0
    00085                                          ? LeftBorder
    00086                                          : x == width-1
    00087                                              ? RightBorder
    00088                                              : NotAtBorder) |
    00089                                        (y == 0
    00090                                          ? TopBorder
    00091                                          : y == height-1
    00092                                              ? BottomBorder
    00093                                              : NotAtBorder) |
    00094                                        (z == 0
    00095                                          ? FrontBorder
    00096                                          : z == depth-1
    00097                                              ? RearBorder
    00098                                              : NotAtBorder));
    00099 }
    00100
    00101 inline AtVolumeBorder isAtVolumeBorder(Diff3D const & p, Diff3D const & shape)
    00102 {
    00103     return isAtVolumeBorder(p[0], p[1], p[2], shape[0], shape[1], shape[2]);
    00104 }
    00105
    00106 /** \brief Find out whether a voxel is at a scan-order relevant volume border.
    00107     This function checks if \a x == 0 or \a y == 0 or \a z == \a 0 and returns the
    00108         appropriate value of \ref vigra::AtVolumeBorder, or zero when the voxel is
    00109         not at te volume border.
    00110     The behavior of the function is undefined if (x,y,z) is not inside the volume.
    00111 */
    00112 inline AtVolumeBorder isAtVolumeBorderCausal(int x, int y, int z, int width, int height, int /* depth */)
    00113 {
    00114     return static_cast<AtVolumeBorder>((x == 0
    00115                                          ? LeftBorder
    00116                                          : x == width-1
    00117                                              ? RightBorder
    00118                                              : NotAtBorder) |
    00119                                        (y == 0
    00120                                          ? TopBorder
    00121                                          : y == height-1
    00122                                              ? BottomBorder
    00123                                              : NotAtBorder) |
    00124                                        (z == 0
    00125                                          ? FrontBorder
    00126                                          : NotAtBorder));
    00127 }
    00128 /** TODO: Write new comment \brief Find out whether a voxel is at a scan-order relevant volume border.
    00129     This function checks if \a x == 0 or \a y == 0 or \a z == \a 0 and returns the
    00130         appropriate value of \ref vigra::AtVolumeBorder, or zero when the voxel is
    00131         not at te volume border.
    00132     The behavior of the function is undefined if (x,y,z) is not inside the volume.
    00133 */
    00134 inline AtVolumeBorder isAtVolumeBorderAntiCausal(int x, int y, int z, int width, int height, int depth)
    00135 {
    00136     return static_cast<AtVolumeBorder>((x == 0
    00137                                          ? LeftBorder
    00138                                          : x == width-1
    00139                                              ? RightBorder
    00140                                              : NotAtBorder) |
    00141                                        (y == 0
    00142                                          ? TopBorder
    00143                                          : y == height-1
    00144                                              ? BottomBorder
    00145                                              : NotAtBorder) |
    00146                                        (z == depth-1
    00147                                          ? RearBorder
    00148                                          : NotAtBorder));
    00149 }
    00150
    00151 /********************************************************/
    00152 /*                                                      */
    00153 /*                   Neighborhood3DSix                  */
    00154 /*                                                      */
    00155 /********************************************************/
    00156
    00157 /** 3D 6-Neighborhood. */
    00158 namespace Neighborhood3DSix
    00159 {
    00160
    00161 /** \brief Encapsulation of direction management of neighbors for a 3D 6-neighborhood.
    00162 */
    00163 class NeighborCode3D
    00164 {
    00165     public:
    00166
    00167     typedef Diff3D difference_type;
    00168
    00169     /** provides enumeration of all directions.
    00170         DirectionCount may be used for portable loop termination conditions.
    00171     */
    00172     enum Direction {
    00173         Error = -1,
    00174         InFront= 0,
    00175         North,
    00176         West ,
    00177         Behind,
    00178         South,
    00179         East,
    00180         DirectionCount,
    00181         CausalFirst = InFront,
    00182         CausalLast  = West,
    00183         AntiCausalFirst = Behind,
    00184         AntiCausalLast  = East,
    00185
    00186         InitialDirection = InFront,
    00187         OppositeDirPrefix = 1,
    00188         OppositeOffset = 3
    00189     };
    00190
    00191     static unsigned int directionBit(Direction d)
    00192     {
    00193         static unsigned int b[] = { 1 << InFront,
    00194                                     1 << North,
    00195                                     1 << West,
    00196                                     1 << Behind,
    00197                                     1 << South,
    00198                                     1 << East
    00199                                   };
    00200         return b[d];
    00201     };
    00202
    00203
    00204     /** The number of valid neighbors if the current center is at the volume border.
    00205     */
    00206     static unsigned int nearBorderDirectionCount(AtVolumeBorder b)
    00207     {
    00208         static unsigned int c[] = { 6, 5, 5, 0, 5, 4, 4, 0, 5, 4,
    00209                                     4, 0, 0, 0, 0, 0, 5, 4, 4, 0,
    00210                                     4, 3, 3, 0, 4, 3, 3, 0, 0, 0,
    00211                                     0, 0, 5, 4, 4, 0, 4, 3, 3, 0,
    00212                                     4, 3, 3};
    00213         return c[b];
    00214     }
    00215
    00216     /** The valid direction codes when the center is at the volume border.
    00217         \a index must be in the range <tt>0...nearBorderDirectionCount(b)-1</tt>.
    00218     */
    00219     static Direction nearBorderDirections(AtVolumeBorder b, int index)
    00220     {
    00221         static Direction c[43][6] = {
    00222                 { InFront, North, West, Behind, South, East},   // 0 - NotAtBorder
    00223                 { InFront, North, West, Behind, South, Error},  // 1 - AtRightBorder
    00224                 { InFront, North, Behind, South, East, Error},  // 2 - AtLeftBorder
    00225                 { Error, Error, Error, Error, Error, Error},
    00226                 { InFront, West, Behind, South, East, Error},   // 4 - AtTopBorder
    00227                 { InFront, West, Behind, South, Error, Error},  // 5 - AtTopRightBorder
    00228                 { InFront, Behind, South, East, Error, Error},  // 6 - AtTopLeftBorder
    00229                 { Error, Error, Error, Error, Error, Error},
    00230                 { InFront, North, West, Behind, East, Error},   // 8 - AtBottomBorder
    00231                 { InFront, North, West, Behind, Error, Error},  // 9 - AtBottomRightBorder
    00232                 { InFront, North, Behind, East, Error, Error},  //10- AtBottomLeftBorder
    00233                 { Error, Error, Error, Error, Error, Error},
    00234                 { Error, Error, Error, Error, Error, Error},
    00235                 { Error, Error, Error, Error, Error, Error},
    00236                 { Error, Error, Error, Error, Error, Error},
    00237                 { Error, Error, Error, Error, Error, Error},
    00238                 { North, West, Behind, South, East, Error},     //16 - AtFrontBorder
    00239                 { North, West, Behind, South, Error, Error},    //17 - AtFrontRightBorder
    00240                 { North, Behind, South, East, Error, Error},    //18 - AtFrontLeftBorder
    00241                 { Error, Error, Error, Error, Error, Error},
    00242                 { West, Behind, South, East, Error,  Error},    //20 - AtTopFrontBorder
    00243                 { West, Behind, South, Error, Error, Error},    //21 - AtTopRightFrontBorder
    00244                 { Behind, South, East, Error, Error,  Error},   //22 - AtTopLeftFrontBorder
    00245                 { Error, Error, Error, Error, Error, Error},
    00246                 { North, West, Behind, East, Error, Error},     //24 - AtBottomFrontBorder
    00247                 { North, West, Behind, Error, Error, Error},    //25 - AtBottomRightFrontBorder
    00248                 { North, Behind, East, Error, Error, Error},    //26 - AtBottomLeftFrontBorder
    00249                 { Error, Error, Error, Error, Error, Error},
    00250                 { Error, Error, Error, Error, Error, Error},
    00251                 { Error, Error, Error, Error, Error, Error},
    00252                 { Error, Error, Error, Error, Error, Error},
    00253                 { Error, Error, Error, Error, Error, Error},
    00254                 { InFront, North, West, South, East,Error},     //32 - AtRearBorder
    00255                 { InFront, North, West, South, Error, Error},   //33 - AtRearRightBorder
    00256                 { InFront, North, South, East, Error, Error},   //34 - AtRearLeftBorder
    00257                 { Error, Error, Error, Error, Error, Error},
    00258                 { InFront, West, South, East, Error, Error},    //36 - AtTopRearBorder
    00259                 { InFront, West, South, Error, Error, Error},   //37 - AtTopRightRearBorder
    00260                 { InFront, South, East, Error, Error, Error},   //38 - AtTopLeftRearBorder
    00261                 { Error, Error, Error, Error, Error, Error},
    00262                 { InFront, North, West, East, Error, Error},    //40 - AtBottomRearBorder
    00263                 { InFront, North, West, Error, Error, Error},   //41 - AtBottomRightRearBorder
    00264                 { InFront, North, East, Error, Error, Error}    //42 - AtBottomLeftRearBorder
    00265                };
    00266         return c[b][index];
    00267     }
    00268
    00269     /** The valid direction three codes in anti causal direction (means: look back in scanline
    00270         direction)when the center is at the volume border.
    00271         Should be used with isAtVolumeBorderCausal to determine the Directions, as this
    00272         avoids using of the nonesense border ids (e.g. 0,1,8,9...) of this table.
    00273         \a index must be in the range <tt>0...nearBorderDirectionCount(b)-1</tt>.
    00274     */
    00275     static Direction nearBorderDirectionsCausal(AtVolumeBorder b, int index)
    00276     {
    00277         static Direction c[43][3] = {
    00278             { InFront, North, West},                    // 0 - NotAtBorder
    00279             { InFront, North, West},                    // 1 - AtRightBorder
    00280             { InFront, North, Error},                   // 2 - AtLeftBorder
    00281             { Error, Error, Error},
    00282             { InFront, West, Error},                    // 4 - AtTopBorder
    00283             { InFront, West, Error},                    // 5 - AtTopRightBorder
    00284             { InFront, Error,Error},                    // 6 - AtTopLeftBorder
    00285             { Error, Error, Error},
    00286             { InFront, North, West},                    // 8 - AtBottomBorder
    00287             { InFront, North, West},                    // 9 - AtBottomRightBorder
    00288             { InFront, North, Error},                   //10- AtBottomLeftBorder
    00289             { Error, Error, Error},
    00290             { Error, Error, Error},
    00291             { Error, Error, Error},
    00292             { Error, Error, Error},
    00293             { Error, Error, Error},
    00294             { North, West, Error},                      //16 - AtFrontBorder
    00295             { North, West, Error},                      //17 - AtFrontRightBorder
    00296             { North, Error, Error},                     //18 - AtFrontLeftBorder
    00297             { Error, Error, Error},
    00298             { West, Error, Error},                      //20 - AtTopFrontBorder
    00299             { West, Error, Error},                      //21 - AtTopRightFrontBorder
    00300             { Error, Error,  Error},                    //22 - AtTopLeftFrontBorder
    00301             { Error, Error, Error},
    00302             { North, West, Error},                      //24 - AtBottomFrontBorder
    00303             { North, West, Error},                      //25 - AtBottomRightFrontBorder
    00304             { North, Error, Error},                     //26 - AtBottomLeftFrontBorder
    00305             { Error, Error, Error},
    00306             { Error, Error, Error},
    00307             { Error, Error, Error},
    00308             { Error, Error, Error},
    00309             { Error, Error, Error},
    00310             { InFront, North, West},                    //32 - AtRearBorder
    00311             { InFront, North, West},                    //33 - AtRearRightBorder
    00312             { InFront, North, Error},                   //34 - AtRearLeftBorder
    00313             { Error, Error, Error},
    00314             { InFront, West, Error},                    //36 - AtTopRearBorder
    00315             { InFront, West, Error},                    //37 - AtTopRightRearBorder
    00316             { InFront, Error, Error},                   //38 - AtTopLeftRearBorder
    00317             { Error, Error, Error},
    00318             { InFront, North, West},                    //40 - AtBottomRearBorder
    00319             { InFront, North, West},                    //41 - AtBottomRightRearBorder
    00320             { InFront, North, Error}                    //42 - AtBottomLeftRearBorder
    00321         };
    00322         return c[b][index];
    00323     }
    00324
    00325     /** transform direction code into corresponding Diff3D offset.
    00326         (note: there is no bounds checking on the code you pass.)
    00327     */
    00328     static Diff3D const & diff(Direction code)
    00329     {
    00330         static Diff3D d[] = {
    00331                     Diff3D(  0,  0, -1),  //InFront
    00332                     Diff3D(  0, -1,  0),  //North
    00333                     Diff3D( -1,  0,  0),  //West
    00334                     Diff3D(  0,  0,  1),  //Behind
    00335                     Diff3D(  0,  1,  0),  //South
    00336                     Diff3D(  1,  0,  0)   //East
    00337                 };
    00338         return d[code];
    00339     }
    00340
    00341     /** Equivalent to <tt>diff(static_cast<Direction>(code))</tt>.
    00342         (note: there is no bounds checking on the code you pass.)
    00343     */
    00344     static Diff3D const & diff(int code) { return diff(static_cast<Direction>(code)); }
    00345
    00346     /**  Equivalent to <tt>diff(code)[dim]</tt> */
    00347     static int diff(Direction code, int dim) { return diff(code)[dim]; }
    00348
    00349     /** Get the relative offset from one neighbor to the other.
    00350         For example, <tt>relativeDiff(East, West) == multi_differencetype(-2,0,0)</tt>.
    00351         (note: there is no bounds checking on the code you pass.)
    00352     */
    00353     static Diff3D const & relativeDiff(Direction fromCode, Direction toCode)
    00354     {
    00355       static Diff3D d[6][6] =
    00356           {
    00357                 //     InFront      -      North         -           West     -         Behind     -      South        -        East
    00358                 { Diff3D( 0, 0, 0), Diff3D(0, -1, 1), Diff3D(-1, 0, 1), Diff3D( 0, 0, 2), Diff3D( 0, 1, 1),  Diff3D( 1, 0, 1)}, //InFront
    00359                 { Diff3D( 0, 1,-1), Diff3D( 0, 0, 0), Diff3D(-1, 1, 0), Diff3D( 0, 1, 1), Diff3D( 0, 2, 0),  Diff3D( 1, 1, 0)}, //North
    00360                 { Diff3D( 1, 0,-1), Diff3D( 1,-1, 0), Diff3D( 0, 0, 0), Diff3D( 1, 0, 1), Diff3D( 1, 1, 0),  Diff3D( 2, 0, 0)}, //West
    00361                 { Diff3D( 0, 0,-2), Diff3D( 0,-1,-1), Diff3D(-1, 0,-1), Diff3D( 0, 0, 0), Diff3D( 0, 1,-1),  Diff3D( 1, 0,-1)}, //Behind
    00362                 { Diff3D( 0,-1,-1), Diff3D( 0,-2, 0), Diff3D(-1,-1, 0), Diff3D( 0,-1, 1), Diff3D( 0, 0, 0),  Diff3D( 1,-1, 0)}, //South
    00363                 { Diff3D(-1, 0,-1), Diff3D(-1,-1, 0), Diff3D(-2, 0, 0), Diff3D(-1, 0, 1), Diff3D(-1, 1, 0), Diff3D( 0, 0, 0) }  //East
    00364           };
    00365
    00366         return d[fromCode][toCode];
    00367     }
    00368
    00369     /** Equivalent to relativeDiff(static_cast<Direction>(fromCode), static_cast<Direction>(toCode)).
    00370         (note: there is no bounds checking on the code you pass.)
    00371     */
    00372     static Diff3D const & relativeDiff(int fromCode, int toCode)
    00373     {
    00374         return relativeDiff(static_cast<Direction>(fromCode), static_cast<Direction>(toCode));
    00375     }
    00376
    00377     /**  X-component of diff() */
    00378     static int dX(Direction code) { return diff(code)[0]; }
    00379     /**  Y-component of diff() */
    00380     static int dY(Direction code) { return diff(code)[1]; }
    00381     /**  Z-component of diff() */
    00382     static int dZ(Direction code) { return diff(code)[2]; }
    00383
    00384     /**  X-component of diff() */
    00385     static int dX(int code) { return diff(code)[0]; }
    00386     /**  Y-component of diff() */
    00387     static int dY(int code) { return diff(code)[1]; }
    00388     /**  Z-component of diff() */
    00389     static int dZ(int code) { return diff(code)[2]; }
    00390
    00391
    00392     /** transform Diff3D offset into corresponding direction code.
    00393         The code <tt>Direction::Error</tt> will be returned if <tt>diff</tt>
    00394         is not in the 3DSix-Neighborhood.
    00395     */
    00396     static Direction code(Diff3D const & diff)
    00397     {
    00398         switch(diff[0]) {
    00399             case  0:
    00400             {
    00401                 switch(diff[1]) {
    00402                     case 0:
    00403                         switch(diff[2]) {
    00404                             case 1:
    00405                                 return Behind;
    00406                             case -1:
    00407                                 return InFront;
    00408                             default:
    00409                                 return Error;
    00410                         }
    00411
    00412                     case 1:
    00413                         return (diff[2] == 0) ? South : Error;
    00414                     case -1:
    00415                         return (diff[2] == 0) ? North : Error;
    00416                     default:
    00417                         return Error;
    00418                 }
    00419         }
    00420         case -1:
    00421             return ((diff[1] == 0) && (diff[2] == 0)) ? West : Error;
    00422         case  1:
    00423             return ((diff[1] == 0) && (diff[2] == 0)) ? East : Error;
    00424         }
    00425         return Error;
    00426     }
    00427
    00428     /** Check whether a code refers to a diagonal direction.
    00429         Useful if you want to abstract the differences between 6- and 26-neighborhood.
    00430         Always <tt>false</tt> for 6-neighborhood.
    00431     */
    00432     static bool isDiagonal(Direction) { return false; }
    00433
    00434     static Diff3D const & right()           { return diff(East); }          /**<  Offset to the right neighbor */
    00435     static Diff3D const & top()             { return diff(North); }         /**<  Offset to the top neighbor */
    00436     static Diff3D const & left()            { return diff(West); }          /**<  Offset to the left neighbor */
    00437     static Diff3D const & bottom()          { return diff(South); }         /**<  Offset to the bottom neighbor */
    00438     static Diff3D const & rear()            { return diff(Behind); }        /**<  Offset to the rear neighbor */
    00439     static Diff3D const & front()           { return diff(InFront); }       /**<  Offset to the neighbor in front */
    00440
    00441     static Diff3D const & east()            { return diff(East); }          /**<  Offset to the east neighbor */
    00442     static Diff3D const & north()           { return diff(North); }         /**<  Offset to the north neighbor */
    00443     static Diff3D const & west()            { return diff(West); }          /**<  Offset to the west neighbor */
    00444     static Diff3D const & south()           { return diff(South); }         /**<  Offset to the south neighbor */
    00445     static Diff3D const & behind()          { return diff(Behind); }        /**<  Offset to the rear neighbor */
    00446     static Diff3D const & infront()         { return diff(InFront); }       /**<  Offset to the neighbor in front */
    00447
    00448 }; // class Neighborhood3DSix
    00449
    00450
    00451 /** Export NeighborCode3D::Direction into the scope of namespace Neighborhood3DSix.
    00452 */
    00453 typedef NeighborCode3D::Direction Direction;
    00454
    00455 static const Direction East           = NeighborCode3D::East;               /**<  Export NeighborCode3D::East to namespace Neighborhood3DSix */
    00456 static const Direction North          = NeighborCode3D::North;              /**<  Export NeighborCode3D::North to namespace Neighborhood3DSix */
    00457 static const Direction West           = NeighborCode3D::West;               /**<  Export NeighborCode3D::West to namespace Neighborhood3DSix */
    00458 static const Direction South          = NeighborCode3D::South;              /**<  Export NeighborCode3D::South to namespace Neighborhood3DSix */
    00459 static const Direction Behind         = NeighborCode3D::Behind;             /**<  Export NeighborCode3D::Behind to namespace Neighborhood3DSix */
    00460 static const Direction InFront        = NeighborCode3D::InFront;            /**<  Export NeighborCode3D::InFront to namespace Neighborhood3DSix */
    00461 static const Direction DirectionCount = NeighborCode3D::DirectionCount;     /**<  Export NeighborCode3D::DirectionCount to namespace Neighborhood3DSix */
    00462
    00463
    00464 }//namespace Neighborhood3DSix
    00465
    00466 /** Export \ref vigra::Neighborhood3DSix::NeighborCode3D into the scope of namespace vigra.
    00467 */
    00468 typedef Neighborhood3DSix::NeighborCode3D NeighborCode3DSix;
    00469
    00470 /********************************************************/
    00471 /*                                                      */
    00472 /*                   Neighborhood3DTwentySix            */
    00473 /*                                                      */
    00474 /********************************************************/
    00475 /** 3D 26-Neighborhood. */
    00476 namespace Neighborhood3DTwentySix
    00477 {
    00478
    00479 /** \brief Encapsulation of direction management of neighbors for a 3D 26-neighborhood.
    00480 */
    00481 class NeighborCode3D
    00482 {
    00483     public:
    00484
    00485     typedef Diff3D difference_type;
    00486
    00487    /** provides enumeration of all directions.
    00488        DirectionCount may be used for portable loop termination conditions.
    00489      */
    00490     enum Direction {
    00491         Error = -1,
    00492             InFrontNorthWest = 0,
    00493             InFrontNorth,
    00494             InFrontNorthEast,
    00495             InFrontWest,
    00496         InFront,
    00497             InFrontEast,
    00498             InFrontSouthWest,
    00499             InFrontSouth,
    00500             InFrontSouthEast,
    00501
    00502             NorthWest,
    00503             North,
    00504             NorthEast,
    00505         West,
    00506             East,
    00507             SouthWest,
    00508             South,
    00509             SouthEast,
    00510
    00511             BehindNorthWest,
    00512             BehindNorth,
    00513             BehindNorthEast,
    00514             BehindWest,
    00515         Behind,
    00516             BehindEast,
    00517             BehindSouthWest,
    00518             BehindSouth,
    00519             BehindSouthEast,
    00520
    00521         DirectionCount,
    00522             CausalFirst = InFrontNorthWest,
    00523             CausalLast  = West,
    00524             AntiCausalFirst = BehindSouthEast,
    00525             AntiCausalLast  = East,
    00526
    00527             InitialDirection = InFrontNorthWest,
    00528             OppositeDirPrefix = -1,
    00529             OppositeOffset = 25
    00530     };
    00531
    00532     static unsigned int directionBit(Direction d)
    00533     {
    00534         static unsigned int b[] = {
    00535                 1 <<  InFrontNorthWest,
    00536                 1 <<  InFrontNorth,
    00537                 1 <<  InFrontNorthEast,
    00538                 1 <<  InFrontWest,
    00539                 1 <<  InFront,
    00540                 1 <<  InFrontEast,
    00541                 1 <<  InFrontSouthWest,
    00542                 1 <<  InFrontSouth,
    00543                 1 <<  InFrontSouthEast,
    00544
    00545                 1 <<  NorthWest,
    00546                 1 <<  North,
    00547                 1 <<  NorthEast,
    00548                 1 <<  West,
    00549                 1 <<  East,
    00550                 1 <<  SouthWest,
    00551                 1 <<  South,
    00552                 1 <<  SouthEast,
    00553
    00554                 1 <<  BehindNorthWest,
    00555                 1 <<  BehindNorth,
    00556                 1 <<  BehindNorthEast,
    00557                 1 <<  BehindWest,
    00558                 1 <<  Behind,
    00559                 1 <<  BehindEast,
    00560                 1 <<  BehindSouthWest,
    00561                 1 <<  BehindSouth,
    00562                 1 <<  BehindSouthEast
    00563             };
    00564         return b[d];
    00565     };
    00566
    00567
    00568
    00569     /** The number of valid neighbors if the current center is at the volume border.
    00570     */
    00571     static unsigned int nearBorderDirectionCount(AtVolumeBorder b)
    00572     {
    00573         static unsigned int c[] = { 26, 17, 17,  0, 17, 11, 11,  0, 17, 11,
    00574                                     11,  0,  0,  0,  0,  0, 17, 11, 11,  0,
    00575                                     11,  7,  7,  0, 11,  7,  7,  0,  0,  0,
    00576                                      0,  0, 17, 11, 11,  0, 11,  7,  7,  0,
    00577                                     11,  7,  7};
    00578         return c[b];
    00579     }
    00580
    00581     /** The valid direction codes when the center is at the volume border.
    00582         \a index must be in the range <tt>0...nearBorderDirectionCount(b)-1</tt>.
    00583     */
    00584     static Direction nearBorderDirections(AtVolumeBorder b, int index)
    00585     {
    00586         static Direction c[43][26] = {
    00587                    //0 - NotAtBorder
    00588                    {    InFrontNorthWest,   InFrontNorth,   InFrontNorthEast,
    00589                         InFrontWest,        InFront,        InFrontEast,
    00590                         InFrontSouthWest,   InFrontSouth,   InFrontSouthEast,
    00591
    00592                         NorthWest, North, NorthEast,
    00593                         West,             East,
    00594                         SouthWest, South, SouthEast,
    00595
    00596                         BehindNorthWest, BehindNorth, BehindNorthEast,
    00597                         BehindWest,      Behind,      BehindEast,
    00598                         BehindSouthWest, BehindSouth, BehindSouthEast},
    00599                     //1 - AtRightBorder
    00600                     {   InFrontNorthWest, InFrontNorth, /*InFrontNorthEast,*/
    00601                         InFrontWest,      InFront,      /*InFrontEast,*/
    00602                         InFrontSouthWest, InFrontSouth, /*InFrontSouthEast,*/
    00603
    00604                         NorthWest, North, /*NorthEast,*/
    00605                         West,             /*East,*/
    00606                         SouthWest, South, /*SouthEast,*/
    00607
    00608                         BehindNorthWest, BehindNorth, /*BehindNorthEast,*/
    00609                         BehindWest,      Behind,      /*BehindEast,*/
    00610                         BehindSouthWest, BehindSouth, /*BehindSouthEast,*/
    00611                         Error, Error, Error, Error, Error, Error, Error, Error, Error},
    00612                     //2 - AtLeftBorder
    00613                     {   /*InFrontNorthWest,*/   InFrontNorth, InFrontNorthEast,
    00614                         /*InFrontWest,*/       InFront,      InFrontEast,
    00615                         /*InFrontSouthWest,*/   InFrontSouth, InFrontSouthEast,
    00616
    00617                         /*NorthWest,*/ North, NorthEast,
    00618                         /*West,*/            East,
    00619                         /*SouthWest,*/ South, SouthEast,
    00620
    00621                         /*BehindNorthWest,*/ BehindNorth, BehindNorthEast,
    00622                         /*BehindWest,*/     Behind,      BehindEast,
    00623                         /*BehindSouthWest,*/ BehindSouth, BehindSouthEast,
    00624                         Error, Error, Error, Error, Error, Error, Error, Error, Error},
    00625                     //3 - Nothin'
    00626                     {   Error, Error, Error, Error, Error, Error, Error, Error, Error,
    00627                         Error, Error, Error, Error,        Error, Error, Error, Error,
    00628                         Error, Error, Error, Error, Error, Error, Error, Error, Error},
    00629                     //4 - AtTopBorder
    00630                     {   /*InFrontNorthWest, InFrontNorth, InFrontNorthEast,*/
    00631                         InFrontWest,        InFront,      InFrontEast,
    00632                         InFrontSouthWest, InFrontSouth,   InFrontSouthEast,
    00633
    00634                         /*NorthWest, North, NorthEast,*/
    00635                         West,             East,
    00636                         SouthWest, South, SouthEast,
    00637
    00638                         /*BehindNorthWest, BehindNorth, BehindNorthEast,*/
    00639                         BehindWest,                 Behind,                 BehindEast,
    00640                         BehindSouthWest, BehindSouth, BehindSouthEast,
    00641                         Error, Error, Error, Error, Error, Error, Error, Error, Error},
    00642                     //5 - AtTopRightBorder
    00643                     {   /*InFrontNorthWest, InFrontNorth,   InFrontNorthEast,*/
    00644                         InFrontWest,        InFront,        /*InFrontEast,*/
    00645                         InFrontSouthWest, InFrontSouth,     /*InFrontSouthEast,*/
    00646
    00647                         /*NorthWest, North, NorthEast,*/
    00648                         West,             /*East,*/
    00649                         SouthWest, South, /*SouthEast,*/
    00650
    00651                         /*BehindNorthWest, BehindNorth, BehindNorthEast,*/
    00652                         BehindWest,        Behind,      /*BehindEast,*/
    00653                         BehindSouthWest, BehindSouth,   /*BehindSouthEast,*/
    00654                         Error, Error, Error, Error, Error, Error, Error, Error, Error,
    00655                         Error, Error, Error, Error, Error, Error},
    00656                     //6 - AtTopLeftBorder
    00657                     {   /*InFrontNorthWest,     InFrontNorth,   InFrontNorthEast,*/
    00658                         /*InFrontWest,*/        InFront,        InFrontEast,
    00659                         /*InFrontSouthWest,*/   InFrontSouth,   InFrontSouthEast,
    00660
    00661                         /*NorthWest,    North,  NorthEast,*/
    00662                         /*West,*/               East,
    00663                         /*SouthWest,*/  South,  SouthEast,
    00664
    00665                         /*BehindNorthWest,      BehindNorth, BehindNorthEast,*/
    00666                         /*BehindWest, */        Behind,      BehindEast,
    00667                         /*BehindSouthWest,*/    BehindSouth, BehindSouthEast,
    00668                         Error, Error, Error, Error, Error, Error, Error, Error, Error,
    00669                         Error, Error, Error, Error, Error, Error},
    00670                     //7 - Nothin'
    00671                     {   Error, Error, Error, Error, Error, Error, Error, Error, Error,
    00672                         Error, Error, Error, Error, Error, Error, Error, Error,
    00673                         Error, Error, Error, Error, Error, Error, Error, Error, Error},
    00674                     //8 - AtBottomBorder
    00675                     {   InFrontNorthWest, InFrontNorth,    InFrontNorthEast,
    00676                         InFrontWest,      InFront,         InFrontEast,
    00677                         /*InFrontSouthWest, InFrontSouth, InFrontSouthEast,*/
    00678
    00679                         NorthWest,      North,  NorthEast,
    00680                         West,                   East,
    00681                         /*SouthWest,    South,  SouthEast,*/
    00682
    00683                         BehindNorthWest,    BehindNorth, BehindNorthEast,
    00684                         BehindWest,         Behind,      BehindEast,
    00685                         /*BehindSouthWest,  BehindSouth, BehindSouthEast*/
    00686                         Error, Error, Error, Error, Error, Error, Error, Error, Error},
    00687                     //9 - AtBottomRightBorder
    00688                     {   InFrontNorthWest, InFrontNorth,    /*InFrontNorthEast,*/
    00689                         InFrontWest,      InFront,         /*InFrontEast,*/
    00690                         /*InFrontSouthWest, InFrontSouth,  InFrontSouthEast,*/
    00691
    00692                         NorthWest, North,   /*NorthEast,*/
    00693                         West,               /*East,*/
    00694                         /*SouthWest, South, SouthEast,*/
    00695
    00696                         BehindNorthWest, BehindNorth,   /*BehindNorthEast,*/
    00697                         BehindWest,      Behind,        /*BehindEast,*/
    00698                         /*BehindSouthWest, BehindSouth, BehindSouthEast*/
    00699                         Error, Error, Error, Error, Error, Error, Error, Error, Error,
    00700                         Error, Error, Error, Error, Error, Error},
    00701                     //10 - AtBottomLeftBorder
    00702                     {   /*InFrontNorthWest,*/   InFrontNorth,   InFrontNorthEast,
    00703                         /*InFrontWest,*/        InFront,        InFrontEast,
    00704                         /*InFrontSouthWest,     InFrontSouth,   InFrontSouthEast,*/
    00705
    00706                         /*NorthWest,*/  North,  NorthEast,
    00707                         /*West,*/               East,
    00708                         /*SouthWest,    South,  SouthEast,*/
    00709
    00710                         /*BehindNorthWest,*/ BehindNorth,   BehindNorthEast,
    00711                         /*BehindWest,*/      Behind,        BehindEast,
    00712                         /*BehindSouthWest, BehindSouth,     BehindSouthEast*/
    00713                         Error, Error, Error, Error, Error, Error, Error, Error, Error,
    00714                         Error, Error, Error, Error, Error, Error},
    00715                     //11 - Nothin'
    00716                     {   Error, Error, Error, Error, Error, Error, Error, Error, Error,
    00717                         Error, Error, Error, Error, Error, Error, Error, Error,
    00718                         Error, Error, Error, Error, Error, Error, Error, Error, Error},
    00719                     //12 - Nothin'
    00720                     {   Error, Error, Error, Error, Error, Error, Error, Error, Error,
    00721                         Error, Error, Error, Error, Error, Error, Error, Error,
    00722                         Error, Error, Error, Error, Error, Error, Error, Error, Error},
    00723                     //13 - Nothin'
    00724                     {   Error, Error, Error, Error, Error, Error, Error, Error, Error,
    00725                         Error, Error, Error, Error, Error, Error, Error, Error,
    00726                         Error, Error, Error, Error, Error, Error, Error, Error, Error},
    00727                     //14 - Nothin'
    00728                     {   Error, Error, Error, Error, Error, Error, Error, Error, Error,
    00729                         Error, Error, Error, Error, Error, Error, Error, Error,
    00730                         Error, Error, Error, Error, Error, Error, Error, Error, Error},
    00731                     //15 - Nothin'
    00732                     {   Error, Error, Error, Error, Error, Error, Error, Error, Error,
    00733                         Error, Error, Error, Error, Error, Error, Error, Error,
    00734                         Error, Error, Error, Error, Error, Error, Error, Error, Error},
    00735                     //16 - AtFrontBorder
    00736                     {   /*InFrontNorthWest, InFrontNorth,    InFrontNorthEast,
    00737                         InFrontWest,        InFront,         InFrontEast,
    00738                         InFrontSouthWest, InFrontSouth, InFrontSouthEast,*/
    00739
    00740                         NorthWest, North, NorthEast,
    00741                         West,             East,
    00742                         SouthWest, South, SouthEast,
    00743
    00744                         BehindNorthWest, BehindNorth, BehindNorthEast,
    00745                         BehindWest,      Behind,      BehindEast,
    00746                         BehindSouthWest, BehindSouth, BehindSouthEast,
    00747                         Error, Error, Error, Error, Error, Error, Error, Error, Error},
    00748                     //17 - AtFrontRightBorder
    00749                     {   /*InFrontNorthWest, InFrontNorth,    InFrontNorthEast,
    00750                         InFrontWest,              InFront,                 InFrontEast,
    00751                         InFrontSouthWest, InFrontSouth, InFrontSouthEast,*/
    00752
    00753                         NorthWest, North, /*NorthEast,*/
    00754                         West,             /*East,*/
    00755                         SouthWest, South, /*SouthEast,*/
    00756
    00757                         BehindNorthWest, BehindNorth, /*BehindNorthEast,*/
    00758                         BehindWest,      Behind,      /*BehindEast,*/
    00759                         BehindSouthWest, BehindSouth, /*BehindSouthEast,*/
    00760                         Error, Error, Error, Error, Error, Error, Error, Error, Error,
    00761                         Error, Error, Error, Error, Error, Error},
    00762                     //18 - AtFrontLeftBorder
    00763                     {   /*InFrontNorthWest, InFrontNorth,   InFrontNorthEast,
    00764                         InFrontWest,        InFront,        InFrontEast,
    00765                         InFrontSouthWest,   InFrontSouth,   InFrontSouthEast,*/
    00766
    00767                         /*NorthWest,*/ North, NorthEast,
    00768                         /*West,*/             East,
    00769                         /*SouthWest,*/ South, SouthEast,
    00770
    00771                         /*BehindNorthWest,*/ BehindNorth, BehindNorthEast,
    00772                         /*BehindWest,*/      Behind,      BehindEast,
    00773                         /*BehindSouthWest,*/ BehindSouth, BehindSouthEast,
    00774                         Error, Error, Error, Error, Error, Error, Error, Error, Error,
    00775                         Error, Error, Error, Error, Error, Error},
    00776                     //19 - Nothin'
    00777                     {   Error, Error, Error, Error, Error, Error, Error, Error, Error,
    00778                         Error, Error, Error, Error, Error, Error, Error, Error,
    00779                         Error, Error, Error, Error, Error, Error, Error, Error, Error},
    00780                     //20 - AtTopFrontBorder
    00781                     {   /*InFrontNorthWest, InFrontNorth,   InFrontNorthEast,
    00782                         InFrontWest,        InFront,        InFrontEast,
    00783                         InFrontSouthWest,   InFrontSouth,   InFrontSouthEast,*/
    00784
    00785                         /*NorthWest,    North,  NorthEast,*/
    00786                         West,                   East,
    00787                         SouthWest,      South,  SouthEast,
    00788
    00789                         /*BehindNorthWest,  BehindNorth,    BehindNorthEast,*/
    00790                         BehindWest,         Behind,         BehindEast,
    00791                         BehindSouthWest,    BehindSouth,    BehindSouthEast,
    00792                         Error, Error, Error, Error, Error, Error, Error, Error, Error,
    00793                         Error, Error, Error, Error, Error, Error},
    00794                     //21 - AtTopRightFrontBorder
    00795                     {   /*InFrontNorthWest, InFrontNorth,  InFrontNorthEast,
    00796                         InFrontWest,        InFront,       InFrontEast,
    00797                         InFrontSouthWest,   InFrontSouth,  InFrontSouthEast,*/
    00798
    00799                         /*NorthWest, North, NorthEast,*/
    00800                         West,               /*East,*/
    00801                         SouthWest,   South, /*SouthEast,*/
    00802
    00803                         /*BehindNorthWest, BehindNorth, BehindNorthEast,*/
    00804                         BehindWest,        Behind,      /*BehindEast,*/
    00805                         BehindSouthWest, BehindSouth,   /*BehindSouthEast,*/
    00806                         Error, Error, Error, Error, Error, Error, Error, Error, Error,
    00807                         Error, Error, Error, Error, Error, Error,
    00808                         Error, Error, Error, Error},
    00809                     //22 - AtTopLeftFrontBorder
    00810                     {   /*InFrontNorthWest, InFrontNorth,   InFrontNorthEast,
    00811                         InFrontWest,        InFront,        InFrontEast,
    00812                         InFrontSouthWest,   InFrontSouth,   InFrontSouthEast,*/
    00813
    00814                         /*NorthWest,    North, NorthEast,*/
    00815                         /*West,*/              East,
    00816                         /*SouthWest,*/  South, SouthEast,
    00817
    00818                         /*BehindNorthWest,      BehindNorth, BehindNorthEast,*/
    00819                         /*BehindWest,*/         Behind,      BehindEast,
    00820                         /*BehindSouthWest,*/    BehindSouth, BehindSouthEast,
    00821                         Error, Error, Error, Error, Error, Error, Error, Error, Error,
    00822                         Error, Error, Error, Error, Error, Error,
    00823                         Error, Error, Error, Error},
    00824                     //23 - Nothin'
    00825                     {   Error, Error, Error, Error, Error, Error, Error, Error, Error,
    00826                         Error, Error, Error, Error, Error, Error, Error, Error,
    00827                         Error, Error, Error, Error, Error, Error, Error, Error, Error},
    00828                     //24 - AtBottomFrontBorder
    00829                     {   /*InFrontNorthWest, InFrontNorth, InFrontNorthEast,
    00830                         InFrontWest,        InFront,      InFrontEast,
    00831                         InFrontSouthWest,   InFrontSouth, InFrontSouthEast,*/
    00832
    00833                         NorthWest,      North, NorthEast,
    00834                         West,                  East,
    00835                         /*SouthWest,    South, SouthEast,*/
    00836
    00837                         BehindNorthWest,    BehindNorth, BehindNorthEast,
    00838                         BehindWest,         Behind,      BehindEast,
    00839                         /*BehindSouthWest,  BehindSouth, BehindSouthEast*/
    00840                         Error, Error, Error, Error, Error, Error, Error, Error, Error,
    00841                         Error, Error, Error, Error, Error, Error},
    00842                     //25 - AtBottomRightFrontBorder
    00843                     {   /*InFrontNorthWest, InFrontNorth,    InFrontNorthEast,
    00844                         InFrontWest,        InFront,         InFrontEast,
    00845                         InFrontSouthWest, InFrontSouth, InFrontSouthEast,*/
    00846
    00847                         NorthWest,      North,  /*NorthEast,*/
    00848                         West,                   /* East,*/
    00849                         /*SouthWest,    South,  SouthEast,*/
    00850
    00851                         BehindNorthWest,    BehindNorth, /*BehindNorthEast,*/
    00852                         BehindWest,         Behind,      /*BehindEast,*/
    00853                         /*BehindSouthWest,  BehindSouth, BehindSouthEast*/
    00854                         Error, Error, Error, Error, Error, Error, Error, Error, Error,
    00855                         Error, Error, Error, Error, Error, Error,
    00856                         Error, Error, Error, Error},
    00857                     //26 - AtBottomLeftFrontBorder
    00858                     { /*InFrontNorthWest, InFrontNorth, InFrontNorthEast,
    00859                         InFrontWest,      InFront,      InFrontEast,
    00860                         InFrontSouthWest, InFrontSouth, InFrontSouthEast,*/
    00861
    00862                         /*NorthWest,*/ North, NorthEast,
    00863                         /*West,*/             East,
    00864                         /*SouthWest,   South, SouthEast,*/
    00865
    00866                         /*BehindNorthWest,*/ BehindNorth, BehindNorthEast,
    00867                         /*BehindWest,*/      Behind,      BehindEast,
    00868                         /*BehindSouthWest,   BehindSouth, BehindSouthEast*/
    00869                         Error, Error, Error, Error, Error, Error, Error, Error, Error,
    00870                         Error, Error, Error, Error, Error, Error,
    00871                         Error, Error, Error, Error},
    00872                     //27 - Nothin'
    00873                     {   Error, Error, Error, Error, Error, Error, Error, Error, Error,
    00874                         Error, Error, Error, Error, Error, Error, Error, Error,
    00875                         Error, Error, Error, Error, Error, Error, Error, Error, Error},
    00876                     //28 - Nothin'
    00877                     {   Error, Error, Error, Error, Error, Error, Error, Error, Error,
    00878                         Error, Error, Error, Error, Error, Error, Error, Error,
    00879                         Error, Error, Error, Error, Error, Error, Error, Error, Error},
    00880                     //29 - Nothin'
    00881                     {   Error, Error, Error, Error, Error, Error, Error, Error, Error,
    00882                         Error, Error, Error, Error, Error, Error, Error, Error,
    00883                         Error, Error, Error, Error, Error, Error, Error, Error, Error},
    00884                     //30 - Nothin'
    00885                     {   Error, Error, Error, Error, Error, Error, Error, Error, Error,
    00886                         Error, Error, Error, Error, Error, Error, Error, Error,
    00887                         Error, Error, Error, Error, Error, Error, Error, Error, Error},
    00888                     //31 - Nothin'
    00889                     {   Error, Error, Error, Error, Error, Error, Error, Error, Error,
    00890                         Error, Error, Error, Error, Error, Error, Error, Error,
    00891                         Error, Error, Error, Error, Error, Error, Error, Error, Error},
    00892                     //32 - AtRearBorder
    00893                     {   InFrontNorthWest, InFrontNorth, InFrontNorthEast,
    00894                         InFrontWest,      InFront,      InFrontEast,
    00895                         InFrontSouthWest, InFrontSouth, InFrontSouthEast,
    00896
    00897                         NorthWest, North, NorthEast,
    00898                         West,             East,
    00899                         SouthWest, South, SouthEast,
    00900
    00901                         /*BehindNorthWest, BehindNorth, BehindNorthEast,
    00902                         BehindWest,        Behind,      BehindEast,
    00903                         BehindSouthWest,   BehindSouth, BehindSouthEast,*/
    00904                         Error, Error, Error, Error, Error, Error, Error, Error, Error},
    00905                     //33 - AtRearRightBorder
    00906                     {   InFrontNorthWest, InFrontNorth, /*InFrontNorthEast,*/
    00907                         InFrontWest,      InFront,      /*InFrontEast,*/
    00908                         InFrontSouthWest, InFrontSouth, /*InFrontSouthEast,*/
    00909
    00910                         NorthWest, North, /*NorthEast,*/
    00911                         West,             /*East,*/
    00912                         SouthWest, South, /*SouthEast,*/
    00913
    00914                         /*BehindNorthWest, BehindNorth, BehindNorthEast,
    00915                         BehindWest,        Behind,      BehindEast,
    00916                         BehindSouthWest,   BehindSouth, BehindSouthEast,*/
    00917                         Error, Error, Error, Error, Error, Error, Error, Error, Error,
    00918                         Error, Error, Error, Error, Error, Error},
    00919                     //34 - AtRearLeftBorder
    00920                     {   /*InFrontNorthWest,*/ InFrontNorth, InFrontNorthEast,
    00921                         /*InFrontWest,*/      InFront,      InFrontEast,
    00922                         /*InFrontSouthWest,*/ InFrontSouth, InFrontSouthEast,
    00923
    00924                         /*NorthWest,*/ North, NorthEast,
    00925                         /*West,*/             East,
    00926                         /*SouthWest,*/ South, SouthEast,
    00927
    00928                         /*BehindNorthWest, BehindNorth,   BehindNorthEast,
    00929                         BehindWest,        Behind,        BehindEast,
    00930                         BehindSouthWest,   BehindSouth,   BehindSouthEast,*/
    00931                         Error, Error, Error, Error, Error, Error, Error, Error, Error,
    00932                         Error, Error, Error, Error, Error, Error},
    00933                     //35 - Nothin'
    00934                     {   Error, Error, Error, Error, Error, Error, Error, Error, Error,
    00935                         Error, Error, Error, Error, Error, Error, Error, Error,
    00936                         Error, Error, Error, Error, Error, Error, Error, Error, Error},
    00937                     //36 - AtTopRearBorder
    00938                     {   /*InFrontNorthWest, InFrontNorth,   InFrontNorthEast,*/
    00939                         InFrontWest,        InFront,        InFrontEast,
    00940                         InFrontSouthWest,   InFrontSouth,   InFrontSouthEast,
    00941
    00942                         /*NorthWest,    North, NorthEast,*/
    00943                         West,                  East,
    00944                         SouthWest,      South, SouthEast,
    00945
    00946                         /*BehindNorthWest, BehindNorth,   BehindNorthEast,
    00947                         BehindWest,        Behind,        BehindEast,
    00948                         BehindSouthWest,   BehindSouth,   BehindSouthEast,*/
    00949                         Error, Error, Error, Error, Error, Error, Error, Error, Error,
    00950                         Error, Error, Error, Error, Error, Error},
    00951                     //37 - AtTopRightRearBorder
    00952                     {   /*InFrontNorthWest, InFrontNorth,   InFrontNorthEast,*/
    00953                         InFrontWest,        InFront,        /*InFrontEast,*/
    00954                         InFrontSouthWest,   InFrontSouth,   /*InFrontSouthEast,*/
    00955
    00956                         /*NorthWest, North, NorthEast,*/
    00957                         West,               /*East,*/
    00958                         SouthWest,   South, /*SouthEast,*/
    00959
    00960                         /*BehindNorthWest,  BehindNorth, BehindNorthEast,
    00961                         BehindWest,         Behind,      BehindEast,
    00962                         BehindSouthWest,    BehindSouth, BehindSouthEast,*/
    00963                         Error, Error, Error, Error, Error, Error, Error, Error, Error,
    00964                         Error, Error, Error, Error, Error, Error,
    00965                         Error, Error, Error, Error},
    00966                     //38 - AtTopLeftRearBorder
    00967                     {   /*InFrontNorthWest,     InFrontNorth,    InFrontNorthEast,*/
    00968                         /*InFrontWest,*/        InFront,         InFrontEast,
    00969                         /*InFrontSouthWest,*/   InFrontSouth,   InFrontSouthEast,
    00970
    00971                         /*NorthWest,    North,  NorthEast,*/
    00972                         /*West,*/               East,
    00973                         /*SouthWest,*/  South,  SouthEast,
    00974
    00975                         /*BehindNorthWest,  BehindNorth,    BehindNorthEast,
    00976                         BehindWest,         Behind,         BehindEast,
    00977                         BehindSouthWest,    BehindSouth,    BehindSouthEast,*/
    00978                         Error, Error, Error, Error, Error, Error, Error, Error, Error,
    00979                         Error, Error, Error, Error, Error, Error,
    00980                         Error, Error, Error, Error},
    00981                     //39 - Nothin'
    00982                     {   Error, Error, Error, Error, Error, Error, Error, Error, Error,
    00983                         Error, Error, Error, Error, Error, Error, Error, Error,
    00984                         Error, Error, Error, Error, Error, Error, Error, Error, Error},
    00985                     //40 - AtBottomRearBorder
    00986                     {   InFrontNorthWest,   InFrontNorth,   InFrontNorthEast,
    00987                         InFrontWest,        InFront,        InFrontEast,
    00988                         /*InFrontSouthWest, InFrontSouth,   InFrontSouthEast,*/
    00989
    00990                         NorthWest,      North, NorthEast,
    00991                         West,                  East,
    00992                         /*SouthWest,    South, SouthEast,*/
    00993
    00994                         /*BehindNorthWest,  BehindNorth, BehindNorthEast,
    00995                         BehindWest,         Behind,      BehindEast,
    00996                         BehindSouthWest,    BehindSouth, BehindSouthEast,*/
    00997                         Error, Error, Error, Error, Error, Error, Error, Error, Error,
    00998                         Error, Error, Error, Error, Error, Error},
    00999                     //41 - AtBottomRightRearBorder
    01000                     {   InFrontNorthWest,   InFrontNorth, /*InFrontNorthEast,*/
    01001                         InFrontWest,        InFront,      /*InFrontEast,*/
    01002                         /*InFrontSouthWest, InFrontSouth, InFrontSouthEast,*/
    01003
    01004                         NorthWest,   North, /*NorthEast,*/
    01005                         West,               /*East,*/
    01006                         /*SouthWest, South, SouthEast,*/
    01007
    01008                         /*BehindNorthWest, BehindNorth, BehindNorthEast,
    01009                         BehindWest,        Behind,      BehindEast,
    01010                         BehindSouthWest,   BehindSouth, BehindSouthEast,*/
    01011                         Error, Error, Error, Error, Error, Error, Error, Error, Error,
    01012                         Error, Error, Error, Error, Error, Error,
    01013                         Error, Error, Error, Error},
    01014                     //42 - AtBottomLeftRearBorder
    01015                     {   /*InFrontNorthWest,*/   InFrontNorth,   InFrontNorthEast,
    01016                         /*InFrontWest,*/        InFront,        InFrontEast,
    01017                         /*InFrontSouthWest,     InFrontSouth,   InFrontSouthEast,*/
    01018
    01019                         /*NorthWest,*/  North,  NorthEast,
    01020                         /*West,*/               East,
    01021                         /*SouthWest,    South,  SouthEast,*/
    01022
    01023                         /*BehindNorthWest,  BehindNorth, BehindNorthEast,
    01024                         BehindWest,         Behind,      BehindEast,
    01025                         BehindSouthWest,    BehindSouth, BehindSouthEast,*/
    01026                         Error, Error, Error, Error, Error, Error, Error, Error, Error,
    01027                         Error, Error, Error, Error, Error, Error,
    01028                         Error, Error, Error, Error}
    01029                };
    01030         return c[b][index];
    01031     }
    01032
    01033     /** The valid direction three codes in anti causal direction (means: look back in scanline
    01034         direction)when the center is at the volume border.
    01035             Should be used with isAtVolumeBorderCausal to determine the Directions, as this
    01036             avoids using of the nonesense border ids (e.g. 0,1,8,9...) of this table.
    01037         \a index must be in the range <tt>0...nearBorderDirectionCount(b)-1</tt>.
    01038      */
    01039     static Direction nearBorderDirectionsCausal(AtVolumeBorder b, int index)
    01040     {
    01041         static Direction c[43][13] = {
    01042             //0 - NotAtBorder -----> should never be used
    01043                                 { InFrontNorthWest, InFrontNorth,    InFrontNorthEast,
    01044                                   InFrontWest,      InFront,         InFrontEast,
    01045                                   InFrontSouthWest, InFrontSouth,    InFrontSouthEast,
    01046
    01047                                   NorthWest,        North,           NorthEast,
    01048                                   West},
    01049             //1 - AtRightBorder
    01050                                 { InFrontNorthWest, InFrontNorth,    /* InFrontNorthEast, */
    01051                                   InFrontWest,      InFront,         /* InFrontEast, */
    01052                                   InFrontSouthWest, InFrontSouth,    /* InFrontSouthEast, */
    01053
    01054                                   NorthWest,        North,           /* NorthEast, */
    01055                                   West,
    01056                                   Error, Error, Error, Error},
    01057             //2 - AtLeftBorder
    01058                                 { /*InFrontNorthWest,*/ InFrontNorth,InFrontNorthEast,
    01059                                   /*InFrontWest,*/  InFront,         InFrontEast,
    01060                                   /*InFrontSouthWest,*/InFrontSouth, InFrontSouthEast,
    01061
    01062                                   /*NorthWest,*/    North,           NorthEast,
    01063                                   /*West*/
    01064                                   Error, Error, Error, Error, Error},
    01065             //3 - Nothin'
    01066                                 { Error, Error, Error, Error, Error, Error, Error, Error, Error, Error, Error, Error, Error},
    01067             //4 - AtTopBorder
    01068                                 { /*InFrontNorthWest,InFrontNorth,   InFrontNorthEast,*/
    01069                                   InFrontWest,       InFront,        InFrontEast,
    01070                                   InFrontSouthWest,  InFrontSouth,   InFrontSouthEast,
    01071
    01072                                   /*NorthWest,       North,          NorthEast,*/
    01073                                   West,
    01074                                   Error, Error, Error, Error, Error, Error},
    01075             //5 - AtTopRightBorder
    01076                                 { /*InFrontNorthWest,InFrontNorth,   InFrontNorthEast,*/
    01077                                   InFrontWest,       InFront,        /*InFrontEast,*/
    01078                                   InFrontSouthWest,  InFrontSouth,   /*InFrontSouthEast,*/
    01079
    01080                                   /*NorthWest, North, NorthEast,*/
    01081                                   West,
    01082                                   Error, Error, Error, Error, Error, Error, Error, Error},
    01083             //6 - AtTopLeftBorder
    01084                                 { /*InFrontNorthWest,InFrontNorth,    InFrontNorthEast,*/
    01085                                   /*InFrontWest,*/   InFront,         InFrontEast,
    01086                                   /*InFrontSouthWest,*/InFrontSouth,  InFrontSouthEast,
    01087
    01088                                   /*NorthWest,       North,           NorthEast,*/
    01089                                   /*West,*/
    01090                                   Error, Error, Error, Error, Error, Error, Error, Error, Error},
    01091             //7 - Nothin'
    01092                                 { Error, Error, Error, Error, Error, Error, Error, Error, Error, Error, Error, Error, Error},
    01093             //8 - AtBottomBorder
    01094                                 { InFrontNorthWest,  InFrontNorth,    InFrontNorthEast,
    01095                                   InFrontWest,       InFront,         InFrontEast,
    01096                                   /* InFrontSouthWest,  InFrontSouth,    InFrontSouthEast, */
    01097
    01098                                   NorthWest,         North,           NorthEast,
    01099                                   West,
    01100                                   Error, Error, Error},
    01101             //9 - AtBottomRightBorder
    01102                                 { InFrontNorthWest, InFrontNorth,    /* InFrontNorthEast, */
    01103                                   InFrontWest,      InFront,         /* InFrontEast, */
    01104                                   /* InFrontSouthWest, InFrontSouth,    InFrontSouthEast, */
    01105
    01106                                   NorthWest,        North,           /* NorthEast, */
    01107                                   West,
    01108                                   Error, Error, Error,Error, Error, Error},
    01109             //10 - AtBottomLeftBorder
    01110                                 { /*InFrontNorthWest,*/InFrontNorth, InFrontNorthEast,
    01111                                   /*InFrontWest,*/  InFront,         InFrontEast,
    01112                                   /*InFrontSouthWest, InFrontSouth, InFrontSouthEast, */
    01113
    01114                                   /*NorthWest,*/    North,           NorthEast,
    01115                                   /*West*/
    01116                                   Error, Error, Error, Error, Error, Error, Error},
    01117             //11 - Nothin'
    01118                                 { Error, Error, Error, Error, Error, Error, Error, Error, Error, Error, Error, Error, Error},
    01119             //12 - Nothin'
    01120                                 { Error, Error, Error, Error, Error, Error, Error, Error, Error, Error, Error, Error, Error},
    01121             //13 - Nothin'
    01122                                 { Error, Error, Error, Error, Error, Error, Error, Error, Error, Error, Error, Error, Error},
    01123             //14 - Nothin'
    01124                                 { Error, Error, Error, Error, Error, Error, Error, Error, Error, Error, Error, Error, Error},
    01125             //15 - Nothin'
    01126                                 { Error, Error, Error, Error, Error, Error, Error, Error, Error, Error, Error, Error, Error},
    01127             //16 - AtFrontBorder
    01128                                 { /*InFrontNorthWest,InFrontNorth,   InFrontNorthEast,
    01129                                   InFrontWest,      InFront,         InFrontEast,
    01130                                   InFrontSouthWest, InFrontSouth,    InFrontSouthEast,*/
    01131
    01132                                   NorthWest,        North,           NorthEast,
    01133                                   West,
    01134                                   Error, Error, Error, Error, Error, Error, Error, Error, Error},
    01135             //17 - AtFrontRightBorder
    01136                                 { /*InFrontNorthWest,InFrontNorth,   InFrontNorthEast,
    01137                                   InFrontWest,      InFront,         InFrontEast,
    01138                                   InFrontSouthWest, InFrontSouth,    InFrontSouthEast,*/
    01139
    01140                                   NorthWest,        North,           /*NorthEast,*/
    01141                                   West,
    01142                                   Error, Error, Error, Error, Error, Error, Error, Error, Error, Error},
    01143             //18 - AtFrontLeftBorder
    01144                                 { /*InFrontNorthWest,InFrontNorth,   InFrontNorthEast,
    01145                                   InFrontWest,      InFront,         InFrontEast,
    01146                                   InFrontSouthWest, InFrontSouth,    InFrontSouthEast,*/
    01147
    01148                                   /*NorthWest,*/    North,           NorthEast,
    01149                                   /*West,*/
    01150                                   Error, Error, Error, Error, Error, Error, Error, Error, Error, Error, Error},
    01151             //19 - Nothin'
    01152                                 { Error, Error, Error, Error, Error, Error, Error, Error, Error, Error, Error, Error, Error},
    01153             //20 - AtTopFrontBorder
    01154                                 { /*InFrontNorthWest,InFrontNorth,   InFrontNorthEast,
    01155                                   InFrontWest,      InFront,         InFrontEast,
    01156                                   InFrontSouthWest, InFrontSouth,    InFrontSouthEast,*/
    01157
    01158                                   /*NorthWest, North, NorthEast,*/
    01159                                   West,
    01160                                   Error, Error, Error, Error, Error, Error, Error, Error, Error, Error, Error, Error},
    01161             //21 - AtTopRightFrontBorder
    01162                                 { /*InFrontNorthWest, InFrontNorth,  InFrontNorthEast,
    01163                                   InFrontWest,        InFront,       InFrontEast,
    01164                                   InFrontSouthWest,   InFrontSouth,  InFrontSouthEast,*/
    01165
    01166                                   /*NorthWest,        North,         NorthEast,*/
    01167                                   West,
    01168                                   Error, Error, Error, Error, Error, Error, Error, Error, Error, Error, Error, Error},
    01169             //22 - AtTopLeftFrontBorder
    01170                                 { Error, Error, Error, Error, Error, Error, Error, Error, Error, Error, Error, Error, Error},
    01171             //23 - Nothin
    01172                                 { Error, Error, Error, Error, Error, Error, Error, Error, Error, Error, Error, Error, Error},
    01173             //24 - AtBottomFrontBorder
    01174                                 { /*InFrontNorthWest, InFrontNorth,  InFrontNorthEast,
    01175                                   InFrontWest,        InFront,       InFrontEast,
    01176                                   InFrontSouthWest,   InFrontSouth,  InFrontSouthEast,*/
    01177
    01178                                   NorthWest,          North,         NorthEast,
    01179                                   West,
    01180                                   Error, Error, Error, Error, Error, Error, Error, Error, Error},
    01181             //25 - AtBottomRightFrontBorder
    01182                                 { /*InFrontNorthWest, InFrontNorth,  InFrontNorthEast,
    01183                                   InFrontWest,        InFront,       InFrontEast,
    01184                                   InFrontSouthWest,   InFrontSouth,  InFrontSouthEast,*/
    01185
    01186                                   NorthWest,          North,         /*NorthEast,*/
    01187                                   West,
    01188                                   Error, Error, Error, Error, Error, Error, Error, Error, Error, Error},
    01189             //26 - AtBottomLeftFrontBorder
    01190                                 { /*InFrontNorthWest, InFrontNorth,  InFrontNorthEast,
    01191                                   InFrontWest,        InFront,       InFrontEast,
    01192                                   InFrontSouthWest,   InFrontSouth,  InFrontSouthEast,*/
    01193
    01194                                   /*NorthWest,*/      North,         NorthEast,
    01195                                   /* West, */
    01196                                   Error, Error, Error, Error, Error, Error, Error, Error, Error, Error, Error},
    01197             //27 - Nothin
    01198                                 { Error, Error, Error, Error, Error, Error, Error, Error, Error, Error, Error, Error, Error},
    01199             //28 - Nothin
    01200                                 { Error, Error, Error, Error, Error, Error, Error, Error, Error, Error, Error, Error, Error},
    01201             //29 - Nothin
    01202                                 { Error, Error, Error, Error, Error, Error, Error, Error, Error, Error, Error, Error, Error},
    01203             //30 - Nothin
    01204                                 { Error, Error, Error, Error, Error, Error, Error, Error, Error, Error, Error, Error, Error},
    01205             //31 - Nothin
    01206                                 { Error, Error, Error, Error, Error, Error, Error, Error, Error, Error, Error, Error, Error},
    01207             //32 - AtRearBorder
    01208                                 { InFrontNorthWest,   InFrontNorth,  InFrontNorthEast,
    01209                                   InFrontWest,        InFront,       InFrontEast,
    01210                                   InFrontSouthWest,   InFrontSouth,  InFrontSouthEast,
    01211
    01212                                   NorthWest,          North,         NorthEast,
    01213                                   West},
    01214             //33 - AtRearRightBorder
    01215                                 { InFrontNorthWest,   InFrontNorth,  InFrontNorthEast,
    01216                                   InFrontWest,        InFront,       InFrontEast,
    01217                                   InFrontSouthWest,   InFrontSouth,  InFrontSouthEast,
    01218
    01219                                   NorthWest,          North,         NorthEast,
    01220                                   West},
    01221             //34 - AtRearLeftBorder
    01222                                 { /*InFrontNorthWest,*/InFrontNorth, InFrontNorthEast,
    01223                                   /*InFrontWest,*/    InFront,       InFrontEast,
    01224                                   /*InFrontSouthWest,*/InFrontSouth, InFrontSouthEast,
    01225
    01226                                   /*NorthWest,*/      North,         NorthEast,
    01227                                   /*West*/
    01228                                   Error, Error, Error, Error, Error},
    01229             //35 - Nothin
    01230                                 { Error, Error, Error, Error, Error, Error, Error, Error, Error, Error, Error, Error, Error},
    01231             //36 - AtTopRearBorder
    01232                                 { /*InFrontNorthWest, InFrontNorth,  InFrontNorthEast,*/
    01233                                   InFrontWest,        InFront,       InFrontEast,
    01234                                   InFrontSouthWest,   InFrontSouth,  InFrontSouthEast,
    01235
    01236                                   /*NorthWest,        North,         NorthEast,*/
    01237                                   West,
    01238                                   Error, Error, Error, Error, Error, Error},
    01239             //37 - AtTopRightRearBorder
    01240                                 { /*InFrontNorthWest, InFrontNorth,  InFrontNorthEast,*/
    01241                                   InFrontWest,        InFront,       /*InFrontEast,*/
    01242                                   InFrontSouthWest,   InFrontSouth,  /*InFrontSouthEast,*/
    01243
    01244                                   /*NorthWest,        North,         NorthEast,*/
    01245                                   West,
    01246                                   Error, Error, Error, Error, Error, Error, Error, Error},
    01247             //38 - AtTopLeftRearBorder
    01248                                 { /*InFrontNorthWest, InFrontNorth,  InFrontNorthEast,*/
    01249                                   /*InFrontWest,*/    InFront,       InFrontEast,
    01250                                   /*InFrontSouthWest,*/InFrontSouth, InFrontSouthEast,
    01251
    01252                                   /*NorthWest, North, NorthEast,*/
    01253                                   /*West,*/
    01254                                   Error, Error, Error, Error, Error, Error, Error, Error, Error},
    01255             //39 - Nothin
    01256                                 { Error, Error, Error, Error, Error, Error, Error, Error, Error, Error, Error, Error, Error},
    01257             //40 - AtBottomRearBorder
    01258                                 { InFrontNorthWest,   InFrontNorth,  InFrontNorthEast,
    01259                                   InFrontWest,        InFront,       InFrontEast,
    01260                                   InFrontSouthWest,   InFrontSouth,  InFrontSouthEast,
    01261
    01262                                   NorthWest,          North,         NorthEast,
    01263                                   West},
    01264             //41 - AtBottomRightRearBorder
    01265                                 { InFrontNorthWest,  InFrontNorth,   InFrontNorthEast,
    01266                                   InFrontWest,       InFront,        InFrontEast,
    01267                                   InFrontSouthWest,  InFrontSouth,   InFrontSouthEast,
    01268
    01269                                   NorthWest,         North,          NorthEast,
    01270                                   West},
    01271             //42 - AtBottomLeftRearBorder
    01272                                 { /*InFrontNorthWest,*/InFrontNorth, InFrontNorthEast,
    01273                                   /*InFrontWest,*/   InFront,        InFrontEast,
    01274                                   /*InFrontSouthWest,InFrontSouth,   InFrontSouthEast,*/
    01275
    01276                                   /*NorthWest,*/     North,          NorthEast,
    01277                                   /*West*/
    01278                                   Error, Error, Error, Error, Error, Error, Error}
    01279         };
    01280         return c[b][index];
    01281     }
    01282
    01283     /** transform direction code into corresponding Diff3D offset.
    01284         (note: there is no bounds checking on the code you pass.)
    01285     */
    01286     static Diff3D const & diff(Direction code)
    01287     {
    01288         static Diff3D d[] = {   Diff3D( -1, -1, -1),  //InFrontNorthWest
    01289                                 Diff3D(  0, -1, -1),  //InFrontNorth
    01290                                 Diff3D(  1, -1, -1),  //InFrontNorthEast
    01291                                 Diff3D( -1,  0, -1),  //InFrontWest
    01292                                 Diff3D(  0,  0, -1),  //InFront
    01293                                 Diff3D(  1,  0, -1),  //InFrontEast
    01294                                 Diff3D( -1,  1, -1),  //InFrontSouthWest
    01295                                 Diff3D(  0,  1, -1),  //InFrontSouth
    01296                                 Diff3D(  1,  1, -1),  //InFrontSouthEast
    01297
    01298                                 Diff3D( -1, -1,  0),  //NorthWest
    01299                                 Diff3D(  0, -1,  0),  //North
    01300                                 Diff3D(  1, -1,  0),  //NorthEast
    01301                                 Diff3D( -1,  0,  0),  //West
    01302                                 Diff3D(  1,  0,  0),  //East
    01303                                 Diff3D( -1,  1,  0),  //SouthWest
    01304                                 Diff3D(  0,  1,  0),  //South
    01305                                 Diff3D(  1,  1,  0),  //SouthEast
    01306
    01307                                 Diff3D( -1, -1,  1),  //BehindNorthWest
    01308                                 Diff3D(  0, -1,  1),  //BehindNorth
    01309                                 Diff3D(  1, -1,  1),  //BehindNorthEast
    01310                                 Diff3D( -1,  0,  1),  //BehindWest
    01311                                 Diff3D(  0,  0,  1),  //Behind
    01312                                 Diff3D(  1,  0,  1),  //BehindEast
    01313                                 Diff3D( -1,  1,  1),  //BehindSouthWest
    01314                                 Diff3D(  0,  1,  1),  //BehindSouth
    01315                                 Diff3D(  1,  1,  1),  //BehindSouthEast
    01316                             };
    01317         return d[code];
    01318     }
    01319
    01320     /** Equivalent to <tt>diff(static_cast<Direction>(code))</tt>.
    01321         (note: there is no bounds checking on the code you pass.)
    01322     */
    01323     static Diff3D const & diff(int code) { return diff(static_cast<Direction>(code)); }
    01324
    01325     /**  Equivalent to <tt>diff(code)[dim]</tt> */
    01326     static int diff(Direction code, int dim) { return diff(code)[dim]; }
    01327
    01328     /** Get the relative offset from one neighbor to the other.
    01329     For example, <tt>relativeDiff(East, West) == multi_differencetype(-2,0,0)</tt>.
    01330     (note: there is no bounds checking on the code you pass.)
    01331     */
    01332     static Diff3D const relativeDiff(Direction fromCode, Direction toCode)
    01333     {
    01334         //Uncomment the following lines may cause the program to crash because of insufficient
    01335         //static allocatable memory on the stack
    01336         /*
    01337             static Diff3D d[][] = {
    01338                 //   InFront-NW    ---     InFront-N   ---     InFront-NE  ---    Infront-W    ---     InFront     ---   InFront-E     ---   InFront-SW    ---      InFront-S  ---   InFront-SE    ---    NorthWest   ---       North      ---    NorthEast    ---      West      ---       East       ---    SouthWest    ---    South        ---     SouthEast  ---     Behind-NW    ---     Behind-N    ---      Behind-NE  ---     Behind-W    ---      Behind     ---    Behind-E     ---    Behind-SW    ---      Behind-S   ---    Behind-SE
    01339                 {    Diff3D( 0,  0,  0),    Diff3D( 1,  0,  0),    Diff3D( 2,  0,  0),    Diff3D( 0,  1,  0),    Diff3D( 1,  1,  0),    Diff3D( 2,  1,  0),    Diff3D( 0,  2,  0),    Diff3D( 1,  2,  0),    Diff3D( 2, 2,  0),    Diff3D( 0,  0,  1),    Diff3D( 1,  0,  1),    Diff3D( 2,  0,  1),    Diff3D( 0,  1,  1),    Diff3D( 2,  1,  1),    Diff3D( 0,  2,  1),    Diff3D( 1,  2,  1),    Diff3D( 2,  2,  1),    Diff3D( 0,  0,  2),    Diff3D( 1,  0,  2),    Diff3D( 2,  0,  2),    Diff3D( 0,  1,  2),    Diff3D( 1,  1,  2), Diff3D( 2,  1,  2),    Diff3D( 0,  2,  2),    Diff3D( 1,  2,  2),    Diff3D( 2,  2,  2)    },    //InFront-NW
    01340                 {    Diff3D(-1,  0,  0),    Diff3D( 0,  0,  0),    Diff3D( 1,  0,  0),    Diff3D(-1,  1,  0),    Diff3D( 0,  1,  0),    Diff3D( 1,  1,  0),    Diff3D(-1,  2,  0),    Diff3D( 0,  2,  0),    Diff3D( 1, 2,  0),    Diff3D(-1,  0,  1),    Diff3D( 0,  0,  1),    Diff3D( 1,  0,  1),    Diff3D(-1,  1,  1),    Diff3D( 1,  1,  1),    Diff3D(-1,  2,  1),    Diff3D( 0,  2,  1),    Diff3D( 1,  2,  1),    Diff3D(-1,  0,  2),    Diff3D( 0,  0,  2),    Diff3D( 1,  0,  2),    Diff3D(-1,  1,  2),    Diff3D( 0,  1,  2), Diff3D( 1,  1,  2),    Diff3D(-1,  2,  2),    Diff3D( 0,  2,  2),    Diff3D( 1,  2,  2)    },    //InFront-N
    01341                 {    Diff3D(-2,  0,  0),    Diff3D(-1,  0,  0),    Diff3D( 0,  0,  0),    Diff3D(-2,  1,  0),    Diff3D(-1,  1,  0),    Diff3D( 0,  1,  0),    Diff3D(-2,  2,  0),    Diff3D(-1,  2,  0),    Diff3D( 0, 2,  0),    Diff3D(-2,  0,  1),    Diff3D(-1,  0,  1),    Diff3D( 0,  0,  1),    Diff3D(-2,  1,  1),    Diff3D( 0,  1,  1),    Diff3D(-2,  2,  1),    Diff3D(-1,  2,  1),    Diff3D( 0,  2,  1),    Diff3D(-2,  0,  2),    Diff3D(-1,  0,  2),    Diff3D( 0,  0,  2),    Diff3D(-2,  1,  2),    Diff3D(-1,  1,  2), Diff3D( 0,  1,  2),    Diff3D(-2,  2,  2),    Diff3D(-1,  2,  2),    Diff3D( 0,  2,  2)    },    //InFront-NE
    01342                 {    Diff3D(0,  -1,  0),    Diff3D( 1, -1,  0),    Diff3D( 2, -1,  0),    Diff3D( 0,  0,  0),    Diff3D( 1,  0,  0),    Diff3D( 2,  0,  0),    Diff3D( 0,  1,  0),    Diff3D( 1,  1,  0),    Diff3D( 2, 1,  0),    Diff3D( 0, -1,  1),    Diff3D( 1, -1,  1),    Diff3D( 2, -1,  1),    Diff3D( 0,  0,  1),    Diff3D( 2,  0,  1),    Diff3D( 0,  1,  1),    Diff3D( 1,  1,  1),    Diff3D( 2,  1,  1),    Diff3D( 0, -1,  2),    Diff3D( 1, -1,  2),    Diff3D( 2, -1,  2),    Diff3D( 0,  0,  2),    Diff3D( 1,  0,  2), Diff3D( 2,  0,  2),    Diff3D( 0,  1,  2),    Diff3D( 1,  1,  2),    Diff3D( 2,  1,  2)    },    //Infront-W
    01343                 {    Diff3D(-1, -1,  0),    Diff3D( 0, -1,  0),    Diff3D( 1, -1,  0),    Diff3D(-1,  0,  0),    Diff3D( 0,  0,  0),    Diff3D( 1,  0,  0),    Diff3D(-1,  1,  0),    Diff3D( 0,  1,  0),    Diff3D( 1, 1,  0),    Diff3D(-1, -1,  1),    Diff3D( 0, -1,  1),    Diff3D( 1, -1,  1),    Diff3D(-1,  0,  1),    Diff3D( 1,  0,  1),    Diff3D(-1,  1,  1),    Diff3D( 0,  1,  1),    Diff3D( 1,  1,  1),    Diff3D(-1, -1,  2),    Diff3D( 0, -1,  2),    Diff3D( 1, -1,  2),    Diff3D(-1,  0,  2),    Diff3D( 0,  0,  2), Diff3D( 1,  0,  2),    Diff3D(-1,  1,  2),    Diff3D( 0,  1,  2),    Diff3D( 1,  1,  2)    },    //InFront
    01344                 {    Diff3D(-2, -1,  0),    Diff3D(-1, -1,  0),    Diff3D( 0, -1,  0),    Diff3D(-2,  0,  0),    Diff3D(-1,  0,  0),    Diff3D( 0,  0,  0),    Diff3D(-2,  1,  0),    Diff3D(-1,  1,  0),    Diff3D( 0, 1,  0),    Diff3D(-2, -1,  1),    Diff3D(-1, -1,  1),    Diff3D( 0, -1,  1),    Diff3D(-2,  0,  1),    Diff3D( 0,  0,  1),    Diff3D(-2,  1,  1),    Diff3D(-1,  1,  1),    Diff3D( 0,  1,  1),    Diff3D(-2, -1,  2),    Diff3D(-1, -1,  2),    Diff3D( 0, -1,  2),    Diff3D(-2,  0,  2),    Diff3D(-1,  0,  2), Diff3D( 0,  0,  2),    Diff3D(-2,  1,  2),    Diff3D(-1,  1,  2),    Diff3D( 0,  1,  2)    },    //InFront-E
    01345                 {    Diff3D( 0, -2,  0),    Diff3D( 1, -2,  0),    Diff3D( 2, -2,  0),    Diff3D( 0, -1,  0),    Diff3D( 1, -1,  0),    Diff3D( 2, -1,  0),    Diff3D( 0,  0,  0),    Diff3D( 1,  0,  0),    Diff3D( 2, 0,  0),    Diff3D( 0, -2,  1),    Diff3D( 1, -2,  1),    Diff3D( 2, -2,  1),    Diff3D( 0, -1,  1),    Diff3D( 2, -1,  1),    Diff3D( 0,  0,  1),    Diff3D( 1,  0,  1),    Diff3D( 2,  0,  1),    Diff3D( 0, -2,  2),    Diff3D( 1, -2,  2),    Diff3D( 2, -2,  2),    Diff3D( 0, -1,  2),    Diff3D( 1, -1,  2), Diff3D( 2, -1,  2),    Diff3D( 0,  0,  2),    Diff3D( 1,  0,  2),    Diff3D( 2,  0,  2)    },    //InFront-SW
    01346                 {    Diff3D(-1, -2,  0),    Diff3D( 0, -2,  0),    Diff3D( 1, -2,  0),    Diff3D(-1, -1,  0),    Diff3D( 0, -1,  0),    Diff3D( 1, -1,  0),    Diff3D(-1,  0,  0),    Diff3D( 0,  0,  0),    Diff3D( 1, 0,  0),    Diff3D(-1, -2,  1),    Diff3D( 0, -2,  1),    Diff3D( 1, -2,  1),    Diff3D(-1, -1,  1),    Diff3D( 1, -1,  1),    Diff3D(-1,  0,  1),    Diff3D( 0,  0,  1),    Diff3D( 1,  0,  1),    Diff3D(-1, -2,  2),    Diff3D( 0, -2,  2),    Diff3D( 1, -2,  2),    Diff3D(-1, -1,  2),    Diff3D( 0, -1,  2), Diff3D( 1, -1,  2),    Diff3D(-1,  0,  2),    Diff3D( 0,  0,  2),    Diff3D( 1,  0,  2)    },    //InFront-S
    01347                 {    Diff3D(-2, -2,  0),    Diff3D(-1, -2,  0),    Diff3D( 0, -2,  0),    Diff3D(-2, -1,  0),    Diff3D(-1, -1,  0),    Diff3D( 0, -1,  0),    Diff3D(-2,  0,  0),    Diff3D(-1,  0,  0),    Diff3D( 0, 0,  0),    Diff3D(-2, -2,  1),    Diff3D(-1, -2,  1),    Diff3D( 0, -2,  1),    Diff3D(-2, -1,  1),    Diff3D( 0, -1,  1),    Diff3D(-2,  0,  1),    Diff3D(-1,  0,  1),    Diff3D( 0,  0,  1),    Diff3D(-2, -2,  2),    Diff3D(-1, -2,  2),    Diff3D( 0, -2,  2),    Diff3D(-2, -1,  2),    Diff3D(-1, -1,  2), Diff3D( 0, -1,  2),    Diff3D(-2,  0,  2),    Diff3D(-1,  0,  2),    Diff3D( 0,  0,  2)    },    //InFront-SE
    01348                 {    Diff3D( 0,  0, -1),    Diff3D( 1,  0, -1),    Diff3D( 2,  0, -1),    Diff3D( 0,  1, -1),    Diff3D( 1,  1, -1),    Diff3D( 2,  1, -1),    Diff3D( 0,  2, -1),    Diff3D( 1,  2, -1),    Diff3D( 2, 2, -1),    Diff3D( 0,  0,  0),    Diff3D( 1,  0,  0),    Diff3D( 2,  0,  0),    Diff3D( 0,  1,  0),    Diff3D( 2,  1,  0),    Diff3D( 0,  2,  0),    Diff3D( 1,  2,  0),    Diff3D( 2,  2,  0),    Diff3D( 0,  0,  1),    Diff3D( 1,  0,  1),    Diff3D( 2,  0,  1),    Diff3D( 0,  1,  1),    Diff3D( 1,  1,  1), Diff3D( 2,  1,  1),    Diff3D( 0,  2,  1),    Diff3D( 1,  2,  1),    Diff3D( 2,  2,  1)    },    //NorthWest
    01349                 {    Diff3D(-1,  0, -1),    Diff3D( 0,  0, -1),    Diff3D( 1,  0, -1),    Diff3D(-1,  1, -1),    Diff3D( 0,  1, -1),    Diff3D( 1,  1, -1),    Diff3D(-1,  2, -1),    Diff3D( 0,  2, -1),    Diff3D( 1, 2, -1),    Diff3D(-1,  0,  0),    Diff3D( 0,  0,  0),    Diff3D( 1,  0,  0),    Diff3D(-1,  1,  0),    Diff3D( 1,  1,  0),    Diff3D(-1,  2,  0),    Diff3D( 0,  2,  0),    Diff3D( 1,  2,  0),    Diff3D(-1,  0,  1),    Diff3D( 0,  0,  1),    Diff3D( 1,  0,  1),    Diff3D(-1,  1,  1),    Diff3D( 0,  1,  1), Diff3D( 1,  1,  1),    Diff3D(-1,  2,  1),    Diff3D( 0,  2,  1),    Diff3D( 1,  2,  1)    },    //North
    01350                 {    Diff3D(-2,  0, -1),    Diff3D(-1,  0, -1),    Diff3D( 0,  0, -1),    Diff3D(-2,  1, -1),    Diff3D(-1,  1, -1),    Diff3D( 0,  1, -1),    Diff3D(-2,  2, -1),    Diff3D(-1,  2, -1),    Diff3D( 0, 2, -1),    Diff3D(-2,  0,  0),    Diff3D(-1,  0,  0),    Diff3D( 0,  0,  0),    Diff3D(-2,  1,  0),    Diff3D( 0,  1,  0),    Diff3D(-2,  2,  0),    Diff3D(-1,  2,  0),    Diff3D( 0,  2,  0),    Diff3D(-2,  0,  1),    Diff3D(-1,  0,  1),    Diff3D( 0,  0,  1),    Diff3D(-2,  1,  1),    Diff3D(-1,  1,  1), Diff3D( 0,  1,  1),    Diff3D(-2,  2,  1),    Diff3D(-1,  2,  1),    Diff3D( 0,  2,  1)    },    //NortEast
    01351                 {    Diff3D( 0, -1, -1),    Diff3D( 1, -1, -1),    Diff3D( 2, -1, -1),    Diff3D( 0,  0, -1),    Diff3D( 1,  0, -1),    Diff3D( 2,  0, -1),    Diff3D( 0,  1, -1),    Diff3D( 1,  1, -1),    Diff3D( 2, 1, -1),    Diff3D( 0, -1,  0),    Diff3D( 1, -1,  0),    Diff3D( 2, -1,  0),    Diff3D( 0,  0,  0),    Diff3D( 2,  0,  0),    Diff3D( 0,  1,  0),    Diff3D( 1,  1,  0),    Diff3D( 2,  1,  0),    Diff3D( 0, -1,  1),    Diff3D( 1, -1,  1),    Diff3D( 2, -1,  1),    Diff3D( 0,  0,  1),    Diff3D( 1,  0,  1), Diff3D( 2,  0,  1),    Diff3D( 0,  1,  1),    Diff3D( 1,  1,  1),    Diff3D( 2,  1,  1)    },    //West
    01352                 {    Diff3D(-2, -1, -1),    Diff3D(-1, -1, -1),    Diff3D( 0, -1, -1),    Diff3D(-2,  0, -1),    Diff3D(-1,  0, -1),    Diff3D( 0,  0, -1),    Diff3D(-2,  1, -1),    Diff3D(-1,  1, -1),    Diff3D( 0, 1, -1),    Diff3D(-2, -1,  0),    Diff3D(-1, -1,  0),    Diff3D( 0, -1,  0),    Diff3D(-2,  0,  0),    Diff3D( 0,  0,  0),    Diff3D(-2,  1,  0),    Diff3D(-1,  1,  0),    Diff3D( 0,  1,  0),    Diff3D(-2, -1,  1),    Diff3D(-1, -1,  1),    Diff3D( 0, -1,  1),    Diff3D(-2,  0,  1),    Diff3D(-1,  0,  1), Diff3D( 0,  0,  1),    Diff3D(-2,  1,  1),    Diff3D(-1,  1,  1),    Diff3D( 0,  1,  1)    },    //East
    01353                 {    Diff3D( 0, -2, -1),    Diff3D( 1, -2, -1),    Diff3D( 2, -2, -1),    Diff3D( 0, -1, -1),    Diff3D( 1, -1, -1),    Diff3D( 2, -1, -1),    Diff3D( 0,  0, -1),    Diff3D( 1,  0, -1),    Diff3D( 2, 0, -1),    Diff3D( 0, -2,  0),    Diff3D( 1, -2,  0),    Diff3D( 2, -2,  0),    Diff3D( 0, -1,  0),    Diff3D( 2, -1,  0),    Diff3D( 0,  0,  0),    Diff3D( 1,  0,  0),    Diff3D( 2,  0,  0),    Diff3D( 0, -2,  1),    Diff3D( 1, -2,  1),    Diff3D( 2, -2,  1),    Diff3D( 0, -1,  1),    Diff3D( 1, -1,  1), Diff3D( 2, -1,  1),    Diff3D( 0,  0,  1),    Diff3D( 1,  0,  1),    Diff3D( 2,  0,  1)    },    //SouthWest
    01354                 {    Diff3D(-1, -2, -1),    Diff3D( 0, -2, -1),    Diff3D( 1, -2, -1),    Diff3D(-1, -1, -1),    Diff3D( 0, -1, -1),    Diff3D( 1, -1, -1),    Diff3D(-1,  0, -1),    Diff3D( 0,  0, -1),    Diff3D( 1, 0, -1),    Diff3D(-1, -2,  0),    Diff3D( 0, -2,  0),    Diff3D( 1, -2,  0),    Diff3D(-1, -1,  0),    Diff3D( 1, -1,  0),    Diff3D(-1,  0,  0),    Diff3D( 0,  0,  0),    Diff3D( 1,  0,  0),    Diff3D(-1, -2,  1),    Diff3D( 0, -2,  1),    Diff3D( 1, -2,  1),    Diff3D(-1, -1,  1),    Diff3D( 0, -1,  1), Diff3D( 1, -1,  1),    Diff3D(-1,  0,  1),    Diff3D( 0,  0,  1),    Diff3D( 1,  0,  1)    },    //South
    01355                 {    Diff3D(-2, -2, -1),    Diff3D(-1, -2, -1),    Diff3D( 0, -2, -1),    Diff3D(-2, -1, -1),    Diff3D(-1, -1, -1),    Diff3D( 0, -1, -1),    Diff3D(-2,  0, -1),    Diff3D(-1,  0, -1),    Diff3D( 0, 0, -1),    Diff3D(-2, -2,  0),    Diff3D(-1, -2,  0),    Diff3D( 0, -2,  0),    Diff3D(-2, -1,  0),    Diff3D( 0, -1,  0),    Diff3D(-2,  0,  0),    Diff3D(-1,  0,  0),    Diff3D( 0,  0,  0),    Diff3D(-2, -2,  1),    Diff3D(-1, -2,  1),    Diff3D( 0, -2,  1),    Diff3D(-2, -1,  1),    Diff3D(-1, -1,  1), Diff3D( 0, -1,  1),    Diff3D(-2,  0,  1),    Diff3D(-1,  0,  1),    Diff3D( 0,  0,  1)    },    //SouthEast
    01356                 {    Diff3D( 0,  0, -2),    Diff3D( 1,  0, -2),    Diff3D( 2,  0, -2),    Diff3D( 0,  1, -2),    Diff3D( 1,  1, -2),    Diff3D( 2,  1, -2),    Diff3D( 0,  2, -2),    Diff3D( 1,  2, -2),    Diff3D( 2, 2, -2),    Diff3D( 0,  0, -1),    Diff3D( 1,  0, -1),    Diff3D( 2,  0, -1),    Diff3D( 0,  1, -1),    Diff3D( 2,  1, -1),    Diff3D( 0,  2, -1),    Diff3D( 1,  2, -1),    Diff3D( 2,  2, -1),    Diff3D( 0,  0,  0),    Diff3D( 1,  0,  0),    Diff3D( 2,  0,  0),    Diff3D( 0,  1,  0),    Diff3D( 1,  1,  0),    Diff3D( 2,  1,  0),    Diff3D( 0,  2,  0),    Diff3D( 1,  2,  0),    Diff3D( 2,  2,  0)    },    //Behind-NW
    01357                 {    Diff3D(-1,  0, -2),    Diff3D( 0,  0, -2),    Diff3D( 1,  0, -2),    Diff3D(-1,  1, -2),    Diff3D( 0,  1, -2),    Diff3D( 1,  1, -2),    Diff3D(-1,  2, -2),    Diff3D( 0,  2, -2),    Diff3D( 1, 2, -2),    Diff3D(-1,  0, -1),    Diff3D( 0,  0, -1),    Diff3D( 1,  0, -1),    Diff3D(-1,  1, -1),    Diff3D( 1,  1, -1),    Diff3D(-1,  2, -1),    Diff3D( 0,  2, -1),    Diff3D( 1,  2, -1),    Diff3D(-1,  0,  0),    Diff3D( 0,  0,  0),    Diff3D( 1,  0,  0),    Diff3D(-1,  1,  0),    Diff3D( 0,  1,  0),    Diff3D( 1,  1,  0),    Diff3D(-1,  2,  0),    Diff3D( 0,  2,  0),    Diff3D( 1,  2,  0)    },    //Behind-N
    01358                 {    Diff3D(-2,  0, -2),    Diff3D(-1,  0, -2),    Diff3D( 0,  0, -2),    Diff3D(-2,  1, -2),    Diff3D(-1,  1, -2),    Diff3D( 0,  1, -2),    Diff3D(-2,  2, -2),    Diff3D(-1,  2, -2),    Diff3D( 0, 2, -2),    Diff3D(-2,  0, -1),    Diff3D(-1,  0, -1),    Diff3D( 0,  0, -1),    Diff3D(-2,  1, -1),    Diff3D( 0,  1, -1),    Diff3D(-2,  2, -1),    Diff3D(-1,  2, -1),    Diff3D( 0,  2, -1),    Diff3D(-2,  0,  0),    Diff3D(-1,  0,  0),    Diff3D( 0,  0,  0),    Diff3D(-2,  1,  0),    Diff3D(-1,  1,  0),    Diff3D( 0,  1,  0),    Diff3D(-2,  2,  0),    Diff3D(-1,  2,  0),    Diff3D( 0,  2,  0)    },    //Behind-NE
    01359                 {    Diff3D( 0, -1, -2),    Diff3D( 1, -1, -2),    Diff3D( 2, -1, -2),    Diff3D( 0,  0, -2),    Diff3D( 1,  0, -2),    Diff3D( 2,  0, -2),    Diff3D( 0,  1, -2),    Diff3D( 1,  1, -2),    Diff3D( 2, 1, -2),    Diff3D( 0, -1, -1),    Diff3D( 1, -1, -1),    Diff3D( 2, -1, -1),    Diff3D( 0,  0, -1),    Diff3D( 2,  0, -1),    Diff3D( 0,  1, -1),    Diff3D( 1,  1, -1),    Diff3D( 2,  1, -1),    Diff3D( 0, -1,  0),    Diff3D( 1, -1,  0),    Diff3D( 2, -1,  0),    Diff3D( 0,  0,  0),    Diff3D( 1,  0,  0), Diff3D( 2,  0,  0),    Diff3D( 0,  1,  0),    Diff3D( 1,  1,  0),    Diff3D( 2,  1,  0)    },    //Behind-W
    01360                 {    Diff3D(-1, -1, -2),    Diff3D( 0, -1, -2),    Diff3D( 1, -1, -2),    Diff3D(-1,  0, -2),    Diff3D( 0,  0, -2),    Diff3D( 1,  0, -2),    Diff3D(-1,  1, -2),    Diff3D( 0,  1, -2),    Diff3D( 1, 1, -2),    Diff3D(-1, -1, -1),    Diff3D( 0, -1, -1),    Diff3D( 1, -1, -1),    Diff3D(-1,  0, -1),    Diff3D( 1,  0, -1),    Diff3D(-1,  1, -1),    Diff3D( 0,  1, -1),    Diff3D( 1,  1, -1),    Diff3D(-1, -1,  0),    Diff3D( 0, -1,  0),    Diff3D( 1, -1,  0),    Diff3D(-1,  0,  0),    Diff3D( 0,  0,  0), Diff3D( 1,  0,  0),    Diff3D(-1,  1,  0),    Diff3D( 0,  1,  0),    Diff3D( 1,  1,  0)    },    //Behind
    01361                 {    Diff3D(-2, -1, -2),    Diff3D(-1, -1, -2),    Diff3D( 0, -1, -2),    Diff3D(-2,  0, -2),    Diff3D(-1,  0, -2),    Diff3D( 0,  0, -2),    Diff3D(-2,  1, -2),    Diff3D(-1,  1, -2),    Diff3D( 0, 1, -2),    Diff3D(-2, -1, -1),    Diff3D(-1, -1, -1),    Diff3D( 0, -1, -1),    Diff3D(-2,  0, -1),    Diff3D( 0,  0, -1),    Diff3D(-2,  1, -1),    Diff3D(-1,  1, -1),    Diff3D( 0,  1, -1),    Diff3D(-2, -1,  0),    Diff3D(-1, -1,  0),    Diff3D( 0, -1,  0),    Diff3D(-2,  0,  0),    Diff3D(-1,  0,  0), Diff3D( 0,  0,  0),    Diff3D(-2,  1,  0),    Diff3D(-1,  1,  0),    Diff3D( 0,  1,  0)    },    //Behind-E
    01362                 {    Diff3D( 0, -2, -2),    Diff3D( 1, -2, -2),    Diff3D( 2, -2, -2),    Diff3D( 0, -1, -2),    Diff3D( 1, -1, -2),    Diff3D( 2, -1, -2),    Diff3D( 0,  0, -2),    Diff3D( 1,  0, -2),    Diff3D( 2, 0, -2),    Diff3D( 0, -2, -1),    Diff3D( 1, -2, -1),    Diff3D( 2, -2, -1),    Diff3D( 0, -1, -1),    Diff3D( 2, -1, -1),    Diff3D( 0,  0, -1),    Diff3D( 1,  0, -1),    Diff3D( 2,  0, -1),    Diff3D( 0, -2,  0),    Diff3D( 1, -2,  0),    Diff3D( 2, -2,  0),    Diff3D( 0, -1,  0),    Diff3D( 1, -1,  0), Diff3D( 2, -1,  0),    Diff3D( 0,  0,  0),    Diff3D( 1,  0,  0),    Diff3D( 2,  0,  0)    },    //Behind-SW
    01363                 {    Diff3D(-1, -2, -2),    Diff3D( 0, -2, -2),    Diff3D( 1, -2, -2),    Diff3D(-1, -1, -2),    Diff3D( 0, -1, -2),    Diff3D( 1, -1, -2),    Diff3D(-1,  0, -2),    Diff3D( 0,  0, -2),    Diff3D( 1, 0, -2),    Diff3D(-1, -2, -1),    Diff3D( 0, -2, -1),    Diff3D( 1, -2, -1),    Diff3D(-1, -1, -1),    Diff3D( 1, -1, -1),    Diff3D(-1,  0, -1),    Diff3D( 0,  0, -1),    Diff3D( 1,  0, -1),    Diff3D(-1, -2,  0),    Diff3D( 0, -2,  0),    Diff3D( 1, -2,  0),    Diff3D(-1, -1,  0),    Diff3D( 0, -1,  0), Diff3D( 1, -1,  0),    Diff3D(-1,  0,  0),    Diff3D( 0,  0,  0),    Diff3D( 1,  0,  0)    },    //Behind-S
    01364                 {    Diff3D(-2, -2, -2),    Diff3D(-1, -2, -2),    Diff3D( 0, -2, -2),    Diff3D(-2, -1, -2),    Diff3D(-1, -1, -2),    Diff3D( 0, -1, -2),    Diff3D(-2,  0, -2),    Diff3D(-1,  0, -2),    Diff3D( 0, 0, -2),    Diff3D(-2, -2, -1),    Diff3D(-1, -2, -1),    Diff3D( 0, -2, -1),    Diff3D(-2, -1, -1),    Diff3D( 0, -1, -1),    Diff3D(-2,  0, -1),    Diff3D(-1,  0, -1),    Diff3D( 0,  0, -1),    Diff3D(-2, -2,  0),    Diff3D(-1, -2,  0),    Diff3D( 0, -2,  0),    Diff3D(-2, -1,  0),    Diff3D(-1, -1,  0), Diff3D( 0, -1,  0),    Diff3D(-2,  0,  0),    Diff3D(-1,  0,  0), Diff3D( 0,  0,  0)    }        //Behind-SE
    01365             };
    01366             return d[fromCode][toCode];
    01367         */
    01368         return diff(toCode)-diff(fromCode);
    01369     }
    01370
    01371    /** Equivalent to relativeDiff(static_cast<Direction>(fromCode), static_cast<Direction>(toCode)).
    01372        (note: there is no bounds checking on the code you pass.)
    01373    */
    01374     static Diff3D const relativeDiff(int fromCode, int toCode)
    01375     {
    01376         return relativeDiff(static_cast<Direction>(fromCode), static_cast<Direction>(toCode));
    01377     }
    01378
    01379     /**  X-component of diff() */
    01380     static int dX(Direction code) { return diff(code)[0]; }
    01381     /**  Y-component of diff() */
    01382     static int dY(Direction code) { return diff(code)[1]; }
    01383     /**  Z-component of diff() */
    01384     static int dZ(Direction code) { return diff(code)[2]; }
    01385
    01386     /**  X-component of diff() */
    01387     static int dX(int code) { return diff(code)[0]; }
    01388     /**  Y-component of diff() */
    01389     static int dY(int code) { return diff(code)[1]; }
    01390     /**  Z-component of diff() */
    01391     static int dZ(int code) { return diff(code)[2]; }
    01392
    01393     /** transform 6-neighborhood code into 26-neighborhood code.
    01394      */
    01395     static Direction code(Neighborhood3DSix::Direction d)
    01396     {
    01397         switch (d){
    01398             case Neighborhood3DSix::InFront :
    01399                     return InFront;
    01400             case Neighborhood3DSix::North :
    01401                     return North;
    01402             case Neighborhood3DSix::West :
    01403                     return West;
    01404             case Neighborhood3DSix::East :
    01405                     return East;
    01406             case Neighborhood3DSix::South :
    01407                     return South;
    01408             case Neighborhood3DSix::Behind :
    01409                     return Behind;
    01410             default:
    01411                 vigra_fail("NeighborCode3D::code(): Internal error -- invalid direction code.");
    01412         }
    01413         return Error;
    01414     }
    01415
    01416     /** transform Diff3D offset into corresponding direction code.
    01417        The code <tt>Direction::Error</tt> will be returned if <tt>diff</tt>
    01418        is not in the 3DTwentySix-Neighborhood.
    01419     */
    01420     static Direction code(Diff3D const & diff)
    01421     {
    01422         switch(diff[0]){
    01423             case -1:
    01424                 switch(diff[1]){
    01425                     case -1:
    01426                         switch(diff[2]){
    01427                             case -1: return InFrontNorthWest; // ( -1, -1, -1)
    01428                             case  0: return NorthWest;        // ( -1, -1,  0)
    01429                             case  1: return BehindNorthWest;  // ( -1, -1,  1)
    01430                         }
    01431                     case  0:
    01432                         switch(diff[2]){
    01433                             case -1: return InFrontWest;      // ( -1,  0, -1)
    01434                             case  0: return West;             // ( -1,  0,  0)
    01435                             case  1: return BehindWest;       // ( -1,  0,  1)
    01436                         }
    01437                     case  1:
    01438                         switch(diff[2]){
    01439                             case -1: return InFrontSouthWest; // ( -1,  1, -1)
    01440                             case  0: return SouthWest;        // ( -1,  1,  0)
    01441                             case  1: return BehindSouthWest;  // ( -1,  1,  1)
    01442                         }
    01443                 }
    01444             case  0:
    01445                 switch(diff[1]){
    01446                     case -1:
    01447                         switch(diff[2]){
    01448                             case -1: return InFrontNorth;     // (  0,  0, -1)
    01449                             case  0: return North;            // (  0, -1,  0)
    01450                             case  1: return BehindNorth;      // (  0, -1,  1)
    01451                         }
    01452                     case  0:
    01453                         switch(diff[2]){
    01454                             case -1: return InFront;          // (  0,  0, -1)
    01455                             case  1: return Behind;           // (  0,  0,  1)
    01456                         }
    01457                     case  1:
    01458                         switch(diff[2]){
    01459                             case -1: return InFrontSouth;     // (  0,  1, -1)
    01460                             case  0: return South;            // (  0,  1,  0)
    01461                             case  1: return BehindSouth;      // (  0,  1,  1)
    01462                         }
    01463                 }
    01464             case  1:
    01465                 switch(diff[1]){
    01466                     case -1:
    01467                         switch(diff[2]){
    01468                             case -1: return InFrontNorthEast;  // (  1, -1, -1)
    01469                             case  0: return NorthEast;         // (  1, -1,  0)
    01470                             case  1: return BehindNorthEast;   // (  1, -1,  1)
    01471                         }
    01472                     case  0:
    01473                         switch(diff[2]){
    01474                             case -1: return InFrontEast;       // (  1,  0, -1)
    01475                             case  0: return East;              // (  1,  0,  0)
    01476                             case  1: return BehindEast;        // (  1,  0,  1)
    01477                         }
    01478                     case  1:
    01479                         switch(diff[2]){
    01480                             case -1: return InFrontSouthEast;  // (  1,  1, -1)
    01481                             case  0: return SouthEast;         // (  1,  1,  0)
    01482                             case  1: return BehindSouthEast;   // (  1,  1,  1)
    01483                         }
    01484                 }
    01485         }
    01486         return Error; // better safe than sorry
    01487     }
    01488
    01489     /** Check whether a code refers to a diagonal direction.
    01490         Useful if you want to abstract the differences between 6- and 26-neighborhood.
    01491         Always <tt>false</tt> for 6-neighborhood.
    01492     */
    01493     static bool isDiagonal(Direction dir) {
    01494         Diff3D d = diff(dir);
    01495         if (abs(d[0])+abs(d[1])+abs(d[2])==1)
    01496             return false;
    01497         else
    01498             return true;
    01499     }
    01500
    01501     static Diff3D const & frontTopLeft()        { return diff(InFrontNorthWest); }    /**<  Offset to the front-top-left neighbor */
    01502     static Diff3D const & frontTop()            { return diff(InFrontNorth); }        /**<  Offset to the front-top neighbor */
    01503     static Diff3D const & frontTopRight()       { return diff(InFrontNorthEast); }    /**<  Offset to the front-top-right neighbor */
    01504     static Diff3D const & frontLeft()           { return diff(InFrontWest); }         /**<  Offset to the front-left neighbor */
    01505     static Diff3D const & front()               { return diff(InFront); }             /**<  Offset to the front neighbor */
    01506     static Diff3D const & frontRight()          { return diff(InFrontEast); }         /**<  Offset to the front-right neighbor */
    01507     static Diff3D const & frontBottomLeft()     { return diff(InFrontSouthWest); }    /**<  Offset to the front-bottom-left neighbor */
    01508     static Diff3D const & frontBottom()         { return diff(InFrontSouth); }        /**<  Offset to the front-bottom neighbor */
    01509     static Diff3D const & frontBottomRight()    { return diff(InFrontSouthEast); }    /**<  Offset to the front-bottom-right neighbor */
    01510
    01511     static Diff3D const & topLeft()             { return diff(NorthWest); }           /**<  Offset to the top-left neighbor */
    01512     static Diff3D const & top()                 { return diff(North); }               /**<  Offset to the top neighbor */
    01513     static Diff3D const & topRight()            { return diff(NorthEast); }           /**<  Offset to the top-right neighbor */
    01514     static Diff3D const & left()                { return diff(West); }                /**<  Offset to the left neighbor */
    01515     static Diff3D const & right()               { return diff(East); }                /**<  Offset to the right neighbor */
    01516     static Diff3D const & bottomLeft()          { return diff(SouthWest); }           /**<  Offset to the bottom-left neighbor */
    01517     static Diff3D const & bottom()              { return diff(South); }               /**<  Offset to the bottom neighbor */
    01518     static Diff3D const & bottomRight()         { return diff(SouthEast); }           /**<  Offset to the bottom-right neighbor */
    01519
    01520     static Diff3D const & rearTopLeft()         { return diff(BehindNorthWest); }     /**<  Offset to the rear-top-left neighbor */
    01521     static Diff3D const & rearTop()             { return diff(BehindNorth); }         /**<  Offset to the rear-top neighbor */
    01522     static Diff3D const & rearTopRight()        { return diff(BehindNorthEast); }     /**<  Offset to the rear-top-right neighbor */
    01523     static Diff3D const & rearLeft()            { return diff(BehindWest); }          /**<  Offset to the rear-left neighbor */
    01524     static Diff3D const & rear()                { return diff(Behind); }              /**<  Offset to the rear neighbor */
    01525     static Diff3D const & rearRight()           { return diff(BehindEast); }          /**<  Offset to the rear-right neighbor */
    01526     static Diff3D const & rearBottomLeft()      { return diff(BehindSouthWest); }     /**<  Offset to the rear-bottom-left neighbor */
    01527     static Diff3D const & rearBottom()          { return diff(BehindSouth); }         /**<  Offset to the rear-bottom neighbor */
    01528     static Diff3D const & rearBottomRight()     { return diff(BehindSouthEast); }     /**<  Offset to the rear-bottom-right neighbor */
    01529
    01530     //----- other namings
    01531
    01532     static Diff3D const & infrontNorthWest()    { return diff(InFrontNorthWest); }    /**<  Offset to the infront-north-west neighbor */
    01533     static Diff3D const & infrontNorth()        { return diff(InFrontNorth); }        /**<  Offset to the infront-north neighbor */
    01534     static Diff3D const & infrontNorthEast()    { return diff(InFrontNorthEast); }    /**<  Offset to the infront-north-east neighbor */
    01535     static Diff3D const & infrontWest()         { return diff(InFrontWest); }         /**<  Offset to the infront-west neighbor */
    01536     static Diff3D const & infront()             { return diff(InFront); }             /**<  Offset to the infront neighbor */
    01537     static Diff3D const & infrontEast()         { return diff(InFrontEast); }         /**<  Offset to the infront-east neighbor */
    01538     static Diff3D const & infrontSouthWest()    { return diff(InFrontSouthWest); }    /**<  Offset to the infront-south-west neighbor */
    01539     static Diff3D const & infrontSouth()        { return diff(InFrontSouth); }        /**<  Offset to the infront-south neighbor */
    01540     static Diff3D const & infrontSouthEast()    { return diff(InFrontSouthEast); }    /**<  Offset to the infront-south-east neighbor */
    01541
    01542     static Diff3D const & northWest()           { return diff(NorthWest); }            /**<  Offset to the north-west neighbor */
    01543     static Diff3D const & north()               { return diff(North); }                /**<  Offset to the north neighbor */
    01544     static Diff3D const & northEast()           { return diff(NorthEast); }            /**<  Offset to the north-east neighbor */
    01545     static Diff3D const & west()                { return diff(West); }                 /**<  Offset to the west neighbor */
    01546     static Diff3D const & east()                { return diff(East); }                 /**<  Offset to the right neighbor */
    01547     static Diff3D const & southWest()           { return diff(SouthWest); }            /**<  Offset to the south-west neighbor */
    01548     static Diff3D const & south()               { return diff(South); }                /**<  Offset to the south neighbor */
    01549     static Diff3D const & southEast()           { return diff(SouthEast); }            /**<  Offset to the south-east neighbor */
    01550
    01551     static Diff3D const & behindNorthWest()     { return diff(BehindNorthWest); }      /**<  Offset to the behind-north-west neighbor */
    01552     static Diff3D const & behindNorth()         { return diff(BehindNorth); }          /**<  Offset to the behind-north neighbor */
    01553     static Diff3D const & behindNorthEast()     { return diff(BehindNorthEast); }      /**<  Offset to the behind-north-east neighbor */
    01554     static Diff3D const & behindEast()          { return diff(BehindWest); }           /**<  Offset to the behind-west neighbor */
    01555     static Diff3D const & behind()              { return diff(Behind); }               /**<  Offset to the behind neighbor */
    01556     static Diff3D const & behindWest()          { return diff(BehindEast); }           /**<  Offset to the behind-right neighbor */
    01557     static Diff3D const & behindSouthWest()     { return diff(BehindSouthWest); }      /**<  Offset to the behind-south-west neighbor */
    01558     static Diff3D const & behindSouth()         { return diff(BehindSouth); }          /**<  Offset to the behind-south neighbor */
    01559     static Diff3D const & behindSouthEast()     { return diff(BehindSouthEast); }      /**<  Offset to the behind-south-east neighbor */
    01560 }; // class Neighborhood3D
    01561
    01562
    01563 /** Export NeighborCode3D::Direction into the scope of namespace Neighborhood3DSix.
    01564  */
    01565 typedef NeighborCode3D::Direction Direction;
    01566
    01567 static const Direction InFrontNorthWest   = NeighborCode3D::InFrontNorthWest;     /**<  Export NeighborCode3D::InFrontNorthWest to namespace Neighborhood3DTwentySix */
    01568 static const Direction InFrontNorth       = NeighborCode3D::InFrontNorth;         /**<  Export NeighborCode3D::InFrontNorth to namespace Neighborhood3DTwentySix */
    01569 static const Direction InFrontNorthEast   = NeighborCode3D::InFrontNorthEast;     /**<  Export NeighborCode3D::InFrontNorthEast to namespace Neighborhood3DTwentySix */
    01570 static const Direction InFrontWest        = NeighborCode3D::InFrontWest;          /**<  Export NeighborCode3D::InFrontWest to namespace Neighborhood3DTwentySix */
    01571 static const Direction InFront            = NeighborCode3D::InFront;              /**<  Export NeighborCode3D::InFront to namespace Neighborhood3DTwentySix */
    01572 static const Direction InFrontEast        = NeighborCode3D::InFrontEast;          /**<  Export NeighborCode3D::InFrontEast to namespace Neighborhood3DTwentySix */
    01573 static const Direction InFrontSouthWest   = NeighborCode3D::InFrontSouthWest;     /**<  Export NeighborCode3D::InFrontSouthWest to namespace Neighborhood3DTwentySix */
    01574 static const Direction InFrontSouth       = NeighborCode3D::InFrontSouth;         /**<  Export NeighborCode3D::InFrontSouth to namespace Neighborhood3DTwentySix */
    01575 static const Direction InFrontSouthEast   = NeighborCode3D::InFrontSouthEast;     /**<  Export NeighborCode3D::InFrontSouthEast to namespace Neighborhood3DTwentySix */
    01576
    01577 static const Direction NorthWest          = NeighborCode3D::NorthWest;            /**<  Export NeighborCode3D::NorthWest to namespace Neighborhood3DTwentySix */
    01578 static const Direction North              = NeighborCode3D::North;                /**<  Export NeighborCode3D::North to namespace Neighborhood3DTwentySix */
    01579 static const Direction NorthEast          = NeighborCode3D::NorthEast;            /**<  Export NeighborCode3D::NorthEast to namespace Neighborhood3DTwentySix */
    01580 static const Direction West               = NeighborCode3D::West;                 /**<  Export NeighborCode3D::West to namespace Neighborhood3DTwentySix */
    01581 static const Direction East               = NeighborCode3D::East;                 /**<  Export NeighborCode3D::East to namespace Neighborhood3DTwentySix */
    01582 static const Direction SouthWest          = NeighborCode3D::SouthWest;            /**<  Export NeighborCode3D::SouthWest to namespace Neighborhood3DTwentySix */
    01583 static const Direction South              = NeighborCode3D::South;                /**<  Export NeighborCode3D::South to namespace Neighborhood3DTwentySix */
    01584 static const Direction SouthEast          = NeighborCode3D::SouthEast;            /**<  Export NeighborCode3D::SouthEast to namespace Neighborhood3DTwentySix */
    01585
    01586 static const Direction BehindNorthWest    = NeighborCode3D::BehindNorthWest;      /**<  Export NeighborCode3D::BehindNorthWest to namespace Neighborhood3DTwentySix */
    01587 static const Direction BehindNorth        = NeighborCode3D::BehindNorth;          /**<  Export NeighborCode3D::BehindNorth to namespace Neighborhood3DTwentySix */
    01588 static const Direction BehindNorthEast    = NeighborCode3D::BehindNorthEast;      /**<  Export NeighborCode3D::BehindNorthEast to namespace Neighborhood3DTwentySix */
    01589 static const Direction BehindWest         = NeighborCode3D::BehindWest;           /**<  Export NeighborCode3D::BehindWest to namespace Neighborhood3DTwentySix */
    01590 static const Direction Behind             = NeighborCode3D::Behind;               /**<  Export NeighborCode3D::Behind to namespace Neighborhood3DTwentySix */
    01591 static const Direction BehindEast         = NeighborCode3D::BehindEast;           /**<  Export NeighborCode3D::BehindEast to namespace Neighborhood3DTwentySix */
    01592 static const Direction BehindSouthWest    = NeighborCode3D::BehindSouthWest;      /**<  Export NeighborCode3D::BehindSouthWest to namespace Neighborhood3DTwentySix */
    01593 static const Direction BehindSouth        = NeighborCode3D::BehindSouth;          /**<  Export NeighborCode3D::BehindSouth to namespace Neighborhood3DTwentySix */
    01594 static const Direction BehindSouthEast    = NeighborCode3D::BehindSouthEast;      /**<  Export NeighborCode3D::BehindSouthEast to namespace Neighborhood3DTwentySix */
    01595
    01596 static const Direction DirectionCount     = NeighborCode3D::DirectionCount;       /**<  Export NeighborCode3D::DirectionCount to namespace Neighborhood3DTwentySix */
    01597
    01598 }//namespace Neighborhood3DTwentySix
    01599
    01600 /** Export \ref vigra::Neighborhood3DTwentySix::NeighborCode3D into the scope of namespace vigra.
    01601  */
    01602 typedef Neighborhood3DTwentySix::NeighborCode3D NeighborCode3DTwentySix;
    01603
    01604 //@}
    01605
    01606 } // namespace vigra
    01607
    01608 #endif /* VIGRA_VOXELNEIGHBORHOOD_HXX */

© Ullrich Köthe (ullrich.koethe@iwr.uni-heidelberg.de) Heidelberg Collaboratory for Image Processing, University of Heidelberg, Germany | html generated using doxygen and Python vigra 1.9.0 (Tue Nov 6 2012)