2019-04-26 21:21:50 +02:00
|
|
|
# See LICENSE for licensing information.
|
|
|
|
|
#
|
2021-01-22 20:23:28 +01:00
|
|
|
# Copyright (c) 2016-2021 Regents of the University of California and The Board
|
2019-06-14 17:43:41 +02:00
|
|
|
# of Regents for the Oklahoma Agricultural and Mechanical College
|
|
|
|
|
# (acting for and on behalf of Oklahoma State University)
|
|
|
|
|
# All rights reserved.
|
2019-04-26 21:21:50 +02:00
|
|
|
#
|
2018-09-07 23:46:58 +02:00
|
|
|
class grid_cell:
|
2016-11-17 00:02:07 +01:00
|
|
|
"""
|
|
|
|
|
A single cell that can be occupied in a given layer, blocked,
|
|
|
|
|
visited, etc.
|
|
|
|
|
"""
|
|
|
|
|
def __init__(self):
|
2016-11-17 01:47:31 +01:00
|
|
|
self.path = False
|
2016-11-17 00:02:07 +01:00
|
|
|
self.blocked = False
|
2016-11-17 01:47:31 +01:00
|
|
|
self.source = False
|
|
|
|
|
self.target = False
|
2017-04-24 19:27:04 +02:00
|
|
|
# -1 means it isn't visited yet
|
2020-11-03 15:29:17 +01:00
|
|
|
self.min_cost = -1
|
2016-11-17 00:02:07 +01:00
|
|
|
|
2017-04-24 20:28:36 +02:00
|
|
|
def reset(self):
|
2020-11-03 15:29:17 +01:00
|
|
|
"""
|
2017-04-24 20:28:36 +02:00
|
|
|
Reset the dynamic info about routing. The pins/blockages are not reset so
|
|
|
|
|
that they can be reused.
|
|
|
|
|
"""
|
|
|
|
|
self.min_cost=-1
|
|
|
|
|
self.min_path=None
|
2017-06-05 23:42:56 +02:00
|
|
|
self.blocked=False
|
|
|
|
|
self.source=False
|
|
|
|
|
self.target=False
|
|
|
|
|
|
2018-11-02 22:57:40 +01:00
|
|
|
def get_cost(self):
|
|
|
|
|
# We can display the cost of the frontier
|
|
|
|
|
if self.min_cost > 0:
|
|
|
|
|
return self.min_cost
|
2020-11-03 15:29:17 +01:00
|
|
|
|
2017-04-24 19:27:04 +02:00
|
|
|
def get_type(self):
|
2019-05-31 17:43:37 +02:00
|
|
|
type_string = ""
|
2020-11-03 15:29:17 +01:00
|
|
|
|
2016-11-17 00:02:07 +01:00
|
|
|
if self.blocked:
|
2019-05-31 17:43:37 +02:00
|
|
|
type_string += "X"
|
2017-04-24 19:27:04 +02:00
|
|
|
|
|
|
|
|
if self.source:
|
2019-05-31 17:43:37 +02:00
|
|
|
type_string += "S"
|
2016-11-17 20:24:17 +01:00
|
|
|
|
2017-04-24 19:27:04 +02:00
|
|
|
if self.target:
|
2019-05-31 17:43:37 +02:00
|
|
|
type_string += "T"
|
2016-11-17 00:02:07 +01:00
|
|
|
|
2016-11-17 01:47:31 +01:00
|
|
|
if self.path:
|
2019-05-31 17:43:37 +02:00
|
|
|
type_string += "P"
|
2016-11-17 20:24:17 +01:00
|
|
|
|
2021-01-06 18:41:13 +01:00
|
|
|
return type_string
|
2020-11-03 15:29:17 +01:00
|
|
|
|