Ignore:
Timestamp:
Aug 18, 2009, 8:42:39 AM (16 years ago)
Author:
Frederik Heber <heber@…>
Children:
daf5d6
Parents:
3de1d2
Message:

Further bugfixes to three-step-procedure in convex envelope, not yet working.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • molecuilder/src/boundary.cpp

    r3de1d2 r27459a  
    620620  }
    621621
     622  //CalculateConcavityPerBoundaryPoint(out, TesselStruct);
     623  StoreTrianglesinFile(out, mol, filename, "-first");
     624
    622625  // First step: RemovePointFromTesselatedSurface
    623626  PointRunner = TesselStruct->PointsOnBoundary.begin();
     
    641644  }
    642645
    643 
    644 //  // print all lines
    645 //  LineRunner = TesselStruct->LinesOnBoundary.begin();
    646 //  LineAdvance = LineRunner;  // we need an advanced line, as the LineRunner might get removed
    647 //  *out << Verbose(1) << "Printing all boundary lines for debugging." << endl;
    648 //  while (LineRunner != TesselStruct->LinesOnBoundary.end()) {
    649 //    LineAdvance++;
    650 //    line = LineRunner->second;
    651 //    *out << Verbose(2) << "INFO: Current line is " << *line << "." << endl;
    652 //    if (LineAdvance != TesselStruct->LinesOnBoundary.end())
    653 //      *out << Verbose(2) << "INFO: Next line will be " << *(LineAdvance->second) << "." << endl;
    654 //    LineRunner = LineAdvance;
    655 //  }
    656 //
    657 //  // print all triangles
    658 //  TriangleRunner = TesselStruct->TrianglesOnBoundary.begin();
    659 //  TriangleAdvance = TriangleRunner;  // we need an advanced line, as the LineRunner might get removed
    660 //  *out << Verbose(1) << "Printing all boundary triangles for debugging." << endl;
    661 //  while (TriangleRunner != TesselStruct->TrianglesOnBoundary.end()) {
    662 //    TriangleAdvance++;
    663 //    *out << Verbose(2) << "INFO: Current triangle is " << *(TriangleRunner->second) << "." << endl;
    664 //    if (TriangleAdvance != TesselStruct->TrianglesOnBoundary.end())
    665 //      *out << Verbose(2) << "INFO: Next triangle will be " << *(TriangleAdvance->second) << "." << endl;
    666 //    TriangleRunner = TriangleAdvance;
    667 //  }
     646  //CalculateConcavityPerBoundaryPoint(out, TesselStruct);
     647  StoreTrianglesinFile(out, mol, filename, "-second");
    668648
    669649  // second step: PickFarthestofTwoBaselines
     
    674654    line = LineRunner->second;
    675655    *out << Verbose(1) << "INFO: Picking farthest baseline for line is " << *line << "." << endl;
    676     if (LineAdvance != TesselStruct->LinesOnBoundary.end())
    677656    // take highest of both lines
    678     TesselStruct->PickFarthestofTwoBaselines(out, line);
     657    if (TesselStruct->IsConvexRectangle(out, line) == NULL)
     658      TesselStruct->PickFarthestofTwoBaselines(out, line);
    679659    LineRunner = LineAdvance;
    680660  }
    681661
    682   // calculate remaining concavity
    683   for (PointRunner = TesselStruct->PointsOnBoundary.begin(); PointRunner != TesselStruct->PointsOnBoundary.end(); PointRunner++) {
    684     point = PointRunner->second;
    685     *out << Verbose(1) << "INFO: Current point is " << *point << "." << endl;
    686     point->value = 0;
    687     for (LineMap::iterator LineRunner = point->lines.begin(); LineRunner != point->lines.end(); LineRunner++) {
    688       line = LineRunner->second;
    689       *out << Verbose(2) << "INFO: Current line of point " << *point << " is " << *line << "." << endl;
    690       if (!line->CheckConvexityCriterion(out))
    691         point->value += 1;
    692     }
    693   }
    694 
    695   // 4. Store triangles in tecplot file
    696   if (filename != NULL) {
    697     if (DoTecplotOutput) {
    698       string OutputName(filename);
    699       OutputName.append("_intermed");
    700       OutputName.append(TecplotSuffix);
    701       ofstream *tecplot = new ofstream(OutputName.c_str());
    702       write_tecplot_file(out, tecplot, mol->TesselStruct, mol, 0);
    703       tecplot->close();
    704       delete(tecplot);
    705     }
    706     if (DoRaster3DOutput) {
    707       string OutputName(filename);
    708       OutputName.append("_intermed");
    709       OutputName.append(Raster3DSuffix);
    710       ofstream *rasterplot = new ofstream(OutputName.c_str());
    711       write_raster3d_file(out, rasterplot, mol->TesselStruct, mol);
    712       rasterplot->close();
    713       delete(rasterplot);
    714     }
    715   }
     662  //CalculateConcavityPerBoundaryPoint(out, TesselStruct);
     663  StoreTrianglesinFile(out, mol, filename, "-third");
    716664
    717665  // third step: IsConvexRectangle
     
    735683  }
    736684
     685  CalculateConcavityPerBoundaryPoint(out, TesselStruct);
     686
     687  // end
     688  *out << Verbose(0) << "End of ConvexizeNonconvexEnvelope" << endl;
     689  return volume;
     690};
     691
     692/** Calculates the concavity for each of the BoundaryPointSet's in a Tesselation.
     693 * Sets BoundaryPointSet::value equal to the number of connected lines that are not convex.
     694 * \param *out output stream for debugging
     695 * \param *TesselStruct pointer to Tesselation structure
     696 */
     697void CalculateConcavityPerBoundaryPoint(ofstream *out, class Tesselation *TesselStruct)
     698{
     699  class BoundaryPointSet *point = NULL;
     700  class BoundaryLineSet *line = NULL;
    737701  // calculate remaining concavity
    738   for (PointRunner = TesselStruct->PointsOnBoundary.begin(); PointRunner != TesselStruct->PointsOnBoundary.end(); PointRunner++) {
     702  for (PointMap::iterator PointRunner = TesselStruct->PointsOnBoundary.begin(); PointRunner != TesselStruct->PointsOnBoundary.end(); PointRunner++) {
    739703    point = PointRunner->second;
    740704    *out << Verbose(1) << "INFO: Current point is " << *point << "." << endl;
     
    747711    }
    748712  }
    749 
     713};
     714
     715/** Stores triangles to file.
     716 * \param *out output stream for debugging
     717 * \param *mol molecule with atoms and bonds
     718 * \param *filename prefix of filename
     719 * \param *extraSuffix intermediate suffix
     720 */
     721void StoreTrianglesinFile(ofstream *out, molecule *mol, const char *filename, const char *extraSuffix)
     722{
    750723  // 4. Store triangles in tecplot file
    751724  if (filename != NULL) {
    752725    if (DoTecplotOutput) {
    753726      string OutputName(filename);
     727      OutputName.append(extraSuffix);
    754728      OutputName.append(TecplotSuffix);
    755729      ofstream *tecplot = new ofstream(OutputName.c_str());
     
    760734    if (DoRaster3DOutput) {
    761735      string OutputName(filename);
     736      OutputName.append(extraSuffix);
    762737      OutputName.append(Raster3DSuffix);
    763738      ofstream *rasterplot = new ofstream(OutputName.c_str());
     
    767742    }
    768743  }
    769 
    770   // end
    771   *out << Verbose(0) << "End of ConvexizeNonconvexEnvelope" << endl;
    772   return volume;
    773744};
    774745
Note: See TracChangeset for help on using the changeset viewer.