IMP  2.2.0
The Integrative Modeling Platform
MapDistanceTransform.h
Go to the documentation of this file.
1 /**
2  * \file IMP/em/MapDistanceTransform.h \brief class for computing a distance
3  * transform of the density map
4  *
5  * Copyright 2007-2014 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  */
34  MapDistanceTransform(IMP::em::DensityMap* map, float density_threshold,
35  float max_distance);
36 
37  /** get the distance from object envelope
38  (-max_float is returned if the point is outside the grid)
39  */
41  long index = get_voxel_by_location(v);
42  if (index >= 0 && index < get_number_of_voxels()) return data_[index];
43  return -std::numeric_limits<float>::max();
44  }
45 
46  private:
47  void compute_distance_transform();
48 
49  protected:
50  // cube neighbors, there are 26 neighbors for each voxel
51  std::vector<long> neighbors_;
52  float max_distance_; // distance up to which the grid distances are computed
53 };
54 
55 IMPEM_END_NAMESPACE
56 
57 #endif /* IMPEM_MAP_DISTANCE_TRANSFORM_H */
Class for getting the distance from the map envelope.
float get_distance_from_envelope(const IMP::algebra::Vector3D &v) const
Class for handling density maps.
Class for handling density maps.
Definition: DensityMap.h:94
long get_number_of_voxels() const
number of map voxels
long get_voxel_by_location(float x, float y, float z) const
Calculate the voxel of a given location.
VectorD< 3 > Vector3D
Definition: VectorD.h:395