Changeset 1db34af


Ignore:
Timestamp:
Nov 28, 2009, 3:48:41 PM (16 years ago)
Author:
Frederik Heber <heber@…>
Children:
f4df97
Parents:
2dff2d (diff), ea3627 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'FixDegeneratedTesselation' into CorrectDegeneratedPolygons

Conflicts:

molecuilder/src/tesselation.cpp

merge only necessary due to stupid git commit --amend

Signed-off-by: Frederik Heber <heber@…>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • molecuilder/src/tesselation.cpp

    r2dff2d r1db34af  
    41324132  /// 2. Go through all lines not contained in degenerated triangles.
    41334133  UniquePolygonSet ListofFours;
     4134  UniquePolygonSet TestedPolygons;
    41344135  for (LineMap::const_iterator LineRunner = LinesOnBoundary.begin(); LineRunner != LinesOnBoundary.end(); LineRunner++) {
    41354136    Log() << Verbose(1) << "Current Line is: " << *(LineRunner->second) << endl;
     
    41484149    TriangleSet *T = Four->GetAllContainedTrianglesFromEndpoints();
    41494150
    4150     /// 2c. check whether triangles are not already simply degenerated.
     4151    /// 2c1. Check whether all triangles have (besides sign) same normal vector)
     4152    TriangleSet::const_iterator Runner = T->begin();
     4153    Vector NormalVector;
     4154    NormalVector.CopyVector(&(*Runner)->NormalVector);
     4155    Runner++;
     4156    bool IsPlanar = true;
     4157    for (; Runner != T->end(); Runner++) {
     4158      if (fabs(fabs(NormalVector.ScalarProduct(&(*Runner)->NormalVector)) - 1.) > MYEPSILON)  // check whether all NormalVectors are parallel
     4159        IsPlanar = false;
     4160    }
     4161
     4162    /// 2c2. check whether triangles are not already simply degenerated.
    41514163    size_t DegeneratedCount = 0;
    41524164    for (TriangleSet::const_iterator Runner = T->begin(); Runner != T->end(); Runner++) {
     
    41554167    }
    41564168    Log() << Verbose(1) << "Found " << DegeneratedCount << " degenerated triangles." << endl;
    4157     if (DegeneratedCount == 0) {
    4158       /// 2c. Find all pairs of those triangles that contain the four endpoints
    4159       const int counter = CountTrianglePairContainingPolygon(Four, T);
    4160       Log() << Verbose(1) << "There are " << counter << " pairs for this polygon of four." << endl;
    4161       if (counter %3 == 0) {
    4162         /// 2d. Check the number of pairs, if greater 1, we have a degenerated polygon (mark down for later use)
    4163         pair < UniquePolygonSet::iterator, bool > Tester = ListofFours.insert(Four);
    4164         if (Tester.second) {
    4165           Log() << Verbose(0) << "ACCEPT: We have a degenerated polygon." << *Four << endl;
     4169
     4170    if (IsPlanar) {
     4171      if(DegeneratedCount == 0) {
     4172        /// 2c. Find all pairs of those triangles that contain the four endpoints
     4173        const int counter = CountTrianglePairContainingPolygon(Four, T);
     4174        Log() << Verbose(1) << "There are " << counter << " pairs for this polygon of four." << endl;
     4175        if (counter %3 == 0) {
     4176          /// 2d. Check the number of pairs, if greater 1, we have a degenerated polygon (mark down for later use)
     4177          pair < UniquePolygonSet::iterator, bool > Tester = ListofFours.insert(Four);
     4178          if (Tester.second) {
     4179            Log() << Verbose(0) << "ACCEPT: We have a degenerated polygon." << *Four << endl;
     4180          } else {
     4181            Log() << Verbose(0) << "REJECT: Degenerated polygon already present." << *Four << endl;
     4182            delete(Four);
     4183          }
    41664184        } else {
    4167           Log() << Verbose(0) << "REJECT: Degenerated polygon already present." << *Four << endl;
     4185          Log() << Verbose(0) << "REJECT: Seems to be the edge line of a degenerated polygon only." << *Four << endl;
    41684186          delete(Four);
    41694187        }
    41704188      } else {
    4171         Log() << Verbose(0) << "REJECT: Seems to be the edge line of a degenerated polygon only." << *Four << endl;
     4189        Log() << Verbose(0) << "REJECT: This polygon contains some simply degenerated triangles." << endl;
    41724190        delete(Four);
    41734191      }
    41744192    } else {
    4175       Log() << Verbose(0) << "REJECT: This polygon contains some simply degenerated triangles." << endl;
     4193      Log() << Verbose(0) << "REJECT: This polygon does not lay on a plane." << endl;
    41764194      delete(Four);
    41774195    }
Note: See TracChangeset for help on using the changeset viewer.