How are non-flat polygons converted to triangles for display?

I’m displaying a stack of vtkQuad like a floating set of sheets of paper, using a vtkPolyData to hold them. Any polygon with more than 3 points might not lie in a plane, of course, and these will likely not, due to the nature of my data source. So how does the VTK machine convert a non-planar polygon to triangles for display? How fine is the mesh? How is it interpolated from the available points around the circumference? What “knobs” (methods) are available to tweak this?

In my application, I have about 20 “sheets” and would like them to be smoother (ie. use a finer mesh), but not so fine that it impairs performance as I move the camera around the scene with an interactor.

I’m actually displaying a second set of “ideal” flat sheets in a contrasting color to see how the measured ones divert from the ideal positions. The measured ones will be partially occluded by the real ones.

I haven’t looked at the details recently, but typically the rendering engine (OpenGL) performs triangulation (often using poor approaches e.g., concave polygons may be incorrectly triangulated). Also, the shading occurs in the hardware - so you don’t typically have a lot of control.

I’m guessing that if you want full control, you’ll have to manage the triangulation to your satisfaction. You can use classes like vtkPlaneSource and vtkTriangleFilter to quickly tessellate your sheets at various levels of resolution. There are other tricks but that will get you started.

Thanks! Just to confirm: So OpenGL receives the raw polygons and handles the tesselation? And to get more control (eg. a finer/smoother mesh) one must insert a filter to “manually” tesselate the polygons down to triangles.


OpenGL defines several geometry primitives:

OpenGL Primitives and Colours
The ones that are not triangles, lines or points will be broken down to triangles by the graphics back-end. If you wish full control over the tesselation, you have to work with the primitives composed by triangles (e.g. GL_TRIANGLE_STRIP).



1 Like