00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef IMPEM_SAMPLED_DENSITY_MAP_H
00010 #define IMPEM_SAMPLED_DENSITY_MAP_H
00011
00012 #include "em_config.h"
00013 #include "exp.h"
00014 #include "DensityMap.h"
00015 #include "DensityHeader.h"
00016 #include "def.h"
00017 #include "KernelParameters.h"
00018 #include <vector>
00019 #include "IMP/base_types.h"
00020 #include "IMP/core/XYZR.h"
00021 #include "IMP/atom/Mass.h"
00022 IMPEM_BEGIN_NAMESPACE
00023
00024
00025
00026
00027
00028
00029
00030
00031 class IMPEMEXPORT SampledDensityMap: public DensityMap
00032 {
00033
00034 public:
00035
00036
00037
00038
00039
00040 SampledDensityMap() {
00041 }
00042
00043
00044 SampledDensityMap(const DensityHeader &header);
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056 SampledDensityMap(const Particles &ps, emreal resolution,
00057 emreal voxel_size,
00058 IMP::FloatKey radius_key=IMP::core::XYZR::get_default_radius_key(),
00059 IMP::FloatKey mass_key=IMP::atom::Mass::get_mass_key(),
00060 int sig_cuttoff=3);
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071 virtual void resample();
00072
00073
00074 void set_particles(IMP::Particles &ps,
00075 IMP::FloatKey radius_key = IMP::core::XYZR::get_default_radius_key(),
00076 IMP::FloatKey mass_key = IMP::atom::Mass::get_mass_key());
00077 void calc_sampling_bounding_box(const emreal &x,const emreal &y,
00078 const emreal &z,
00079 const emreal &kdist,
00080 int &iminx,int &iminy, int &iminz,
00081 int &imaxx,int &imaxy, int &imaxz) const;
00082
00083 KernelParameters *get_kernel_params() { return &kernel_params_;}
00084
00085
00086 inline const core::XYZRs & get_xyzr_particles() const {return xyzr_;}
00087
00088 inline const Particles & get_sampled_particles() const {return ps_;}
00089 inline FloatKey get_weight_key() const {return weight_key_;}
00090 inline FloatKey get_radius_key() const {return radius_key_;}
00091
00092
00093 IMP_REF_COUNTED_DESTRUCTOR(SampledDensityMap);
00094 protected:
00095
00096
00097
00098
00099 IMP::algebra::BoundingBoxD<3>
00100 calculate_particles_bounding_box(const Particles &ps);
00101 void set_header(const algebra::VectorD<3> &lower_bound,
00102 const algebra::VectorD<3> &upper_bound,
00103 emreal maxradius, emreal resolution, emreal voxel_size,
00104 int sig_offset);
00105
00106
00107 int lower_voxel_shift(const emreal &loc, const emreal &kdist,
00108 const emreal &orig, int ndim) const {
00109 int imin;
00110 imin = static_cast<int>(std::floor((loc-kdist-orig)
00111 / header_.get_spacing()));
00112
00113 if (imin < 0)
00114 imin = 0;
00115 if (imin > ndim-1)
00116 imin = ndim-1;
00117 return imin;
00118 }
00119
00120
00121 int upper_voxel_shift(const emreal &loc, const emreal &kdist,
00122 const emreal &orig, int ndim) const {
00123 int imax;
00124 imax = static_cast<int>(std::floor((loc+kdist-orig)
00125 / header_.get_spacing()));
00126
00127 if (imax < 0) imax = 0;
00128 if (imax > ndim-1) imax = ndim-1;
00129 return imax;
00130 }
00131 protected:
00132
00133 KernelParameters kernel_params_;
00134 Particles ps_;
00135 core::XYZRs xyzr_;
00136
00137 FloatKey weight_key_;
00138 FloatKey radius_key_;
00139 FloatKey x_key_,y_key_,z_key_;
00140 };
00141
00142 IMPEM_END_NAMESPACE
00143
00144 #endif