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