Isis Developer Reference
Isis::ImageOverlapSet Class Reference

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

#include <ImageOverlapSet.h>

Inheritance diagram for Isis::ImageOverlapSet:
Inheritance graph
Collaboration diagram for Isis::ImageOverlapSet:
Collaboration graph

Public Member Functions

 ImageOverlapSet (bool continueOnError=false, bool useThread=true)
 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

◆ ImageOverlapSet()

Isis::ImageOverlapSet::ImageOverlapSet ( bool continueOnError = false,
bool useThread = true )

Create FindImageOverlaps object.

Create an empty FindImageOverlaps object.

Parameters
continueOnErrorWhether or not this class throws exceptions in addition to logging errors.
See also
automaticRegistration.doc

◆ ~ImageOverlapSet()

Isis::ImageOverlapSet::~ImageOverlapSet ( )
virtual

Delete this object.

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

References Size().

Member Function Documentation

◆ AddSerialNumbers()

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
toThe object to receive the new serial numbers
fromThe object to copy the serial numbers from

Referenced by FindAllOverlaps().

◆ Errors()

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

Return the a list of errors encountered.

References p_errorLog.

◆ FindAllOverlaps()

void Isis::ImageOverlapSet::FindAllOverlaps ( SerialNumberList * snlist = NULL)
protected

Find the overlaps between all the existing ImageOverlap Objects.

Parameters
snlistThe serialnumber list relating to the overlaps described by the current known ImageOverlap objects or NULL

References AddSerialNumbers(), Isis::PolygonTools::Despike(), Isis::PolygonTools::Difference(), Isis::PolygonTools::Equal(), Isis::globalFactory, Isis::PolygonTools::Intersect(), Isis::PolygonTools::MakeMultiPolygon(), and Isis::Progress::SetText().

Referenced by FindImageOverlaps(), and FindImageOverlaps().

◆ FindImageOverlaps() [1/3]

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

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

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

Parameters
snsThe serial number list to use when finding overlaps

References _FILEINFO_, Isis::Cube::close(), Isis::PolygonTools::Despike(), FindAllOverlaps(), Isis::PolygonTools::MakeMultiPolygon(), Isis::Cube::open(), Isis::IException::Programmer, and Isis::Cube::readFootprint().

Referenced by FindImageOverlaps().

◆ FindImageOverlaps() [2/3]

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
boundariesThe files to find overlaps between
outputFileThe output ImageOverlapSet file

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

◆ FindImageOverlaps() [3/3]

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
dataAn array of the form {ImageOverlapSet* instance, SerialNumberList *snlist)
Returns
void* Returns null

void *ImageOverlapSet::FindImageOverlapsThreadStart(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
snsThe serial number list to use when finding overlaps
polygonsThe polygons which are to be used when finding overlaps
See also
automaticRegistration.doc

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

◆ operator[]() [1/2]

const ImageOverlap * Isis::ImageOverlapSet::operator[] ( int index)
inline

Returns the images which overlap at a given loverlap.

Parameters
indexThe index of the overlap
Returns
const ImageOverlap* The polygon and serial numbers which define the indexed overlap.

◆ operator[]() [2/2]

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
serialNumberThe serial number to be search for in all existing ImageOverlaps
Returns
List of related ImageOverlap objects, ownership is retained by ImageOverlapSet*

◆ ReadImageOverlaps()

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

Create polygons of overlap from the file specified.

Parameters
filenameThe file to read the image overlaps from

References _FILEINFO_, Isis::FileName::expanded(), and Isis::IException::Unknown.

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

◆ Size()

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().

◆ WriteImageOverlaps()

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

Write polygons of overlap to the file specified.

Parameters
filenameThe file to write the image overlaps to

References _FILEINFO_, Isis::FileName::expanded(), Isis::IException::Io, and Isis::IException::User.

Referenced by FindImageOverlaps().

Member Data Documentation

◆ p_errorLog

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: