mirror of https://codeberg.org/topola/topola.git
refactor(geometry): move edit code to its own file
This commit is contained in:
parent
adc1852b46
commit
1f55e92026
|
|
@ -7,8 +7,9 @@ use rstar::{RTree, AABB};
|
|||
use thiserror::Error;
|
||||
|
||||
use crate::geometry::{
|
||||
edit::GeometryEdit,
|
||||
primitive::{AccessPrimitiveShape, PrimitiveShape},
|
||||
recording_with_rtree::{GeometryEdit, RecordingGeometryWithRtree},
|
||||
recording_with_rtree::RecordingGeometryWithRtree,
|
||||
with_rtree::BboxedIndex,
|
||||
AccessBendWeight, AccessDotWeight, AccessSegWeight, GenericNode, Geometry, GeometryLabel,
|
||||
GetOffset, GetPos, GetWidth,
|
||||
|
|
|
|||
|
|
@ -0,0 +1,50 @@
|
|||
use std::{collections::HashMap, hash::Hash, marker::PhantomData};
|
||||
|
||||
use crate::{
|
||||
drawing::graph::{GetLayer, Retag},
|
||||
graph::{GenericIndex, GetPetgraphIndex},
|
||||
};
|
||||
|
||||
use super::{AccessBendWeight, AccessDotWeight, AccessSegWeight, GetWidth};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct GeometryEdit<
|
||||
PW: GetWidth + GetLayer + TryInto<DW> + TryInto<SW> + TryInto<BW> + Retag<PI> + Copy,
|
||||
DW: AccessDotWeight<PW> + GetLayer,
|
||||
SW: AccessSegWeight<PW> + GetLayer,
|
||||
BW: AccessBendWeight<PW> + GetLayer,
|
||||
CW: Copy,
|
||||
PI: GetPetgraphIndex + TryInto<DI> + TryInto<SI> + TryInto<BI> + Eq + Hash + Copy,
|
||||
DI: GetPetgraphIndex + Into<PI> + Eq + Hash + Copy,
|
||||
SI: GetPetgraphIndex + Into<PI> + Eq + Hash + Copy,
|
||||
BI: GetPetgraphIndex + Into<PI> + Eq + Hash + Copy,
|
||||
> {
|
||||
pub(super) dots: HashMap<DI, (Option<DW>, Option<DW>)>,
|
||||
pub(super) segs: HashMap<SI, (Option<((DI, DI), SW)>, Option<((DI, DI), SW)>)>,
|
||||
pub(super) bends: HashMap<BI, (Option<((DI, DI, DI), BW)>, Option<((DI, DI, DI), BW)>)>,
|
||||
pub(super) compounds: HashMap<GenericIndex<CW>, (Option<(Vec<PI>, CW)>, Option<(Vec<PI>, CW)>)>,
|
||||
primitive_weight_marker: PhantomData<PW>,
|
||||
}
|
||||
|
||||
impl<
|
||||
PW: GetWidth + GetLayer + TryInto<DW> + TryInto<SW> + TryInto<BW> + Retag<PI> + Copy,
|
||||
DW: AccessDotWeight<PW> + GetLayer,
|
||||
SW: AccessSegWeight<PW> + GetLayer,
|
||||
BW: AccessBendWeight<PW> + GetLayer,
|
||||
CW: Copy,
|
||||
PI: GetPetgraphIndex + TryInto<DI> + TryInto<SI> + TryInto<BI> + Eq + Hash + Copy,
|
||||
DI: GetPetgraphIndex + Into<PI> + Eq + Hash + Copy,
|
||||
SI: GetPetgraphIndex + Into<PI> + Eq + Hash + Copy,
|
||||
BI: GetPetgraphIndex + Into<PI> + Eq + Hash + Copy,
|
||||
> GeometryEdit<PW, DW, SW, BW, CW, PI, DI, SI, BI>
|
||||
{
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
dots: HashMap::new(),
|
||||
segs: HashMap::new(),
|
||||
bends: HashMap::new(),
|
||||
compounds: HashMap::new(),
|
||||
primitive_weight_marker: PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
#[macro_use]
|
||||
mod geometry;
|
||||
pub mod compound;
|
||||
pub mod edit;
|
||||
pub mod poly;
|
||||
pub mod primitive;
|
||||
pub mod recording_with_rtree;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use std::{collections::HashMap, hash::Hash, marker::PhantomData};
|
||||
use std::hash::Hash;
|
||||
|
||||
use geo::Point;
|
||||
use petgraph::stable_graph::StableDiGraph;
|
||||
|
|
@ -11,53 +11,12 @@ use crate::{
|
|||
|
||||
use super::{
|
||||
compound::ManageCompounds,
|
||||
edit::GeometryEdit,
|
||||
with_rtree::{BboxedIndex, GeometryWithRtree},
|
||||
AccessBendWeight, AccessDotWeight, AccessSegWeight, GenericNode, Geometry, GeometryLabel,
|
||||
GetWidth,
|
||||
};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct GeometryEdit<
|
||||
PW: GetWidth + GetLayer + TryInto<DW> + TryInto<SW> + TryInto<BW> + Retag<PI> + Copy,
|
||||
DW: AccessDotWeight<PW> + GetLayer,
|
||||
SW: AccessSegWeight<PW> + GetLayer,
|
||||
BW: AccessBendWeight<PW> + GetLayer,
|
||||
CW: Copy,
|
||||
PI: GetPetgraphIndex + TryInto<DI> + TryInto<SI> + TryInto<BI> + Eq + Hash + Copy,
|
||||
DI: GetPetgraphIndex + Into<PI> + Eq + Hash + Copy,
|
||||
SI: GetPetgraphIndex + Into<PI> + Eq + Hash + Copy,
|
||||
BI: GetPetgraphIndex + Into<PI> + Eq + Hash + Copy,
|
||||
> {
|
||||
dots: HashMap<DI, (Option<DW>, Option<DW>)>,
|
||||
segs: HashMap<SI, (Option<((DI, DI), SW)>, Option<((DI, DI), SW)>)>,
|
||||
bends: HashMap<BI, (Option<((DI, DI, DI), BW)>, Option<((DI, DI, DI), BW)>)>,
|
||||
compounds: HashMap<GenericIndex<CW>, (Option<(Vec<PI>, CW)>, Option<(Vec<PI>, CW)>)>,
|
||||
primitive_weight_marker: PhantomData<PW>,
|
||||
}
|
||||
|
||||
impl<
|
||||
PW: GetWidth + GetLayer + TryInto<DW> + TryInto<SW> + TryInto<BW> + Retag<PI> + Copy,
|
||||
DW: AccessDotWeight<PW> + GetLayer,
|
||||
SW: AccessSegWeight<PW> + GetLayer,
|
||||
BW: AccessBendWeight<PW> + GetLayer,
|
||||
CW: Copy,
|
||||
PI: GetPetgraphIndex + TryInto<DI> + TryInto<SI> + TryInto<BI> + Eq + Hash + Copy,
|
||||
DI: GetPetgraphIndex + Into<PI> + Eq + Hash + Copy,
|
||||
SI: GetPetgraphIndex + Into<PI> + Eq + Hash + Copy,
|
||||
BI: GetPetgraphIndex + Into<PI> + Eq + Hash + Copy,
|
||||
> GeometryEdit<PW, DW, SW, BW, CW, PI, DI, SI, BI>
|
||||
{
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
dots: HashMap::new(),
|
||||
segs: HashMap::new(),
|
||||
bends: HashMap::new(),
|
||||
compounds: HashMap::new(),
|
||||
primitive_weight_marker: PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct RecordingGeometryWithRtree<
|
||||
PW: GetWidth + GetLayer + TryInto<DW> + TryInto<SW> + TryInto<BW> + Retag<PI> + Copy,
|
||||
|
|
|
|||
Loading…
Reference in New Issue