ansys-pyensight-core 0.10.9__py3-none-any.whl → 0.10.10__py3-none-any.whl
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.
- ansys/pyensight/core/utils/views.py +108 -9
- {ansys_pyensight_core-0.10.9.dist-info → ansys_pyensight_core-0.10.10.dist-info}/METADATA +1 -1
- {ansys_pyensight_core-0.10.9.dist-info → ansys_pyensight_core-0.10.10.dist-info}/RECORD +5 -5
- {ansys_pyensight_core-0.10.9.dist-info → ansys_pyensight_core-0.10.10.dist-info}/WHEEL +0 -0
- {ansys_pyensight_core-0.10.9.dist-info → ansys_pyensight_core-0.10.10.dist-info}/licenses/LICENSE +0 -0
|
@@ -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,
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
290
|
-
|
|
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:
|
|
@@ -29,9 +29,9 @@ ansys/pyensight/core/utils/query.py,sha256=OXKDbf1sOTX0sUvtKcp64LhVl-BcrEsE43w8u
|
|
|
29
29
|
ansys/pyensight/core/utils/readers.py,sha256=_IluAWz8mmoe5SM3hAewHIqlhtKMfEqrUJoQOlJ4U4I,12138
|
|
30
30
|
ansys/pyensight/core/utils/support.py,sha256=QI3z9ex7zJxjFbkCPba9DWqWgPFIThORqr0nvRfVjuc,4089
|
|
31
31
|
ansys/pyensight/core/utils/variables.py,sha256=ZUiJdDIeRcowrnLXaJQqGwA0RbrfXhc1s4o4v9A4PiY,95133
|
|
32
|
-
ansys/pyensight/core/utils/views.py,sha256=
|
|
32
|
+
ansys/pyensight/core/utils/views.py,sha256=16HhsxhrwjH_vRtyN96S5rItCfb8ACdVIQkBuEGgPh8,27273
|
|
33
33
|
ansys/pyensight/core/utils/resources/Materials/000_sky.exr,sha256=xAR1gFd2uxPZDnvgfegdhEhRaqKtZldQDiR_-1rHKO0,8819933
|
|
34
|
-
ansys_pyensight_core-0.10.
|
|
35
|
-
ansys_pyensight_core-0.10.
|
|
36
|
-
ansys_pyensight_core-0.10.
|
|
37
|
-
ansys_pyensight_core-0.10.
|
|
34
|
+
ansys_pyensight_core-0.10.10.dist-info/licenses/LICENSE,sha256=K6LiJHOa9IbWFelXmXNRzFr3zG45SOGZIN7vdLdURGU,1097
|
|
35
|
+
ansys_pyensight_core-0.10.10.dist-info/WHEEL,sha256=G2gURzTEtmeR8nrdXUJfNiB3VYVxigPQ-bEQujpNiNs,82
|
|
36
|
+
ansys_pyensight_core-0.10.10.dist-info/METADATA,sha256=j2qVkHFkgjFLJbBjOz82BXIEuaVmP-lB_UQC8T5bhxQ,12229
|
|
37
|
+
ansys_pyensight_core-0.10.10.dist-info/RECORD,,
|
|
File without changes
|
{ansys_pyensight_core-0.10.9.dist-info → ansys_pyensight_core-0.10.10.dist-info}/licenses/LICENSE
RENAMED
|
File without changes
|