00001
00002
00003
00004
00005
00006 #ifndef BALL_STRUCTURE_TRIANGULATEDSAS_H
00007 #define BALL_STRUCTURE_TRIANGULATEDSAS_H
00008
00009
00010
00011 #ifdef debug_triangulation
00012 # define with_bonds
00013
00014 #endif
00015 #ifdef with_indices
00016 # define print_debug_info
00017 #endif
00018
00019 #ifndef BALL_STRUCTURE_SASEDGE_H
00020 # include <BALL/STRUCTURE/SASEdge.h>
00021 #endif
00022
00023 #ifndef BALL_STRUCTURE_SASFACE_H
00024 # include <BALL/STRUCTURE/SASFace.h>
00025 #endif
00026
00027 #ifndef BALL_TRUCTURE_SOLVENTEXCLUDEDSURFACE_H
00028 # include <BALL/STRUCTURE/solventAccessibleSurface.h>
00029 #endif
00030
00031 #ifndef BALL_STRUCTURE_TRIANGULATEDSURFACE_H
00032 # include <BALL/STRUCTURE/triangulatedSurface.h>
00033 #endif
00034
00035 #ifndef BALL_STRUCTURE_TRIANGLE_H
00036 # include <BALL/STRUCTURE/triangle.h>
00037 #endif
00038
00039 #ifndef BALL_STRUCTURE_TRIANGLEEDGE_H
00040 # include <BALL/STRUCTURE/triangleEdge.h>
00041 #endif
00042
00043 #ifndef BALL_STRUCTURE_TRIANGLEPOINT_H
00044 # include <BALL/STRUCTURE/trianglePoint.h>
00045 #endif
00046
00047 #ifndef BALL_MATHS_ANGLE_H
00048 # include <BALL/MATHS/angle.h>
00049 #endif
00050
00051 #ifndef BALL_MATHS_CIRCLE3_H
00052 # include <BALL/MATHS/circle3.h>
00053 #endif
00054
00055 #ifndef BALL_MATHS_VECTOR3_H
00056 # include <BALL/MATHS/vector3.h>
00057 #endif
00058
00059 #ifndef BALL_DATATYPE_HASHGRID_H
00060 # include <BALL/DATATYPE/hashGrid.h>
00061 #endif
00062
00063 #include <list>
00064 #include <vector>
00065
00066 namespace BALL
00067 {
00068 class SASTriangulator;
00069
00073 class BALL_EXPORT TriangulatedSAS : public TriangulatedSurface
00074 {
00075
00076 public:
00077
00078 #ifdef debug_triangulation
00079 void printToHINFile(string filename);
00080 #endif
00081
00087 friend class SASTriangulator;
00088
00089 BALL_CREATE(TriangulatedSAS)
00090
00091
00094
00098 TriangulatedSAS()
00099 ;
00100
00106 TriangulatedSAS(const TriangulatedSAS& surface, bool = true)
00107 ;
00108
00114 TriangulatedSAS(SolventAccessibleSurface* sas, const double& density)
00115 ;
00116
00120 virtual ~TriangulatedSAS()
00121 ;
00123
00127
00132 void set(const TriangulatedSAS& surface, bool = true)
00133 ;
00134
00138 TriangulatedSAS& operator = (const TriangulatedSAS& surface)
00139 ;
00140
00142
00146
00149 void setDensity(const double& density)
00150 ;
00151
00154 double getDensity() const
00155 ;
00156
00159 void compute()
00160 ;
00161
00163
00164 protected:
00165
00166
00167
00169
00170 SolventAccessibleSurface* sas_;
00171
00172 double density_;
00173
00175
00176 };
00177
00178
00179
00186 class BALL_EXPORT SASTriangulator
00187 {
00188
00189 public:
00190
00191 #ifdef debug_triangulation
00192 void printToHINFile(string filename);
00193 void Contour2HIN(const std::list<TriangleEdge*>& contour, const string& file);
00194 void SASEdge2HIN(SASEdge* edge, const string& file);
00195 #endif
00196
00197 BALL_CREATE(SASTriangulator)
00198
00199
00202
00206 SASTriangulator()
00207 ;
00208
00213 SASTriangulator(TriangulatedSAS* tsas)
00214 ;
00215
00219 virtual ~SASTriangulator()
00220 ;
00222
00226
00227 void run()
00228 ;
00229
00230 private:
00231
00232 void triangulateFace(SASFace* face)
00233 ;
00234
00235 void createPlanes
00236 (SASFace* face,
00237 std::list< std::pair<TPlane3<double>,double> >& planes)
00238 ;
00239
00240 void tagPoints
00241 (TriangulatedSurface& part,
00242 const std::list< std::pair<TPlane3<double>,double> >& planes)
00243 ;
00244
00245 void removeInsideTriangles(TriangulatedSurface& part)
00246 ;
00247
00248 HashGrid3<TrianglePoint*> createHashGrid(const TriangulatedSurface& part)
00249 ;
00250
00251 void createPoints
00252 (TriangulatedSurface& part,
00253 const std::list< std::pair<TPlane3<double>,double> >& planes,
00254 HashGrid3<TrianglePoint*>& grid)
00255 ;
00256
00257 void createNewTriangles
00258 (TriangulatedSurface& part,
00259 HashGrid3<TrianglePoint*>& grid)
00260 ;
00261
00262 void onePointOutside
00263 (Index outside,
00264 Triangle* t,
00265 TriangulatedSurface& part,
00266 HashGrid3<TrianglePoint*>& grid)
00267 ;
00268
00269 void twoPointsOutside
00270 (Position outside1,
00271 Position outside2,
00272 Triangle* t,
00273 TriangulatedSurface& part,
00274 HashGrid3<TrianglePoint*>& grid)
00275 ;
00276
00277 TrianglePoint* vertexExists
00278 (const TVector3<double>& point,
00279 HashGrid3<TrianglePoint*>& grid)
00280 ;
00281
00282 Size numberOfRefinements(const double& density, const double& radius)
00283 ;
00284
00285 void buildTemplateSpheres()
00286 ;
00287
00289
00290 protected:
00291
00295
00296 TriangulatedSAS* tsas_;
00297 double sqrt_density_;
00298 std::vector< std::list< TVector3<double> > > edge_;
00299 HashMap<Size,TriangulatedSurface> template_spheres_;
00300
00302
00303 };
00304
00305
00306 }
00307
00308
00309 #endif // BALL_STRUCTURE_TRIANGULATEDSAS_H