BALL
1.4.1
|
00001 // -*- Mode: C++; tab-width: 2; -*- 00002 // vi: set ts=2: 00003 // 00004 00005 #ifndef BALL_STRUCTURE_TRIANGULATEDSES_H 00006 #define BALL_STRUCTURE_TRIANGULATEDSES_H 00007 00008 #ifndef BALL_TRUCTURE_SOLVENTEXCLUDEDSURFACE_H 00009 # include <BALL/STRUCTURE/solventExcludedSurface.h> 00010 #endif 00011 00012 #ifndef BALL_STRUCTURE_TRIANGLE_H 00013 # include <BALL/STRUCTURE/triangle.h> 00014 #endif 00015 00016 #ifndef BALL_STRUCTURE_TRIANGLEEDGE_H 00017 # include <BALL/STRUCTURE/triangleEdge.h> 00018 #endif 00019 00020 #ifndef BALL_STRUCTURE_TRIANGLEPOINT_H 00021 # include <BALL/STRUCTURE/trianglePoint.h> 00022 #endif 00023 00024 #ifndef BALL_STRUCTURE_TRIANGULATEDSURFACE_H 00025 # include <BALL/STRUCTURE/triangulatedSurface.h> 00026 #endif 00027 00028 #ifndef BALL_MATHS_ANGLE_H 00029 # include <BALL/MATHS/angle.h> 00030 #endif 00031 00032 #ifndef BALL_MATHS_CIRCLE3_H 00033 # include <BALL/MATHS/circle3.h> 00034 #endif 00035 00036 #ifndef BALL_MATHS_SPHERE3_H 00037 # include <BALL/MATHS/sphere3.h> 00038 #endif 00039 00040 #ifndef BALL_MATHS_VECTOR3_H 00041 # include <BALL/MATHS/vector3.h> 00042 #endif 00043 00044 #include <list> 00045 #include <vector> 00046 00047 namespace BALL 00048 { 00049 class SESTriangulator; 00050 00054 class BALL_EXPORT TriangulatedSES : public TriangulatedSurface 00055 { 00056 00057 public: 00058 00064 friend class SESTriangulator; 00065 00066 BALL_CREATE(TriangulatedSES) 00067 00068 00071 00075 TriangulatedSES() 00076 ; 00077 00083 TriangulatedSES(const TriangulatedSES& surface, bool = true) 00084 ; 00085 00091 TriangulatedSES(SolventExcludedSurface* ses, const double& density) 00092 ; 00093 00097 virtual ~TriangulatedSES() 00098 ; 00100 00104 00109 void set(const TriangulatedSES& surface, bool = true) 00110 ; 00111 00115 TriangulatedSES& operator = (const TriangulatedSES& surface) 00116 ; 00117 00120 void setDensity(const double& density) 00121 ; 00122 00125 double getDensity() const 00126 ; 00127 00129 00133 00134 void compute() 00135 throw(Exception::GeneralException,Exception::DivisionByZero); 00136 00138 00139 protected: 00140 00141 /*_ @name Attributes 00142 */ 00144 00145 SolventExcludedSurface* ses_; 00146 00147 double density_; 00148 00150 00151 }; 00152 00153 00154 00161 class BALL_EXPORT SESTriangulator 00162 { 00163 00164 public: 00165 00166 BALL_CREATE(SESTriangulator) 00167 00168 00171 00175 SESTriangulator() 00176 ; 00177 00181 SESTriangulator(TriangulatedSES* tses) 00182 ; 00183 00187 virtual ~SESTriangulator() 00188 ; 00190 00194 00195 void run() 00196 throw(Exception::GeneralException,Exception::DivisionByZero); 00197 00198 private: 00199 00200 void preProcessing() 00201 ; 00202 00203 void triangulateToricFaces() 00204 ; 00205 00206 void partitionSingularEdges() 00207 ; 00208 00209 void triangulateContactFaces() 00210 ; 00211 00212 void triangulateSphericFaces() 00213 ; 00214 00215 void triangulateToricFace 00216 (SESFace* face, 00217 const double& probe_radius) 00218 ; 00219 00220 void triangulateFreeToricFace 00221 (SESFace* face, 00222 const double& probe_radius) 00223 ; 00224 00225 void triangulateSingularToricFace 00226 (SESFace* face, 00227 const double& probe_radius) 00228 ; 00229 00230 void triangulateNonSingularToricFace 00231 (SESFace* face, 00232 const double& probe_radius) 00233 ; 00234 00235 void partitionSingularEdge(SESEdge* singular_edge) 00236 ; 00237 00238 void partitionFreeSingularEdge(SESEdge* singular_edge) 00239 ; 00240 00241 void partitionNonFreeSingularEdge(SESEdge* singular_edge) 00242 ; 00243 00244 void triangulateContactFace 00245 (SESFace* face, 00246 const TSphere3<double>& sphere) 00247 ; 00248 00249 bool triangulateSphericFace 00250 (SESFace* face, 00251 const TSphere3<double>& sphere) 00252 ; 00253 00254 bool buildSphericTriangles 00255 (SESFace* face, 00256 TriangulatedSES& part, 00257 const TSphere3<double>& sphere, 00258 bool convex = true) 00259 ; 00260 00261 bool buildFirstTriangle 00262 (SESFace* face, 00263 TriangulatedSES& part, 00264 std::list<TriangleEdge*>& border, 00265 const TSphere3<double>& sphere, 00266 const HashSet<TrianglePoint*>& points, 00267 bool convex) 00268 ; 00269 00270 SESEdge* firstSESEdge(const std::list<SESEdge*>& sesedge) 00271 ; 00272 00273 void buildUnambiguousTriangle 00274 (TriangleEdge* edge, 00275 TrianglePoint* point, 00276 std::list<TriangleEdge*>& border, 00277 const TSphere3<double>& sphere, 00278 TriangulatedSES& part, 00279 bool convex 00280 ) 00281 ; 00282 00283 void buildAmbiguousTriangles 00284 (TriangleEdge* edge, 00285 std::list<TrianglePoint*> points, 00286 std::list<TriangleEdge*>& border, 00287 const TSphere3<double>& sphere, 00288 TriangulatedSES& part, 00289 bool convex 00290 ) 00291 ; 00292 00293 void createTriangleAndEdges 00294 (TriangleEdge* edge, 00295 TrianglePoint* point, 00296 const TSphere3<double>& sphere, 00297 TriangleEdge*& edge1, 00298 bool& old1, 00299 TriangleEdge*& edge2, 00300 bool& old2, 00301 Triangle*& triangle, 00302 bool convex 00303 ) 00304 ; 00305 00306 void partitionOfCircle 00307 (const TCircle3<double>& circle, 00308 const TVector3<double>& p0, 00309 const TAngle<double>& phi, 00310 Size number_of_segments, 00311 vector< TVector3<double> >& partition, 00312 bool on_surface = true) 00313 ; 00314 00315 Size numberOfRefinements(const double& density, const double& radius) 00316 ; 00317 00318 void buildTemplateSpheres() 00319 ; 00320 00321 void buildTriangles 00322 (SESEdge* edge0, 00323 SESEdge* edge1, 00324 SESEdge* edge2, 00325 SESEdge* edge3, 00326 const std::vector< TVector3<double> >& centers, 00327 const std::vector< TVector3<double> >& edge1_points, 00328 const std::vector< TVector3<double> >& edge3_points, 00329 const double& probe_radius) 00330 ; 00331 00333 00334 protected: 00335 00336 /*_ @name Attributes 00337 */ 00339 00340 TriangulatedSES* tses_; 00341 std::vector<TrianglePoint*> point_; 00342 std::vector<std::list<TriangleEdge*> > edge_; 00343 HashMap<Size, std::list<TrianglePoint*> > template_spheres_; 00344 double sqrt_density_; 00345 00347 00348 }; 00349 00350 00351 } // namespace BALL 00352 00353 00354 #endif // BALL_STRUCTURE_TRIANGULATEDSES_H