00001 #ifndef OPENTISSUE_CORE_GEOMETRY_GEOMETRY_DIRECTION_LUT_H
00002 #define OPENTISSUE_CORE_GEOMETRY_GEOMETRY_DIRECTION_LUT_H
00003
00004
00005
00006
00007
00008
00009
00010 #include <OpenTissue/configuration.h>
00011
00012 namespace OpenTissue
00013 {
00014
00015 namespace geometry
00016 {
00017
00018 template<typename lut_container>
00019 void create_lut6(lut_container & lut)
00020 {
00021 typedef typename lut_container::value_type vector3_type;
00022 typedef typename vector3_type::value_traits value_traits;
00023
00024 lut.clear();
00025 lut.push_back( vector3_type( value_traits::one(), value_traits::zero(), value_traits::zero()) );
00026 lut.push_back( vector3_type( value_traits::zero(), value_traits::one(), value_traits::zero()) );
00027 lut.push_back( vector3_type( value_traits::zero(), value_traits::zero(), value_traits::one()) );
00028 lut.push_back( vector3_type(-value_traits::one(), value_traits::zero(), value_traits::zero()) );
00029 lut.push_back( vector3_type( value_traits::zero(),-value_traits::one(), value_traits::zero()) );
00030 lut.push_back( vector3_type( value_traits::zero(), value_traits::zero(),-value_traits::one()) );
00031 }
00032
00033 template<typename lut_container>
00034 void create_lut14(lut_container & lut)
00035 {
00036 typedef typename lut_container::value_type vector3_type;
00037 typedef typename vector3_type::value_traits value_traits;
00038
00039 lut.clear();
00040 lut.push_back( vector3_type( value_traits::one(), value_traits::zero(), value_traits::zero()) );
00041 lut.push_back( vector3_type( value_traits::zero(), value_traits::one(), value_traits::zero()) );
00042 lut.push_back( vector3_type( value_traits::zero(), value_traits::zero(), value_traits::one()) );
00043 lut.push_back( vector3_type(-value_traits::one(), value_traits::zero(), value_traits::zero()) );
00044 lut.push_back( vector3_type( value_traits::zero(),-value_traits::one(), value_traits::zero()) );
00045 lut.push_back( vector3_type( value_traits::zero(), value_traits::zero(),-value_traits::one()) );
00046 lut.push_back( vector3_type( value_traits::one(), value_traits::one(),-value_traits::one()) );
00047 lut.push_back( vector3_type( value_traits::one(),-value_traits::one(), value_traits::one()) );
00048 lut.push_back( vector3_type(-value_traits::one(), value_traits::one(), value_traits::one()) );
00049 lut.push_back( vector3_type( value_traits::one(),-value_traits::one(),-value_traits::one()) );
00050 lut.push_back( vector3_type(-value_traits::one(), value_traits::one(),-value_traits::one()) );
00051 lut.push_back( vector3_type(-value_traits::one(),-value_traits::one(), value_traits::one()) );
00052 lut.push_back( vector3_type(-value_traits::one(),-value_traits::one(),-value_traits::one()) );
00053 lut.push_back( vector3_type( value_traits::one(), value_traits::one(), value_traits::one()) );
00054 }
00055
00056 template<typename lut_container>
00057 void create_lut26(lut_container & lut)
00058 {
00059 typedef typename lut_container::value_type vector3_type;
00060 typedef typename vector3_type::value_traits value_traits;
00061
00062 lut.clear();
00063 lut.push_back( vector3_type( value_traits::one(), value_traits::zero(), value_traits::zero()) );
00064 lut.push_back( vector3_type( value_traits::zero(), value_traits::one(), value_traits::zero()) );
00065 lut.push_back( vector3_type( value_traits::zero(), value_traits::zero(), value_traits::one()) );
00066 lut.push_back( vector3_type(-value_traits::one(), value_traits::zero(), value_traits::zero()) );
00067 lut.push_back( vector3_type( value_traits::zero(),-value_traits::one(), value_traits::zero()) );
00068 lut.push_back( vector3_type( value_traits::zero(), value_traits::zero(),-value_traits::one()) );
00069 lut.push_back( vector3_type( value_traits::one(), value_traits::one(),-value_traits::one()) );
00070 lut.push_back( vector3_type( value_traits::one(),-value_traits::one(), value_traits::one()) );
00071 lut.push_back( vector3_type(-value_traits::one(), value_traits::one(), value_traits::one()) );
00072 lut.push_back( vector3_type( value_traits::one(),-value_traits::one(),-value_traits::one()) );
00073 lut.push_back( vector3_type(-value_traits::one(), value_traits::one(),-value_traits::one()) );
00074 lut.push_back( vector3_type(-value_traits::one(),-value_traits::one(), value_traits::one()) );
00075 lut.push_back( vector3_type(-value_traits::one(),-value_traits::one(),-value_traits::one()) );
00076 lut.push_back( vector3_type( value_traits::one(), value_traits::one(), value_traits::one()) );
00077 lut.push_back( vector3_type( value_traits::one(), value_traits::one(), value_traits::zero()) );
00078 lut.push_back( vector3_type( value_traits::one(), value_traits::zero(), value_traits::one()) );
00079 lut.push_back( vector3_type( value_traits::zero(), value_traits::one(), value_traits::one()) );
00080 lut.push_back( vector3_type(-value_traits::one(),-value_traits::one(), value_traits::zero()) );
00081 lut.push_back( vector3_type(-value_traits::one(), value_traits::zero(), value_traits::one()) );
00082 lut.push_back( vector3_type( value_traits::zero(),-value_traits::one(),-value_traits::one()) );
00083 lut.push_back( vector3_type( value_traits::one(),-value_traits::one(), value_traits::zero()) );
00084 lut.push_back( vector3_type( value_traits::one(), value_traits::zero(),-value_traits::one()) );
00085 lut.push_back( vector3_type( value_traits::zero(),-value_traits::one(), value_traits::one()) );
00086 lut.push_back( vector3_type(-value_traits::one(), value_traits::one(), value_traits::zero()) );
00087 lut.push_back( vector3_type(-value_traits::one(), value_traits::zero(), value_traits::one()) );
00088 lut.push_back( vector3_type( value_traits::zero(), value_traits::one(),-value_traits::one()) );
00089 }
00090
00091
00102 template<typename lut_iterator, typename vector3_type>
00103 unsigned int direction_bitmask( lut_iterator begin, lut_iterator end, vector3_type const & v)
00104 {
00105 typedef typename vector3_type::value_traits value_traits;
00106
00107 unsigned int mask = 0;
00108 for(lut_iterator lut = begin; lut != end;++lut)
00109 {
00110 vector3_type const & dir = *(lut);
00111 mask = mask << 1;
00112 if((v * dir) > value_traits::zero() )
00113 {
00114
00115 mask = (mask | 0x001);
00116 }
00117 }
00118 return mask;
00119 }
00120
00121 }
00122
00123 }
00124
00125
00126 #endif