Changeset 185:33ee25e05181

Show
Ignore:
Timestamp:
04/30/2012 07:22:02 PM (13 months ago)
Author:
Andreas Schaefer <gentryx@…>
Branch:
default
Message:

stripped FixedCoord? from out of place ID

Location:
src
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • src/misc/floatcoord.h

    r104 r185  
    99 
    1010/** 
    11  * A real valued coordinate class, which contains an optional ID. 
     11 * A real valued coordinate class. Can also be seen as a short, 
     12 * fixed-size vector. 
    1213 */ 
    1314template<int DIM> 
     
    2728 
    2829    boost::array<double, DIM> c; 
    29     // fixme: get rid of this 
    30     int id; 
    3130}; 
    3231 
     
    4039    explicit 
    4140    inline 
    42     FloatCoord(const double& x = 0, const int _id = 0)  
     41    FloatCoord(const double& x = 0)  
    4342    { 
    4443        c[0] = x; 
    45         id = _id; 
    4644    } 
    4745 
     
    6159template<> 
    6260class FloatCoord<2> : public FloatCoordBase<2> 
     61{ 
     62public: 
     63 
     64    explicit 
     65    inline 
     66    FloatCoord( 
     67        const double& x = 0,  
     68        const double& y = 0)  
     69    { 
     70        c[0] = x; 
     71        c[1] = y; 
     72    } 
     73 
     74    inline 
     75    double length() const 
     76    { 
     77        return sqrt(c[0] * c[0] +  
     78                    c[1] * c[1]); 
     79    } 
     80 
     81    inline 
     82    double sum() const 
     83    { 
     84        return c[0] + c[1]; 
     85    } 
     86}; 
     87 
     88template<> 
     89class FloatCoord<3> : public FloatCoordBase<3> 
    6390{ 
    6491public: 
     
    6996        const double& x = 0,  
    7097        const double& y = 0,  
    71         const int _id = 0)  
    72     { 
    73         c[0] = x; 
    74         c[1] = y; 
    75         id = _id; 
    76     } 
    77  
    78     inline 
    79     double length() const 
    80     { 
    81         return sqrt(c[0] * c[0] +  
    82                     c[1] * c[1]); 
    83     } 
    84  
    85     inline 
    86     double sum() const 
    87     { 
    88         return c[0] + c[1]; 
    89     } 
    90 }; 
    91  
    92 template<> 
    93 class FloatCoord<3> : public FloatCoordBase<3> 
    94 { 
    95 public: 
    96  
    97     explicit 
    98     inline 
    99     FloatCoord( 
    100         const double& x = 0,  
    101         const double& y = 0,  
    102         const double& z = 0, 
    103         const int _id = 0)  
     98        const double& z = 0) 
    10499    { 
    105100        c[0] = x; 
    106101        c[1] = y; 
    107102        c[2] = z; 
    108         id = _id; 
    109103    } 
    110104 
  • src/misc/meshlessadapter.h

    r33 r185  
    2424    static const int MAX_SIZE = 300000; 
    2525 
    26     typedef std::list<FloatCoord<DIM> > CoordList; 
     26    typedef std::list<std::pair<FloatCoord<DIM>, int> > CoordList; 
    2727    typedef Grid<CoordList, TOPOLOGY> CoordListGrid; 
    28     typedef SuperVector<FloatCoord<DIM> > CoordVec; 
     28    typedef SuperVector<std::pair<FloatCoord<DIM>, int> > CoordVec; 
    2929    typedef SuperVector<SuperVector<int> > Graph; 
    3030 
     
    5858    } 
    5959 
    60     inline void insert(CoordListGrid *grid, const FloatCoord<DIM>& pos) const 
     60    inline void insert(CoordListGrid *grid, const FloatCoord<DIM>& pos, const int& id) const 
    6161    { 
    6262        Coord<2> c = posToCoord(pos); 
    63         (*grid)[c].push_back(pos); 
     63        (*grid)[c].push_back(std::make_pair(pos, id)); 
    6464    } 
    6565 
     
    9696        CoordBoxSequence<DIM> s = box.sequence(); 
    9797        while (s.hasNext()) { 
    98             const std::list<FloatCoord<DIM> >& list = positions[s.next()]; 
    99             for (typename std::list<FloatCoord<DIM> >::const_iterator iter = list.begin(); 
     98            const CoordList& list = positions[s.next()]; 
     99            for (typename CoordList::const_iterator iter = list.begin(); 
    100100                 iter != list.end(); 
    101101                 ++iter) { 
     
    189189            for (SuperVector<int>::const_iterator n = graph[i].begin();  
    190190                 n != graph[i].end(); ++n)  
    191                 if (manhattanDistance(positions[i], positions[*n]) > 1) 
     191                if (manhattanDistance(positions[i].first, positions[*n].first) > 1) 
    192192                    return false; 
    193193 
     
    267267 
    268268    bool searchList( 
    269         const std::list<FloatCoord<DIM> >& list, 
     269        const CoordList& list, 
    270270        const FloatCoord<DIM>& pos, 
    271271        std::set<int> *coords = 0) const 
     
    273273        bool found = false; 
    274274 
    275         for (typename std::list<FloatCoord<DIM> >::const_iterator iter = list.begin(); 
     275        for (typename CoordList::const_iterator iter = list.begin(); 
    276276             iter != list.end(); 
    277277             ++iter) { 
    278             if (distance2(pos, *iter) < radius2) { 
     278            if (distance2(pos, iter->first) < radius2) { 
    279279                found = true; 
    280280                if (coords) 
    281                     coords->insert(iter->id); 
     281                    coords->insert(iter->second); 
    282282            } 
    283283        } 
  • src/misc/test/unit/meshlessadaptertest.h

    r27 r185  
    6565 
    6666        for (int i = 0; i < 6; ++i)  
    67             adapter.insert(&grid, FloatCoord<2>(i + 0.5, 0.5, i)); 
     67            adapter.insert(&grid, FloatCoord<2>(i + 0.5, 0.5), i); 
    6868 
    6969        std::set<int> coords; 
     
    124124        MyAdapter::Graph graph; 
    125125        for (int i = 0; i < width; ++i) { 
    126             positions.push_back(FloatCoord<2>(i * 0.5, 0.5, i)); 
     126            positions.push_back(std::make_pair(FloatCoord<2>(i * 0.5, 0.5), i)); 
    127127            SuperVector<int> neighbors; 
    128128            neighbors << ((i + width - 1) % width) 
  • src/testbed/testbed.cpp

    r184 r185  
    151151            coefficients,  
    152152            source, 
     153            index + 
    153154            coord.x() + 
    154155            coord.y() * DIM_X +  
     
    198199    operator[](FixedCoord<X, Y, Z> /*unused*/) const 
    199200    { 
    200         return FixedNeighborhood<DIM_X, DIM_Y, DIM_Z, X + Y * DIM_X + Z * DIM_X * DIM_Y>(coefficients, source); 
     201        return FixedNeighborhood<DIM_X, DIM_Y, DIM_Z, INDEX + X + Y * DIM_X + Z * DIM_X * DIM_Y>(coefficients, source); 
     202    } 
     203 
     204    Neighborhood<DIM_X, DIM_Y, DIM_Z> 
     205    operator[](Coord<3> coord) const 
     206    { 
     207        return Neighborhood<DIM_X, DIM_Y, DIM_Z>( 
     208            coefficients,  
     209            source, 
     210            INDEX + 
     211            coord.x() + 
     212            coord.y() * DIM_X +  
     213            coord.z() * DIM_X * DIM_Y); 
    201214    } 
    202215