1

I would like to render scalar data on a structured grid that pass a certain threshold (for example, see below)

an example of the kind of rendering I'd like, generated with paraview

I have tried with vtk. See the following snippet below for my code

 grid.SetPoints(points)                                                         
 grid.SetDimensions(nx,ny,nz)                                                   
 grid.GetPointData().SetScalars(scalars)                                        
                                                                                
 threshold = vtk.vtkThresholdPoints()                                           
 threshold.SetInputData(grid)                                                   
 threshold.ThresholdByUpper(0.5)                                                
                                                                                
 mapper = vtk.vtkDataSetMapper()                                                
 mapper.SetInputConnection(threshold.GetOutputPort())                           
                                                                                
 actor = vtk.vtkActor()                                                         
 actor.SetMapper(mapper)                                                        
 renderer.AddActor(actor)                                                       
                                                                                
 interactor.Start()    

I.e. I have a structured grid with points and scalars set. I then build a threshold mapper and actor. The threshold looks like its working insofar as the correct subset is being singled out. But instead of an array of cubes it generates an array of dots (see below).

my own render produces a series of dots as opposed to cubes

My question: How can I replace these dots with cubes as they are shown in the first figure

1 Answer 1

1

Use vtkThreshold instead of vtkThresholdPoints.

As you want cubes, you need topology to be preserved. The points version extract only points, so it breaks the cells information.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.