Class SpatialCell¶
Defined in File SpatialCell.h
Class Documentation¶
-
class
SpatialCell
¶ 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
The SpatialCellSet example in the module documentation.
Public Types
-
typedef std::vector<std::shared_ptr<SpatialCellCandidate>>
CandidateList
¶
-
typedef SpatialCellCandidateIterator
iterator
¶
Public Functions
-
SpatialCell
(std::string const &label, lsst::geom::Box2I const &bbox = lsst::geom::Box2I(), CandidateList const &candidateList = CandidateList())¶ Constructor
- Parameters
label
: string representing “name” of cellbbox
: Bounding box of cell in overall imagecandidateList
: list of candidates to represent this cell
-
SpatialCell
(SpatialCell const&)¶
-
SpatialCell
(SpatialCell&&)¶
-
SpatialCell &
operator=
(SpatialCell const&)¶
-
SpatialCell &
operator=
(SpatialCell&&)¶
-
virtual
~SpatialCell
()¶ Destructor
-
bool
empty
() const¶ Determine if cell has no usable candidates
-
size_t
size
() const¶ Return number of usable candidates in Cell
-
void
sortCandidates
()¶ Rearrange the candidates to reflect their current ratings
-
SpatialCellCandidateIterator
begin
()¶ Return an iterator to the beginning of the Candidates
-
SpatialCellCandidateIterator
begin
(bool ignoreBad)¶ - Parameters
ignoreBad
: If true, ignore BAD candidates
-
SpatialCellCandidateIterator
end
()¶ Return an iterator to (one after) the end of the Candidates
-
SpatialCellCandidateIterator
end
(bool ignoreBad)¶ - Parameters
ignoreBad
: If true, ignore BAD candidates
Add a candidate to the list, preserving ranking
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.
-
void
setIgnoreBad
(bool ignoreBad)¶ Set whether we should omit BAD candidates from candidate list when traversing.
-
bool
getIgnoreBad
() const¶ Get whether we are omitting BAD candidates from candidate list when traversing.
-
std::shared_ptr<SpatialCellCandidate>
getCandidateById
(int id, bool noThrow = false)¶ Return the SpatialCellCandidate with the specified id
- Parameters
id
: The desired IDnoThrow
: Return NULL in case of error
- Exceptions
lsst::pex::exceptions::NotFoundError
: if no candidate matches the id
-
std::string const &
getLabel
() const¶ Get SpatialCell’s label
-
lsst::geom::Box2I const &
getBBox
() const¶ Get SpatialCell’s BBox
-
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
- 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)
- Parameters
visitor
: Pass this object to every CandidatenMaxPerCell
: Visit no more than this many Candidates (<= 0: all)ignoreExceptions
: Ignore any exceptions thrown by the processingreset
: Reset visitor before passing it around
-
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)
This is the const version of SpatialCellSet::visitCandidates
- Parameters
visitor
: Pass this object to every CandidatenMaxPerCell
: Visit no more than this many Candidates (-ve: all)ignoreExceptions
: Ignore any exceptions thrown by the processingreset
: Reset visitor before passing it around
-
void
visitAllCandidates
(CandidateVisitor *visitor, bool const ignoreExceptions = false, bool const reset = true)¶ Call the visitor’s processCandidate method for every Candidate in the SpatialCell
- See
- Parameters
visitor
: Pass this object to every CandidateignoreExceptions
: Ignore any exceptions thrown byreset
: Reset visitor before passing it around
-
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)
This is the const version of SpatialCellSet::visitAllCandidates
- Parameters
visitor
: Pass this object to every CandidateignoreExceptions
: Ignore any exceptions thrown by the processingreset
: Reset visitor before passing it around