8 #ifndef IMPALGEBRA_GRID_INDEXES_H
9 #define IMPALGEBRA_GRID_INDEXES_H
11 #include <IMP/algebra/algebra_config.h>
13 #include "internal/vector.h"
14 #include "internal/grid_internal.h"
19 IMPALGEBRA_BEGIN_NAMESPACE
29 internal::VectorData<int, D, true> data_;
32 if (data_.get_dimension()==0 && o.data_.get_dimension()==0) {
34 }
else if (data_.get_dimension()==0) {
36 }
else if (o.data_.get_dimension()==0) {
41 "Dimensions don't match");
43 return internal::lexicographical_compare(begin(), end(),
47 #if !defined(IMP_DOXYGEN) && !defined(SWIG)
48 const internal::VectorData<int, D, true>& get_data()
const {
51 internal::VectorData<int, D, true>& access_data() {
57 data_.set_coordinates(vals.begin(), vals.end());
62 data_.set_coordinates(b,e);
65 ExtendedGridIndexD(
int x,
int y,
int z) {
68 data_.set_coordinates(v, v+3);
70 ExtendedGridIndexD() {
72 unsigned int get_dimension()
const {
73 return data_.get_dimension();
80 "Using uninitialized grid index");
81 return data_.get_data()[i]);
84 for (
unsigned int i=0; i< get_dimension(); ++i) {
86 if (i != get_dimension()-1) out <<
", ";
92 typedef const int* iterator;
93 iterator begin()
const {
return data_.get_data();}
94 iterator end()
const {
return data_.get_data()+get_dimension();}
97 unsigned int __len__()
const {
return get_dimension();}
100 return boost::hash_range(begin(), end()));
101 ExtendedGridIndexD<D> get_uniform_offset(
int ii)
const {
102 Ints ret(get_dimension(), 0);
103 for (
unsigned int i=0; i< get_dimension(); ++i) {
104 ret[i]= operator[](i)+ii;
107 return ExtendedGridIndexD<D>(ret);
109 ExtendedGridIndexD<D> get_offset(
int i,
int j,
int k)
const {
111 int v[]={operator[](0)+i,
114 ExtendedGridIndexD<D> ret(v, v+3);
119 #if !defined(SWIG) && !defined(IMP_DOXYGEN)
121 inline std::size_t hash_value(
const ExtendedGridIndexD<D> &ind) {
122 return ind.__hash__();
145 internal::VectorData<int, D, true> data_;
148 if (data_.get_dimension()==0 && o.data_.get_dimension()==0) {
150 }
else if (data_.get_dimension()==0) {
152 }
else if (o.data_.get_dimension()==0) {
157 "Dimensions don't match");
159 return internal::lexicographical_compare(begin(), end(),
163 #if !defined(IMP_DOXYGEN) && !defined(SWIG)
164 const internal::VectorData<int, D, true>& get_data()
const {
167 internal::VectorData<int, D, true>& access_data() {
174 unsigned int get_dimension()
const {
return data_.get_dimension();}
181 "Using uninitialized grid index");
182 return data_.get_data()[i]);
185 for (
unsigned int i=0; i< get_dimension(); ++i) {
187 if (i != get_dimension()-1) out <<
", ";
192 typedef const int* iterator;
193 iterator begin()
const {
return data_.get_data();}
194 iterator end()
const {
return data_.get_data()+get_dimension();}
196 data_.set_coordinates(vals.begin(), vals.end());
200 data_.set_coordinates(b,e);
203 unsigned int __len__()
const {
return get_dimension();}
207 return boost::hash_range(begin(), end()));
211 #if !defined(SWIG) && !defined(IMP_DOXYGEN)
214 return ind.__hash__();
224 #if !defined(IMP_DOXYGEN)
225 typedef GridIndexD<1> GridIndex1D;
226 typedef ExtendedGridIndexD<1> ExtendedGridIndex1D;
231 typedef GridIndexD<2> GridIndex2D;
232 typedef ExtendedGridIndexD<2> ExtendedGridIndex2D;
235 ExtendedGridIndex2Ds;
237 typedef GridIndexD<3> GridIndex3D;
238 typedef ExtendedGridIndexD<3> ExtendedGridIndex3D;
241 ExtendedGridIndex3Ds;
243 typedef GridIndexD<4> GridIndex4D;
244 typedef ExtendedGridIndexD<4> ExtendedGridIndex4D;
247 ExtendedGridIndex4Ds;
249 typedef GridIndexD<5> GridIndex5D;
250 typedef ExtendedGridIndexD<5> ExtendedGridIndex5D;
253 ExtendedGridIndex5Ds;
255 typedef GridIndexD<6> GridIndex6D;
256 typedef ExtendedGridIndexD<6> ExtendedGridIndex6D;
259 ExtendedGridIndex6Ds;
261 typedef GridIndexD<-1> GridIndexKD;
262 typedef ExtendedGridIndexD<-1> ExtendedGridIndexKD;
265 ExtendedGridIndexKDs;
268 IMPALGEBRA_END_NAMESPACE