Ignore:
Timestamp:
Aug 10, 2009, 4:11:47 PM (16 years ago)
Author:
Frederik Heber <heber@…>
Children:
ada6d2
Parents:
0cf171
Message:

New function ConvexizeNonconvexEnvelope() to calculate the volume of a non-convex envelope.

The central idea is that the volume of a convex envelope is easy to determine as a sum of pyramids with respect to a center inside the envelope. Hence, if we can "reduce" the non-convex envelope to a convex one in such a way that we know the added volume, we may determine the volume of a non-convex envelope.
The nice side effect is that we may use our Find_non_convex_border() algorithm to calculate also the convex envelope.

  • We go through all BoundaryPoints and check whether one of its Baselines does not fulfill the ConvexCriterion. If so, we remove it, as it can not be a boundary point on the convex envelope, and re-construct the attached triangles. The added volume is a general tetraeder, whose formula is known.
  • FIX: Find_convex_border() - We check whether AddPoint is successful or not.
  • builder.cpp: case 'o' - changed to use ConvexizeNonconvexEnvelope() instead of Find_convex_border()
  • Tesselation:AddPoint() - now takes second argument which is the index for BPS and always set BPS to either the newly created or the already present point. Return argument discerns between new and already present point.
  • Tesselation::BPS, BLS, BTS are now public not private. We have to access them from ConvexizeNonconvexEnvelope()
File:
1 edited

Legend:

Unmodified
Added
Removed
  • molecuilder/src/tesselation.cpp

    r0cf171 r70c4567  
    208208 * \return NULL - if endpoint not contained in BoundaryLineSet, or pointer to BoundaryPointSet otherwise
    209209 */
    210 inline class BoundaryPointSet *BoundaryLineSet::GetOtherEndpoint(class BoundaryPointSet *point)
     210class BoundaryPointSet *BoundaryLineSet::GetOtherEndpoint(class BoundaryPointSet *point)
    211211{
    212212  if (endpoints[0] == point)
     
    10441044        // add Walker to boundary points
    10451045        *out << Verbose(2) << "Adding " << *Walker << " to BoundaryPoints." << endl;
    1046         AddPoint(Walker);
    1047         if (BPS[0] != NULL)
     1046        if (AddPoint(Walker,0))
    10481047          NewPoint = BPS[0];
    10491048        else
     
    11001099/** Adds an point to the tesselation::PointsOnBoundary list.
    11011100 * \param *Walker point to add
    1102  */
    1103 void
    1104 Tesselation::AddPoint(TesselPoint *Walker)
     1101 * \param n TesselStruct::BPS index to put pointer into
     1102 * \return true - new point was added, false - point already present
     1103 */
     1104bool
     1105Tesselation::AddPoint(TesselPoint *Walker, int n)
    11051106{
    11061107  PointTestPair InsertUnique;
    1107   BPS[0] = new class BoundaryPointSet(Walker);
    1108   InsertUnique = PointsOnBoundary.insert(PointPair(Walker->nr, BPS[0]));
    1109   if (InsertUnique.second) // if new point was not present before, increase counter
     1108  BPS[n] = new class BoundaryPointSet(Walker);
     1109  InsertUnique = PointsOnBoundary.insert(PointPair(Walker->nr, BPS[n]));
     1110  if (InsertUnique.second) { // if new point was not present before, increase counter
    11101111    PointsOnBoundaryCount++;
    1111   else {
    1112     delete(BPS[0]);
    1113     BPS[0] = NULL;
     1112    return true;
     1113  } else {
     1114    delete(BPS[n]);
     1115    BPS[n] = InsertUnique.first->second;
     1116    return false;
    11141117  }
    11151118}
Note: See TracChangeset for help on using the changeset viewer.