lsst.jointcal  14.0-14-g932474c+8
FastFinder.h
Go to the documentation of this file.
1 // -*- LSST-C++ -*-
2 #ifndef LSST_JOINTCAL_FAST_FINDER_H
3 #define LSST_JOINTCAL_FAST_FINDER_H
4 
5 #include <vector>
7 
8 namespace lsst {
9 namespace jointcal {
10 
30 class FastFinder {
32 public:
33  const BaseStarList baselist; // shallow copy of the initial list of stars (not used, acts as a
34  // conservatory). The need is arguable.
35  unsigned count; // total number of objects (size of input list stars).
36  /* the sorted pointer array: It does not seem very wise to use smart
37  pointers here because reference counts will uselessly jump around
38  during sorting */
39  // Unfortunately we *must* use shared_ptr here because the return value of findClosest is used to pass
40  // ownership
42  unsigned nslice; // number of (X) slices
43  std::vector<unsigned> index; // index in "stars" of first object of each slice.
44  double xmin, xmax, xstep; // x bounds, slice size
45 
46  typedef decltype(stars)::value_type stars_element;
47  typedef decltype(stars)::const_iterator pstar;
48 
50  FastFinder(const BaseStarList &list, const unsigned nXSlice = 100);
51 
53  std::shared_ptr<const BaseStar> findClosest(const Point &where, const double maxDist,
54  bool (*SkipIt)(const BaseStar &) = nullptr) const;
55 
57  std::shared_ptr<const BaseStar> secondClosest(const Point &where, const double maxDist,
59  bool (*SkipIt)(const BaseStar &) = nullptr) const;
60 
62  void dump() const;
63 
66 
67  class Iterator {
68  public: // could be made private, but what for??
71  double yStart, yEnd; // Y limits ( for all stripes)
72  /* pointers to the first and beyond last stars in the y range for
73  the current stripe : */
75  pstar null_value; // with pointers being iterators, the null value is not NULL
76 
77  void check() const;
78 
79  public:
80  Iterator(const FastFinder &f, const Point &where, double maxDist);
81  void operator++();
82  stars_element operator*() const;
83  };
84 
85  Iterator beginScan(const Point &where, double maxDist) const;
86 
87  void findRangeInSlice(const int iSlice, const double yStart, const double yEnd, pstar &start,
88  pstar &end) const;
89  pstar locateYStart(pstar begin, pstar end, double yVal) const;
90  pstar locateYEnd(pstar begin, pstar end, double yVal) const;
91 };
92 } // namespace jointcal
93 } // namespace lsst
94 #endif // LSST_JOINTCAL_FAST_FINDER_H
A point in a plane.
Definition: Point.h:13
decltype(stars) typedef ::const_iterator pstar
Definition: FastFinder.h:47
std::vector< std::shared_ptr< const BaseStar > > stars
Definition: FastFinder.h:41
Iterator(const FastFinder &f, const Point &where, double maxDist)
Definition: FastFinder.cc:157
void dump() const
mostly for debugging
Definition: FastFinder.cc:54
pstar locateYEnd(pstar begin, pstar end, double yVal) const
Definition: FastFinder.cc:129
The base class for handling stars. Used by all matching routines.
Definition: BaseStar.h:22
std::shared_ptr< const BaseStar > findClosest(const Point &where, const double maxDist, bool(*SkipIt)(const BaseStar &)=nullptr) const
Find the closest with some rejection capability.
Definition: FastFinder.cc:60
std::lists of Stars.
Definition: StarList.h:35
Class for a simple mapping implementing a generic Gtransfo.
Iterator beginScan(const Point &where, double maxDist) const
Definition: FastFinder.cc:151
Iterator meant to traverse objects within some limiting distance.
Definition: FastFinder.h:67
FastFinder(const BaseStarList &list, const unsigned nXSlice=100)
Constructor.
Definition: FastFinder.cc:14
pstar locateYStart(pstar begin, pstar end, double yVal) const
Definition: FastFinder.cc:111
STL class.
void findRangeInSlice(const int iSlice, const double yStart, const double yEnd, pstar &start, pstar &end) const
Definition: FastFinder.cc:145
const BaseStarList baselist
Definition: FastFinder.h:33
STL class.
This is an auxillary class for matching objects from starlists.
Definition: FastFinder.h:31
std::vector< unsigned > index
Definition: FastFinder.h:43
decltype(stars) typedef ::value_type stars_element
Definition: FastFinder.h:46
std::shared_ptr< const BaseStar > secondClosest(const Point &where, const double maxDist, std::shared_ptr< const BaseStar > &closest, bool(*SkipIt)(const BaseStar &)=nullptr) const
Definition: FastFinder.cc:78
stars_element operator*() const
Definition: FastFinder.cc:182