Skip to content

Commit

Permalink
#266: automatic sizing of edges
Browse files Browse the repository at this point in the history
  • Loading branch information
ppebay committed Jun 23, 2022
1 parent 42ffb39 commit ffe01e7
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/lbaf/IO/lbsMeshBasedVisualizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ def create_scalar_bar_actor(self, mapper, title, x, y):
# Return created scalar bar actor
return scalar_bar_actor

def create_rendering_pipeline(self, iteration: int, glyph_factor: float, object_mesh):
def create_rendering_pipeline(self, iteration: int, edge_width: int, glyph_factor: float, win_size: int, object_mesh):
""" Create VTK-based pipeline all the way to render window."""

# Create rank mesh for current phase
Expand Down Expand Up @@ -448,7 +448,7 @@ def create_rendering_pipeline(self, iteration: int, glyph_factor: float, object_
# Create communication volume and its scalar bar actors
edge_actor = vtk.vtkActor()
edge_actor.SetMapper(edge_mapper)
edge_actor.GetProperty().SetLineWidth(10)
edge_actor.GetProperty().SetLineWidth(edge_width)
edge_actor.GetProperty().SetOpacity(1.0)
volume_actor = self.create_scalar_bar_actor(
edge_mapper, "Inter-Object Volume", 0.05, 0.05)
Expand Down Expand Up @@ -524,7 +524,7 @@ def create_rendering_pipeline(self, iteration: int, glyph_factor: float, object_
render_window = vtk.vtkRenderWindow()
render_window.AddRenderer(renderer)
render_window.SetWindowName("LBAF")
render_window.SetSize(800, 800)
render_window.SetSize(win_size, win_size)
return render_window

def generate(self, gen_meshes, gen_mulmed):
Expand Down Expand Up @@ -585,15 +585,24 @@ def generate(self, gen_meshes, gen_mulmed):
"Visualization generation not yet implemented in 3-D")
continue

# Compute visualization parameters
self.__logger.info(
f"Generating 2-D visualization for iteration {iteration}:")
win_size = 800
self.__logger.info(
f"\tnumber of pixels: {win_size}x{win_size}")
edge_width = 0.1 * win_size / max(self.__grid_size)
self.__logger.info(
f"\tcommunication edges width: {edge_width:.2g}")
glyph_factor = self.__grid_resolution / (
(self.__max_o_per_dim + 1)
* math.sqrt(self.__time_range[1]))
self.__logger.info(
f"\tobject glyphs scaling: {glyph_factor:.2g}")

# Run visualization pipeline
render_window = self.create_rendering_pipeline(
iteration, glyph_factor, object_mesh)
iteration, edge_width, glyph_factor, win_size, object_mesh)
render_window.Render()

# Convert window to image
Expand Down

0 comments on commit ffe01e7

Please sign in to comment.