29#ifndef LSST_AFW_MATH_SPATIALCELL_H
30#define LSST_AFW_MATH_SPATIALCELL_H
47template <
typename ImagePixelT>
49template <
typename ImagePixelT,
typename MaskPixelT,
typename VariancePixelT>
56class SpatialCellCandidate;
77 : _id(++_CandidateId), _status(
UNKNOWN), _xCenter(xCenter), _yCenter(yCenter) {}
108 virtual bool isBad()
const {
return (_status ==
BAD); }
113 float const _xCenter;
114 float const _yCenter;
117 static int _CandidateId;
136 static void setWidth(
int width) { _width = width; }
204 bool ignoreBad,
bool);
207 CandidateList::iterator _iterator;
208 CandidateList::iterator _end;
331 bool const ignoreExceptions =
false,
bool const reset =
true);
346 bool const ignoreExceptions =
false,
bool const reset =
true)
const;
357 bool const reset =
true);
371 bool const reset =
true)
const;
438 bool const ignoreExceptions =
false);
449 bool const ignoreExceptions =
false)
const;
CandidateVisitor()=default
virtual void processCandidate(SpatialCellCandidate *)
virtual ~CandidateVisitor()=default
Base class for candidate objects in a SpatialCell.
SpatialCellCandidate(float const xCenter, float const yCenter)
virtual void setCandidateRating(double)
Set the candidate's rating.
SpatialCellCandidate(SpatialCellCandidate const &)=default
virtual bool isBad() const
Is this candidate unacceptable?
float getYCenter() const
Return the object's row-centre.
SpatialCellCandidate(SpatialCellCandidate &&)=default
float getXCenter() const
Return the object's column-centre.
int getId() const
Return the candidate's unique ID.
void setStatus(Status status)
Set the candidate's status.
virtual double getCandidateRating() const =0
Return candidate's rating.
virtual bool instantiate()
Do anything needed to make this candidate usable.
Status getStatus() const
Return the candidate's status.
virtual ~SpatialCellCandidate()=default
(virtual) destructor – this is a base class you know
An iterator that only returns usable members of the SpatialCell.
SpatialCellCandidateIterator(CandidateList::iterator iterator, CandidateList::iterator end, bool ignoreBad)
ctor; designed to be used to pass begin to SpatialCellCandidateIterator
bool operator==(SpatialCellCandidateIterator const &rhs) const
Are two SpatialCellCandidateIterators equal?
void operator++()
Advance the iterator, maybe skipping over candidates labelled BAD.
size_t operator-(SpatialCellCandidateIterator const &rhs) const
Return the number of candidate between this and rhs.
bool operator!=(SpatialCellCandidateIterator const &rhs) const
Are two SpatialCellCandidateIterators unequal?
std::shared_ptr< SpatialCellCandidate const > operator*() const
Dereference the iterator to return the Candidate (if there is one)
Class to ensure constraints for spatial modeling.
SpatialCell(SpatialCell &&)=default
SpatialCellCandidateIterator end()
Return an iterator to (one after) the end of the Candidates.
size_t size() const
Return number of usable candidates in Cell.
bool getIgnoreBad() const
Get whether we are omitting BAD candidates from candidate list when traversing.
void sortCandidates()
Rearrange the candidates to reflect their current ratings.
void removeCandidate(std::shared_ptr< SpatialCellCandidate > candidate)
Remove a candidate from the list.
SpatialCell(SpatialCell const &)=default
virtual ~SpatialCell()=default
Destructor.
SpatialCell & operator=(SpatialCell &&)=default
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.
lsst::geom::Box2I const & getBBox() const
Get SpatialCell's BBox.
SpatialCellCandidateIterator begin()
Return an iterator to the beginning of the Candidates.
SpatialCellCandidateIterator begin(bool ignoreBad)
std::vector< std::shared_ptr< SpatialCellCandidate > > CandidateList
bool empty() const
Determine if cell has no usable candidates.
std::shared_ptr< SpatialCellCandidate > getCandidateById(int id, bool noThrow=false)
Return the SpatialCellCandidate with the specified id.
void setIgnoreBad(bool ignoreBad)
Set whether we should omit BAD candidates from candidate list when traversing.
SpatialCell(std::string const &label, lsst::geom::Box2I const &bbox=lsst::geom::Box2I(), CandidateList const &candidateList=CandidateList())
Constructor.
SpatialCell & operator=(SpatialCell const &)=default
std::string const & getLabel() const
Get SpatialCell's label.
void visitAllCandidates(CandidateVisitor *visitor, bool const ignoreExceptions=false, bool const reset=true)
Call the visitor's processCandidate method for every Candidate in the SpatialCell.
void insertCandidate(std::shared_ptr< SpatialCellCandidate > candidate)
Add a candidate to the list, preserving ranking.
SpatialCellCandidateIterator end(bool ignoreBad)
Base class for candidate objects in a SpatialCell that are able to return an Image of some sort (e....
SpatialCellImageCandidate(float const xCenter, float const yCenter)
ctor
static int getWidth()
Return the width of the image that getImage should return.
double getChi2() const
Return the candidate's chi^2.
SpatialCellImageCandidate(SpatialCellImageCandidate &&)=default
static int getHeight()
Return the height of the image that getImage should return.
static void setWidth(int width)
Set the width of the image that getImage should return.
static void setHeight(int height)
Set the height of the image that getImage should return.
SpatialCellImageCandidate(SpatialCellImageCandidate const &)=default
~SpatialCellImageCandidate() override=default
void setChi2(double chi2)
Set the candidate's chi^2.
A collection of SpatialCells covering an entire image.
SpatialCellSet(SpatialCellSet &&)=default
void sortCandidates()
Rearrange the Candidates in all SpatialCells to reflect their current ratings.
void visitAllCandidates(CandidateVisitor *visitor, bool const ignoreExceptions=false)
Call the visitor's processCandidate method for every Candidate in the SpatialCellSet.
SpatialCellSet & operator=(SpatialCellSet const &)=default
void setIgnoreBad(bool ignoreBad)
Set whether we should omit BAD candidates from candidate list when traversing.
lsst::geom::Box2I getBBox() const
Return the bounding box of the image.
SpatialCellSet & operator=(SpatialCellSet &&)=default
void insertCandidate(std::shared_ptr< SpatialCellCandidate > candidate)
Insert a candidate into the correct cell.
SpatialCellSet(SpatialCellSet const &)=default
std::shared_ptr< SpatialCellCandidate > getCandidateById(int id, bool noThrow=false)
Return the SpatialCellCandidate with the specified id.
CellList & getCellList()
Return our SpatialCells.
virtual ~SpatialCellSet()=default
Destructor.
void visitCandidates(CandidateVisitor *visitor, int const nMaxPerCell=-1, bool const ignoreExceptions=false)
Call the visitor's processCandidate method for each Candidate in the SpatialCellSet.
SpatialCellSet(lsst::geom::Box2I const ®ion, int xSize, int ySize=0)
Constructor.
std::vector< std::shared_ptr< SpatialCell > > CellList
An integer coordinate rectangle.
g2d::python::Image< double > Image