USGS

Isis 3.0 Developer's Reference (API)

Home

Isis::ImageOverlapSet Class Reference
[Pattern Matching]

This class is used to find the overlaps between all the images in a list of serial numbers. More...

#include <ImageOverlapSet.h>

Inherits QThread.

List of all members.

Public Member Functions

 ImageOverlapSet (bool continueOnError=false)
 Create FindImageOverlaps object.
virtual ~ImageOverlapSet ()
 Delete this object.
void FindImageOverlaps (SerialNumberList &boundaries)
 Create polygons of overlap from the images specified in the serial number list.
void FindImageOverlaps (std::vector< QString > sns, std::vector< geos::geom::MultiPolygon * > polygons)
 This is a strict pthread implementation of this class' multi-threading!
void FindImageOverlaps (SerialNumberList &boundaries, QString outputFile)
 This method calculates image overlaps given a SerialNumberList and writes it to the filename specified by outputFile.
void ReadImageOverlaps (const QString &filename)
 Create polygons of overlap from the file specified.
void WriteImageOverlaps (const QString &filename)
 Write polygons of overlap to the file specified.
int Size ()
 Returns the total number of latitude and longitude overlaps.
const ImageOverlapoperator[] (int index)
 Returns the images which overlap at a given loverlap.
std::vector< ImageOverlap * > operator[] (QString serialNumber)
 Return the overlaps that have a specific serial number.
const std::vector< PvlGroup > & Errors ()
 Return the a list of errors encountered.

Protected Member Functions

void FindAllOverlaps (SerialNumberList *snlist=NULL)
 Find the overlaps between all the existing ImageOverlap Objects.
void AddSerialNumbers (ImageOverlap *to, ImageOverlap *from)
 Add the serial numbers from the second overlap to the first.

Protected Attributes

std::vector< PvlGroupp_errorLog
 This is a list of detailed* errors including all known information.

Detailed Description

This class is used to find the overlaps between all the images in a list of serial numbers.

The overlaps are created in (Lon,Lat) coordinates of geos::geom::MultiPolygons. Each overlap has an associated list of serial numbers which are contained in that overlap.

Author:
2006-01-20 Stuart Sides

Constructor & Destructor Documentation

Isis::ImageOverlapSet::ImageOverlapSet ( bool  continueOnError = false  ) 

Create FindImageOverlaps object.

Create an empty FindImageOverlaps object.

Parameters:
continueOnError Whether or not this class throws exceptions in addition to logging errors.
See also:
automaticRegistration.doc
Isis::ImageOverlapSet::~ImageOverlapSet (  )  [virtual]

Delete this object.

Delete the FindImageOverlaps object. The stored ImageOverlaps will be deleted as well.

References Size().


Member Function Documentation

void Isis::ImageOverlapSet::AddSerialNumbers ( ImageOverlap to,
ImageOverlap from 
) [protected]

Add the serial numbers from the second overlap to the first.

Note: Need to check for existence of a SN before adding it

Parameters:
to The object to receive the new serial numbers
from The object to copy the serial numbers from

References Isis::ImageOverlap::Add(), and Isis::ImageOverlap::Size().

Referenced by FindAllOverlaps().

const std::vector<PvlGroup>& Isis::ImageOverlapSet::Errors (  )  [inline]

Return the a list of errors encountered.

References p_errorLog.

void Isis::ImageOverlapSet::FindAllOverlaps ( SerialNumberList snlist = NULL  )  [protected]
void Isis::ImageOverlapSet::FindImageOverlaps ( SerialNumberList boundaries,
QString  outputFile 
)

This method calculates image overlaps given a SerialNumberList and writes it to the filename specified by outputFile.

This method is internally optimized and multi-threaded: the overlaps will NOT persist in memory after this method is called. This object will be reset to its initial state when this is called, and it is invalid to call this method if you have called other methods first.

This method is internally multi-threaded and more efficient than the others for calculating overlaps.

Parameters:
boundaries The files to find overlaps between
outputFile The output ImageOverlapSet file

References _FILEINFO_, FindImageOverlaps(), Isis::IException::Programmer, and WriteImageOverlaps().

void Isis::ImageOverlapSet::FindImageOverlaps ( std::vector< QString >  sns,
std::vector< geos::geom::MultiPolygon * >  polygons 
)

This is a strict pthread implementation of this class' multi-threading!

void ImageOverlapSet::FindImageOverlaps(SerialNumberList &boundaries, QString outputFile) { Do a common sense programmer check, this should be empty before we start if(!p_lonLatOverlaps.empty()) { string msg = "FindImageOverlaps(SerialNumberList&,QString) may not be called on an ImageOverlapSet " \ "which already contains overlaps."; throw iException::Message(iException::Programmer, msg, _FILEINFO_); }

p_writtenSoFar = 0; p_calculatedSoFar = -1;

This will enable using mutexes in the method calls where necessary. p_threadedCalculate = true;

We need to pass a this pointer to the thread AND the serial number list in order to have it calculate properly. Build the void* to pass in. void *data[] = {this, &boundaries};

This is the thread that will be calculating the overlaps. Our current thread will be the one writing to the output file so synchronization at exit is not an issue. pthread_t calculateThread;

Enter the initialization phase: don't try to write until the other thread says initialization is done by unlocking this mutex. pthread_mutex_lock(&initDataMutex);

Create the other thread - it will initialize variables (the ImageOverlap list), unlock the initDataMutex, and proceed to calculate. After each polygon is calculated the calculating mutex will also be unlocked in order to allow I/O if possible. When done calculatedSoFar == p_lonLatOverlaps.size() and the calculating mutex is unlocked. pthread_create(&calculateThread, NULL, FindImageOverlapsThreadStart, &data);

this will let us pass when initialization is done pthread_mutex_lock(&initDataMutex);

Final unlock of the initialization mutex - we locked it to get into this code pthread_mutex_unlock(&initDataMutex);

While our exit condition is not true, call WriteImageOverlaps with the filename. The WriteImageOverlaps call will block if it is waiting on calculations. while(p_calculatedSoFar != (int)p_lonLatOverlaps.size()) { WriteImageOverlaps(outputFile); }

Wait for the calculation thread to actually exit, this has more than likely already occurred. void *result; pthread_join(calculateThread, &result);

re-initialize object to original state p_lonLatOverlaps.clear(); p_writtenSoFar = 0; p_calculatedSoFar = -1; p_threadedCalculate = false; } This is the method that is called when a thread is spawned by FindImageOverlaps(...). It simply calls FindImageOverlaps with a SerialNumberList and exits.

Parameters:
data An array of the form {ImageOverlapSet* instance, SerialNumberList *snlist)
Returns:
void* Returns null

void *ImageOverlapSetFindImageOverlapsThreadStart(void *data) { ImageOverlapSet *instance = (ImageOverlapSet *) ((void**)data)[0]; SerialNumberList *snlist = (SerialNumberList *)((void**)data)[1]; instance->FindImageOverlaps( *snlist ); pthread_exit(NULL); } Create polygons of overlap from the polygons specified. The serial numbers and the polygons are assumed to be parallel arrays. The original polygons passed as arguments are copied, so the ownership of the originals remains with the caller.

Parameters:
sns The serial number list to use when finding overlaps
polygons The polygons which are to be used when finding overlaps
See also:
automaticRegistration.doc

References _FILEINFO_, FindAllOverlaps(), and Isis::IException::Programmer.

void Isis::ImageOverlapSet::FindImageOverlaps ( SerialNumberList sns  ) 

Create polygons of overlap from the images specified in the serial number list.

All polygons create by this class will be deleted when it is destroyed, so callers should not delete the polygons returned by various members.

Parameters:
sns The serial number list to use when finding overlaps

References _FILEINFO_, Isis::Cube::close(), Isis::PolygonTools::Despike(), Isis::SerialNumberList::fileName(), FindAllOverlaps(), Isis::PolygonTools::MakeMultiPolygon(), Isis::Cube::open(), Isis::ImagePolygon::Polys(), Isis::IException::Programmer, Isis::Cube::read(), Isis::SerialNumberList::serialNumber(), and Isis::SerialNumberList::size().

Referenced by FindImageOverlaps().

std::vector< ImageOverlap * > Isis::ImageOverlapSet::operator[] ( QString  serialNumber  ) 

Return the overlaps that have a specific serial number.

Search the existing ImageOverlap objects for all that have the serial numbers associated with them. Note: This could be costly when many overlaps exist.

Parameters:
serialNumber The serial number to be search for in all existing ImageOverlaps
Returns:
List of related ImageOverlap objects, ownership is retained by ImageOverlapSet*
const ImageOverlap* Isis::ImageOverlapSet::operator[] ( int  index  )  [inline]

Returns the images which overlap at a given loverlap.

Parameters:
index The index of the overlap
Returns:
const ImageOverlap* The polygon and serial numbers which define the indexed overlap.
void Isis::ImageOverlapSet::ReadImageOverlaps ( const QString &  filename  ) 

Create polygons of overlap from the file specified.

Parameters:
filename The file to read the image overlaps from

References _FILEINFO_, and Isis::IException::Unknown.

Referenced by Isis::InterestOperator::Operate().

int Isis::ImageOverlapSet::Size (  )  [inline]

Returns the total number of latitude and longitude overlaps.

Returns:
int The number of lat/lon overlaps

Referenced by Isis::InterestOperator::FindOverlap(), and ~ImageOverlapSet().

void Isis::ImageOverlapSet::WriteImageOverlaps ( const QString &  filename  ) 

Write polygons of overlap to the file specified.

Parameters:
filename The file to write the image overlaps to

References _FILEINFO_, Isis::IException::Io, and Isis::IException::User.

Referenced by FindImageOverlaps().


Member Data Documentation

std::vector<PvlGroup> Isis::ImageOverlapSet::p_errorLog [protected]

This is a list of detailed* errors including all known information.

Referenced by Errors().


The documentation for this class was generated from the following files: