Skip to content

Commit

Permalink
Hide basecomponent properties
Browse files Browse the repository at this point in the history
  • Loading branch information
ppizarror committed Oct 15, 2024
1 parent e61bc1c commit 9b9df40
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 17 deletions.
2 changes: 1 addition & 1 deletion MLStructFP/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
__description__ = 'Machine learning structural floor plan dataset'
__keywords__ = ['ml', 'ai', 'floor plan', 'architectural', 'dataset', 'cnn']
__email__ = '[email protected]'
__version__ = '0.6.8'
__version__ = '0.6.9'

# URL
__url__ = 'https://github.com/MLSTRUCT/MLSTRUCT-FP'
Expand Down
46 changes: 33 additions & 13 deletions MLStructFP/db/_c.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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:
"""
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand All @@ -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,
Expand Down Expand Up @@ -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(
Expand Down
6 changes: 3 additions & 3 deletions MLStructFP/db/_c_rect.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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 == '':
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 9b9df40

Please sign in to comment.