VTK/Closed Surface Clipping: Difference between revisions

From KitwarePublic
< VTK
Jump to navigationJump to search
Line 16: Line 16:


The newly-created clip surfaces have the following limitations:
The newly-created clip surfaces have the following limitations:
* If the contours at the clip plane are not closed, or if they don't have simple topology, an incorrect surface will be generated.  
* If the contours at the clip plane are not closed, or if they don't have simple topology, then an incorrect surface will be generated.  
* The triangles that are generated are often very narrow.  The code does not attempt to generate high-quality triangles.
* The triangles that are generated are often very narrow.  The code does not attempt to generate high-quality triangles.
* This filter ignores vtkVertex cells, and the output will contain no verts.
* This filter ignores vtkVertex cells, and the output will contain no verts.

Revision as of 17:45, 30 March 2010

ClipClosedSurface regression test.

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.

This class was contributed to VTK by David Gobbi on March 30, 2010.

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 supplied with a clipping plane that clips away all open edges.
  • The input surface can be concave, and can even be composed of multiple closed surfaces, as long as there is no intersection between the surfaces. If the surfaces share an edge or a face, then the surfaces will be considered to be intersecting.

Caveats

The newly-created clip surfaces have the following limitations:

  • If the contours at the clip plane are not closed, or if they don't have simple topology, then an incorrect surface will be generated.
  • The triangles that are generated are often very narrow. The code does not attempt to generate high-quality triangles.
  • This filter ignores vtkVertex cells, and the output will contain no verts.
  • Similarly, input lines will be discarded unless the GenerateOutline option is on.

Options

ClippedVolumeOutline
  • GenerateFaces - On by default. If turned off, the output will have no polygons, which useful if only the outlines are desired.
  • GenerateOutline - Off by default. If turned on, contours will be generated where the planes intersect the surface.
  • GenerateColorScalars - Off by default. Generate color scalars for the output, see below for more.

The GenerateColorScalars 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 lines cannot be colored differently from polys. If you need the lines to be a different color, then you could use two instances of vtkClipClosedSurface: one to generates faces, and another to generates outlines.

If GenerateColorScalars 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 cell 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 GenerateCellScalars, you should avoid using vtkStripper to post-process the data.

Algorithm

ClipClosedSurface wireframe.

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 end-to-end to form polygons.
  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.
  7. Some of the new triangles are subdivided in order to add back the points that were removed in step 3.