[vtkusers] VTK hexahedronal unstructured grid

ISTB f.dshabarow at gmail.com
Tue Jul 24 05:28:26 EDT 2012


Hi everybody, I am trying to visualize the hexahedronal mesh but without
success. I tried to use the example provided by vtk to visualize one
hexahedron and it works. However, when I try to visualize more than one, it
does not work. Here the code:
 
vtkSmartPointer<vtkUnstructuredGrid>  vUGrid =
vtkSmartPointer<vtkUnstructuredGrid>::New();
 vtkSmartPointer<vtkPoints>  vPoints = vtkSmartPointer<vtkPoints>::New(); 


for (unsigned int i = 0; i < 1; i++) 
{ 
        vPoints->InsertNextPoint(0.0+i, 0.0+i, 0.0+i); 
        vPoints->InsertNextPoint(1.0+i, 0.0+i, 0.0+i); 
        vPoints->InsertNextPoint(1.0+i, 1.0+i, 0.0+i); 
        vPoints->InsertNextPoint(0.0, 1.0, 0.0); 
        vPoints->InsertNextPoint(0.0, 0.0, 1.0); 
        vPoints->InsertNextPoint(1.0, 0.0, 1.0); 
        vPoints->InsertNextPoint(1.0, 1.0, 1.0); 
        vPoints->InsertNextPoint(0.0, 1.0, 1.0); 

        vtkSmartPointer<vtkHexahedron>  vHexahedron =
vtkSmartPointer<vtkHexahedron>::New();
         vHexahedron->GetPointIds()->SetNumberOfIds(8); 
        for (unsigned int j = 0; j < 8; j++) { 
                vHexahedron->GetPointIds()->SetId(j,j); 
        } 
        vUGrid->SetPoints(vPoints); 
        vUGrid->InsertNextCell(vHexahedron->GetCellType(),
vHexahedron->GetPointIds());
 } 

vtkSmartPointer<vtkDataSetMapper> mapper =
vtkSmartPointer<vtkDataSetMapper>::New();
 mapper->SetInput(vUGrid); 

vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New(); 
actor->SetMapper(mapper); 
          
vtkSmartPointer<vtkRenderer> renderer = vtkSmartPointer<vtkRenderer>::New(); 
vtkSmartPointer<vtkRenderWindow> renderWindow =
vtkSmartPointer<vtkRenderWindow>::New();
 renderWindow->AddRenderer(renderer); 
vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor =
vtkSmartPointer<vtkRenderWindowInteractor>::New();
 ui.qvtkWidget->SetRenderWindow(renderWindow); 
renderer->AddActor(actor); 
renderer->SetBackground(0.3, 0.6, 0.3); // Background color green 
renderWindow->Render(); 





--
View this message in context: http://vtk.1045678.n5.nabble.com/VTK-hexahedronal-unstructured-grid-tp5714868.html
Sent from the VTK - Users mailing list archive at Nabble.com.



More information about the vtkusers mailing list