00001 /** 00002 * \file SurfaceShellDensityMap.h 00003 * \brief Represent a molecule as shells of distance from the surface 00004 * 00005 * Copyright 2007-2010 IMP Inventors. All rights reserved. 00006 * 00007 */ 00008 00009 #ifndef IMPEM_SURFACE_SHELL_DENSITY_MAP_H 00010 #define IMPEM_SURFACE_SHELL_DENSITY_MAP_H 00011 00012 #include "em_config.h" 00013 #include "exp.h" 00014 #include "SampledDensityMap.h" 00015 #include "DensityHeader.h" 00016 #include "def.h" 00017 #include <vector> 00018 00019 IMPEM_BEGIN_NAMESPACE 00020 00021 #define IMP_DEFAULT_NUM_SHELLS 5 00022 #define IMP_SIG_CUTOFF 3 00023 #define IMP_BACKGROUND_VAL 0.0 00024 #define IMP_SURFACE_VAL 1.0 00025 00026 //! The class repersents a molecule as shells of distance from the surface 00027 /** 00028 */ 00029 class IMPEMEXPORT SurfaceShellDensityMap: public SampledDensityMap 00030 { 00031 public: 00032 00033 //! Creates a new density map. 00034 /** The header of the map is not determined and no data is being allocated 00035 */ 00036 SurfaceShellDensityMap(); 00037 00038 //! Creates a new density map. 00039 //! The size of the map is determined by the header and the data is allocated. 00040 SurfaceShellDensityMap(const DensityHeader &header); 00041 00042 //! Generatea a surface shell density map from the input particles. 00043 /** /param[in] ps particles with XYZ, radius and weight attributes 00044 /param[in] voxel_size the voxel size. 00045 /note the voxel size and the number of shells determines 00046 the resolution/accuracy of the surface rasterization. 00047 /param[in] sig_cutoff Choose what should be the sigma cutoff for 00048 accurate sampling. It is used in two functions; 00049 (i) to determine the size of the grid dimensions 00050 (ii) to determine the voxels around the coords participating 00051 in the sampling procedure. 00052 */ 00053 SurfaceShellDensityMap(const Particles &ps, 00054 float resolution, 00055 float voxel_size, 00056 IMP::FloatKey radius_key = IMP::core::XYZR::get_default_radius_key(), 00057 IMP::FloatKey mass_key = IMP::atom::Mass::get_mass_key(), 00058 int num_shells=IMP_DEFAULT_NUM_SHELLS); 00059 00060 //! Resample the grid to consist of density shells of a model 00061 /** 00062 All voxels that are outside of the model defined by the particles will be 00063 set to zero. 00064 Voxels on the surface between the model and the background 00065 will be set of 1. 00066 The interior voxels will be assign value according to their 00067 corresponding shell ( the value increases as the voxel is farthrer away 00068 from the surface). 00069 */ 00070 void resample(); 00071 protected: 00072 //! Set the value of the map voxels as either scene or background 00073 /** 00074 /param[in] scene_val all voxels corredponsing to particles will 00075 be set to this value 00076 */ 00077 void binaries(float scene_val); 00078 00079 //! Checks if the one of the nieghbors of the voxel is a background voxel 00080 /** 00081 /param[in] voxel_ind the index of the voxel 00082 /return true is the at least of the nieghbors of the voxel is 00083 in the background 00084 */ 00085 bool has_background_neighbor(long voxel_ind); 00086 00087 //! Finds all of the voxels that are part of the surface 00088 //! (i.e, seperate background from scene) 00089 /** 00090 /param[in] shell indexes of all of the surface particles 00091 will be stored here. 00092 */ 00093 void set_surface_shell(std::vector<long> *shell); 00094 00095 void set_neighbor_mask(); 00096 float surface_val_; 00097 std::vector<long> neighbor_shift_; 00098 std::vector<emreal> neighbor_dist_; 00099 int num_shells_; 00100 }; 00101 00102 IMPEM_END_NAMESPACE 00103 00104 #endif /* IMPEM_SURFACE_SHELL_DENSITY_MAP_H */