IMP logo
IMP Reference Guide  develop.7482b7c7af, 2026/12/05
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-2026 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
15IMPEM_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 envelope voxel. Positive distance
23 means inside the object, negative - outside.
24 */
25class 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 determines
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 // Check each axis separately (a linear index can be in range even
42 // when the point is outside of the grid)
43 if (!is_part_of_volume(v[0], v[1], v[2])) {
44 return -std::numeric_limits<float>::max();
45 }
46 return data_[get_voxel_by_location(v)];
47 }
48
49 private:
50 void compute_distance_transform();
51
52 protected:
53 // cube neighbors, there are 26 neighbors for each voxel
54 std::vector<long> neighbors_;
55 float max_distance_; // distance up to which the grid distances are computed
56};
57
58IMPEM_END_NAMESPACE
59
60#endif /* IMPEM_MAP_DISTANCE_TRANSFORM_H */
Class for handling density maps.
Class for handling density maps.
Definition DensityMap.h:95
long get_voxel_by_location(float x, float y, float z) const
Calculate the voxel of a given location.
bool is_part_of_volume(float x, float y, float z) const
Checks whether a given point is in the grid.
MapDistanceTransform(IMP::em::DensityMap *map, float density_threshold, float max_distance)
float get_distance_from_envelope(const IMP::algebra::Vector3D &v) const
VectorD< 3 > Vector3D
Definition VectorD.h:407