00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
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
00074
00077 virtual void DeepCopy(vtkFieldData *pd);
00078
00081 virtual void ShallowCopy(vtkFieldData *pd);
00082
00083
00084
00085
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 NUM_ATTRIBUTES
00096 };
00097
00098 enum AttributeLimitTypes
00099 {
00100 MAX,
00101 EXACT,
00102 NOLIMIT
00103 };
00104
00105
00107
00108 int SetScalars(vtkDataArray* da);
00109 int SetActiveScalars(const char* name);
00110 vtkDataArray* GetScalars();
00112
00114
00115 int SetVectors(vtkDataArray* da);
00116 int SetActiveVectors(const char* name);
00117 vtkDataArray* GetVectors();
00119
00121
00122 int SetNormals(vtkDataArray* da);
00123 int SetActiveNormals(const char* name);
00124 vtkDataArray* GetNormals();
00126
00128
00129 int SetTCoords(vtkDataArray* da);
00130 int SetActiveTCoords(const char* name);
00131 vtkDataArray* GetTCoords();
00133
00135
00136 int SetTensors(vtkDataArray* da);
00137 int SetActiveTensors(const char* name);
00138 vtkDataArray* GetTensors();
00140
00142
00143 int SetGlobalIds(vtkDataArray* da);
00144 int SetActiveGlobalIds(const char* name);
00145 vtkDataArray* GetGlobalIds();
00147
00149
00150 int SetPedigreeIds(vtkAbstractArray* da);
00151 int SetActivePedigreeIds(const char* name);
00152 vtkAbstractArray* GetPedigreeIds();
00154
00156
00159 vtkDataArray* GetScalars(const char* name);
00160 vtkDataArray* GetVectors(const char* name);
00161 vtkDataArray* GetNormals(const char* name);
00162 vtkDataArray* GetTCoords(const char* name);
00163 vtkDataArray* GetTensors(const char* name);
00164 vtkDataArray* GetGlobalIds(const char* name);
00165 vtkAbstractArray* GetPedigreeIds(const char* name);
00167
00175 int SetActiveAttribute(const char* name, int attributeType);
00176
00178 int SetActiveAttribute(int index, int attributeType);
00179
00182 void GetAttributeIndices(int* indexArray);
00183
00188 int IsArrayAnAttribute(int idx);
00189
00194 vtkDataArray* GetAttribute(int attributeType);
00195
00201 vtkAbstractArray* GetAbstractAttribute(int attributeType);
00202
00204 virtual void RemoveArray(const char *name);
00205
00207
00209 static const char* GetAttributeTypeAsString(int attributeType);
00210 static const char* GetLongAttributeTypeAsString(int attributeType);
00212
00213
00214
00215
00216 enum AttributeCopyOperations
00217 {
00218 COPYTUPLE=0,
00219 INTERPOLATE=1,
00220 PASSDATA=2,
00221 ALLCOPY
00222 };
00223
00224
00229 void SetCopyAttribute (int index, int value, int ctype=ALLCOPY);
00230
00232
00243 void SetCopyScalars(int i, int ctype=ALLCOPY);
00244 int GetCopyScalars(int ctype=ALLCOPY);
00245 vtkBooleanMacro(CopyScalars, int);
00247
00249
00260 void SetCopyVectors(int i, int ctype=ALLCOPY);
00261 int GetCopyVectors(int ctype=ALLCOPY);
00262 vtkBooleanMacro(CopyVectors, int);
00264
00266
00277 void SetCopyNormals(int i, int ctype=ALLCOPY);
00278 int GetCopyNormals(int ctype=ALLCOPY);
00279 vtkBooleanMacro(CopyNormals, int);
00281
00283
00294 void SetCopyTCoords(int i, int ctype=ALLCOPY);
00295 int GetCopyTCoords(int ctype=ALLCOPY);
00296 vtkBooleanMacro(CopyTCoords, int);
00298
00300
00311 void SetCopyTensors(int i, int ctype=ALLCOPY);
00312 int GetCopyTensors(int ctype=ALLCOPY);
00313 vtkBooleanMacro(CopyTensors, int);
00315
00317
00328 void SetCopyGlobalIds(int i, int ctype=ALLCOPY);
00329 int GetCopyGlobalIds(int ctype=ALLCOPY);
00330 vtkBooleanMacro(CopyGlobalIds, int);
00332
00334
00345 void SetCopyPedigreeIds(int i, int ctype=ALLCOPY);
00346 int GetCopyPedigreeIds(int ctype=ALLCOPY);
00347 vtkBooleanMacro(CopyPedigreeIds, int);
00349
00361 virtual void CopyAllOn(int ctype=ALLCOPY);
00362
00374 virtual void CopyAllOff(int ctype=ALLCOPY);
00375
00376
00377
00385 virtual void PassData(vtkFieldData* fd);
00386
00387
00388
00390
00398 void CopyAllocate(vtkDataSetAttributes* pd, vtkIdType sze=0,
00399 vtkIdType ext=1000)
00400 {
00401 this->CopyAllocate(pd, sze, ext, 0);
00402 }
00403 void CopyAllocate(vtkDataSetAttributes* pd, vtkIdType sze,
00404 vtkIdType ext, int shallowCopyArrays);
00406
00408
00410 void CopyStructuredData(vtkDataSetAttributes *inDsa,
00411 const int *inExt, const int *outExt);
00413
00421 void CopyData(vtkDataSetAttributes *fromPd, vtkIdType fromId, vtkIdType toId);
00422
00423
00425
00429 void CopyTuple(vtkAbstractArray *fromData, vtkAbstractArray *toData,
00430 vtkIdType fromId, vtkIdType toId);
00432
00433
00434
00435
00437
00442 void InterpolateAllocate(vtkDataSetAttributes* pd, vtkIdType sze=0,
00443 vtkIdType ext=1000)
00444 {
00445 this->InterpolateAllocate(pd, sze, ext, 0);
00446 }
00447 void InterpolateAllocate(vtkDataSetAttributes* pd, vtkIdType sze,
00448 vtkIdType ext, int shallowCopyArrays);
00450
00452
00457 void InterpolatePoint(vtkDataSetAttributes *fromPd, vtkIdType toId,
00458 vtkIdList *ids, double *weights);
00460
00462
00469 void InterpolateEdge(vtkDataSetAttributes *fromPd, vtkIdType toId,
00470 vtkIdType p1, vtkIdType p2, double t);
00472
00474
00484 void InterpolateTime(vtkDataSetAttributes *from1,
00485 vtkDataSetAttributes *from2,
00486 vtkIdType id, double t);
00488
00489
00490 class FieldList;
00491
00492
00493
00495
00497 void CopyAllocate(vtkDataSetAttributes::FieldList& list, vtkIdType sze=0,
00498 vtkIdType ext=1000);
00500
00502
00506 void CopyData(vtkDataSetAttributes::FieldList& list,
00507 vtkDataSetAttributes* dsa, int idx, vtkIdType fromId,
00508 vtkIdType toId);
00510
00512
00517 void InterpolateAllocate(vtkDataSetAttributes::FieldList& list, vtkIdType sze=0,
00518 vtkIdType ext=1000);
00520
00522
00526 void InterpolatePoint(
00527 vtkDataSetAttributes::FieldList& list,
00528 vtkDataSetAttributes *fromPd,
00529 int idx, vtkIdType toId,
00530 vtkIdList *ids, double *weights);
00532
00533 friend class vtkDataSetAttributes::FieldList;
00534
00535
00536
00537 protected:
00538 vtkDataSetAttributes();
00539 ~vtkDataSetAttributes();
00540
00541 void InternalCopyAllocate(vtkDataSetAttributes* pd,
00542 int ctype,
00543 vtkIdType sze=0,
00544 vtkIdType ext=1000,
00545 int shallowCopyArrays=0);
00546
00547 void InternalCopyAllocate(
00548 vtkDataSetAttributes::FieldList& list,
00549 int ctype,
00550 vtkIdType sze, vtkIdType ext);
00551
00553 virtual void InitializeFields();
00554
00555 int AttributeIndices[NUM_ATTRIBUTES];
00556 int CopyAttributeFlags[ALLCOPY][NUM_ATTRIBUTES];
00557
00558 vtkFieldData::BasicIterator RequiredArrays;
00559
00560 int* TargetIndices;
00561
00562 virtual void RemoveArray(int index);
00563
00564 static const int NumberOfAttributeComponents[NUM_ATTRIBUTES];
00565 static const int AttributeLimits[NUM_ATTRIBUTES];
00566 static const char AttributeNames[NUM_ATTRIBUTES][12];
00567 static const char LongAttributeNames[NUM_ATTRIBUTES][35];
00568
00569 private:
00570 int SetAttribute(vtkAbstractArray* da, int attributeType);
00571 static int CheckNumberOfComponents(vtkAbstractArray* da, int attributeType);
00572
00573 vtkFieldData::BasicIterator ComputeRequiredArrays(vtkDataSetAttributes* pd, int ctype);
00574
00575 private:
00576 vtkDataSetAttributes(const vtkDataSetAttributes&);
00577 void operator=(const vtkDataSetAttributes&);
00578
00579 public:
00580
00581
00582
00583 class VTK_FILTERING_EXPORT FieldList
00584 {
00585 public:
00586 FieldList(int numInputs);
00587 ~FieldList();
00588 void PrintSelf(ostream &os, vtkIndent indent);
00589
00590 void InitializeFieldList(vtkDataSetAttributes* dsa);
00591 void IntersectFieldList(vtkDataSetAttributes* dsa);
00592
00597 void UnionFieldList(vtkDataSetAttributes* dsa);
00598
00599
00600 int IsAttributePresent(int attrType);
00601
00602
00603 int GetNumberOfFields() { return this->NumberOfFields; }
00604 int GetFieldIndex(int i) { return this->FieldIndices[i]; }
00605 const char* GetFieldName(int i) { return this->Fields[i]; }
00606 int GetFieldComponents(int i) { return this->FieldComponents[i]; }
00607 int GetDSAIndex(int index, int i) { return this->DSAIndices[index][i]; }
00608
00609 friend class vtkDataSetAttributes;
00610
00611 protected:
00612 FieldList(const FieldList&) {}
00613 void operator=(const FieldList&) {}
00614
00615 void SetFieldIndex(int i, int index)
00616 { this->FieldIndices[i] = index; }
00617 private:
00618 void SetField(int index, vtkAbstractArray *da);
00619 void RemoveField(const char *name);
00620 void ClearFields();
00621 void GrowBy(unsigned int delta);
00622
00623 int NumberOfFields;
00624
00625
00626 char** Fields;
00627 int *FieldTypes;
00628 int *FieldComponents;
00629 int *FieldIndices;
00630 vtkLookupTable **LUT;
00631 vtkInformation **FieldInformation;
00632
00633 vtkIdType NumberOfTuples;
00634
00635
00636
00637
00638
00639
00640 int **DSAIndices;
00641 int NumberOfDSAIndices;
00642 int CurrentInput;
00643 };
00644
00645
00646 };
00647
00648 #endif
00649
00650