IMP  2.3.1
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-2014 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() { initialized_ = false; }
47 
48  DistanceMask(const DensityHeader *header) {
49  header_ = header;
50  initialized_ = true;
51  }
52 
53  void show(std::ostream &out) const { out << "DistanceMask"; }
54 #if !defined(SWIG) && !defined(IMP_DOXYGEN)
55  //! Sets the parameters that depend on the radius of a given particle.
56  const RadiusDependentDistanceMask *set_mask(float radius);
57 
58  //! Finds the precomputed mask given a particle radius.
59  /**
60  \param[in] radius searching for parameters of this radius
61  \param[in] eps used for numerical stability
62  \note The parameters are indexes by the radius. To maintain
63  numerical stability, look for a radius within +-eps from the
64  queried radius.
65  \note the function return nullptr and writes a warning if parameters
66  for this radius were not found.
67  */
68  const RadiusDependentDistanceMask *get_mask(float radius,
69  float eps = 0.001) const;
70 #endif
71  bool is_mask_set(float radius, float eps = 0.001) {
72  return get_mask(radius, eps) != nullptr;
73  }
74 
75  protected:
76  typedef std::map<float, const RadiusDependentDistanceMask *> MASK_MAP;
77  bool initialized_;
78  MASK_MAP masks_;
79  const DensityHeader *header_;
80  KernelParameters kernel_params_;
81 };
82 
83 IMPEM_END_NAMESPACE
84 #endif /* IMPEM_MASKING_H */
Import IMP/kernel/base_types.h in the namespace.
Metadata for a density file.
Calculates and stores Gaussian kernel parameters.
Calculates and stores a distance mask.
Definition: masking.h:42
void show(Hierarchy h, std::ostream &out=std::cout)
Print out a molecular hierarchy.