本文整理匯總了Python中vtk.vtkDelaunay2D方法的典型用法代碼示例。如果您正苦於以下問題:Python vtk.vtkDelaunay2D方法的具體用法?Python vtk.vtkDelaunay2D怎麽用?Python vtk.vtkDelaunay2D使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類vtk
的用法示例。
在下文中一共展示了vtk.vtkDelaunay2D方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: update
# 需要導入模塊: import vtk [as 別名]
# 或者: from vtk import vtkDelaunay2D [as 別名]
def update(self):
delaunay = vtkDelaunay2D()
delaunay.SetInput(self.input_)
delaunay.SetTolerance(self.tolerance)
delaunay.SetAlpha(self.alpha)
delaunay.Update()
self.output_ = delaunay.GetOutput()
示例2: create_actor_delaunay
# 需要導入模塊: import vtk [as 別名]
# 或者: from vtk import vtkDelaunay2D [as 別名]
def create_actor_delaunay(pts, color, **kwargs):
""" Creates a VTK actor for rendering triangulated plots using Delaunay triangulation.
Keyword Arguments:
* ``d3d``: flag to choose between Delaunay2D (``False``) and Delaunay3D (``True``). *Default: False*
:param pts: points
:type pts: vtkFloatArray
:param color: actor color
:type color: list
:return: a VTK actor
:rtype: vtkActor
"""
# Keyword arguments
array_name = kwargs.get('name', "")
array_index = kwargs.get('index', 0)
use_delaunay3d = kwargs.get("d3d", False)
# Create points
points = vtk.vtkPoints()
points.SetData(pts)
# Create a PolyData object and add points
polydata = vtk.vtkPolyData()
polydata.SetPoints(points)
# Apply Delaunay triangulation on the poly data object
triangulation = vtk.vtkDelaunay3D() if use_delaunay3d else vtk.vtkDelaunay2D()
triangulation.SetInputData(polydata)
# Map triangulated surface to the graphics primitives
mapper = vtk.vtkDataSetMapper()
mapper.SetInputConnection(triangulation.GetOutputPort())
mapper.SetArrayName(array_name)
mapper.SetArrayId(array_index)
# Create an actor and set its properties
actor = vtk.vtkActor()
actor.SetMapper(mapper)
actor.GetProperty().SetColor(*color)
# Return the actor
return actor
示例3: delaunay_2d
# 需要導入模塊: import vtk [as 別名]
# 或者: from vtk import vtkDelaunay2D [as 別名]
def delaunay_2d(poly_data, tol=1e-05, alpha=0.0, offset=1.0, bound=False,
inplace=False, edge_source=None, progress_bar=False):
"""Apply a delaunay 2D filter along the best fitting plane.
Parameters
----------
tol : float
Specify a tolerance to control discarding of closely spaced
points. This tolerance is specified as a fraction of the diagonal
length of the bounding box of the points.
alpha : float
Specify alpha (or distance) value to control output of this
filter. For a non-zero alpha value, only edges or triangles
contained within a sphere centered at mesh vertices will be
output. Otherwise, only triangles will be output.
offset : float
Specify a multiplier to control the size of the initial, bounding
Delaunay triangulation.
bound : bool
Boolean controls whether bounding triangulation points (and
associated triangles) are included in the output. (These are
introduced as an initial triangulation to begin the triangulation
process. This feature is nice for debugging output.)
inplace : bool
If True, overwrite this mesh with the triangulated mesh.
edge_source : pyvista.PolyData, optional
Specify the source object used to specify constrained edges and
loops. (This is optional.) If set, and lines/polygons are
defined, a constrained triangulation is created. The
lines/polygons are assumed to reference points in the input point
set (i.e. point ids are identical in the input and source). Note
that this method does not connect the pipeline. See
SetSourceConnection for connecting the pipeline.
progress_bar : bool, optional
Display a progress bar to indicate progress.
"""
alg = vtk.vtkDelaunay2D()
alg.SetProjectionPlaneMode(vtk.VTK_BEST_FITTING_PLANE)
alg.SetInputDataObject(poly_data)
alg.SetTolerance(tol)
alg.SetAlpha(alpha)
alg.SetOffset(offset)
alg.SetBoundingTriangulation(bound)
if edge_source is not None:
alg.SetSourceData(edge_source)
_update_alg(alg, progress_bar, 'Computing 2D Triangulation')
# Sometimes lines are given in the output. The `.triangulate()` filter cleans those
mesh = _get_output(alg).triangulate()
if inplace:
poly_data.overwrite(mesh)
else:
return mesh
示例4: createDEM_v1
# 需要導入模塊: import vtk [as 別名]
# 或者: from vtk import vtkDelaunay2D [as 別名]
def createDEM_v1():
ds = xr.open_dataset('../data/output/Peru_20160601-20180530_comp4.nc')
points = vtk.vtkPoints()
numPoints = ds.south_north.size*ds.west_east.size
print('Write points \n')
for i,j in product(ds.south_north.values,ds.west_east.values):
points.InsertNextPoint(ds.lat.isel(south_north=i,west_east=j), ds.lon.isel(south_north=i,west_east=j), ds.HGT.isel(south_north=i,west_east=j).values/6370000.0)
print('Create unstructured grid \n')
polydata = vtk.vtkPolyData()
polydata.SetPoints(points)
delaunay = vtk.vtkDelaunay2D()
delaunay.SetInputData(polydata)
delaunay.Update()
# subdivision = vtk.vtkButterflySubdivisionFilter()
# subdivision.SetInputConnection(delaunay.GetOutputPort())
# subdivision.Update()
#smoother = vtk.vtkWindowedSincPolyDataFilter()
#smoother.SetInputConnection(delaunay.GetOutputPort())
#smoother.SetNumberOfIterations(5)
#smoother.BoundarySmoothingOff()
#smoother.FeatureEdgeSmoothingOff()
#smoother.SetFeatureAngle(120.0)
#smoother.SetPassBand(.001)
#smoother.NonManifoldSmoothingOff()
#smoother.NormalizeCoordinatesOff()
#smoother.Update()
appendFilter = vtk.vtkAppendFilter()
appendFilter.AddInputData(delaunay.GetOutput())
appendFilter.Update()
unstructuredGrid = vtk.vtkUnstructuredGrid()
unstructuredGrid.ShallowCopy(appendFilter.GetOutput())
writer = vtk.vtkXMLUnstructuredGridWriter()
writer.SetFileName('cosipy.vtu')
writer.SetInputData(unstructuredGrid)
writer.Write()
示例5: set_topography
# 需要導入模塊: import vtk [as 別名]
# 或者: from vtk import vtkDelaunay2D [as 別名]
def set_topography(self):
# Create points on an XY grid with random Z coordinate
vertices = copy.copy(self.geo_model._grid.topography.values)
points = vtk.vtkPoints()
# for v in vertices:
# v[-1] = v[-1]
# points.InsertNextPoint(v)
if self.ve !=1:
vertices[:, 2]= vertices[:, 2]*self.ve
points.SetData(numpy_to_vtk(vertices))
# Add the grid points to a polydata object
polydata = vtk.vtkPolyData()
polydata.SetPoints(points)
#
# glyphFilter = vtk.vtkVertexGlyphFilter()
# glyphFilter.SetInputData(polydata)
# glyphFilter.Update()
#
# # Create a mapper and actor
# pointsMapper = vtk.vtkPolyDataMapper()
# pointsMapper.SetInputConnection(glyphFilter.GetOutputPort())
#
# pointsActor = vtk.vtkActor()
# pointsActor.SetMapper(pointsMapper)
# pointsActor.GetProperty().SetPointSize(3)
# pointsActor.GetProperty().SetColor(colors.GetColor3d("Red"))
# Triangulate the grid points
delaunay = vtk.vtkDelaunay2D()
delaunay.SetInputData(polydata)
delaunay.Update()
# Create a mapper and actor
triangulatedMapper = vtk.vtkPolyDataMapper()
triangulatedMapper.SetInputConnection(delaunay.GetOutputPort())
triangulatedActor = vtk.vtkActor()
triangulatedActor.SetMapper(triangulatedMapper)
self.topography_surface = triangulatedActor
self._topography_polydata = polydata
self._topography_delauny = delaunay
self.ren_list[0].AddActor(triangulatedActor)
self.ren_list[1].AddActor(triangulatedActor)
self.ren_list[2].AddActor(triangulatedActor)
self.ren_list[3].AddActor(triangulatedActor)
try:
if self.geo_model.solutions.geological_map is not None:
self.set_geological_map()
except AttributeError as ae:
warnings.warn(str(ae))