VTK
dox/Filters/Core/vtkDataObjectToDataSetFilter.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    vtkDataObjectToDataSetFilter.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 =========================================================================*/
00070 #ifndef __vtkDataObjectToDataSetFilter_h
00071 #define __vtkDataObjectToDataSetFilter_h
00072 
00073 #include "vtkFiltersCoreModule.h" // For export macro
00074 #include "vtkDataSetAlgorithm.h"
00075 
00076 class vtkCellArray;
00077 class vtkDataArray;
00078 class vtkDataSet;
00079 class vtkPointSet;
00080 class vtkPolyData;
00081 class vtkRectilinearGrid;
00082 class vtkStructuredGrid;
00083 class vtkStructuredPoints;
00084 class vtkUnstructuredGrid;
00085 
00086 class VTKFILTERSCORE_EXPORT vtkDataObjectToDataSetFilter : public vtkDataSetAlgorithm
00087 {
00088 public:
00089   static vtkDataObjectToDataSetFilter *New();
00090   vtkTypeMacro(vtkDataObjectToDataSetFilter,vtkDataSetAlgorithm);
00091   void PrintSelf(ostream& os, vtkIndent indent);
00092 
00094   vtkDataObject *GetInput();
00095 
00097 
00098   void SetDataSetType(int);
00099   vtkGetMacro(DataSetType,int);
00100   void SetDataSetTypeToPolyData() {
00101     this->SetDataSetType(VTK_POLY_DATA);};
00102   void SetDataSetTypeToStructuredPoints() {
00103     this->SetDataSetType(VTK_STRUCTURED_POINTS);};
00104   void SetDataSetTypeToStructuredGrid() {
00105     this->SetDataSetType(VTK_STRUCTURED_GRID);};
00106   void SetDataSetTypeToRectilinearGrid() {
00107     this->SetDataSetType(VTK_RECTILINEAR_GRID);};
00108   void SetDataSetTypeToUnstructuredGrid() {
00109     this->SetDataSetType(VTK_UNSTRUCTURED_GRID);};
00111 
00113 
00118   vtkDataSet *GetOutput();
00119   vtkDataSet *GetOutput(int idx);
00120   vtkPolyData *GetPolyDataOutput();
00121   vtkStructuredPoints *GetStructuredPointsOutput();
00122   vtkStructuredGrid *GetStructuredGridOutput();
00123   vtkUnstructuredGrid *GetUnstructuredGridOutput();
00124   vtkRectilinearGrid *GetRectilinearGridOutput();
00126 
00128 
00139   void SetPointComponent(int comp, char *arrayName, int arrayComp,
00140                          int min, int max, int normalize);
00141   void SetPointComponent(int comp, char *arrayName, int arrayComp)
00142     {this->SetPointComponent(comp, arrayName, arrayComp, -1, -1, this->DefaultNormalize);};
00143   const char *GetPointComponentArrayName(int comp);
00144   int GetPointComponentArrayComponent(int comp);
00145   int GetPointComponentMinRange(int comp);
00146   int GetPointComponentMaxRange(int comp);
00147   int GetPointComponentNormailzeFlag(int comp);
00149 
00151 
00158   void SetVertsComponent(char *arrayName, int arrayComp, int min, int max);
00159   void SetVertsComponent(char *arrayName, int arrayComp)
00160     {this->SetVertsComponent(arrayName, arrayComp, -1, -1);};
00161   const char *GetVertsComponentArrayName();
00162   int GetVertsComponentArrayComponent();
00163   int GetVertsComponentMinRange();
00164   int GetVertsComponentMaxRange();
00165   void SetLinesComponent(char *arrayName, int arrayComp, int min, int max);
00166   void SetLinesComponent(char *arrayName, int arrayComp)
00167     {this->SetLinesComponent(arrayName, arrayComp, -1, -1);};
00168   const char *GetLinesComponentArrayName();
00169   int GetLinesComponentArrayComponent();
00170   int GetLinesComponentMinRange();
00171   int GetLinesComponentMaxRange();
00172   void SetPolysComponent(char *arrayName, int arrayComp, int min, int max);
00173   void SetPolysComponent(char *arrayName, int arrayComp)
00174     {this->SetPolysComponent(arrayName, arrayComp, -1, -1);};
00175   const char *GetPolysComponentArrayName();
00176   int GetPolysComponentArrayComponent();
00177   int GetPolysComponentMinRange();
00178   int GetPolysComponentMaxRange();
00179   void SetStripsComponent(char *arrayName, int arrayComp, int min, int max);
00180   void SetStripsComponent(char *arrayName, int arrayComp)
00181     {this->SetStripsComponent(arrayName, arrayComp, -1, -1);};
00182   const char *GetStripsComponentArrayName();
00183   int GetStripsComponentArrayComponent();
00184   int GetStripsComponentMinRange();
00185   int GetStripsComponentMaxRange();
00187 
00189 
00196   void SetCellTypeComponent(char *arrayName, int arrayComp,
00197                             int min, int max);
00198   void SetCellTypeComponent(char *arrayName, int arrayComp)
00199     {this->SetCellTypeComponent(arrayName, arrayComp, -1, -1);};
00200   const char *GetCellTypeComponentArrayName();
00201   int GetCellTypeComponentArrayComponent();
00202   int GetCellTypeComponentMinRange();
00203   int GetCellTypeComponentMaxRange();
00204   void SetCellConnectivityComponent(char *arrayName, int arrayComp,
00205                                     int min, int max);
00206   void SetCellConnectivityComponent(char *arrayName, int arrayComp)
00207     {this->SetCellConnectivityComponent(arrayName, arrayComp, -1, -1);};
00208   const char *GetCellConnectivityComponentArrayName();
00209   int GetCellConnectivityComponentArrayComponent();
00210   int GetCellConnectivityComponentMinRange();
00211   int GetCellConnectivityComponentMaxRange();
00213 
00215 
00217   vtkSetMacro(DefaultNormalize,int);
00218   vtkGetMacro(DefaultNormalize,int);
00219   vtkBooleanMacro(DefaultNormalize,int);
00221 
00223 
00226   vtkSetVector3Macro(Dimensions,int);
00227   vtkGetVectorMacro(Dimensions,int,3);
00229 
00231 
00233   vtkSetVector3Macro(Origin,double);
00234   vtkGetVectorMacro(Origin,double,3);
00236 
00238 
00240   vtkSetVector3Macro(Spacing,double);
00241   vtkGetVectorMacro(Spacing,double,3);
00243 
00245 
00250   void SetDimensionsComponent(char *arrayName, int arrayComp, int min, int max);
00251   void SetDimensionsComponent(char *arrayName, int arrayComp)
00252     {this->SetDimensionsComponent(arrayName, arrayComp, -1, -1);};
00253   void SetSpacingComponent(char *arrayName, int arrayComp, int min, int max);
00254   void SetSpacingComponent(char *arrayName, int arrayComp)
00255     {this->SetSpacingComponent(arrayName, arrayComp, -1, -1);};
00256   void SetOriginComponent(char *arrayName, int arrayComp, int min, int max);
00257   void SetOriginComponent(char *arrayName, int arrayComp)
00258     {this->SetOriginComponent(arrayName, arrayComp, -1, -1);};
00260 
00261 protected:
00262   vtkDataObjectToDataSetFilter();
00263   ~vtkDataObjectToDataSetFilter();
00264 
00265   virtual int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *); //generate output data
00266   virtual int RequestInformation(vtkInformation *, vtkInformationVector **, vtkInformationVector *);
00267   virtual int RequestUpdateExtent(vtkInformation *, vtkInformationVector **, vtkInformationVector *);
00268   virtual int FillInputPortInformation(int port, vtkInformation *info);
00269   virtual int RequestDataObject(vtkInformation *, vtkInformationVector **,
00270                                 vtkInformationVector *);
00271 
00272   char Updating;
00273 
00274   // control flags used to generate the output dataset
00275   int DataSetType; //the type of dataset to generate
00276 
00277   // Support definition of points
00278   char *PointArrays[3]; //the name of the arrays
00279   int PointArrayComponents[3]; //the array components used for x-y-z
00280   vtkIdType PointComponentRange[3][2]; //the range of the components to use
00281   int PointNormalize[3]; //flags control normalization
00282 
00283   // These define cells for vtkPolyData
00284   char *VertsArray; //the name of the array
00285   int VertsArrayComponent; //the array component
00286   vtkIdType VertsComponentRange[2]; //the range of the components to use
00287 
00288   char *LinesArray; //the name of the array
00289   int LinesArrayComponent; //the array component used for cell types
00290   vtkIdType LinesComponentRange[2]; //the range of the components to use
00291 
00292   char *PolysArray; //the name of the array
00293   int PolysArrayComponent; //the array component
00294   vtkIdType PolysComponentRange[2]; //the range of the components to use
00295 
00296   char *StripsArray; //the name of the array
00297   int StripsArrayComponent; //the array component
00298   vtkIdType StripsComponentRange[2]; //the range of the components to use
00299 
00300   // Used to define vtkUnstructuredGrid datasets
00301   char *CellTypeArray; //the name of the array
00302   int CellTypeArrayComponent; //the array component used for cell types
00303   vtkIdType CellTypeComponentRange[2]; //the range of the components to use
00304 
00305   char *CellConnectivityArray; //the name of the array
00306   int CellConnectivityArrayComponent; //the array components used for cell connectivity
00307   vtkIdType CellConnectivityComponentRange[2]; //the range of the components to use
00308 
00309   // helper methods (and attributes) to construct datasets
00310   void SetArrayName(char* &name, char *newName);
00311   vtkIdType ConstructPoints(vtkDataObject *input, vtkPointSet *ps);
00312   vtkIdType ConstructPoints(vtkDataObject *input, vtkRectilinearGrid *rg);
00313   int ConstructCells(vtkDataObject *input, vtkPolyData *pd);
00314   int ConstructCells(vtkDataObject *input, vtkUnstructuredGrid *ug);
00315   vtkCellArray *ConstructCellArray(vtkDataArray *da, int comp,
00316                                    vtkIdType compRange[2]);
00317 
00318   // Default value for normalization
00319   int DefaultNormalize;
00320 
00321   // Couple of different ways to specify dimensions, spacing, and origin.
00322   int Dimensions[3];
00323   double Origin[3];
00324   double Spacing[3];
00325 
00326   char *DimensionsArray; //the name of the array
00327   int DimensionsArrayComponent; //the component of the array used for dimensions
00328   vtkIdType DimensionsComponentRange[2]; //the ComponentRange of the array for the dimensions
00329 
00330   char *OriginArray; //the name of the array
00331   int OriginArrayComponent; //the component of the array used for Origins
00332   vtkIdType OriginComponentRange[2]; //the ComponentRange of the array for the Origins
00333 
00334   char *SpacingArray; //the name of the array
00335   int SpacingArrayComponent; //the component of the array used for Spacings
00336   vtkIdType SpacingComponentRange[2]; //the ComponentRange of the array for the Spacings
00337 
00338   void ConstructDimensions(vtkDataObject *input);
00339   void ConstructSpacing(vtkDataObject *input);
00340   void ConstructOrigin(vtkDataObject *input);
00341 
00342 private:
00343   vtkDataObjectToDataSetFilter(const vtkDataObjectToDataSetFilter&);  // Not implemented.
00344   void operator=(const vtkDataObjectToDataSetFilter&);  // Not implemented.
00345 };
00346 
00347 #endif