ssDepthSortPolyData.h

Go to the documentation of this file.
00001 /* $Id: ssDepthSortPolyData.h,v 1.2 2005/05/11 11:40:12 pfb Exp $ */
00002 
00003 #ifndef __ssDepthSortPolyData_h
00004 #define __ssDepthSortPolyData_h
00005 
00010 /*=========================================================================
00011  * This file addapted (modified) from a file of Vtk V3.2 - pfb
00012  ==========================================================================*/
00013 
00014 /*=========================================================================
00015 
00016   Program:   Visualization Toolkit
00017   Module:    $RCSfile: ssDepthSortPolyData.h,v $
00018   Language:  C++
00019   Date:      $Date: 2005/05/11 11:40:12 $
00020   Version:   $Revision: 1.2 $
00021   Thanks:    Scott Hill for implementing this class
00022 
00023 
00024 Copyright (c) 1993-2001 Ken Martin, Will Schroeder, Bill Lorensen 
00025 All rights reserved.
00026 
00027 Redistribution and use in source and binary forms, with or without
00028 modification, are permitted provided that the following conditions are met:
00029 
00030  * Redistributions of source code must retain the above copyright notice,
00031    this list of conditions and the following disclaimer.
00032 
00033  * Redistributions in binary form must reproduce the above copyright notice,
00034    this list of conditions and the following disclaimer in the documentation
00035    and/or other materials provided with the distribution.
00036 
00037  * Neither name of Ken Martin, Will Schroeder, or Bill Lorensen nor the names
00038    of any contributors may be used to endorse or promote products derived
00039    from this software without specific prior written permission.
00040 
00041  * Modified source versions must be plainly marked as such, and must not be
00042    misrepresented as being the original software.
00043 
00044 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
00045 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00046 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00047 ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
00048 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00049 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
00050 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00051 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00052 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00053 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00054 
00055 =========================================================================*/
00066 // .SECTION Caveats
00067 // The sort operation will not work well for long, thin primitives, or cells
00068 // that intersect, overlap, or interpenetrate each other.
00069 
00070 
00071 #include <vtkPolyDataToPolyDataFilter.h>
00072 #include <vtkCamera.h>
00073 #include <vtkProp3D.h>
00074 #include <vtkTransform.h>
00075 
00076 class VTK_EXPORT ssDepthSortPolyData : public vtkPolyDataToPolyDataFilter 
00077 {
00078 public:
00082   enum SortMethod
00083     {
00084     SS_DIRECTION_BACK_TO_FRONT = 0,
00085     SS_DIRECTION_FRONT_TO_BACK,
00086     SS_DIRECTION_SPECIFIED_VECTOR
00087     };
00088 
00093   static ssDepthSortPolyData *New();
00094 
00095   vtkTypeMacro(ssDepthSortPolyData, vtkPolyDataToPolyDataFilter);
00096   void PrintSelf(ostream& os, vtkIndent indent);
00097 
00103   virtual void SetDirection(int arg)
00104     {
00105     this->Direction = arg;
00106     }
00107 
00114   virtual int GetDirection() const
00115     {
00116     return this->Direction;
00117     }
00118 
00122   void SetDirectionToFrontToBack()
00123     {
00124     this->SetDirection(SS_DIRECTION_FRONT_TO_BACK);
00125     };
00126 
00130   void SetDirectionToBackToFront()
00131     {
00132     this->SetDirection(SS_DIRECTION_BACK_TO_FRONT);
00133     };
00134 
00138   void SetDirectionToSpecifiedVector()
00139     {
00140     this->SetDirection(SS_DIRECTION_SPECIFIED_VECTOR);
00141     };
00142 
00149   virtual void SetCamera(vtkCamera *arg)
00150     {
00151     this->Camera = arg;
00152     }
00153 
00158   virtual vtkCamera *GetCamera() const
00159     {
00160     return this->Camera;
00161     }
00162 
00170   void SetProp3D(vtkProp3D *arg);
00171   vtkProp3D *GetProp3D();
00172 
00181   virtual void SetVector(double x, double y, double z)
00182     {
00183     this->Vector[0] = x;
00184     this->Vector[1] = y;
00185     this->Vector[2] = z;
00186     }
00187 
00194   virtual void SetVector(double x[3])
00195     {
00196     this->Vector[0] = x[0];
00197     this->Vector[1] = x[1];
00198     this->Vector[2] = x[2];
00199     }
00200 
00205   virtual const double *GetVector() const
00206     {
00207     return this->Vector;
00208     }
00209 
00214   virtual void GetVector(double x[3])
00215     {
00216     x[0] = this->Vector[0];
00217     x[1] = this->Vector[1];
00218     x[2] = this->Vector[2];
00219     }
00220 
00230   virtual void SetOrigin(double x, double y, double z)
00231     {
00232     this->Origin[0] = x;
00233     this->Origin[1] = y;
00234     this->Origin[2] = z;
00235     }
00236 
00244   virtual void SetOrigin(double x[3])
00245     {
00246     this->Origin[0] = x[0];
00247     this->Origin[1] = x[1];
00248     this->Origin[2] = x[2];
00249     }
00250 
00255   virtual const double *GetOrigin() const
00256     {
00257     return this->Origin;
00258     }
00259 
00264   virtual void GetOrigin(double x[3])
00265     {
00266     x[0] = this->Origin[0];
00267     x[1] = this->Origin[1];
00268     x[2] = this->Origin[2];
00269     }
00270 
00278   virtual void SetSortScalars(int arg)
00279     {
00280     this->SortScalars = arg;
00281     }
00282 
00287   virtual int GetSortScalars()
00288     {
00289     return this->SortScalars;
00290     }
00291 
00295   virtual void SortScalarsOn()
00296     {
00297     this->SetSortScalars(1);
00298     }
00299 
00303   virtual void SortScalarsOff()
00304     {
00305     this->SetSortScalars(0);
00306     }
00307 
00313   unsigned long GetMTime();
00314 
00315 protected:
00316   ssDepthSortPolyData();
00317   ~ssDepthSortPolyData();
00318   ssDepthSortPolyData(const ssDepthSortPolyData&) {};
00319   void operator=(const ssDepthSortPolyData&) {};
00320 
00324   void Execute();
00325 
00331   void ComputeProjectionVector(double vector[3], double origin[3]);
00332 
00333   int Direction;
00334   vtkCamera *Camera;
00335   vtkProp3D *Prop3D;
00336   vtkTransform *Transform;
00337   double Vector[3];
00338   double Origin[3];
00339   int SortScalars;
00340   
00341 };
00342 
00346 #endif