src/ccstruct/blobs.cpp
void TWERD::MergeBlobs(unsigned start, unsigned end) {
  if (end > blobs.size()) {
    end = blobs.size();
  }
  if (start >= end) {
    return; // Nothing to do.
  }
  TESSLINE *outline = blobs[start]->outlines;
  for (auto i = start + 1; i < end; ++i) {
    TBLOB *next_blob = blobs[i];
    // Take the outlines from the next blob.
    if (outline == nullptr) {
      blobs[start]->outlines = next_blob->outlines;
      outline = blobs[start]->outlines;
    } else {
      while (outline->next != nullptr) {
        outline = outline->next;
      }
      outline->next = next_blob->outlines;
      next_blob->outlines = nullptr;
    }
    // Delete the next blob and move on.
    delete next_blob;
    blobs[i] = nullptr;
  }
  // Remove dead blobs from the vector.
  // TODO: optimize.
  for (auto i = start + 1; i < end && start + 1 < blobs.size(); ++i) {
    blobs.erase(blobs.begin() + start + 1);
  }
}
// Merges the blobs from start to end, not including end, and deletes
// the blobs between start and end.
Merges the blobs from start to end, not including end, and deletes
the blobs between start and end.
Merges the blobs from start to end not including end and deletes the blobs between start and end .
void TWERD::MergeBlobs(unsigned start, unsigned end) {
  if (end > blobs.size()) {
    end = blobs.size();
  }
  if (start >= end) {
    return; 
  }
  TESSLINE *outline = blobs[start]->outlines;
  for (auto i = start + 1; i < end; ++i) {
    TBLOB *next_blob = blobs[i];
    if (outline == nullptr) {
      blobs[start]->outlines = next_blob->outlines;
      outline = blobs[start]->outlines;
    } else {
      while (outline->next != nullptr) {
        outline = outline->next;
      }
      outline->next = next_blob->outlines;
      next_blob->outlines = nullptr;
    }
    delete next_blob;
    blobs[i] = nullptr;
  }
  for (auto i = start + 1; i < end && start + 1 < blobs.size(); ++i) {
    blobs.erase(blobs.begin() + start + 1);
  }
}
void TWERD :: MergeBlobs ( unsigned start , unsigned end ) { if ( end > blobs . size ( ) ) { end = blobs . size ( ) ; } if ( start >= end ) { return ; } TESSLINE * outline = blobs [ start ] -> outlines ; for ( auto i = start + 1 ; i < end ; ++ i ) { TBLOB * next_blob = blobs [ i ] ; if ( outline == nullptr ) { blobs [ start ] -> outlines = next_blob -> outlines ; outline = blobs [ start ] -> outlines ; } else { while ( outline -> next != nullptr ) { outline = outline -> next ; } outline -> next = next_blob -> outlines ; next_blob -> outlines = nullptr ; } delete next_blob ; blobs [ i ] = nullptr ; } for ( auto i = start + 1 ; i < end && start + 1 < blobs . size ( ) ; ++ i ) { blobs . erase ( blobs . begin ( ) + start + 1 ) ; } }
Merges the blobs from start to end, not including end, and deletes
the blobs between start and end.
Merges the blobs from start to end not including end and deletes the blobs between start and end .
// Nothing to do. // Take the outlines from the next blob. // Delete the next blob and move on. // Remove dead blobs from the vector. // TODO: optimize.