00001
00009 #if !defined(HASURFACE_H)
00010 #define HASURFACE_H
00011
00012
00013 #include "hastl.h"
00014 #include "haconst.h"
00015 #include "halinalg.h"
00016 #include "vec3d.h"
00017 #include "object3d.h"
00018
00019 #define MAXVARS 10
00020 #define MAXTIMES 10
00021
00022
00023 const int MAX_ISO_VERTS = 1200000;
00024 const double VERTEX_SCALE = 10000.0;
00025
00026
00028 class HaField3D
00029 {
00030 public:
00031
00032 HaField3D();
00033 virtual ~HaField3D();
00034
00035 virtual void clear();
00036 void FillZeros();
00037
00038 int SaveToFile(const char* fname, int binary=TRUE);
00039 int RestoreFromFile(const char* fname, int binary=TRUE);
00040
00041 virtual void copy_from(const HaField3D& ref_field);
00042
00043 virtual bool SetDimensions(int new_Nx, int new_Ny, int new_Nz);
00044
00045 int GetNx() const { return m_Nx ; }
00046 int GetNy() const { return m_Ny ; }
00047 int GetNz() const { return m_Nz ; }
00048
00049 double GetXmin() const { return xmin; }
00050 double GetYmin() const { return ymin; }
00051 double GetZmin() const { return zmin; }
00052 double GetXmax() const { return xmax; }
00053 double GetYmax() const { return ymax; }
00054 double GetZmax() const { return zmax; }
00055
00056 double GetXstep() const { return xstep; }
00057 double GetYstep() const { return ystep; }
00058 double GetZstep() const { return zstep; }
00059
00060 bool SetGridCornersCoord(double xmin_new, double ymin_new, double zmin_new,
00061 double xmax_new, double ymax_new, double zmax_new);
00062
00063 int GetLinIdx(int ix, int iy, int iz);
00064
00065 float* GetFieldPtr() { return m_field_data.begin(); }
00066
00068 bool GetXYZ(float& x, float& y , float& z, const int ix, const int iy, const int iz);
00069
00070 float* GetValPtr( int ix, int iy, int iz);
00071 float GetValue( int ix, int iy, int iz);
00072
00073
00074 void SetValue(int ix, int iy, int iz, float val);
00075
00076 int GetClosestGridPoint( double x, double y, double z, int& ix, int& iy, int& iz);
00077
00078
00079 double GetInterpolValAtPoint( double x, double y, double z);
00080
00081 bool grid_to_xyz_float(const int numverts, const float* vr, const float* vc, const float* vl,
00082 float* xyz_coord);
00083
00084 protected:
00085 float xmin, xmax;
00086 float ymin, ymax;
00087 float zmin, zmax;
00088
00089 float xstep;
00090 float ystep;
00091 float zstep;
00092
00093 int m_Nx, m_Ny, m_Nz;
00094 HaVec_float m_field_data;
00095
00096 };
00097
00098
00099 class HaNonLocField3D_2 : public HaField3D
00100 {
00101 public:
00102 HaNonLocField3D_2();
00103 virtual ~HaNonLocField3D_2();
00104
00105 bool SetDepth(int new_depth);
00106 int GetDepth() const;
00107
00108 virtual void clear();
00109 virtual bool SetDimensions(int new_Nx, int new_Ny, int new_Nz);
00110
00111 float GetValue_nloc(int ix, int iy, int iz,
00112 int ir_shift, int ic_shift, int il_shift);
00113
00114 float* GetValuePtr_nloc(int ix, int iy, int iz,
00115 int ir_shift, int ic_shift, int il_shift);
00116
00117 protected:
00118 int depth;
00119 int nl_cube_size;
00120 HaMat_float m_nonl_field_data;
00121
00122 };
00123
00124 class ValAtPoint
00125 {
00126 public:
00127 ValAtPoint() {}
00128 ValAtPoint(short ir_new,short ic_new, short il_new, double new_val);
00129
00130 virtual ~ValAtPoint() {}
00131
00132 short ix;
00133 short iy;
00134 short iz;
00135 double val;
00136 };
00137
00138 class HaNonLocField3D : public HaField3D
00139 {
00140 public:
00141 HaNonLocField3D();
00142 virtual ~HaNonLocField3D();
00143
00144 vector< list<ValAtPoint> > fvals;
00145
00146 int SaveField(HaString fname);
00147
00148 protected:
00149
00150 };
00151
00152
00153 class VertexField3D
00154 {
00155 public:
00156 VertexField3D(HaField3D* new_pfld);
00157 ~VertexField3D();
00158
00159 double GetX() const;
00160 double GetY() const;
00161 double GetZ() const;
00162
00163 double GetVal() const;
00164 bool SetVal(const double new_val);
00165
00166 int iy,ix,iz;
00167
00168 protected:
00169 HaField3D* pfld;
00170 };
00171
00172 enum MolSurfaceType { VDW_SURF=0, SACCESS_SURF=1,SEXCL_SURF=2};
00173
00174
00175 class HaSurface
00177 {
00178 public:
00179
00180 HaSurface();
00181 virtual ~HaSurface();
00182
00183 virtual void clear();
00184
00185 int valid;
00186 float isolevel;
00187
00188 bool calc_isosurf( HaField3D* field, float iso_level);
00189
00190 static void main_march( float *ptGRID, int NC, int NR, int NL,
00191 int LOWLEV,
00192 float GLEV, float ARX, float ARY, float ARZ,
00193 int NVERTS, float *VX, float *VY, float *VZ,
00194 float *NX,float *NY, float *NZ,
00195 int NPTS, int *VPTS, int*IVERT, int *IPTS, int *IPOLY,
00196 int *ITRI);
00197
00198 int CalcMolSurf(int surf_type, float solv_rad, HaMat_float& cnt_crd, HaVec_float& cnt_rad);
00199
00200
00201
00202 static float rmin_axx_sph;
00203 static float overlap_axx_sph;
00204 static int ndiv_sph;
00205 static Vec3D_arr vrt_std;
00206 static Vec3D_arr tcnt_std;
00207
00208 HaMat_float verts;
00209 HaMat_float norms;
00210 HaMat_int tr_indx;
00211
00212 int GetNumTr() { return tr_indx.num_cols(); }
00213 int GetNumVerts() const { return verts.num_cols(); }
00214
00215 virtual int SetNumVerts( const int new_num_verts);
00216
00217
00218
00219
00220
00221 HaVec_ptr sph;
00222 HaVec_double srad;
00223 HaVec_short flag_sph;
00224 Vec3D_arr tess;
00225 HaVec_double tsurf;
00226 HaVec_short itsph;
00227 HaVec_short itsph_r;
00228
00229 bool Print_info(ostream& sout, const int level) const;
00230
00231 protected:
00232
00233 };
00234
00235 const int MC_SIZE = 100000;
00236 const int MV_SIZE = 100000;
00237
00238 extern "C"{
00239
00240 void gsurf_(integer* ksurf,
00241 freal* rmin,
00242 freal* ofac,
00243 freal* rd,
00244 integer* ndiv,
00245 logical* ass1,
00246 integer* natom,
00247 logical* ghost,
00248 integer* np);
00249
00250 typedef struct
00251 {
00252 freal xe[MC_SIZE];
00253 freal ye[MC_SIZE];
00254 freal ze[MC_SIZE];
00255 freal re[MC_SIZE];
00256 int_2 iuse[MC_SIZE];
00257 } csfe_type;
00258
00259 typedef struct
00260 {
00261 int_4 jvt1[3*60];
00262 int_4 jvt2[3*4];
00263 } penta_type;
00264
00265 typedef struct
00266 {
00267 int_4 ito[MV_SIZE];
00268 int_4 iso[MV_SIZE];
00269 int_4 isa[MV_SIZE];
00270 freal xp[MV_SIZE];
00271 freal yp[MV_SIZE];
00272 freal zp[MV_SIZE];
00273 freal ap[MV_SIZE];
00274 } pun_type;
00275
00276 typedef struct
00277 {
00278 doublereal cv[32*3];
00279 freal xc1[15360];
00280 freal yc1[15360];
00281 freal zc1[15360];
00282 } poli_type;
00283
00284 extern csfe_type csfe_;
00285 extern pun_type pun_;
00286 extern penta_type penta_;
00287 extern poli_type poli_;
00288
00289 }
00290
00291
00292 class HaDisplayedSurface: public HaSurface, public Object3D
00293 {
00294 public:
00295 HaDisplayedSurface();
00296 virtual ~HaDisplayedSurface();
00297
00298 virtual void clear();
00299
00300
00301
00302 virtual int RotateObj( const HaMat_double& rot_mat, const Vec3D& cnt);
00303
00304 virtual int Translate( const Vec3D& tr_vec );
00305
00306 bool ColourUniform(int r, int g, int b );
00307
00308 virtual int SetNumVerts(const int new_num_verts);
00309 HaVec_short colors;
00310
00311 protected:
00312
00313 };
00314
00315
00316 class HaDot
00317 {
00318 public:
00319 HaDot() {};
00320 HaDot(const double new_x, const double new_y,
00321 const double new_z, const int col);
00322
00323 virtual ~HaDot();
00324 short col;
00325
00326 double GetX() const { return xpos; }
00327 double GetY() const { return ypos; }
00328 double GetZ() const { return zpos; }
00329
00330 void SetX( const double new_x ) { xpos = new_x; }
00331 void SetY( const double new_y ) { ypos = new_y; }
00332 void SetZ( const double new_z ) { zpos = new_z; }
00333
00334 protected:
00335
00336 double xpos;
00337 double ypos;
00338 double zpos;
00339 };
00340
00341
00342
00343 class DotStruct : public Object3D
00344 {
00345 public:
00346
00347 DotStruct();
00348 virtual ~DotStruct();
00349
00350 vector<HaDot> dots;
00351 int GetCount() { return dots.size(); }
00352
00353 void AddDot(double x, double y, double z, int col );
00354
00355
00356
00357 virtual const char* GetObjName() const { return "Dot Surface"; }
00358
00359 virtual int RotateObj( const HaMat_double& rot_mat, const Vec3D& cnt );
00360
00361 virtual int Translate( const Vec3D& tr_vec);
00362
00363 };
00364
00365
00366
00367
00368
00369 #endif // End of !defined(HASURFACE_H)