diff --git a/MLStructFP/__init__.py b/MLStructFP/__init__.py index 087076a..4e43a90 100644 --- a/MLStructFP/__init__.py +++ b/MLStructFP/__init__.py @@ -9,7 +9,7 @@ __description__ = 'Machine learning structural floor plan dataset' __keywords__ = ['ml', 'ai', 'floor plan', 'architectural', 'dataset', 'cnn'] __email__ = 'pablo@ppizarror.com' -__version__ = '0.6.8' +__version__ = '0.6.9' # URL __url__ = 'https://github.com/MLSTRUCT/MLSTRUCT-FP' diff --git a/MLStructFP/db/_c.py b/MLStructFP/db/_c.py index 4d2cbed..58ea64f 100644 --- a/MLStructFP/db/_c.py +++ b/MLStructFP/db/_c.py @@ -21,9 +21,9 @@ class BaseComponent(abc.ABC): """ Floor plan base component. """ - floor: 'Floor' - id: int - points: List['GeomPoint2D'] + _floor: 'Floor' + _id: int + _points: List['GeomPoint2D'] # The coordinates of the object def __init__( self, @@ -43,11 +43,23 @@ def __init__( assert isinstance(component_id, int) and component_id > 0 assert isinstance(x, VectorInstance) and len(x) > 0 assert isinstance(y, VectorInstance) and len(y) == len(x) - self.id = component_id - self.floor = floor - self.points = [] + self._floor = floor + self._id = component_id + self._points = [] for i in range(len(x)): - self.points.append(GeomPoint2D(float(x[i]), float(y[i]))) + self._points.append(GeomPoint2D(float(x[i]), float(y[i]))) + + @property + def floor(self) -> 'Floor': + return self._floor + + @property + def id(self) -> int: + return self._id + + @property + def points(self) -> List['GeomPoint2D']: + return [p for p in self._points] def plot_plotly(self, *args, **kwargs) -> None: """ @@ -75,7 +87,7 @@ def __svg_path(self, dx: NumberType = 0, dy: NumberType = 0) -> str: :param dx: X displacement :param dy: Y displacement """ - px, py = [p.x for p in self.points], [p.y for p in self.points] + px, py = [p.x for p in self._points], [p.y for p in self._points] for i in range(len(px)): # Adds displacement (dx, dy) px[i] += dx py[i] += dy @@ -134,7 +146,7 @@ def plot_matplotlib( :param color: Plot color :param fill: Fill object """ - px, py = [p.x for p in self.points], [p.y for p in self.points] + px, py = [p.x for p in self._points], [p.y for p in self._points] px.append(px[0]) py.append(py[0]) if fill: @@ -149,8 +161,8 @@ class BasePolyObj(BasePolyComponent, abc.ABC): """ __basename: str __color: str - category: int - category_name: str + _category: int + _category_name: str def __init__( self, @@ -181,8 +193,16 @@ def __init__( ctx[obj_id] = self self.__basename = basename self.__color = color - self.category = category - self.category_name = category_name + self._category_name = category_name + self._category = category + + @property + def category(self) -> int: + return self._category + + @property + def category_name(self) -> str: + return self._category_name # noinspection PyUnusedLocal def plot_plotly( diff --git a/MLStructFP/db/_c_rect.py b/MLStructFP/db/_c_rect.py index 698b7f9..e7f0b3f 100644 --- a/MLStructFP/db/_c_rect.py +++ b/MLStructFP/db/_c_rect.py @@ -78,7 +78,7 @@ def get_mass_center(self) -> 'GeomPoint2D': """ Returns the mass center of the rect. """ - return GeomPoint2D(sum(p.x for p in self.points), sum(p.y for p in self.points)).scale(1 / len(self.points)) + return GeomPoint2D(sum(p.x for p in self._points), sum(p.y for p in self._points)).scale(1 / len(self._points)) def plot_plotly( self, @@ -103,7 +103,7 @@ def plot_plotly( :param color: Color, if empty use default object color :param show_legend: Add object legend to plot """ - px, py = [p.x for p in self.points], [p.y for p in self.points] + px, py = [p.x for p in self._points], [p.y for p in self._points] px.append(px[0]) py.append(py[0]) if color == '': @@ -144,7 +144,7 @@ def plot_matplotlib( """ if color == '': color = '#000000' - px, py = [p.x for p in self.points], [p.y for p in self.points] + px, py = [p.x for p in self._points], [p.y for p in self._points] if fill: ax.fill(px, py, color=color, lw=None, alpha=alpha) else: