Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members | Related Pages

vtkDataSetAttributes.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    $RCSfile: vtkDataSetAttributes.h,v $
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 =========================================================================*/
00032 #ifndef __vtkDataSetAttributes_h
00033 #define __vtkDataSetAttributes_h
00034 
00035 #include "vtkFieldData.h"
00036 
00037 class VTK_FILTERING_EXPORT vtkDataSetAttributes : public vtkFieldData
00038 {
00039 public:
00041   static vtkDataSetAttributes *New();
00042   
00043   vtkTypeRevisionMacro(vtkDataSetAttributes,vtkFieldData);
00044   void PrintSelf(ostream& os, vtkIndent indent);
00045 
00048   virtual void Initialize();
00049 
00052   virtual void Update() {}
00053 
00060   virtual void PassData(vtkFieldData* fd);
00061 
00063 
00070   void CopyAllocate(vtkDataSetAttributes* pd, vtkIdType sze=0,
00071                     vtkIdType ext=1000);
00073 
00081   void CopyData(vtkDataSetAttributes *fromPd, vtkIdType fromId, vtkIdType toId);
00082 
00084 
00087   void InterpolateAllocate(vtkDataSetAttributes* pd, vtkIdType sze=0,
00088                            vtkIdType ext=1000);
00090   
00092 
00096   void CopyStructuredData(vtkDataSetAttributes *inDsa,
00097                           const int *inExt, const int *outExt);
00099 
00101 
00103   void InterpolatePoint(vtkDataSetAttributes *fromPd, vtkIdType toId, 
00104                         vtkIdList *ids, double *weights);
00106   
00108 
00112   void InterpolateEdge(vtkDataSetAttributes *fromPd, vtkIdType toId,
00113                        vtkIdType p1, vtkIdType p2, double t);
00115 
00117 
00124   void InterpolateTime(vtkDataSetAttributes *from1, 
00125                        vtkDataSetAttributes *from2,
00126                        vtkIdType id, double t);
00128 
00131   virtual void DeepCopy(vtkFieldData *pd);
00132 
00134   virtual void ShallowCopy(vtkFieldData *pd);
00135 
00137 
00138   int SetScalars(vtkDataArray* da);
00139   int SetActiveScalars(const char* name);
00140   vtkDataArray* GetScalars();
00142 
00144 
00145   int SetVectors(vtkDataArray* da);
00146   int SetActiveVectors(const char* name);
00147   vtkDataArray* GetVectors();
00149 
00151 
00152   int SetNormals(vtkDataArray* da);
00153   int SetActiveNormals(const char* name);
00154   vtkDataArray* GetNormals();
00156 
00158 
00159   int SetTCoords(vtkDataArray* da);
00160   int SetActiveTCoords(const char* name);
00161   vtkDataArray* GetTCoords();
00163 
00165 
00166   int SetTensors(vtkDataArray* da);
00167   int SetActiveTensors(const char* name);
00168   vtkDataArray* GetTensors();
00170 
00172 
00175   vtkDataArray* GetScalars(const char* name);
00176   vtkDataArray* GetVectors(const char* name);
00177   vtkDataArray* GetNormals(const char* name);
00178   vtkDataArray* GetTCoords(const char* name);
00179   vtkDataArray* GetTensors(const char* name);
00181 
00188   int SetActiveAttribute(const char* name, int attributeType);
00189 
00191   int SetActiveAttribute(int index, int attributeType);
00192 
00194   void SetCopyAttribute (int index, int value);
00195 
00197 
00203   void SetCopyScalars(int i);
00204   int GetCopyScalars();
00205   vtkBooleanMacro(CopyScalars, int);
00207 
00209 
00215   void SetCopyVectors(int i);
00216   int GetCopyVectors();
00217   vtkBooleanMacro(CopyVectors, int);
00219 
00221 
00227   void SetCopyNormals(int i);
00228   int GetCopyNormals();
00229   vtkBooleanMacro(CopyNormals, int);
00231 
00233 
00239   void SetCopyTCoords(int i);
00240   int GetCopyTCoords();
00241   vtkBooleanMacro(CopyTCoords, int);
00243 
00245 
00251   void SetCopyTensors(int i);
00252   int GetCopyTensors();
00253   vtkBooleanMacro(CopyTensors, int);
00255 
00262   virtual void CopyAllOn();
00263 
00270   virtual void CopyAllOff();
00271 
00273 
00277   void CopyTuple(vtkDataArray *fromData, vtkDataArray *toData, 
00278                  vtkIdType fromId, vtkIdType toId);
00280 
00283   void GetAttributeIndices(int* indexArray);
00284 
00289   int IsArrayAnAttribute(int idx);
00290 
00293   vtkDataArray* GetAttribute(int attributeType);
00294 
00296   virtual void RemoveArray(const char *name);
00297 
00299 
00301   static const char* GetAttributeTypeAsString(int attributeType);
00302   static const char* GetLongAttributeTypeAsString(int attributeType);
00304 
00305 //BTX
00306   // Always keep NUM_ATTRIBUTES as the last entry
00307   enum AttributeTypes 
00308   {
00309     SCALARS=0,
00310     VECTORS=1,
00311     NORMALS=2,
00312     TCOORDS=3,
00313     TENSORS=4,
00314     NUM_ATTRIBUTES
00315   };
00316 
00317   enum AttributeLimitTypes 
00318   {
00319     MAX, 
00320     EXACT, 
00321     NOLIMIT
00322   };
00323 
00324   class FieldList;
00325 
00327 
00329   void CopyAllocate(vtkDataSetAttributes::FieldList& list, vtkIdType sze=0, 
00330                     vtkIdType ext=1000);
00332 
00334 
00338   void CopyData(vtkDataSetAttributes::FieldList& list, 
00339                 vtkDataSetAttributes* dsa, int idx, vtkIdType fromId,
00340                 vtkIdType toId);
00342 
00343   friend class vtkDataSetAttributes::FieldList;
00344 //ETX
00345 
00346 protected:
00347   vtkDataSetAttributes();
00348   ~vtkDataSetAttributes();
00349 
00350   // special methods to support managing data
00351   void InterpolateTuple(vtkDataArray *fromData, vtkDataArray *toData,
00352                         vtkIdType toId, vtkIdList *ptIds, double *weights);
00353   void InterpolateTuple(vtkDataArray *fromData, vtkDataArray *toData,
00354                         vtkIdType toId, vtkIdType id1, vtkIdType id2, 
00355                         double t);
00356   void InterpolateTuple(vtkDataArray *fromData1, vtkDataArray *fromData2, 
00357                         vtkDataArray *toData, vtkIdType id, double t);
00358 
00360   virtual void InitializeFields();
00361 
00362   int AttributeIndices[NUM_ATTRIBUTES]; //index to attribute array in field data
00363   int CopyAttributeFlags[NUM_ATTRIBUTES]; //copy flag for attribute data
00364 
00365 //BTX
00366   vtkFieldData::BasicIterator RequiredArrays;
00367 //ETX
00368 
00369   int* TargetIndices;
00370 
00371   virtual void RemoveArray(int index);
00372 
00373   static const int NumberOfAttributeComponents[NUM_ATTRIBUTES];
00374   static const int AttributeLimits[NUM_ATTRIBUTES];
00375   static const char AttributeNames[NUM_ATTRIBUTES][10];
00376   static const char LongAttributeNames[NUM_ATTRIBUTES][35];
00377 
00378 private:
00379   int SetAttribute(vtkDataArray* da, int attributeType);
00380   static int CheckNumberOfComponents(vtkDataArray* da, int attributeType);
00381 
00382 //BTX
00383   vtkFieldData::BasicIterator  ComputeRequiredArrays(vtkDataSetAttributes* pd);
00384 
00385 private:
00386   vtkDataSetAttributes(const vtkDataSetAttributes&);  // Not implemented.
00387   void operator=(const vtkDataSetAttributes&);  // Not implemented.
00388 
00389 public:
00390   // This public class is used to perform set operations, other misc. 
00391   // operations on fields. For example, vtkAppendFilter uses it to 
00392   // determine which attributes the input datasets share in common.
00393   class VTK_FILTERING_EXPORT FieldList
00394   {
00395   public:
00396     FieldList(int numInputs);
00397     ~FieldList();
00398 
00399     void InitializeFieldList(vtkDataSetAttributes* dsa);
00400     void IntersectFieldList(vtkDataSetAttributes* dsa);
00401 
00402     //Determine whether data is available
00403     int IsAttributePresent(int attrType); //true/false attributes specified
00404     
00405     // Accessor methods.
00406     int GetNumberOfFields() { return this->NumberOfFields; }
00407     int GetFieldIndex(int i) { return this->FieldIndices[i]; }
00408     int GetDSAIndex(int index, int i) { return this->DSAIndices[index][i]; }
00409     
00410     friend class vtkDataSetAttributes;
00411 
00412   protected:
00413     FieldList(const FieldList&) {} //prevent these methods from being used
00414     void operator=(const FieldList&) {}
00415 
00416   private:
00417     void SetField(int index, vtkDataArray *da);
00418     void RemoveField(const char *name);
00419     void ClearFields();
00420     
00421     //These keep track of what is common across datasets
00422     char** Fields; //the names of the fields (first five are named attributes)
00423     int *FieldTypes; //the types of the fields (first five are named 
00424                      //attributes)
00425     int *FieldComponents; //the number of components in each  fields 
00426                           // (first five are named attributes)
00427     int *FieldIndices; //output data array index 
00428                        // (first five are named attributes)
00429     vtkLookupTable **LUT; //luts associated with each array
00430     vtkIdType NumberOfTuples; //a running total of values
00431     int NumberOfFields; //the number of fields
00432     
00433     //For every vtkDataSetAttributes that are processed, keep track of the 
00434     //indices into various things. The indices are organized so that the
00435     //first NUM_ATTRIBUTES refer to attributes, the next refer to the 
00436     //non-attribute fields, for a total of NUM_ATTRIBUTES + NumberOfFields.
00437     //CurrentInput is the current input being processed.
00438     int **DSAIndices;
00439     int NumberOfDSAIndices;
00440     int CurrentInput;
00441   };
00442 
00443 //ETX
00444 };
00445 
00446 #endif
00447 
00448 

Generated on Mon Jan 21 23:07:19 2008 for VTK by  doxygen 1.4.3-20050530