示例#1
0
def test_laplace(aorta_surface, compare_surfaces):
    name = __name__ + '_test_laplace.vtp'
    smoother = smoothing.vmtkSurfaceSmoothing()
    smoother.Surface = aorta_surface
    smoother.Method = 'laplace'
    smoother.Execute()

    assert compare_surfaces(smoother.Surface, name) == True
示例#2
0
def test_laplace(aorta_surface, compare_surfaces):
    name = __name__ + '_test_laplace.vtp'
    smoother = smoothing.vmtkSurfaceSmoothing()
    smoother.Surface = aorta_surface
    smoother.Method = 'laplace'
    smoother.Execute()

    assert compare_surfaces(smoother.Surface, name) == True
示例#3
0
def test_laplace_change_relaxation(aorta_surface, compare_surfaces):
    name = __name__ + '_test_laplace_change_relaxation.vtp'
    smoother = smoothing.vmtkSurfaceSmoothing()
    smoother.Surface = aorta_surface
    smoother.Method = 'laplace'
    smoother.RelaxationFactor = 0.05
    smoother.Execute()

    assert compare_surfaces(smoother.Surface, name) == True
示例#4
0
def test_taubin_change_passband(aorta_surface, compare_surfaces):
    name = __name__ + '_test_taubin_change_passband.vtp'
    smoother = smoothing.vmtkSurfaceSmoothing()
    smoother.Surface = aorta_surface
    smoother.Method = 'taubin'
    smoother.PassBand = 1.5
    smoother.Execute()

    assert compare_surfaces(smoother.Surface, name) == True
示例#5
0
def test_laplace_change_relaxation(aorta_surface, compare_surfaces):
    name = __name__ + '_test_laplace_change_relaxation.vtp'
    smoother = smoothing.vmtkSurfaceSmoothing()
    smoother.Surface = aorta_surface
    smoother.Method = 'laplace'
    smoother.RelaxationFactor = 0.05
    smoother.Execute()

    assert compare_surfaces(smoother.Surface, name) == True
示例#6
0
def test_taubin_change_passband(aorta_surface, compare_surfaces):
    name = __name__ + '_test_taubin_change_passband.vtp'
    smoother = smoothing.vmtkSurfaceSmoothing()
    smoother.Surface = aorta_surface
    smoother.Method = 'taubin'
    smoother.PassBand = 1.5
    smoother.Execute()

    assert compare_surfaces(smoother.Surface, name) == True
示例#7
0
def surface_smooth():
    '''
    网格表面的平滑
    '''
    input_file = 'id2_model.vtp'
    output_file = 'id2_mode_sm_laplace.vtp'
    surfacereader = sr.vmtkSurfaceReader()
    surfacereader.InputFileName = input_file
    surfacereader.Execute()

    # 没有平滑的网格表面
    originsurface_mapper = vtk.vtkPolyDataMapper()
    originsurface_mapper.SetInputData(surfacereader.Surface)
    originsurface_actor = vtk.vtkActor()
    originsurface_actor.SetMapper(originsurface_mapper)
    color = [0, 1, 0]
    originsurface_actor.GetProperty().SetColor(color)
    originsurface_actor.GetProperty().SetOpacity(0.8)

    surfacesmooth = ss.vmtkSurfaceSmoothing()
    surfacesmooth.Surface = surfacereader.Surface
    surfacesmooth.NumberOfIterations = 30
    surfacesmooth.PassBand = 1.0
    surfacesmooth.RelaxationFactor = 0.01
    surfacesmooth.BoundarySmoothing = 1
    surfacesmooth.NormalizeCoordinates = 1
    surfacesmooth.Method = "laplace"  # ["taubin","laplace"]
    surfacesmooth.Execute()

    renderer = rd.vmtkRenderer()
    renderer.Initialize()
    renderer.Renderer.AddActor(originsurface_actor)

    surface_viewer = sv.vmtkSurfaceViewer()
    surface_viewer.vmtkRenderer = renderer
    surface_viewer.Surface = surfacesmooth.Surface
    surface_viewer.Display = 1
    surface_viewer.Color = [1.0, 0, 0]
    surface_viewer.ColorMap = "cooltowarm"
    surface_viewer.Execute()

    surface_writer = sw.vmtkSurfaceWriter()
    surface_writer.OutputFileName = output_file
    surface_writer.Surface = surfacesmooth.Surface
    surface_writer.Execute()