lsst.afw  20.0.0-11-g7b7d0ee7e+614f89f815
Public Types | Public Member Functions | List of all members
lsst::afw::math::SpatialCell Class Reference

Class to ensure constraints for spatial modeling. More...

#include <SpatialCell.h>

Public Types

typedef std::vector< std::shared_ptr< SpatialCellCandidate > > CandidateList
 
typedef SpatialCellCandidateIterator iterator
 

Public Member Functions

 SpatialCell (std::string const &label, lsst::geom::Box2I const &bbox=lsst::geom::Box2I(), CandidateList const &candidateList=CandidateList())
 Constructor. More...
 
 SpatialCell (SpatialCell const &)=default
 
 SpatialCell (SpatialCell &&)=default
 
SpatialCelloperator= (SpatialCell const &)=default
 
SpatialCelloperator= (SpatialCell &&)=default
 
virtual ~SpatialCell ()=default
 Destructor. More...
 
bool empty () const
 Determine if cell has no usable candidates. More...
 
size_t size () const
 Return number of usable candidates in Cell. More...
 
void sortCandidates ()
 Rearrange the candidates to reflect their current ratings. More...
 
SpatialCellCandidateIterator begin ()
 Return an iterator to the beginning of the Candidates. More...
 
SpatialCellCandidateIterator begin (bool ignoreBad)
 
SpatialCellCandidateIterator end ()
 Return an iterator to (one after) the end of the Candidates. More...
 
SpatialCellCandidateIterator end (bool ignoreBad)
 
void insertCandidate (std::shared_ptr< SpatialCellCandidate > candidate)
 Add a candidate to the list, preserving ranking. More...
 
void removeCandidate (std::shared_ptr< SpatialCellCandidate > candidate)
 Remove a candidate from the list. More...
 
void setIgnoreBad (bool ignoreBad)
 Set whether we should omit BAD candidates from candidate list when traversing. More...
 
bool getIgnoreBad () const
 Get whether we are omitting BAD candidates from candidate list when traversing. More...
 
std::shared_ptr< SpatialCellCandidategetCandidateById (int id, bool noThrow=false)
 Return the SpatialCellCandidate with the specified id. More...
 
std::string const & getLabel () const
 Get SpatialCell's label. More...
 
lsst::geom::Box2I const & getBBox () const
 Get SpatialCell's BBox. More...
 
void visitCandidates (CandidateVisitor *visitor, int const nMaxPerCell=-1, bool const ignoreExceptions=false, bool const reset=true)
 Call the visitor's processCandidate method for each Candidate in the SpatialCell. More...
 
void visitCandidates (CandidateVisitor *visitor, int const nMaxPerCell=-1, bool const ignoreExceptions=false, bool const reset=true) const
 Call the visitor's processCandidate method for each Candidate in the SpatialCell (const version) More...
 
void visitAllCandidates (CandidateVisitor *visitor, bool const ignoreExceptions=false, bool const reset=true)
 Call the visitor's processCandidate method for every Candidate in the SpatialCell. More...
 
void visitAllCandidates (CandidateVisitor *visitor, bool const ignoreExceptions=false, bool const reset=true) const
 Call the visitor's processCandidate method for each Candidate in the SpatialCell (const version) More...
 

Detailed Description

Class to ensure constraints for spatial modeling.

A given image is divided up into cells, with each cell represented by an instance of this class. Each cell itself contains a list of instances of classes derived from SpatialCellCandidate. One class member from each cell will be chosen to fit to a spatial model. In case of a poor fit, the next class instance in the list will be fit for. If all instances in a list are rejected from the spatial model, the best one will be used.

See also
The SpatialCellSet example in the module documentation.

Definition at line 227 of file SpatialCell.h.

Member Typedef Documentation

◆ CandidateList

Definition at line 229 of file SpatialCell.h.

◆ iterator

Definition at line 230 of file SpatialCell.h.

Constructor & Destructor Documentation

◆ SpatialCell() [1/3]

lsst::afw::math::SpatialCell::SpatialCell ( std::string const &  label,
lsst::geom::Box2I const &  bbox = lsst::geom::Box2I(),
CandidateList const &  candidateList = CandidateList() 
)

Constructor.

Parameters
labelstring representing "name" of cell
bboxBounding box of cell in overall image
candidateListlist of candidates to represent this cell

Definition at line 73 of file SpatialCell.cc.

◆ SpatialCell() [2/3]

lsst::afw::math::SpatialCell::SpatialCell ( SpatialCell const &  )
default

◆ SpatialCell() [3/3]

lsst::afw::math::SpatialCell::SpatialCell ( SpatialCell &&  )
default

◆ ~SpatialCell()

virtual lsst::afw::math::SpatialCell::~SpatialCell ( )
virtualdefault

Destructor.

Member Function Documentation

◆ begin() [1/2]

SpatialCellCandidateIterator lsst::afw::math::SpatialCell::begin ( )
inline

Return an iterator to the beginning of the Candidates.

Definition at line 267 of file SpatialCell.h.

◆ begin() [2/2]

SpatialCellCandidateIterator lsst::afw::math::SpatialCell::begin ( bool  ignoreBad)
inline
Parameters
ignoreBadIf true, ignore BAD candidates

Definition at line 270 of file SpatialCell.h.

◆ empty()

bool lsst::afw::math::SpatialCell::empty ( ) const

Determine if cell has no usable candidates.

Definition at line 99 of file SpatialCell.cc.

◆ end() [1/2]

SpatialCellCandidateIterator lsst::afw::math::SpatialCell::end ( )
inline

Return an iterator to (one after) the end of the Candidates.

Definition at line 277 of file SpatialCell.h.

◆ end() [2/2]

SpatialCellCandidateIterator lsst::afw::math::SpatialCell::end ( bool  ignoreBad)
inline
Parameters
ignoreBadIf true, ignore BAD candidates

Definition at line 280 of file SpatialCell.h.

◆ getBBox()

lsst::geom::Box2I const& lsst::afw::math::SpatialCell::getBBox ( ) const
inline

Get SpatialCell's BBox.

Definition at line 318 of file SpatialCell.h.

◆ getCandidateById()

std::shared_ptr< SpatialCellCandidate > lsst::afw::math::SpatialCell::getCandidateById ( int  id,
bool  noThrow = false 
)

Return the SpatialCellCandidate with the specified id.

Parameters
idThe desired ID
noThrowReturn NULL in case of error
Exceptions
lsst::pex::exceptions::NotFoundErrorif no candidate matches the id

Definition at line 121 of file SpatialCell.cc.

◆ getIgnoreBad()

bool lsst::afw::math::SpatialCell::getIgnoreBad ( ) const
inline

Get whether we are omitting BAD candidates from candidate list when traversing.

Definition at line 300 of file SpatialCell.h.

◆ getLabel()

std::string const& lsst::afw::math::SpatialCell::getLabel ( ) const
inline

Get SpatialCell's label.

Definition at line 314 of file SpatialCell.h.

◆ insertCandidate()

void lsst::afw::math::SpatialCell::insertCandidate ( std::shared_ptr< SpatialCellCandidate candidate)

Add a candidate to the list, preserving ranking.

Definition at line 83 of file SpatialCell.cc.

◆ operator=() [1/2]

SpatialCell& lsst::afw::math::SpatialCell::operator= ( SpatialCell &&  )
default

◆ operator=() [2/2]

SpatialCell& lsst::afw::math::SpatialCell::operator= ( SpatialCell const &  )
default

◆ removeCandidate()

void lsst::afw::math::SpatialCell::removeCandidate ( std::shared_ptr< SpatialCellCandidate candidate)

Remove a candidate from the list.

This is not a particularly efficient operation, since we're using a std::vector, but should not hurt too much if the number of candidates in a cell is small.

Definition at line 89 of file SpatialCell.cc.

◆ setIgnoreBad()

void lsst::afw::math::SpatialCell::setIgnoreBad ( bool  ignoreBad)
inline

Set whether we should omit BAD candidates from candidate list when traversing.

Definition at line 298 of file SpatialCell.h.

◆ size()

size_t lsst::afw::math::SpatialCell::size ( ) const

Return number of usable candidates in Cell.

Definition at line 113 of file SpatialCell.cc.

◆ sortCandidates()

void lsst::afw::math::SpatialCell::sortCandidates ( )

Rearrange the candidates to reflect their current ratings.

Definition at line 81 of file SpatialCell.cc.

◆ visitAllCandidates() [1/2]

void lsst::afw::math::SpatialCell::visitAllCandidates ( CandidateVisitor visitor,
bool const  ignoreExceptions = false,
bool const  reset = true 
)

Call the visitor's processCandidate method for every Candidate in the SpatialCell.

Parameters
visitorPass this object to every Candidate
ignoreExceptionsIgnore any exceptions thrown by
resetReset visitor before passing it around
See also
visitCandidates

Definition at line 193 of file SpatialCell.cc.

◆ visitAllCandidates() [2/2]

void lsst::afw::math::SpatialCell::visitAllCandidates ( CandidateVisitor visitor,
bool const  ignoreExceptions = false,
bool const  reset = true 
) const

Call the visitor's processCandidate method for each Candidate in the SpatialCell (const version)

This is the const version of SpatialCellSet::visitAllCandidates

Parameters
visitorPass this object to every Candidate
ignoreExceptionsIgnore any exceptions thrown by the processing
resetReset visitor before passing it around
Todo:
This is currently implemented via a const_cast (arghhh). The problem is that SpatialCell::begin() const isn't yet implemented

Definition at line 215 of file SpatialCell.cc.

◆ visitCandidates() [1/2]

void lsst::afw::math::SpatialCell::visitCandidates ( CandidateVisitor visitor,
int const  nMaxPerCell = -1,
bool const  ignoreExceptions = false,
bool const  reset = true 
)

Call the visitor's processCandidate method for each Candidate in the SpatialCell.

Parameters
visitorPass this object to every Candidate
nMaxPerCellVisit no more than this many Candidates (<= 0: all)
ignoreExceptionsIgnore any exceptions thrown by the processing
resetReset visitor before passing it around
Note
This is obviously similar to the Design Patterns (Go4) Visitor pattern, but we've simplified the double dispatch (i.e. we don't call a virtual method on SpatialCellCandidate that in turn calls processCandidate(*this), but can be re-defined)

Definition at line 136 of file SpatialCell.cc.

◆ visitCandidates() [2/2]

void lsst::afw::math::SpatialCell::visitCandidates ( CandidateVisitor visitor,
int const  nMaxPerCell = -1,
bool const  ignoreExceptions = false,
bool const  reset = true 
) const

Call the visitor's processCandidate method for each Candidate in the SpatialCell (const version)

This is the const version of SpatialCellSet::visitCandidates

Parameters
visitorPass this object to every Candidate
nMaxPerCellVisit no more than this many Candidates (-ve: all)
ignoreExceptionsIgnore any exceptions thrown by the processing
resetReset visitor before passing it around
Todo:
This is currently implemented via a const_cast (arghhh). The problem is that SpatialCell::begin() const isn't yet implemented

Definition at line 163 of file SpatialCell.cc.


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