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) override;
68 
73  void Initialize() override;
74 
79  virtual void Update() {}
80 
81  // -- shallow and deep copy -----------------------------------------------
82 
88  void DeepCopy(vtkFieldData *pd) override;
89 
94  void ShallowCopy(vtkFieldData *pd) 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) 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) override;
394 
396  void CopyAllOff(int ctype=ALLCOPY) override;
397 
398  // -- passthrough operations ----------------------------------------------
399 
409  void PassData(vtkFieldData* fd) override;
410 
411  // -- copytuple operations ------------------------------------------------
412 
414 
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 
441  void SetupForCopy(vtkDataSetAttributes* pd);
442 
443 
452  void CopyStructuredData(vtkDataSetAttributes *inDsa,
453  const int *inExt,
454  const int *outExt,
455  bool setSize = true);
456 
458 
468  void CopyData(vtkDataSetAttributes *fromPd, vtkIdType fromId, vtkIdType toId);
469  void CopyData(vtkDataSetAttributes *fromPd,
470  vtkIdList *fromIds, vtkIdList *toIds);
472 
478  void CopyData(vtkDataSetAttributes *fromPd, vtkIdType dstStart, vtkIdType n,
479  vtkIdType srcStart);
480 
482 
488  void CopyTuple(vtkAbstractArray *fromData, vtkAbstractArray *toData,
489  vtkIdType fromId, vtkIdType toId);
490  void CopyTuples(vtkAbstractArray *fromData, vtkAbstractArray *toData,
491  vtkIdList *fromIds, vtkIdList *toIds);
492  void CopyTuples(vtkAbstractArray *fromData, vtkAbstractArray *toData,
493  vtkIdType dstStart, vtkIdType n, vtkIdType srcStart);
495 
496 
497  // -- interpolate operations ----------------------------------------------
498 
500 
509  vtkIdType ext=1000)
510  {
511  this->InterpolateAllocate(pd, sze, ext, 0);
512  }
513  void InterpolateAllocate(vtkDataSetAttributes* pd, vtkIdType sze,
514  vtkIdType ext, int shallowCopyArrays);
516 
524  void InterpolatePoint(vtkDataSetAttributes *fromPd, vtkIdType toId,
525  vtkIdList *ids, double *weights);
526 
536  void InterpolateEdge(vtkDataSetAttributes *fromPd, vtkIdType toId,
537  vtkIdType p1, vtkIdType p2, double t);
538 
551  void InterpolateTime(vtkDataSetAttributes *from1,
552  vtkDataSetAttributes *from2,
553  vtkIdType id, double t);
554 
555  class FieldList;
556 
557  // field list copy operations ------------------------------------------
558 
563  void CopyAllocate(vtkDataSetAttributes::FieldList& list, vtkIdType sze=0,
564  vtkIdType ext=1000);
565 
572  void CopyData(vtkDataSetAttributes::FieldList& list,
573  vtkDataSetAttributes* dsa, int idx, vtkIdType fromId,
574  vtkIdType toId);
575  void CopyData(vtkDataSetAttributes::FieldList& list,
576  vtkDataSetAttributes* dsa, int idx, vtkIdType dstStart,
577  vtkIdType n, vtkIdType srcStart);
578 
585  void InterpolateAllocate(vtkDataSetAttributes::FieldList& list, vtkIdType sze=0,
586  vtkIdType ext=1000);
587 
594  void InterpolatePoint(
596  vtkDataSetAttributes *fromPd,
597  int idx, vtkIdType toId,
598  vtkIdList *ids, double *weights);
599 
601 
602 protected:
604  ~vtkDataSetAttributes() override;
605 
607  int ctype,
608  vtkIdType sze=0,
609  vtkIdType ext=1000,
610  int shallowCopyArrays=0,
611  bool createNewArrays=true);
612 
615  int ctype,
616  vtkIdType sze, vtkIdType ext);
617 
621  void InitializeFields() override;
622 
623  int AttributeIndices[NUM_ATTRIBUTES]; //index to attribute array in field data
624  int CopyAttributeFlags[ALLCOPY][NUM_ATTRIBUTES]; //copy flag for attribute data
625 
627 
629 
631  static const int AttributeLimits[NUM_ATTRIBUTES];
632  static const char AttributeNames[NUM_ATTRIBUTES][12];
633  static const char LongAttributeNames[NUM_ATTRIBUTES][35];
634 
635 private:
636  static int CheckNumberOfComponents(vtkAbstractArray* da, int attributeType);
637 
638  vtkFieldData::BasicIterator ComputeRequiredArrays(vtkDataSetAttributes* pd, int ctype);
639 
640 private:
642  void operator=(const vtkDataSetAttributes&) = delete;
643 
644 public:
645  // This public class is used to perform set operations, other misc.
646  // operations on fields. For example, vtkAppendFilter uses it to
647  // determine which attributes the input datasets share in common.
648  class vtkInternalComponentNames;
649  class VTKCOMMONDATAMODEL_EXPORT FieldList
650  {
651  public:
652  FieldList(int numInputs);
653  ~FieldList();
654  void PrintSelf(ostream &os, vtkIndent indent);
655 
656  void InitializeFieldList(vtkDataSetAttributes* dsa);
657  void IntersectFieldList(vtkDataSetAttributes* dsa);
658 
666  void UnionFieldList(vtkDataSetAttributes* dsa);
667 
668  //Determine whether data is available
669  int IsAttributePresent(int attrType); //true/false attributes specified
670 
671  // Accessor methods.
672  int GetNumberOfFields() { return this->NumberOfFields; }
673  int GetFieldIndex(int i) { return this->FieldIndices[i]; }
674  const char* GetFieldName(int i) { return this->Fields[i]; }
675  int GetFieldComponents(int i) { return this->FieldComponents[i]; }
676  int GetDSAIndex(int index, int i) { return this->DSAIndices[index][i]; }
677 
678  friend class vtkDataSetAttributes;
679 
680  protected:
681  void SetFieldIndex(int i, int index)
682  { this->FieldIndices[i] = index; }
683  private:
684  FieldList(const FieldList&) = delete;
685  void operator=(const FieldList&) = delete;
686 
687  void SetField(int index, vtkAbstractArray *da);
688  void RemoveField(const char *name);
689  void ClearFields();
690  void GrowBy(unsigned int delta);
691 
692  int NumberOfFields; //the number of fields (including five named attributes)
693  // These keep track of what is common across datasets. The first
694  // six items are always named attributes.
695  char** Fields; // the names of the fields
696  int *FieldTypes; // the types of the fields
697  int *FieldComponents; // the number of components in field
698  int *FieldIndices; // output data array index
699  vtkLookupTable **LUT; // luts associated with each array
700  vtkInformation **FieldInformation; // Information map associated with each array
701 
702  vtkInternalComponentNames **FieldComponentsNames; // the name for each component in the field
703 
704  vtkIdType NumberOfTuples; // a running total of values
705 
706  //For every vtkDataSetAttributes that are processed, keep track of the
707  //indices into various things. The indices are organized so that the
708  //first NUM_ATTRIBUTES refer to attributes, the next refer to the
709  //non-attribute fields, for a total of NUM_ATTRIBUTES + NumberOfFields.
710  //CurrentInput is the current input being processed.
711  int **DSAIndices;
712  int NumberOfDSAIndices;
713  int CurrentInput;
714 
715  };
716 
717 };
718 
719 #endif
static const char * GhostArrayName()
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]
virtual void PassData(vtkFieldData *fd)
Pass entire arrays of input data through to output.
virtual void CopyAllOn(int unused=0)
Turn on copying of all data.
int vtkIdType
Definition: vtkType.h:345
static const int NumberOfAttributeComponents[NUM_ATTRIBUTES]
virtual void Update()
Attributes have a chance to bring themselves up to date; right now this is ignored.
~vtkDataSetAttributes() override
virtual void CopyAllOff(int unused=0)
Turn off copying of all data.
static const int AttributeLimits[NUM_ATTRIBUTES]
static vtkFieldData * New()
virtual void InitializeFields()
Release all data but do not delete object.
a simple class to control print indentation
Definition: vtkIndent.h:39
list of point or cell ids
Definition: vtkIdList.h:36
void CopyAllocate(vtkDataSetAttributes *pd, vtkIdType sze=0, vtkIdType ext=1000)
Allocates point data for point-by-point (or cell-by-cell) copy operation.
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)
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]
void InternalCopyAllocate(vtkDataSetAttributes *pd, int ctype, vtkIdType sze=0, vtkIdType ext=1000, int shallowCopyArrays=0, bool createNewArrays=true)
represent and manipulate fields of data
Definition: vtkFieldData.h:56