Skip to content

Commit

Permalink
fix(model): Expose ceiling plenums as part of model translation
Browse files Browse the repository at this point in the history
  • Loading branch information
chriswmackey committed Nov 19, 2024
1 parent 8f92898 commit d012823
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 21 deletions.
44 changes: 29 additions & 15 deletions dragonfly_display/cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ def display():
'multipliers on each Building story should be passed along to the '
'generated Honeybee Room objects or if full geometry objects should be '
'written for each story in the building.', default=True, show_default=True)
@click.option(
'--no-plenum/--plenum', ' /-p', help='Flag to indicate whether '
'ceiling/floor plenums should be auto-generated for the Rooms.',
default=True, show_default=True)
@click.option(
'--no-ceil-adjacency/--ceil-adjacency', ' /-a', help='Flag to indicate '
'whether adjacencies should be solved between interior stories when '
Expand Down Expand Up @@ -114,7 +118,7 @@ def display():
'file contents. By default, it will be printed out to stdout.',
type=click.File('w'), default='-', show_default=True)
def model_to_vis_set_cli(
model_file, multiplier, no_ceil_adjacency,
model_file, multiplier, no_plenum, no_ceil_adjacency,
color_by, wireframe, mesh, show_color_by,
room_attr, face_attr, color_attr, grid_display_mode, show_grid,
output_format, output_file):
Expand All @@ -130,6 +134,7 @@ def model_to_vis_set_cli(
try:
# process all of the CLI input so that it can be passed to the function
full_geometry = not multiplier
add_plenum = not no_plenum
ceil_adjacency = not no_ceil_adjacency
exclude_wireframe = not wireframe
faces = not mesh
Expand All @@ -140,7 +145,7 @@ def model_to_vis_set_cli(
hide_grid = not show_grid

# pass the input to the function in order to convert the model
model_to_vis_set(model_file, full_geometry, ceil_adjacency, color_by,
model_to_vis_set(model_file, full_geometry, add_plenum, ceil_adjacency, color_by,
exclude_wireframe, faces, hide_color_by,
room_attrs, face_attrs, text_labels, grid_display_mode,
hide_grid, output_format, output_file)
Expand All @@ -152,11 +157,11 @@ def model_to_vis_set_cli(


def model_to_vis_set(
model_file, full_geometry=False, ceil_adjacency=False, color_by='type',
exclude_wireframe=False, faces=False, hide_color_by=False,
model_file, full_geometry=False, plenum=False, ceil_adjacency=False,
color_by='type', exclude_wireframe=False, faces=False, hide_color_by=False,
room_attr=(), face_attr=(), text_attr=False, grid_display_mode='Default',
hide_grid=False, output_format='vsf', output_file=None,
multiplier=True, no_ceil_adjacency=True, wireframe=True, mesh=True,
multiplier=True, no_plenum=True, no_ceil_adjacency=True, wireframe=True, mesh=True,
show_color_by=True, color_attr=True, show_grid=True
):
"""Translate a Dragonfly Model file (.dfjson) to a VisualizationSet file (.vsf).
Expand All @@ -169,6 +174,8 @@ def model_to_vis_set(
full_geometry: Boolean to note if the multipliers on each Story should
be passed along to the generated Honeybee Room objects or if full
geometry objects should be written for each story in the building.
plenum: Boolean to indicate whether ceiling/floor plenums should
be auto-generated for the Rooms. (Default: False).
ceil_adjacency: Boolean to indicate whether adjacencies should be solved
between interior stories when Room2D floor and ceiling geometries
are coplanar. This ensures that Surface boundary conditions are used
Expand Down Expand Up @@ -252,10 +259,10 @@ def model_to_vis_set(
# create the VisualizationSet
multiplier = not full_geometry
vis_set = model_obj.to_vis_set(
multiplier, ceil_adjacency, color_by=color_by, include_wireframe=wireframe,
use_mesh=mesh, hide_color_by=hide_color_by, room_attrs=room_attributes,
face_attrs=face_attributes, grid_display_mode=grid_display_mode,
hide_grid=hide_grid)
multiplier, plenum, ceil_adjacency, color_by=color_by,
include_wireframe=wireframe, use_mesh=mesh, hide_color_by=hide_color_by,
room_attrs=room_attributes, face_attrs=face_attributes,
grid_display_mode=grid_display_mode, hide_grid=hide_grid)

# output the VisualizationSet through the CLI
return _output_vis_set_to_format(vis_set, output_format, output_file)
Expand All @@ -271,6 +278,10 @@ def model_to_vis_set(
'multipliers on each Building story should be passed along to the '
'generated Honeybee Room objects or if full geometry objects should be '
'written for each story in the building.', default=True, show_default=True)
@click.option(
'--no-plenum/--plenum', ' /-p', help='Flag to indicate whether '
'ceiling/floor plenums should be auto-generated for the Rooms.',
default=True, show_default=True)
@click.option(
'--no-ceil-adjacency/--ceil-adjacency', ' /-a', help='Flag to indicate '
'whether adjacencies should be solved between interior stories when '
Expand All @@ -297,7 +308,7 @@ def model_to_vis_set(
'file contents. By default, it will be printed out to stdout',
type=click.File('w'), default='-', show_default=True)
def model_comparison_to_vis_set_cli(
base_model_file, incoming_model_file, multiplier, no_ceil_adjacency,
base_model_file, incoming_model_file, multiplier, no_plenum, no_ceil_adjacency,
base_color, incoming_color, output_format, output_file):
"""Translate two Dragonfly Models to be compared to a VisualizationSet.
Expand All @@ -316,12 +327,13 @@ def model_comparison_to_vis_set_cli(
try:
# process all of the CLI input so that it can be passed to the function
full_geometry = not multiplier
add_plenum = not no_plenum
ceil_adjacency = not no_ceil_adjacency

# pass the input to the function in order to convert the model
model_comparison_to_vis_set(
base_model_file, incoming_model_file, full_geometry, ceil_adjacency,
base_color, incoming_color, output_format, output_file)
base_model_file, incoming_model_file, full_geometry, add_plenum,
ceil_adjacency, base_color, incoming_color, output_format, output_file)
except Exception as e:
_logger.exception('Failed to translate Model to VisualizationSet.\n{}'.format(e))
sys.exit(1)
Expand All @@ -330,8 +342,8 @@ def model_comparison_to_vis_set_cli(


def model_comparison_to_vis_set(
base_model_file, incoming_model_file, full_geometry=False, ceil_adjacency=False,
base_color='#74eded', incoming_color='#ed7474',
base_model_file, incoming_model_file, full_geometry=False, plenum=False,
ceil_adjacency=False, base_color='#74eded', incoming_color='#ed7474',
output_format='vsf', output_file=None,
):
"""Translate two Honeybee Models to be compared to a VisualizationSet.
Expand All @@ -349,6 +361,8 @@ def model_comparison_to_vis_set(
full_geometry: Boolean to note if the multipliers on each Story should
be passed along to the generated Honeybee Room objects or if full
geometry objects should be written for each story in the building.
plenum: Boolean to indicate whether ceiling/floor plenums should
be auto-generated for the Rooms. (Default: False).
ceil_adjacency: Boolean to indicate whether adjacencies should be solved
between interior stories when Room2D floor and ceiling geometries
are coplanar. This ensures that Surface boundary conditions are used
Expand Down Expand Up @@ -380,7 +394,7 @@ def model_comparison_to_vis_set(
# create the VisualizationSet
multiplier = not full_geometry
vis_set = base_model.to_vis_set_comparison(
incoming_model, multiplier, ceil_adjacency, base_color, incoming_color)
incoming_model, multiplier, plenum, ceil_adjacency, base_color, incoming_color)

# output the VisualizationSet through the CLI
return _output_vis_set_to_format(vis_set, output_format, output_file)
Expand Down
16 changes: 10 additions & 6 deletions dragonfly_display/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@


def model_to_vis_set(
model, use_multiplier=True, solve_ceiling_adjacencies=False,
model, use_multiplier=True, add_plenum=False, solve_ceiling_adjacencies=False,
color_by='type', include_wireframe=True, use_mesh=True,
hide_color_by=False, room_attrs=None, face_attrs=None,
grid_display_mode='Default', hide_grid=False):
Expand All @@ -19,6 +19,8 @@ def model_to_vis_set(
will be multiplied. If False, full geometry objects will be written
for each and every floor in the building that are represented through
multipliers and all resulting multipliers will be 1. (Default: True).
add_plenum: Boolean to indicate whether ceiling/floor plenums should
be auto-generated for the Rooms. (Default: False).
solve_ceiling_adjacencies: Boolean to note whether adjacencies should be
solved between interior stories when Room2D floor and ceiling
geometries are coplanar. This ensures that Surface boundary
Expand Down Expand Up @@ -71,7 +73,7 @@ def model_to_vis_set(
"""
# create the Honeybee Model from the Dragonfly one
hb_model = model.to_honeybee(
'District', use_multiplier=use_multiplier,
'District', use_multiplier=use_multiplier, add_plenum=add_plenum,
solve_ceiling_adjacencies=solve_ceiling_adjacencies,
enforce_adj=False, enforce_solid=True)[0]
# convert the Honeybee Model to a VisualizationSet
Expand All @@ -81,8 +83,8 @@ def model_to_vis_set(


def model_comparison_to_vis_set(
base_model, incoming_model, use_multiplier=True, solve_ceiling_adjacencies=False,
base_color=None, incoming_color=None):
base_model, incoming_model, use_multiplier=True, add_plenum=False,
solve_ceiling_adjacencies=False, base_color=None, incoming_color=None):
"""Translate two Dragonfly Models to be compared to a VisualizationSet.
Args:
Expand All @@ -97,6 +99,8 @@ def model_comparison_to_vis_set(
will be multiplied. If False, full geometry objects will be written
for each and every floor in the building that are represented through
multipliers and all resulting multipliers will be 1. (Default: True).
add_plenum: Boolean to indicate whether ceiling/floor plenums should
be auto-generated for the Rooms. (Default: False).
solve_ceiling_adjacencies: Boolean to note whether adjacencies should be
solved between interior stories when Room2D floor and ceiling
geometries are coplanar. This ensures that Surface boundary
Expand All @@ -109,11 +113,11 @@ def model_comparison_to_vis_set(
"""
# create the Honeybee Models from the Dragonfly ones
base_model = base_model.to_honeybee(
'District', use_multiplier=use_multiplier,
'District', use_multiplier=use_multiplier, add_plenum=add_plenum,
solve_ceiling_adjacencies=solve_ceiling_adjacencies,
enforce_adj=False, enforce_solid=True)[0]
incoming_model = incoming_model.to_honeybee(
'District', use_multiplier=use_multiplier,
'District', use_multiplier=use_multiplier, add_plenum=add_plenum,
solve_ceiling_adjacencies=solve_ceiling_adjacencies,
enforce_adj=False, enforce_solid=True)[0]
# convert the Honeybee Model to a VisualizationSet
Expand Down

0 comments on commit d012823

Please sign in to comment.