VTK
dox/Graphics/vtkGlyph3D.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    vtkGlyph3D.h
00005 
00006   Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
00007   All rights reserved.
00008   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
00009 
00010      This software is distributed WITHOUT ANY WARRANTY; without even
00011      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00012      PURPOSE.  See the above copyright notice for more information.
00013 
00014 =========================================================================*/
00085 #ifndef __vtkGlyph3D_h
00086 #define __vtkGlyph3D_h
00087 
00088 #include "vtkPolyDataAlgorithm.h"
00089 
00090 #define VTK_SCALE_BY_SCALAR 0
00091 #define VTK_SCALE_BY_VECTOR 1
00092 #define VTK_SCALE_BY_VECTORCOMPONENTS 2
00093 #define VTK_DATA_SCALING_OFF 3
00094 
00095 #define VTK_COLOR_BY_SCALE  0
00096 #define VTK_COLOR_BY_SCALAR 1
00097 #define VTK_COLOR_BY_VECTOR 2
00098 
00099 #define VTK_USE_VECTOR 0
00100 #define VTK_USE_NORMAL 1
00101 #define VTK_VECTOR_ROTATION_OFF 2
00102 
00103 #define VTK_INDEXING_OFF 0
00104 #define VTK_INDEXING_BY_SCALAR 1
00105 #define VTK_INDEXING_BY_VECTOR 2
00106 
00107 class vtkTransform;
00108 
00109 class VTK_GRAPHICS_EXPORT vtkGlyph3D : public vtkPolyDataAlgorithm
00110 {
00111 public:
00112   vtkTypeMacro(vtkGlyph3D,vtkPolyDataAlgorithm);
00113   void PrintSelf(ostream& os, vtkIndent indent);
00114 
00119   static vtkGlyph3D *New();
00120 
00123   void SetSource(vtkPolyData *pd) {this->SetSource(0,pd);};
00124 
00127   void SetSource(int id, vtkPolyData *pd);
00128 
00130 
00133   void SetSourceConnection(int id, vtkAlgorithmOutput* algOutput);
00134   void SetSourceConnection(vtkAlgorithmOutput* algOutput)
00135     {
00136       this->SetSourceConnection(0, algOutput);
00137     }
00139 
00141   vtkPolyData *GetSource(int id=0);
00142 
00144 
00145   vtkSetMacro(Scaling,int);
00146   vtkBooleanMacro(Scaling,int);
00147   vtkGetMacro(Scaling,int);
00149 
00151 
00152   vtkSetMacro(ScaleMode,int);
00153   vtkGetMacro(ScaleMode,int);
00154   void SetScaleModeToScaleByScalar()
00155     {this->SetScaleMode(VTK_SCALE_BY_SCALAR);};
00156   void SetScaleModeToScaleByVector()
00157     {this->SetScaleMode(VTK_SCALE_BY_VECTOR);};
00158   void SetScaleModeToScaleByVectorComponents()
00159     {this->SetScaleMode(VTK_SCALE_BY_VECTORCOMPONENTS);};
00160   void SetScaleModeToDataScalingOff()
00161     {this->SetScaleMode(VTK_DATA_SCALING_OFF);};
00162   const char *GetScaleModeAsString();
00164 
00166 
00167   vtkSetMacro(ColorMode,int);
00168   vtkGetMacro(ColorMode,int);
00169   void SetColorModeToColorByScale()
00170     {this->SetColorMode(VTK_COLOR_BY_SCALE);};
00171   void SetColorModeToColorByScalar()
00172     {this->SetColorMode(VTK_COLOR_BY_SCALAR);};
00173   void SetColorModeToColorByVector()
00174     {this->SetColorMode(VTK_COLOR_BY_VECTOR);};
00175   const char *GetColorModeAsString();
00177 
00179 
00180   vtkSetMacro(ScaleFactor,double);
00181   vtkGetMacro(ScaleFactor,double);
00183 
00185 
00186   vtkSetVector2Macro(Range,double);
00187   vtkGetVectorMacro(Range,double,2);
00189 
00191 
00192   vtkSetMacro(Orient,int);
00193   vtkBooleanMacro(Orient,int);
00194   vtkGetMacro(Orient,int);
00196 
00198 
00200   vtkSetMacro(Clamping,int);
00201   vtkBooleanMacro(Clamping,int);
00202   vtkGetMacro(Clamping,int);
00204 
00206 
00207   vtkSetMacro(VectorMode,int);
00208   vtkGetMacro(VectorMode,int);
00209   void SetVectorModeToUseVector() {this->SetVectorMode(VTK_USE_VECTOR);};
00210   void SetVectorModeToUseNormal() {this->SetVectorMode(VTK_USE_NORMAL);};
00211   void SetVectorModeToVectorRotationOff()
00212     {this->SetVectorMode(VTK_VECTOR_ROTATION_OFF);};
00213   const char *GetVectorModeAsString();
00215 
00217 
00223   vtkSetMacro(IndexMode,int);
00224   vtkGetMacro(IndexMode,int);
00225   void SetIndexModeToScalar() {this->SetIndexMode(VTK_INDEXING_BY_SCALAR);};
00226   void SetIndexModeToVector() {this->SetIndexMode(VTK_INDEXING_BY_VECTOR);};
00227   void SetIndexModeToOff() {this->SetIndexMode(VTK_INDEXING_OFF);};
00228   const char *GetIndexModeAsString();
00230 
00232 
00236   vtkSetMacro(GeneratePointIds,int);
00237   vtkGetMacro(GeneratePointIds,int);
00238   vtkBooleanMacro(GeneratePointIds,int);
00240 
00242 
00245   vtkSetStringMacro(PointIdsName);
00246   vtkGetStringMacro(PointIdsName);
00248 
00250 
00253   vtkSetMacro(FillCellData,int);
00254   vtkGetMacro(FillCellData,int);
00255   vtkBooleanMacro(FillCellData,int);
00257 
00260   virtual int IsPointVisible(vtkDataSet*, vtkIdType) {return 1;};
00261 
00263 
00266   void SetSourceTransform(vtkTransform*);
00267   vtkGetObjectMacro(SourceTransform, vtkTransform);
00269 
00271   virtual unsigned long GetMTime();
00272 
00273 protected:
00274   vtkGlyph3D();
00275   ~vtkGlyph3D();
00276 
00277   virtual int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *);
00278   virtual int RequestUpdateExtent(vtkInformation *, vtkInformationVector **, vtkInformationVector *);
00279   virtual int FillInputPortInformation(int, vtkInformation *);
00280 
00281   vtkPolyData* GetSource(int idx, vtkInformationVector *sourceInfo);
00282 
00283   vtkPolyData **Source; // Geometry to copy to each point
00284   int Scaling; // Determine whether scaling of geometry is performed
00285   int ScaleMode; // Scale by scalar value or vector magnitude
00286   int ColorMode; // new scalars based on scale, scalar or vector
00287   double ScaleFactor; // Scale factor to use to scale geometry
00288   double Range[2]; // Range to use to perform scalar scaling
00289   int Orient; // boolean controls whether to "orient" data
00290   int VectorMode; // Orient/scale via normal or via vector data
00291   int Clamping; // whether to clamp scale factor
00292   int IndexMode; // what to use to index into glyph table
00293   int GeneratePointIds; // produce input points ids for each output point
00294   int FillCellData; // whether to fill output cell data
00295   char *PointIdsName;
00296   vtkTransform* SourceTransform;
00297 
00298 private:
00299   vtkGlyph3D(const vtkGlyph3D&);  // Not implemented.
00300   void operator=(const vtkGlyph3D&);  // Not implemented.
00301 };
00302 
00304 
00305 inline const char *vtkGlyph3D::GetScaleModeAsString(void)
00306 {
00307   if ( this->ScaleMode == VTK_SCALE_BY_SCALAR )
00308     {
00309     return "ScaleByScalar";
00310     }
00311   else if ( this->ScaleMode == VTK_SCALE_BY_VECTOR ) 
00312     {
00313     return "ScaleByVector";
00314     }
00315   else 
00316     {
00317     return "DataScalingOff";
00318     }
00319 }
00321 
00323 
00324 inline const char *vtkGlyph3D::GetColorModeAsString(void)
00325 {
00326   if ( this->ColorMode == VTK_COLOR_BY_SCALAR )
00327     {
00328     return "ColorByScalar";
00329     }
00330   else if ( this->ColorMode == VTK_COLOR_BY_VECTOR ) 
00331     {
00332     return "ColorByVector";
00333     }
00334   else 
00335     {
00336     return "ColorByScale";
00337     }
00338 }
00340 
00342 
00343 inline const char *vtkGlyph3D::GetVectorModeAsString(void)
00344 {
00345   if ( this->VectorMode == VTK_USE_VECTOR) 
00346     {
00347     return "UseVector";
00348     }
00349   else if ( this->VectorMode == VTK_USE_NORMAL) 
00350     {
00351     return "UseNormal";
00352     }
00353   else 
00354     {
00355     return "VectorRotationOff";
00356     }
00357 }
00359 
00361 
00362 inline const char *vtkGlyph3D::GetIndexModeAsString(void)
00363 {
00364   if ( this->IndexMode == VTK_INDEXING_OFF) 
00365     {
00366     return "IndexingOff";
00367     }
00368   else if ( this->IndexMode == VTK_INDEXING_BY_SCALAR) 
00369     {
00370     return "IndexingByScalar";
00371     }
00372   else 
00373     {
00374     return "IndexingByVector";
00375     }
00376 }
00378 
00379 #endif