UniformGrid3D.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006 #ifndef _UNIFORMGRID3D_H_20050124_1703
00007 #define _UNIFORMGRID3D_H_20050124_1703
00008
00009 #include "point.h"
00010 #include <DataStructs/DiscreteValueVect.h>
00011 #include "Grid3D.h"
00012 #include <iostream>
00013 namespace RDGeom {
00014 class UniformGrid3D : public Grid3D {
00015
00016 public:
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 UniformGrid3D(double dimX, double dimY, double dimZ, double spacing=0.5,
00034 RDKit::DiscreteValueVect::DiscreteValueType valType=RDKit::DiscreteValueVect::TWOBITVALUE,
00035 const RDGeom::Point3D *offset=0){
00036 if (offset == 0) {
00037 initGrid(dimX, dimY, dimZ, spacing, valType,
00038 Point3D(-0.5*dimX, -0.5*dimY, -0.5*dimZ));
00039 } else {
00040 initGrid(dimX, dimY, dimZ, spacing, valType, *offset);
00041 }
00042 }
00043
00044 UniformGrid3D(const UniformGrid3D &other);
00045
00046 UniformGrid3D(const std::string pkl);
00047
00048 UniformGrid3D(const char *pkl,unsigned int);
00049
00050 ~UniformGrid3D();
00051
00052
00053
00054
00055 int getGridPointIndex(const Point3D &point) const;
00056
00057
00058
00059
00060 int getVal(const Point3D &point) const;
00061
00062
00063
00064
00065 unsigned int getVal(unsigned int pointId) const;
00066
00067
00068
00069
00070 void setVal(const Point3D &point, unsigned int val);
00071
00072
00073 Point3D getGridPointLoc(unsigned int pointId) const;
00074
00075
00076 void setVal(unsigned int pointId, unsigned int val);
00077
00078
00079 unsigned int getSize() const { return d_numX*d_numY*d_numZ; };
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093 void setSphereOccupancy(const Point3D & center, double radius,
00094 double stepSize, int maxNumLayers=-1,
00095 bool ignoreOutOfBound=true);
00096
00097
00098
00099
00100 int getGridIndex(unsigned int xi, unsigned int yi, unsigned int zi) const;
00101
00102
00103 unsigned int getNumX() const { return d_numX; };
00104
00105
00106 unsigned int getNumY() const { return d_numY; };
00107
00108
00109 unsigned int getNumZ() const { return d_numZ; };
00110
00111
00112 const Point3D &getOffset() const { return d_offSet; };
00113
00114
00115 double getSpacing() const { return d_spacing; };
00116
00117
00118 const RDKit::DiscreteValueVect *getOccupancyVect() const { return dp_storage;} ;
00119
00120
00121
00122 virtual bool compareParams(const UniformGrid3D &other) const;
00123
00124
00125
00126
00127 UniformGrid3D &operator|=(const UniformGrid3D &other);
00128
00129
00130
00131
00132 UniformGrid3D &operator&=(const UniformGrid3D &other);
00133
00134
00135
00136
00137 UniformGrid3D &operator+=(const UniformGrid3D &other);
00138
00139
00140
00141
00142 UniformGrid3D &operator-=(const UniformGrid3D &other);
00143
00144
00145 std::string toString() const;
00146
00147 UniformGrid3D operator& (const UniformGrid3D &other) const{
00148 PRECONDITION(dp_storage,"bad storage");
00149 PRECONDITION(compareParams(other),"mismatched params");
00150 UniformGrid3D res(d_numX*d_spacing,d_numY*d_spacing,d_numZ*d_spacing,
00151 d_spacing,dp_storage->getValueType(),&d_offSet);
00152
00153 };
00154
00155 private:
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168 void initGrid(double dimX, double dimY, double dimZ, double spacing,
00169 RDKit::DiscreteValueVect::DiscreteValueType valType,
00170 const RDGeom::Point3D &offSet,RDKit::DiscreteValueVect *data=0);
00171 unsigned int d_numX, d_numY, d_numZ;
00172 double d_spacing;
00173 Point3D d_offSet;
00174 RDKit::DiscreteValueVect *dp_storage;
00175
00176
00177 void initFromText(const char *pkl,const unsigned int length);
00178
00179 };
00180
00181
00182
00183
00184
00185 void writeGridToStream(const UniformGrid3D &grid, std::ostream &outStrm);
00186
00187
00188
00189
00190
00191 void writeGridToFile(const UniformGrid3D &grid, std::string filename);
00192
00193 }
00194
00195 #endif
00196