16#include <peak_icv_c/types/peak_icv_polygon.h>
34template <
typename Po
intType>
36 :
private detail::IBackendAccessible<Polygon<PointType>>
37 ,
private detail::IBackendExchangeable<Polygon<PointType>>
98 PEAK_ICV_NO_DISCARD std::vector<peak::common::detail::PointT<PointType>>
GetPoints()
const;
107 PEAK_ICV_NO_DISCARD
bool IsClosed()
const;
110 friend peak::common::detail::BackendAccessor<Polygon>;
114 explicit Polygon(peak_icv_polygon_handle handle);
118 peak_icv_polygon_handle m_handle{};
121template <
typename Po
intType>
125 return PEAK_ICV_C_ABI_PREFIX peak_icv_Polygon_Create(&m_handle);
129template <
typename Po
intType>
132 std::vector<PointTypeC> cPoints;
133 cPoints.reserve(points.size());
134 std::transform(points.begin(), points.end(), std::back_inserter(cPoints), [](
const auto& cppPoint) {
135 return peak::common::detail::BackendAccessor<peak::common::detail::PointT<PointType>>::CreateCType(cppPoint);
138 return PEAK_ICV_C_ABI_PREFIX peak_icv_Polygon_CreateFromPoints(
143template <
typename Po
intType>
145 : m_handle{ polygonHandle }
148template <
typename Po
intType>
151 if (m_handle != other.m_handle)
154 return PEAK_ICV_C_ABI_PREFIX peak_icv_Polygon_IncreaseUseCount(other.m_handle);
156 m_handle = other.m_handle;
160template <
typename Po
intType>
163 if (m_handle != other.m_handle)
165 m_handle = other.m_handle;
166 other.m_handle =
nullptr;
170template <
typename Po
intType>
173 static_cast<void>(PEAK_ICV_C_ABI_PREFIX peak_icv_Polygon_Destroy(m_handle));
176template <
typename Po
intType>
179 if (m_handle != other.m_handle)
181 if (m_handle !=
nullptr)
184 return PEAK_ICV_C_ABI_PREFIX peak_icv_Polygon_Destroy(m_handle);
189 return PEAK_ICV_C_ABI_PREFIX peak_icv_Polygon_IncreaseUseCount(other.m_handle);
191 m_handle = other.m_handle;
196template <
typename Po
intType>
199 if (m_handle != other.m_handle)
201 if (m_handle !=
nullptr)
204 return PEAK_ICV_C_ABI_PREFIX peak_icv_Polygon_Destroy(m_handle);
208 m_handle = other.m_handle;
209 other.m_handle =
nullptr;
214template <
typename Po
intType>
217 size_t numPoints = 0;
219 return PEAK_ICV_C_ABI_PREFIX peak_icv_Polygon_GetPoints_GetCount(m_handle, &numPoints);
226 std::vector<PointTypeC> cPoints(numPoints);
228 return PEAK_ICV_C_ABI_PREFIX peak_icv_Polygon_GetPoints(m_handle, cPoints.data(), numPoints *
sizeof(PointTypeC));
231 std::vector<peak::common::detail::PointT<PointType>> cppPoints{};
232 cppPoints.reserve(numPoints);
233 std::transform(cPoints.begin(), cPoints.end(), std::back_inserter(cppPoints), [](
const auto& cPoint) {
234 return peak::common::detail::BackendAccessor<peak::common::detail::PointT<PointType>>::CreateInstance(cPoint);
240template <
typename Po
intType>
243 bool isClosed =
false;
245 return PEAK_ICV_C_ABI_PREFIX peak_icv_Polygon_IsClosed(m_handle, &isClosed);
251template <
typename Po
intType>
257template <
typename Po
intType>
265namespace experimental
A polygon is a two-dimensional geometric shape that is made up of a finite number of straight line se...
std::vector< peak::common::detail::PointT< PointType > > GetPoints() const
Provides the points from a polygon.
Polygon & operator=(const Polygon &other)
bool IsClosed() const
Checks if a polygon is closed. A closed polygon contains the same point as first and last point....
Polygon()
Creates an empty polygon.
typename c_type_of_< Type >::type c_type_of_t
void ExecuteAndMapReturnCodes(const CallableType &callableObject)
peak::common::detail::c_type_of_t< Type > * handle_of_t