[vtkusers] Rendering vtkTriQuadraticHexahedron
Gustavo C Longhin
longhin at simworx.com.br
Fri Feb 25 13:30:25 EST 2011
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
More information about the vtkusers
mailing list