IMP logo
IMP Reference Guide  2.20.0
The Integrative Modeling Platform
masking.h
Go to the documentation of this file.
1 /**
2  * \file IMP/em/masking.h
3  * \brief masking tools
4  *
5  * Copyright 2007-2022 IMP Inventors. All rights reserved.
6  *
7  */
8 
9 #ifndef IMPEM_MASKING_H
10 #define IMPEM_MASKING_H
11 
12 #include <IMP/em/em_config.h>
13 #include <IMP/base_types.h>
14 #include "DensityHeader.h"
15 #include "KernelParameters.h"
16 IMPEM_BEGIN_NAMESPACE
17 /** Mask based on the distance. */
18 class IMPEMEXPORT RadiusDependentDistanceMask {
19  // class RadiusDependentDistanceMask {
20  public:
21  RadiusDependentDistanceMask(float sampling_radius,
22  const DensityHeader &header);
23  inline const std::vector<double> *get_neighbor_shift() const {
24  return &neighbor_shift_;
25  }
26  inline const std::vector<double> *get_neighbor_dist() const {
27  return &neighbor_dist_;
28  }
29  inline const std::vector<double> *get_neighbor_dist_exp() const {
30  return &neighbor_dist_exp_;
31  }
32 
33  void show(std::ostream &out) const { out << "RadiusDependentDistanceMask"; }
34 
35  protected:
36  std::vector<double> neighbor_shift_;
37  std::vector<double> neighbor_dist_;
38  std::vector<double> neighbor_dist_exp_;
39 };
40 
41 //! Calculates and stores a distance mask
42 class IMPEMEXPORT DistanceMask
43  // class DistanceMask
44  {
45  public:
46  DistanceMask()
47  : initialized_(false), header_(nullptr) {}
48 
49  DistanceMask(const DensityHeader *header)
50  : initialized_(true), header_(header) {}
51 
52  void show(std::ostream &out) const { out << "DistanceMask"; }
53 #if !defined(SWIG) && !defined(IMP_DOXYGEN)
54  //! Sets the parameters that depend on the radius of a given particle.
55  const RadiusDependentDistanceMask *set_mask(float radius);
56 
57  //! Finds the precomputed mask given a particle radius.
58  /**
59  \param[in] radius searching for parameters of this radius
60  \param[in] eps used for numerical stability
61  \note The parameters are indexes by the radius. To maintain
62  numerical stability, look for a radius within +-eps from the
63  queried radius.
64  \note the function return nullptr and writes a warning if parameters
65  for this radius were not found.
66  */
67  const RadiusDependentDistanceMask *get_mask(float radius,
68  float eps = 0.001) const;
69 #endif
70  bool is_mask_set(float radius, float eps = 0.001) {
71  return get_mask(radius, eps) != nullptr;
72  }
73 
74  protected:
75  typedef std::map<float, const RadiusDependentDistanceMask *> MASK_MAP;
76  bool initialized_;
77  MASK_MAP masks_;
78  const DensityHeader *header_;
79  KernelParameters kernel_params_;
80 };
81 
82 IMPEM_END_NAMESPACE
83 #endif /* IMPEM_MASKING_H */
Basic types used by IMP.
Calculates and stores Gaussian kernel parameters.
Metadata for a density file.
Calculates and stores Gaussian kernel parameters.
Calculates and stores a distance mask.
Definition: masking.h:42
std::ostream & show(Hierarchy h, std::ostream &out=std::cout)
Print the hierarchy using a given decorator to display each node.