layout: general info about the module

This commit is contained in:
hakki 2024-10-20 20:56:25 +02:00 committed by mikolaj
parent 2ef645bbaf
commit de0ba42e18
4 changed files with 17 additions and 2 deletions

View File

@ -27,16 +27,21 @@ use crate::{
},
};
/// Represents a weight for various compounds
#[derive(Debug, Clone, Copy)]
#[enum_dispatch(GetMaybeNet)]
pub enum CompoundWeight {
/// Represents the weight of a polygon compound, includes its basic [`Layout`] information
Poly(PolyWeight),
/// Represents Via weight properties, containing its [`Layout`] properties
Via(ViaWeight),
}
/// The alias to differ node types
pub type NodeIndex = GenericNode<PrimitiveIndex, GenericIndex<CompoundWeight>>;
#[derive(Debug, Getters)]
/// Structure for managing the Layout design
pub struct Layout<R: AccessRules> {
drawing: Drawing<CompoundWeight, R>,
}
@ -46,6 +51,7 @@ impl<R: AccessRules> Layout<R> {
Self { drawing }
}
/// Insert [`Cane`] object into the [`Layout`]
pub fn insert_cane(
&mut self,
from: DotIndex,
@ -59,12 +65,14 @@ impl<R: AccessRules> Layout<R> {
.insert_cane(from, around, dot_weight, seg_weight, bend_weight, cw)
}
/// Remove [`Cane`] object from the [`Layout`]
pub fn remove_cane(&mut self, cane: &Cane, face: LooseDotIndex) {
self.drawing.remove_cane(cane, face)
}
#[debug_ensures(ret.is_ok() -> self.drawing.node_count() == old(self.drawing.node_count()) + weight.to_layer - weight.from_layer + 2)]
#[debug_ensures(ret.is_err() -> self.drawing.node_count() == old(self.drawing.node_count()))]
/// Insert [`Via`] into the [`Layout`]
pub fn add_via(&mut self, weight: ViaWeight) -> Result<GenericIndex<ViaWeight>, Infringement> {
let compound = self.drawing.add_compound(weight.into());
let mut dots = vec![];
@ -96,6 +104,7 @@ impl<R: AccessRules> Layout<R> {
Ok(GenericIndex::<ViaWeight>::new(compound.petgraph_index()))
}
pub fn add_fixed_dot(&mut self, weight: FixedDotWeight) -> Result<FixedDotIndex, Infringement> {
self.drawing.add_fixed_dot(weight)
}

View File

@ -1,3 +1,5 @@
//! Layout module for handling board geometry.
mod layout;
pub mod poly;
pub mod via;

View File

@ -1,3 +1,5 @@
//! Module for handling Polygon properties
use enum_dispatch::enum_dispatch;
use geo::{LineString, Point, Polygon};

View File

@ -1,3 +1,5 @@
//! Module for handling Vias properties
use serde::{Deserialize, Serialize};
use crate::{