source: vtkvis/trunk/DataSet.h @ 6372

Last change on this file since 6372 was 6162, checked in by ldelgass, 8 years ago

merge r5843:5844 from 1.8 branch

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