VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: vtkDataSetAttributes.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 =========================================================================*/ 00049 #ifndef __vtkDataSetAttributes_h 00050 #define __vtkDataSetAttributes_h 00051 00052 #include "vtkFieldData.h" 00053 00054 class vtkLookupTable; 00055 00056 class VTK_FILTERING_EXPORT vtkDataSetAttributes : public vtkFieldData 00057 { 00058 public: 00060 static vtkDataSetAttributes *New(); 00061 00062 vtkTypeMacro(vtkDataSetAttributes,vtkFieldData); 00063 void PrintSelf(ostream& os, vtkIndent indent); 00064 00067 virtual void Initialize(); 00068 00071 virtual void Update() {} 00072 00073 // -- shallow and deep copy ----------------------------------------------- 00074 00077 virtual void DeepCopy(vtkFieldData *pd); 00078 00081 virtual void ShallowCopy(vtkFieldData *pd); 00082 00083 // -- attribute types ----------------------------------------------------- 00084 //BTX 00085 // Always keep NUM_ATTRIBUTES as the last entry 00086 enum AttributeTypes 00087 { 00088 SCALARS=0, 00089 VECTORS=1, 00090 NORMALS=2, 00091 TCOORDS=3, 00092 TENSORS=4, 00093 GLOBALIDS=5, 00094 PEDIGREEIDS=6, 00095 EDGEFLAG=7, 00096 NUM_ATTRIBUTES 00097 }; 00098 00099 enum AttributeLimitTypes 00100 { 00101 MAX, 00102 EXACT, 00103 NOLIMIT 00104 }; 00105 //ETX 00106 00108 00109 int SetScalars(vtkDataArray* da); 00110 int SetActiveScalars(const char* name); 00111 vtkDataArray* GetScalars(); 00113 00115 00116 int SetVectors(vtkDataArray* da); 00117 int SetActiveVectors(const char* name); 00118 vtkDataArray* GetVectors(); 00120 00122 00123 int SetNormals(vtkDataArray* da); 00124 int SetActiveNormals(const char* name); 00125 vtkDataArray* GetNormals(); 00127 00129 00130 int SetTCoords(vtkDataArray* da); 00131 int SetActiveTCoords(const char* name); 00132 vtkDataArray* GetTCoords(); 00134 00136 00137 int SetTensors(vtkDataArray* da); 00138 int SetActiveTensors(const char* name); 00139 vtkDataArray* GetTensors(); 00141 00143 00144 int SetGlobalIds(vtkDataArray* da); 00145 int SetActiveGlobalIds(const char* name); 00146 vtkDataArray* GetGlobalIds(); 00148 00150 00151 int SetPedigreeIds(vtkAbstractArray* da); 00152 int SetActivePedigreeIds(const char* name); 00153 vtkAbstractArray* GetPedigreeIds(); 00155 00157 00160 vtkDataArray* GetScalars(const char* name); 00161 vtkDataArray* GetVectors(const char* name); 00162 vtkDataArray* GetNormals(const char* name); 00163 vtkDataArray* GetTCoords(const char* name); 00164 vtkDataArray* GetTensors(const char* name); 00165 vtkDataArray* GetGlobalIds(const char* name); 00166 vtkAbstractArray* GetPedigreeIds(const char* name); 00168 00176 int SetActiveAttribute(const char* name, int attributeType); 00177 00179 int SetActiveAttribute(int index, int attributeType); 00180 00183 void GetAttributeIndices(int* indexArray); 00184 00189 int IsArrayAnAttribute(int idx); 00190 00195 vtkDataArray* GetAttribute(int attributeType); 00196 00202 vtkAbstractArray* GetAbstractAttribute(int attributeType); 00203 00205 00206 virtual void RemoveArray(const char *name); 00207 virtual void RemoveArray(int index); 00209 00210 00212 00214 static const char* GetAttributeTypeAsString(int attributeType); 00215 static const char* GetLongAttributeTypeAsString(int attributeType); 00217 00218 // -- attribute copy properties ------------------------------------------ 00219 00220 //BTX 00221 enum AttributeCopyOperations 00222 { 00223 COPYTUPLE=0, 00224 INTERPOLATE=1, 00225 PASSDATA=2, 00226 ALLCOPY //all of the above 00227 }; 00228 //ETX 00229 00234 void SetCopyAttribute (int index, int value, int ctype=ALLCOPY); 00235 00237 00248 void SetCopyScalars(int i, int ctype=ALLCOPY); 00249 int GetCopyScalars(int ctype=ALLCOPY); 00250 vtkBooleanMacro(CopyScalars, int); 00252 00254 00265 void SetCopyVectors(int i, int ctype=ALLCOPY); 00266 int GetCopyVectors(int ctype=ALLCOPY); 00267 vtkBooleanMacro(CopyVectors, int); 00269 00271 00282 void SetCopyNormals(int i, int ctype=ALLCOPY); 00283 int GetCopyNormals(int ctype=ALLCOPY); 00284 vtkBooleanMacro(CopyNormals, int); 00286 00288 00299 void SetCopyTCoords(int i, int ctype=ALLCOPY); 00300 int GetCopyTCoords(int ctype=ALLCOPY); 00301 vtkBooleanMacro(CopyTCoords, int); 00303 00305 00316 void SetCopyTensors(int i, int ctype=ALLCOPY); 00317 int GetCopyTensors(int ctype=ALLCOPY); 00318 vtkBooleanMacro(CopyTensors, int); 00320 00322 00333 void SetCopyGlobalIds(int i, int ctype=ALLCOPY); 00334 int GetCopyGlobalIds(int ctype=ALLCOPY); 00335 vtkBooleanMacro(CopyGlobalIds, int); 00337 00339 00350 void SetCopyPedigreeIds(int i, int ctype=ALLCOPY); 00351 int GetCopyPedigreeIds(int ctype=ALLCOPY); 00352 vtkBooleanMacro(CopyPedigreeIds, int); 00354 00366 virtual void CopyAllOn(int ctype=ALLCOPY); 00367 00379 virtual void CopyAllOff(int ctype=ALLCOPY); 00380 00381 // -- passthrough operations ---------------------------------------------- 00382 00390 virtual void PassData(vtkFieldData* fd); 00391 00392 // -- copytuple operations ------------------------------------------------ 00393 00395 00403 void CopyAllocate(vtkDataSetAttributes* pd, vtkIdType sze=0, 00404 vtkIdType ext=1000) 00405 { 00406 this->CopyAllocate(pd, sze, ext, 0); 00407 } 00408 void CopyAllocate(vtkDataSetAttributes* pd, vtkIdType sze, 00409 vtkIdType ext, int shallowCopyArrays); 00411 00413 00415 void CopyStructuredData(vtkDataSetAttributes *inDsa, 00416 const int *inExt, const int *outExt); 00418 00426 void CopyData(vtkDataSetAttributes *fromPd, vtkIdType fromId, vtkIdType toId); 00427 00428 00430 00434 void CopyTuple(vtkAbstractArray *fromData, vtkAbstractArray *toData, 00435 vtkIdType fromId, vtkIdType toId); 00437 00438 00439 // -- interpolate operations ---------------------------------------------- 00440 00442 00447 void InterpolateAllocate(vtkDataSetAttributes* pd, vtkIdType sze=0, 00448 vtkIdType ext=1000) 00449 { 00450 this->InterpolateAllocate(pd, sze, ext, 0); 00451 } 00452 void InterpolateAllocate(vtkDataSetAttributes* pd, vtkIdType sze, 00453 vtkIdType ext, int shallowCopyArrays); 00455 00457 00462 void InterpolatePoint(vtkDataSetAttributes *fromPd, vtkIdType toId, 00463 vtkIdList *ids, double *weights); 00465 00467 00474 void InterpolateEdge(vtkDataSetAttributes *fromPd, vtkIdType toId, 00475 vtkIdType p1, vtkIdType p2, double t); 00477 00479 00489 void InterpolateTime(vtkDataSetAttributes *from1, 00490 vtkDataSetAttributes *from2, 00491 vtkIdType id, double t); 00493 00494 //BTX 00495 class FieldList; 00496 00497 // field list copy operations ------------------------------------------ 00498 00500 00502 void CopyAllocate(vtkDataSetAttributes::FieldList& list, vtkIdType sze=0, 00503 vtkIdType ext=1000); 00505 00507 00511 void CopyData(vtkDataSetAttributes::FieldList& list, 00512 vtkDataSetAttributes* dsa, int idx, vtkIdType fromId, 00513 vtkIdType toId); 00515 00517 00522 void InterpolateAllocate(vtkDataSetAttributes::FieldList& list, vtkIdType sze=0, 00523 vtkIdType ext=1000); 00525 00527 00531 void InterpolatePoint( 00532 vtkDataSetAttributes::FieldList& list, 00533 vtkDataSetAttributes *fromPd, 00534 int idx, vtkIdType toId, 00535 vtkIdList *ids, double *weights); 00537 00538 friend class vtkDataSetAttributes::FieldList; 00539 //ETX 00540 00541 //BTX 00542 protected: 00543 vtkDataSetAttributes(); 00544 ~vtkDataSetAttributes(); 00545 00546 void InternalCopyAllocate(vtkDataSetAttributes* pd, 00547 int ctype, 00548 vtkIdType sze=0, 00549 vtkIdType ext=1000, 00550 int shallowCopyArrays=0); 00551 00552 void InternalCopyAllocate( 00553 vtkDataSetAttributes::FieldList& list, 00554 int ctype, 00555 vtkIdType sze, vtkIdType ext); 00556 00558 virtual void InitializeFields(); 00559 00560 int AttributeIndices[NUM_ATTRIBUTES]; //index to attribute array in field data 00561 int CopyAttributeFlags[ALLCOPY][NUM_ATTRIBUTES]; //copy flag for attribute data 00562 00563 vtkFieldData::BasicIterator RequiredArrays; 00564 00565 int* TargetIndices; 00566 00567 static const int NumberOfAttributeComponents[NUM_ATTRIBUTES]; 00568 static const int AttributeLimits[NUM_ATTRIBUTES]; 00569 static const char AttributeNames[NUM_ATTRIBUTES][12]; 00570 static const char LongAttributeNames[NUM_ATTRIBUTES][35]; 00571 00572 private: 00573 int SetAttribute(vtkAbstractArray* da, int attributeType); 00574 static int CheckNumberOfComponents(vtkAbstractArray* da, int attributeType); 00575 00576 vtkFieldData::BasicIterator ComputeRequiredArrays(vtkDataSetAttributes* pd, int ctype); 00577 00578 private: 00579 vtkDataSetAttributes(const vtkDataSetAttributes&); // Not implemented. 00580 void operator=(const vtkDataSetAttributes&); // Not implemented. 00581 00582 public: 00583 // This public class is used to perform set operations, other misc. 00584 // operations on fields. For example, vtkAppendFilter uses it to 00585 // determine which attributes the input datasets share in common. 00586 class vtkInternalComponentNames; 00587 class VTK_FILTERING_EXPORT FieldList 00588 { 00589 public: 00590 FieldList(int numInputs); 00591 ~FieldList(); 00592 void PrintSelf(ostream &os, vtkIndent indent); 00593 00594 void InitializeFieldList(vtkDataSetAttributes* dsa); 00595 void IntersectFieldList(vtkDataSetAttributes* dsa); 00596 00601 void UnionFieldList(vtkDataSetAttributes* dsa); 00602 00603 //Determine whether data is available 00604 int IsAttributePresent(int attrType); //true/false attributes specified 00605 00606 // Accessor methods. 00607 int GetNumberOfFields() { return this->NumberOfFields; } 00608 int GetFieldIndex(int i) { return this->FieldIndices[i]; } 00609 const char* GetFieldName(int i) { return this->Fields[i]; } 00610 int GetFieldComponents(int i) { return this->FieldComponents[i]; } 00611 int GetDSAIndex(int index, int i) { return this->DSAIndices[index][i]; } 00612 00613 friend class vtkDataSetAttributes; 00614 00615 protected: 00616 FieldList(const FieldList&) {} //prevent these methods from being used 00617 void operator=(const FieldList&) {} 00618 00619 void SetFieldIndex(int i, int index) 00620 { this->FieldIndices[i] = index; } 00621 private: 00622 void SetField(int index, vtkAbstractArray *da); 00623 void RemoveField(const char *name); 00624 void ClearFields(); 00625 void GrowBy(unsigned int delta); 00626 00627 int NumberOfFields; //the number of fields (including five named attributes) 00628 // These keep track of what is common across datasets. The first 00629 // six items are always named attributes. 00630 char** Fields; // the names of the fields 00631 int *FieldTypes; // the types of the fields 00632 int *FieldComponents; // the number of components in field 00633 int *FieldIndices; // output data array index 00634 vtkLookupTable **LUT; // luts associated with each array 00635 vtkInformation **FieldInformation; // Information map associated with each array 00636 00637 vtkInternalComponentNames **FieldComponentsNames; // the name for each component in the field 00638 00639 vtkIdType NumberOfTuples; // a running total of values 00640 00641 //For every vtkDataSetAttributes that are processed, keep track of the 00642 //indices into various things. The indices are organized so that the 00643 //first NUM_ATTRIBUTES refer to attributes, the next refer to the 00644 //non-attribute fields, for a total of NUM_ATTRIBUTES + NumberOfFields. 00645 //CurrentInput is the current input being processed. 00646 int **DSAIndices; 00647 int NumberOfDSAIndices; 00648 int CurrentInput; 00649 00650 }; 00651 //ETX 00652 }; 00653 00654 #endif 00655 00656