source: trunk/packages/vizservers/vtkvis/DataSet.h @ 4369

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

Add colormode for PolyData?, by default color map if an active scalar field with
multiple components is present (color scalars). Add protocol for image/text3d
drawing components. Make 'color' synonym for 'ccolor' in protocol commands,
also accept 'ccolor' or 'constant' as colormode. Add experimental commands for
simple legend (no field info required), extended colormode for heightmap with
explicit range. Add fontconfig support (needs testing). Added code to remove
duplicate points from unstructured grids. Should probably be optional. Stack
trace on error (if WANT_TRACE is on) using VTK.

  • Property svn:eol-style set to native
File size: 3.4 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
15#include <string>
16#include <vector>
17
18#include "Types.h"
19#include "Trace.h"
20
21namespace VtkVis {
22
23/**
24 * \brief VTK DataSet wrapper
25 */
26class DataSet {
27public:
28    /**
29     * These enum values intentionally match vtkDataObject::FieldAssociations
30     * and vtkDataObject::AttributeTypes
31     */
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    bool isCloud() const;
61
62    const std::string& getName() const;
63
64    vtkDataSet *getVtkDataSet();
65
66    const char *getVtkType() const;
67
68    bool setActiveScalars(const char *name);
69
70    const char *getActiveScalarsName() const;
71
72    DataAttributeType getActiveScalarsType() const;
73
74    bool setActiveVectors(const char *name);
75
76    const char *getActiveVectorsName() const;
77
78    DataAttributeType getActiveVectorsType() const;
79
80    bool hasField(const char *fieldName) const
81    {
82        return getFieldInfo(fieldName, NULL, NULL);
83    }
84
85    bool hasField(const char *fieldName, DataAttributeType type) const
86    {
87        return getFieldInfo(fieldName, type, NULL);
88    }
89
90    bool getFieldInfo(const char *fieldName, DataAttributeType *type, int *numComponents) const;
91
92    bool getFieldInfo(const char *fieldName, DataAttributeType type, int *numComponents) const;
93
94    void getFieldNames(std::vector<std::string>& names,
95                       DataAttributeType type, int numComponents = -1) const;
96
97    bool getDataRange(double minmax[2], const char *fieldName,
98                      DataAttributeType type, int component = -1) const;
99
100    void getScalarRange(double minmax[2]) const;
101
102    void getVectorRange(double minmax[2], int component = -1) const;
103
104    void getBounds(double bounds[6]) const;
105
106    void getCellSizeRange(double minmax[2], double *average);
107
108    bool getScalarValue(double x, double y, double z, double *value) const;
109
110    bool getVectorValue(double x, double y, double z, double vector[3]) const;
111
112    void setOpacity(double opacity);
113
114    /**
115     * \brief Get the opacity setting for the DataSet
116     *
117     * This method is used for record-keeping.  The renderer controls
118     * the visibility of related graphics objects.
119     */
120    inline double getOpacity()
121    {
122        return _opacity;
123    }
124
125    void setVisibility(bool state);
126
127    bool getVisibility() const;
128
129    static void getCellSizeRange(vtkDataSet *dataSet, double minmax[2], double *average);
130
131    static void print(vtkDataSet *ds);
132
133private:
134    DataSet();
135
136    void setDefaultArrays();
137    void print() const;
138
139    std::string _name;
140    vtkSmartPointer<vtkDataSet> _dataSet;
141    bool _visible;
142    double _opacity;
143    double _cellSizeRange[2];
144    double _cellSizeAverage;
145};
146
147}
148
149#endif
Note: See TracBrowser for help on using the repository browser.