pub struct RoadGraph {
pub nodes: Vec<RoadNode>,
pub edges: Vec<RoadEdge>,
pub blocks: Vec<CityBlock>,
}Expand description
Fields§
§nodes: Vec<RoadNode>Road intersections and endpoints.
edges: Vec<RoadEdge>Road segments (check RoadEdge::active before traversal).
blocks: Vec<CityBlock>Enclosed city blocks extracted by crate::polygons::extract_blocks.
Implementations§
Source§impl RoadGraph
impl RoadGraph
Sourcepub fn add_node(&mut self, position: Vec2) -> NodeId
pub fn add_node(&mut self, position: Vec2) -> NodeId
Inserts a new node and returns its NodeId.
Sourcepub fn add_node_with_elevation(
&mut self,
position: Vec2,
elevation: f32,
) -> NodeId
pub fn add_node_with_elevation( &mut self, position: Vec2, elevation: f32, ) -> NodeId
Inserts a new node with an explicit elevation and returns its NodeId.
Sourcepub fn add_edge(
&mut self,
start: NodeId,
end: NodeId,
road_type: RoadType,
) -> EdgeId
pub fn add_edge( &mut self, start: NodeId, end: NodeId, road_type: RoadType, ) -> EdgeId
Inserts a new active edge between two nodes and returns its EdgeId.
Sourcepub fn split_edge(
&mut self,
edge_id: EdgeId,
split_pos: Vec2,
) -> (NodeId, EdgeId, EdgeId)
pub fn split_edge( &mut self, edge_id: EdgeId, split_pos: Vec2, ) -> (NodeId, EdgeId, EdgeId)
Deactivates an edge and splits it at split_pos, returning (new_node, edge_a, edge_b).
The original edge is marked inactive. Two new edges are created connecting the original endpoints through the new split node.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for RoadGraph
impl<'de> Deserialize<'de> for RoadGraph
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for RoadGraph
impl RefUnwindSafe for RoadGraph
impl Send for RoadGraph
impl Sync for RoadGraph
impl Unpin for RoadGraph
impl UnsafeUnpin for RoadGraph
impl UnwindSafe for RoadGraph
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more