-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(visualization): Adding components to colored meshes and legends
- Loading branch information
1 parent
0946d6a
commit f835aeb
Showing
14 changed files
with
196 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
# Ladybug: A Plugin for Environmental Analysis (GPL) started by Mostapha Sadeghipour Roudsari | ||
# This file is part of Ladybug. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with Ladybug; If not, see <http://www.gnu.org/licenses/>. | ||
# | ||
# @license GPL-3.0+ <http://spdx.org/licenses/GPL-3.0+> | ||
|
||
|
||
""" | ||
Use this component to generate colors based on values and legend parameters. | ||
- | ||
Args: | ||
_values: A list of numerical values with which to color the mesh. | ||
The number of values must match the number of faces or vertices | ||
in the mesh. | ||
_mesh: A Mesh object, with a number of faces or vertices that match | ||
the number of input values and will be colored with restults. | ||
legend_par_: Optional legend parameters from the Ladybug | ||
'Legend Parameters' component. | ||
legend_title_: A text string for Legend title. Typically, the units | ||
of the data are used here but the type of data might also be used. | ||
Default is an empty string. | ||
global_title_: A text string to label the entire mesh. It will be | ||
displayed in the lower left of the result mesh. Default is for no | ||
title. | ||
Returns: | ||
mesh: The input _mesh that has been colored with results. | ||
legend: Geometry representing the legend for the mesh. | ||
title: A text object for the global_title. | ||
colors: The colors associated with each input value. | ||
legend_par: The input legend parameters with defaults filled for | ||
unset properties. | ||
""" | ||
|
||
ghenv.Component.Name = "LadybugPlus_Color Mesh" | ||
ghenv.Component.NickName = 'colorMesh' | ||
ghenv.Component.Message = 'VER 0.0.04\nMAY_31_2019' | ||
ghenv.Component.Category = "LadybugPlus" | ||
ghenv.Component.SubCategory = "03 :: Extra" | ||
ghenv.Component.AdditionalHelpFromDocStrings = "1" | ||
|
||
try: | ||
from ladybug.resultmesh import ResultMesh | ||
from ladybug_rhino.togeometry import to_mesh3d | ||
from ladybug_rhino.fromgeometry import from_mesh3d | ||
from ladybug_rhino.fromobjects import legend_objects | ||
from ladybug_rhino.text import text_objects | ||
from ladybug_dotnet.color import color_to_color | ||
except ImportError as e: | ||
raise ImportError('\nFailed to import ladybug:\n\t{}'.format(e)) | ||
|
||
if len(_values) != 0 and _values[0] is not None and _mesh: | ||
# generate Ladybug objects | ||
res_mesh = ResultMesh(_values, to_mesh3d(_mesh), legend_par_) | ||
|
||
# generate titles | ||
if legend_title_ is not None: | ||
res_mesh.legend_parameters.title = legend_title_ | ||
if global_title_ is not None: | ||
title = text_objects(global_title_, res_mesh.lower_title_location, | ||
res_mesh.legend_parameters.text_height, | ||
res_mesh.legend_parameters.font) | ||
|
||
# draw rhino objects | ||
lb_mesh = res_mesh.colored_mesh | ||
mesh = from_mesh3d(lb_mesh) | ||
legend = legend_objects(res_mesh.legend) | ||
colors = [color_to_color(col) for col in lb_mesh.colors] | ||
legend_par = res_mesh.legend_parameters |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# Ladybug: A Plugin for Environmental Analysis (GPL) started by Mostapha Sadeghipour Roudsari | ||
# This file is part of Ladybug. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with Ladybug; If not, see <http://www.gnu.org/licenses/>. | ||
# | ||
# @license GPL-3.0+ <http://spdx.org/licenses/GPL-3.0+> | ||
|
||
|
||
""" | ||
Genrate a mesh with corresponding test points. | ||
The resulting mesh will be in a format that the 'Color Mesh' component will accept. | ||
- | ||
Args: | ||
_geometry: Brep or Mesh from which to generate the points and grid. | ||
_grid_size: Number for the size of the test grid. | ||
_dist_surface_: Number for the distance to move points from the surfaces | ||
of the input _geometry. Typically, this should be a small positive | ||
number to ensure points are not blocked by the mesh. Default is 0. | ||
Returns: | ||
points: Test points at the center of each mesh face. | ||
vectors: Vectors for the normal direction at each of the points. | ||
face_areas: Area of each mesh face. | ||
mesh: Analysis mesh that can be passed to the 'Color Mesh' component. | ||
""" | ||
|
||
ghenv.Component.Name = "Ladybug_Generate Point Grid" | ||
ghenv.Component.NickName = 'genPts' | ||
ghenv.Component.Message = 'VER 0.0.04\nMAY_31_2019' | ||
ghenv.Component.Category = "LadybugPlus" | ||
ghenv.Component.SubCategory = "03 :: Extra" | ||
ghenv.Component.AdditionalHelpFromDocStrings = "1" | ||
|
||
try: | ||
from ladybug_rhino.togeometry import to_gridded_mesh3d | ||
from ladybug_rhino.fromgeometry import from_mesh3d | ||
from ladybug_rhino.fromgeometry import from_point3d, from_vector3d | ||
except ImportError as e: | ||
raise ImportError('\nFailed to import ladybug:\n\t{}'.format(e)) | ||
|
||
import Rhino.Geometry as rg | ||
|
||
|
||
if _geometry and _grid_size is not None: | ||
# check the input and generate the mesh. | ||
_dist_surface_ = _dist_surface_ or 0 | ||
if type(_geometry) == rg.Brep: | ||
lb_mesh = to_gridded_mesh3d(_geometry, _grid_size, _dist_surface_) | ||
elif type(_geometry) == rg.Mesh: | ||
lb_mesh = to_mesh3d(_geometry) | ||
else: | ||
raise TypeError( | ||
'_geometry must be a Brep or a Mesh. Got {}.'.format(type(_geometry))) | ||
|
||
# generate the test points, vectors, and areas. | ||
points = [from_point3d(pt) for pt in lb_mesh.face_centroids] | ||
vectors = [from_vector3d(vec) for vec in lb_mesh.face_normals] | ||
face_areas = lb_mesh.face_areas | ||
mesh = from_mesh3d(lb_mesh) |
Binary file not shown.
Binary file modified
BIN
+48 Bytes
(100%)
plugin/grasshopper/userObjects/LadybugPlus_Color Range.ghuser
Binary file not shown.
Binary file modified
BIN
+24 Bytes
(100%)
plugin/grasshopper/userObjects/LadybugPlus_Download Weather.ghuser
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified
BIN
+1.51 KB
(130%)
plugin/grasshopper/userObjects/LadybugPlus_Legend Parameters.ghuser
Binary file not shown.
Binary file not shown.