[vtkusers] VTK hexahedronal unstructured grid

David E DeMarle dave.demarle at kitware.com
Tue Jul 24 07:29:27 EDT 2012


Although you add more and more points to vPoints above this code, here
you are telling  every cell to use the same (the first 8) points in
vPoints.
>         for (unsigned int j = 0; j < 8; j++) {
>                 vHexahedron->GetPointIds()->SetId(j,j);
>         }


This can be moved outside of the loop. You only have to tell the
unstructured grid that vPoints is the container that holds its points
once.
>         vUGrid->SetPoints(vPoints);

David E DeMarle
Kitware, Inc.
R&D Engineer
21 Corporate Drive
Clifton Park, NY 12065-8662
Phone: 518-881-4909


On Tue, Jul 24, 2012 at 5:28 AM, ISTB <f.dshabarow at gmail.com> wrote:
>
> 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.
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers



More information about the vtkusers mailing list