[vtkusers] vtkCutter does not work in CutCombustor example when data converted to hex unstructured mesh
Jason Hoogland
jdhoogland at wbmpl.com.au
Mon Apr 27 20:53:27 EDT 2009
vtkCutter works nicely in the
VisualizationAlgorithms/Python/CutCombustor.py example for me, although
while both sides of the cut plane are coloured on x86 and x86_64
machines running ubuntu 8.10 with nvidia cards (GeForce Go 6200/6400 and
quadro fx 540 respectively), only the side facing the normal vector
direction is coloured on an x86_64 with ubuntu 8.04 machine with an ati
FireGL V3100.
But the colour contours don't display for me using the same data when
converted to an unstructured mesh. To create the unstructured data, I
used pv3.3.0:
1. Open File > View files of all types > cd to VTKData/Data/ > load
combxyz.bin using the PLOT3D reader as a Binary file, specifying
combq.bin as the Q file. Select all Functions expect Entropy (which
later caused problems with inf points for me). I used all the default
PLOT3DReader settings.
2. Filters > Connectivity, this creates PVConnectivityFilter1 object
which turns the data from structured to unstructured
3. Keep the new object highlighted and go to Save Data > Data Mode:
ASCII, Ghost Level 0, save conveniently as e.g. combNewUnstructured.vtm.
This saves a combNewUnstructured.vtm xml file, and a directory
combNewUnstructured/ containing combNewUnstructured_0.vtu, an xml for
the unstructured data
4. Delete the data objects and load this combNewUnstructured_0.vtu data
separately
5. Save Data > VTK legacy file (ASCII) conveniently e.g.
combNewUnstructuredLegacy.vtk
Check it by loading in paraview and/or scanning the file.
After copying the new legacy file into the CutCombustor.py directory I
then modified the script:
#!/usr/bin/env python
# This example shows how to use cutting (vtkCutter) and how it
# compares with extracting a plane from a computational grid.
import vtk
from vtk.util.misc import vtkGetDataRoot
#VTK_DATA_ROOT = vtkGetDataRoot()
VTK_DATA_ROOT = "."
# Read some data.
data = vtk.vtkUnstructuredGridReader()
data.SetFileName(VTK_DATA_ROOT + "/combNewUnstructuredLegacy.vtk")
data.SetScalarsName("Temperature")
data.SetVectorsName("Velocity")
data.Update()
#pl3d = vtk.vtkPLOT3DReader()
#pl3d.SetXYZFileName(VTK_DATA_ROOT + "/Data/combxyz.bin")
#pl3d.SetQFileName(VTK_DATA_ROOT + "/Data/combq.bin")
#pl3d.SetScalarFunctionNumber(100)
#pl3d.SetVectorFunctionNumber(202)
#pl3d.Update()
# The cutter uses an implicit function to perform the cutting.
# Here we define a plane, specifying its center and normal.
# Then we assign the plane to the cutter.
plane = vtk.vtkPlane()
plane.SetOrigin(data.GetOutput().GetCenter())
plane.SetNormal(-0.287, 0, 0.9579)
planeCut = vtk.vtkCutter()
planeCut.SetInputConnection(data.GetOutputPort())
planeCut.SetCutFunction(plane)
cutMapper = vtk.vtkPolyDataMapper()
cutMapper.SetInputConnection(planeCut.GetOutputPort())
#cutMapper.SetScalarRange(data.GetOutput().GetPointData().GetScalars().G
etRange())
cutMapper.SetScalarRange(data.GetOutput().GetScalarRange())
cutActor = vtk.vtkActor()
cutActor.SetMapper(cutMapper)
#cutActor.GetProperty().SetRepresentationToWireframe()
#cutActor.GetProperty().SetColor(0, 0, 0)
# Here we extract a computational plane from the structured grid.
# We render it as wireframe.
#compPlane = vtk.vtkStructuredGridGeometryFilter()
#compPlane.SetInputConnection(data.GetOutputPort())
#compPlane.SetExtent(0, 100, 0, 100, 9, 9)
#planeMapper = vtk.vtkPolyDataMapper()
#planeMapper.SetInputConnection(compPlane.GetOutputPort())
#planeMapper.ScalarVisibilityOff()
#planeActor = vtk.vtkActor()
#planeActor.SetMapper(planeMapper)
#planeActor.GetProperty().SetRepresentationToWireframe()
#planeActor.GetProperty().SetColor(0, 0, 0)
# The outline of the data puts the data in context.
#outline = vtk.vtkStructuredGridOutlineFilter()
outline = vtk.vtkOutlineFilter()
outline.SetInputConnection(data.GetOutputPort())
outlineMapper = vtk.vtkPolyDataMapper()
outlineMapper.SetInputConnection(outline.GetOutputPort())
outlineActor = vtk.vtkActor()
outlineActor.SetMapper(outlineMapper)
outlineProp = outlineActor.GetProperty()
outlineProp.SetColor(0, 0, 0)
# Create the RenderWindow, Renderer and both Actors
ren = vtk.vtkRenderer()
renWin = vtk.vtkRenderWindow()
renWin.AddRenderer(ren)
iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)
# Add the actors to the renderer, set the background and size
ren.AddActor(outlineActor)
#ren.AddActor(planeActor)
ren.AddActor(cutActor)
ren.SetBackground(1, 1, 1)
renWin.SetSize(400, 300)
cam1 = ren.GetActiveCamera()
cam1.SetClippingRange(11.1034, 59.5328)
cam1.SetFocalPoint(9.71821, 0.458166, 29.3999)
cam1.SetPosition(-2.95748, -26.7271, 44.5309)
cam1.SetViewUp(0.0184785, 0.479657, 0.877262)
iren.Initialize()
renWin.Render()
iren.Start()
The cut plane is displayed within the box, but there are no colours.
Could this be related to this post?:
http://markmail.org/message/vze4injatoxhti5w
Also, when the two lines for "SetRepresentationToWireframe" are
uncommented, there is no change, the mesh for the cut plane is not
displayed.
If I load up the combNewUnstructuredLegacy.vtk file in pv and use
Filters > Tetrahedralize and save as say
combNewTetUnstructuredLegacy.vtk, and load this instead into the script,
again no colours are displayed but if the SetRepresentationToWireframe
is used, the cut mesh is displayed.
Paraview is a fantastic tool but I'd like to be able to use vtk directly
for post-processing OpenFOAM meshes, which are becoming more
hex-dominant.
Jason
Jason Hoogland
Mechanical Engineer
BMT WBM Pty Ltd
490 Upper Edward Street,
Brisbane 4000 Queensland
Tel +61 7 3831 6744
Fax +61 7 3832 3627
www.wbmpl.com.au
More information about the vtkusers
mailing list