Coverage for mpcforces_extractor\cli\visualize.py: 0%
19 statements
« prev ^ index » next coverage.py v7.6.4, created at 2024-11-06 21:34 +0100
« prev ^ index » next coverage.py v7.6.4, created at 2024-11-06 21:34 +0100
1import os
2import time
3from pathlib import Path
4import typer
5from mpcforces_extractor.visualization.tcl_visualize import VisualizerConnectedParts
6from mpcforces_extractor.reader.modelreaders import FemFileReader
8visualize_cmd = typer.Typer(name="visualize", invoke_without_command=True)
11@visualize_cmd.callback()
12def visualize(
13 input_path_fem: str = typer.Argument(..., help="Path to the .fem file (model)"),
14 output_path: str = typer.Argument(..., help="Path to the output folder"),
15 blocksize: int = typer.Option(8, help="Blocksize for the MPC forces"),
16):
17 """
18 Visualizes the connected parts of the model by moving them into separate components
19 """
21 # Check if the files exist, if not raise an error
22 if not Path(input_path_fem).exists():
23 raise FileNotFoundError(f"File {input_path_fem} not found")
25 # Visualize the connected parts
26 start_time = time.time()
27 output_vis = os.path.join(output_path, "tcl_visualization")
29 # Read the fem file
30 reader = FemFileReader(input_path_fem, blocksize)
31 reader.create_entities()
33 # Visualize
34 visualizer = VisualizerConnectedParts(output_vis)
35 visualizer.output_tcl_lines_for_part_vis()
37 print("TCL visualization lines written to", output_vis)
38 print("..took ", round(time.time() - start_time, 2), "seconds")