Assignments
Assignments
triangle.h
Go to the documentation of this file.
1#ifndef TRIANGLE_INCLUDED
2#define TRIANGLE_INCLUDED
3#include <Util/geometry.h>
4#include <Util/polynomial.h>
5#include "shape.h"
6#include "scene.h"
7
8namespace Ray
9{
12 {
14 GLuint _indices[3];
15
16 public:
18 TriangleIndex( void ){ _indices[0] = _indices[1] = _indices[2] = 0; }
19
21 TriangleIndex( unsigned int i0 , unsigned int i1 , unsigned int i2 ){ _indices[0] = i0 , _indices[1] = i1 , _indices[2] = i2; }
22
24 GLuint& operator[] ( int idx ) { return _indices[idx]; }
25
27 const GLuint &operator[] ( int idx ) const { return _indices[idx]; }
28 };
29
31 class Triangle : public Shape
32 {
34 size_t _vIndices[3];
35
37 const class Vertex* _v[3];
38
39 public:
41 static std::string Directive( void ){ return "shape_triangle"; }
42
44 Triangle( void );
45
47 // Shape methods //
49 private:
50 void _write( std::ostream &stream ) const;
51 void _read( std::istream &stream );
52 public:
53 std::string name( void ) const { return "triangle"; }
54 void init( const class LocalSceneData &data );
55 void initOpenGL( void );
56 void updateBoundingBox( void );
57 bool processFirstIntersection( const Util::Ray3D &ray , const Util::BoundingBox1D &range , const RayIntersectionFilter &rFilter , const RayIntersectionKernel &rKernel , ShapeProcessingInfo spInfo , unsigned int tIdx ) const;
58 int processAllIntersections( const Util::Ray3D &ray , const Util::BoundingBox1D &range , const RayIntersectionFilter &rFilter , const RayIntersectionKernel &rKernel , ShapeProcessingInfo spInfo , unsigned int tIdx ) const;
59 bool isInside( Util::Point3D p ) const;
60 void addTrianglesOpenGL( std::vector< TriangleIndex >& triangles );
61 void drawOpenGL( GLSLProgram * glslProgram ) const;
62 };
63}
64#endif // TRIANGLE_INCLUDED
65
66
Definition: GLSLProgram.h:33
Definition: scene.h:62
Definition: shape.h:89
std::function< bool(double) > RayIntersectionFilter
Definition: shape.h:163
std::function< void(const ShapeProcessingInfo &, const class RayShapeIntersectionInfo &) > RayIntersectionKernel
Definition: shape.h:164
Definition: triangle.h:32
bool processFirstIntersection(const Util::Ray3D &ray, const Util::BoundingBox1D &range, const RayIntersectionFilter &rFilter, const RayIntersectionKernel &rKernel, ShapeProcessingInfo spInfo, unsigned int tIdx) const
Definition: triangle.todo.cpp:48
void updateBoundingBox(void)
Definition: triangle.todo.cpp:29
void addTrianglesOpenGL(std::vector< TriangleIndex > &triangles)
Definition: triangle.cpp:26
void _write(std::ostream &stream) const
Definition: triangle.cpp:18
size_t _vIndices[3]
Definition: triangle.h:34
void init(const class LocalSceneData &data)
Definition: triangle.todo.cpp:12
void drawOpenGL(GLSLProgram *glslProgram) const
Definition: triangle.todo.cpp:59
const class Vertex * _v[3]
Definition: triangle.h:37
void initOpenGL(void)
Definition: triangle.todo.cpp:37
Triangle(void)
Definition: triangle.cpp:11
int processAllIntersections(const Util::Ray3D &ray, const Util::BoundingBox1D &range, const RayIntersectionFilter &rFilter, const RayIntersectionKernel &rKernel, ShapeProcessingInfo spInfo, unsigned int tIdx) const
Definition: triangle.cpp:31
static std::string Directive(void)
Definition: triangle.h:41
std::string name(void) const
Definition: triangle.h:53
void _read(std::istream &stream)
Definition: triangle.cpp:13
bool isInside(Util::Point3D p) const
Definition: triangle.cpp:24
Definition: triangle.h:12
GLuint _indices[3]
Definition: triangle.h:14
GLuint & operator[](int idx)
Definition: triangle.h:24
TriangleIndex(void)
Definition: triangle.h:18
TriangleIndex(unsigned int i0, unsigned int i1, unsigned int i2)
Definition: triangle.h:21
Definition: scene.h:203
Definition: geometry.h:345
Definition: geometry.h:299
Definition: box.h:7