1 /*=========================================================================
3 Program: Visualization Toolkit
4 Module: $RCSfile: vtkDepthSortPolyData.h,v $
6 Date: $Date: 2002/05/16 02:03:50 $
7 Version: $Revision: 1.10 $
9 Copyright (c) 1993-2002 Ken Martin, Will Schroeder, Bill Lorensen
11 See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
13 This software is distributed WITHOUT ANY WARRANTY; without even
14 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 PURPOSE. See the above copyright notice for more information.
17 =========================================================================*/
18 // .NAME vtkDepthSortPolyData - sort poly data along camera view direction
19 // .SECTION Description
20 // vtkDepthSortPolyData rearranges the order of cells so that certain
21 // rendering operations (e.g., transparency or Painter's algorithms)
22 // generate correct results. To use this filter you must specify the
23 // direction vector along which to sort the cells. You can do this by
24 // specifying a camera and/or prop to define a view direction; or
25 // explicitly set a view direction.
28 // The sort operation will not work well for long, thin primitives, or cells
29 // that intersect, overlap, or interpenetrate each other.
31 #ifndef __vtkDepthSortPolyData_h
32 #define __vtkDepthSortPolyData_h
34 #include "vtkPolyDataToPolyDataFilter.h"
36 #define VTK_DIRECTION_BACK_TO_FRONT 0
37 #define VTK_DIRECTION_FRONT_TO_BACK 1
38 #define VTK_DIRECTION_SPECIFIED_VECTOR 2
40 #define VTK_SORT_FIRST_POINT 0
41 #define VTK_SORT_BOUNDS_CENTER 1
42 #define VTK_SORT_PARAMETRIC_CENTER 2
48 class VTK_HYBRID_EXPORT vtkDepthSortPolyData : public vtkPolyDataToPolyDataFilter
52 // Instantiate object.
53 static vtkDepthSortPolyData *New();
55 vtkTypeRevisionMacro(vtkDepthSortPolyData,vtkPolyDataToPolyDataFilter);
56 void PrintSelf(ostream& os, vtkIndent indent);
59 // Specify the sort method for the polygonal primitives. By default, the
60 // poly data is sorted from back to front.
61 vtkSetMacro(Direction,int);
62 vtkGetMacro(Direction,int);
63 void SetDirectionToFrontToBack()
64 {this->SetDirection(VTK_DIRECTION_FRONT_TO_BACK);}
65 void SetDirectionToBackToFront()
66 {this->SetDirection(VTK_DIRECTION_BACK_TO_FRONT);}
67 void SetDirectionToSpecifiedVector()
68 {this->SetDirection(VTK_DIRECTION_SPECIFIED_VECTOR);}
71 // Specify the point to use when sorting. The fastest is to just
72 // take the first cell point. Other options are to take the bounding
73 // box center or the parametric center of the cell. By default, the
74 // first cell point is used.
75 vtkSetMacro(DepthSortMode,int);
76 vtkGetMacro(DepthSortMode,int);
77 void SetDepthSortModeToFirstPoint()
78 {this->SetDepthSortMode(VTK_SORT_FIRST_POINT);}
79 void SetDepthSortModeToBoundsCenter()
80 {this->SetDepthSortMode(VTK_SORT_BOUNDS_CENTER);}
81 void SetDepthSortModeToParametricCenter()
82 {this->SetDepthSortMode(VTK_SORT_PARAMETRIC_CENTER);}
85 // Specify a camera that is used to define a view direction along which
86 // the cells are sorted. This ivar only has effect if the direction is set
87 // to front-to-back or back-to-front, and a camera is specified.
88 virtual void SetCamera(vtkCamera*);
89 vtkGetObjectMacro(Camera,vtkCamera);
92 // Specify a transformation matrix (via the vtkProp3D::GetMatrix() method)
93 // that is used to include the effects of transformation. This ivar only
94 // has effect if the direction is set to front-to-back or back-to-front,
95 // and a camera is specified. Specifying the vtkProp3D is optional.
96 void SetProp3D(vtkProp3D *);
97 vtkProp3D *GetProp3D();
100 // Set/Get the sort direction. This ivar only has effect if the sort
101 // direction is set to SetDirectionToSpecifiedVector(). The sort occurs
102 // in the direction of the vector.
103 vtkSetVector3Macro(Vector,double);
104 vtkGetVectorMacro(Vector,double,3);
107 // Set/Get the sort origin. This ivar only has effect if the sort
108 // direction is set to SetDirectionToSpecifiedVector(). The sort occurs
109 // in the direction of the vector, with this point specifying the
111 vtkSetVector3Macro(Origin,double);
112 vtkGetVectorMacro(Origin,double,3);
115 // Set/Get a flag that controls the generation of scalar values
116 // corresponding to the sort order. If enabled, the output of this
117 // filter will include scalar values that range from 0 to (ncells-1),
118 // where 0 is closest to the sort direction.
119 vtkSetMacro(SortScalars, int);
120 vtkGetMacro(SortScalars, int);
121 vtkBooleanMacro(SortScalars, int);
124 // Return MTime also considering the dependent objects: the camera
125 // and/or the prop3D.
126 unsigned long GetMTime();
129 vtkDepthSortPolyData();
130 ~vtkDepthSortPolyData();
133 void ComputeProjectionVector(double vector[3], double origin[3]);
139 vtkTransform *Transform;
145 vtkDepthSortPolyData(const vtkDepthSortPolyData&); // Not implemented.
146 void operator=(const vtkDepthSortPolyData&); // Not implemented.