InsightSoftwareConsortium / itkwidgets

An elegant Python interface for visualization on the web platform to interactively generate insights into multidimensional images, point sets, and geometry.
https://itkwidgets.readthedocs.io/
Apache License 2.0
573 stars 83 forks source link

Support for high-order Lagrange elements #306

Open mgenet opened 4 years ago

mgenet commented 4 years ago

Hello,

Hope it is the right place to ask. I am trying to visualize ugrids with high-order elements, e.g.,

order = 2
n_points = (order + 1) * (order + 2) // 2
cell = vtk.vtkLagrangeTriangle()
cell.GetPointIds().SetNumberOfIds(n_points)
cell.GetPoints().SetNumberOfPoints(n_points)
cell.Initialize()
point = [0., 0., 0.]
barycentric_index = [0, 0, 0]
for k_point in range(n_points):
    cell.GetPointIds().SetId(k_point, k_point)
    cell.ToBarycentricIndex(k_point, barycentric_index)
    for k_dim in range(2):
      point[k_dim] = (barycentric_index[k_dim] / order)**2
    cell.GetPoints().SetPoint(k_point, point[0], point[1], point[2])
cell_array = vtk.vtkCellArray()
cell_array.InsertNextCell(cell)
ugrid = vtk.vtkUnstructuredGrid()
ugrid.SetPoints(cell.GetPoints())
ugrid.SetCells(cell.GetCellType(), cell_array)
itkwidgets.view(geometries=[ugrid])

(inspired from https://blog.kitware.com/modeling-arbitrary-order-lagrange-finite-elements-in-the-visualization-toolkit), to no avail. Is there any support for high-order elements? If not, is it planned? Thanks!

Martin

thewtex commented 4 years ago

Hello Martin,

This depends on vtk Python package support for these features, which @tjcorona is working on.

Be well, Matt

mgenet commented 4 years ago

Awesome. Thanks!

jorgensd commented 3 years ago

This seems to be supported by other packages using VTK, such as pyvista, (ref minimal example in https://github.com/pyvista/pyvista/issues/947). Is there anything in particular missing in itkwidgets for this?

mgenet commented 2 years ago

Any update on this? Thanks a lot!