00001
00002
00003
00004
00005
00006
00007 #ifndef BALL_STRUCTURE_TRIANGULATEDSES_H
00008 #define BALL_STRUCTURE_TRIANGULATEDSES_H
00009
00010 #ifndef BALL_TRUCTURE_SOLVENTEXCLUDEDSURFACE_H
00011 # include <BALL/STRUCTURE/solventExcludedSurface.h>
00012 #endif
00013
00014 #ifndef BALL_STRUCTURE_TRIANGLE_H
00015 # include <BALL/STRUCTURE/triangle.h>
00016 #endif
00017
00018 #ifndef BALL_STRUCTURE_TRIANGLEEDGE_H
00019 # include <BALL/STRUCTURE/triangleEdge.h>
00020 #endif
00021
00022 #ifndef BALL_STRUCTURE_TRIANGLEPOINT_H
00023 # include <BALL/STRUCTURE/trianglePoint.h>
00024 #endif
00025
00026 #ifndef BALL_STRUCTURE_TRIANGULATEDSURFACE_H
00027 # include <BALL/STRUCTURE/triangulatedSurface.h>
00028 #endif
00029
00030 #ifndef BALL_MATHS_ANGLE_H
00031 # include <BALL/MATHS/angle.h>
00032 #endif
00033
00034 #ifndef BALL_MATHS_CIRCLE3_H
00035 # include <BALL/MATHS/circle3.h>
00036 #endif
00037
00038 #ifndef BALL_MATHS_SPHERE3_H
00039 # include <BALL/MATHS/sphere3.h>
00040 #endif
00041
00042 #ifndef BALL_MATHS_VECTOR3_H
00043 # include <BALL/MATHS/vector3.h>
00044 #endif
00045
00046 #include <list>
00047 #include <vector>
00048
00049 namespace BALL
00050 {
00051 class SESTriangulator;
00052
00056 class BALL_EXPORT TriangulatedSES : public TriangulatedSurface
00057 {
00058
00059 public:
00060
00066 friend class SESTriangulator;
00067
00068 BALL_CREATE(TriangulatedSES)
00069
00070
00073
00077 TriangulatedSES()
00078 ;
00079
00085 TriangulatedSES(const TriangulatedSES& surface, bool = true)
00086 ;
00087
00093 TriangulatedSES(SolventExcludedSurface* ses, const double& density)
00094 ;
00095
00099 virtual ~TriangulatedSES()
00100 ;
00102
00106
00111 void set(const TriangulatedSES& surface, bool = true)
00112 ;
00113
00117 TriangulatedSES& operator = (const TriangulatedSES& surface)
00118 ;
00119
00122 void setDensity(const double& density)
00123 ;
00124
00127 double getDensity() const
00128 ;
00129
00131
00135
00136 void compute()
00137 throw(Exception::GeneralException,Exception::DivisionByZero);
00138
00140
00141 protected:
00142
00143
00144
00146
00147 SolventExcludedSurface* ses_;
00148
00149 double density_;
00150
00152
00153 };
00154
00155
00156
00163 class BALL_EXPORT SESTriangulator
00164 {
00165
00166 public:
00167
00168 BALL_CREATE(SESTriangulator)
00169
00170
00173
00177 SESTriangulator()
00178 ;
00179
00183 SESTriangulator(TriangulatedSES* tses)
00184 ;
00185
00189 virtual ~SESTriangulator()
00190 ;
00192
00196
00197 void run()
00198 throw(Exception::GeneralException,Exception::DivisionByZero);
00199
00200 private:
00201
00202 void preProcessing()
00203 ;
00204
00205 void triangulateToricFaces()
00206 ;
00207
00208 void partitionSingularEdges()
00209 ;
00210
00211 void triangulateContactFaces()
00212 ;
00213
00214 void triangulateSphericFaces()
00215 ;
00216
00217 void triangulateToricFace
00218 (SESFace* face,
00219 const double& probe_radius)
00220 ;
00221
00222 void triangulateFreeToricFace
00223 (SESFace* face,
00224 const double& probe_radius)
00225 ;
00226
00227 void triangulateSingularToricFace
00228 (SESFace* face,
00229 const double& probe_radius)
00230 ;
00231
00232 void triangulateNonSingularToricFace
00233 (SESFace* face,
00234 const double& probe_radius)
00235 ;
00236
00237 void partitionSingularEdge(SESEdge* singular_edge)
00238 ;
00239
00240 void partitionFreeSingularEdge(SESEdge* singular_edge)
00241 ;
00242
00243 void partitionNonFreeSingularEdge(SESEdge* singular_edge)
00244 ;
00245
00246 void triangulateContactFace
00247 (SESFace* face,
00248 const TSphere3<double>& sphere)
00249 ;
00250
00251 bool triangulateSphericFace
00252 (SESFace* face,
00253 const TSphere3<double>& sphere)
00254 ;
00255
00256 bool buildSphericTriangles
00257 (SESFace* face,
00258 TriangulatedSES& part,
00259 const TSphere3<double>& sphere,
00260 bool convex = true)
00261 ;
00262
00263 bool buildFirstTriangle
00264 (SESFace* face,
00265 TriangulatedSES& part,
00266 std::list<TriangleEdge*>& border,
00267 const TSphere3<double>& sphere,
00268 const HashSet<TrianglePoint*>& points,
00269 bool convex)
00270 ;
00271
00272 SESEdge* firstSESEdge(const std::list<SESEdge*>& sesedge)
00273 ;
00274
00275 void buildUnambiguousTriangle
00276 (TriangleEdge* edge,
00277 TrianglePoint* point,
00278 std::list<TriangleEdge*>& border,
00279 const TSphere3<double>& sphere,
00280 TriangulatedSES& part,
00281 bool convex
00282 )
00283 ;
00284
00285 void buildAmbiguousTriangles
00286 (TriangleEdge* edge,
00287 std::list<TrianglePoint*> points,
00288 std::list<TriangleEdge*>& border,
00289 const TSphere3<double>& sphere,
00290 TriangulatedSES& part,
00291 bool convex
00292 )
00293 ;
00294
00295 void createTriangleAndEdges
00296 (TriangleEdge* edge,
00297 TrianglePoint* point,
00298 const TSphere3<double>& sphere,
00299 TriangleEdge*& edge1,
00300 bool& old1,
00301 TriangleEdge*& edge2,
00302 bool& old2,
00303 Triangle*& triangle,
00304 bool convex
00305 )
00306 ;
00307
00308 void partitionOfCircle
00309 (const TCircle3<double>& circle,
00310 const TVector3<double>& p0,
00311 const TAngle<double>& phi,
00312 Size number_of_segments,
00313 vector< TVector3<double> >& partition,
00314 bool on_surface = true)
00315 ;
00316
00317 Size numberOfRefinements(const double& density, const double& radius)
00318 ;
00319
00320 void buildTemplateSpheres()
00321 ;
00322
00323 void buildTriangles
00324 (SESEdge* edge0,
00325 SESEdge* edge1,
00326 SESEdge* edge2,
00327 SESEdge* edge3,
00328 const std::vector< TVector3<double> >& centers,
00329 const std::vector< TVector3<double> >& edge1_points,
00330 const std::vector< TVector3<double> >& edge3_points,
00331 const double& probe_radius)
00332 ;
00333
00335
00336 protected:
00337
00338
00339
00341
00342 TriangulatedSES* tses_;
00343 std::vector<TrianglePoint*> point_;
00344 std::vector<std::list<TriangleEdge*> > edge_;
00345 HashMap<Size, std::list<TrianglePoint*> > template_spheres_;
00346 double sqrt_density_;
00347
00349
00350 };
00351
00352
00353 }
00354
00355
00356 #endif // BALL_STRUCTURE_TRIANGULATEDSES_H