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

dox/Common/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_COMMON_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 00300 static const char* GetAttributeTypeAsString(int attributeType); 00301 00302 //BTX 00303 // Always keep NUM_ATTRIBUTES as the last entry 00304 enum AttributeTypes 00305 { 00306 SCALARS=0, 00307 VECTORS=1, 00308 NORMALS=2, 00309 TCOORDS=3, 00310 TENSORS=4, 00311 NUM_ATTRIBUTES 00312 }; 00313 00314 enum AttributeLimitTypes 00315 { 00316 MAX, 00317 EXACT, 00318 NOLIMIT 00319 }; 00320 00321 class FieldList; 00322 00324 00326 void CopyAllocate(vtkDataSetAttributes::FieldList& list, vtkIdType sze=0, 00327 vtkIdType ext=1000); 00329 00331 00335 void CopyData(vtkDataSetAttributes::FieldList& list, 00336 vtkDataSetAttributes* dsa, int idx, vtkIdType fromId, 00337 vtkIdType toId); 00339 00340 friend class vtkDataSetAttributes::FieldList; 00341 //ETX 00342 00343 protected: 00344 vtkDataSetAttributes(); 00345 ~vtkDataSetAttributes(); 00346 00347 // special methods to support managing data 00348 void InterpolateTuple(vtkDataArray *fromData, vtkDataArray *toData, 00349 vtkIdType toId, vtkIdList *ptIds, double *weights); 00350 void InterpolateTuple(vtkDataArray *fromData, vtkDataArray *toData, 00351 vtkIdType toId, vtkIdType id1, vtkIdType id2, 00352 double t); 00353 void InterpolateTuple(vtkDataArray *fromData1, vtkDataArray *fromData2, 00354 vtkDataArray *toData, vtkIdType id, double t); 00355 00357 virtual void InitializeFields(); 00358 00359 int AttributeIndices[NUM_ATTRIBUTES]; //index to attribute array in field data 00360 int CopyAttributeFlags[NUM_ATTRIBUTES]; //copy flag for attribute data 00361 00362 //BTX 00363 vtkFieldData::BasicIterator RequiredArrays; 00364 //ETX 00365 00366 int* TargetIndices; 00367 00368 virtual void RemoveArray(int index); 00369 00370 static const int NumberOfAttributeComponents[NUM_ATTRIBUTES]; 00371 static const int AttributeLimits[NUM_ATTRIBUTES]; 00372 static const char AttributeNames[NUM_ATTRIBUTES][10]; 00373 00374 private: 00375 int SetAttribute(vtkDataArray* da, int attributeType); 00376 static int CheckNumberOfComponents(vtkDataArray* da, int attributeType); 00377 00378 //BTX 00379 vtkFieldData::BasicIterator ComputeRequiredArrays(vtkDataSetAttributes* pd); 00380 00381 private: 00382 vtkDataSetAttributes(const vtkDataSetAttributes&); // Not implemented. 00383 void operator=(const vtkDataSetAttributes&); // Not implemented. 00384 00385 public: 00386 // This public class is used to perform set operations, other misc. 00387 // operations on fields. For example, vtkAppendFilter uses it to 00388 // determine which attributes the input datasets share in common. 00389 class VTK_COMMON_EXPORT FieldList 00390 { 00391 public: 00392 FieldList(int numInputs); 00393 ~FieldList(); 00394 00395 void InitializeFieldList(vtkDataSetAttributes* dsa); 00396 void IntersectFieldList(vtkDataSetAttributes* dsa); 00397 00398 //Determine whether data is available 00399 int IsAttributePresent(int attrType); //true/false attributes specified 00400 00401 // Accessor methods. 00402 int GetNumberOfFields() { return this->NumberOfFields; } 00403 int GetFieldIndex(int i) { return this->FieldIndices[i]; } 00404 int GetDSAIndex(int index, int i) { return this->DSAIndices[index][i]; } 00405 00406 friend class vtkDataSetAttributes; 00407 00408 protected: 00409 FieldList(const FieldList&) {} //prevent these methods from being used 00410 void operator=(const FieldList&) {} 00411 00412 private: 00413 void SetField(int index, vtkDataArray *da); 00414 void RemoveField(const char *name); 00415 void ClearFields(); 00416 00417 //These keep track of what is common across datasets 00418 char** Fields; //the names of the fields (first five are named attributes) 00419 int *FieldTypes; //the types of the fields (first five are named 00420 //attributes) 00421 int *FieldComponents; //the number of components in each fields 00422 // (first five are named attributes) 00423 int *FieldIndices; //output data array index 00424 // (first five are named attributes) 00425 vtkLookupTable **LUT; //luts associated with each array 00426 vtkIdType NumberOfTuples; //a running total of values 00427 int NumberOfFields; //the number of fields 00428 00429 //For every vtkDataSetAttributes that are processed, keep track of the 00430 //indices into various things. The indices are organized so that the 00431 //first NUM_ATTRIBUTES refer to attributes, the next refer to the 00432 //non-attribute fields, for a total of NUM_ATTRIBUTES + NumberOfFields. 00433 //CurrentInput is the current input being processed. 00434 int **DSAIndices; 00435 int NumberOfDSAIndices; 00436 int CurrentInput; 00437 }; 00438 00439 //ETX 00440 }; 00441 00442 #endif 00443 00444