[vtkusers] Rendering vtkTriQuadraticHexahedron

Thompson, David C dcthomp at sandia.gov
Fri Feb 25 16:47:58 EST 2011


Hi Gustavo,

Can you say exactly how the hexahedral case doesn't work? Does it fail to compile? Is the rendering incorrect?

If the rendering looks malformed, it might be because the points are not ordered the way VTK expects.

    Thanks,
    David
________________________________________
From: vtkusers-bounces at vtk.org [vtkusers-bounces at vtk.org] On Behalf Of Gustavo C Longhin [longhin at simworx.com.br]
Sent: Friday, February 25, 2011 10:30
To: vtkusers at vtk.org
Subject: [vtkusers] Rendering vtkTriQuadraticHexahedron

Hi All,

     I am trying to render a vtkTriQuadraticHexahedron passing it
through a vtkTessellatorFilter so I can get smoothed surfaces / edges etc.
     It worked perfectly with a vtkQuadraticTetra.
     Can some of you tell me what am I missing ?
     I am running VTK 5.6.1 (under windows :-().
     My code:

     vtkPoints * aPoints = vtkPoints::New();
     aPoints->SetNumberOfPoints(27);

     const int nNPFace = 9;
     int BottomNodes[nNPFace] = {0,8,1,9,2,10,3,11,24};
     int MiddleNodes[nNPFace] = {16,22,17,21,18,23,19,20,26};
     int TopNodes[nNPFace] = {4,12,5,13,6,14,7,15,25};

     aPoints->InsertPoint(BottomNodes[0], 0.5, 0, 0);
     aPoints->InsertPoint(BottomNodes[1], 2, 0, 0);
     aPoints->InsertPoint(BottomNodes[2], 4, 0, 0);
     aPoints->InsertPoint(BottomNodes[3], 4, 2.5, 0.1);
     aPoints->InsertPoint(BottomNodes[4], 4, 4, 0);
     aPoints->InsertPoint(BottomNodes[5], 2, 4, 0);
     aPoints->InsertPoint(BottomNodes[6], 0.5, 4, 0);
     aPoints->InsertPoint(BottomNodes[7], 0, 2.1, 0);
     aPoints->InsertPoint(BottomNodes[8], 2, 2, 0);

     aPoints->InsertPoint(MiddleNodes[0], 0, 0, 2);
     aPoints->InsertPoint(MiddleNodes[1], 2, 0.5, 2);
     aPoints->InsertPoint(MiddleNodes[2], 4, 0, 2);
     aPoints->InsertPoint(MiddleNodes[3], 4, 2, 2);
     aPoints->InsertPoint(MiddleNodes[4], 4, 4.1, 2);
     aPoints->InsertPoint(MiddleNodes[5], 2, 4, 2);
     aPoints->InsertPoint(MiddleNodes[6], 0, 4, 2.1);
     aPoints->InsertPoint(MiddleNodes[7], 0, 2, 2);
     aPoints->InsertPoint(MiddleNodes[8], 2, 2, 2.1);

     aPoints->InsertPoint(TopNodes[0], 0, 0, 4);
     aPoints->InsertPoint(TopNodes[1], 2.1, 0, 4);
     aPoints->InsertPoint(TopNodes[2], 4, 0, 4);
     aPoints->InsertPoint(TopNodes[3], 4, 2.1, 5);
     aPoints->InsertPoint(TopNodes[4], 4, 4, 4.1);
     aPoints->InsertPoint(TopNodes[5], 2, 4, 4);
     aPoints->InsertPoint(TopNodes[6], 0.1, 4, 4);
     aPoints->InsertPoint(TopNodes[7], 0, 2, 5);
     aPoints->InsertPoint(TopNodes[8], 2, 2, 4.1);

     vtkTriQuadraticHexahedron * aHexa = vtkTriQuadraticHexahedron::New();
     for(int i = 0; i < nNPFace; i++)
     {
         aHexa->GetPointIds()->SetId(BottomNodes[i], BottomNodes[i]);
         aHexa->GetPointIds()->SetId(MiddleNodes[i], MiddleNodes[i]);
         aHexa->GetPointIds()->SetId(TopNodes[i], TopNodes[i]);
     }


     vtkFloatArray * Scalars = vtkFloatArray::New();
     Scalars->SetName("Temperature");
     for(int i = 0; i < 27; i++)
     {
         Scalars->InsertNextValue(i*10+1);
     }


     vtkUnstructuredGrid * aGrid = vtkUnstructuredGrid::New();
     aGrid->Allocate(1, 1);
     aGrid->InsertNextCell(aHexa->GetCellType(), aHexa->GetPointIds());

     aGrid->SetPoints(aPoints);
     aGrid->GetPointData()->SetScalars(Scalars);

     vtkTessellatorFilter * tf = vtkTessellatorFilter::New();
     tf->SetOutputDimension(2);
     tf->SetInput(aGrid);
     tf->Update();

     vtkDataSetMapper * aMapper = vtkDataSetMapper::New();
     aMapper->SetInput(tf->GetOutput());
     aMapper->SetScalarRange(0, 270);
     aMapper->Update();
     vtkActor * aActor = vtkActor::New();
     aActor->SetMapper(aMapper);
.
.
.
.


The aActor object is then used in a GetRenderer()->AddActor(aActor) call.
  In the same code, exchanging the vtkTriQuadraticHexahedron with
vtkQuadraticTetra (and obviously correcting the Point Information) works
perfectly. I must be missing something.
Thanks a lot.
Best regards.
Gustavo

--
Gustavo C Longhin
Coord. Eng. de Software
SimWorx Eng P&D
+55 (19) 92854509
+55 (19) 37466155
+55 (19) 32891800

_______________________________________________
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