ansys-pyensight-core 0.10.9__tar.gz → 0.10.10__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of ansys-pyensight-core might be problematic. Click here for more details.

Files changed (37) hide show
  1. {ansys_pyensight_core-0.10.9 → ansys_pyensight_core-0.10.10}/PKG-INFO +1 -1
  2. {ansys_pyensight_core-0.10.9 → ansys_pyensight_core-0.10.10}/pyproject.toml +1 -1
  3. {ansys_pyensight_core-0.10.9 → ansys_pyensight_core-0.10.10}/src/ansys/pyensight/core/utils/views.py +108 -9
  4. {ansys_pyensight_core-0.10.9 → ansys_pyensight_core-0.10.10}/LICENSE +0 -0
  5. {ansys_pyensight_core-0.10.9 → ansys_pyensight_core-0.10.10}/README.rst +0 -0
  6. {ansys_pyensight_core-0.10.9 → ansys_pyensight_core-0.10.10}/src/ansys/pyensight/core/__init__.py +0 -0
  7. {ansys_pyensight_core-0.10.9 → ansys_pyensight_core-0.10.10}/src/ansys/pyensight/core/common.py +0 -0
  8. {ansys_pyensight_core-0.10.9 → ansys_pyensight_core-0.10.10}/src/ansys/pyensight/core/deep_pixel_view.html +0 -0
  9. {ansys_pyensight_core-0.10.9 → ansys_pyensight_core-0.10.10}/src/ansys/pyensight/core/dockerlauncher.py +0 -0
  10. {ansys_pyensight_core-0.10.9 → ansys_pyensight_core-0.10.10}/src/ansys/pyensight/core/dvs.py +0 -0
  11. {ansys_pyensight_core-0.10.9 → ansys_pyensight_core-0.10.10}/src/ansys/pyensight/core/enscontext.py +0 -0
  12. {ansys_pyensight_core-0.10.9 → ansys_pyensight_core-0.10.10}/src/ansys/pyensight/core/enshell_grpc.py +0 -0
  13. {ansys_pyensight_core-0.10.9 → ansys_pyensight_core-0.10.10}/src/ansys/pyensight/core/ensight_grpc.py +0 -0
  14. {ansys_pyensight_core-0.10.9 → ansys_pyensight_core-0.10.10}/src/ansys/pyensight/core/ensobj.py +0 -0
  15. {ansys_pyensight_core-0.10.9 → ansys_pyensight_core-0.10.10}/src/ansys/pyensight/core/launch_ensight.py +0 -0
  16. {ansys_pyensight_core-0.10.9 → ansys_pyensight_core-0.10.10}/src/ansys/pyensight/core/launcher.py +0 -0
  17. {ansys_pyensight_core-0.10.9 → ansys_pyensight_core-0.10.10}/src/ansys/pyensight/core/libuserd.py +0 -0
  18. {ansys_pyensight_core-0.10.9 → ansys_pyensight_core-0.10.10}/src/ansys/pyensight/core/listobj.py +0 -0
  19. {ansys_pyensight_core-0.10.9 → ansys_pyensight_core-0.10.10}/src/ansys/pyensight/core/locallauncher.py +0 -0
  20. {ansys_pyensight_core-0.10.9 → ansys_pyensight_core-0.10.10}/src/ansys/pyensight/core/py.typed +0 -0
  21. {ansys_pyensight_core-0.10.9 → ansys_pyensight_core-0.10.10}/src/ansys/pyensight/core/renderable.py +0 -0
  22. {ansys_pyensight_core-0.10.9 → ansys_pyensight_core-0.10.10}/src/ansys/pyensight/core/session.py +0 -0
  23. {ansys_pyensight_core-0.10.9 → ansys_pyensight_core-0.10.10}/src/ansys/pyensight/core/sgeo_poll.html +0 -0
  24. {ansys_pyensight_core-0.10.9 → ansys_pyensight_core-0.10.10}/src/ansys/pyensight/core/utils/__init__.py +0 -0
  25. {ansys_pyensight_core-0.10.9 → ansys_pyensight_core-0.10.10}/src/ansys/pyensight/core/utils/adr.py +0 -0
  26. {ansys_pyensight_core-0.10.9 → ansys_pyensight_core-0.10.10}/src/ansys/pyensight/core/utils/dsg_server.py +0 -0
  27. {ansys_pyensight_core-0.10.9 → ansys_pyensight_core-0.10.10}/src/ansys/pyensight/core/utils/export.py +0 -0
  28. {ansys_pyensight_core-0.10.9 → ansys_pyensight_core-0.10.10}/src/ansys/pyensight/core/utils/omniverse.py +0 -0
  29. {ansys_pyensight_core-0.10.9 → ansys_pyensight_core-0.10.10}/src/ansys/pyensight/core/utils/omniverse_cli.py +0 -0
  30. {ansys_pyensight_core-0.10.9 → ansys_pyensight_core-0.10.10}/src/ansys/pyensight/core/utils/omniverse_dsg_server.py +0 -0
  31. {ansys_pyensight_core-0.10.9 → ansys_pyensight_core-0.10.10}/src/ansys/pyensight/core/utils/omniverse_glb_server.py +0 -0
  32. {ansys_pyensight_core-0.10.9 → ansys_pyensight_core-0.10.10}/src/ansys/pyensight/core/utils/parts.py +0 -0
  33. {ansys_pyensight_core-0.10.9 → ansys_pyensight_core-0.10.10}/src/ansys/pyensight/core/utils/query.py +0 -0
  34. {ansys_pyensight_core-0.10.9 → ansys_pyensight_core-0.10.10}/src/ansys/pyensight/core/utils/readers.py +0 -0
  35. {ansys_pyensight_core-0.10.9 → ansys_pyensight_core-0.10.10}/src/ansys/pyensight/core/utils/resources/Materials/000_sky.exr +0 -0
  36. {ansys_pyensight_core-0.10.9 → ansys_pyensight_core-0.10.10}/src/ansys/pyensight/core/utils/support.py +0 -0
  37. {ansys_pyensight_core-0.10.9 → ansys_pyensight_core-0.10.10}/src/ansys/pyensight/core/utils/variables.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ansys-pyensight-core
3
- Version: 0.10.9
3
+ Version: 0.10.10
4
4
  Summary: A python wrapper for Ansys EnSight
5
5
  Author-email: "ANSYS, Inc." <pyansys.core@ansys.com>
6
6
  Maintainer-email: "ANSYS, Inc." <pyansys.core@ansys.com>
@@ -6,7 +6,7 @@ build-backend = "flit_core.buildapi"
6
6
 
7
7
  [project]
8
8
  name = "ansys-pyensight-core"
9
- version = "0.10.9"
9
+ version = "0.10.10"
10
10
  description = "A python wrapper for Ansys EnSight"
11
11
  readme = "README.rst"
12
12
  requires-python = ">=3.10,<3.14"
@@ -94,8 +94,7 @@ class _Simba:
94
94
  self.views.set_view_direction(
95
95
  1, 1, 1, perspective=self.ensight.objs.core.vports[0].PERSPECTIVE
96
96
  )
97
- self.auto_scale()
98
- return self.get_camera()
97
+ return self.auto_scale()
99
98
 
100
99
  def get_camera(self):
101
100
  """Get EnSight camera settings in VTK format."""
@@ -208,8 +207,49 @@ class _Simba:
208
207
  parallel_scale = 1 / data[9]
209
208
  return camera_position, focal_point, self.views._normalize_vector(view_up), parallel_scale
210
209
 
210
+ def get_camera_axes(self):
211
+ """
212
+ Returns the camera's local axes: right, up, and forward vectors.
213
+ These are useful for applying transformations in view space.
214
+
215
+ Parameters:
216
+ camera (dict): A dictionary with keys 'position', 'focal_point', and 'view_up'.
217
+
218
+ Returns:
219
+ right (np.ndarray): Right vector (X axis in view space).
220
+ up (np.ndarray): Up vector (Y axis in view space).
221
+ forw ard (np.ndarray): Forward vector (Z axis in view space, pointing from position to focal point).
222
+ """
223
+ camera = self.get_camera()
224
+ position = np.array(camera["position"])
225
+ focal_point = np.array(camera["focal_point"])
226
+ view_up = np.array(camera["view_up"])
227
+
228
+ # Forward vector: from camera position to focal point
229
+ forward = focal_point - position
230
+ forward /= np.linalg.norm(forward)
231
+
232
+ # Right vector: cross product of forward and view_up
233
+ right = np.cross(forward, view_up)
234
+ right /= np.linalg.norm(right)
235
+
236
+ # Recompute up vector to ensure orthogonality
237
+ up = np.cross(right, forward)
238
+ up /= np.linalg.norm(up)
239
+
240
+ return right, up, forward
241
+
211
242
  def set_camera(
212
- self, orthographic, view_up=None, position=None, focal_point=None, view_angle=None, pan=None
243
+ self,
244
+ orthographic,
245
+ view_up=None,
246
+ position=None,
247
+ focal_point=None,
248
+ view_angle=None,
249
+ pan=None,
250
+ mousex=None,
251
+ mousey=None,
252
+ invert_y=False,
213
253
  ):
214
254
  """Set the EnSight camera settings from the VTK input."""
215
255
  self.ensight.view_transf.function("global")
@@ -219,7 +259,6 @@ class _Simba:
219
259
  vport = self.ensight.objs.core.VPORTS[0]
220
260
  if view_angle:
221
261
  vport.PERSPECTIVEANGLE = view_angle / 2
222
-
223
262
  if view_up and position and focal_point:
224
263
  if not pan:
225
264
  q_current = self.normalize(np.array(vport.ROTATION.copy()))
@@ -232,7 +271,17 @@ class _Simba:
232
271
  angles = self.quaternion_to_euler(q_relative)
233
272
  self.ensight.view_transf.rotate(*angles)
234
273
  else:
235
- self.ensight.view_transf.translate(*pan)
274
+ if mousex and mousey:
275
+ self.screen_to_world(
276
+ mousex=mousex, mousey=mousey, invert_y=invert_y, set_center=True
277
+ )
278
+ current_camera = self.get_camera()
279
+ right, up, _ = self.get_camera_axes()
280
+ translation_vector = np.array(position) - np.array(current_camera["position"])
281
+ dx = np.dot(translation_vector, right)
282
+ dy = np.dot(translation_vector, up)
283
+ self.ensight.view_transf.translate(-dx, -dy, 0)
284
+
236
285
  self.render()
237
286
 
238
287
  def set_perspective(self, value):
@@ -265,7 +314,37 @@ class _Simba:
265
314
  self.ensight.render()
266
315
  self.ensight.refresh(1)
267
316
 
268
- def drag_allowed(self, mousex, mousey, invert_y=False):
317
+ def _probe_setup(self, part_obj, get_probe_data=False):
318
+ self.ensight.query_interact.number_displayed(100)
319
+ self.ensight.query_interact.query("surface")
320
+ self.ensight.query_interact.display_id("OFF")
321
+ self.ensight.query_interact.label_always_on_top("ON")
322
+ self.ensight.query_interact.marker_size_normalized(2)
323
+ if get_probe_data:
324
+ variable_string = """Coordinates 'X' 'Y' 'Z'"""
325
+ variable_list = [variable_string]
326
+ variable_name = part_obj.COLORBYPALETTE
327
+ if variable_name:
328
+ if isinstance(variable_name, str):
329
+ variable_list.append(variable_name)
330
+ else:
331
+ if isinstance(variable_name, list):
332
+ if variable_name[0]:
333
+ variable_name = variable_name[0].DESCRIPTION
334
+ variable_list.append(variable_name)
335
+ else:
336
+ variable_name = None
337
+ if isinstance(self.ensight, ModuleType):
338
+ self.ensight.query_interact.select_varname_begin(*variable_list)
339
+ else:
340
+ command = "ensight.query_interact.select_varname_begin("
341
+ for var in variable_list:
342
+ command += var + ","
343
+ command = command[:-1] + ")"
344
+ self.ensight._session.cmd(command)
345
+ self.render()
346
+
347
+ def drag_allowed(self, mousex, mousey, invert_y=False, probe=False, get_probe_data=False):
269
348
  """Return True if the picked object is allowed dragging in the interactor."""
270
349
  mousex = int(mousex)
271
350
  mousey = int(mousey)
@@ -277,8 +356,14 @@ class _Simba:
277
356
  part_id, tool_id = self.ensight._session.cmd(
278
357
  f"ensight.objs.core.VPORTS[0].simba_what_is_picked({mousex}, {mousey}, {invert_y})"
279
358
  )
359
+ coords = [None, None, None]
360
+ if probe:
361
+ screen_to_world = self.screen_to_world(
362
+ mousex=mousex, mousey=mousey, invert_y=invert_y, set_center=False
363
+ )
364
+ coords = screen_to_world["model_point"]
280
365
  if tool_id > -1:
281
- return True
366
+ return True, coords[0], coords[1], coords[2], False
282
367
  part_types_allowed = [
283
368
  self.ensight.objs.enums.PART_CLIP_PLANE,
284
369
  self.ensight.objs.enums.PART_ISO_SURFACE,
@@ -286,8 +371,22 @@ class _Simba:
286
371
  ]
287
372
  if part_id > -1:
288
373
  part_obj = self.ensight.objs.core.PARTS.find(part_id, "PARTNUMBER")[0]
289
- return part_obj.PARTTYPE in part_types_allowed
290
- return False
374
+ if probe:
375
+ width, height = tuple(self.ensight.objs.core.WINDOWSIZE)
376
+ if invert_y:
377
+ mousey = height - mousey
378
+ self.ensight.query_interact.number_displayed(100)
379
+ self.ensight.query_interact.query("surface")
380
+ self.ensight.query_interact.display_id("OFF")
381
+ self.ensight.query_interact.create(mousex / width, mousey / height)
382
+ self._probe_setup(part_obj, get_probe_data=get_probe_data)
383
+ return part_obj.PARTTYPE in part_types_allowed, coords[0], coords[1], coords[2], True
384
+ if (
385
+ get_probe_data and self.ensight.objs.core.PROBES[0].PROBE_DATA
386
+ ): # In case we have picked a probe point
387
+ for part in self.ensight.objs.core.PARTS:
388
+ self._probe_setup(part, get_probe_data=get_probe_data)
389
+ return False, coords[0], coords[1], coords[2], False
291
390
 
292
391
 
293
392
  class Views: