BALL
1.4.1
|
00001 // -*- Mode: C++; tab-width: 2; -*- 00002 // vi: set ts=2: 00003 // 00004 00005 #ifndef BALL_STRUCTURE_TRIANGULATEDSAS_H 00006 #define BALL_STRUCTURE_TRIANGULATEDSAS_H 00007 00008 #ifndef BALL_STRUCTURE_SASEDGE_H 00009 # include <BALL/STRUCTURE/SASEdge.h> 00010 #endif 00011 00012 #ifndef BALL_STRUCTURE_SASFACE_H 00013 # include <BALL/STRUCTURE/SASFace.h> 00014 #endif 00015 00016 #ifndef BALL_TRUCTURE_SOLVENTEXCLUDEDSURFACE_H 00017 # include <BALL/STRUCTURE/solventAccessibleSurface.h> 00018 #endif 00019 00020 #ifndef BALL_STRUCTURE_TRIANGULATEDSURFACE_H 00021 # include <BALL/STRUCTURE/triangulatedSurface.h> 00022 #endif 00023 00024 #ifndef BALL_STRUCTURE_TRIANGLE_H 00025 # include <BALL/STRUCTURE/triangle.h> 00026 #endif 00027 00028 #ifndef BALL_STRUCTURE_TRIANGLEEDGE_H 00029 # include <BALL/STRUCTURE/triangleEdge.h> 00030 #endif 00031 00032 #ifndef BALL_STRUCTURE_TRIANGLEPOINT_H 00033 # include <BALL/STRUCTURE/trianglePoint.h> 00034 #endif 00035 00036 #ifndef BALL_MATHS_ANGLE_H 00037 # include <BALL/MATHS/angle.h> 00038 #endif 00039 00040 #ifndef BALL_MATHS_CIRCLE3_H 00041 # include <BALL/MATHS/circle3.h> 00042 #endif 00043 00044 #ifndef BALL_MATHS_VECTOR3_H 00045 # include <BALL/MATHS/vector3.h> 00046 #endif 00047 00048 #ifndef BALL_DATATYPE_HASHGRID_H 00049 # include <BALL/DATATYPE/hashGrid.h> 00050 #endif 00051 00052 #include <list> 00053 #include <vector> 00054 00055 namespace BALL 00056 { 00057 class SASTriangulator; 00058 00062 class BALL_EXPORT TriangulatedSAS : public TriangulatedSurface 00063 { 00064 00065 public: 00066 00072 friend class SASTriangulator; 00073 00074 BALL_CREATE(TriangulatedSAS) 00075 00076 00079 00083 TriangulatedSAS(); 00084 00090 TriangulatedSAS(const TriangulatedSAS& surface, bool = true); 00091 00097 TriangulatedSAS(SolventAccessibleSurface* sas, const double& density); 00098 00102 virtual ~TriangulatedSAS(); 00104 00108 00113 void set(const TriangulatedSAS& surface, bool = true); 00114 00118 TriangulatedSAS& operator = (const TriangulatedSAS& surface); 00119 00121 00125 00128 void setDensity(const double& density); 00129 00132 double getDensity() const; 00133 00136 void compute(); 00137 00139 00140 protected: 00141 00142 /*_ @name Attributes 00143 */ 00145 00146 SolventAccessibleSurface* sas_; 00147 00148 double density_; 00149 00151 00152 }; 00153 00160 class BALL_EXPORT SASTriangulator 00161 { 00162 00163 public: 00164 00165 #ifdef debug_triangulation 00166 void printToHINFile(string filename); 00167 void Contour2HIN(const std::list<TriangleEdge*>& contour, const string& file); 00168 void SASEdge2HIN(SASEdge* edge, const string& file); 00169 #endif 00170 00171 BALL_CREATE(SASTriangulator) 00172 00173 00176 00180 SASTriangulator(); 00181 00186 SASTriangulator(TriangulatedSAS* tsas); 00187 00191 virtual ~SASTriangulator(); 00193 00197 00198 void run(); 00199 00200 private: 00201 00202 void triangulateFace(SASFace* face); 00203 00204 void createPlanes(SASFace* face, 00205 std::list< std::pair<TPlane3<double>,double> >& planes); 00206 00207 void tagPoints(TriangulatedSurface& part, 00208 const std::list< std::pair<TPlane3<double>,double> >& planes); 00209 00210 void removeInsideTriangles(TriangulatedSurface& part); 00211 00212 HashGrid3<TrianglePoint*> createHashGrid(const TriangulatedSurface& part); 00213 00214 void createPoints(TriangulatedSurface& part, 00215 const std::list< std::pair<TPlane3<double>,double> >& planes, 00216 HashGrid3<TrianglePoint*>& grid); 00217 00218 void createNewTriangles(TriangulatedSurface& part, HashGrid3<TrianglePoint*>& grid); 00219 00220 void onePointOutside(Index outside, Triangle* t, 00221 TriangulatedSurface& part, HashGrid3<TrianglePoint*>& grid); 00222 00223 void twoPointsOutside(Position outside1, Position outside2, 00224 Triangle* t, TriangulatedSurface& part, HashGrid3<TrianglePoint*>& grid); 00225 00226 TrianglePoint* vertexExists(const TVector3<double>& point, HashGrid3<TrianglePoint*>& grid); 00227 00228 Size numberOfRefinements(const double& density, const double& radius); 00229 00230 void buildTemplateSpheres(); 00231 00233 00234 protected: 00235 00239 00240 TriangulatedSAS* tsas_; 00241 00242 double sqrt_density_; 00243 00244 std::vector< std::list< TVector3<double> > > edge_; 00245 00246 HashMap<Size,TriangulatedSurface> template_spheres_; 00247 00249 00250 }; 00251 00252 } // namespace BALL 00253 00254 00255 #endif // BALL_STRUCTURE_TRIANGULATEDSAS_H