extern "C" {
#[doc(hidden)] fn cv_new_VectorOfPoint() -> *mut c_void;
#[doc(hidden)] fn cv_delete_VectorOfPoint(ptr: *mut c_void);
#[doc(hidden)] fn cv_push_VectorOfPoint(ptr: *mut c_void, ptr2: *const c_void);
#[doc(hidden)] fn cv_VectorOfPoint_len(ptr: *mut c_void) -> i32;
#[doc(hidden)] fn cv_VectorOfPoint_get(ptr: *mut c_void, index: i32) -> *mut c_void;
}
#[allow(dead_code)]
pub struct VectorOfPoint {
pub(crate) ptr: *mut c_void
}
impl VectorOfPoint {
pub fn new() -> Self {
unsafe { Self { ptr: cv_new_VectorOfPoint() } }
}
pub fn len(&self) -> i32 {
unsafe { cv_VectorOfPoint_len(self.ptr) }
}
#[doc(hidden)]
pub fn as_raw_VectorOfPoint(&self) -> *mut c_void {
self.ptr
}
}
impl Drop for VectorOfPoint {
fn drop(&mut self) {
unsafe { cv_delete_VectorOfPoint(self.ptr) };
}
}
impl VectorOfPoint {
pub fn push(&mut self, val: core::Point) {
unsafe { cv_push_VectorOfPoint(self.ptr, &val as *const _ as _) }
}
pub fn get(&self, index: i32) -> &mut core::Point {
unsafe { (cv_VectorOfPoint_get(self.ptr, index) as *mut core::Point).as_mut().unwrap() }
}
}
extern "C" { #[doc(hidden)] fn cv_VectorOfPoint_data(ptr: *mut c_void) -> *mut c_void; }
impl ::std::ops::Deref for VectorOfPoint {
type Target = [core::Point];
fn deref(&self) -> &Self::Target {
unsafe {
let length = cv_VectorOfPoint_len(self.ptr) as usize;
let data = cv_VectorOfPoint_data(self.ptr);
::std::slice::from_raw_parts(::std::mem::transmute(data), length)
}
}
}