source: trunk/packages/vizservers/vtkvis/RpVtkDataSet.h @ 2640

Last change on this file since 2640 was 2640, checked in by ldelgass, 13 years ago

Add new inline methods to check if named field exists

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