use crate::float::overlay::OverlayOptions;
use crate::string::graph::StringGraph;
use crate::string::rule::StringRule;
use i_float::adapter::FloatPointAdapter;
use i_float::float::compatible::FloatPointCompatible;
use i_float::float::number::FloatNumber;
use i_shape::base::data::Shapes;
use i_shape::float::adapter::ShapesToFloat;
use i_shape::float::despike::DeSpikeContour;
use i_shape::float::simple::SimplifyContour;
pub struct FloatStringGraph<'a, P: FloatPointCompatible<T>, T: FloatNumber> {
pub graph: StringGraph<'a>,
pub adapter: FloatPointAdapter<P, T>,
}
impl<P: FloatPointCompatible<T>, T: FloatNumber> FloatStringGraph<'_, P, T> {
#[inline(always)]
pub fn extract_shapes(&self, string_rule: StringRule) -> Shapes<P> {
self.extract_shapes_custom(string_rule, Default::default())
}
#[inline]
pub fn extract_shapes_custom(&self, string_rule: StringRule, options: OverlayOptions<T>) -> Shapes<P> {
let shapes = self
.graph
.extract_shapes_custom(string_rule, options.int_with_adapter(&self.adapter));
let mut float = shapes.to_float(&self.adapter);
if options.clean_result {
if options.preserve_output_collinear {
float.despike_contour(&self.adapter);
} else {
float.simplify_contour(&self.adapter);
}
}
float
}
}