def __init__(self, module_manager):
     SimpleVTKClassModuleBase.__init__(
         self, module_manager,
         vtk.vtkGreedyTerrainDecimation(), 'Processing.',
         ('vtkImageData',), ('vtkPolyData',),
         replaceDoc=True,
         inputFunctions=None, outputFunctions=None)
예제 #2
0
 def __init__(self, module_manager):
     SimpleVTKClassModuleBase.__init__(self,
                                       module_manager,
                                       vtk.vtkGreedyTerrainDecimation(),
                                       'Processing.', ('vtkImageData', ),
                                       ('vtkPolyData', ),
                                       replaceDoc=True,
                                       inputFunctions=None,
                                       outputFunctions=None)
예제 #3
0
파일: utils.py 프로젝트: kezilu/pextant
def decimate(zarray, corrected_absolute_error):
    row_size, col_size = zarray.shape
    number_of_elevation_entries = zarray.size
    vectorized_elevations = np.reshape(zarray, (number_of_elevation_entries, 1))
    vtk_array = numpy_to_vtk(vectorized_elevations, deep=True,
                             array_type=VTK_FLOAT)
    image = vtkImageData()
    image.SetDimensions(col_size, row_size, 1)
    image.AllocateScalars(vtk_array.GetDataType(), 4)
    image.GetPointData().GetScalars().DeepCopy(vtk_array)

    deci = vtkGreedyTerrainDecimation()
    deci.SetInputData(image)
    deci.BoundaryVertexDeletionOn()
    deci.SetErrorMeasureToAbsoluteError()
    deci.SetAbsoluteError(corrected_absolute_error)
    deci.Update()

    return deci
예제 #4
0
from vtk.test import Testing
from vtk.util.misc import vtkGetDataRoot
VTK_DATA_ROOT = vtkGetDataRoot()

lut = vtk.vtkLookupTable()
lut.SetHueRange(0.6, 0)
lut.SetSaturationRange(1.0, 0)
lut.SetValueRange(0.5, 1.0)
# Read the data: a height field results
demReader = vtk.vtkDEMReader()
demReader.SetFileName("" + str(VTK_DATA_ROOT) + "/Data/SainteHelens.dem")
demReader.Update()
lo = lindex(demReader.GetOutput().GetScalarRange(), 0)
hi = lindex(demReader.GetOutput().GetScalarRange(), 1)
# Decimate the terrain
deci = vtk.vtkGreedyTerrainDecimation()
deci.SetInputConnection(demReader.GetOutputPort())
deci.BoundaryVertexDeletionOn()
#  deci SetErrorMeasureToSpecifiedReduction
#  deci SetReduction 0.95
deci.SetErrorMeasureToNumberOfTriangles()
deci.SetNumberOfTriangles(5000)
#  deci SetErrorMeasureToAbsoluteError
#  deci SetAbsoluteError 25.0
#  deci SetErrorMeasureToRelativeError
#  deci SetAbsoluteError 0.01
normals = vtk.vtkPolyDataNormals()
normals.SetInputConnection(deci.GetOutputPort())
normals.SetFeatureAngle(60)
normals.ConsistencyOn()
normals.SplittingOff()
예제 #5
0
lut = vtk.vtkLookupTable()
lut.SetHueRange(0.6, 0)
lut.SetSaturationRange(1.0, 0)
lut.SetValueRange(0.5, 1.0)

# Read the data: a height field results
demReader = vtk.vtkDEMReader()
demReader.SetFileName(VTK_DATA_ROOT + "/Data/SainteHelens.dem")
demReader.Update()

lo = demReader.GetOutput().GetScalarRange()[0]
hi = demReader.GetOutput().GetScalarRange()[1]

# Decimate the terrain
deci = vtk.vtkGreedyTerrainDecimation()
deci.SetInputConnection(demReader.GetOutputPort())
deci.BoundaryVertexDeletionOn()
#  deci.SetErrorMeasureToSpecifiedReduction()
#  deci.SetReduction(0.95)
deci.SetErrorMeasureToNumberOfTriangles()
deci.SetNumberOfTriangles(5000)
#  deci.SetErrorMeasureToAbsoluteError()
#  deci.SetAbsoluteError(25.0)
#  deci.SetErrorMeasureToRelativeError()
#  deci.SetAbsoluteError(0.01)

normals = vtk.vtkPolyDataNormals()
normals.SetInputConnection(deci.GetOutputPort())
normals.SetFeatureAngle(60)
normals.ConsistencyOn()