LSSTApplications  10.0-2-g4f67435,11.0.rc2+1,11.0.rc2+12,11.0.rc2+3,11.0.rc2+4,11.0.rc2+5,11.0.rc2+6,11.0.rc2+7,11.0.rc2+8
LSSTDataManagementBasePackage
Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
lsst.afw.detection::FootprintMerge Class Reference

Public Types

typedef
FootprintMergeList::KeyTuple 
KeyTuple
 
typedef
FootprintMergeList::FilterMap 
FilterMap
 

Public Member Functions

 FootprintMerge (boost::shared_ptr< Footprint > footprint, boost::shared_ptr< afw::table::SourceTable > sourceTable, boost::shared_ptr< PeakTable > peakTable, afw::table::SchemaMapper const &peakSchemaMapper, KeyTuple const &keys)
 
bool overlaps (Footprint const &rhs) const
 
void add (boost::shared_ptr< Footprint > footprint, afw::table::SchemaMapper const &peakSchemaMapper, KeyTuple const &keys, float minNewPeakDist=-1., float maxSamePeakDist=-1.)
 
void add (FootprintMerge const &other, FilterMap const &keys, float minNewPeakDist=-1., float maxSamePeakDist=-1.)
 
afw::geom::Box2I getBBox () const
 
boost::shared_ptr< FootprintgetMergedFootprint () const
 
boost::shared_ptr
< afw::table::SourceRecord
getSource () const
 

Private Member Functions

bool _addSpans (boost::shared_ptr< Footprint > footprint)
 
void _addPeaks (PeakCatalog const &otherPeaks, afw::table::SchemaMapper const *peakSchemaMapper, KeyTuple const *keys, float minNewPeakDist, float maxSamePeakDist)
 

Private Attributes

std::vector< boost::shared_ptr
< Footprint > > 
_footprints
 
boost::shared_ptr
< afw::table::SourceRecord
_source
 

Detailed Description

Definition at line 47 of file FootprintMerge.cc.

Member Typedef Documentation

Definition at line 51 of file FootprintMerge.cc.

Definition at line 50 of file FootprintMerge.cc.

Constructor & Destructor Documentation

lsst.afw.detection::FootprintMerge::FootprintMerge ( boost::shared_ptr< Footprint footprint,
boost::shared_ptr< afw::table::SourceTable sourceTable,
boost::shared_ptr< PeakTable peakTable,
afw::table::SchemaMapper const &  peakSchemaMapper,
KeyTuple const &  keys 
)
inlineexplicit

Definition at line 53 of file FootprintMerge.cc.

59  :
60  _footprints(1, footprint),
61  _source(sourceTable->makeRecord())
62  {
63  PTR(Footprint) newFootprint = boost::make_shared<Footprint>(*footprint);
64 
65  _source->set(keys.footprint, true);
66  // Replace all the Peaks in the merged Footprint with new ones that include the origin flags
67  newFootprint->getPeaks() = PeakCatalog(peakTable);
68  for (
69  PeakCatalog::iterator iter = footprint->getPeaks().begin();
70  iter != footprint->getPeaks().end();
71  ++iter
72  ) {
73  PTR(PeakRecord) newPeak = peakTable->copyRecord(*iter, peakSchemaMapper);
74  newPeak->set(keys.peak, true);
75  newFootprint->getPeaks().push_back(newPeak);
76  }
77  _source->setFootprint(newFootprint);
78  }
int iter
#define PTR(...)
Definition: base.h:41
for(FootprintList::const_iterator ptr=feet->begin(), end=feet->end();ptr!=end;++ptr)
Definition: saturated.cc:82
std::vector< boost::shared_ptr< Footprint > > _footprints
lsst::afw::detection::Footprint Footprint
Definition: Source.h:61
boost::shared_ptr< afw::table::SourceRecord > _source
afw::table::CatalogT< PeakRecord > PeakCatalog
Definition: Peak.h:225

Member Function Documentation

void lsst.afw.detection::FootprintMerge::_addPeaks ( PeakCatalog const &  otherPeaks,
afw::table::SchemaMapper const *  peakSchemaMapper,
KeyTuple const *  keys,
float  minNewPeakDist,
float  maxSamePeakDist 
)
inlineprivate

Definition at line 159 of file FootprintMerge.cc.

165  {
166  if (minNewPeakDist < 0 && maxSamePeakDist < 0) return;
167 
168  PeakCatalog & currentPeaks = getMergedFootprint()->getPeaks();
169  PTR(PeakRecord) nearestPeak;
170  // Create new list of peaks
171  PeakCatalog newPeaks(currentPeaks.getTable());
172  float minNewPeakDist2 = minNewPeakDist*minNewPeakDist;
173  float maxSamePeakDist2 = maxSamePeakDist*maxSamePeakDist;
174  for (PeakCatalog::const_iterator otherIter = otherPeaks.begin();
175  otherIter != otherPeaks.end(); ++otherIter) {
176 
177  float minDist2 = std::numeric_limits<float>::infinity();
178 
179  for (PeakCatalog::const_iterator currentIter = currentPeaks.begin();
180  currentIter != currentPeaks.end(); ++currentIter) {
181  float dist2 = otherIter->getI().distanceSquared(currentIter->getI());
182 
183  if (dist2 < minDist2) {
184  minDist2 = dist2;
185  nearestPeak = currentIter;
186  }
187  }
188 
189  if (minDist2 < maxSamePeakDist2 && nearestPeak && keys && maxSamePeakDist > 0) {
190  nearestPeak->set(keys->peak, true);
191  } else if (minDist2 > minNewPeakDist2 && !(minNewPeakDist < 0)) {
192  if (peakSchemaMapper) {
193  PTR(PeakRecord) newPeak = newPeaks.addNew();
194  newPeak->assign(*otherIter, *peakSchemaMapper);
195  newPeak->set(keys->peak, true);
196  } else {
197  newPeaks.push_back(otherIter);
198  }
199  }
200 
201  }
202 
203  getMergedFootprint()->getPeaks().insert(
204  getMergedFootprint()->getPeaks().end(),
205  newPeaks.begin(), newPeaks.end(),
206  true // deep-copy
207  );
208  }
#define PTR(...)
Definition: base.h:41
for(FootprintList::const_iterator ptr=feet->begin(), end=feet->end();ptr!=end;++ptr)
Definition: saturated.cc:82
afw::table::CatalogT< PeakRecord > PeakCatalog
Definition: Peak.h:225
CatalogIterator< typename Internal::const_iterator > const_iterator
Definition: Catalog.h:108
boost::shared_ptr< Footprint > getMergedFootprint() const
bool lsst.afw.detection::FootprintMerge::_addSpans ( boost::shared_ptr< Footprint footprint)
inlineprivate

Definition at line 151 of file FootprintMerge.cc.

151  {
152  FootprintSet fpSet = mergeFootprintPair(*getMergedFootprint(), *footprint);
153  if (fpSet.getFootprints()->size() != 1u) return false;
154  getMergedFootprint()->_bbox.include(footprint->getBBox());
155  getMergedFootprint()->getSpans().swap(fpSet.getFootprints()->front()->getSpans());
156  return true;
157  }
boost::shared_ptr< Footprint > getMergedFootprint() const
void lsst.afw.detection::FootprintMerge::add ( boost::shared_ptr< Footprint footprint,
afw::table::SchemaMapper const &  peakSchemaMapper,
KeyTuple const &  keys,
float  minNewPeakDist = -1.,
float  maxSamePeakDist = -1. 
)
inline

Definition at line 100 of file FootprintMerge.cc.

106  {
107  if (_addSpans(footprint)) {
108  _footprints.push_back(footprint);
109  _source->set(keys.footprint, true);
110  _addPeaks(footprint->getPeaks(), &peakSchemaMapper, &keys, minNewPeakDist, maxSamePeakDist);
111  }
112  }
std::vector< boost::shared_ptr< Footprint > > _footprints
boost::shared_ptr< afw::table::SourceRecord > _source
bool _addSpans(boost::shared_ptr< Footprint > footprint)
void _addPeaks(PeakCatalog const &otherPeaks, afw::table::SchemaMapper const *peakSchemaMapper, KeyTuple const *keys, float minNewPeakDist, float maxSamePeakDist)
void lsst.afw.detection::FootprintMerge::add ( FootprintMerge const &  other,
FilterMap const &  keys,
float  minNewPeakDist = -1.,
float  maxSamePeakDist = -1. 
)
inline

Definition at line 123 of file FootprintMerge.cc.

128  {
129  if (_addSpans(other.getMergedFootprint())) {
130  _footprints.insert(_footprints.end(), other._footprints.begin(), other._footprints.end());
131  // Set source flags to the OR of the flags of the two inputs
132  for (FilterMap::const_iterator i = keys.begin(); i != keys.end(); ++i) {
133  afw::table::Key<afw::table::Flag> const & flagKey = i->second.footprint;
134  _source->set(flagKey, _source->get(flagKey) || other._source->get(flagKey));
135  }
136  _addPeaks(other.getMergedFootprint()->getPeaks(), NULL, NULL, minNewPeakDist, maxSamePeakDist);
137  }
138  }
std::vector< boost::shared_ptr< Footprint > > _footprints
boost::shared_ptr< afw::table::SourceRecord > _source
bool _addSpans(boost::shared_ptr< Footprint > footprint)
void _addPeaks(PeakCatalog const &otherPeaks, afw::table::SchemaMapper const *peakSchemaMapper, KeyTuple const *keys, float minNewPeakDist, float maxSamePeakDist)
afw::geom::Box2I lsst.afw.detection::FootprintMerge::getBBox ( ) const
inline

Definition at line 141 of file FootprintMerge.cc.

141 { return getMergedFootprint()->getBBox(); }
boost::shared_ptr< Footprint > getMergedFootprint() const
boost::shared_ptr< Footprint > lsst.afw.detection::FootprintMerge::getMergedFootprint ( ) const
inline

Definition at line 143 of file FootprintMerge.cc.

143 { return _source->getFootprint(); }
boost::shared_ptr< afw::table::SourceRecord > _source
boost::shared_ptr< afw::table::SourceRecord > lsst.afw.detection::FootprintMerge::getSource ( ) const
inline

Definition at line 145 of file FootprintMerge.cc.

145 { return _source; }
boost::shared_ptr< afw::table::SourceRecord > _source
bool lsst.afw.detection::FootprintMerge::overlaps ( Footprint const &  rhs) const
inline

Definition at line 87 of file FootprintMerge.cc.

87  {
88  return mergeFootprintPair(*getMergedFootprint(), rhs).getFootprints()->size() == 1u;
89  }
boost::shared_ptr< Footprint > getMergedFootprint() const

Member Data Documentation

std::vector<boost::shared_ptr< Footprint > > lsst.afw.detection::FootprintMerge::_footprints
private

Definition at line 210 of file FootprintMerge.cc.

boost::shared_ptr< afw::table::SourceRecord > lsst.afw.detection::FootprintMerge::_source
private

Definition at line 211 of file FootprintMerge.cc.


The documentation for this class was generated from the following file: