Skip to content

Commit

Permalink
refactor(*): add a separate method to add metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
devang-chauhan committed Aug 13, 2021
1 parent 9f801cd commit e49dc0e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
9 changes: 3 additions & 6 deletions honeybee_vtk/to_vtk.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,16 +103,14 @@ def convert_sensor_grid(
def convert_shade(shade: Shade) -> PolyData:
polydata = convert_face_3d(shade.geometry)
metadata = polydata._get_metadata(shade)
for key, value in metadata.items():
polydata.add_data(value, key, data_range=[0, 0])
polydata._add_metadata(metadata)
return polydata


def convert_aperture(aperture: Aperture) -> List[PolyData]:
polydata = convert_face_3d(aperture.geometry)
metadata = polydata._get_metadata(aperture)
for key, value in metadata.items():
polydata.add_data(value, key, data_range=[0, 0])
polydata._add_metadata(metadata)
data = [polydata]
for shade in aperture.outdoor_shades:
polydata = convert_shade(shade)
Expand All @@ -125,8 +123,7 @@ def convert_face(face: Face) -> List[PolyData]:

polydata = convert_face_3d(face.punched_geometry)
metadata = polydata._get_metadata(face)
for key, value in metadata.items():
polydata.add_data(value, key, data_range=[0, 0])
polydata._add_metadata(metadata)
data = [polydata]
for aperture in face.apertures:
data.extend(convert_aperture(aperture))
Expand Down
9 changes: 9 additions & 0 deletions honeybee_vtk/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,15 @@ def _get_metadata(self, hb_object: Union[Face, Aperture, Shade]) -> Dict[str, li

return metadata

def _add_metadata(self, metadata: Dict[str, list]) -> None:
"""Add metadata to Polydata.
Args:
metadata: A dictionary generated from _get_metadata method.
"""
for key, value in metadata.items():
self.add_data(value, key, data_range=[0, 0])

def __repr__(self) -> Tuple[str]:
return (
f'Name: {self.name} |'
Expand Down

0 comments on commit e49dc0e

Please sign in to comment.