[vtkusers] Rendering vtkTriQuadraticHexahedron

Gustavo C Longhin longhin at simworx.com.br
Sat Feb 26 06:41:20 EST 2011


Hi David,

     Actually I've solved my problem. There goes my working code:

*vtkUnstructuredGridGeometryFilter* *geom;
     geom=vtkUnstructuredGridGeometryFilter::New();

     geom->SetInput(aGrid);
     vtkTessellatorFilter * tf = vtkTessellatorFilter::New();
     tf->SetOutputDimension(3);
     tf->SetInput(geom->GetOutput());
     tf->Update();

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


     If I use the *vtkUnstructuredGridGeometryFilter* prior to feeding 
the TessellatorFilter it works fine ! The thing is for me that this is 
not documented. My code is working fine now, the nodes ordering is ok as 
well.
     One thing I am not sure is whether I've solved the problem or I 
just bypass it.
     One thing I didn't mention was that in case one wants to render the 
triQuadraticHex... without the necessity of having its surfaces smoothed 
the code also works fine, (in that case the TessellatorFilter is not 
needed). This for me indicates that the documentation for the 
TessellatorFilter is incomplete.
     I've found the solution googling on this link:
http://paraview.sourcearchive.com/documentation/3.6.2/TestUnstructuredGridGeometryFilter_8cxx-source.html
     Search for the use of *vtkUnstructuredGridGeometryFilter* and see 
that it is receiving the Output() from a UnstructuredGrid with 
triQuadraticHex on it. Well, that solved my problem.
     In case I wasn't clear or if you need some more information just 
let me know.
     Best Regards.
Gustavo.
passing my Unstructured
On 25/02/2011 18:47, Thompson, David C wrote:
> 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
>
>


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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20110226/95a37deb/attachment.htm>


More information about the vtkusers mailing list