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