source: branches/nanovis2/packages/vizservers/vtkvis/RpVtkDataSet.h @ 3305

Last change on this file since 3305 was 3305, checked in by ldelgass, 11 years ago

sync with trunk

  • Property svn:eol-style set to native
File size: 3.8 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 __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    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    bool isXY() const;
53
54    int numDimensions() const;
55
56    bool is2D(PrincipalPlane *plane = NULL, double *offset = NULL) const;
57
58    PrincipalPlane principalPlane() 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    void showOutline(bool state);
128
129    void setOutlineColor(float color[3]);
130
131    void setClippingPlanes(vtkPlaneCollection *planes)
132    {
133        if (_outlineMapper != NULL) {
134            _outlineMapper->SetClippingPlanes(planes);
135        }
136    }
137
138    /**
139     * \brief Return the VTK prop object for the outline
140     */
141    inline vtkProp *getProp()
142    {
143        return _prop;
144    }
145
146    static void print(vtkDataSet *ds);
147
148private:
149    DataSet();
150
151    void setDefaultArrays();
152    void print() const;
153
154    void initProp();
155
156    std::string _name;
157    vtkSmartPointer<vtkDataSet> _dataSet;
158    bool _visible;
159    double _opacity;
160    double _cellSizeRange[2];
161    double _cellSizeAverage;
162    vtkSmartPointer<vtkOutlineFilter> _outlineFilter;
163    vtkSmartPointer<vtkActor> _prop;
164    vtkSmartPointer<vtkPolyDataMapper> _outlineMapper;
165};
166
167}
168}
169
170#endif
Note: See TracBrowser for help on using the repository browser.