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

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

Refactor vtkvis to support setting colormap fields by name/attribute type
rather than always using active scalars/vectors. Also convert common
graphics objects set methods in Renderer to template methods and separate
core and graphics object related methods to separate files.

  • Property svn:eol-style set to native
File size: 3.3 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 getFieldInfo(const char *fieldName, DataAttributeType *type, int *numComponents) const;
77
78    bool getFieldInfo(const char *fieldName, DataAttributeType type, int *numComponents) const;
79
80    void getFieldNames(std::vector<std::string>& names,
81                       DataAttributeType type, int numComponents = -1) const;
82
83    bool getDataRange(double minmax[2], const char *fieldName,
84                      DataAttributeType type, int component = -1) const;
85
86    void getScalarRange(double minmax[2]) const;
87
88    void getVectorRange(double minmax[2], int component = -1) const;
89
90    void getBounds(double bounds[6]) const;
91
92    void getCellSizeRange(double minmax[2], double *average);
93
94    bool getScalarValue(double x, double y, double z, double *value) const;
95
96    bool getVectorValue(double x, double y, double z, double vector[3]) const;
97
98    void setOpacity(double opacity);
99
100    /**
101     * \brief Get the opacity setting for the DataSet
102     *
103     * This method is used for record-keeping.  The renderer controls
104     * the visibility of related graphics objects.
105     */
106    inline double getOpacity()
107    {
108        return _opacity;
109    }
110
111    void setVisibility(bool state);
112
113    bool getVisibility() const;
114
115    void showOutline(bool state);
116
117    void setOutlineColor(float color[3]);
118
119    /**
120     * \brief Return the VTK prop object for the outline
121     */
122    inline vtkProp *getProp()
123    {
124        return _prop;
125    }
126
127private:
128    DataSet();
129
130    void setDefaultArrays();
131    void print() const;
132
133    void initProp();
134
135    std::string _name;
136    vtkSmartPointer<vtkDataSet> _dataSet;
137    bool _visible;
138    double _opacity;
139    double _cellSizeRange[2];
140    double _cellSizeAverage;
141    vtkSmartPointer<vtkOutlineFilter> _outlineFilter;
142    vtkSmartPointer<vtkActor> _prop;
143    vtkSmartPointer<vtkPolyDataMapper> _outlineMapper;
144};
145
146}
147}
148
149#endif
Note: See TracBrowser for help on using the repository browser.