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 
108  // ----------- ghost points and ghost cells -------------------------------------------
109  //The following bit fields are consistent with VisIt ghost zones specification
110  //For details, see http://www.visitusers.org/index.php?title=Representing_ghost_data
111 
113  {
114  DUPLICATECELL = 1, //the cell is present on multiple processors
115  HIGHCONNECTIVITYCELL = 2, //the cell has more neighbors than in a regular mesh
116  LOWCONNECTIVITYCELL = 4, //the cell has less neighbors than in a regular mesh
117  REFINEDCELL = 8, //other cells are present that refines it.
118  EXTERIORCELL = 16, //the cell is on the exterior of the data set
119  HIDDENCELL = 32 //the cell is needed to maintain connectivity, but the data values should be ignored.
120  };
121 
123  {
124  DUPLICATEPOINT =1, //the cell is present on multiple processors
125  HIDDENPOINT =2 //the point is needed to maintain connectivity, but the data values should be ignored.
126  };
127 
128  //A vtkDataArray with this name must be of type vtkUnsignedCharArray.
129  //Each value must be assigned according to the bit fields described in
130  //PointGhostTypes or CellGhostType
131  static const char* GhostArrayName() { return "vtkGhostType";}
132 
133  //-----------------------------------------------------------------------------------
134 
136 
137  int SetScalars(vtkDataArray* da);
138  int SetActiveScalars(const char* name);
139  vtkDataArray* GetScalars();
141 
143 
144  int SetVectors(vtkDataArray* da);
145  int SetActiveVectors(const char* name);
146  vtkDataArray* GetVectors();
148 
150 
151  int SetNormals(vtkDataArray* da);
152  int SetActiveNormals(const char* name);
153  vtkDataArray* GetNormals();
155 
157 
158  int SetTCoords(vtkDataArray* da);
159  int SetActiveTCoords(const char* name);
160  vtkDataArray* GetTCoords();
162 
164 
165  int SetTensors(vtkDataArray* da);
166  int SetActiveTensors(const char* name);
167  vtkDataArray* GetTensors();
169 
171 
172  int SetGlobalIds(vtkDataArray* da);
173  int SetActiveGlobalIds(const char* name);
174  vtkDataArray* GetGlobalIds();
176 
178 
179  int SetPedigreeIds(vtkAbstractArray* da);
180  int SetActivePedigreeIds(const char* name);
181  vtkAbstractArray* GetPedigreeIds();
183 
185 
188  vtkDataArray* GetScalars(const char* name);
189  vtkDataArray* GetVectors(const char* name);
190  vtkDataArray* GetNormals(const char* name);
191  vtkDataArray* GetTCoords(const char* name);
192  vtkDataArray* GetTensors(const char* name);
193  vtkDataArray* GetGlobalIds(const char* name);
194  vtkAbstractArray* GetPedigreeIds(const char* name);
196 
204  int SetActiveAttribute(const char* name, int attributeType);
205 
207  int SetActiveAttribute(int index, int attributeType);
208 
211  void GetAttributeIndices(int* indexArray);
212 
217  int IsArrayAnAttribute(int idx);
218 
233  int SetAttribute(vtkAbstractArray* aa, int attributeType);
234 
239  vtkDataArray* GetAttribute(int attributeType);
240 
246  vtkAbstractArray* GetAbstractAttribute(int attributeType);
247 
249 
250  virtual void RemoveArray(const char *name);
251  virtual void RemoveArray(int index);
253 
254 
256 
258  static const char* GetAttributeTypeAsString(int attributeType);
259  static const char* GetLongAttributeTypeAsString(int attributeType);
261 
262  // -- attribute copy properties ------------------------------------------
263 
264 //BTX
266  {
267  COPYTUPLE=0,
268  INTERPOLATE=1,
269  PASSDATA=2,
270  ALLCOPY //all of the above
271  };
272 //ETX
273 
278  void SetCopyAttribute (int index, int value, int ctype=ALLCOPY);
279 
281 
292  void SetCopyScalars(int i, int ctype=ALLCOPY);
293  int GetCopyScalars(int ctype=ALLCOPY);
294  vtkBooleanMacro(CopyScalars, int);
296 
298 
309  void SetCopyVectors(int i, int ctype=ALLCOPY);
310  int GetCopyVectors(int ctype=ALLCOPY);
311  vtkBooleanMacro(CopyVectors, int);
313 
315 
326  void SetCopyNormals(int i, int ctype=ALLCOPY);
327  int GetCopyNormals(int ctype=ALLCOPY);
328  vtkBooleanMacro(CopyNormals, int);
330 
332 
343  void SetCopyTCoords(int i, int ctype=ALLCOPY);
344  int GetCopyTCoords(int ctype=ALLCOPY);
345  vtkBooleanMacro(CopyTCoords, int);
347 
349 
360  void SetCopyTensors(int i, int ctype=ALLCOPY);
361  int GetCopyTensors(int ctype=ALLCOPY);
362  vtkBooleanMacro(CopyTensors, int);
364 
366 
377  void SetCopyGlobalIds(int i, int ctype=ALLCOPY);
378  int GetCopyGlobalIds(int ctype=ALLCOPY);
379  vtkBooleanMacro(CopyGlobalIds, int);
381 
383 
394  void SetCopyPedigreeIds(int i, int ctype=ALLCOPY);
395  int GetCopyPedigreeIds(int ctype=ALLCOPY);
396  vtkBooleanMacro(CopyPedigreeIds, int);
398 
410  virtual void CopyAllOn(int ctype=ALLCOPY);
411 
423  virtual void CopyAllOff(int ctype=ALLCOPY);
424 
425  // -- passthrough operations ----------------------------------------------
426 
434  virtual void PassData(vtkFieldData* fd);
435 
436  // -- copytuple operations ------------------------------------------------
437 
439 
448  vtkIdType ext=1000)
449  {
450  this->CopyAllocate(pd, sze, ext, 0);
451  }
452  void CopyAllocate(vtkDataSetAttributes* pd, vtkIdType sze,
453  vtkIdType ext, int shallowCopyArrays);
455 
457 
459  void CopyStructuredData(vtkDataSetAttributes *inDsa,
460  const int *inExt, const int *outExt);
462 
464 
471  void CopyData(vtkDataSetAttributes *fromPd, vtkIdType fromId, vtkIdType toId);
472  void CopyData(vtkDataSetAttributes *fromPd,
473  vtkIdList *fromIds, vtkIdList *toIds);
475 
477 
480  void CopyData(vtkDataSetAttributes *fromPd, vtkIdType dstStart, vtkIdType n,
481  vtkIdType srcStart);
483 
485 
489  void CopyTuple(vtkAbstractArray *fromData, vtkAbstractArray *toData,
490  vtkIdType fromId, vtkIdType toId);
491  void CopyTuples(vtkAbstractArray *fromData, vtkAbstractArray *toData,
492  vtkIdList *fromIds, vtkIdList *toIds);
493  void CopyTuples(vtkAbstractArray *fromData, vtkAbstractArray *toData,
494  vtkIdType dstStart, vtkIdType n, vtkIdType srcStart);
496 
497 
498  // -- interpolate operations ----------------------------------------------
499 
501 
507  vtkIdType ext=1000)
508  {
509  this->InterpolateAllocate(pd, sze, ext, 0);
510  }
511  void InterpolateAllocate(vtkDataSetAttributes* pd, vtkIdType sze,
512  vtkIdType ext, int shallowCopyArrays);
514 
516 
521  void InterpolatePoint(vtkDataSetAttributes *fromPd, vtkIdType toId,
522  vtkIdList *ids, double *weights);
524 
526 
533  void InterpolateEdge(vtkDataSetAttributes *fromPd, vtkIdType toId,
534  vtkIdType p1, vtkIdType p2, double t);
536 
538 
548  void InterpolateTime(vtkDataSetAttributes *from1,
549  vtkDataSetAttributes *from2,
550  vtkIdType id, double t);
552 
553 //BTX
554  class FieldList;
555 
556  // field list copy operations ------------------------------------------
557 
559 
561  void CopyAllocate(vtkDataSetAttributes::FieldList& list, vtkIdType sze=0,
562  vtkIdType ext=1000);
564 
566 
570  void CopyData(vtkDataSetAttributes::FieldList& list,
571  vtkDataSetAttributes* dsa, int idx, vtkIdType fromId,
572  vtkIdType toId);
574 
576 
581  void InterpolateAllocate(vtkDataSetAttributes::FieldList& list, vtkIdType sze=0,
582  vtkIdType ext=1000);
584 
586 
590  void InterpolatePoint(
592  vtkDataSetAttributes *fromPd,
593  int idx, vtkIdType toId,
594  vtkIdList *ids, double *weights);
596 
598 //ETX
599 
600 //BTX
601 protected:
604 
606  int ctype,
607  vtkIdType sze=0,
608  vtkIdType ext=1000,
609  int shallowCopyArrays=0);
610 
613  int ctype,
614  vtkIdType sze, vtkIdType ext);
615 
617  virtual void InitializeFields();
618 
619  int AttributeIndices[NUM_ATTRIBUTES]; //index to attribute array in field data
620  int CopyAttributeFlags[ALLCOPY][NUM_ATTRIBUTES]; //copy flag for attribute data
621 
623 
625 
627  static const int AttributeLimits[NUM_ATTRIBUTES];
628  static const char AttributeNames[NUM_ATTRIBUTES][12];
629  static const char LongAttributeNames[NUM_ATTRIBUTES][35];
630 
631 private:
632  static int CheckNumberOfComponents(vtkAbstractArray* da, int attributeType);
633 
634  vtkFieldData::BasicIterator ComputeRequiredArrays(vtkDataSetAttributes* pd, int ctype);
635 
636 private:
637  vtkDataSetAttributes(const vtkDataSetAttributes&); // Not implemented.
638  void operator=(const vtkDataSetAttributes&); // Not implemented.
639 
640 public:
641  // This public class is used to perform set operations, other misc.
642  // operations on fields. For example, vtkAppendFilter uses it to
643  // determine which attributes the input datasets share in common.
644  class vtkInternalComponentNames;
646  {
647  public:
648  FieldList(int numInputs);
649  ~FieldList();
650  void PrintSelf(ostream &os, vtkIndent indent);
651 
652  void InitializeFieldList(vtkDataSetAttributes* dsa);
653  void IntersectFieldList(vtkDataSetAttributes* dsa);
654 
659  void UnionFieldList(vtkDataSetAttributes* dsa);
660 
661  //Determine whether data is available
662  int IsAttributePresent(int attrType); //true/false attributes specified
663 
664  // Accessor methods.
665  int GetNumberOfFields() { return this->NumberOfFields; }
666  int GetFieldIndex(int i) { return this->FieldIndices[i]; }
667  const char* GetFieldName(int i) { return this->Fields[i]; }
668  int GetFieldComponents(int i) { return this->FieldComponents[i]; }
669  int GetDSAIndex(int index, int i) { return this->DSAIndices[index][i]; }
670 
671  friend class vtkDataSetAttributes;
672 
673  protected:
674  FieldList(const FieldList&) {} //prevent these methods from being used
675  void operator=(const FieldList&) {}
676 
677  void SetFieldIndex(int i, int index)
678  { this->FieldIndices[i] = index; }
679  private:
680  void SetField(int index, vtkAbstractArray *da);
681  void RemoveField(const char *name);
682  void ClearFields();
683  void GrowBy(unsigned int delta);
684 
685  int NumberOfFields; //the number of fields (including five named attributes)
686  // These keep track of what is common across datasets. The first
687  // six items are always named attributes.
688  char** Fields; // the names of the fields
689  int *FieldTypes; // the types of the fields
690  int *FieldComponents; // the number of components in field
691  int *FieldIndices; // output data array index
692  vtkLookupTable **LUT; // luts associated with each array
693  vtkInformation **FieldInformation; // Information map associated with each array
694 
695  vtkInternalComponentNames **FieldComponentsNames; // the name for each component in the field
696 
697  vtkIdType NumberOfTuples; // a running total of values
698 
699  //For every vtkDataSetAttributes that are processed, keep track of the
700  //indices into various things. The indices are organized so that the
701  //first NUM_ATTRIBUTES refer to attributes, the next refer to the
702  //non-attribute fields, for a total of NUM_ATTRIBUTES + NumberOfFields.
703  //CurrentInput is the current input being processed.
704  int **DSAIndices;
705  int NumberOfDSAIndices;
706  int CurrentInput;
707 
708  };
709 //ETX
710 };
711 
712 #endif
void InternalCopyAllocate(vtkDataSetAttributes *pd, int ctype, vtkIdType sze=0, vtkIdType ext=1000, int shallowCopyArrays=0)
static const char * GhostArrayName()
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)
virtual void CopyAllOn(int unused=0)
int vtkIdType
Definition: vtkType.h:275
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: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:54
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