OpenCOVER
RenderObject.h
Go to the documentation of this file.
1/* This file is part of COVISE.
2
3 You can use it under the terms of the GNU Lesser General Public License
4 version 2.1 or later, see lgpl-2.1.txt.
5
6 * License: LGPL 2+ */
7
21#ifndef RENDER_OBJ
22#define RENDER_OBJ
23
24#include <util/coExport.h>
25#include <cstdlib>
26
27namespace opencover
28{
29
30struct Bind
31{
32 enum
33 {
36 None = 2,
38 };
39};
40
41struct Pack
42{
43 enum
44 {
45 None = 2,
46 RGBA = 4,
48 Float = 6,
49 };
50};
51
52struct Field
53{
54 enum Id
55 {
64 NumChannels, // invalid!
78 };
79};
80
81// sonst muesste ObjectManager.h eingebunden wrden, was Fehlermeldungen beim
82//compilieren gibt, gibt aber sicher irgendwann Probleme
83
84inline void packRGBA(int *pc, int pos, float r, float g, float b, float a)
85{
86 if (pc)
87 {
88 unsigned char *chptr;
89
90 chptr = (unsigned char *)&pc[pos];
91#ifdef BYTESWAP
92 *chptr = (unsigned char)(a * 255.0);
93 chptr++;
94 *chptr = (unsigned char)(b * 255.0);
95 chptr++;
96 *chptr = (unsigned char)(g * 255.0);
97 chptr++;
98 *chptr = (unsigned char)(r * 255.0);
99#else
100 *chptr = (unsigned char)(r * 255.0);
101 chptr++;
102 *chptr = (unsigned char)(g * 255.0);
103 chptr++;
104 *chptr = (unsigned char)(b * 255.0);
105 chptr++;
106 *chptr = (unsigned char)(a * 255.0);
107#endif
108 }
109}
110
111inline void unpackRGBA(const int *pc, int pos, float *r, float *g, float *b, float *a)
112{
113 if (pc)
114 {
115 const unsigned char *chptr;
116
117 chptr = (const unsigned char *)&pc[pos];
118#ifdef BYTESWAP
119 *a = ((float)(*chptr)) / 255.0f;
120 chptr++;
121 *b = ((float)(*chptr)) / 255.0f;
122 chptr++;
123 *g = ((float)(*chptr)) / 255.0f;
124 chptr++;
125 *r = ((float)(*chptr)) / 255.0f;
126#else
127 *r = ((float)(*chptr)) / 255.0f;
128 chptr++;
129 *g = ((float)(*chptr)) / 255.0f;
130 chptr++;
131 *b = ((float)(*chptr)) / 255.0f;
132 chptr++;
133 *a = ((float)(*chptr)) / 255.0f;
134#endif
135 }
136 else
137 {
138 *r = 1;
139 *g = 1;
140 *b = 1;
141 *a = 1;
142 }
143}
144
146class COVEREXPORT RenderObject
147{
148public:
150 virtual ~RenderObject();
151
152 virtual const char *getName() const = 0;
153
154 virtual bool isGeometry() const = 0;
155 virtual RenderObject *getGeometry() const = 0;
156 virtual RenderObject *getNormals() const = 0;
157 virtual RenderObject *getColors() const = 0;
158 virtual RenderObject *getTexture() const = 0;
159 virtual RenderObject *getVertexAttribute() const = 0;
160 virtual RenderObject *getColorMap(int idx) const = 0;
161
162 virtual const char *getAttribute(const char *) const = 0;
163
164 //XXX: hacks for Volume plugin and Tracer
165 virtual bool isSet() const = 0;
166 virtual size_t getNumElements() const = 0;
167 virtual RenderObject *getElement(size_t idx) const = 0;
168
169 virtual bool isUniformGrid() const = 0;
170 virtual void getSize(int &nx, int &ny, int &nz) const = 0;
171 virtual float getMin(int channel) const = 0;
172 virtual float getMax(int channel) const = 0;
173 virtual void getMinMax(float &xmin, float &xmax,
174 float &ymin, float &ymax,
175 float &zmin, float &zmax) const = 0;
176
177 virtual bool isVectors() const = 0;
178 virtual const unsigned char *getByte(Field::Id idx) const = 0;
179 virtual const int *getInt(Field::Id idx) const = 0;
180 virtual const float *getFloat(Field::Id idx) const = 0;
181
182 virtual bool isUnstructuredGrid() const = 0;
183};
184}
185#endif
Definition: ARToolKit.h:33
void unpackRGBA(const int *pc, int pos, float *r, float *g, float *b, float *a)
Definition: RenderObject.h:111
void packRGBA(int *pc, int pos, float r, float g, float b, float a)
Definition: RenderObject.h:84
Definition: RenderObject.h:31
@ OverAll
Definition: RenderObject.h:37
@ PerFace
Definition: RenderObject.h:35
@ None
Definition: RenderObject.h:36
@ PerVertex
Definition: RenderObject.h:34
Definition: RenderObject.h:42
@ RGBA
Definition: RenderObject.h:46
@ None
Definition: RenderObject.h:45
@ Texture
Definition: RenderObject.h:47
@ Float
Definition: RenderObject.h:48
Definition: RenderObject.h:53
Id
Definition: RenderObject.h:55
@ Channel1
Definition: RenderObject.h:57
@ Red
Definition: RenderObject.h:68
@ Channel3
Definition: RenderObject.h:59
@ Z
Definition: RenderObject.h:67
@ Blue
Definition: RenderObject.h:70
@ Channel6
Definition: RenderObject.h:62
@ Connections
Definition: RenderObject.h:75
@ NumChannels
Definition: RenderObject.h:64
@ Y
Definition: RenderObject.h:66
@ ColorMap
Definition: RenderObject.h:77
@ RGBA
Definition: RenderObject.h:71
@ Channel7
Definition: RenderObject.h:63
@ Byte
Definition: RenderObject.h:72
@ Texture
Definition: RenderObject.h:73
@ Channel4
Definition: RenderObject.h:60
@ Channel2
Definition: RenderObject.h:58
@ Channel0
Definition: RenderObject.h:56
@ Elements
Definition: RenderObject.h:74
@ X
Definition: RenderObject.h:65
@ Channel5
Definition: RenderObject.h:61
@ Green
Definition: RenderObject.h:69
@ Types
Definition: RenderObject.h:76
base class for data received from visualization systems (e.g. COVISE or Vistle)
Definition: RenderObject.h:147
virtual void getSize(int &nx, int &ny, int &nz) const =0
virtual bool isUnstructuredGrid() const =0
virtual const unsigned char * getByte(Field::Id idx) const =0
virtual bool isSet() const =0
virtual bool isUniformGrid() const =0
virtual RenderObject * getTexture() const =0
virtual RenderObject * getGeometry() const =0
virtual RenderObject * getColorMap(int idx) const =0
virtual float getMax(int channel) const =0
virtual bool isVectors() const =0
virtual RenderObject * getColors() const =0
virtual float getMin(int channel) const =0
virtual const int * getInt(Field::Id idx) const =0
virtual bool isGeometry() const =0
virtual RenderObject * getElement(size_t idx) const =0
virtual RenderObject * getVertexAttribute() const =0
virtual const float * getFloat(Field::Id idx) const =0
virtual void getMinMax(float &xmin, float &xmax, float &ymin, float &ymax, float &zmin, float &zmax) const =0
virtual size_t getNumElements() const =0
virtual const char * getName() const =0
virtual const char * getAttribute(const char *) const =0
virtual RenderObject * getNormals() const =0