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 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 =========================================================================*/ 00036 #ifndef __vtkDataSetAttributes_h 00037 #define __vtkDataSetAttributes_h 00038 00039 #include "vtkFieldData.h" 00040 00041 class VTK_COMMON_EXPORT vtkDataSetAttributes : public vtkFieldData 00042 { 00043 public: 00045 static vtkDataSetAttributes *New(); 00046 00047 vtkTypeRevisionMacro(vtkDataSetAttributes,vtkFieldData); 00048 void PrintSelf(ostream& os, vtkIndent indent); 00049 00052 virtual void Initialize(); 00053 00056 virtual void Update() {} 00057 00064 virtual void PassData(vtkFieldData* fd); 00065 00067 00074 void CopyAllocate(vtkDataSetAttributes* pd, vtkIdType sze=0, 00075 vtkIdType ext=1000); 00077 00085 void CopyData(vtkDataSetAttributes *fromPd, vtkIdType fromId, vtkIdType toId); 00086 00088 00091 void InterpolateAllocate(vtkDataSetAttributes* pd, vtkIdType sze=0, 00092 vtkIdType ext=1000); 00094 00096 00100 void CopyStructuredData(vtkDataSetAttributes *inDsa, 00101 const int *inExt, const int *outExt); 00103 00105 00107 void InterpolatePoint(vtkDataSetAttributes *fromPd, vtkIdType toId, 00108 vtkIdList *ids, float *weights); 00110 00112 00116 void InterpolateEdge(vtkDataSetAttributes *fromPd, vtkIdType toId, 00117 vtkIdType p1, vtkIdType p2, float t); 00119 00121 00128 void InterpolateTime(vtkDataSetAttributes *from1, 00129 vtkDataSetAttributes *from2, 00130 vtkIdType id, float t); 00132 00135 virtual void DeepCopy(vtkFieldData *pd); 00136 00138 virtual void ShallowCopy(vtkFieldData *pd); 00139 00141 00142 int SetScalars(vtkDataArray* da); 00143 int SetActiveScalars(const char* name); 00144 vtkDataArray* GetScalars(); 00146 00148 00149 int SetVectors(vtkDataArray* da); 00150 int SetActiveVectors(const char* name); 00151 vtkDataArray* GetVectors(); 00153 00155 00156 int SetNormals(vtkDataArray* da); 00157 int SetActiveNormals(const char* name); 00158 vtkDataArray* GetNormals(); 00160 00162 00163 int SetTCoords(vtkDataArray* da); 00164 int SetActiveTCoords(const char* name); 00165 vtkDataArray* GetTCoords(); 00167 00169 00170 int SetTensors(vtkDataArray* da); 00171 int SetActiveTensors(const char* name); 00172 vtkDataArray* GetTensors(); 00174 00176 00179 vtkDataArray* GetScalars(const char* name); 00180 vtkDataArray* GetVectors(const char* name); 00181 vtkDataArray* GetNormals(const char* name); 00182 vtkDataArray* GetTCoords(const char* name); 00183 vtkDataArray* GetTensors(const char* name); 00185 00192 int SetActiveAttribute(const char* name, int attributeType); 00193 00195 int SetActiveAttribute(int index, int attributeType); 00196 00198 void SetCopyAttribute (int index, int value); 00199 00201 00207 void SetCopyScalars(int i); 00208 int GetCopyScalars(); 00209 vtkBooleanMacro(CopyScalars, int); 00211 00213 00219 void SetCopyVectors(int i); 00220 int GetCopyVectors(); 00221 vtkBooleanMacro(CopyVectors, int); 00223 00225 00231 void SetCopyNormals(int i); 00232 int GetCopyNormals(); 00233 vtkBooleanMacro(CopyNormals, int); 00235 00237 00243 void SetCopyTCoords(int i); 00244 int GetCopyTCoords(); 00245 vtkBooleanMacro(CopyTCoords, int); 00247 00249 00255 void SetCopyTensors(int i); 00256 int GetCopyTensors(); 00257 vtkBooleanMacro(CopyTensors, int); 00259 00266 virtual void CopyAllOn(); 00267 00274 virtual void CopyAllOff(); 00275 00277 00281 void CopyTuple(vtkDataArray *fromData, vtkDataArray *toData, 00282 vtkIdType fromId, vtkIdType toId); 00284 00287 void GetAttributeIndices(int* indexArray); 00288 00293 int IsArrayAnAttribute(int idx); 00294 00297 vtkDataArray* GetAttribute(int attributeType); 00298 00300 virtual void RemoveArray(const char *name); 00301 00304 static const char* GetAttributeTypeAsString(int attributeType); 00305 00306 //BTX 00307 // Always keep NUM_ATTRIBUTES as the last entry 00308 enum AttributeTypes 00309 { 00310 SCALARS=0, 00311 VECTORS=1, 00312 NORMALS=2, 00313 TCOORDS=3, 00314 TENSORS=4, 00315 NUM_ATTRIBUTES 00316 }; 00317 00318 enum AttributeLimitTypes 00319 { 00320 MAX, 00321 EXACT, 00322 NOLIMIT 00323 }; 00324 00325 class FieldList; 00326 00328 00330 void CopyAllocate(vtkDataSetAttributes::FieldList& list, vtkIdType sze=0, 00331 vtkIdType ext=1000); 00333 00335 00339 void CopyData(vtkDataSetAttributes::FieldList& list, 00340 vtkDataSetAttributes* dsa, int idx, vtkIdType fromId, 00341 vtkIdType toId); 00343 00344 friend class vtkDataSetAttributes::FieldList; 00345 //ETX 00346 00347 protected: 00348 vtkDataSetAttributes(); 00349 ~vtkDataSetAttributes(); 00350 00351 // special methods to support managing data 00352 void InterpolateTuple(vtkDataArray *fromData, vtkDataArray *toData, 00353 vtkIdType toId, vtkIdList *ptIds, float *weights); 00354 void InterpolateTuple(vtkDataArray *fromData, vtkDataArray *toData, 00355 vtkIdType toId, vtkIdType id1, vtkIdType id2, float t); 00356 void InterpolateTuple(vtkDataArray *fromData1, vtkDataArray *fromData2, 00357 vtkDataArray *toData, vtkIdType id, float 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 00377 private: 00378 int SetAttribute(vtkDataArray* da, int attributeType); 00379 static int CheckNumberOfComponents(vtkDataArray* da, int attributeType); 00380 00381 //BTX 00382 vtkFieldData::BasicIterator ComputeRequiredArrays(vtkDataSetAttributes* pd); 00383 00384 private: 00385 vtkDataSetAttributes(const vtkDataSetAttributes&); // Not implemented. 00386 void operator=(const vtkDataSetAttributes&); // Not implemented. 00387 00388 public: 00389 // This public class is used to perform set operations, other misc. 00390 // operations on fields. For example, vtkAppendFilter uses it to 00391 // determine which attributes the input datasets share in common. 00392 class VTK_COMMON_EXPORT FieldList 00393 { 00394 public: 00395 FieldList(int numInputs); 00396 ~FieldList(); 00397 00398 void InitializeFieldList(vtkDataSetAttributes* dsa); 00399 void IntersectFieldList(vtkDataSetAttributes* dsa); 00400 00401 //Determine whether data is available 00402 int IsAttributePresent(int attrType); //true/false attributes specified 00403 00404 // Accessor methods. 00405 int GetNumberOfFields() { return this->NumberOfFields; } 00406 int GetFieldIndex(int i) { return this->FieldIndices[i]; } 00407 int GetDSAIndex(int index, int i) { return this->DSAIndices[index][i]; } 00408 00409 friend class vtkDataSetAttributes; 00410 00411 protected: 00412 FieldList(const FieldList&) {} //prevent these methods from being used 00413 void operator=(const FieldList&) {} 00414 00415 private: 00416 void SetField(int index, vtkDataArray *da); 00417 void RemoveField(const char *name); 00418 void ClearFields(); 00419 00420 //These keep track of what is common across datasets 00421 char** Fields; //the names of the fields (first five are named attributes) 00422 int *FieldTypes; //the types of the fields (first five are named 00423 //attributes) 00424 int *FieldComponents; //the number of components in each fields 00425 // (first five are named attributes) 00426 int *FieldIndices; //output data array index 00427 // (first five are named attributes) 00428 vtkLookupTable **LUT; //luts associated with each array 00429 vtkIdType NumberOfTuples; //a running total of values 00430 int NumberOfFields; //the number of fields 00431 00432 //For every vtkDataSetAttributes that are processed, keep track of the 00433 //indices into various things. The indices are organized so that the 00434 //first NUM_ATTRIBUTES refer to attributes, the next refer to the 00435 //non-attribute fields, for a total of NUM_ATTRIBUTES + NumberOfFields. 00436 //CurrentInput is the current input being processed. 00437 int **DSAIndices; 00438 int NumberOfDSAIndices; 00439 int CurrentInput; 00440 }; 00441 00442 //ETX 00443 }; 00444 00445 #endif 00446 00447