Assignments
Assignments
shapeList.h
Go to the documentation of this file.
1#ifndef GROUP_INCLUDED
2#define GROUP_INCLUDED
3#include <vector>
4#include <unordered_map>
5#include <Util/geometry.h>
6#include "shape.h"
7
8namespace Ray
9{
11 class AffineShape : public Shape
12 {
13 protected:
16 public:
18 AffineShape( void );
19
21 virtual Util::Matrix4D getMatrix( void ) const = 0;
22
24 virtual Util::Matrix4D getInverseMatrix( void ) const = 0;
25
27 virtual Util::Matrix3D getNormalMatrix( void ) const = 0;
28
30 // Shape methods //
32 public:
33 void initOpenGL( void );
34 void updateBoundingBox( void );
35 bool processFirstIntersection( const Util::Ray3D &ray , const Util::BoundingBox1D &range , const RayIntersectionFilter &rFilter , const RayIntersectionKernel &rKernel , ShapeProcessingInfo spInfo , unsigned int tIdx ) const;
36 int processAllIntersections( const Util::Ray3D &ray , const Util::BoundingBox1D &range , const RayIntersectionFilter &rFilter , const RayIntersectionKernel &rKernel , ShapeProcessingInfo spInfo , unsigned int tIdx ) const;
37 void processOverlapping( const Filter &filter , const Kernel &kernel , ShapeProcessingInfo tInfo ) const;
38 virtual bool isInside( Util::Point3D p ) const;
39 virtual void drawOpenGL( GLSLProgram *glslProgram ) const;
40 };
41
42
45 {
48
51
54 public:
56 static std::string Directive( void ){ return "static_affine"; }
57
59 StaticAffineShape( void );
60
62 void set( Util::Matrix4D m );
63
65 // Shape methods //
67 private:
68 void _write( std::ostream &stream ) const;
69 void _read( std::istream &stream );
70 public:
71 std::string name( void ) const { return "static affine"; }
72 void init( const class LocalSceneData &data );
73 void initOpenGL( void );
74
76 // AffineShape methods //
78 public:
79 Util::Matrix4D getMatrix( void ) const;
80 Util::Matrix4D getInverseMatrix( void ) const;
81 Util::Matrix3D getNormalMatrix( void ) const;
82 };
83
86 {
88 std::string _paramName;
89
92 public:
93
95 DynamicAffineShape( void );
96
98 static std::string Directive( void ){ return "dynamic_affine"; }
99
101 // Shape methods //
103 private:
104 void _write( std::ostream &stream ) const;
105 void _read( std::istream &stream );
106 public:
107 std::string name( void ) const { return "dynamic affine"; }
108 void init( const class LocalSceneData &data );
109
111 // AffineShape methods //
113 public:
114 Util::Matrix4D getMatrix( void ) const;
115 Util::Matrix4D getInverseMatrix( void ) const;
116 Util::Matrix3D getNormalMatrix( void ) const;
117 };
118
120 class Difference : public Shape
121 {
124
125 public:
127 Difference( Shape *shape0=NULL , Shape *shape1=NULL );
128
130 static std::string Directive( void ){ return "shape_difference"; }
131
133 // Shape methods //
135 private:
136 void _write( std::ostream &stream ) const;
137 void _read( std::istream &stream );
138 public:
139 std::string name( void ) const { return "difference"; }
140 void init( const class LocalSceneData& data );
141 void initOpenGL( void );
142 void updateBoundingBox( void );
143 bool processFirstIntersection( const Util::Ray3D &ray , const Util::BoundingBox1D &range , const RayIntersectionFilter &rFilter , const RayIntersectionKernel &rKernel , ShapeProcessingInfo spInfo , unsigned int tIdx ) const;
144 int processAllIntersections( const Util::Ray3D &ray , const Util::BoundingBox1D &range , const RayIntersectionFilter &rFilter , const RayIntersectionKernel &rKernel , ShapeProcessingInfo spInfo , unsigned int tIdx ) const;
145 bool isInside( Util::Point3D p ) const;
146 void drawOpenGL( GLSLProgram *glslProgram ) const;
147 size_t primitiveNum( void ) const;
148 };
149
152 {
153 public:
155 double t;
156
158 const Shape *shape;
159
163 static bool Compare( const ShapeBoundingBoxHit &v1 , const ShapeBoundingBoxHit &v2 );
164 };
165
167 class ShapeList : public Shape
168 {
169 friend class Union;
170 friend class Intersection;
171
173 static std::string _DirectiveHeader( void ){ return "shape_list"; }
174 public:
175
177 static std::unordered_map< std::string , Util::BaseFactory< Shape > * > ShapeFactories;
178
180 static std::string Directive( void ){ return _DirectiveHeader() + std::string( "_begin" ); }
181
183 std::vector< Shape* > shapes;
184
186 // Shape methods //
188 protected:
189 void _write( std::ostream &stream ) const;
190 void _read( std::istream &stream );
191 public:
192 std::string name( void ) const { return "shape list"; }
193 void init( const class LocalSceneData &data );
194 void initOpenGL( void );
195 void updateBoundingBox( void );
196 bool processFirstIntersection( const Util::Ray3D &ray , const Util::BoundingBox1D &range , const RayIntersectionFilter &rFilter , const RayIntersectionKernel &rKernel , ShapeProcessingInfo spInfo , unsigned int tIdx ) const;
197 int processAllIntersections( const Util::Ray3D &ray , const Util::BoundingBox1D &range , const RayIntersectionFilter &rFilter , const RayIntersectionKernel &rKernel , ShapeProcessingInfo spInfo , unsigned int tIdx ) const;
198 void processOverlapping( const Filter &filter , const Kernel &kernel , ShapeProcessingInfo tInfo ) const;
199 bool isInside( Util::Point3D p ) const;
200 void drawOpenGL( GLSLProgram * glslProgram ) const;
201 void addTrianglesOpenGL( std::vector< class TriangleIndex >& triangles );
202 };
203
205 class TriangleList : public ShapeList
206 {
207 friend class Scene;
208
210 GLuint _vertexBufferID = 0;
211
214
216 unsigned int _tNum;
217
219 unsigned int _vNum;
220
222 const class Vertex *_vertices;
223
226
228 const class Material *_material;
229 public:
231 static std::string Directive( void ){ return "shape_triangles"; }
232
234 TriangleList( void );
235
237 // Shape methods //
239 private:
240 void _write( std::ostream &stream ) const;
241 void _read( std::istream &stream );
242 public:
243 std::string name( void ) const { return "triangles"; }
244 void init( const class LocalSceneData &data );
245 void initOpenGL( void );
246 bool processFirstIntersection( const Util::Ray3D &ray , const Util::BoundingBox1D &range , const RayIntersectionFilter &rFilter , const RayIntersectionKernel &rKernel , ShapeProcessingInfo spInfo , unsigned int tIdx ) const;
247 int processAllIntersections( const Util::Ray3D &ray , const Util::BoundingBox1D &range , const RayIntersectionFilter &rFilter , const RayIntersectionKernel &rKernel , ShapeProcessingInfo spInfo , unsigned int tIdx ) const;
248 void processOverlapping( const Filter &filter , const Kernel &kernel , ShapeProcessingInfo tInfo ) const;
249 void drawOpenGL( GLSLProgram * glslProgram ) const;
250 };
251
253 class Union : public Shape
254 {
257 public:
259 static std::string Directive( void ){ return "shape_union"; }
260
262 // Shape methods //
264 private:
265 void _write( std::ostream &stream ) const;
266 void _read( std::istream &stream );
267 public:
268 std::string name( void ) const { return "union"; }
269 void init( const class LocalSceneData &data );
270 void initOpenGL( void );
271 void updateBoundingBox( void );
272 bool isInside( Util::Point3D p ) const;
273 bool processFirstIntersection( const Util::Ray3D &ray , const Util::BoundingBox1D &range , const RayIntersectionFilter &rFilter , const RayIntersectionKernel &rKernel , ShapeProcessingInfo spInfo , unsigned int tIdx ) const;
274 int processAllIntersections( const Util::Ray3D &ray , const Util::BoundingBox1D &range , const RayIntersectionFilter &rFilter , const RayIntersectionKernel &rKernel , ShapeProcessingInfo spInfo , unsigned int tIdx ) const;
275 void drawOpenGL( GLSLProgram * glslProgram ) const;
276 };
277
278
280 class Intersection : public Shape
281 {
284
285 public:
287 static std::string Directive( void ){ return "shape_intersection"; }
288
290 // Shape methods //
292 private:
293 void _write( std::ostream &stream ) const;
294 void _read( std::istream &stream );
295 public:
296 std::string name( void ) const { return "intersection"; }
297 void init( const class LocalSceneData &data );
298 void initOpenGL( void );
299 void updateBoundingBox( void );
300 bool isInside( Util::Point3D p ) const;
301 bool processFirstIntersection( const Util::Ray3D &ray , const Util::BoundingBox1D &range , const RayIntersectionFilter &rFilter , const RayIntersectionKernel &rKernel , ShapeProcessingInfo spInfo , unsigned int tIdx ) const;
302 int processAllIntersections( const Util::Ray3D &ray , const Util::BoundingBox1D &range , const RayIntersectionFilter &rFilter , const RayIntersectionKernel &rKernel , ShapeProcessingInfo spInfo , unsigned int tIdx ) const;
303 void drawOpenGL( GLSLProgram * glslProgram ) const;
304 };
305}
306#endif // GROUP_INCLUDED
Definition: GLSLProgram.h:33
Definition: shapeList.h:12
Shape * _shape
Definition: shapeList.h:15
virtual Util::Matrix4D getMatrix(void) const =0
virtual bool isInside(Util::Point3D p) const
Definition: shapeList.todo.cpp:120
virtual Util::Matrix4D getInverseMatrix(void) const =0
void processOverlapping(const Filter &filter, const Kernel &kernel, ShapeProcessingInfo tInfo) const
Definition: shapeList.cpp:17
void initOpenGL(void)
Definition: shapeList.cpp:15
AffineShape(void)
Definition: shapeList.cpp:13
int processAllIntersections(const Util::Ray3D &ray, const Util::BoundingBox1D &range, const RayIntersectionFilter &rFilter, const RayIntersectionKernel &rKernel, ShapeProcessingInfo spInfo, unsigned int tIdx) const
Definition: shapeList.cpp:43
bool processFirstIntersection(const Util::Ray3D &ray, const Util::BoundingBox1D &range, const RayIntersectionFilter &rFilter, const RayIntersectionKernel &rKernel, ShapeProcessingInfo spInfo, unsigned int tIdx) const
Definition: shapeList.cpp:32
virtual void drawOpenGL(GLSLProgram *glslProgram) const
Definition: shapeList.todo.cpp:138
virtual Util::Matrix3D getNormalMatrix(void) const =0
void updateBoundingBox(void)
Definition: shapeList.todo.cpp:129
Definition: shapeList.h:121
Difference(Shape *shape0=NULL, Shape *shape1=NULL)
Definition: shapeList.cpp:124
bool processFirstIntersection(const Util::Ray3D &ray, const Util::BoundingBox1D &range, const RayIntersectionFilter &rFilter, const RayIntersectionKernel &rKernel, ShapeProcessingInfo spInfo, unsigned int tIdx) const
Definition: shapeList.todo.cpp:20
Shape * _shape1
Definition: shapeList.h:123
void initOpenGL(void)
Definition: shapeList.cpp:166
void drawOpenGL(GLSLProgram *glslProgram) const
Definition: shapeList.cpp:171
size_t primitiveNum(void) const
void _read(std::istream &stream)
Definition: shapeList.cpp:136
int processAllIntersections(const Util::Ray3D &ray, const Util::BoundingBox1D &range, const RayIntersectionFilter &rFilter, const RayIntersectionKernel &rKernel, ShapeProcessingInfo spInfo, unsigned int tIdx) const
Definition: shapeList.todo.cpp:29
bool isInside(Util::Point3D p) const
Definition: shapeList.todo.cpp:37
void updateBoundingBox(void)
Definition: shapeList.todo.cpp:12
Shape * _shape0
Definition: shapeList.h:123
static std::string Directive(void)
Definition: shapeList.h:130
void _write(std::ostream &stream) const
Definition: shapeList.cpp:126
void init(const class LocalSceneData &data)
Definition: shapeList.cpp:160
std::string name(void) const
Definition: shapeList.h:139
Definition: shapeList.h:86
std::string name(void) const
Definition: shapeList.h:107
Util::Matrix4D getMatrix(void) const
Definition: shapeList.cpp:115
void _write(std::ostream &stream) const
Definition: shapeList.cpp:91
std::string _paramName
Definition: shapeList.h:88
Util::Matrix4D getInverseMatrix(void) const
Definition: shapeList.cpp:117
const Util::Matrix4D * _matrix
Definition: shapeList.h:91
DynamicAffineShape(void)
Definition: shapeList.cpp:89
static std::string Directive(void)
Definition: shapeList.h:98
void init(const class LocalSceneData &data)
Definition: shapeList.cpp:107
Util::Matrix3D getNormalMatrix(void) const
Definition: shapeList.cpp:119
void _read(std::istream &stream)
Definition: shapeList.cpp:100
Definition: shapeList.h:281
void initOpenGL(void)
Definition: shapeList.cpp:335
int processAllIntersections(const Util::Ray3D &ray, const Util::BoundingBox1D &range, const RayIntersectionFilter &rFilter, const RayIntersectionKernel &rKernel, ShapeProcessingInfo spInfo, unsigned int tIdx) const
Definition: shapeList.todo.cpp:269
bool isInside(Util::Point3D p) const
Definition: shapeList.todo.cpp:296
ShapeList _shapeList
Definition: shapeList.h:283
bool processFirstIntersection(const Util::Ray3D &ray, const Util::BoundingBox1D &range, const RayIntersectionFilter &rFilter, const RayIntersectionKernel &rKernel, ShapeProcessingInfo spInfo, unsigned int tIdx) const
Definition: shapeList.todo.cpp:260
void updateBoundingBox(void)
Definition: shapeList.todo.cpp:288
void init(const class LocalSceneData &data)
Definition: shapeList.todo.cpp:277
void _read(std::istream &stream)
Definition: shapeList.cpp:323
static std::string Directive(void)
Definition: shapeList.h:287
void drawOpenGL(GLSLProgram *glslProgram) const
Definition: shapeList.cpp:330
void _write(std::ostream &stream) const
Definition: shapeList.cpp:314
std::string name(void) const
Definition: shapeList.h:296
Definition: scene.h:62
Definition: scene.h:249
Definition: scene.h:139
Definition: shapeList.h:152
static bool Compare(const ShapeBoundingBoxHit &v1, const ShapeBoundingBoxHit &v2)
Definition: shapeList.cpp:179
double t
Definition: shapeList.h:155
const Shape * shape
Definition: shapeList.h:158
Definition: shape.h:89
std::function< void(const ShapeProcessingInfo &, const Shape &) > Kernel
Definition: shape.h:162
std::function< bool(double) > RayIntersectionFilter
Definition: shape.h:163
std::function< ShapeProcessingInfo::ProcessingType(const ShapeProcessingInfo &, const Shape &) > Filter
Definition: shape.h:161
std::function< void(const ShapeProcessingInfo &, const class RayShapeIntersectionInfo &) > RayIntersectionKernel
Definition: shape.h:164
Definition: shapeList.h:168
static std::string _DirectiveHeader(void)
Definition: shapeList.h:173
static std::unordered_map< std::string, Util::BaseFactory< Shape > * > ShapeFactories
Definition: shapeList.h:177
void addTrianglesOpenGL(std::vector< class TriangleIndex > &triangles)
Definition: shapeList.cpp:219
std::string name(void) const
Definition: shapeList.h:192
static std::string Directive(void)
Definition: shapeList.h:180
void updateBoundingBox(void)
Definition: shapeList.todo.cpp:86
void _read(std::istream &stream)
Definition: shapeList.cpp:186
void processOverlapping(const Filter &filter, const Kernel &kernel, ShapeProcessingInfo tInfo) const
Definition: shapeList.cpp:224
void init(const class LocalSceneData &data)
Definition: shapeList.todo.cpp:73
bool processFirstIntersection(const Util::Ray3D &ray, const Util::BoundingBox1D &range, const RayIntersectionFilter &rFilter, const RayIntersectionKernel &rKernel, ShapeProcessingInfo spInfo, unsigned int tIdx) const
Definition: shapeList.todo.cpp:49
int processAllIntersections(const Util::Ray3D &ray, const Util::BoundingBox1D &range, const RayIntersectionFilter &rFilter, const RayIntersectionKernel &rKernel, ShapeProcessingInfo spInfo, unsigned int tIdx) const
Definition: shapeList.todo.cpp:58
bool isInside(Util::Point3D p) const
Definition: shapeList.todo.cpp:64
void drawOpenGL(GLSLProgram *glslProgram) const
Definition: shapeList.todo.cpp:105
void initOpenGL(void)
Definition: shapeList.todo.cpp:94
void _write(std::ostream &stream) const
Definition: shapeList.cpp:208
std::vector< Shape * > shapes
Definition: shapeList.h:183
Definition: shapeList.h:45
Util::Matrix3D _normalTransform
Definition: shapeList.h:53
std::string name(void) const
Definition: shapeList.h:71
Util::Matrix3D getNormalMatrix(void) const
Definition: shapeList.cpp:84
Util::Matrix4D _inverseTransform
Definition: shapeList.h:50
Util::Matrix4D getMatrix(void) const
Definition: shapeList.cpp:80
void _write(std::ostream &stream) const
Definition: shapeList.cpp:62
StaticAffineShape(void)
Definition: shapeList.cpp:58
Util::Matrix4D getInverseMatrix(void) const
Definition: shapeList.cpp:82
Util::Matrix4D _localTransform
Definition: shapeList.h:47
void init(const class LocalSceneData &data)
Definition: shapeList.todo.cpp:153
void _read(std::istream &stream)
Definition: shapeList.cpp:71
static std::string Directive(void)
Definition: shapeList.h:56
void initOpenGL(void)
Definition: shapeList.cpp:78
void set(Util::Matrix4D m)
Definition: shapeList.cpp:60
Definition: shapeList.h:206
void _write(std::ostream &stream) const
Definition: shapeList.cpp:245
const class Vertex * _vertices
Definition: shapeList.h:222
TriangleList(void)
Definition: shapeList.cpp:243
int _materialIndex
Definition: shapeList.h:225
GLuint _vertexBufferID
Definition: shapeList.h:210
unsigned int _vNum
Definition: shapeList.h:219
std::string name(void) const
Definition: shapeList.h:243
void initOpenGL(void)
Definition: shapeList.todo.cpp:196
bool processFirstIntersection(const Util::Ray3D &ray, const Util::BoundingBox1D &range, const RayIntersectionFilter &rFilter, const RayIntersectionKernel &rKernel, ShapeProcessingInfo spInfo, unsigned int tIdx) const
Definition: shapeList.cpp:268
void _read(std::istream &stream)
Definition: shapeList.cpp:254
static std::string Directive(void)
Definition: shapeList.h:231
const class Material * _material
Definition: shapeList.h:228
int processAllIntersections(const Util::Ray3D &ray, const Util::BoundingBox1D &range, const RayIntersectionFilter &rFilter, const RayIntersectionKernel &rKernel, ShapeProcessingInfo spInfo, unsigned int tIdx) const
Definition: shapeList.cpp:274
void processOverlapping(const Filter &filter, const Kernel &kernel, ShapeProcessingInfo tInfo) const
Definition: shapeList.cpp:262
GLuint _elementBufferID
Definition: shapeList.h:213
void init(const class LocalSceneData &data)
Definition: shapeList.todo.cpp:179
void drawOpenGL(GLSLProgram *glslProgram) const
Definition: shapeList.todo.cpp:168
unsigned int _tNum
Definition: shapeList.h:216
Definition: shapeList.h:254
void _read(std::istream &stream)
Definition: shapeList.cpp:293
void initOpenGL(void)
Definition: shapeList.cpp:305
std::string name(void) const
Definition: shapeList.h:268
bool isInside(Util::Point3D p) const
Definition: shapeList.todo.cpp:248
void _write(std::ostream &stream) const
Definition: shapeList.cpp:284
void updateBoundingBox(void)
Definition: shapeList.todo.cpp:240
ShapeList _shapeList
Definition: shapeList.h:256
int processAllIntersections(const Util::Ray3D &ray, const Util::BoundingBox1D &range, const RayIntersectionFilter &rFilter, const RayIntersectionKernel &rKernel, ShapeProcessingInfo spInfo, unsigned int tIdx) const
Definition: shapeList.todo.cpp:221
void init(const class LocalSceneData &data)
Definition: shapeList.todo.cpp:229
bool processFirstIntersection(const Util::Ray3D &ray, const Util::BoundingBox1D &range, const RayIntersectionFilter &rFilter, const RayIntersectionKernel &rKernel, ShapeProcessingInfo spInfo, unsigned int tIdx) const
Definition: shapeList.todo.cpp:212
static std::string Directive(void)
Definition: shapeList.h:259
void drawOpenGL(GLSLProgram *glslProgram) const
Definition: shapeList.cpp:300
Definition: scene.h:203
Definition: geometry.h:345
Definition: geometry.h:168
Definition: geometry.h:299
Definition: box.h:7
Definition: shape.h:147