IMP  2.0.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-2013 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 class IMPEMEXPORT RadiusDependentDistanceMask {
18  //class RadiusDependentDistanceMask {
19 public:
20  RadiusDependentDistanceMask(
21  float sampling_radius, const DensityHeader &header);
22  inline const std::vector<double> *get_neighbor_shift() const {
23  return &neighbor_shift_;}
24  inline const std::vector<double> *get_neighbor_dist() const {
25  return &neighbor_dist_;}
26  inline const std::vector<double> *get_neighbor_dist_exp() const {
27  return &neighbor_dist_exp_;}
28 
29  void show(std::ostream& out) const { out << "RadiusDependentDistanceMask"; }
30 protected:
31  std::vector<double> neighbor_shift_;
32  std::vector<double> neighbor_dist_;
33  std::vector<double> neighbor_dist_exp_;
34 };
35 
36 //! Calculates and stores a distance mask
37 class IMPEMEXPORT DistanceMask
38 //class DistanceMask
39 {
40 public:
41  DistanceMask() {
42  initialized_ = false;
43  }
44 
45  DistanceMask(const DensityHeader *header) {
46  header_=header;
47  initialized_ = true;
48  }
49 
50  void show(std::ostream& out) const { out << "DistanceMask"; }
51 #if !defined(SWIG) && !defined(IMP_DOXYGEN)
52  //! Sets the parameters that depend on the radius of a given particle.
53  const RadiusDependentDistanceMask* set_mask(float radius);
54 
55  //! Finds the precomputed mask given a particle radius.
56  /**
57  \param[in] radius searching for parameters of this radius
58  \param[in] eps used for numerical stability
59  \note The parameters are indexes by the radius. To maintain
60  numeratical stability, look for a radius within +-eps from the
61  queried radius.
62  \note the function return nullptr and writes a warning if parameters
63  for this radius were not found.
64  */
65  const RadiusDependentDistanceMask* get_mask(
66  float radius,float eps=0.001) const;
67 #endif
68  bool is_mask_set(float radius,float eps=0.001) {
69  return get_mask(radius, eps) != nullptr;
70  }
71 protected:
72  typedef
73  std::map<float, const RadiusDependentDistanceMask*> MASK_MAP;
74  bool initialized_;
75  MASK_MAP masks_;
76  const DensityHeader *header_;
77  KernelParameters kernel_params_;
78 };
79 
80 IMPEM_END_NAMESPACE
81 #endif /* IMPEM_MASKING_H */