ansys-pyensight-core 0.9.0__py3-none-any.whl → 0.9.2__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.

@@ -132,40 +132,41 @@ class GLBSession(dsg_server.DSGSession):
132
132
  """
133
133
  mesh = self._gltf.meshes[meshid]
134
134
  for prim_idx, prim in enumerate(mesh.primitives):
135
- # POINTS, LINES, LINE_LOOP, LINE_STRIP, TRIANGLES, TRIANGLE_STRIP, TRIANGLE_FAN
135
+ # POINTS, LINES, TRIANGLES, LINE_LOOP, LINE_STRIP, TRIANGLE_STRIP, TRIANGLE_FAN
136
136
  mode = prim.mode
137
- if mode not in (pygltflib.TRIANGLES, pygltflib.LINES, pygltflib.POINTS):
138
- self.warn(
139
- f"Unhandled connectivity {mode}. Currently only TRIANGLE and LINE connectivity is supported."
140
- )
137
+ if mode not in (
138
+ pygltflib.TRIANGLES,
139
+ pygltflib.LINES,
140
+ pygltflib.POINTS,
141
+ pygltflib.LINE_LOOP,
142
+ pygltflib.LINE_STRIP,
143
+ pygltflib.TRIANGLE_STRIP,
144
+ pygltflib.TRIANGLE_FAN,
145
+ ):
146
+ self.warn(f"Unhandled connectivity detected: {mode}. Geometry skipped.")
141
147
  continue
142
148
  glb_materialid = prim.material
149
+ line_width = self._callback_handler._omni.line_width
143
150
 
144
151
  # GLB Prim -> DSG Part
145
152
  part_name = f"{parentname}_prim{prim_idx}_"
146
153
  cmd, part_pb = self._create_pb("PART", parent_id=parentid, name=part_name)
147
- part_pb.render = dynamic_scene_graph_pb2.UpdatePart.RenderingMode.CONNECTIVITY
154
+ if mode == pygltflib.POINTS:
155
+ part_pb.render = dynamic_scene_graph_pb2.UpdatePart.RenderingMode.NODES
156
+ part_pb.node_size_default = line_width
157
+ else:
158
+ part_pb.render = dynamic_scene_graph_pb2.UpdatePart.RenderingMode.CONNECTIVITY
148
159
  part_pb.shading = dynamic_scene_graph_pb2.UpdatePart.ShadingMode.NODAL
149
160
  self._map_material(glb_materialid, part_pb)
150
161
  part_dsg_id = part_pb.id
151
162
  self._handle_update_command(cmd)
152
163
 
153
164
  # GLB Attributes -> DSG Geom
154
- conn = self._get_data(prim.indices, 0)
155
- cmd, conn_pb = self._create_pb("GEOM", parent_id=part_dsg_id)
156
- if mode == pygltflib.TRIANGLES:
157
- conn_pb.payload_type = dynamic_scene_graph_pb2.UpdateGeom.ArrayType.TRIANGLES
158
- elif mode == pygltflib.LINES:
159
- conn_pb.payload_type = dynamic_scene_graph_pb2.UpdateGeom.ArrayType.LINES
160
- else:
161
- conn_pb.payload_type = dynamic_scene_graph_pb2.UpdateGeom.ArrayType.POINTS
162
- conn_pb.int_array.extend(conn)
163
- conn_pb.chunk_offset = 0
164
- conn_pb.total_array_size = len(conn)
165
- self._handle_update_command(cmd)
166
-
165
+ # Verts
166
+ num_verts = 0
167
167
  if prim.attributes.POSITION is not None:
168
168
  verts = self._get_data(prim.attributes.POSITION)
169
+ num_verts = len(verts) // 3
169
170
  cmd, verts_pb = self._create_pb("GEOM", parent_id=part_dsg_id)
170
171
  verts_pb.payload_type = dynamic_scene_graph_pb2.UpdateGeom.ArrayType.COORDINATES
171
172
  verts_pb.flt_array.extend(verts)
@@ -173,6 +174,35 @@ class GLBSession(dsg_server.DSGSession):
173
174
  verts_pb.total_array_size = len(verts)
174
175
  self._handle_update_command(cmd)
175
176
 
177
+ # Connectivity
178
+ if num_verts and (mode != pygltflib.POINTS):
179
+ if prim.indices is not None:
180
+ conn = self._get_data(prim.indices, 0)
181
+ else:
182
+ conn = numpy.array(list(range(num_verts)), dtype=numpy.uint32)
183
+ cmd, conn_pb = self._create_pb("GEOM", parent_id=part_dsg_id)
184
+ if mode == pygltflib.TRIANGLES:
185
+ conn_pb.payload_type = dynamic_scene_graph_pb2.UpdateGeom.ArrayType.TRIANGLES
186
+ elif mode == pygltflib.TRIANGLE_STRIP:
187
+ conn_pb.payload_type = dynamic_scene_graph_pb2.UpdateGeom.ArrayType.TRIANGLES
188
+ conn = self._tri_strip_to_tris(conn)
189
+ elif mode == pygltflib.TRIANGLE_FAN:
190
+ conn_pb.payload_type = dynamic_scene_graph_pb2.UpdateGeom.ArrayType.TRIANGLES
191
+ conn = self._tri_fan_to_tris(conn)
192
+ elif mode == pygltflib.LINES:
193
+ conn_pb.payload_type = dynamic_scene_graph_pb2.UpdateGeom.ArrayType.LINES
194
+ elif mode == pygltflib.LINE_LOOP:
195
+ conn_pb.payload_type = dynamic_scene_graph_pb2.UpdateGeom.ArrayType.LINES
196
+ conn = self._line_loop_to_lines(conn)
197
+ elif mode == pygltflib.LINE_STRIP:
198
+ conn_pb.payload_type = dynamic_scene_graph_pb2.UpdateGeom.ArrayType.LINES
199
+ conn = self._line_strip_to_lines(conn)
200
+ conn_pb.int_array.extend(conn)
201
+ conn_pb.chunk_offset = 0
202
+ conn_pb.total_array_size = len(conn)
203
+ self._handle_update_command(cmd)
204
+
205
+ # Normals
176
206
  if prim.attributes.NORMAL is not None:
177
207
  normals = self._get_data(prim.attributes.NORMAL)
178
208
  cmd, normals_pb = self._create_pb("GEOM", parent_id=part_dsg_id)
@@ -182,6 +212,7 @@ class GLBSession(dsg_server.DSGSession):
182
212
  normals_pb.total_array_size = len(normals)
183
213
  self._handle_update_command(cmd)
184
214
 
215
+ # Texture coords
185
216
  if prim.attributes.TEXCOORD_0 is not None:
186
217
  # Note: texture coords are stored as VEC2, so we get 2 components back
187
218
  texcoords = self._get_data(prim.attributes.TEXCOORD_0, components=2)
@@ -199,6 +230,103 @@ class GLBSession(dsg_server.DSGSession):
199
230
  texcoords_pb.variable_id = glb_varid
200
231
  self._handle_update_command(cmd)
201
232
 
233
+ @staticmethod
234
+ def _tri_strip_to_tris(conn: numpy.ndarray) -> numpy.ndarray:
235
+ """
236
+ Convert GL_TRIANGLE_STRIP connectivity into GL_TRIANGLES
237
+
238
+ Parameters
239
+ ----------
240
+ conn: numpy.ndarray
241
+ The tri strip connectivity
242
+
243
+ Returns
244
+ -------
245
+ numpy.array:
246
+ Triangles connectivity
247
+ """
248
+ tris = []
249
+ swap = False
250
+ for i in range(len(conn) - 2):
251
+ tris.append(conn[i])
252
+ if swap:
253
+ tris.append(conn[i + 2])
254
+ tris.append(conn[i + 1])
255
+ else:
256
+ tris.append(conn[i + 1])
257
+ tris.append(conn[i + 2])
258
+ swap = not swap
259
+ return numpy.array(tris, dtype=conn.dtype)
260
+
261
+ @staticmethod
262
+ def _tri_fan_to_tris(conn: numpy.ndarray) -> numpy.ndarray:
263
+ """
264
+ Convert GL_TRIANGLE_FAN connectivity into GL_TRIANGLES
265
+
266
+ Parameters
267
+ ----------
268
+ conn: numpy.ndarray
269
+ The fan connectivity
270
+
271
+ Returns
272
+ -------
273
+ numpy.array:
274
+ Triangles connectivity
275
+ """
276
+ tris = []
277
+ for i in range(1, len(conn) - 1):
278
+ tris.append(conn[0])
279
+ tris.append(conn[i])
280
+ tris.append(conn[i + 1])
281
+ return numpy.array(tris, dtype=conn.dtype)
282
+
283
+ @staticmethod
284
+ def _line_strip_to_lines(conn) -> numpy.ndarray:
285
+ """
286
+ Convert GL_LINE_STRIP connectivity into GL_LINES
287
+
288
+ Parameters
289
+ ----------
290
+ conn: numpy.ndarray
291
+ The line strip connectivity
292
+
293
+ Returns
294
+ -------
295
+ numpy.array:
296
+ Lines connectivity
297
+ """
298
+ lines = []
299
+ num_nodes = len(conn)
300
+ for i in range(num_nodes - 1):
301
+ lines.append(conn[i])
302
+ lines.append(conn[i + 1])
303
+ return numpy.array(lines, dtype=conn.dtype)
304
+
305
+ @staticmethod
306
+ def _line_loop_to_lines(conn) -> numpy.ndarray:
307
+ """
308
+ Convert GL_LINE_LOOP connectivity into GL_LINES
309
+
310
+ Parameters
311
+ ----------
312
+ conn: numpy.ndarray
313
+ The line loop connectivity
314
+
315
+ Returns
316
+ -------
317
+ numpy.array:
318
+ Lines connectivity
319
+ """
320
+ lines = []
321
+ num_nodes = len(conn)
322
+ for i in range(num_nodes):
323
+ lines.append(conn[i])
324
+ if i + 1 == num_nodes:
325
+ lines.append(conn[0])
326
+ else:
327
+ lines.append(conn[i + 1])
328
+ return numpy.array(lines, dtype=conn.dtype)
329
+
202
330
  def _get_data(
203
331
  self,
204
332
  accessorid: int,
@@ -452,7 +580,16 @@ class GLBSession(dsg_server.DSGSession):
452
580
  view_pb.fieldofview = camera.perspective.yfov
453
581
  view_pb.aspectratio = camera.aspectratio.aspectRatio
454
582
  self._handle_update_command(cmd)
455
- for node_id in self._gltf.scenes[scene_idx].nodes:
583
+ # walk the scene nodes RJF
584
+ scene = self._gltf.scenes[scene_idx]
585
+ try:
586
+ if self._callback_handler._omni.line_width == 0.0:
587
+ width = float(scene.extensions["ANSYS_linewidth"]["linewidth"])
588
+ self._callback_handler._omni.line_width = width
589
+ except (KeyError, ValueError):
590
+ # in the case where the extension does not exist or is mal-formed
591
+ pass
592
+ for node_id in scene.nodes:
456
593
  self._walk_node(node_id, view_pb.id)
457
594
  self._finish_part()
458
595
 
@@ -490,11 +627,22 @@ class GLBSession(dsg_server.DSGSession):
490
627
  List[float]
491
628
  The computed timeline.
492
629
  """
493
- # if ANSYS_scene_time is used, time ranges will come from there
494
- if "ANSYS_scene_time" in self._gltf.scenes[scene_idx].extensions:
495
- return self._gltf.scenes[scene_idx].extensions["ANSYS_scene_time"]
496
- # if there is only one scene, then use the input timeline
497
630
  num_scenes = len(self._gltf.scenes)
631
+ # if ANSYS_scene_timevalue is used, time ranges will come from there
632
+ try:
633
+ t0 = self._gltf.scenes[scene_idx].extensions["ANSYS_scene_timevalue"]["timevalue"]
634
+ idx = scene_idx + 1
635
+ if idx >= num_scenes:
636
+ idx = scene_idx
637
+ t1 = self._gltf.scenes[idx].extensions["ANSYS_scene_timevalue"]["timevalue"]
638
+ else:
639
+ t1 = t0
640
+ return [t0, t1]
641
+ except KeyError:
642
+ # If we fail due to dictionary key issue, the extension does not exist or is
643
+ # improperly formatted.
644
+ pass
645
+ # if there is only one scene, then use the input timeline
498
646
  if num_scenes == 1:
499
647
  return input_timeline
500
648
  # if the timeline has zero length, we make it the number of scenes
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: ansys-pyensight-core
3
- Version: 0.9.0
3
+ Version: 0.9.2
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>
@@ -20,7 +20,7 @@ Requires-Dist: ansys-api-pyensight==0.4.2
20
20
  Requires-Dist: requests>=2.28.2
21
21
  Requires-Dist: docker>=6.1.0
22
22
  Requires-Dist: urllib3<3.0.0
23
- Requires-Dist: numpy>=1.21.0,<2
23
+ Requires-Dist: numpy>=1.21.0,<3
24
24
  Requires-Dist: Pillow>=9.3.0
25
25
  Requires-Dist: pypng>=0.0.20
26
26
  Requires-Dist: psutil>=5.9.2
@@ -4,7 +4,7 @@ ansys/pyensight/core/deep_pixel_view.html,sha256=6u4mGOuzJiPze8N8pIKJsEGPv5y6-zb
4
4
  ansys/pyensight/core/dockerlauncher.py,sha256=LmgEFEjl0l3D_JaeJu5bbGR28aluHYtzb0-BmrC7ta8,28251
5
5
  ansys/pyensight/core/enscontext.py,sha256=GSKkjZt1QEPyHEQ59EEBgKGMik9vjCdR9coR4uX7fEw,12141
6
6
  ansys/pyensight/core/enshell_grpc.py,sha256=-OxSdFI_p3DmQnqh1jT_a_aSh_w-EUD2IaWGKxrnyjI,17122
7
- ansys/pyensight/core/ensight_grpc.py,sha256=0_qv9gUQsWyRSGGtTW84PNNEVegtsCPrnT6oXix-hvc,16415
7
+ ansys/pyensight/core/ensight_grpc.py,sha256=IkntqzHmNzhADZ1VZJtWGpaB3ZlSThcovsbXyliW_Sk,29458
8
8
  ansys/pyensight/core/ensobj.py,sha256=uDtM2KHcAwd4hu5pcUYWbSD729ApHGIvuqZhEq8PxTI,18558
9
9
  ansys/pyensight/core/launch_ensight.py,sha256=iZJM6GdpzGRDLzrv1V2QZ5veIOpNSB5xPpJUFY7rBuo,10254
10
10
  ansys/pyensight/core/launcher.py,sha256=ymwfixwoHO7_c4qOetqccQbZjGT1HjeA7jwPi2JxlmE,10585
@@ -12,17 +12,17 @@ ansys/pyensight/core/libuserd.py,sha256=JIORrVqmbjsqnT9O-FUPwq1B1-Jt-lmDKaPkrrtV
12
12
  ansys/pyensight/core/listobj.py,sha256=Trw87IxIMXtmUd1DzywRmMzORU704AG4scX4fqYmO6M,9340
13
13
  ansys/pyensight/core/locallauncher.py,sha256=ot05X0vj-xDqNSx-2A_RDBBuN9Fyk2dONjkkD9gtVyM,16264
14
14
  ansys/pyensight/core/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
15
- ansys/pyensight/core/renderable.py,sha256=YhPfqjvTlJXn9BB4ctJXRwTfs0Yol8JLgOU9XQt5AC0,36203
16
- ansys/pyensight/core/session.py,sha256=T0zPiBmOMroBYhsw4Byf4Y-fKxJX_LhnI6DOzm1hat0,72767
15
+ ansys/pyensight/core/renderable.py,sha256=KidVTVCZ4hKYq54pP9KoJ8OCxeWBXNUJYyKSwMZ2Sls,36362
16
+ ansys/pyensight/core/session.py,sha256=gNWuihZEjmPcnEE5t7CXdK53e2Ah8MgdI5Tb3yE6CpQ,72876
17
17
  ansys/pyensight/core/sgeo_poll.html,sha256=1M4BIc5CZpYA3b40qzk22NcPCLhjFnWdoS2PrS6Rhn4,752
18
18
  ansys/pyensight/core/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
19
19
  ansys/pyensight/core/utils/adr.py,sha256=XslZhlwcrSGzOlnhzprOv3ju_ppxxsWBjCnQL5KiNms,3570
20
- ansys/pyensight/core/utils/dsg_server.py,sha256=RjUuGGgKfm1umJcItLjCYeTgx3BlSM5PmJ_9zW9G5ZI,44232
20
+ ansys/pyensight/core/utils/dsg_server.py,sha256=FfiTJ7XsTW3OhI2w7PKMX5SLVoznGgZ6In-Q_wpkggE,45017
21
21
  ansys/pyensight/core/utils/export.py,sha256=UAJQcrElo3esQD0CWdxxjMQ8yE1vB4cdAhF33_uZfQw,22605
22
- ansys/pyensight/core/utils/omniverse.py,sha256=EAQnS_bapR2owEGa4X3hcyqpzGEnUf734nhW3WeglpY,13888
23
- ansys/pyensight/core/utils/omniverse_cli.py,sha256=m5TgxHxDVVSqEY4kGss0OwV-aYHDVX076JPwKlx1fp0,20042
24
- ansys/pyensight/core/utils/omniverse_dsg_server.py,sha256=gW9uQfHmuSYS9VrwI6jkn6BxIfu3MoxUbK7QlN6Cuec,35482
25
- ansys/pyensight/core/utils/omniverse_glb_server.py,sha256=FlftOS-MFCFlFyIFGe8o7dpHASPRjc37f_KJtDto7ss,24921
22
+ ansys/pyensight/core/utils/omniverse.py,sha256=Y16_nXjfymnXpJmddAkqNnVCWGr8RTjHqA6JSNz8GA8,18483
23
+ ansys/pyensight/core/utils/omniverse_cli.py,sha256=aVYu4HsSZBl7A9_xU3DfItNB-hpxCdMPXm_oMAOU_HQ,20261
24
+ ansys/pyensight/core/utils/omniverse_dsg_server.py,sha256=Bnc99LU2216Dk2t8v0rVNH8sJm8pQiYwqkcH1N5zTvE,38384
25
+ ansys/pyensight/core/utils/omniverse_glb_server.py,sha256=gP6NEmrmqB1ALFGGLkNwnIhn7JWHylRvyIb8JbXrbmA,29879
26
26
  ansys/pyensight/core/utils/parts.py,sha256=222XFRCjLgH7hho-cK9JrGCg3-KlTf54KIgc7y50sTE,52173
27
27
  ansys/pyensight/core/utils/query.py,sha256=OXKDbf1sOTX0sUvtKcp64LhVl-BcrEsE43w8uMxLOYI,19828
28
28
  ansys/pyensight/core/utils/readers.py,sha256=cNNzrE5pjy4wpQKWAzIIJfJCSpY3HU43az02f5I3pVU,11968
@@ -30,7 +30,7 @@ ansys/pyensight/core/utils/support.py,sha256=QI3z9ex7zJxjFbkCPba9DWqWgPFIThORqr0
30
30
  ansys/pyensight/core/utils/variables.py,sha256=ZUiJdDIeRcowrnLXaJQqGwA0RbrfXhc1s4o4v9A4PiY,95133
31
31
  ansys/pyensight/core/utils/views.py,sha256=ZKhJ6vMT7Rdd4bwJ0egMYTV7-D7Q7I19fF2_j_CMQ0o,12489
32
32
  ansys/pyensight/core/utils/resources/Materials/000_sky.exr,sha256=xAR1gFd2uxPZDnvgfegdhEhRaqKtZldQDiR_-1rHKO0,8819933
33
- ansys_pyensight_core-0.9.0.dist-info/LICENSE,sha256=qQWivZ12ETN5l3QxvTARY-QI5eoRRlyHdwLlAj0Bg5I,1089
34
- ansys_pyensight_core-0.9.0.dist-info/WHEEL,sha256=CpUCUxeHQbRN5UGRQHYRJorO5Af-Qy_fHMctcQ8DSGI,82
35
- ansys_pyensight_core-0.9.0.dist-info/METADATA,sha256=sw7c3IaFUCrk7RHe3WyCrFjbmQF0Fjwymg4dus2PpWg,12113
36
- ansys_pyensight_core-0.9.0.dist-info/RECORD,,
33
+ ansys_pyensight_core-0.9.2.dist-info/LICENSE,sha256=qQWivZ12ETN5l3QxvTARY-QI5eoRRlyHdwLlAj0Bg5I,1089
34
+ ansys_pyensight_core-0.9.2.dist-info/WHEEL,sha256=CpUCUxeHQbRN5UGRQHYRJorO5Af-Qy_fHMctcQ8DSGI,82
35
+ ansys_pyensight_core-0.9.2.dist-info/METADATA,sha256=KkO1m505t8Zbu76uwkfORfA33vR2HpHwyros1mwRFvs,12113
36
+ ansys_pyensight_core-0.9.2.dist-info/RECORD,,