BALL 1.5.0
solventExcludedSurface.h
Go to the documentation of this file.
1// -*- Mode: C++; tab-width: 2; -*-
2// vi: set ts=2:
3//
4
5#ifndef BALL_STRUCTURE_SOLVENTEXCLUDEDSURFACE_H
6#define BALL_STRUCTURE_SOLVENTEXCLUDEDSURFACE_H
7
8#ifndef BALL_STRUCTURE_SESEDGE_H
10#endif
11
12#ifndef BALL_STRUCTURE_SESFACE_H
14#endif
15
16#ifndef BALL_STRUCTURE_SESVERTEX_H
18#endif
19
20#ifndef BALL_STRUCTURE_REDUCEDSURFACE_H
22#endif
23
24#ifndef BALL_MATHS_ANGLE_H
25# include <BALL/MATHS/angle.h>
26#endif
27
28#ifndef BALL_MATHS_CIRCLE3_H
29# include <BALL/MATHS/circle3.h>
30#endif
31
32#ifndef BALL_MATHS_SPHERE3_H
33# include <BALL/MATHS/sphere3.h>
34#endif
35
36#ifndef BALL_MATHS_VECTOR3_H
37# include <BALL/MATHS/vector3.h>
38#endif
39
40#ifndef BALL_MATHS_VECTOR4_H
41# include <BALL/MATHS/vector4.h>
42#endif
43
44#ifndef BALL_DATATYPE_HASHGRID_H
46#endif
47
48#ifndef BALL_DATATYPE_HASHMAP_H
50#endif
51
52#include <vector>
53#include <list>
54
55
56namespace BALL
57{
58 class SESComputer;
59 class SESSingularityCleaner;
60 class TriangulatedSES;
61 class SESTriangulator;
62
67 {
68 public:
69
78 friend class SESComputer;
80 friend class TriangulatedSES;
81 friend class SESTriangulator;
82
84
85
88
89 typedef std::vector<SESVertex*>::iterator
91 typedef std::vector<SESVertex*>::const_iterator
93 typedef std::vector<SESEdge*>::iterator
95 typedef std::vector<SESEdge*>::const_iterator
97 typedef std::list<SESEdge*>::iterator
99 typedef std::list<SESEdge*>::const_iterator
101 typedef std::vector<SESFace*>::iterator
103 typedef std::vector<SESFace*>::const_iterator
105 typedef std::vector<SESFace*>::iterator
107 typedef std::vector<SESFace*>::const_iterator
109 typedef std::vector<SESFace*>::iterator
111 typedef std::vector<SESFace*>::const_iterator
113
115
118
123
130 (const SolventExcludedSurface& ses, bool = false);
131
135
140 ;
141
143
146
147 void clear();
148
149 void clean(const double& density);
150
154 void compute();
155
157 ;
158
159 bool check()
160 ;
161
163
166
168 ;
170 ;
172 ;
174 ;
175
177 ;
179 ;
181 ;
183 ;
184
186 ;
188 ;
190 ;
192 ;
193
195 ;
197 ;
199 ;
201 ;
202
204 ;
206 ;
208 ;
210 ;
211
213 ;
215 ;
217 ;
219 ;
220
222
223 private:
224
225 void splitSphericFace(Position i)
226 ;
227
228 void deleteSmallToricFace(SESFace* face)
229 ;
230
231 void deleteSmallSingularToricFace(SESFace* face)
232 ;
233
234 bool cleanToricFace(SESFace* face, const double& sqrt_density)
235 ;
236
237 bool cleanSingularToricFace(SESFace* face, const double& sqrt_density)
238 ;
239
240 void cleanVertices()
241 ;
242
243 void cleanEdges()
244 ;
245
246 void cleanContactFaces()
247 ;
248
249 void cleanToricFaces()
250 ;
251
252 void cleanSphericFaces()
253 ;
254
255
256 protected:
257
258 /*_ the number of vertices of the solvent exluded surface
259 */
261 /*_ the vertices of the solvent exluded surface
262 */
263 ::std::vector<SESVertex*> vertices_;
264 /*_ the number of edges of the solvent exluded surface
265 */
267 /*_ the edges of the solvent exluded surface
268 */
269 ::std::vector<SESEdge*> edges_;
270 /*_ the number of singular edges of the solvent exluded surface
271 */
273 /*_ the singular edges of the solvent exluded surface
274 */
275 ::std::list<SESEdge*> singular_edges_;
276 /*_ the number of contact faces of the solvent exluded surface
277 */
279 /*_ the contact faces of the solvent exluded surface
280 */
281 ::std::vector<SESFace*> contact_faces_;
282 /*_ the number of toric reentrant faces of the solvent exluded surface
283 */
285 /*_ the toric reentrant faces of the solvent exluded surface
286 */
287 ::std::vector<SESFace*> toric_faces_;
288 /*_ the number of spheric reentrant faces of the solvent exluded surface
289 */
291 /*_ the spheric reentrant faces of the solvent exluded surface
292 */
293 ::std::vector<SESFace*> spheric_faces_;
294 /*_ the corresponding reduced surface
295 */
297
298 };
299
300
304
307 BALL_EXPORT std::ostream& operator <<
308 (std::ostream& s, const SolventExcludedSurface& ses);
309
311
312
313
318 {
319 public:
320
322
323
326
327
331 ;
332
336 ;
337
341 virtual ~SESComputer()
342 ;
343
345
348
352 void run();
353
355
356 private:
357
358 /*_ @name SES computation (private)
359 */
361
362 void preProcessing()
363 ;
364
365 void get()
366 ;
367
368 void createSphericFace(Position j)
369 ;
370
371 SESVertex* createVertex
372 (const TVector3<double>& probe_center,
373 Index index)
374 ;
375
376 void pushVertex
377 (SESFace* face,
378 const TSphere3<double>& probe,
379 RSVertex* rsvertex)
380 ;
381
382 SESEdge* createConcaveEdge
383 (SESFace* spheric_face,
384 Position p1,
385 Position p2,
386 Index index,
387 const double& radius_of_probe)
388 ;
389
390 void pushConcaveEdge
391 (SESFace* face,
392 Position p1,
393 Position p2,
394 const double& radius_of_probe)
395 ;
396
397 SESEdge* createConvexEdge
398 (SESFace* toric_face,
399 RSVertex* rsvertex)
400 ;
401
402 void createToricFace(Position i)
403 ;
404
405 void treatSingularToricFace(Position i)
406 ;
407
408 void createFreeToricFace(Position i)
409 ;
410
411 SESVertex* createSingularVertex
412 (Position ip,
413 const TVector3<double>& dir,
414 SESFace* face0,
415 SESFace* face1,
416 SESFace* face2,
417 SESEdge* edge0,
418 SESEdge* edge1,
419 SESEdge* edge2)
420 ;
421
422 void updateEdge
423 (SESEdge* edge,
424 SESVertex* vertex1,
425 SESVertex* vertex2,
426 bool is_new)
427 ;
428
429 void getPoint
430 (const TVector3<double>& p1,
431 const TVector3<double>& p2,
432 const double& dist,
433 TVector3<double>& result);
434
435 Index vertexExists(const TVector3<double>& point);
436
438
439
440 protected:
441
442 /*_ a pointer to the solvent excluded surface to compute
443 */
445 /*_ a HashGrid to store and find the vertices in an efficient way
446 */
447 HashGrid3<Index> vertex_grid_;
448 };
449
450
451
452
457 {
458 public:
459
461
462 typedef std::pair< std::pair<TAngle<double>,Index>,TVector3<double> > Intersection;
463
465 {
467 };
468
469 friend class SESComputer;
470
474
479 ;
480
485 HashGrid3<Index>* vertex_grid_)
486 ;
487
492 ;
493
495
498
502 bool run();
503
505
506 private:
507
511
512 Index vertexExists(TVector3<double> point)
513 ;
514
515 void treatSingularities()
516 ;
517
518 void getSingularFaces(std::list<SESFace*>& faces)
519 ;
520
521 bool treatFirstCategory()
522 ;
523
524 void treatSecondCategory()
525 ;
526
527 void getFirstCategoryFaces(std::list<SESFace*>& first_category_faces)
528 ;
529
530 void noCut(SESFace* face1, SESFace* face2)
531 ;
532
533 void twoCuts(SESFace* face1, SESFace* face2)
534 ;
535
536 void treatSingularEdge
537 (SESEdge* edge,
539 ::std::list<SESEdge*>& deletable_edges)
540 ;
541
542 void getIntersectionsOfSingularEdge
543 (SESEdge* edge,
544 const TAngle<double>& phi,
546 std::list<Intersection>& intersections)
547 ;
548
549 bool getIntersectionPointsAndAngles
550 (const TCircle3<double>& circle,
551 const TVector3<double>& point,
552 Position index1,
553 Position index2,
554 Position probe_index,
555 TAngle<double>& phi1,
556 TVector3<double>& point1,
557 TAngle<double>& phi2,
558 TVector3<double>& point2)
559 ;
560
561 bool isIntersection
562 (const TAngle<double>& min_phi,
563 const TAngle<double>& max_phi,
564 const TAngle<double>& phi,
565 const TVector3<double>& middle,
566 const TSphere3<double>& probe)
567 ;
568
569 void buildEndEdges
570 (SESEdge* edge,
571 const std::list<Intersection>& min,
572 const std::list<Intersection>& max,
573 SESVertex*& vertex1,
574 SESVertex*& vertex2,
575 Index& actual_min,
576 Index& actual_max)
577 ;
578
579 void buildEdge
580 (SESEdge* edge,
581 Index face1,
582 Index& face2,
583 Index end,
584 SESVertex*& vertex,
585 const HashSet<Index>& indices,
586 bool minimum);
587
588 void getExtrema
589 (const std::list<Intersection>& intersections,
590 std::list<Intersection>& min,
591 std::list<Intersection>& max);
592
593 void buildEndEdge
594 (SESEdge* edge,
595 const std::list<Intersection>& extrema,
596 SESVertex*& vertex,
597 Index& actual_extremum,
598 bool min);
599
600 bool probeIntersection
601 (Index face1,
602 Index face2,
603 Index face3,
604 TVector3<double>& point1,
605 TVector3<double>& point2);
606
607 void sort
608 (SESFace* face1,
609 SESFace* face2,
610 std::vector<SESEdge*>& sesedge1,
611 std::vector<SESEdge*>& sesedge2,
612 std::vector<SESVertex*>& sesvertex1,
613 std::vector<SESVertex*>& sesvertex2);
614
615 void sort
616 (Index u1, Index u2, Index u3,
617 Index& s1, Index& s2, Index& s3);
618
620
621
622 protected:
623
624 /*_ a pointer to the solvent excluded surface to compute
625 */
627 /*_ a pointer to a HashGrid to store and find the vertices
628 in an efficient way
629 */
631 /*_ for each triple of probe spheres its intersections
632 */
637 >
638 >
640
641 };
642
643
644} // namespace BALL
645
646#endif // BALL_STRUCTURE_SOLVENTEXCLUDEDSURFACE_H
#define BALL_CREATE(name)
Definition: create.h:62
STL namespace.
Definition: constants.h:13
BALL_SIZE_TYPE Position
T max(const T &a, const T &b)
Definition: MATHS/common.h:75
T min(const T &a, const T &b)
Definition: MATHS/common.h:102
Three-dimensional Hash Grid Class.
Definition: hashGrid.h:755
HashMap class based on the STL map (containing serveral convenience functions)
Definition: hashMap.h:74
std::list< SESEdge * >::const_iterator ConstSingularEdgeIterator
ConstEdgeIterator beginEdge() const
SphericFaceIterator endSphericFace()
VertexIterator endVertex()
std::vector< SESEdge * >::const_iterator ConstEdgeIterator
std::vector< SESFace * >::const_iterator ConstToricFaceIterator
SingularEdgeIterator endSingularEdge()
std::vector< SESFace * >::iterator ToricFaceIterator
::std::vector< SESEdge * > edges_
SolventExcludedSurface(ReducedSurface *reduced_surface)
ConstSphericFaceIterator beginSphericFace() const
VertexIterator beginVertex()
ConstVertexIterator beginVertex() const
std::vector< SESVertex * >::const_iterator ConstVertexIterator
SingularEdgeIterator beginSingularEdge()
std::vector< SESVertex * >::iterator VertexIterator
std::vector< SESFace * >::iterator SphericFaceIterator
std::vector< SESFace * >::iterator ContactFaceIterator
SphericFaceIterator beginSphericFace()
ConstToricFaceIterator endToricFace() const
ConstContactFaceIterator endContactFace() const
::std::list< SESEdge * > singular_edges_
ContactFaceIterator beginContactFace()
ToricFaceIterator beginToricFace()
ConstContactFaceIterator beginContactFace() const
::std::vector< SESFace * > spheric_faces_
std::vector< SESFace * >::const_iterator ConstContactFaceIterator
ConstSingularEdgeIterator beginSingularEdge() const
ToricFaceIterator endToricFace()
std::vector< SESFace * >::const_iterator ConstSphericFaceIterator
::std::vector< SESFace * > toric_faces_
std::vector< SESEdge * >::iterator EdgeIterator
ContactFaceIterator endContactFace()
ConstSingularEdgeIterator endSingularEdge() const
::std::vector< SESVertex * > vertices_
::std::vector< SESFace * > contact_faces_
ConstVertexIterator endVertex() const
ConstEdgeIterator endEdge() const
std::list< SESEdge * >::iterator SingularEdgeIterator
SolventExcludedSurface(const SolventExcludedSurface &ses, bool=false)
ConstSphericFaceIterator endSphericFace() const
void clean(const double &density)
ConstToricFaceIterator beginToricFace() const
SolventExcludedSurface * ses_
std::pair< std::pair< TAngle< double >, Index >, TVector3< double > > Intersection
HashMap< Position, HashMap< Position, HashMap< Position, ProbeIntersection * > > > probe_intersections_
SESSingularityCleaner(SolventExcludedSurface *ses, HashGrid3< Index > *vertex_grid_)
#define BALL_EXPORT
Definition: COMMON/global.h:50