use super::symbolic::{
SymbolicCircle, SymbolicFillArea, SymbolicPolyline, SymbolicRepresentationCollection,
SymbolicText,
};
impl SymbolicRepresentationCollection {
pub fn from_data(data: ifc_lite_processing::SymbolicData) -> Self {
let mut collection = Self::with_capacity(data.polylines.len(), data.circles.len());
collection.truncated = data.truncated.clone();
for p in data.polylines {
collection.add_polyline(SymbolicPolyline::new(
p.express_id,
p.ifc_type,
p.points,
p.closed,
p.world_y,
p.representation,
));
}
for c in data.circles {
collection.add_circle(SymbolicCircle::new(
c.express_id,
c.ifc_type,
c.center_x,
c.center_y,
c.radius,
c.world_y,
c.start_angle,
c.end_angle,
c.representation,
));
}
for t in data.texts {
collection.add_text(SymbolicText::new_styled(
t.express_id,
t.ifc_type,
t.x,
t.y,
t.dir_x,
t.dir_y,
t.height,
t.content,
t.alignment,
t.world_y,
t.color,
t.target_px,
t.representation,
));
}
for f in data.fills {
let fill = SymbolicFillArea::new(
f.express_id,
f.ifc_type,
f.points,
f.holes_offsets,
f.fill_color,
f.world_y,
f.representation,
);
collection.add_fill(if f.has_hatching {
fill.with_hatching(
f.hatch_spacing,
f.hatch_angle,
Some(f.hatch_angle_secondary).filter(|a| !a.is_nan()),
f.hatch_line_width,
)
} else {
fill
});
}
collection
}
}