Skip to content

Commit

Permalink
Added pyvista export function to antenna structures class to aid in v…
Browse files Browse the repository at this point in the history
…isualisation.
  • Loading branch information
LyceanEM committed Jun 3, 2024
1 parent a08ca37 commit 813358d
Showing 1 changed file with 34 additions and 1 deletion.
35 changes: 34 additions & 1 deletion lyceanem/base_classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ def translate_structures(self, vector):
None
"""
for item in range(len(self.solids)):
self.solids[item] = GF.translate_mesh(self.solids[item],vector, relative=True)
self.solids[item] = GF.translate_mesh(self.solids[item],vector)


def triangles_base_raycaster(self):
Expand Down Expand Up @@ -437,7 +437,40 @@ def translate_antenna(self,translation_vector):
self.structures.translate_structures(translation_vector)
self.points.translate_points(translation_vector)

def pyvista_export(self):
"""
Export the aperture points and structures as easy to visualize pyvista objects.
Returns
-------
aperture_meshes : list
aperture meshes included in the antenna structure class
structure_meshes : list
list of the triangle mesh objects in the antenna structure class
"""
import pyvista as pv
aperture_meshes = []
structure_meshes = []
# export and convert structures
triangle_meshes = self.export_all_structures()

def structure_cells(array):
## add collumn of 3s to beggining of each row
array = np.append(np.ones((array.shape[0], 1), dtype=np.int32) * 3, array, axis=1)
return array

for item in triangle_meshes:
new_mesh = pv.PolyData(item.points, structure_cells(item.cells[0].data))
# need to transfer across the point data and cell data
structure_meshes.append(new_mesh)

point_sets = [self.export_all_points()]
for item in point_sets:
new_points = pv.PolyData(item.points)
aperture_meshes.append(new_points)

return aperture_meshes, structure_meshes



Expand Down

0 comments on commit 813358d

Please sign in to comment.