I want to visualize a tetrahedron, and my code is:
nodes = [
[ 3.56000000e+02, 2.56000000e+02, 0.00000000e+00],
[ 1.56000000e+02, 1.56000000e+02, 1.22464676e-14],
[ 1.56000000e+02, 2.06000000e+02, -8.66025391e+01],
[ 1.56000000e+02, 3.06000000e+02, -8.66025391e+01],
[ 1.56000000e+02, 3.56000000e+02, -2.44929351e-14],
[ 1.56000000e+02, 3.06000000e+02, 8.66025391e+01],
[ 1.56000000e+02, 2.06000000e+02, 8.66025391e+01]
]
elem = [
[4, 0, 5, 3],
[1, 2, 6, 0],
[2, 5, 0, 3],
[2, 5, 6, 0]
]
import vtkmodules.all as vtk
points = vtk.vtkPoints()
for p in nodes:
points.InsertNextPoint(p[0], p[1], p[2])
unstructuredGrid = vtk.vtkUnstructuredGrid()
unstructuredGrid.SetPoints(points)
cellArray = vtk.vtkCellArray()
for tre in elem:
tetra = vtk.vtkTetra()
tetra.GetPointIds().SetId(0, tre[0])
tetra.GetPointIds().SetId(1, tre[1])
tetra.GetPointIds().SetId(2, tre[2])
tetra.GetPointIds().SetId(3, tre[3])
cellArray.InsertNextCell(tetra)
unstructuredGrid.SetCells(vtk.VTK_TETRA, cellArray)
mapper = vtk.vtkDataSetMapper()
mapper.SetInputData(unstructuredGrid)
actor = vtk.vtkActor()
actor.SetMapper(mapper)
actor.GetProperty().SetOpacity(0.3)
actor.GetProperty().SetColor(1, 1, 0)
renderer = vtk.vtkRenderer()
renderer.AddActor(actor)
renderer.SetBackground(1, 1, 1)
renWin = vtk.vtkRenderWindow()
renWin.AddRenderer(renderer)
iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)
iren.SetInteractorStyle(vtk.vtkInteractorStyleTrackballCamera())
iren.Initialize()
iren.Start()
And the result is:
But, I expect the result figure could display the inner grid, for example:
How can I obtain the second result? Any suggestion is appreciated~~~