OSDN Git Service

FIRST REPOSITORY
[eos/hostdependOTHERS.git] / I686LINUX / util / I686LINUX / include / vtk / vtkDepthSortPolyData.h
1 /*=========================================================================
2
3   Program:   Visualization Toolkit
4   Module:    $RCSfile: vtkDepthSortPolyData.h,v $
5   Language:  C++
6   Date:      $Date: 2002/05/16 02:03:50 $
7   Version:   $Revision: 1.10 $
8
9   Copyright (c) 1993-2002 Ken Martin, Will Schroeder, Bill Lorensen 
10   All rights reserved.
11   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
12
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.
16
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.
26
27 // .SECTION Caveats
28 // The sort operation will not work well for long, thin primitives, or cells
29 // that intersect, overlap, or interpenetrate each other.
30
31 #ifndef __vtkDepthSortPolyData_h
32 #define __vtkDepthSortPolyData_h
33
34 #include "vtkPolyDataToPolyDataFilter.h"
35
36 #define VTK_DIRECTION_BACK_TO_FRONT 0
37 #define VTK_DIRECTION_FRONT_TO_BACK 1
38 #define VTK_DIRECTION_SPECIFIED_VECTOR 2
39
40 #define VTK_SORT_FIRST_POINT 0
41 #define VTK_SORT_BOUNDS_CENTER 1
42 #define VTK_SORT_PARAMETRIC_CENTER 2
43
44 class vtkCamera;
45 class vtkProp3D;
46 class vtkTransform;
47
48 class VTK_HYBRID_EXPORT vtkDepthSortPolyData : public vtkPolyDataToPolyDataFilter 
49 {
50 public:
51   // Description:
52   // Instantiate object.
53   static vtkDepthSortPolyData *New();
54
55   vtkTypeRevisionMacro(vtkDepthSortPolyData,vtkPolyDataToPolyDataFilter);
56   void PrintSelf(ostream& os, vtkIndent indent);
57
58   // Description:
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);}
69
70   // Description:
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);}
83
84   // Description:
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);
90
91   // Description:
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();
98
99   // Description:
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);
105
106   // Description:
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
110   // origin.
111   vtkSetVector3Macro(Origin,double);
112   vtkGetVectorMacro(Origin,double,3);
113
114   // Description:
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);
122
123   // Description:
124   // Return MTime also considering the dependent objects: the camera
125   // and/or the prop3D.
126   unsigned long GetMTime();
127
128 protected:
129   vtkDepthSortPolyData();
130   ~vtkDepthSortPolyData();
131
132   void Execute();
133   void ComputeProjectionVector(double vector[3], double origin[3]);
134
135   int Direction;
136   int DepthSortMode;
137   vtkCamera *Camera;
138   vtkProp3D *Prop3D;
139   vtkTransform *Transform;
140   double Vector[3];
141   double Origin[3];
142   int SortScalars;
143   
144 private:
145   vtkDepthSortPolyData(const vtkDepthSortPolyData&);  // Not implemented.
146   void operator=(const vtkDepthSortPolyData&);  // Not implemented.
147 };
148
149 #endif