29 #ifndef LSST_AFW_MATH_SPATIALCELL_H
30 #define LSST_AFW_MATH_SPATIALCELL_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) {}
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.
std::shared_ptr< SpatialCellCandidate const > operator*() const
Dereference the iterator to return the Candidate (if there is one)
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?
Class to ensure constraints for spatial modeling.
lsst::geom::Box2I const & getBBox() const
Get SpatialCell's BBox.
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.
std::vector< std::shared_ptr< SpatialCellCandidate > > CandidateList
void removeCandidate(std::shared_ptr< SpatialCellCandidate > candidate)
Remove a candidate from the list.
SpatialCell(SpatialCell const &)=default
virtual ~SpatialCell()=default
Destructor.
std::string const & getLabel() const
Get SpatialCell's label.
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.
SpatialCellCandidateIterator begin()
Return an iterator to the beginning of the Candidates.
SpatialCellCandidateIterator begin(bool ignoreBad)
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.
SpatialCell & operator=(SpatialCell const &)=default
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.
void visitAllCandidates(CandidateVisitor *visitor, bool const ignoreExceptions=false, bool const reset=true)
Call the visitor's processCandidate method for every Candidate in the SpatialCell.
SpatialCell & operator=(SpatialCell &&)=default
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.
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 const &)=default
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.
std::vector< std::shared_ptr< SpatialCell > > CellList
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.
An integer coordinate rectangle.
Backwards-compatibility support for depersisting the old Calib (FluxMag0/FluxMag0Err) objects.
A base class for image defects.