コード例 #1
0
quadric.SetCoefficients([.5, 1, .2, 0, .1, 0, 0, .2, 0, 0])
sample = vtk.vtkSampleFunction()
sample.SetSampleDimensions(res, res, res)
sample.SetImplicitFunction(quadric)
sample.ComputeNormalsOn()
sample.Update()

#
# Extract voxel cells
extract = vtk.vtkExtractCells()
extract.SetInputConnection(sample.GetOutputPort())
extract.AddCellRange(0, sample.GetOutput().GetNumberOfCells())
extract.Update()

# Now contour the cells, using scalar tree or not
stree = vtk.vtkSpanSpace()
stree.SetDataSet(extract.GetOutput())
stree.SetNumberOfCellsPerBucket(1)

contour = vtk.vtkContour3DLinearGrid()
contour.SetInputConnection(extract.GetOutputPort())
contour.SetValue(0, 0.5)
contour.SetValue(1, 0.75)
contour.SetMergePoints(mergePoints)
contour.SetSequentialProcessing(serialProcessing)
contour.SetInterpolateAttributes(interpolateAttr)
contour.SetComputeNormals(computeNormals)
contour.UseScalarTreeOff()

contourST = vtk.vtkContour3DLinearGrid()
contourST.SetInputConnection(extract.GetOutputPort())
コード例 #2
0
ファイル: TestScalarTrees.py プロジェクト: ciwei100000/vtk8
renWin.AddRenderer(ren0)
renWin.AddRenderer(ren1)
iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)

reader = vtk.vtkExodusIIReader()
reader.SetFileName("" + str(VTK_DATA_ROOT) + "/Data/disk_out_ref.ex2")
reader.SetPointResultArrayStatus("Temp", 1)
reader.Update()
input = reader.GetOutput().GetBlock(0).GetBlock(0)

# Create scalar trees to test
sTree = vtk.vtkSimpleScalarTree()
sTree.SetBranchingFactor(3)

spanTree = vtk.vtkSpanSpace()
spanTree.SetResolution(100)

# First create the usual contour grid (non-threaded)
cf = vtk.vtkContourFilter()
cf.SetInputData(input)
cf.SetUseScalarTree(1)
cf.SetValue(0, 350)
cf.SetInputArrayToProcess(0, 0, 0, 0, "Temp")
cf.GenerateTrianglesOff()

contourMapper = vtk.vtkPolyDataMapper()
contourMapper.SetInputConnection(cf.GetOutputPort())
contourMapper.ScalarVisibilityOff()

contourActor = vtk.vtkActor()
#!/usr/bin/env python
import vtk
from vtk.util.misc import vtkGetDataRoot
VTK_DATA_ROOT = vtkGetDataRoot()

# Debugging parameters
sze = 300

reader = vtk.vtkExodusIIReader()
reader.SetFileName(VTK_DATA_ROOT + "/Data/disk_out_ref.ex2")
reader.UpdateInformation()
reader.SetPointResultArrayStatus("CH4", 1)
reader.Update()

tree = vtk.vtkSpanSpace()

#contour = vtk.vtkSMPContourGrid()
contour = vtk.vtkContourGrid()
contour.SetInputConnection(reader.GetOutputPort())
contour.SetInputArrayToProcess(0, 0, 0, vtk.vtkAssignAttribute.POINT_DATA, "CH4")
contour.SetValue(0, 0.000718448)
#contour.MergePiecesOff()
contour.UseScalarTreeOn()
contour.SetScalarTree(tree)
contour.Update()

mapper = vtk.vtkCompositePolyDataMapper2()
mapper.SetInputConnection(contour.GetOutputPort())
mapper.ScalarVisibilityOff()

actor = vtk.vtkActor()
コード例 #4
0
renWin.AddRenderer(ren0)
renWin.AddRenderer(ren1)
iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)

reader = vtk.vtkExodusIIReader()
reader.SetFileName("" + str(VTK_DATA_ROOT) + "/Data/disk_out_ref.ex2")
reader.SetPointResultArrayStatus("Temp",1);
reader.Update ();
input = reader.GetOutput().GetBlock(0).GetBlock(0);

# Create scalar trees to test
sTree = vtk.vtkSimpleScalarTree()
sTree.SetBranchingFactor(3)

spanTree = vtk.vtkSpanSpace()
spanTree.SetResolution(100);

# First create the usual contour grid (non-threaded)
cf = vtk.vtkContourFilter()
cf.SetInputData(input)
cf.SetUseScalarTree(1)
cf.SetValue(0,350)
cf.SetInputArrayToProcess(0, 0, 0, 0, "Temp");
cf.GenerateTrianglesOff()

contourMapper = vtk.vtkPolyDataMapper()
contourMapper.SetInputConnection(cf.GetOutputPort())
contourMapper.ScalarVisibilityOff()

contourActor = vtk.vtkActor()