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 =========================================================================*/
44 #ifndef vtkDataSetAttributes_h
45 #define vtkDataSetAttributes_h
46 
47 #include "vtkCommonDataModelModule.h" // For export macro
48 #include "vtkFieldData.h"
49 
50 class vtkLookupTable;
51 
52 class VTKCOMMONDATAMODEL_EXPORT vtkDataSetAttributes : public vtkFieldData
53 {
54 public:
58  static vtkDataSetAttributes *New();
59 
61  void PrintSelf(ostream& os, vtkIndent indent) override;
62 
67  void Initialize() override;
68 
73  virtual void Update() {}
74 
75  // -- shallow and deep copy -----------------------------------------------
76 
82  void DeepCopy(vtkFieldData *pd) override;
83 
88  void ShallowCopy(vtkFieldData *pd) override;
89 
90  // -- attribute types -----------------------------------------------------
91 
92  // Always keep NUM_ATTRIBUTES as the last entry
94  {
95  SCALARS=0,
96  VECTORS=1,
97  NORMALS=2,
98  TCOORDS=3,
99  TENSORS=4,
100  GLOBALIDS=5,
101  PEDIGREEIDS=6,
102  EDGEFLAG=7,
103  NUM_ATTRIBUTES
104  };
105 
107  {
110  NOLIMIT
111  };
112 
113  // ----------- ghost points and ghost cells -------------------------------------------
114  //The following bit fields are consistent with VisIt ghost zones specification
115  //For details, see http://www.visitusers.org/index.php?title=Representing_ghost_data
116 
118  {
119  DUPLICATECELL = 1, //the cell is present on multiple processors
120  HIGHCONNECTIVITYCELL = 2, //the cell has more neighbors than in a regular mesh
121  LOWCONNECTIVITYCELL = 4, //the cell has less neighbors than in a regular mesh
122  REFINEDCELL = 8, //other cells are present that refines it.
123  EXTERIORCELL = 16, //the cell is on the exterior of the data set
124  HIDDENCELL = 32 //the cell is needed to maintain connectivity, but the data values should be ignored.
125  };
126 
128  {
129  DUPLICATEPOINT =1, //the cell is present on multiple processors
130  HIDDENPOINT =2 //the point is needed to maintain connectivity, but the data values should be ignored.
131  };
132 
133  //A vtkDataArray with this name must be of type vtkUnsignedCharArray.
134  //Each value must be assigned according to the bit fields described in
135  //PointGhostTypes or CellGhostType
136  static const char* GhostArrayName() { return "vtkGhostType";}
137 
138  //-----------------------------------------------------------------------------------
139 
141 
144  int SetScalars(vtkDataArray* da);
145  int SetActiveScalars(const char* name);
146  vtkDataArray* GetScalars();
148 
150 
153  int SetVectors(vtkDataArray* da);
154  int SetActiveVectors(const char* name);
155  vtkDataArray* GetVectors();
157 
159 
162  int SetNormals(vtkDataArray* da);
163  int SetActiveNormals(const char* name);
164  vtkDataArray* GetNormals();
166 
168 
171  int SetTCoords(vtkDataArray* da);
172  int SetActiveTCoords(const char* name);
173  vtkDataArray* GetTCoords();
175 
177 
180  int SetTensors(vtkDataArray* da);
181  int SetActiveTensors(const char* name);
182  vtkDataArray* GetTensors();
184 
186 
189  int SetGlobalIds(vtkDataArray* da);
190  int SetActiveGlobalIds(const char* name);
191  vtkDataArray* GetGlobalIds();
193 
195 
198  int SetPedigreeIds(vtkAbstractArray* da);
199  int SetActivePedigreeIds(const char* name);
200  vtkAbstractArray* GetPedigreeIds();
202 
204 
209  vtkDataArray* GetScalars(const char* name);
210  vtkDataArray* GetVectors(const char* name);
211  vtkDataArray* GetNormals(const char* name);
212  vtkDataArray* GetTCoords(const char* name);
213  vtkDataArray* GetTensors(const char* name);
214  vtkDataArray* GetGlobalIds(const char* name);
215  vtkAbstractArray* GetPedigreeIds(const char* name);
217 
232  int SetActiveAttribute(const char* name, int attributeType);
233 
237  int SetActiveAttribute(int index, int attributeType);
238 
243  void GetAttributeIndices(int* indexArray);
244 
251  int IsArrayAnAttribute(int idx);
252 
275  int SetAttribute(vtkAbstractArray* aa, int attributeType);
276 
283  vtkDataArray* GetAttribute(int attributeType);
284 
292  vtkAbstractArray* GetAbstractAttribute(int attributeType);
293 
295 
299  void RemoveArray(int index) override;
301 
302 
304 
308  static const char* GetAttributeTypeAsString(int attributeType);
309  static const char* GetLongAttributeTypeAsString(int attributeType);
311 
312  // -- attribute copy properties ------------------------------------------
313 
315  {
316  COPYTUPLE=0,
317  INTERPOLATE=1,
318  PASSDATA=2,
319  ALLCOPY //all of the above
320  };
321 
343  void SetCopyAttribute (int index, int value, int ctype=ALLCOPY);
344 
349  int GetCopyAttribute (int index, int ctype);
350 
352  void SetCopyScalars(vtkTypeBool i, int ctype=ALLCOPY);
353  vtkTypeBool GetCopyScalars(int ctype=ALLCOPY);
354  vtkBooleanMacro(CopyScalars, vtkTypeBool);
355 
357  void SetCopyVectors(vtkTypeBool i, int ctype=ALLCOPY);
358  vtkTypeBool GetCopyVectors(int ctype=ALLCOPY);
359  vtkBooleanMacro(CopyVectors, vtkTypeBool);
360 
362  void SetCopyNormals(vtkTypeBool i, int ctype=ALLCOPY);
363  vtkTypeBool GetCopyNormals(int ctype=ALLCOPY);
364  vtkBooleanMacro(CopyNormals, vtkTypeBool);
365 
367  void SetCopyTCoords(vtkTypeBool i, int ctype=ALLCOPY);
368  vtkTypeBool GetCopyTCoords(int ctype=ALLCOPY);
369  vtkBooleanMacro(CopyTCoords, vtkTypeBool);
370 
372  void SetCopyTensors(vtkTypeBool i, int ctype=ALLCOPY);
373  vtkTypeBool GetCopyTensors(int ctype=ALLCOPY);
374  vtkBooleanMacro(CopyTensors, vtkTypeBool);
375 
377  void SetCopyGlobalIds(vtkTypeBool i, int ctype=ALLCOPY);
378  vtkTypeBool GetCopyGlobalIds(int ctype=ALLCOPY);
379  vtkBooleanMacro(CopyGlobalIds, vtkTypeBool);
380 
382  void SetCopyPedigreeIds(vtkTypeBool i, int ctype=ALLCOPY);
383  vtkTypeBool GetCopyPedigreeIds(int ctype=ALLCOPY);
384  vtkBooleanMacro(CopyPedigreeIds, vtkTypeBool);
385 
387  void CopyAllOn(int ctype=ALLCOPY) override;
388 
390  void CopyAllOff(int ctype=ALLCOPY) override;
391 
392  // -- passthrough operations ----------------------------------------------
393 
403  void PassData(vtkFieldData* fd) override;
404 
405  // -- copytuple operations ------------------------------------------------
406 
408 
420  vtkIdType ext=1000)
421  {
422  this->CopyAllocate(pd, sze, ext, 0);
423  }
424  void CopyAllocate(vtkDataSetAttributes* pd, vtkIdType sze,
425  vtkIdType ext, int shallowCopyArrays);
427 
435  void SetupForCopy(vtkDataSetAttributes* pd);
436 
437 
446  void CopyStructuredData(vtkDataSetAttributes *inDsa,
447  const int *inExt,
448  const int *outExt,
449  bool setSize = true);
450 
452 
462  void CopyData(vtkDataSetAttributes *fromPd, vtkIdType fromId, vtkIdType toId);
463  void CopyData(vtkDataSetAttributes *fromPd,
464  vtkIdList *fromIds, vtkIdList *toIds);
466 
472  void CopyData(vtkDataSetAttributes *fromPd, vtkIdType dstStart, vtkIdType n,
473  vtkIdType srcStart);
474 
476 
482  void CopyTuple(vtkAbstractArray *fromData, vtkAbstractArray *toData,
483  vtkIdType fromId, vtkIdType toId);
484  void CopyTuples(vtkAbstractArray *fromData, vtkAbstractArray *toData,
485  vtkIdList *fromIds, vtkIdList *toIds);
486  void CopyTuples(vtkAbstractArray *fromData, vtkAbstractArray *toData,
487  vtkIdType dstStart, vtkIdType n, vtkIdType srcStart);
489 
490 
491  // -- interpolate operations ----------------------------------------------
492 
494 
503  vtkIdType ext=1000)
504  {
505  this->InterpolateAllocate(pd, sze, ext, 0);
506  }
507  void InterpolateAllocate(vtkDataSetAttributes* pd, vtkIdType sze,
508  vtkIdType ext, int shallowCopyArrays);
510 
518  void InterpolatePoint(vtkDataSetAttributes *fromPd, vtkIdType toId,
519  vtkIdList *ids, double *weights);
520 
530  void InterpolateEdge(vtkDataSetAttributes *fromPd, vtkIdType toId,
531  vtkIdType p1, vtkIdType p2, double t);
532 
545  void InterpolateTime(vtkDataSetAttributes *from1,
546  vtkDataSetAttributes *from2,
547  vtkIdType id, double t);
548 
549  class FieldList;
550 
551  // field list copy operations ------------------------------------------
552 
557  void CopyAllocate(vtkDataSetAttributes::FieldList& list, vtkIdType sze=0,
558  vtkIdType ext=1000);
559 
566  void CopyData(vtkDataSetAttributes::FieldList& list,
567  vtkDataSetAttributes* dsa, int idx, vtkIdType fromId,
568  vtkIdType toId);
569  void CopyData(vtkDataSetAttributes::FieldList& list,
570  vtkDataSetAttributes* dsa, int idx, vtkIdType dstStart,
571  vtkIdType n, vtkIdType srcStart);
572 
579  void InterpolateAllocate(vtkDataSetAttributes::FieldList& list, vtkIdType sze=0,
580  vtkIdType ext=1000);
581 
588  void InterpolatePoint(
590  vtkDataSetAttributes *fromPd,
591  int idx, vtkIdType toId,
592  vtkIdList *ids, double *weights);
593 
595 
596 protected:
598  ~vtkDataSetAttributes() override;
599 
601  int ctype,
602  vtkIdType sze=0,
603  vtkIdType ext=1000,
604  int shallowCopyArrays=0,
605  bool createNewArrays=true);
606 
609  int ctype,
610  vtkIdType sze, vtkIdType ext);
611 
615  void InitializeFields() override;
616 
617  int AttributeIndices[NUM_ATTRIBUTES]; //index to attribute array in field data
618  int CopyAttributeFlags[ALLCOPY][NUM_ATTRIBUTES]; //copy flag for attribute data
619 
621 
623 
625  static const int AttributeLimits[NUM_ATTRIBUTES];
626  static const char AttributeNames[NUM_ATTRIBUTES][12];
627  static const char LongAttributeNames[NUM_ATTRIBUTES][35];
628 
629 private:
630  static int CheckNumberOfComponents(vtkAbstractArray* da, int attributeType);
631 
632  vtkFieldData::BasicIterator ComputeRequiredArrays(vtkDataSetAttributes* pd, int ctype);
633 
634 private:
636  void operator=(const vtkDataSetAttributes&) = delete;
637 
638 public:
639  // This public class is used to perform set operations, other misc.
640  // operations on fields. For example, vtkAppendFilter uses it to
641  // determine which attributes the input datasets share in common.
642  class vtkInternalComponentNames;
643  class VTKCOMMONDATAMODEL_EXPORT FieldList
644  {
645  public:
646  FieldList(int numInputs);
647  ~FieldList();
648  void PrintSelf(ostream &os, vtkIndent indent);
649 
650  void InitializeFieldList(vtkDataSetAttributes* dsa);
651  void IntersectFieldList(vtkDataSetAttributes* dsa);
652 
660  void UnionFieldList(vtkDataSetAttributes* dsa);
661 
662  //Determine whether data is available
663  int IsAttributePresent(int attrType); //true/false attributes specified
664 
665  // Accessor methods.
666  int GetNumberOfFields() { return this->NumberOfFields; }
667  int GetFieldIndex(int i) { return this->FieldIndices[i]; }
668  const char* GetFieldName(int i) { return this->Fields[i]; }
669  int GetFieldComponents(int i) { return this->FieldComponents[i]; }
670  int GetDSAIndex(int index, int i) { return this->DSAIndices[index][i]; }
671 
672  friend class vtkDataSetAttributes;
673 
674  protected:
675  void SetFieldIndex(int i, int index)
676  { this->FieldIndices[i] = index; }
677  private:
678  FieldList(const FieldList&) = delete;
679  void operator=(const FieldList&) = delete;
680 
681  void SetField(int index, vtkAbstractArray *da);
682  void RemoveField(const char *name);
683  void ClearFields();
684  void GrowBy(unsigned int delta);
685 
686  int NumberOfFields; //the number of fields (including five named attributes)
687  // These keep track of what is common across datasets. The first
688  // six items are always named attributes.
689  char** Fields; // the names of the fields
690  int *FieldTypes; // the types of the fields
691  int *FieldComponents; // the number of components in field
692  int *FieldIndices; // output data array index
693  vtkLookupTable **LUT; // luts associated with each array
694  vtkInformation **FieldInformation; // Information map associated with each array
695 
696  vtkInternalComponentNames **FieldComponentsNames; // the name for each component in the field
697 
698  vtkIdType NumberOfTuples; // a running total of values
699 
700  //For every vtkDataSetAttributes that are processed, keep track of the
701  //indices into various things. The indices are organized so that the
702  //first NUM_ATTRIBUTES refer to attributes, the next refer to the
703  //non-attribute fields, for a total of NUM_ATTRIBUTES + NumberOfFields.
704  //CurrentInput is the current input being processed.
705  int **DSAIndices;
706  int NumberOfDSAIndices;
707  int CurrentInput;
708 
709  };
710 
711 };
712 
713 #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.
int vtkTypeBool
Definition: vtkABI.h:69
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:33
list of point or cell ids
Definition: vtkIdList.h:30
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:48
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.
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:53