20 int offset,
double threshold)
72 const int rel_beg = abs_beg-
m_offset;
73 const int rel_end = abs_end-
m_offset;
75 if (rel_beg < 0 or rel_beg >= rel_end or rel_end > (
int)
m_span.size()) {
76 spdlog::debug(
"activity::subspan bogus absolute:[{},{}] m_offset={} span.size={}",
77 abs_beg, abs_end, m_offset,
m_span.size());
107 for (
auto it =
begin(); it !=
end(); ++it) {
136 ret.push_back(std::make_pair(
a.first,
b.first));
137 ret.push_back(std::make_pair(
a.first,
b.second));
138 ret.push_back(std::make_pair(
a.second,
b.first));
139 ret.push_back(std::make_pair(
a.second,
b.second));
148 const size_t nstrips = m_strips.size();
151 m_strips.push_back(strip);
156 m_strips.push_back(strip);
157 m_corners =
find_corners(m_strips.front(), m_strips.back());
164 for (
const auto&
c : m_corners) {
169 if (strip.
in(pind)) {
170 surviving.push_back(
c);
175 for (
size_t si1 = 0; si1 < nstrips; ++si1) {
177 for (
const auto&
c : corners) {
181 for (
size_t si2 = 0; si2 < nstrips; ++si2) {
182 if (si1 == si2) {
continue; }
183 const auto& s2 = m_strips[si2];
185 const int pind = coords.
pitch_index(pitch, s2.layer);
194 surviving.push_back(
c);
198 m_corners = surviving;
199 m_strips.push_back(strip);
219 const size_t nstrips = strips.size();
221 for (
size_t ind=0; ind<nstrips; ++ind) {
222 ret[ind].add(
m_coords, strips[ind]);
232 if (blob.
strips().size() == 1) {
239 std::vector<double> pitches;
240 const auto corners = blob.
corners();
241 if (corners.empty()) {
244 for (
const auto&
c : blob.
corners()) {
246 pitches.push_back(p);
248 if (pitches.empty()) {
252 auto pbeg = pitches.begin();
253 auto pend = pitches.end();
255 const auto mm = std::minmax_element(pbeg, pend);
256 int pind1 = std::floor((*
mm.first)/pitch_mag);
257 int pind2 = std::ceil((*
mm.second)/pitch_mag);
262 if (pind2 <= apind1 or pind1 >= apind2) {
276 std::stringstream ss;
278 const auto& strips = this->strips();
279 ss <<
"\tstrips (" << strips.size() <<
"):\n";
280 for (
const auto&
s : strips) {
281 ss <<
"\t\t" <<
s <<
"\n";
283 const auto corners = this->corners();
284 ss <<
"\tcorners (" << corners.size() <<
"):\n";
285 for (
const auto&
c : corners) {
286 ss <<
"\t\t" <<
c <<
"\n";
293 std::stringstream ss;
295 for (
auto strip: make_strips()) {
296 ss <<
"\t" << strip <<
"\n";
306 for (
const auto& blob : prior_blobs) {
312 for (
auto strip : strips) {
315 if (newblob.
corners().empty()) {
318 ret.push_back(newblob);
328 [](
const Blob&
b) {
return b.valid(); });
330 blobs.resize(
end - blobs.begin());
336 for (
auto & blob: blobs) {
338 auto& strips = blob.strips();
339 const int nlayers = strips.size();
340 std::vector< std::vector<grid_index_t> > mms(nlayers);
341 for (
const auto&
corner : blob.corners()) {
352 for (
int layer=0; layer<nlayers; ++layer) {
353 if (
corner.first.layer == layer or
corner.second.layer == layer) {
358 mms[layer].push_back(pind);
359 mms[layer].push_back(pind+1);
363 for (
int layer=0; layer<nlayers; ++layer) {
364 auto mm = std::minmax_element(mms[layer].
begin(), mms[layer].
end());
365 strips[layer].bounds.first = *
mm.first;
366 strips[layer].bounds.second = *
mm.second;
376 for (
const auto&
activity : activities) {
389 prune(coords, blobs);
ranges_t active_ranges() const
span(IterB &&b, IterE &&e, Adaptor &&adaptor) -> span< decltype(adaptor(std::forward< IterB >(b))), decltype(adaptor(std::forward< IterE >(e))) >
bool in(grid_index_t pitch_index) const
double pitch_location(const coordinate_t &one, const coordinate_t &two, layer_index_t other) const
strips_t make_strips() const
void prune(const Coordinates &coords, blobs_t &blobs)
std::vector< Strip > strips_t
Strip make_strip(const range_t &subspan) const
std::vector< range_t > ranges_t
vector_t::const_iterator iterator_t
constexpr ProductStatus dropped() noexcept
decltype(auto) constexpr end(T &&obj)
ADL-aware version of std::end.
size_t drop_invalid(blobs_t &blobs)
free functions
def activity(output, slices, slice_line, cluster_tap_file)
int pitch_index(double pitch, layer_index_t layer) const
blobs_t operator()(const Activity &activity)
Activity projection(const Blob &blob, const Activity &activity)
Activity subspan(int pi_begin, int pi_end) const
Activity(layer_index_t layer)
std::string as_string() const
int pitch_index(const iterator_t &it) const
const std::vector< double > & pitch_mags() const
layer_index_t layer() const
static int max(int a, int b)
const strips_t & strips() const
static crossings_t find_corners(const Strip &one, const Strip &two)
const Coordinates & m_coords
std::vector< crossing_t > crossings_t
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
std::vector< Blob > blobs_t
Tiling(const Coordinates &coords)
T min(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
std::string as_string() const
const GenericPointer< typename T::ValueType > T2 value
void debug(const char *fmt, const Args &...args)
blobs_t make_blobs(const Coordinates &coords, const activities_t &activities)
decltype(auto) constexpr begin(T &&obj)
ADL-aware version of std::begin.
void add(const Coordinates &coords, const Strip &strip)
const crossings_t & corners() const
std::vector< Activity > activities_t
std::pair< iterator_t, iterator_t > range_t
crossing_t addresses() const
void trace(const char *fmt, const Args &...args)