VTK Learning Twenty-two- fault triangulation

VTK Learning Twenty-two- fault triangulation

Description

Create a constrained Delaunay triangulation following fault lines. The
fault lines serve as constraint edges in the Delaunay triangulation.
根据断层线创建约束Delaunay三角剖分。在Delaunay三角剖分中,断层线作为约束边。

Code

#!/usr/bin/env python

# Create a constrained Delaunay triangulation following fault lines. The
# fault lines serve as constraint edges in the Delaunay triangulation.

import vtk
from vtk.util.misc import vtkGetDataRoot
from vtk.util.colors import *
VTK_DATA_ROOT = vtkGetDataRoot()
VTK_DATA_ROOT ="D:/codelearnning/vtk/VTK_BUILD/ExternalData/Testing"
# Generate some points by reading a VTK data file. The data file also
# has edges that represent constraint lines. This is originally from a
# geologic horizon.
reader = vtk.vtkPolyDataReader()
reader.SetFileName(VTK_DATA_ROOT + "/Data/faults.vtk")

# Perform a 2D triangulation with constraint edges.
delny = vtk.vtkDelaunay2D()
delny.SetInputConnection(reader.GetOutputPort())
delny.SetSourceConnection(reader.GetOutputPort())
delny.SetTolerance(0.00001)
normals = vtk.vtkPolyDataNormals()
normals.SetInputConnection(delny.GetOutputPort())
mapMesh = vtk.vtkPolyDataMapper()
mapMesh.SetInputConnection(normals.GetOutputPort())
meshActor = vtk.vtkActor()
meshActor.SetMapper(mapMesh)
meshActor.GetProperty().SetColor(beige)

# Now pretty up the mesh with tubed edges and balls at the vertices.
tuber = vtk.vtkTubeFilter()
tuber.SetInputConnection(reader.GetOutputPort())
tuber.SetRadius(5)
mapLines = vtk.vtkPolyDataMapper()
mapLines.SetInputConnection(tuber.GetOutputPort())
linesActor = vtk.vtkActor()
linesActor.SetMapper(mapLines)
linesActor.GetProperty().SetColor(1, 0, 0)
linesActor.GetProperty().SetColor(tomato)

# Create graphics objects
# Create the rendering window, renderer, and interactive renderer
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(linesActor)
ren.AddActor(meshActor)
ren.SetBackground(1, 1, 1)
renWin.SetSize(350, 250)

cam1 = vtk.vtkCamera()
cam1.SetClippingRange(2580, 129041)
cam1.SetFocalPoint(461550, 6.58e+006, 2132)
cam1.SetPosition(463960, 6.559e+06, 16982)
cam1.SetViewUp(-0.321899, 0.522244, 0.78971)
light = vtk.vtkLight()
light.SetPosition(0, 0, 1)
light.SetFocalPoint(0, 0, 0)
ren.SetActiveCamera(cam1)
ren.AddLight(light)

ren.GetActiveCamera().Zoom(1.5)
iren.LightFollowCameraOff()

iren.Initialize()
renWin.Render()
iren.Start()

Result

原始数据(断层线)、剖分结果和剖分结果的线框图。
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

Data

https://gitee.com/wblong/vtk_data

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值