Python vtk.vtkFloatArray() Examples
The following are 7
code examples of vtk.vtkFloatArray().
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: vtkVisualization.py From MOTSFusion with MIT License | 5 votes |
def __init__(self, positions: np.ndarray, vectors: np.ndarray): self.num_vectors = 0 # VTK position representation self._positions = vtk.vtkPoints() # VTK vector representation self._vectors = vtk.vtkFloatArray() self._vectors.SetName("Vector Field") self._vectors.SetNumberOfComponents(3) # Visualization Pipeline # - Data source position_data = vtk.vtkPolyData() position_data.SetPoints(self._positions) position_data.GetPointData().AddArray(self._vectors) position_data.GetPointData().SetActiveVectors("Vector Field") # - Add the vector arrays as 3D Glyphs arrow_source = vtk.vtkArrowSource() add_arrows = vtk.vtkGlyph3D() add_arrows.SetInputData(position_data) add_arrows.SetSourceConnection(arrow_source.GetOutputPort()) add_arrows.Update() # - Map the data representation to graphics primitives mapper = vtk.vtkPolyDataMapper() mapper.SetInputConnection(add_arrows.GetOutputPort()) super().__init__(mapper) self.add_vectors(positions, vectors)
Example #2
Source File: VTKBlender.py From VTKBlender with Apache License 2.0 | 5 votes |
def create_point_data(self): pcoords = vtk.vtkFloatArray() pcoords.SetNumberOfComponents(3) pcoords.SetNumberOfTuples(len(self.mesh.vertices)) for i in range(len(self.mesh.vertices)): v = self.mesh.vertices[i] p0 = v.co[0] p1 = v.co[1] p2 = v.co[2] pcoords.SetTuple3(i, p0, p1, p2) self.points.SetData(pcoords)
Example #3
Source File: VTKBlender.py From VTKBlender with Apache License 2.0 | 5 votes |
def process_uvcoords(self): if me.faceUV: if uvlayer: uvnames = me.getUVLayerNames() if uvlayer in uvnames: me.activeUVLayer = uvlayer tcoords = vtk.vtkFloatArray() tcoords.SetNumberOfComponents(2) tcoords.SetNumberOfTuples(len(me.verts)) for face in me.faces: for i in range(len(face.verts)): uv = face.uv[i] tcoords.SetTuple2(face.v[i].index, uv[0], uv[1]) pdata.GetPointData().SetTCoords(tcoords);
Example #4
Source File: vtkPointSetNormalsEstimation.py From pcloudpy with BSD 3-Clause "New" or "Revised" License | 5 votes |
def update(self): normalArray = vtkFloatArray() normalArray.SetNumberOfComponents( 3 ) normalArray.SetNumberOfTuples( self.input_.GetNumberOfPoints() ) normalArray.SetName( "Normals" ) kDTree = vtkKdTree() kDTree.BuildLocatorFromPoints(self.input_.GetPoints()) # Estimate the normal at each point. for pointId in xrange(0, self.input_.GetNumberOfPoints()): point = [0,0,0] self.input_.GetPoint(pointId, point) neighborIds = vtkIdList() if self.mode == FIXED_NUMBER: kDTree.FindClosestNPoints(self.number_neighbors, point, neighborIds) elif self.mode == RADIUS: kDTree.FindPointsWithinRadius(self.radius, point, neighborIds) #If there are not at least 3 points within the specified radius (the current # #point gets included in the neighbors set), a plane is not defined. Instead, # #force it to use 3 points. if neighborIds.GetNumberOfIds() < 3 : kDTree.FindClosestNPoints(3, point, neighborIds) bestPlane = vtkPlane() self.best_fit_plane(self.input_.GetPoints(), bestPlane, neighborIds) normal = bestPlane.GetNormal() normalArray.SetTuple( pointId, normal ) self.output_ = vtkPolyData() self.output_.ShallowCopy(self.input_) self.output_.GetPointData().SetNormals(normalArray)
Example #5
Source File: vtk_adaptor.py From tessagon with Apache License 2.0 | 5 votes |
def create_empty_mesh(self): self.pcoords = vtk.vtkFloatArray() self.pcoords.SetNumberOfComponents(3) self.points = vtk.vtkPoints() self.polys = vtk.vtkCellArray() self.poly_data = vtk.vtkPolyData()
Example #6
Source File: vtk_adaptor.py From tessagon with Apache License 2.0 | 5 votes |
def initialize_colors(self): self.scalars = vtk.vtkFloatArray() self.scalars.SetNumberOfComponents(1) self.scalars.SetNumberOfTuples(self.face_count)
Example #7
Source File: show_lidar_vtk.py From Det3D with Apache License 2.0 | 5 votes |
def draw_box(x): cube = vtk.vtkPolyData() points = vtk.vtkPoints() polys = vtk.vtkCellArray() scalars = vtk.vtkFloatArray() for i in range(8): points.InsertPoint(i, x[i]) for i in range(6): polys.InsertNextCell(mkVtkIdList(pts[i])) for i in range(8): scalars.InsertTuple1(i, i) cube.SetPoints(points) del points cube.SetPolys(polys) del polys cube.GetPointData().SetScalars(scalars) del scalars cubeMapper = vtk.vtkPolyDataMapper() if vtk.VTK_MAJOR_VERSION <= 5: cubeMapper.SetInput(cube) else: cubeMapper.SetInputData(cube) cubeMapper.SetScalarRange(0, 7) # cubeMapper.SetScalarVisibility(2) cubeActor = vtk.vtkActor() cubeActor.SetMapper(cubeMapper) cubeActor.GetProperty().SetOpacity(0.4) return cubeActor