source: vtkvis/tags/1.7.2/DataSet.h @ 4807

Last change on this file since 4807 was 4781, checked in by ldelgass, 9 years ago

merge r4739 from vtkvis trunk

  • Property svn:eol-style set to native
File size: 3.4 KB
Line 
1/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2/*
3 * Copyright (C) 2004-2012  HUBzero Foundation, LLC
4 *
5 * Author: Leif Delgass <ldelgass@purdue.edu>
6 */
7
8#ifndef VTKVIS_DATASET_H
9#define VTKVIS_DATASET_H
10
11#include <vtkSmartPointer.h>
12#include <vtkDataSet.h>
13#include <vtkDataSetReader.h>
14
15#include <string>
16#include <vector>
17
18#include "Types.h"
19#include "Trace.h"
20
21namespace VtkVis {
22
23/**
24 * \brief VTK DataSet wrapper
25 */
26class DataSet {
27public:
28    /**
29     * These enum values intentionally match vtkDataObject::FieldAssociations
30     * and vtkDataObject::AttributeTypes
31     */
32    enum DataAttributeType {
33        POINT_DATA,
34        CELL_DATA,
35        FIELD_DATA
36    };
37    DataSet(const std::string& name);
38    virtual ~DataSet();
39
40    void writeDataFile(const char *filename);
41
42    bool setDataFile(const char *filename);
43
44    bool setData(char *data, int nbytes);
45
46    bool setData(vtkDataSetReader *reader);
47
48    bool setData(vtkDataSet *ds);
49
50    vtkDataSet *copyData(vtkDataSet *ds);
51
52    int numDimensions() const;
53
54    bool is2D(PrincipalPlane *plane = NULL, double *offset = NULL) const;
55
56    PrincipalPlane principalPlane() const;
57
58    bool isCloud() const;
59
60    const std::string& getName() const;
61
62    vtkDataSet *getVtkDataSet();
63
64    const char *getVtkType() const;
65
66    bool setActiveScalars(const char *name);
67
68    const char *getActiveScalarsName() const;
69
70    DataAttributeType getActiveScalarsType() const;
71
72    bool setActiveVectors(const char *name);
73
74    const char *getActiveVectorsName() const;
75
76    DataAttributeType getActiveVectorsType() const;
77
78    bool hasField(const char *fieldName) const
79    {
80        return getFieldInfo(fieldName, NULL, NULL);
81    }
82
83    bool hasField(const char *fieldName, DataAttributeType type) const
84    {
85        return getFieldInfo(fieldName, type, NULL);
86    }
87
88    bool getFieldInfo(const char *fieldName, DataAttributeType *type, int *numComponents) const;
89
90    bool getFieldInfo(const char *fieldName, DataAttributeType type, int *numComponents) const;
91
92    void getFieldNames(std::vector<std::string>& names,
93                       DataAttributeType type, int numComponents = -1) const;
94
95    bool getDataRange(double minmax[2], const char *fieldName,
96                      DataAttributeType type, int component = -1) const;
97
98    void getScalarRange(double minmax[2]) const;
99
100    void getVectorRange(double minmax[2], int component = -1) const;
101
102    void getBounds(double bounds[6]) const;
103
104    void getCellSizeRange(double minmax[2], double *average);
105
106    bool getScalarValue(double x, double y, double z, double *value) const;
107
108    bool getVectorValue(double x, double y, double z, double vector[3]) const;
109
110    void setOpacity(double opacity);
111
112    /**
113     * \brief Get the opacity setting for the DataSet
114     *
115     * This method is used for record-keeping.  The renderer controls
116     * the visibility of related graphics objects.
117     */
118    inline double getOpacity()
119    {
120        return _opacity;
121    }
122
123    void setVisibility(bool state);
124
125    bool getVisibility() const;
126
127    static void getCellSizeRange(vtkDataSet *dataSet, double minmax[2], double *average);
128
129    static void print(vtkDataSet *ds);
130
131private:
132    DataSet();
133
134    void setDefaultArrays();
135    void print() const;
136
137    std::string _name;
138    vtkSmartPointer<vtkDataSet> _dataSet;
139    bool _visible;
140    double _opacity;
141    double _cellSizeRange[2];
142    double _cellSizeAverage;
143};
144
145}
146
147#endif
Note: See TracBrowser for help on using the repository browser.