Skip to content

Commit

Permalink
Feat/glb to usd (#449)
Browse files Browse the repository at this point in the history
  • Loading branch information
randallfrank authored Oct 10, 2024
1 parent e407cbd commit 054d9f8
Show file tree
Hide file tree
Showing 6 changed files with 489 additions and 178 deletions.
22 changes: 11 additions & 11 deletions doc/.vale.ini
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,22 @@ IgnoredScopes = code, tt
# By default, `script`, `style`, `pre`, and `figure` are ignored.
SkippedScopes = script, style, pre, figure

[*.rst]
BlockIgnores = (?s) *({:func:` [^`]*}), \
(?s) *({:samp:` [^`]*}),

# WordTemplate specifies what Vale will consider to be an individual word.
WordTemplate = \b(?:%s)\b

# List of Packages to be used for our guidelines
Packages = Google

# Define the Ansys vocabulary
Vocab = ANSYS
Vale.Terms = NO

[*.{md,rst}]

# Apply the following styles
BasedOnStyles = Vale, Google
Vale.Terms = NO
Vale.Terms = NO

# WordTemplate specifies what Vale will consider to be an individual word.
WordTemplate = \b(?:%s)\b

Google.Colons = NO
Google.Spacing = NO
Google.Ellipses = NO
Google.Will = NO
Google.Quotes = NO
Google.WordList = NO
2 changes: 1 addition & 1 deletion doc/source/user_guide/omniverse_info.rst
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ Developers: Running via the Command Line
There is an omniverse_cli module included in the pyensight install.
This module can be used to execute any service operation from the
command line. The Python included in the EnSight distribution
includes this module as well. Assuming the pyensight repo has been
includes this module as well. Assuming the pyensight repository has been
cloned to: ``D:\repos\pyensight`` the following can be run in a
Python virtual environment that was used to build the module and
has it installed:
Expand Down
3 changes: 3 additions & 0 deletions doc/styles/config/vocabularies/ANSYS/accept.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ autogenerated
casemapped
circumsphere
cmdlang
colorby_rgb
compi
compj
Compute_Per_case
Expand Down Expand Up @@ -70,6 +71,7 @@ num_points
NumPy
numpy
Oddy
Omniverse
Q_criteria
partlist
peakness
Expand All @@ -79,6 +81,7 @@ Pitot
pitot
plist
Protobuf
pyensight
PyPI
Python
Radiograph_grid
Expand Down
17 changes: 12 additions & 5 deletions src/ansys/pyensight/core/utils/dsg_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -741,6 +741,13 @@ def _get_next_message(self, wait: bool = True) -> Any:
except queue.Empty:
return None

def _reset(self):
self._variables = {}
self._groups = {}
self._part = Part(self)
self._scene_bounds = None
self._mesh_block_count = 0 # reset when a new group shows up

def handle_one_update(self) -> None:
"""Monitor the DSG stream and handle a single update operation
Expand All @@ -759,11 +766,7 @@ def handle_one_update(self) -> None:
cmd = self._get_next_message()

# Start anew
self._variables = {}
self._groups = {}
self._part = Part(self)
self._scene_bounds = None
self._mesh_block_count = 0 # reset when a new group shows up
self._reset()
self._callback_handler.begin_update()

# Update our status
Expand Down Expand Up @@ -839,7 +842,11 @@ def _finish_part(self) -> None:
try:
self._callback_handler.finalize_part(self.part)
except Exception as e:
import traceback

self.warn(f"Error encountered while finalizing part geometry: {str(e)}")
traceback_str = "".join(traceback.format_tb(e.__traceback__))
logging.debug(f"Traceback: {traceback_str}")
self._mesh_block_count += 1

def _handle_part(self, part_cmd: Any) -> None:
Expand Down
44 changes: 25 additions & 19 deletions src/ansys/pyensight/core/utils/omniverse_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,15 +276,14 @@ def run_monitor(self):
update_handler = ov_dsg_server.OmniverseUpdateHandler(omni_link)

# Link it to the GLB file monitoring service
glb_link = ov_glb_server.GLBSession(
verbose=1,
handler=update_handler,
)
glb_link = ov_glb_server.GLBSession(verbose=1, handler=update_handler, vrmode=self.vrmode)
if single_file_upload:
start_time = time.time()
logging.info(f"Uploading file: {the_dir}.")
try:
glb_link.start_uploads([0.0, 0.0])
glb_link.upload_file(the_dir)
glb_link.end_uploads()
except Exception as error:
logging.warning(f"Error uploading file: {the_dir}: {error}")
logging.info(f"Uploaded in {(time.time() - start_time):.2f}")
Expand Down Expand Up @@ -326,28 +325,35 @@ def run_monitor(self):
files_to_remove.extend(the_files)
# Times not used for now, but parse them anyway
the_times = glb_info.get("times", [0.0] * len(the_files))
file_timestamps.extend(the_times)
# Validate a few things
if len(the_files) != len(the_times):
logging.warning(
f"Number of times and files are not the same in: {filename}"
)
continue
if len(set(the_times)) != 1:
logging.warning("Time values not currently supported.")
if len(the_files) > 1:
logging.warning("Multiple glb files not currently fully supported.")
files_to_process.extend(the_files)
# Upload the files
for glb_file in files_to_process:
start_time = time.time()
logging.info(
f"Uploading file: {glb_file} to {omni_link.destination}."
)
try:
glb_link.upload_file(glb_file)
except Exception as error:
logging.warning(f"Error uploading file: {glb_file}: {error}")
logging.info(f"Uploaded in {(time.time() - start_time):%.2f}")
# manage time
timeline = sorted(set(file_timestamps))
if len(timeline) != 1:
logging.warning("Time values not currently supported.")
if len(files_to_process) > 1:
logging.warning("Multiple glb files not currently fully supported.")
# Upload the files
glb_link.start_uploads([timeline[0], timeline[-1]])
for glb_file, timestamp in zip(files_to_process, file_timestamps):
start_time = time.time()
logging.info(f"Uploading file: {glb_file} to {omni_link.destination}.")
try:
time_idx = timeline.index(timestamp) + 1
if time_idx == len(timeline):
time_idx -= 1
limits = [timestamp, timeline[time_idx]]
glb_link.upload_file(glb_file, timeline=limits)
except Exception as error:
logging.warning(f"Error uploading file: {glb_file}: {error}")
logging.info(f"Uploaded in {(time.time() - start_time):%.2f}")
glb_link.end_uploads()
for filename in files_to_remove:
try:
# Only delete the file if it is in the_dir_path
Expand Down
Loading

0 comments on commit 054d9f8

Please sign in to comment.