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
RevLine 
[2100]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>
[2455]14#include <vtkProp.h>
15#include <vtkActor.h>
16#include <vtkOutlineFilter.h>
17#include <vtkPolyDataMapper.h>
[2100]18
[2112]19#include <string>
[2100]20#include <vector>
21
[2612]22#include "RpTypes.h"
23
[2100]24namespace Rappture {
25namespace VtkVis {
26
27/**
28 * \brief VTK DataSet wrapper
29 */
30class DataSet {
31public:
[2610]32    enum DataAttributeType {
33        POINT_DATA,
34        CELL_DATA,
35        FIELD_DATA
36    };
[2112]37    DataSet(const std::string& name);
[2100]38    virtual ~DataSet();
39
[2270]40    bool setDataFile(const char *filename);
41
[2100]42    bool setData(char *data, int nbytes);
43
[2270]44    bool setData(vtkDataSetReader *reader);
45
[2121]46    bool setData(vtkDataSet *ds);
47
[2270]48    vtkDataSet *copyData(vtkDataSet *ds);
[2121]49
[2423]50    bool isXY() const;
[2112]51
[2423]52    int numDimensions() const;
53
54    bool is2D(PrincipalPlane *plane = NULL, double *offset = NULL) const;
55
56    PrincipalPlane principalPlane() const;
57
[2194]58    const std::string& getName() const;
59
[2100]60    vtkDataSet *getVtkDataSet();
61
[2332]62    const char *getVtkType() const;
[2260]63
[2393]64    bool setActiveScalars(const char *name);
[2100]65
[2610]66    const char *getActiveScalarsName() const;
[2471]67
[2612]68    DataAttributeType getActiveScalarsType() const;
69
[2393]70    bool setActiveVectors(const char *name);
[2290]71
[2610]72    const char *getActiveVectorsName() const;
[2471]73
[2612]74    DataAttributeType getActiveVectorsType() const;
75
[2640]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
[2612]86    bool getFieldInfo(const char *fieldName, DataAttributeType *type, int *numComponents) const;
87
88    bool getFieldInfo(const char *fieldName, DataAttributeType type, int *numComponents) const;
89
[2610]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
[2402]96    void getScalarRange(double minmax[2]) const;
[2100]97
[2402]98    void getVectorRange(double minmax[2], int component = -1) const;
[2332]99
100    void getBounds(double bounds[6]) const;
101
[2454]102    void getCellSizeRange(double minmax[2], double *average);
[2402]103
[2423]104    bool getScalarValue(double x, double y, double z, double *value) const;
[2332]105
[2423]106    bool getVectorValue(double x, double y, double z, double vector[3]) const;
107
[2455]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
[2194]121    void setVisibility(bool state);
122
123    bool getVisibility() const;
124
[2455]125    void showOutline(bool state);
126
[2478]127    void setOutlineColor(float color[3]);
128
[2455]129    /**
130     * \brief Return the VTK prop object for the outline
131     */
132    inline vtkProp *getProp()
133    {
134        return _prop;
135    }
136
[2100]137private:
[2112]138    DataSet();
[2423]139
140    void setDefaultArrays();
[2402]141    void print() const;
[2112]142
[2455]143    void initProp();
144
[2112]145    std::string _name;
[2100]146    vtkSmartPointer<vtkDataSet> _dataSet;
[2194]147    bool _visible;
[2455]148    double _opacity;
[2454]149    double _cellSizeRange[2];
150    double _cellSizeAverage;
[2455]151    vtkSmartPointer<vtkOutlineFilter> _outlineFilter;
152    vtkSmartPointer<vtkActor> _prop;
153    vtkSmartPointer<vtkPolyDataMapper> _outlineMapper;
[2100]154};
155
156}
157}
158
159#endif
Note: See TracBrowser for help on using the repository browser.