Ignore:
Timestamp:
Jul 7, 2009, 6:49:32 AM (16 years ago)
Author:
Frederik Heber <heber@…>
Children:
eeae5b
Parents:
899029f
Message:

All of Saskia Metzler's changes so far to remove bugs from Tesselation (still not working)

Principle ideas:

  • allow maximum of two triangles per triple of atomic indices to also tesselate "flat" areas
  • detect degeneracies by having a list of candidates and adding multiple triangles (one for each) by an angle criteria

New functions:

  • existsIntersection(): Checks per distance minimiser whether two lines intersect (for intersecting triangles)
  • MinIntersectDistance(): Calculates the minimal distance between two lines (function to minimize)
  • sortCandidates(): Sorting function for the third point candidates
  • CheckPresenceOfTriangle(): For a triple of atomic indices, checks whether a triangle between them already exists (needed for allowing max of two triangles per triple)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • molecuilder/src/boundary.hpp

    r899029f rd2639f  
    55class BoundaryLineSet;
    66class BoundaryTriangleSet;
     7class CandidateForTesselation;
    78
    89// include config.h
     
    1718
    1819#include <gsl/gsl_poly.h>
    19 #include <gsl/gsl_matrix.h>
    20 #include <gsl/gsl_linalg.h>
    21 #include <gsl/gsl_multimin.h>
    22 #include <gsl/gsl_permutation.h>
    2320
    2421#include "linkedcell.hpp"
     
    2724template <typename T> void SetEndpointsOrdered(T endpoints[2], T endpoint1, T endpoint2)
    2825{
    29         if (endpoint1->Nr < endpoint2->Nr) {
    30                 endpoints[0] = endpoint1;
    31                 endpoints[1] = endpoint2;
    32         } else {
    33                 endpoints[0] = endpoint2;
    34                 endpoints[1] = endpoint1;
    35         }
     26  if (endpoint1->Nr < endpoint2->Nr) {
     27    endpoints[0] = endpoint1;
     28    endpoints[1] = endpoint2;
     29  } else {
     30    endpoints[0] = endpoint2;
     31    endpoints[1] = endpoint1;
     32  }
    3633};
    3734
    3835class BoundaryPointSet {
    39         public:
    40                 BoundaryPointSet();
    41                 BoundaryPointSet(atom *Walker);
    42                 ~BoundaryPointSet();
     36  public:
     37    BoundaryPointSet();
     38    BoundaryPointSet(atom *Walker);
     39    ~BoundaryPointSet();
    4340
    44                 void AddLine(class BoundaryLineSet *line);
     41    void AddLine(class BoundaryLineSet *line);
    4542
    46                 LineMap lines;
    47                 int LinesCount;
    48                 atom *node;
    49                 int Nr;
     43    LineMap lines;
     44    int LinesCount;
     45    atom *node;
     46    int Nr;
    5047};
    5148
    5249class BoundaryLineSet {
    53         public:
    54                 BoundaryLineSet();
    55                 BoundaryLineSet(class BoundaryPointSet *Point[2], int number);
    56                 ~BoundaryLineSet();
     50  public:
     51    BoundaryLineSet();
     52    BoundaryLineSet(class BoundaryPointSet *Point[2], int number);
     53    ~BoundaryLineSet();
    5754
    58                 void AddTriangle(class BoundaryTriangleSet *triangle);
     55    void AddTriangle(class BoundaryTriangleSet *triangle);
    5956
    60                 class BoundaryPointSet *endpoints[2];
    61                 TriangleMap triangles;
    62                 int TrianglesCount;
    63                 int Nr;
     57    class BoundaryPointSet *endpoints[2];
     58    TriangleMap triangles;
     59    int TrianglesCount;
     60    int Nr;
    6461};
    6562
    6663class BoundaryTriangleSet {
    67         public:
    68                 BoundaryTriangleSet();
    69                 BoundaryTriangleSet(class BoundaryLineSet *line[3], int number);
    70                 ~BoundaryTriangleSet();
     64  public:
     65    BoundaryTriangleSet();
     66    BoundaryTriangleSet(class BoundaryLineSet *line[3], int number);
     67    ~BoundaryTriangleSet();
    7168
    72                 void GetNormalVector(Vector &NormalVector);
     69    void GetNormalVector(Vector &NormalVector);
    7370
    74                 class BoundaryPointSet *endpoints[3];
    75                 class BoundaryLineSet *lines[3];
    76                 Vector NormalVector;
    77                 int Nr;
     71    class BoundaryPointSet *endpoints[3];
     72    class BoundaryLineSet *lines[3];
     73    Vector NormalVector;
     74    int Nr;
    7875};
    7976
     77
     78class CandidateForTesselation {
     79  public :
     80        CandidateForTesselation(atom* candidate, BoundaryLineSet* currentBaseLine, Vector OptCandidateCenter, Vector OtherOptCandidateCenter);
     81        ~CandidateForTesselation();
     82        atom *point;
     83        BoundaryLineSet *BaseLine;
     84        Vector OptCenter;
     85        Vector OtherOptCenter;
     86};
     87
     88
    8089class Tesselation {
    81         public:
     90  public:
    8291
    83                 Tesselation();
    84                 ~Tesselation();
     92    Tesselation();
     93    ~Tesselation();
    8594
    86                 void TesselateOnBoundary(ofstream *out, config *configuration, molecule *mol);
    87                 void GuessStartingTriangle(ofstream *out);
    88                 void AddPoint(atom * Walker);
    89                 void AddTrianglePoint(atom* Candidate, int n);
    90                 void AddTriangleLine(class BoundaryPointSet *a, class BoundaryPointSet *b, int n);
    91                 void AddTriangleToLines();
    92                 void Find_starting_triangle(ofstream *out, molecule* mol, const double RADIUS, LinkedCell *LC);
    93                 bool Find_next_suitable_triangle(ofstream *out, molecule* mol, BoundaryLineSet &Line, BoundaryTriangleSet &T, const double& RADIUS, int N, const char *filename, LinkedCell *LC);
    94                 bool CheckPresenceOfTriangle(ofstream *out, atom *Candidates[3]);
    95                 void Find_next_suitable_point_via_Angle_of_Sphere(atom* a, atom* b, atom* c, atom* Candidate, atom* Parent, int RecursionLevel, Vector *Chord, Vector *direction1, Vector *OldNormal, Vector ReferencePoint, atom*& Opt_Candidate, double *Storage, const double RADIUS, molecule* mol);
     95    void TesselateOnBoundary(ofstream *out, config *configuration, molecule *mol);
     96    void GuessStartingTriangle(ofstream *out);
     97    void AddPoint(atom * Walker);
     98    void AddTrianglePoint(atom* Candidate, int n);
     99    void AddTriangleLine(class BoundaryPointSet *a, class BoundaryPointSet *b, int n);
     100    void AlwaysAddTriangleLine(class BoundaryPointSet *a, class BoundaryPointSet *b, int n);
     101    void AddTriangleToLines();
     102    void Find_starting_triangle(ofstream *out, molecule* mol, const double RADIUS, LinkedCell *LC);
     103    bool Find_next_suitable_triangle(ofstream *out, molecule* mol, BoundaryLineSet &Line, BoundaryTriangleSet &T, const double& RADIUS, int N, const char *filename, LinkedCell *LC);
     104    int CheckPresenceOfTriangle(ofstream *out, atom *Candidates[3]);
     105    void Find_next_suitable_point_via_Angle_of_Sphere(atom* a, atom* b, atom* c, atom* Candidate, atom* Parent, int RecursionLevel, Vector *Chord, Vector *direction1, Vector *OldNormal, Vector ReferencePoint, atom*& Opt_Candidate, double *Storage, const double RADIUS, molecule* mol);
    96106
    97                 PointMap PointsOnBoundary;
    98                 LineMap LinesOnBoundary;
    99                 TriangleMap TrianglesOnBoundary;
    100                 class BoundaryPointSet *TPS[3]; //this is a Storage for pointers to triangle points, this and BPS[2] needed due to AddLine restrictions
    101                 class BoundaryPointSet *BPS[2];
    102                 class BoundaryLineSet *BLS[3];
    103                 class BoundaryTriangleSet *BTS;
    104                 int PointsOnBoundaryCount;
    105                 int LinesOnBoundaryCount;
    106                 int TrianglesOnBoundaryCount;
    107                 int TriangleFilesWritten;
     107    PointMap PointsOnBoundary;
     108    LineMap LinesOnBoundary;
     109    TriangleMap TrianglesOnBoundary;
     110    class BoundaryPointSet *TPS[3]; //this is a Storage for pointers to triangle points, this and BPS[2] needed due to AddLine restrictions
     111    class BoundaryPointSet *BPS[2];
     112    class BoundaryLineSet *BLS[3];
     113    class BoundaryTriangleSet *BTS;
     114    int PointsOnBoundaryCount;
     115    int LinesOnBoundaryCount;
     116    int TrianglesOnBoundaryCount;
     117    int TriangleFilesWritten;
    108118};
    109119
     
    117127double * GetDiametersOfCluster(ofstream *out, Boundaries *BoundaryPtr, molecule *mol, bool IsAngstroem);
    118128void PrepareClustersinWater(ofstream *out, config *configuration, molecule *mol, double ClusterVolume, double celldensity);
    119 void Find_non_convex_border(ofstream *out, molecule* mol, class Tesselation *T, class LinkedCell *LCList, const char *tempbasename, const double RADIUS);
     129void Find_non_convex_border(ofstream *out, molecule* mol, class Tesselation *T, class LinkedCell *LC, const char *tempbasename, const double RADIUS);
    120130void Find_next_suitable_point(class BoundaryTriangleSet *BaseTriangle, class BoundaryLineSet *BaseLine, atom*& OptCandidate, Vector *OptCandidateCenter, double *ShortestAngle, const double RADIUS, LinkedCell *LC);
    121 
     131bool Choose_preferable_third_point(atom *Candidate, atom *OptCandidate, class BoundaryLineSet *BaseLine, atom *ThirdNode, Tesselation *Tess);
     132bool existsIntersection(Vector point1, Vector point2, Vector point3, Vector point4);
     133bool sortCandidates(CandidateForTesselation* candidate1, CandidateForTesselation* candidate2);
    122134
    123135#endif /*BOUNDARY_HPP_*/
Note: See TracChangeset for help on using the changeset viewer.