IMP  2.0.0
The Integrative Modeling Platform
MapDistanceTransform.h
Go to the documentation of this file.
1 /**
2  * \file MapDistanceTransform.h \brief class for computing a distance
3  * transform of the density map
4  *
5  * Copyright 2007-2013 IMP Inventors. All rights reserved.
6  *
7  */
8 
9 #ifndef IMPEM_MAP_DISTANCE_TRANSFORM_H
10 #define IMPEM_MAP_DISTANCE_TRANSFORM_H
11 
12 #include <IMP/em/em_config.h>
13 #include <IMP/em/DensityMap.h>
14 
15 IMPEM_BEGIN_NAMESPACE
16 
17 //! Class for getting the distance from the map envelope
18 /**
19  The class creates and stores a conversion of density map into
20  a distance transform. The envelope voxels (that are determined
21  using density_threshold) are zero distance. The rest of the voxels
22  hold the distance to the closest envelop voxel. Positive distance
23  means inside the object, negative - outside.
24  */
25 class IMPEMEXPORT MapDistanceTransform : public IMP::em::DensityMap {
26 public:
27  /** init the distance transform
28  \param [in] map - input density map
29  \param [in] density_threshold - a threshold that detemines
30  the envelope of the map
31  \param [in] max_distance - how far from the envelope to compute
32  the transform
33  */
35  float density_threshold,
36  float max_distance);
37 
38  /** get the distance from object envelope
39  (-max_float is returned if the point is outside the grid)
40  */
42  long index = get_voxel_by_location(v);
43  if(index >= 0 && index < get_number_of_voxels()) return data_[index];
44  return -std::numeric_limits<float>::max();
45  }
46 
47  private:
48  void compute_distance_transform();
49 
50  protected:
51  // cube neighbors, there are 26 neighbors for each voxel
52  std::vector<long> neighbors_;
53  float max_distance_; // distance up to which the grid distances are computed
54 };
55 
56 IMPEM_END_NAMESPACE
57 
58 #endif /* IMPEM_MAP_DISTANCE_TRANSFORM_H */