17#include <peak_icv_c/selectors/peak_icv_region_selector.h>
106 template <
typename T>
110 std::vector<Region> m_regions;
113inline RegionSelector::RegionSelector(
const std::vector<Region>& regions)
114 : m_regions{ regions }
124 return SelectBy<peak::common::IntervalU>(
125 PEAK_ICV_C_ABI_PREFIX peak_icv_Region_SelectByArea_GetCount, PEAK_ICV_C_ABI_PREFIX peak_icv_Region_SelectByArea, interval);
130 return SelectBy<peak::common::IntervalF>(PEAK_ICV_C_ABI_PREFIX peak_icv_Region_SelectByCenterOfGravityX_GetCount,
131 PEAK_ICV_C_ABI_PREFIX peak_icv_Region_SelectByCenterOfGravityX, interval);
136 return SelectBy<peak::common::IntervalF>(PEAK_ICV_C_ABI_PREFIX peak_icv_Region_SelectByCenterOfGravityY_GetCount,
137 PEAK_ICV_C_ABI_PREFIX peak_icv_Region_SelectByCenterOfGravityY, interval);
142 return SelectBy<peak::common::RectangleF>(PEAK_ICV_C_ABI_PREFIX peak_icv_Region_SelectByCenterOfGravityRect_GetCount,
143 PEAK_ICV_C_ABI_PREFIX peak_icv_Region_SelectByCenterOfGravityRect, rect);
151 if (m_regions.empty())
156 std::vector<peak_icv_region_handle> handles;
157 handles.reserve(m_regions.size());
159 std::transform(m_regions.begin(), m_regions.end(), std::back_inserter(handles), [](
const auto& region) {
160 return peak::common::detail::BackendAccessor<peak::icv::experimental::Region>::BackendHandle(region);
165 return selectByGetCount(
166 handles.data(), handles.size(), peak::common::detail::BackendAccessor<T>::CreateCType(interval), &count);
174 std::vector<peak_icv_region_handle> selectedHandles(count);
176 return selectBy(handles.data(), handles.size(), peak::common::detail::BackendAccessor<T>::CreateCType(interval),
177 selectedHandles.data(), selectedHandles.size());
179 return RegionSelector(peak::common::detail::BackendAccessor<peak::icv::experimental::Region>::CreateInstances(selectedHandles));
Represents a continuous numeric interval with inclusive lower and upper bounds.
A generic rectangle defined by a point and a size.
Class for selecting regions.
RegionSelector SelectByArea(const peak::common::IntervalU &interval)
Select a number of regions from a set of input regions by their area.
RegionSelector SelectByCenterOfGravityRect(const peak::common::RectangleF &rect)
Select a number of regions from a set of input regions by their center of gravity.
std::vector< Region > GetRegions()
Returns the selected regions.
RegionSelector SelectByCenterOfGravityY(const peak::common::IntervalF &interval)
Select a number of regions from a set of input regions by their center of gravity y.
RegionSelector SelectByCenterOfGravityX(const peak::common::IntervalF &interval)
Select a number of regions from a set of input regions by their center of gravity x.
RegionSelector(const std::vector< Region > ®ions)
Constructor.
typename c_type_of_< Type >::type c_type_of_t
void ExecuteAndMapReturnCodes(const CallableType &callableObject)
std::function< peak_icv_status(peak_icv_region_handle *, size_t, T, peak_icv_region_handle *, size_t)> select_by_function_t
std::function< peak_icv_status(peak_icv_region_handle *, size_t, T, size_t *)> select_by_get_count_function_t