[vtkusers] Please Help: Quadratic Cells

Thompson, David C dcthomp at sandia.gov
Wed Nov 11 12:26:44 EST 2009


Hi Davood,

OpenGL and other rendering libraries only draw points, lines, and triangles.
Over any of these graphics primitives, fields such as texture coordinates or
color will vary linearly. VTK must convert the nonlinear element into a series
of these primitives. The default is to use the fewest possible number of
primitives so that meshes with many cells can be rendered efficiently. In order
to get a more accurate rendering, you should try using the vtkTessellatorFilter
which will subdivide the element (or its boundaries) according to an error metric.

    David
________________________________________
From: vtkusers-bounces at vtk.org [vtkusers-bounces at vtk.org] On Behalf Of Davood Ansari [david.ansari at gmail.com]
Sent: Wednesday, November 11, 2009 08:46
To: vtkusers at vtk.org
Subject: [vtkusers] Please Help: Quadratic Cells

Hi all
I used the following example code to see how the quadratic Tetrahedron gets on the screen.
Surprisingly it is not a curved object but kind of multi linear .
What is wrong with my pipeline ?




int main(int argc, char** argv)
{
    vtkUnstructuredGrid *meshGrid = vtkUnstructuredGrid::New() ;

    VTK_CREATE(vtkPoints, points);
    //points->Allocate(24);
    points->InsertNextPoint(0.,0.,0.) ;
    points->InsertNextPoint(1.,0.,0.) ;
    points->InsertNextPoint(0.,1.,0.) ;
    points->InsertNextPoint(0.,0.,1.) ;

    points->InsertNextPoint(0.5,0.,0.) ;
    points->InsertNextPoint(0.5,0.5,0.) ;
    points->InsertNextPoint(0.0,0.5,0.) ;

    points->InsertNextPoint(0.,0.,0.5) ;
    points->InsertNextPoint(0.65,0.,0.65) ;
    points->InsertNextPoint(0.,0.65,0.65) ;

    meshGrid->SetPoints(points) ;

    vtkIdList* pts = vtkIdList::New();
    pts -> InsertId(0,0) ;
    pts -> InsertId(1,1) ;
    pts -> InsertId(2,2) ;
    pts -> InsertId(3,3) ;
    pts -> InsertId(4,4) ;
    pts -> InsertId(5,5) ;
    pts -> InsertId(6,6) ;
    pts -> InsertId(7,7) ;
    pts -> InsertId(8,8) ;
    pts -> InsertId(9,9) ;

    meshGrid->InsertNextCell (VTK_QUADRATIC_TETRA, pts) ;

    vtkDataSetMapper *meshMapper = vtkDataSetMapper::New();
    meshMapper -> SetInput(meshGrid);
    //meshMapper -> SetRepresentationToWireframe() ;

    vtkActor *meshActor = vtkActor::New();
    meshActor -> SetMapper(meshMapper);

    vtkRenderer *ren = vtkRenderer::New() ;
    ren -> SetBackground(0.2,0.2,0.15) ;
    ren -> AddActor(meshActor) ;

    vtkRenderWindow *renWin = vtkRenderWindow::New() ;
    renWin ->AddRenderer(ren) ;
    renWin ->SetSize(1024,768) ;

    vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New() ;
    iren -> SetRenderWindow(renWin);
    iren -> Initialize();
    iren -> Start();

   std::cout << std::endl ;

}





More information about the vtkusers mailing list