#![deny(
rust_2018_compatibility,
rust_2018_idioms,
nonstandard_style,
unused,
future_incompatible,
non_camel_case_types,
unused_parens,
non_upper_case_globals,
unused_qualifications,
unused_results,
unused_imports,
unused_variables,
bare_trait_objects,
ellipsis_inclusive_range_patterns,
elided_lifetimes_in_paths
)]
#![doc(issue_tracker_base_url = "https://github.com/eadf/boostvoronoi.rs/issues")]
use cpp_map::CppMapError;
use num_traits::{AsPrimitive, NumCast, PrimInt, Signed};
use std::cell::{BorrowError, BorrowMutError};
use std::{fmt, hash::Hash};
mod beach_line;
#[doc(hidden)]
pub mod builder;
mod circle_event;
#[doc(hidden)]
pub mod diagram;
mod end_point;
#[doc(hidden)]
pub mod geometry;
pub(crate) mod predicate;
mod site_event;
#[doc(hidden)]
pub mod utils {
pub mod ctypes;
pub mod file_reader;
pub mod visual_utils;
}
#[doc(hidden)]
pub mod extended_scalar {
pub mod extended_exp_fpt;
pub mod extended_int;
pub mod robust_fpt;
pub(crate) mod robust_sqrt_expr;
}
macro_rules! t {
($($arg:tt)*) => ({
#[cfg(feature = "console_debug")]
print!($($arg)*)
});
}
pub(crate) use t;
macro_rules! tln {
($($arg:tt)*) => ({
#[cfg(feature = "console_debug")]
println!($($arg)*)
});
}
pub(crate) use tln;
#[doc(hidden)]
#[derive(thiserror::Error, Debug)]
pub enum BvError {
#[error("error: Some error with the index map")]
IndexError(String),
#[error(transparent)]
BorrowError(#[from] BorrowError),
#[error(transparent)]
CppMapError(#[from] CppMapError),
#[error(transparent)]
BorrowMutError(#[from] BorrowMutError),
#[error("error: Some error with object id")]
IdError(String),
#[error("error: Some error with a value")]
ValueError(String),
#[error("error: Some error with the beach-line")]
BeachLineError(String),
#[error("error: given value for the radius is less than 0.0.")]
RadiusLessThanZero,
#[error("error: vertices should be added before segments")]
VerticesGoesFirst(String),
#[error("error: Some error")]
InternalError(String),
#[error("Suspected self-intersecting input data")]
SelfIntersecting(String),
#[error("Could not cast number")]
NumberConversion(String),
#[error(transparent)]
BvError(#[from] std::io::Error),
}
#[doc(hidden)]
pub trait InputType:
NumCast
+ AsPrimitive<f64>
+ AsPrimitive<i64>
+ AsPrimitive<i32>
+ PrimInt
+ Sync
+ Hash
+ Copy
+ Default
+ Unpin
+ Signed
+ fmt::Debug
+ fmt::Display
+ std::str::FromStr<Err: fmt::Debug>
{
}
impl InputType for i64 {}
impl InputType for i32 {}
#[doc(hidden)]
pub fn cast<T: NumCast, U: NumCast>(n: T) -> U {
NumCast::from(n).unwrap()
}
#[doc(hidden)]
#[inline(always)]
pub fn try_cast<T: NumCast + fmt::Debug + Copy, U: NumCast>(n: T) -> Result<U, BvError> {
NumCast::from(n).ok_or_else(|| {
BvError::NumberConversion(format!(
"Could not convert {:?} to {}",
n,
std::any::type_name::<U>()
))
})
}
pub(crate) type VobU32 = vob::Vob<u32>;
pub(crate) trait GrowingVob {
fn fill(initial_size: usize) -> Self;
fn set_grow(&mut self, bit: usize, state: bool);
fn get_f(&self, bit: usize) -> bool;
}
impl<T: PrimInt + fmt::Debug> GrowingVob for vob::Vob<T> {
#[inline]
fn fill(initial_size: usize) -> Self {
let mut v = Self::new_with_storage_type(0);
v.resize(initial_size, false);
v
}
#[inline]
fn set_grow(&mut self, bit: usize, state: bool) {
if bit >= self.len() {
self.resize(bit + size_of::<T>(), false);
}
let _ = self.set(bit, state);
}
#[inline(always)]
fn get_f(&self, bit: usize) -> bool {
self.get(bit).unwrap_or(false)
}
}
#[cfg(feature = "cgmath")]
pub use cgmath;
#[cfg(feature = "mint")]
pub use mint;
#[cfg(feature = "geo")]
pub use geo;
#[cfg(feature = "glam")]
pub use glam;
#[cfg(feature = "nalgebra")]
pub use nalgebra;
pub mod prelude {
pub use crate::builder::Builder;
pub use crate::diagram::{
Cell, CellIndex, ColorType, Diagram, Edge, EdgeIndex, SourceCategory, SourceIndex, Vertex,
VertexIndex,
};
pub use crate::geometry::{Line, Point};
pub use crate::utils::file_reader::{read_boost_input_buffer, read_boost_input_file};
pub use crate::utils::visual_utils::VoronoiVisualUtils;
pub use crate::{BvError, InputType};
}