VTK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 
196  vtkDataArray* GetAttribute(int attributeType);
197 
203  vtkAbstractArray* GetAbstractAttribute(int attributeType);
204 
206 
207  virtual void RemoveArray(const char *name);
208  virtual void RemoveArray(int index);
210 
211 
213 
215  static const char* GetAttributeTypeAsString(int attributeType);
216  static const char* GetLongAttributeTypeAsString(int attributeType);
218 
219  // -- attribute copy properties ------------------------------------------
220 
221 //BTX
223  {
224  COPYTUPLE=0,
226  PASSDATA=2,
227  ALLCOPY //all of the above
228  };
229 //ETX
230 
235  void SetCopyAttribute (int index, int value, int ctype=ALLCOPY);
236 
238 
249  void SetCopyScalars(int i, int ctype=ALLCOPY);
250  int GetCopyScalars(int ctype=ALLCOPY);
251  vtkBooleanMacro(CopyScalars, int);
253 
255 
266  void SetCopyVectors(int i, int ctype=ALLCOPY);
267  int GetCopyVectors(int ctype=ALLCOPY);
268  vtkBooleanMacro(CopyVectors, int);
270 
272 
283  void SetCopyNormals(int i, int ctype=ALLCOPY);
284  int GetCopyNormals(int ctype=ALLCOPY);
285  vtkBooleanMacro(CopyNormals, int);
287 
289 
300  void SetCopyTCoords(int i, int ctype=ALLCOPY);
301  int GetCopyTCoords(int ctype=ALLCOPY);
302  vtkBooleanMacro(CopyTCoords, int);
304 
306 
317  void SetCopyTensors(int i, int ctype=ALLCOPY);
318  int GetCopyTensors(int ctype=ALLCOPY);
319  vtkBooleanMacro(CopyTensors, int);
321 
323 
334  void SetCopyGlobalIds(int i, int ctype=ALLCOPY);
335  int GetCopyGlobalIds(int ctype=ALLCOPY);
336  vtkBooleanMacro(CopyGlobalIds, int);
338 
340 
351  void SetCopyPedigreeIds(int i, int ctype=ALLCOPY);
352  int GetCopyPedigreeIds(int ctype=ALLCOPY);
353  vtkBooleanMacro(CopyPedigreeIds, int);
355 
367  virtual void CopyAllOn(int ctype=ALLCOPY);
368 
380  virtual void CopyAllOff(int ctype=ALLCOPY);
381 
382  // -- passthrough operations ----------------------------------------------
383 
391  virtual void PassData(vtkFieldData* fd);
392 
393  // -- copytuple operations ------------------------------------------------
394 
396 
405  vtkIdType ext=1000)
406  {
407  this->CopyAllocate(pd, sze, ext, 0);
408  }
409  void CopyAllocate(vtkDataSetAttributes* pd, vtkIdType sze,
410  vtkIdType ext, int shallowCopyArrays);
412 
414 
416  void CopyStructuredData(vtkDataSetAttributes *inDsa,
417  const int *inExt, const int *outExt);
419 
421 
428  void CopyData(vtkDataSetAttributes *fromPd, vtkIdType fromId, vtkIdType toId);
429  void CopyData(vtkDataSetAttributes *fromPd,
430  vtkIdList *fromIds, vtkIdList *toIds);
432 
434 
438  void CopyTuple(vtkAbstractArray *fromData, vtkAbstractArray *toData,
439  vtkIdType fromId, vtkIdType toId);
440  void CopyTuples(vtkAbstractArray *fromData, vtkAbstractArray *toData,
441  vtkIdList *fromIds, vtkIdList *toIds);
443 
444 
445  // -- interpolate operations ----------------------------------------------
446 
448 
454  vtkIdType ext=1000)
455  {
456  this->InterpolateAllocate(pd, sze, ext, 0);
457  }
458  void InterpolateAllocate(vtkDataSetAttributes* pd, vtkIdType sze,
459  vtkIdType ext, int shallowCopyArrays);
461 
463 
468  void InterpolatePoint(vtkDataSetAttributes *fromPd, vtkIdType toId,
469  vtkIdList *ids, double *weights);
471 
473 
480  void InterpolateEdge(vtkDataSetAttributes *fromPd, vtkIdType toId,
481  vtkIdType p1, vtkIdType p2, double t);
483 
485 
495  void InterpolateTime(vtkDataSetAttributes *from1,
496  vtkDataSetAttributes *from2,
497  vtkIdType id, double t);
499 
500 //BTX
501  class FieldList;
502 
503  // field list copy operations ------------------------------------------
504 
506 
508  void CopyAllocate(vtkDataSetAttributes::FieldList& list, vtkIdType sze=0,
509  vtkIdType ext=1000);
511 
513 
517  void CopyData(vtkDataSetAttributes::FieldList& list,
518  vtkDataSetAttributes* dsa, int idx, vtkIdType fromId,
519  vtkIdType toId);
521 
523 
528  void InterpolateAllocate(vtkDataSetAttributes::FieldList& list, vtkIdType sze=0,
529  vtkIdType ext=1000);
531 
533 
537  void InterpolatePoint(
539  vtkDataSetAttributes *fromPd,
540  int idx, vtkIdType toId,
541  vtkIdList *ids, double *weights);
543 
545 //ETX
546 
547 //BTX
548 protected:
551 
553  int ctype,
554  vtkIdType sze=0,
555  vtkIdType ext=1000,
556  int shallowCopyArrays=0);
557 
560  int ctype,
561  vtkIdType sze, vtkIdType ext);
562 
564  virtual void InitializeFields();
565 
566  int AttributeIndices[NUM_ATTRIBUTES]; //index to attribute array in field data
567  int CopyAttributeFlags[ALLCOPY][NUM_ATTRIBUTES]; //copy flag for attribute data
568 
570 
572 
574  static const int AttributeLimits[NUM_ATTRIBUTES];
575  static const char AttributeNames[NUM_ATTRIBUTES][12];
576  static const char LongAttributeNames[NUM_ATTRIBUTES][35];
577 
578 private:
579  int SetAttribute(vtkAbstractArray* da, int attributeType);
580  static int CheckNumberOfComponents(vtkAbstractArray* da, int attributeType);
581 
582  vtkFieldData::BasicIterator ComputeRequiredArrays(vtkDataSetAttributes* pd, int ctype);
583 
584 private:
585  vtkDataSetAttributes(const vtkDataSetAttributes&); // Not implemented.
586  void operator=(const vtkDataSetAttributes&); // Not implemented.
587 
588 public:
589  // This public class is used to perform set operations, other misc.
590  // operations on fields. For example, vtkAppendFilter uses it to
591  // determine which attributes the input datasets share in common.
592  class vtkInternalComponentNames;
594  {
595  public:
596  FieldList(int numInputs);
597  ~FieldList();
598  void PrintSelf(ostream &os, vtkIndent indent);
599 
600  void InitializeFieldList(vtkDataSetAttributes* dsa);
601  void IntersectFieldList(vtkDataSetAttributes* dsa);
602 
607  void UnionFieldList(vtkDataSetAttributes* dsa);
608 
609  //Determine whether data is available
610  int IsAttributePresent(int attrType); //true/false attributes specified
611 
612  // Accessor methods.
613  int GetNumberOfFields() { return this->NumberOfFields; }
614  int GetFieldIndex(int i) { return this->FieldIndices[i]; }
615  const char* GetFieldName(int i) { return this->Fields[i]; }
616  int GetFieldComponents(int i) { return this->FieldComponents[i]; }
617  int GetDSAIndex(int index, int i) { return this->DSAIndices[index][i]; }
618 
619  friend class vtkDataSetAttributes;
620 
621  protected:
622  FieldList(const FieldList&) {} //prevent these methods from being used
623  void operator=(const FieldList&) {}
624 
625  void SetFieldIndex(int i, int index)
626  { this->FieldIndices[i] = index; }
627  private:
628  void SetField(int index, vtkAbstractArray *da);
629  void RemoveField(const char *name);
630  void ClearFields();
631  void GrowBy(unsigned int delta);
632 
633  int NumberOfFields; //the number of fields (including five named attributes)
634  // These keep track of what is common across datasets. The first
635  // six items are always named attributes.
636  char** Fields; // the names of the fields
637  int *FieldTypes; // the types of the fields
638  int *FieldComponents; // the number of components in field
639  int *FieldIndices; // output data array index
640  vtkLookupTable **LUT; // luts associated with each array
641  vtkInformation **FieldInformation; // Information map associated with each array
642 
643  vtkInternalComponentNames **FieldComponentsNames; // the name for each component in the field
644 
645  vtkIdType NumberOfTuples; // a running total of values
646 
647  //For every vtkDataSetAttributes that are processed, keep track of the
648  //indices into various things. The indices are organized so that the
649  //first NUM_ATTRIBUTES refer to attributes, the next refer to the
650  //non-attribute fields, for a total of NUM_ATTRIBUTES + NumberOfFields.
651  //CurrentInput is the current input being processed.
652  int **DSAIndices;
653  int NumberOfDSAIndices;
654  int CurrentInput;
655 
656  };
657 //ETX
658 };
659 
660 #endif
661 
662 
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:268
GLdouble GLdouble t
Definition: vtkgl.h:11602
static const int NumberOfAttributeComponents[NUM_ATTRIBUTES]
GLuint * ids
Definition: vtkgl.h:11831
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()
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