VTK
vtkDataSetAttributes.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkDataSetAttributes.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
49 #ifndef __vtkDataSetAttributes_h
50 #define __vtkDataSetAttributes_h
51 
52 #include "vtkFieldData.h"
53 
54 class vtkLookupTable;
55 
57 {
58 public:
60  static vtkDataSetAttributes *New();
61 
63  void PrintSelf(ostream& os, vtkIndent indent);
64 
67  virtual void Initialize();
68 
71  virtual void Update() {}
72 
73  // -- shallow and deep copy -----------------------------------------------
74 
77  virtual void DeepCopy(vtkFieldData *pd);
78 
81  virtual void ShallowCopy(vtkFieldData *pd);
82 
83  // -- attribute types -----------------------------------------------------
84 //BTX
85  // Always keep NUM_ATTRIBUTES as the last entry
87  {
88  SCALARS=0,
89  VECTORS=1,
90  NORMALS=2,
91  TCOORDS=3,
92  TENSORS=4,
93  GLOBALIDS=5,
94  PEDIGREEIDS=6,
95  EDGEFLAG=7,
96  NUM_ATTRIBUTES
97  };
98 
100  {
101  MAX,
103  NOLIMIT
104  };
105 //ETX
106 
108 
109  int SetScalars(vtkDataArray* da);
110  int SetActiveScalars(const char* name);
111  vtkDataArray* GetScalars();
113 
115 
116  int SetVectors(vtkDataArray* da);
117  int SetActiveVectors(const char* name);
118  vtkDataArray* GetVectors();
120 
122 
123  int SetNormals(vtkDataArray* da);
124  int SetActiveNormals(const char* name);
125  vtkDataArray* GetNormals();
127 
129 
130  int SetTCoords(vtkDataArray* da);
131  int SetActiveTCoords(const char* name);
132  vtkDataArray* GetTCoords();
134 
136 
137  int SetTensors(vtkDataArray* da);
138  int SetActiveTensors(const char* name);
139  vtkDataArray* GetTensors();
141 
143 
144  int SetGlobalIds(vtkDataArray* da);
145  int SetActiveGlobalIds(const char* name);
146  vtkDataArray* GetGlobalIds();
148 
150 
151  int SetPedigreeIds(vtkAbstractArray* da);
152  int SetActivePedigreeIds(const char* name);
153  vtkAbstractArray* GetPedigreeIds();
155 
157 
160  vtkDataArray* GetScalars(const char* name);
161  vtkDataArray* GetVectors(const char* name);
162  vtkDataArray* GetNormals(const char* name);
163  vtkDataArray* GetTCoords(const char* name);
164  vtkDataArray* GetTensors(const char* name);
165  vtkDataArray* GetGlobalIds(const char* name);
166  vtkAbstractArray* GetPedigreeIds(const char* name);
168 
176  int SetActiveAttribute(const char* name, int attributeType);
177 
179  int SetActiveAttribute(int index, int attributeType);
180 
183  void GetAttributeIndices(int* indexArray);
184 
189  int IsArrayAnAttribute(int idx);
190 
195  vtkDataArray* GetAttribute(int attributeType);
196 
202  vtkAbstractArray* GetAbstractAttribute(int attributeType);
203 
205 
206  virtual void RemoveArray(const char *name);
207  virtual void RemoveArray(int index);
209 
210 
212 
214  static const char* GetAttributeTypeAsString(int attributeType);
215  static const char* GetLongAttributeTypeAsString(int attributeType);
217 
218  // -- attribute copy properties ------------------------------------------
219 
220 //BTX
222  {
223  COPYTUPLE=0,
224  INTERPOLATE=1,
225  PASSDATA=2,
226  ALLCOPY //all of the above
227  };
228 //ETX
229 
234  void SetCopyAttribute (int index, int value, int ctype=ALLCOPY);
235 
237 
248  void SetCopyScalars(int i, int ctype=ALLCOPY);
249  int GetCopyScalars(int ctype=ALLCOPY);
250  vtkBooleanMacro(CopyScalars, int);
252 
254 
265  void SetCopyVectors(int i, int ctype=ALLCOPY);
266  int GetCopyVectors(int ctype=ALLCOPY);
267  vtkBooleanMacro(CopyVectors, int);
269 
271 
282  void SetCopyNormals(int i, int ctype=ALLCOPY);
283  int GetCopyNormals(int ctype=ALLCOPY);
284  vtkBooleanMacro(CopyNormals, int);
286 
288 
299  void SetCopyTCoords(int i, int ctype=ALLCOPY);
300  int GetCopyTCoords(int ctype=ALLCOPY);
301  vtkBooleanMacro(CopyTCoords, int);
303 
305 
316  void SetCopyTensors(int i, int ctype=ALLCOPY);
317  int GetCopyTensors(int ctype=ALLCOPY);
318  vtkBooleanMacro(CopyTensors, int);
320 
322 
333  void SetCopyGlobalIds(int i, int ctype=ALLCOPY);
334  int GetCopyGlobalIds(int ctype=ALLCOPY);
335  vtkBooleanMacro(CopyGlobalIds, int);
337 
339 
350  void SetCopyPedigreeIds(int i, int ctype=ALLCOPY);
351  int GetCopyPedigreeIds(int ctype=ALLCOPY);
352  vtkBooleanMacro(CopyPedigreeIds, int);
354 
366  virtual void CopyAllOn(int ctype=ALLCOPY);
367 
379  virtual void CopyAllOff(int ctype=ALLCOPY);
380 
381  // -- passthrough operations ----------------------------------------------
382 
390  virtual void PassData(vtkFieldData* fd);
391 
392  // -- copytuple operations ------------------------------------------------
393 
395 
404  vtkIdType ext=1000)
405  {
406  this->CopyAllocate(pd, sze, ext, 0);
407  }
408  void CopyAllocate(vtkDataSetAttributes* pd, vtkIdType sze,
409  vtkIdType ext, int shallowCopyArrays);
411 
413 
415  void CopyStructuredData(vtkDataSetAttributes *inDsa,
416  const int *inExt, const int *outExt);
418 
426  void CopyData(vtkDataSetAttributes *fromPd, vtkIdType fromId, vtkIdType toId);
427 
428 
430 
434  void CopyTuple(vtkAbstractArray *fromData, vtkAbstractArray *toData,
435  vtkIdType fromId, vtkIdType toId);
437 
438 
439  // -- interpolate operations ----------------------------------------------
440 
442 
448  vtkIdType ext=1000)
449  {
450  this->InterpolateAllocate(pd, sze, ext, 0);
451  }
452  void InterpolateAllocate(vtkDataSetAttributes* pd, vtkIdType sze,
453  vtkIdType ext, int shallowCopyArrays);
455 
457 
462  void InterpolatePoint(vtkDataSetAttributes *fromPd, vtkIdType toId,
463  vtkIdList *ids, double *weights);
465 
467 
474  void InterpolateEdge(vtkDataSetAttributes *fromPd, vtkIdType toId,
475  vtkIdType p1, vtkIdType p2, double t);
477 
479 
489  void InterpolateTime(vtkDataSetAttributes *from1,
490  vtkDataSetAttributes *from2,
491  vtkIdType id, double t);
493 
494 //BTX
495  class FieldList;
496 
497  // field list copy operations ------------------------------------------
498 
500 
502  void CopyAllocate(vtkDataSetAttributes::FieldList& list, vtkIdType sze=0,
503  vtkIdType ext=1000);
505 
507 
511  void CopyData(vtkDataSetAttributes::FieldList& list,
512  vtkDataSetAttributes* dsa, int idx, vtkIdType fromId,
513  vtkIdType toId);
515 
517 
522  void InterpolateAllocate(vtkDataSetAttributes::FieldList& list, vtkIdType sze=0,
523  vtkIdType ext=1000);
525 
527 
531  void InterpolatePoint(
533  vtkDataSetAttributes *fromPd,
534  int idx, vtkIdType toId,
535  vtkIdList *ids, double *weights);
537 
539 //ETX
540 
541 //BTX
542 protected:
545 
547  int ctype,
548  vtkIdType sze=0,
549  vtkIdType ext=1000,
550  int shallowCopyArrays=0);
551 
554  int ctype,
555  vtkIdType sze, vtkIdType ext);
556 
558  virtual void InitializeFields();
559 
560  int AttributeIndices[NUM_ATTRIBUTES]; //index to attribute array in field data
561  int CopyAttributeFlags[ALLCOPY][NUM_ATTRIBUTES]; //copy flag for attribute data
562 
564 
566 
568  static const int AttributeLimits[NUM_ATTRIBUTES];
569  static const char AttributeNames[NUM_ATTRIBUTES][12];
570  static const char LongAttributeNames[NUM_ATTRIBUTES][35];
571 
572 private:
573  int SetAttribute(vtkAbstractArray* da, int attributeType);
574  static int CheckNumberOfComponents(vtkAbstractArray* da, int attributeType);
575 
576  vtkFieldData::BasicIterator ComputeRequiredArrays(vtkDataSetAttributes* pd, int ctype);
577 
578 private:
579  vtkDataSetAttributes(const vtkDataSetAttributes&); // Not implemented.
580  void operator=(const vtkDataSetAttributes&); // Not implemented.
581 
582 public:
583  // This public class is used to perform set operations, other misc.
584  // operations on fields. For example, vtkAppendFilter uses it to
585  // determine which attributes the input datasets share in common.
586  class vtkInternalComponentNames;
588  {
589  public:
590  FieldList(int numInputs);
591  ~FieldList();
592  void PrintSelf(ostream &os, vtkIndent indent);
593 
594  void InitializeFieldList(vtkDataSetAttributes* dsa);
595  void IntersectFieldList(vtkDataSetAttributes* dsa);
596 
601  void UnionFieldList(vtkDataSetAttributes* dsa);
602 
603  //Determine whether data is available
604  int IsAttributePresent(int attrType); //true/false attributes specified
605 
606  // Accessor methods.
607  int GetNumberOfFields() { return this->NumberOfFields; }
608  int GetFieldIndex(int i) { return this->FieldIndices[i]; }
609  const char* GetFieldName(int i) { return this->Fields[i]; }
610  int GetFieldComponents(int i) { return this->FieldComponents[i]; }
611  int GetDSAIndex(int index, int i) { return this->DSAIndices[index][i]; }
612 
613  friend class vtkDataSetAttributes;
614 
615  protected:
616  FieldList(const FieldList&) {} //prevent these methods from being used
617  void operator=(const FieldList&) {}
618 
619  void SetFieldIndex(int i, int index)
620  { this->FieldIndices[i] = index; }
621  private:
622  void SetField(int index, vtkAbstractArray *da);
623  void RemoveField(const char *name);
624  void ClearFields();
625  void GrowBy(unsigned int delta);
626 
627  int NumberOfFields; //the number of fields (including five named attributes)
628  // These keep track of what is common across datasets. The first
629  // six items are always named attributes.
630  char** Fields; // the names of the fields
631  int *FieldTypes; // the types of the fields
632  int *FieldComponents; // the number of components in field
633  int *FieldIndices; // output data array index
634  vtkLookupTable **LUT; // luts associated with each array
635  vtkInformation **FieldInformation; // Information map associated with each array
636 
637  vtkInternalComponentNames **FieldComponentsNames; // the name for each component in the field
638 
639  vtkIdType NumberOfTuples; // a running total of values
640 
641  //For every vtkDataSetAttributes that are processed, keep track of the
642  //indices into various things. The indices are organized so that the
643  //first NUM_ATTRIBUTES refer to attributes, the next refer to the
644  //non-attribute fields, for a total of NUM_ATTRIBUTES + NumberOfFields.
645  //CurrentInput is the current input being processed.
646  int **DSAIndices;
647  int NumberOfDSAIndices;
648  int CurrentInput;
649 
650  };
651 //ETX
652 };
653 
654 #endif
655 
656 
void InternalCopyAllocate(vtkDataSetAttributes *pd, int ctype, vtkIdType sze=0, vtkIdType ext=1000, int shallowCopyArrays=0)
Store vtkAlgorithm input/output information.
#define VTK_FILTERING_EXPORT
Abstract superclass for all arrays.
void InterpolateAllocate(vtkDataSetAttributes *pd, vtkIdType sze=0, vtkIdType ext=1000)
static const char LongAttributeNames[NUM_ATTRIBUTES][35]
map scalar values into colors via a lookup table
static const char AttributeNames[NUM_ATTRIBUTES][12]
virtual void PassData(vtkFieldData *fd)
virtual void CopyAllOn(int unused=0)
int vtkIdType
Definition: vtkType.h:255
static const int NumberOfAttributeComponents[NUM_ATTRIBUTES]
virtual void CopyAllOff(int unused=0)
static const int AttributeLimits[NUM_ATTRIBUTES]
void PrintSelf(ostream &os, vtkIndent indent)
static vtkFieldData * New()
virtual void InitializeFields()
a simple class to control print indentation
Definition: vtkIndent.h:37
list of point or cell ids
Definition: vtkIdList.h:34
void CopyAllocate(vtkDataSetAttributes *pd, vtkIdType sze=0, vtkIdType ext=1000)
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:53
represent and manipulate attribute data in a dataset
void SetFieldIndex(int i, int index)
virtual void DeepCopy(vtkFieldData *da)
virtual void Initialize()
int CopyAttributeFlags[ALLCOPY][NUM_ATTRIBUTES]
virtual void ShallowCopy(vtkFieldData *da)
virtual void RemoveArray(const char *name)
Definition: vtkFieldData.h:101
vtkFieldData::BasicIterator RequiredArrays
int AttributeIndices[NUM_ATTRIBUTES]
represent and manipulate fields of data
Definition: vtkFieldData.h:58