Python vtk.vtkCubeSource() Examples
The following are 2
code examples of vtk.vtkCubeSource().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
vtk
, or try the search function
.
Example #1
Source File: geometric_objects.py From pyvista with MIT License | 6 votes |
def Cube(center=(0., 0., 0.), x_length=1.0, y_length=1.0, z_length=1.0, bounds=None): """Create a cube. It's possible to specify either the center and side lengths or just the bounds of the cube. If ``bounds`` are given, all other arguments are ignored. Parameters ---------- center : np.ndarray or list Center in [x, y, z]. x_length : float length of the cube in the x-direction. y_length : float length of the cube in the y-direction. z_length : float length of the cube in the z-direction. bounds : np.ndarray or list Specify the bounding box of the cube. If given, all other arguments are ignored. ``(xMin,xMax, yMin,yMax, zMin,zMax)`` """ src = vtk.vtkCubeSource() if bounds is not None: if np.array(bounds).size != 6: raise TypeError('Bounds must be given as length 6 tuple: (xMin,xMax, yMin,yMax, zMin,zMax)') src.SetBounds(bounds) else: src.SetCenter(center) src.SetXLength(x_length) src.SetYLength(y_length) src.SetZLength(z_length) src.Update() return pyvista.wrap(src.GetOutput())
Example #2
Source File: segmentation.py From director with BSD 3-Clause "New" or "Revised" License | 4 votes |
def segmentDoorHandle(otdfType, point1, point2): inputObj = om.findObjectByName('pointcloud snapshot') polyData = inputObj.polyData viewPlaneNormal = np.array(getSegmentationView().camera().GetViewPlaneNormal()) polyData, origin, normal = applyPlaneFit(polyData, expectedNormal=viewPlaneNormal, searchOrigin=point1, searchRadius=0.2, angleEpsilon=0.7, returnOrigin=True) wallPoints = thresholdPoints(polyData, 'dist_to_plane', [-0.01, 0.01]) updatePolyData(wallPoints, 'wall points', parent=getDebugFolder(), visible=False) handlePoint = np.array([0.005, 0.065, 0.011]) xaxis = -normal zaxis = [0, 0, 1] yaxis = np.cross(zaxis, xaxis) yaxis /= np.linalg.norm(yaxis) zaxis = np.cross(xaxis, yaxis) xwidth = 0.01 ywidth = 0.13 zwidth = 0.022 cube = vtk.vtkCubeSource() cube.SetXLength(xwidth) cube.SetYLength(ywidth) cube.SetZLength(zwidth) cube.Update() cube = shallowCopy(cube.GetOutput()) t = getTransformFromAxes(xaxis, yaxis, zaxis) #t.PreMultiply() #t.Translate(-handlePoint) t.PostMultiply() t.Translate(point2) name = 'door handle' obj = showPolyData(cube, name, cls=FrameAffordanceItem, parent='affordances') obj.actor.SetUserTransform(t) obj.addToView(app.getDRCView()) params = dict(origin=origin, xwidth=xwidth, ywidth=ywidth, zwidth=zwidth, xaxis=xaxis, yaxis=yaxis, zaxis=zaxis, friendly_name=name, otdf_type=otdfType) obj.setAffordanceParams(params) obj.updateParamsFromActorTransform() frameObj = showFrame(obj.actor.GetUserTransform(), name + ' frame', parent=obj, visible=False) frameObj.addToView(app.getDRCView())