mirror of https://codeberg.org/topola/topola.git
layout: implement creation and return of the apex
Apex is the dot positioned at the center of a zone that is used to terminate and tie any band ending in the zone.
This commit is contained in:
parent
ea22ba705c
commit
5664b73494
|
|
@ -6,7 +6,7 @@ use crate::{
|
||||||
drawing::{
|
drawing::{
|
||||||
bend::LooseBendWeight,
|
bend::LooseBendWeight,
|
||||||
dot::{DotIndex, FixedDotIndex, FixedDotWeight, LooseDotIndex, LooseDotWeight},
|
dot::{DotIndex, FixedDotIndex, FixedDotWeight, LooseDotIndex, LooseDotWeight},
|
||||||
graph::{PrimitiveIndex, PrimitiveWeight, Retag},
|
graph::{GetLayer, PrimitiveIndex, PrimitiveWeight, Retag},
|
||||||
rules::RulesTrait,
|
rules::RulesTrait,
|
||||||
seg::{
|
seg::{
|
||||||
FixedSegIndex, FixedSegWeight, LoneLooseSegIndex, LoneLooseSegWeight, SeqLooseSegIndex,
|
FixedSegIndex, FixedSegWeight, LoneLooseSegIndex, LoneLooseSegWeight, SeqLooseSegIndex,
|
||||||
|
|
@ -17,16 +17,17 @@ use crate::{
|
||||||
Drawing, Infringement, LayoutException,
|
Drawing, Infringement, LayoutException,
|
||||||
},
|
},
|
||||||
geometry::{
|
geometry::{
|
||||||
compound::CompoundManagerTrait, poly::PolyShape, BendWeightTrait, DotWeightTrait,
|
compound::CompoundManagerTrait, poly::PolyShape, shape::ShapeTrait, BendWeightTrait,
|
||||||
GenericNode, Geometry, GeometryLabel, GetWidth, SegWeightTrait,
|
DotWeightTrait, GenericNode, Geometry, GeometryLabel, GetWidth, SegWeightTrait,
|
||||||
},
|
},
|
||||||
graph::{GenericIndex, GetNodeIndex},
|
graph::{GenericIndex, GetNodeIndex},
|
||||||
layout::{
|
layout::{
|
||||||
connectivity::{
|
connectivity::{
|
||||||
BandIndex, BandWeight, ConnectivityLabel, ConnectivityWeight, ContinentIndex,
|
BandIndex, BandWeight, ConnectivityLabel, ConnectivityWeight, ContinentIndex,
|
||||||
},
|
},
|
||||||
zone::{PourZoneIndex, SolidZoneIndex, Zone, ZoneWeight},
|
zone::{GetMaybeApex, MakePolyShape, PourZoneIndex, SolidZoneIndex, Zone, ZoneWeight},
|
||||||
},
|
},
|
||||||
|
math::Circle,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub type NodeIndex = GenericNode<PrimitiveIndex, GenericIndex<ZoneWeight>>;
|
pub type NodeIndex = GenericNode<PrimitiveIndex, GenericIndex<ZoneWeight>>;
|
||||||
|
|
@ -207,6 +208,25 @@ impl<R: RulesTrait> Layout<R> {
|
||||||
.compound_members(GenericIndex::new(zone.node_index()))
|
.compound_members(GenericIndex::new(zone.node_index()))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn zone_apex(&mut self, zone: GenericIndex<ZoneWeight>) -> FixedDotIndex {
|
||||||
|
if let Some(apex) = self.zone(zone).maybe_apex() {
|
||||||
|
apex
|
||||||
|
} else {
|
||||||
|
self.add_zone_fixed_dot(
|
||||||
|
FixedDotWeight {
|
||||||
|
circle: Circle {
|
||||||
|
pos: self.zone(zone).shape().center(),
|
||||||
|
r: 0.0,
|
||||||
|
},
|
||||||
|
layer: self.zone(zone).layer(),
|
||||||
|
maybe_net: None,
|
||||||
|
},
|
||||||
|
zone,
|
||||||
|
)
|
||||||
|
.unwrap()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn drawing(&self) -> &Drawing<ZoneWeight, R> {
|
pub fn drawing(&self) -> &Drawing<ZoneWeight, R> {
|
||||||
&self.drawing
|
&self.drawing
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,9 +5,9 @@ use petgraph::stable_graph::NodeIndex;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
drawing::{
|
drawing::{
|
||||||
dot::DotIndex,
|
dot::{DotIndex, FixedDotIndex},
|
||||||
graph::{GetLayer, GetMaybeNet, MakePrimitive, PrimitiveIndex, PrimitiveWeight, Retag},
|
graph::{GetLayer, GetMaybeNet, MakePrimitive, PrimitiveIndex, PrimitiveWeight, Retag},
|
||||||
primitive::{GenericPrimitive, Primitive},
|
primitive::{GenericPrimitive, GetLimbs, Primitive},
|
||||||
rules::RulesTrait,
|
rules::RulesTrait,
|
||||||
Drawing,
|
Drawing,
|
||||||
},
|
},
|
||||||
|
|
@ -21,6 +21,11 @@ pub trait MakePolyShape {
|
||||||
fn shape(&self) -> PolyShape;
|
fn shape(&self) -> PolyShape;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[enum_dispatch]
|
||||||
|
pub trait GetMaybeApex {
|
||||||
|
fn maybe_apex(&self) -> Option<FixedDotIndex>;
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Zone<'a, R: RulesTrait> {
|
pub struct Zone<'a, R: RulesTrait> {
|
||||||
pub index: GenericIndex<ZoneWeight>,
|
pub index: GenericIndex<ZoneWeight>,
|
||||||
|
|
@ -72,6 +77,26 @@ impl<'a, R: RulesTrait> MakePolyShape for Zone<'a, R> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<'a, R: RulesTrait> GetMaybeApex for Zone<'a, R> {
|
||||||
|
fn maybe_apex(&self) -> Option<FixedDotIndex> {
|
||||||
|
self.layout
|
||||||
|
.drawing()
|
||||||
|
.geometry()
|
||||||
|
.compound_members(self.index)
|
||||||
|
.find_map(|primitive_node| {
|
||||||
|
if let PrimitiveIndex::FixedDot(dot) = primitive_node {
|
||||||
|
if self.layout.drawing().primitive(dot).segs().is_empty()
|
||||||
|
&& self.layout.drawing().primitive(dot).bends().is_empty()
|
||||||
|
{
|
||||||
|
return Some(dot);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
None
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[enum_dispatch(GetLayer, GetMaybeNet)]
|
#[enum_dispatch(GetLayer, GetMaybeNet)]
|
||||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||||
pub enum ZoneWeight {
|
pub enum ZoneWeight {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue