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