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 "vtkCommonDataModelModule.h" // For export macro
53 #include "vtkFieldData.h"
54 
55 class vtkLookupTable;
56 
58 {
59 public:
61  static vtkDataSetAttributes *New();
62 
64  void PrintSelf(ostream& os, vtkIndent indent);
65 
68  virtual void Initialize();
69 
72  virtual void Update() {}
73 
74  // -- shallow and deep copy -----------------------------------------------
75 
78  virtual void DeepCopy(vtkFieldData *pd);
79 
82  virtual void ShallowCopy(vtkFieldData *pd);
83 
84  // -- attribute types -----------------------------------------------------
85 //BTX
86  // Always keep NUM_ATTRIBUTES as the last entry
88  {
89  SCALARS=0,
90  VECTORS=1,
91  NORMALS=2,
92  TCOORDS=3,
93  TENSORS=4,
94  GLOBALIDS=5,
95  PEDIGREEIDS=6,
96  EDGEFLAG=7,
97  NUM_ATTRIBUTES
98  };
99 
101  {
104  NOLIMIT
105  };
106 //ETX
107 
109 
110  int SetScalars(vtkDataArray* da);
111  int SetActiveScalars(const char* name);
112  vtkDataArray* GetScalars();
114 
116 
117  int SetVectors(vtkDataArray* da);
118  int SetActiveVectors(const char* name);
119  vtkDataArray* GetVectors();
121 
123 
124  int SetNormals(vtkDataArray* da);
125  int SetActiveNormals(const char* name);
126  vtkDataArray* GetNormals();
128 
130 
131  int SetTCoords(vtkDataArray* da);
132  int SetActiveTCoords(const char* name);
133  vtkDataArray* GetTCoords();
135 
137 
138  int SetTensors(vtkDataArray* da);
139  int SetActiveTensors(const char* name);
140  vtkDataArray* GetTensors();
142 
144 
145  int SetGlobalIds(vtkDataArray* da);
146  int SetActiveGlobalIds(const char* name);
147  vtkDataArray* GetGlobalIds();
149 
151 
152  int SetPedigreeIds(vtkAbstractArray* da);
153  int SetActivePedigreeIds(const char* name);
154  vtkAbstractArray* GetPedigreeIds();
156 
158 
161  vtkDataArray* GetScalars(const char* name);
162  vtkDataArray* GetVectors(const char* name);
163  vtkDataArray* GetNormals(const char* name);
164  vtkDataArray* GetTCoords(const char* name);
165  vtkDataArray* GetTensors(const char* name);
166  vtkDataArray* GetGlobalIds(const char* name);
167  vtkAbstractArray* GetPedigreeIds(const char* name);
169 
177  int SetActiveAttribute(const char* name, int attributeType);
178 
180  int SetActiveAttribute(int index, int attributeType);
181 
184  void GetAttributeIndices(int* indexArray);
185 
190  int IsArrayAnAttribute(int idx);
191 
206  int SetAttribute(vtkAbstractArray* aa, int attributeType);
207 
212  vtkDataArray* GetAttribute(int attributeType);
213 
219  vtkAbstractArray* GetAbstractAttribute(int attributeType);
220 
222 
223  virtual void RemoveArray(const char *name);
224  virtual void RemoveArray(int index);
226 
227 
229 
231  static const char* GetAttributeTypeAsString(int attributeType);
232  static const char* GetLongAttributeTypeAsString(int attributeType);
234 
235  // -- attribute copy properties ------------------------------------------
236 
237 //BTX
239  {
240  COPYTUPLE=0,
242  PASSDATA=2,
243  ALLCOPY //all of the above
244  };
245 //ETX
246 
251  void SetCopyAttribute (int index, int value, int ctype=ALLCOPY);
252 
254 
265  void SetCopyScalars(int i, int ctype=ALLCOPY);
266  int GetCopyScalars(int ctype=ALLCOPY);
267  vtkBooleanMacro(CopyScalars, int);
269 
271 
282  void SetCopyVectors(int i, int ctype=ALLCOPY);
283  int GetCopyVectors(int ctype=ALLCOPY);
284  vtkBooleanMacro(CopyVectors, int);
286 
288 
299  void SetCopyNormals(int i, int ctype=ALLCOPY);
300  int GetCopyNormals(int ctype=ALLCOPY);
301  vtkBooleanMacro(CopyNormals, int);
303 
305 
316  void SetCopyTCoords(int i, int ctype=ALLCOPY);
317  int GetCopyTCoords(int ctype=ALLCOPY);
318  vtkBooleanMacro(CopyTCoords, int);
320 
322 
333  void SetCopyTensors(int i, int ctype=ALLCOPY);
334  int GetCopyTensors(int ctype=ALLCOPY);
335  vtkBooleanMacro(CopyTensors, int);
337 
339 
350  void SetCopyGlobalIds(int i, int ctype=ALLCOPY);
351  int GetCopyGlobalIds(int ctype=ALLCOPY);
352  vtkBooleanMacro(CopyGlobalIds, int);
354 
356 
367  void SetCopyPedigreeIds(int i, int ctype=ALLCOPY);
368  int GetCopyPedigreeIds(int ctype=ALLCOPY);
369  vtkBooleanMacro(CopyPedigreeIds, int);
371 
383  virtual void CopyAllOn(int ctype=ALLCOPY);
384 
396  virtual void CopyAllOff(int ctype=ALLCOPY);
397 
398  // -- passthrough operations ----------------------------------------------
399 
407  virtual void PassData(vtkFieldData* fd);
408 
409  // -- copytuple operations ------------------------------------------------
410 
412 
421  vtkIdType ext=1000)
422  {
423  this->CopyAllocate(pd, sze, ext, 0);
424  }
425  void CopyAllocate(vtkDataSetAttributes* pd, vtkIdType sze,
426  vtkIdType ext, int shallowCopyArrays);
428 
430 
432  void CopyStructuredData(vtkDataSetAttributes *inDsa,
433  const int *inExt, const int *outExt);
435 
437 
444  void CopyData(vtkDataSetAttributes *fromPd, vtkIdType fromId, vtkIdType toId);
445  void CopyData(vtkDataSetAttributes *fromPd,
446  vtkIdList *fromIds, vtkIdList *toIds);
448 
450 
453  void CopyData(vtkDataSetAttributes *fromPd, vtkIdType dstStart, vtkIdType n,
454  vtkIdType srcStart);
456 
458 
462  void CopyTuple(vtkAbstractArray *fromData, vtkAbstractArray *toData,
463  vtkIdType fromId, vtkIdType toId);
464  void CopyTuples(vtkAbstractArray *fromData, vtkAbstractArray *toData,
465  vtkIdList *fromIds, vtkIdList *toIds);
466  void CopyTuples(vtkAbstractArray *fromData, vtkAbstractArray *toData,
467  vtkIdType dstStart, vtkIdType n, vtkIdType srcStart);
469 
470 
471  // -- interpolate operations ----------------------------------------------
472 
474 
480  vtkIdType ext=1000)
481  {
482  this->InterpolateAllocate(pd, sze, ext, 0);
483  }
484  void InterpolateAllocate(vtkDataSetAttributes* pd, vtkIdType sze,
485  vtkIdType ext, int shallowCopyArrays);
487 
489 
494  void InterpolatePoint(vtkDataSetAttributes *fromPd, vtkIdType toId,
495  vtkIdList *ids, double *weights);
497 
499 
506  void InterpolateEdge(vtkDataSetAttributes *fromPd, vtkIdType toId,
507  vtkIdType p1, vtkIdType p2, double t);
509 
511 
521  void InterpolateTime(vtkDataSetAttributes *from1,
522  vtkDataSetAttributes *from2,
523  vtkIdType id, double t);
525 
526 //BTX
527  class FieldList;
528 
529  // field list copy operations ------------------------------------------
530 
532 
534  void CopyAllocate(vtkDataSetAttributes::FieldList& list, vtkIdType sze=0,
535  vtkIdType ext=1000);
537 
539 
543  void CopyData(vtkDataSetAttributes::FieldList& list,
544  vtkDataSetAttributes* dsa, int idx, vtkIdType fromId,
545  vtkIdType toId);
547 
549 
554  void InterpolateAllocate(vtkDataSetAttributes::FieldList& list, vtkIdType sze=0,
555  vtkIdType ext=1000);
557 
559 
563  void InterpolatePoint(
565  vtkDataSetAttributes *fromPd,
566  int idx, vtkIdType toId,
567  vtkIdList *ids, double *weights);
569 
571 //ETX
572 
573 //BTX
574 protected:
577 
579  int ctype,
580  vtkIdType sze=0,
581  vtkIdType ext=1000,
582  int shallowCopyArrays=0);
583 
586  int ctype,
587  vtkIdType sze, vtkIdType ext);
588 
590  virtual void InitializeFields();
591 
592  int AttributeIndices[NUM_ATTRIBUTES]; //index to attribute array in field data
593  int CopyAttributeFlags[ALLCOPY][NUM_ATTRIBUTES]; //copy flag for attribute data
594 
596 
598 
600  static const int AttributeLimits[NUM_ATTRIBUTES];
601  static const char AttributeNames[NUM_ATTRIBUTES][12];
602  static const char LongAttributeNames[NUM_ATTRIBUTES][35];
603 
604 private:
605  static int CheckNumberOfComponents(vtkAbstractArray* da, int attributeType);
606 
607  vtkFieldData::BasicIterator ComputeRequiredArrays(vtkDataSetAttributes* pd, int ctype);
608 
609 private:
610  vtkDataSetAttributes(const vtkDataSetAttributes&); // Not implemented.
611  void operator=(const vtkDataSetAttributes&); // Not implemented.
612 
613 public:
614  // This public class is used to perform set operations, other misc.
615  // operations on fields. For example, vtkAppendFilter uses it to
616  // determine which attributes the input datasets share in common.
617  class vtkInternalComponentNames;
619  {
620  public:
621  FieldList(int numInputs);
622  ~FieldList();
623  void PrintSelf(ostream &os, vtkIndent indent);
624 
625  void InitializeFieldList(vtkDataSetAttributes* dsa);
626  void IntersectFieldList(vtkDataSetAttributes* dsa);
627 
632  void UnionFieldList(vtkDataSetAttributes* dsa);
633 
634  //Determine whether data is available
635  int IsAttributePresent(int attrType); //true/false attributes specified
636 
637  // Accessor methods.
638  int GetNumberOfFields() { return this->NumberOfFields; }
639  int GetFieldIndex(int i) { return this->FieldIndices[i]; }
640  const char* GetFieldName(int i) { return this->Fields[i]; }
641  int GetFieldComponents(int i) { return this->FieldComponents[i]; }
642  int GetDSAIndex(int index, int i) { return this->DSAIndices[index][i]; }
643 
644  friend class vtkDataSetAttributes;
645 
646  protected:
647  FieldList(const FieldList&) {} //prevent these methods from being used
648  void operator=(const FieldList&) {}
649 
650  void SetFieldIndex(int i, int index)
651  { this->FieldIndices[i] = index; }
652  private:
653  void SetField(int index, vtkAbstractArray *da);
654  void RemoveField(const char *name);
655  void ClearFields();
656  void GrowBy(unsigned int delta);
657 
658  int NumberOfFields; //the number of fields (including five named attributes)
659  // These keep track of what is common across datasets. The first
660  // six items are always named attributes.
661  char** Fields; // the names of the fields
662  int *FieldTypes; // the types of the fields
663  int *FieldComponents; // the number of components in field
664  int *FieldIndices; // output data array index
665  vtkLookupTable **LUT; // luts associated with each array
666  vtkInformation **FieldInformation; // Information map associated with each array
667 
668  vtkInternalComponentNames **FieldComponentsNames; // the name for each component in the field
669 
670  vtkIdType NumberOfTuples; // a running total of values
671 
672  //For every vtkDataSetAttributes that are processed, keep track of the
673  //indices into various things. The indices are organized so that the
674  //first NUM_ATTRIBUTES refer to attributes, the next refer to the
675  //non-attribute fields, for a total of NUM_ATTRIBUTES + NumberOfFields.
676  //CurrentInput is the current input being processed.
677  int **DSAIndices;
678  int NumberOfDSAIndices;
679  int CurrentInput;
680 
681  };
682 //ETX
683 };
684 
685 #endif
void InternalCopyAllocate(vtkDataSetAttributes *pd, int ctype, vtkIdType sze=0, vtkIdType ext=1000, int shallowCopyArrays=0)
GLuint index
Definition: vtkgl.h:11983
Store vtkAlgorithm input/output information.
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)
GLsizei const GLfloat * value
Definition: vtkgl.h:12021
virtual void CopyAllOn(int unused=0)
int vtkIdType
Definition: vtkType.h:281
GLdouble GLdouble t
Definition: vtkgl.h:11602
static const int NumberOfAttributeComponents[NUM_ATTRIBUTES]
GLuint * ids
Definition: vtkgl.h:11831
#define vtkTypeMacro(thisClass, superclass)
Definition: vtkSetGet.h:632
virtual void CopyAllOff(int unused=0)
const GLenum INTERPOLATE
Definition: vtkgl.h:11586
static const int AttributeLimits[NUM_ATTRIBUTES]
GLuint const GLchar * name
Definition: vtkgl.h:11983
void PrintSelf(ostream &os, vtkIndent indent)
static vtkFieldData * New()
virtual void InitializeFields()
const GLbyte * weights
Definition: vtkgl.h:12766
a simple class to control print indentation
Definition: vtkIndent.h:38
list of point or cell ids
Definition: vtkIdList.h:35
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()
GLclampd n
Definition: vtkgl.h:14370
#define vtkBooleanMacro(name, type)
Definition: vtkSetGet.h:234
int CopyAttributeFlags[ALLCOPY][NUM_ATTRIBUTES]
virtual void ShallowCopy(vtkFieldData *da)
virtual void RemoveArray(const char *name)
Definition: vtkFieldData.h:99
#define VTKCOMMONDATAMODEL_EXPORT
vtkFieldData::BasicIterator RequiredArrays
int AttributeIndices[NUM_ATTRIBUTES]
represent and manipulate fields of data
Definition: vtkFieldData.h:55