vtkSMInputArrayDomain.h 4.82 KB
Newer Older
Berk Geveci's avatar
Berk Geveci committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14
/*=========================================================================

  Program:   ParaView
  Module:    vtkSMInputArrayDomain.h

  Copyright (c) Kitware, Inc.
  All rights reserved.
  See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.

     This software is distributed WITHOUT ANY WARRANTY; without even
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
     PURPOSE.  See the above copyright notice for more information.

=========================================================================*/
Berk Geveci's avatar
Berk Geveci committed
15
// .NAME vtkSMInputArrayDomain - requires input has array of described type
Berk Geveci's avatar
Berk Geveci committed
16
// .SECTION Description
Berk Geveci's avatar
Berk Geveci committed
17 18 19
// vtkSMInputArrayDomain requires that the source proxy pointed by the
// property has an output with one or more arrays of specified type.
// Current restrictions include whether the array is part of point or
20 21 22 23
// cell data and whether it has a given number of components. The restriction
// can be overriden for point and cell properties if the global post filter
// conversion is turned on.
// These attributes are specified in the XML file. Valid XML attributes are:
Berk Geveci's avatar
Berk Geveci committed
24 25 26 27 28
// @verbatim
// * attribute_type - cell or point
// * number_of_components
// @endverbatim
// The attribute type can also be (optionally) obtained from a required
29
// property FieldDataSelection which has a value of
Berk Geveci's avatar
Berk Geveci committed
30
// vtkDataSet::POINT_DATA_FIELD or  vtkDataSet::CELL_DATA_FIELD.
Berk Geveci's avatar
Berk Geveci committed
31
// .SECTION See Also
32
// vtkSMDomain
Berk Geveci's avatar
Berk Geveci committed
33 34 35 36 37 38

#ifndef __vtkSMInputArrayDomain_h
#define __vtkSMInputArrayDomain_h

#include "vtkSMDomain.h"

39 40 41 42 43
// Needed to get around some header defining ANY as a macro
#ifdef ANY
# undef ANY
#endif

Berk Geveci's avatar
Berk Geveci committed
44 45 46 47 48 49 50 51
class vtkPVArrayInformation;
class vtkPVDataSetAttributesInformation;
class vtkSMSourceProxy;

class VTK_EXPORT vtkSMInputArrayDomain : public vtkSMDomain
{
public:
  static vtkSMInputArrayDomain* New();
52
  vtkTypeMacro(vtkSMInputArrayDomain, vtkSMDomain);
Berk Geveci's avatar
Berk Geveci committed
53 54 55 56 57 58 59 60 61 62 63
  void PrintSelf(ostream& os, vtkIndent indent);

  // Description:
  // Returns true if the value of the propery is in the domain.
  // The propery has to be a vtkSMProxyProperty which points
  // to a vtkSMSourceProxy. The input has to have one or more
  // arrays that match the requirements.
  virtual int IsInDomain(vtkSMProperty* property);

  // Description:
  // Returns true if input has one or more arrays that match the
64 65
  // requirements on  the given output port.
  int IsInDomain(vtkSMSourceProxy* proxy, int outputport=0);
Berk Geveci's avatar
Berk Geveci committed
66 67

  // Description:
Berk Geveci's avatar
Berk Geveci committed
68
  // Returns 1 if the array represented by the array information is
69
  // a valid field. The attribute type (point or cell) as well as the
Berk Geveci's avatar
Berk Geveci committed
70
  // number of components are checked for a match
71 72 73 74
  int IsFieldValid(vtkSMSourceProxy* proxy, int outputport,
    vtkPVArrayInformation* arrayInfo);
  int IsFieldValid(vtkSMSourceProxy* proxy, int outputport,
    vtkPVArrayInformation* arrayInfo, int bypass);
75

Berk Geveci's avatar
Berk Geveci committed
76
  // Description:
Berk Geveci's avatar
Berk Geveci committed
77 78
  // Set/get the attribute type. Valid values are: POINT, CELL, ANY.
  // Text representations are: point, cell, any.
79
  vtkSetMacro(AttributeType, unsigned char);
Berk Geveci's avatar
Berk Geveci committed
80
  vtkGetMacro(AttributeType, unsigned char);
81 82
  const char* GetAttributeTypeAsString();
  virtual void SetAttributeType(const char* type);
Berk Geveci's avatar
Berk Geveci committed
83 84

  // Description:
Berk Geveci's avatar
Berk Geveci committed
85 86
  // Set/get the required number of components. Set to 0 for
  // no check.
Berk Geveci's avatar
Berk Geveci committed
87 88 89
  vtkSetMacro(NumberOfComponents, int);
  vtkGetMacro(NumberOfComponents, int);

90 91 92 93 94 95
  /// Get/Set the application wide setting for automatic conversion of properties.
  /// Automatic conversion of properties allows conversion between cell and point
  /// based properties, and the extraction of vector components as scalar properties
  static void SetAutomaticPropertyConversion(bool);
  static bool GetAutomaticPropertyConversion();

96 97 98 99 100
  // Description:
  // Use this method to convert a vtkDataSet::FIELD_ASSOCIATION_* to
  // AttributeTypes enum.
  static int GetAttributeTypeFromFieldAssociation(int);

Berk Geveci's avatar
Berk Geveci committed
101 102 103 104 105
//BTX
  enum AttributeTypes
  {
    POINT = 0,
    CELL = 1,
106
    ANY = 2,
107 108 109
    VERTEX = 3,
    EDGE = 4,
    ROW = 5,
110
    NONE = 6,
111
    LAST_ATTRIBUTE_TYPE
Berk Geveci's avatar
Berk Geveci committed
112 113 114 115 116 117 118 119 120 121 122 123
  };
//ETX

protected:
  vtkSMInputArrayDomain();
  ~vtkSMInputArrayDomain();

  // Description:
  // Set the appropriate ivars from the xml element. Should
  // be overwritten by subclass if adding ivars.
  virtual int ReadXMLAttributes(vtkSMProperty* prop, vtkPVXMLElement* element);

124
  virtual void ChildSaveState(vtkPVXMLElement* domainElement);
Berk Geveci's avatar
Berk Geveci committed
125

Berk Geveci's avatar
Berk Geveci committed
126
  int AttributeInfoContainsArray(vtkSMSourceProxy* proxy,
127
                                 int outputport,
Berk Geveci's avatar
Berk Geveci committed
128
                                 vtkPVDataSetAttributesInformation* attrInfo);
129
  int CheckForArray(vtkPVArrayInformation* arrayInfo,
Berk Geveci's avatar
Berk Geveci committed
130
                    vtkPVDataSetAttributesInformation* attrInfo);
Berk Geveci's avatar
Berk Geveci committed
131 132 133 134 135

  unsigned char AttributeType;
  int NumberOfComponents;

private:
136
  static bool AutomaticPropertyConversion;
Berk Geveci's avatar
Berk Geveci committed
137 138 139 140 141
  vtkSMInputArrayDomain(const vtkSMInputArrayDomain&); // Not implemented
  void operator=(const vtkSMInputArrayDomain&); // Not implemented
};

#endif