VTK/Closed Surface Clipping

From KitwarePublic
< VTK
Revision as of 20:56, 28 March 2010 by Dgobbi (talk | contribs) (Created page with 'The main goal of this project is to make it possible to clip a surface, and then create a "cap" polygon (or polygons) that fill in the area that is enclosed by all the new edges …')
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

The main goal of this project is to make it possible to clip a surface, and then create a "cap" polygon (or polygons) that fill in the area that is enclosed by all the new edges that were created by the clipping. In other words, the goal is to close the surface after the clipping has been performed. For this purpose, a new filter called vtkClipClosedSurface has been created.

Features

The vtkClipClosedSurface filter has the following features:

  • A vtkPlaneCollection is used to set the clip region (arbitrary implicit functions are not allowed).
  • If given a closed surface as input, it will produce a closed surface as output.
  • If given an open surface as input, it will create a closed surface if a clipping plane is given that clips away all open edges.
  • The input surface can be concave, or can be composed of multiple closed, non-intersecting surfaces.

Caveats

The newly-created clip surfaces have the following limitations:

  • The triangles in these surfaces are not suitable for FEM applications.
  • Although the edges of the clip surface are visually matched with the original surface, polygons that appear to be adjacent are not guaranteed to share an edge.

Options

  • GenerateFaces - On by default. If turned off, the output will have no polygons.
  • GenerateOutline - Off by default. If turned on, contours will be generated where the planes intersect the surface.
  • GenerateScalars - Off by default. Generate color scalars for the output, see below for more.

The GenerateScalars option creates color cell scalars so that the cut surfaces are displayed with a different color than the rest of the surface. Cell scalars are used instead of point scalars because the use of point scalars would require point duplication where the cut surfaces meet the rest of the surface. The same scalars are used for the polygons and the lines that are generated, the lines cannot be colored differently from polys. If you need the lines to be a different color, then you should use two instances of vtkClipClosedSurface: one to generates faces, and another to generates outlines.

If GenerateScalars is on, then three colors can be set:

  • ClipColor for the clip surfaces
  • BaseColor for the rest of the surface
  • ActivePlaneColor to color one clip surface in a different color

The purpose of ActivePlaneColor is to color one cut plane differently, e.g. the plane that the user is interacting with. The ActivePlaneId can be set to specify which of the cut planes is the active plane.

The BaseColor will be ignored if the input already has 3-component color scalars. If this is the case, the original scalars will be used instead of BaseColor. This is useful if you want to chain two vtkClipClosedSurface filters together, or if you want to use vtkClipClosedSurface on the output of vtkOutlineSource or vtkVolumeOutlineSource.

Note that many VTK filters that create new cells (e.g. vtkStripper) will erase the cell scalars. So if you use GenerateScalars, you should avoid using vtkStripper.

Algorithm

This filter uses many of the functions that are built into vtkCell and its subclasses, but it also has several internal functions for polygon manipulation. The tolerance for merging points etc. is set at d*1e-5 where "d" is the maximum dimension of the input bounds. An overall description of what is done for each of the clipping planes is as follows:

  1. Clip scalars are generated for all points.
  2. The data is clipped and contoured, using the clip scalars.
  3. The contours are used to generate the cut faces
  4. The process is repeated for the next cut plane

Generation of the cut faces from the cut contours is a multi-step process:

  1. The contour lines are joined tail-to-top to form polygons (it is assumed that the input data is closed).
  2. If the polygons self-intersect, they are split at the intersection points.
  3. Any polygon points that aren't at a corner of the polygon are removed.
  4. The sense of the polygons is set according to the cut plane normal.
  5. If any polygons are within other polygons, cuts are made between the outer and inner polygons.
  6. The ear-cut triangulation method of vtkPolygon is used to triangulate the polygons.