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

Common/vtkDataSetAttributes.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    $RCSfile: vtkDataSetAttributes.h,v $
00005   Language:  C++
00006 
00007   Copyright (c) 1993-2002 Ken Martin, Will Schroeder, Bill Lorensen 
00008   All rights reserved.
00009   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
00010 
00011      This software is distributed WITHOUT ANY WARRANTY; without even 
00012      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
00013      PURPOSE.  See the above copyright notice for more information.
00014 
00015 =========================================================================*/
00048 #ifndef __vtkDataSetAttributes_h
00049 #define __vtkDataSetAttributes_h
00050 
00051 #include "vtkFieldData.h"
00052 
00053 class VTK_COMMON_EXPORT vtkDataSetAttributes : public vtkFieldData
00054 {
00055 public:
00057   static vtkDataSetAttributes *New();
00058   
00059   vtkTypeRevisionMacro(vtkDataSetAttributes,vtkFieldData);
00060   void PrintSelf(ostream& os, vtkIndent indent);
00061 
00064   virtual void Initialize();
00065 
00068   virtual void Update() {}
00069 
00076   virtual void PassData(vtkFieldData* fd);
00077 
00079 
00086   void CopyAllocate(vtkDataSetAttributes* pd, vtkIdType sze=0,
00087                     vtkIdType ext=1000);
00089 
00097   void CopyData(vtkDataSetAttributes *fromPd, vtkIdType fromId, vtkIdType toId);
00098 
00100 
00103   void InterpolateAllocate(vtkDataSetAttributes* pd, vtkIdType sze=0,
00104                            vtkIdType ext=1000);
00106   
00108 
00112   void CopyStructuredData(vtkDataSetAttributes *inDsa,
00113                           const int *inExt, const int *outExt);
00115 
00117 
00119   void InterpolatePoint(vtkDataSetAttributes *fromPd, vtkIdType toId, 
00120                         vtkIdList *ids, float *weights);
00122   
00124 
00128   void InterpolateEdge(vtkDataSetAttributes *fromPd, vtkIdType toId,
00129                        vtkIdType p1, vtkIdType p2, float t);
00131 
00133 
00140   void InterpolateTime(vtkDataSetAttributes *from1, 
00141                        vtkDataSetAttributes *from2,
00142                        vtkIdType id, float t);
00144 
00147   virtual void DeepCopy(vtkFieldData *pd);
00148 
00150   virtual void ShallowCopy(vtkFieldData *pd);
00151 
00153 
00154   int SetScalars(vtkDataArray* da);
00155   int SetActiveScalars(const char* name);
00156   vtkDataArray* GetScalars();
00158 
00160 
00161   int SetVectors(vtkDataArray* da);
00162   int SetActiveVectors(const char* name);
00163   vtkDataArray* GetVectors();
00165 
00167 
00168   int SetNormals(vtkDataArray* da);
00169   int SetActiveNormals(const char* name);
00170   vtkDataArray* GetNormals();
00172 
00174 
00175   int SetTCoords(vtkDataArray* da);
00176   int SetActiveTCoords(const char* name);
00177   vtkDataArray* GetTCoords();
00179 
00181 
00182   int SetTensors(vtkDataArray* da);
00183   int SetActiveTensors(const char* name);
00184   vtkDataArray* GetTensors();
00186 
00188 
00191   vtkDataArray* GetScalars(const char* name);
00192   vtkDataArray* GetVectors(const char* name);
00193   vtkDataArray* GetNormals(const char* name);
00194   vtkDataArray* GetTCoords(const char* name);
00195   vtkDataArray* GetTensors(const char* name);
00197 
00204   int SetActiveAttribute(const char* name, int attributeType);
00205 
00207   int SetActiveAttribute(int index, int attributeType);
00208 
00210   void SetCopyAttribute (int index, int value);
00211 
00213 
00219   void SetCopyScalars(int i);
00220   int GetCopyScalars();
00221   vtkBooleanMacro(CopyScalars, int);
00223 
00225 
00231   void SetCopyVectors(int i);
00232   int GetCopyVectors();
00233   vtkBooleanMacro(CopyVectors, int);
00235 
00237 
00243   void SetCopyNormals(int i);
00244   int GetCopyNormals();
00245   vtkBooleanMacro(CopyNormals, int);
00247 
00249 
00255   void SetCopyTCoords(int i);
00256   int GetCopyTCoords();
00257   vtkBooleanMacro(CopyTCoords, int);
00259 
00261 
00267   void SetCopyTensors(int i);
00268   int GetCopyTensors();
00269   vtkBooleanMacro(CopyTensors, int);
00271 
00278   virtual void CopyAllOn();
00279 
00286   virtual void CopyAllOff();
00287 
00289 
00293   void CopyTuple(vtkDataArray *fromData, vtkDataArray *toData, 
00294                  vtkIdType fromId, vtkIdType toId);
00296 
00299   void GetAttributeIndices(int* indexArray);
00300 
00305   int IsArrayAnAttribute(int idx);
00306 
00309   vtkDataArray* GetAttribute(int attributeType);
00310 
00312   virtual void RemoveArray(const char *name);
00313 
00316   static const char* GetAttributeTypeAsString(int attributeType);
00317 
00318 //BTX
00319   // Always keep NUM_ATTRIBUTES as the last entry
00320   enum AttributeTypes 
00321   {
00322     SCALARS=0,
00323     VECTORS=1,
00324     NORMALS=2,
00325     TCOORDS=3,
00326     TENSORS=4,
00327     NUM_ATTRIBUTES
00328   };
00329 
00330   enum AttributeLimitTypes 
00331   {
00332     MAX, 
00333     EXACT, 
00334     NOLIMIT
00335   };
00336 
00337   class FieldList;
00338 
00340 
00342   void CopyAllocate(vtkDataSetAttributes::FieldList& list, vtkIdType sze=0, 
00343                     vtkIdType ext=1000);
00345 
00347 
00351   void CopyData(vtkDataSetAttributes::FieldList& list, 
00352                 vtkDataSetAttributes* dsa, int idx, vtkIdType fromId,
00353                 vtkIdType toId);
00355 
00356   friend class vtkDataSetAttributes::FieldList;
00357 //ETX
00358 
00359 protected:
00360   vtkDataSetAttributes();
00361   ~vtkDataSetAttributes();
00362 
00363   // special methods to support managing data
00364   void InterpolateTuple(vtkDataArray *fromData, vtkDataArray *toData,
00365                         vtkIdType toId, vtkIdList *ptIds, float *weights);
00366   void InterpolateTuple(vtkDataArray *fromData, vtkDataArray *toData,
00367                         vtkIdType toId, vtkIdType id1, vtkIdType id2, float t);
00368   void InterpolateTuple(vtkDataArray *fromData1, vtkDataArray *fromData2, 
00369                         vtkDataArray *toData, vtkIdType id, float t);
00370 
00372   virtual void InitializeFields();
00373 
00374   int AttributeIndices[NUM_ATTRIBUTES]; //index to attribute array in field data
00375   int CopyAttributeFlags[NUM_ATTRIBUTES]; //copy flag for attribute data
00376 
00377 //BTX
00378   vtkFieldData::BasicIterator RequiredArrays;
00379 //ETX
00380 
00381   int* TargetIndices;
00382 
00383   virtual void RemoveArray(int index);
00384 
00385   static const int NumberOfAttributeComponents[NUM_ATTRIBUTES];
00386   static const int AttributeLimits[NUM_ATTRIBUTES];
00387   static const char AttributeNames[NUM_ATTRIBUTES][10];
00388 
00389 private:
00390   int SetAttribute(vtkDataArray* da, int attributeType);
00391   static int CheckNumberOfComponents(vtkDataArray* da, int attributeType);
00392 
00393 //BTX
00394   vtkFieldData::BasicIterator  ComputeRequiredArrays(vtkDataSetAttributes* pd);
00395 
00396 private:
00397   vtkDataSetAttributes(const vtkDataSetAttributes&);  // Not implemented.
00398   void operator=(const vtkDataSetAttributes&);  // Not implemented.
00399 
00400 public:
00401   // This public class is used to perform set operations, other misc. 
00402   // operations on fields. For example, vtkAppendFilter uses it to 
00403   // determine which attributes the input datasets share in common.
00404   class VTK_COMMON_EXPORT FieldList
00405   {
00406   public:
00407     FieldList(int numInputs);
00408     ~FieldList();
00409 
00410     void InitializeFieldList(vtkDataSetAttributes* dsa);
00411     void IntersectFieldList(vtkDataSetAttributes* dsa);
00412 
00413     //Determine whether data is available
00414     int IsAttributePresent(int attrType); //true/false attributes specified
00415     
00416     // Accessor methods.
00417     int GetNumberOfFields() { return this->NumberOfFields; }
00418     int GetFieldIndex(int i) { return this->FieldIndices[i]; }
00419     int GetDSAIndex(int index, int i) { return this->DSAIndices[index][i]; }
00420     
00421     friend class vtkDataSetAttributes;
00422 
00423   protected:
00424     FieldList(const FieldList&) {} //prevent these methods from being used
00425     void operator=(const FieldList&) {}
00426 
00427   private:
00428     void SetField(int index, vtkDataArray *da);
00429     void RemoveField(const char *name);
00430     void ClearFields();
00431     
00432     //These keep track of what is common across datasets
00433     char** Fields; //the names of the fields (first five are named attributes)
00434     int *FieldTypes; //the types of the fields (first five are named 
00435                      //attributes)
00436     int *FieldComponents; //the number of components in each  fields 
00437                           // (first five are named attributes)
00438     int *FieldIndices; //output data array index 
00439                        // (first five are named attributes)
00440     vtkLookupTable **LUT; //luts associated with each array
00441     vtkIdType NumberOfTuples; //a running total of values
00442     int NumberOfFields; //the number of fields
00443     
00444     //For every vtkDataSetAttributes that are processed, keep track of the 
00445     //indices into various things. The indices are organized so that the
00446     //first NUM_ATTRIBUTES refer to attributes, the next refer to the 
00447     //non-attribute fields, for a total of NUM_ATTRIBUTES + NumberOfFields.
00448     //CurrentInput is the current input being processed.
00449     int **DSAIndices;
00450     int NumberOfDSAIndices;
00451     int CurrentInput;
00452   };
00453 
00454 //ETX
00455 };
00456 
00457 #endif
00458 
00459