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 =========================================================================*/
50 #ifndef vtkDataSetAttributes_h
51 #define vtkDataSetAttributes_h
52 
53 #include "vtkCommonDataModelModule.h" // For export macro
54 #include "vtkFieldData.h"
55 
56 class vtkLookupTable;
57 
58 class VTKCOMMONDATAMODEL_EXPORT vtkDataSetAttributes : public vtkFieldData
59 {
60 public:
64  static vtkDataSetAttributes *New();
65 
67  void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
68 
73  void Initialize() VTK_OVERRIDE;
74 
79  virtual void Update() {}
80 
81  // -- shallow and deep copy -----------------------------------------------
82 
88  void DeepCopy(vtkFieldData *pd) VTK_OVERRIDE;
89 
94  void ShallowCopy(vtkFieldData *pd) VTK_OVERRIDE;
95 
96  // -- attribute types -----------------------------------------------------
97 
98  // Always keep NUM_ATTRIBUTES as the last entry
100  {
101  SCALARS=0,
102  VECTORS=1,
103  NORMALS=2,
104  TCOORDS=3,
105  TENSORS=4,
106  GLOBALIDS=5,
107  PEDIGREEIDS=6,
108  EDGEFLAG=7,
109  NUM_ATTRIBUTES
110  };
111 
113  {
116  NOLIMIT
117  };
118 
119  // ----------- ghost points and ghost cells -------------------------------------------
120  //The following bit fields are consistent with VisIt ghost zones specification
121  //For details, see http://www.visitusers.org/index.php?title=Representing_ghost_data
122 
124  {
125  DUPLICATECELL = 1, //the cell is present on multiple processors
126  HIGHCONNECTIVITYCELL = 2, //the cell has more neighbors than in a regular mesh
127  LOWCONNECTIVITYCELL = 4, //the cell has less neighbors than in a regular mesh
128  REFINEDCELL = 8, //other cells are present that refines it.
129  EXTERIORCELL = 16, //the cell is on the exterior of the data set
130  HIDDENCELL = 32 //the cell is needed to maintain connectivity, but the data values should be ignored.
131  };
132 
134  {
135  DUPLICATEPOINT =1, //the cell is present on multiple processors
136  HIDDENPOINT =2 //the point is needed to maintain connectivity, but the data values should be ignored.
137  };
138 
139  //A vtkDataArray with this name must be of type vtkUnsignedCharArray.
140  //Each value must be assigned according to the bit fields described in
141  //PointGhostTypes or CellGhostType
142  static const char* GhostArrayName() { return "vtkGhostType";}
143 
144  //-----------------------------------------------------------------------------------
145 
147 
150  int SetScalars(vtkDataArray* da);
151  int SetActiveScalars(const char* name);
152  vtkDataArray* GetScalars();
154 
156 
159  int SetVectors(vtkDataArray* da);
160  int SetActiveVectors(const char* name);
161  vtkDataArray* GetVectors();
163 
165 
168  int SetNormals(vtkDataArray* da);
169  int SetActiveNormals(const char* name);
170  vtkDataArray* GetNormals();
172 
174 
177  int SetTCoords(vtkDataArray* da);
178  int SetActiveTCoords(const char* name);
179  vtkDataArray* GetTCoords();
181 
183 
186  int SetTensors(vtkDataArray* da);
187  int SetActiveTensors(const char* name);
188  vtkDataArray* GetTensors();
190 
192 
195  int SetGlobalIds(vtkDataArray* da);
196  int SetActiveGlobalIds(const char* name);
197  vtkDataArray* GetGlobalIds();
199 
201 
204  int SetPedigreeIds(vtkAbstractArray* da);
205  int SetActivePedigreeIds(const char* name);
206  vtkAbstractArray* GetPedigreeIds();
208 
210 
215  vtkDataArray* GetScalars(const char* name);
216  vtkDataArray* GetVectors(const char* name);
217  vtkDataArray* GetNormals(const char* name);
218  vtkDataArray* GetTCoords(const char* name);
219  vtkDataArray* GetTensors(const char* name);
220  vtkDataArray* GetGlobalIds(const char* name);
221  vtkAbstractArray* GetPedigreeIds(const char* name);
223 
238  int SetActiveAttribute(const char* name, int attributeType);
239 
243  int SetActiveAttribute(int index, int attributeType);
244 
249  void GetAttributeIndices(int* indexArray);
250 
257  int IsArrayAnAttribute(int idx);
258 
281  int SetAttribute(vtkAbstractArray* aa, int attributeType);
282 
289  vtkDataArray* GetAttribute(int attributeType);
290 
298  vtkAbstractArray* GetAbstractAttribute(int attributeType);
299 
301 
305  void RemoveArray(int index) VTK_OVERRIDE;
307 
308 
310 
314  static const char* GetAttributeTypeAsString(int attributeType);
315  static const char* GetLongAttributeTypeAsString(int attributeType);
317 
318  // -- attribute copy properties ------------------------------------------
319 
321  {
322  COPYTUPLE=0,
323  INTERPOLATE=1,
324  PASSDATA=2,
325  ALLCOPY //all of the above
326  };
327 
349  void SetCopyAttribute (int index, int value, int ctype=ALLCOPY);
350 
355  int GetCopyAttribute (int index, int ctype);
356 
358  void SetCopyScalars(int i, int ctype=ALLCOPY);
359  int GetCopyScalars(int ctype=ALLCOPY);
360  vtkBooleanMacro(CopyScalars, int);
361 
363  void SetCopyVectors(int i, int ctype=ALLCOPY);
364  int GetCopyVectors(int ctype=ALLCOPY);
365  vtkBooleanMacro(CopyVectors, int);
366 
368  void SetCopyNormals(int i, int ctype=ALLCOPY);
369  int GetCopyNormals(int ctype=ALLCOPY);
370  vtkBooleanMacro(CopyNormals, int);
371 
373  void SetCopyTCoords(int i, int ctype=ALLCOPY);
374  int GetCopyTCoords(int ctype=ALLCOPY);
375  vtkBooleanMacro(CopyTCoords, int);
376 
378  void SetCopyTensors(int i, int ctype=ALLCOPY);
379  int GetCopyTensors(int ctype=ALLCOPY);
380  vtkBooleanMacro(CopyTensors, int);
381 
383  void SetCopyGlobalIds(int i, int ctype=ALLCOPY);
384  int GetCopyGlobalIds(int ctype=ALLCOPY);
385  vtkBooleanMacro(CopyGlobalIds, int);
386 
388  void SetCopyPedigreeIds(int i, int ctype=ALLCOPY);
389  int GetCopyPedigreeIds(int ctype=ALLCOPY);
390  vtkBooleanMacro(CopyPedigreeIds, int);
391 
393  void CopyAllOn(int ctype=ALLCOPY) VTK_OVERRIDE;
394 
396  void CopyAllOff(int ctype=ALLCOPY) VTK_OVERRIDE;
397 
398  // -- passthrough operations ----------------------------------------------
399 
409  void PassData(vtkFieldData* fd) VTK_OVERRIDE;
410 
411  // -- copytuple operations ------------------------------------------------
412 
414 
425  void CopyAllocate(vtkDataSetAttributes* pd, vtkIdType sze=0,
426  vtkIdType ext=1000)
427  {
428  this->CopyAllocate(pd, sze, ext, 0);
429  }
430  void CopyAllocate(vtkDataSetAttributes* pd, vtkIdType sze,
431  vtkIdType ext, int shallowCopyArrays);
433 
438  void CopyStructuredData(vtkDataSetAttributes *inDsa,
439  const int *inExt, const int *outExt);
440 
442 
452  void CopyData(vtkDataSetAttributes *fromPd, vtkIdType fromId, vtkIdType toId);
453  void CopyData(vtkDataSetAttributes *fromPd,
454  vtkIdList *fromIds, vtkIdList *toIds);
456 
462  void CopyData(vtkDataSetAttributes *fromPd, vtkIdType dstStart, vtkIdType n,
463  vtkIdType srcStart);
464 
466 
472  void CopyTuple(vtkAbstractArray *fromData, vtkAbstractArray *toData,
473  vtkIdType fromId, vtkIdType toId);
474  void CopyTuples(vtkAbstractArray *fromData, vtkAbstractArray *toData,
475  vtkIdList *fromIds, vtkIdList *toIds);
476  void CopyTuples(vtkAbstractArray *fromData, vtkAbstractArray *toData,
477  vtkIdType dstStart, vtkIdType n, vtkIdType srcStart);
479 
480 
481  // -- interpolate operations ----------------------------------------------
482 
484 
493  vtkIdType ext=1000)
494  {
495  this->InterpolateAllocate(pd, sze, ext, 0);
496  }
497  void InterpolateAllocate(vtkDataSetAttributes* pd, vtkIdType sze,
498  vtkIdType ext, int shallowCopyArrays);
500 
508  void InterpolatePoint(vtkDataSetAttributes *fromPd, vtkIdType toId,
509  vtkIdList *ids, double *weights);
510 
520  void InterpolateEdge(vtkDataSetAttributes *fromPd, vtkIdType toId,
521  vtkIdType p1, vtkIdType p2, double t);
522 
535  void InterpolateTime(vtkDataSetAttributes *from1,
536  vtkDataSetAttributes *from2,
537  vtkIdType id, double t);
538 
539  class FieldList;
540 
541  // field list copy operations ------------------------------------------
542 
547  void CopyAllocate(vtkDataSetAttributes::FieldList& list, vtkIdType sze=0,
548  vtkIdType ext=1000);
549 
556  void CopyData(vtkDataSetAttributes::FieldList& list,
557  vtkDataSetAttributes* dsa, int idx, vtkIdType fromId,
558  vtkIdType toId);
559 
566  void InterpolateAllocate(vtkDataSetAttributes::FieldList& list, vtkIdType sze=0,
567  vtkIdType ext=1000);
568 
575  void InterpolatePoint(
577  vtkDataSetAttributes *fromPd,
578  int idx, vtkIdType toId,
579  vtkIdList *ids, double *weights);
580 
582 
583 protected:
585  ~vtkDataSetAttributes() VTK_OVERRIDE;
586 
588  int ctype,
589  vtkIdType sze=0,
590  vtkIdType ext=1000,
591  int shallowCopyArrays=0);
592 
595  int ctype,
596  vtkIdType sze, vtkIdType ext);
597 
601  void InitializeFields() VTK_OVERRIDE;
602 
603  int AttributeIndices[NUM_ATTRIBUTES]; //index to attribute array in field data
604  int CopyAttributeFlags[ALLCOPY][NUM_ATTRIBUTES]; //copy flag for attribute data
605 
607 
609 
610  static const int NumberOfAttributeComponents[NUM_ATTRIBUTES];
611  static const int AttributeLimits[NUM_ATTRIBUTES];
612  static const char AttributeNames[NUM_ATTRIBUTES][12];
613  static const char LongAttributeNames[NUM_ATTRIBUTES][35];
614 
615 private:
616  static int CheckNumberOfComponents(vtkAbstractArray* da, int attributeType);
617 
618  vtkFieldData::BasicIterator ComputeRequiredArrays(vtkDataSetAttributes* pd, int ctype);
619 
620 private:
621  vtkDataSetAttributes(const vtkDataSetAttributes&) VTK_DELETE_FUNCTION;
622  void operator=(const vtkDataSetAttributes&) VTK_DELETE_FUNCTION;
623 
624 public:
625  // This public class is used to perform set operations, other misc.
626  // operations on fields. For example, vtkAppendFilter uses it to
627  // determine which attributes the input datasets share in common.
628  class vtkInternalComponentNames;
629  class VTKCOMMONDATAMODEL_EXPORT FieldList
630  {
631  public:
632  FieldList(int numInputs);
633  ~FieldList();
634  void PrintSelf(ostream &os, vtkIndent indent);
635 
638 
647 
648  //Determine whether data is available
649  int IsAttributePresent(int attrType); //true/false attributes specified
650 
651  // Accessor methods.
652  int GetNumberOfFields() { return this->NumberOfFields; }
653  int GetFieldIndex(int i) { return this->FieldIndices[i]; }
654  const char* GetFieldName(int i) { return this->Fields[i]; }
655  int GetFieldComponents(int i) { return this->FieldComponents[i]; }
656  int GetDSAIndex(int index, int i) { return this->DSAIndices[index][i]; }
657 
658  friend class vtkDataSetAttributes;
659 
660  protected:
661  void SetFieldIndex(int i, int index)
662  { this->FieldIndices[i] = index; }
663  private:
664  FieldList(const FieldList&) VTK_DELETE_FUNCTION;
665  void operator=(const FieldList&) VTK_DELETE_FUNCTION;
666 
667  void SetField(int index, vtkAbstractArray *da);
668  void RemoveField(const char *name);
669  void ClearFields();
670  void GrowBy(unsigned int delta);
671 
672  int NumberOfFields; //the number of fields (including five named attributes)
673  // These keep track of what is common across datasets. The first
674  // six items are always named attributes.
675  char** Fields; // the names of the fields
676  int *FieldTypes; // the types of the fields
677  int *FieldComponents; // the number of components in field
678  int *FieldIndices; // output data array index
679  vtkLookupTable **LUT; // luts associated with each array
680  vtkInformation **FieldInformation; // Information map associated with each array
681 
682  vtkInternalComponentNames **FieldComponentsNames; // the name for each component in the field
683 
684  vtkIdType NumberOfTuples; // a running total of values
685 
686  //For every vtkDataSetAttributes that are processed, keep track of the
687  //indices into various things. The indices are organized so that the
688  //first NUM_ATTRIBUTES refer to attributes, the next refer to the
689  //non-attribute fields, for a total of NUM_ATTRIBUTES + NumberOfFields.
690  //CurrentInput is the current input being processed.
691  int **DSAIndices;
692  int NumberOfDSAIndices;
693  int CurrentInput;
694 
695  };
696 
697 };
698 
699 #endif
void InternalCopyAllocate(vtkDataSetAttributes *pd, int ctype, vtkIdType sze=0, vtkIdType ext=1000, int shallowCopyArrays=0)
static const char * GhostArrayName()
void InitializeFields() override
Initialize all of the object's data to NULL.
Store vtkAlgorithm input/output information.
Abstract superclass for all arrays.
void InterpolateAllocate(vtkDataSetAttributes *pd, vtkIdType sze=0, vtkIdType ext=1000)
Initialize point interpolation method.
static const char LongAttributeNames[NUM_ATTRIBUTES][35]
map scalar values into colors via a lookup table
static const char AttributeNames[NUM_ATTRIBUTES][12]
void InitializeFieldList(vtkDataSetAttributes *dsa)
virtual void Update()
Updates the extensions string.
virtual void CopyAllOn(int unused=0)
Turn on copying of all data.
int vtkIdType
Definition: vtkType.h:287
static const int NumberOfAttributeComponents[NUM_ATTRIBUTES]
~vtkDataSetAttributes() override
static const int AttributeLimits[NUM_ATTRIBUTES]
void UnionFieldList(vtkDataSetAttributes *dsa)
Similar to IntersectFieldList() except that it builds a union of the array list.
static vtkFieldData * New()
void IntersectFieldList(vtkDataSetAttributes *dsa)
a simple class to control print indentation
Definition: vtkIndent.h:39
list of point or cell ids
Definition: vtkIdList.h:36
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)
int IsAttributePresent(int attrType)
virtual void DeepCopy(vtkFieldData *da)
Copy a field by creating new data arrays (i.e., duplicate storage).
virtual void Initialize()
Release all data but do not delete object.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkBooleanMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
int CopyAttributeFlags[ALLCOPY][NUM_ATTRIBUTES]
virtual void ShallowCopy(vtkFieldData *da)
Copy a field by reference counting the data arrays.
virtual void RemoveArray(const char *name)
Remove an array (with the given name or index) from the list of arrays.
vtkFieldData::BasicIterator RequiredArrays
int AttributeIndices[NUM_ATTRIBUTES]
represent and manipulate fields of data
Definition: vtkFieldData.h:56