Assignments Assignments

Classes | Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Attributes | Private Member Functions | List of all members
Ray::Shape Class Referenceabstract

`#include <shape.h>`

Inheritance diagram for Ray::Shape:

## Classes
struct | ShapeProcessingInfo

## Public Types
typedef std::function< ShapeProcessingInfo::ProcessingType(const ShapeProcessingInfo &, const Shape &) > | Filter
typedef std::function< void(const ShapeProcessingInfo &, const Shape &) > | Kernel
typedef std::function< bool(double) > | RayIntersectionFilter
typedef std::function< bool(const ShapeProcessingInfo &, const class RayShapeIntersectionInfo &) > | RayIntersectionKernel

## Public Member Functions
virtual | ~Shape (void)
ShapeBoundingBox | boundingBox (void) const
virtual void | init (const class LocalSceneData &data)=0
virtual void | initOpenGL (void)=0
virtual void | updateBoundingBox (void)=0
virtual std::string | name (void) const =0
virtual bool | isInside (Util::Point3D p) const =0
virtual void | drawOpenGL (GLSLProgram *glslProgram) const =0
virtual void | addTrianglesOpenGL (std::vector< class TriangleIndex > &triangles)
size_t | primitiveNum (void) const
virtual void | processOverlapping (const Filter &filter, const Kernel &kernel, ShapeProcessingInfo spInfo) const
virtual bool | processFirstIntersection (const Util::Ray3D &ray, const Util::BoundingBox1D &range, const RayIntersectionFilter &rFilter, const RayIntersectionKernel &rKernel, ShapeProcessingInfo spInfo, unsigned int tIdx) const =0
virtual int | processAllIntersections (const Util::Ray3D &ray, const Util::BoundingBox1D &range, const RayIntersectionFilter &rFilter, const RayIntersectionKernel &rKernel, ShapeProcessingInfo spInfo, unsigned int tIdx) const =0

## Static Public Member Functions
static void | WriteInset (std::ostream &stream)

## Static Public Attributes
static unsigned int | OpenGLTessellationComplexity
static unsigned int | WriteInsetSize = 0

## Protected Attributes
ShapeBoundingBox | _bBox
size_t | _primitiveNum

## Private Member Functions
virtual void | _write (std::ostream &stream) const =0
virtual void | _read (std::istream &stream)=0

## Detailed Description

This is the abstract class that all ray-traceable objects must implement.

## Member Typedef Documentation

## ◆ Filter

typedef std::function< ShapeProcessingInfo::ProcessingType ( const ShapeProcessingInfo & , const Shape & ) > Ray::Shape::Filter

## ◆ Kernel

typedef std::function< void ( const ShapeProcessingInfo & , const Shape & ) > Ray::Shape::Kernel

## ◆ RayIntersectionFilter

typedef std::function< bool ( double ) > Ray::Shape::RayIntersectionFilter

## ◆ RayIntersectionKernel

typedef std::function< bool ( const ShapeProcessingInfo & , const class RayShapeIntersectionInfo & ) > Ray::Shape::RayIntersectionKernel

## Constructor & Destructor Documentation

## ◆ ~Shape()

virtual Ray::Shape::~Shape | ( | void |  | ) |
| inline virtual

The destructor

## Member Function Documentation

## ◆ _read()

virtual void Ray::Shape::_read | ( | std::istream & | stream | ) |
| private pure virtual

This method reads the Shape from the stream (excluding the starting directive)

Implemented in Ray::Box, Ray::Cone, Ray::Cylinder, Ray::Difference, Ray::DynamicAffineShape, Ray::FileInstance, Ray::Intersection, Ray::SceneGeometry, Ray::ShapeList, Ray::Sphere, Ray::StaticAffineShape, Ray::Torus, Ray::Triangle, Ray::TriangleList, and Ray::Union.

## ◆ _write()

virtual void Ray::Shape::_write | ( | std::ostream & | stream | ) | const
| private pure virtual

This method writes the Shape into the stream (including the starting directive)

Implemented in Ray::Box, Ray::Cone, Ray::Cylinder, Ray::Difference, Ray::DynamicAffineShape, Ray::FileInstance, Ray::Intersection, Ray::SceneGeometry, Ray::ShapeList, Ray::Sphere, Ray::StaticAffineShape, Ray::Torus, Ray::Triangle, Ray::TriangleList, and Ray::Union.

## ◆ addTrianglesOpenGL()

virtual void Ray::Shape::addTrianglesOpenGL | ( | std::vector< class TriangleIndex > & | triangles | ) |
| inline virtual

This method adds a triangle to the list of triangles (if the object is of type RayTriangle).

Reimplemented in Ray::ShapeList, and Ray::Triangle.

## ◆ boundingBox()

ShapeBoundingBox Shape::boundingBox | ( | void |  | ) | const

The method returns the bounding box of the shape

## ◆ drawOpenGL()

virtual void Ray::Shape::drawOpenGL | ( | GLSLProgram * | glslProgram | ) | const
| pure virtual

This method calls the necessary OpenGL commands to render the primitive.

Implemented in Ray::AffineShape, Ray::Box, Ray::Cone, Ray::Cylinder, Ray::Difference, Ray::FileInstance, Ray::Intersection, Ray::SceneGeometry, Ray::ShapeList, Ray::Sphere, Ray::Torus, Ray::Triangle, Ray::TriangleList, and Ray::Union.

## ◆ init()

virtual void Ray::Shape::init | ( | const class LocalSceneData & | data | ) |
| pure virtual

This method should be called (once) immediately after setting up the scene graph

Implemented in Ray::Box, Ray::Cone, Ray::Cylinder, Ray::Difference, Ray::DynamicAffineShape, Ray::FileInstance, Ray::Intersection, Ray::ShapeList, Ray::Sphere, Ray::StaticAffineShape, Ray::Torus, Ray::Triangle, Ray::TriangleList, and Ray::Union.

## ◆ initOpenGL()

virtual void Ray::Shape::initOpenGL | ( | void |  | ) |
| pure virtual

This method should be called (once) after an OpenGL context has been created

Implemented in Ray::AffineShape, Ray::Box, Ray::Cone, Ray::Cylinder, Ray::Difference, Ray::FileInstance, Ray::Intersection, Ray::Scene, Ray::SceneGeometry, Ray::ShapeList, Ray::Sphere, Ray::StaticAffineShape, Ray::Torus, Ray::Triangle, Ray::TriangleList, and Ray::Union.

## ◆ isInside()

virtual bool Ray::Shape::isInside | ( | Util::Point3D | p | ) | const
| pure virtual

This method determines if a point is inside a shape. It is assumed that if the shape is not water-tight, the method returns false.

Implemented in Ray::AffineShape, Ray::Box, Ray::Cone, Ray::Cylinder, Ray::Difference, Ray::FileInstance, Ray::Intersection, Ray::SceneGeometry, Ray::ShapeList, Ray::Sphere, Ray::Torus, Ray::Triangle, and Ray::Union.

## ◆ name()

virtual std::string Ray::Shape::name | ( | void |  | ) | const
| pure virtual

This method returns the name of the shape

Implemented in Ray::Box, Ray::Cone, Ray::Cylinder, Ray::Difference, Ray::DynamicAffineShape, Ray::FileInstance, Ray::Intersection, Ray::SceneGeometry, Ray::ShapeList, Ray::Sphere, Ray::StaticAffineShape, Ray::Torus, Ray::Triangle, Ray::TriangleList, and Ray::Union.

## ◆ primitiveNum()

size_t Shape::primitiveNum | ( | void |  | ) | const

This method returns the count of basic shapes contained within the Shape.

## ◆ processAllIntersections()

virtual int Ray::Shape::processAllIntersections | ( | const Util::Ray3D & | ray,
|  | const Util::BoundingBox1D & | range,
|  | const RayIntersectionFilter & | rFilter,
|  | const RayIntersectionKernel & | rKernel,
|  | ShapeProcessingInfo | spInfo,
|  | unsigned int | tIdx ) const
| pure virtual

This method processes all shapes which intersect the ray within the prescribed range and passing the rFilter test, invoking the rKernel kernel with the intersection information. The processing terminates early if the kernel returns false. The function returns the number of valid intersections.

Implemented in Ray::AffineShape, Ray::Box, Ray::Cone, Ray::Cylinder, Ray::Difference, Ray::FileInstance, Ray::Intersection, Ray::Scene, Ray::SceneGeometry, Ray::ShapeList, Ray::Sphere, Ray::Torus, Ray::Triangle, Ray::TriangleList, and Ray::Union.

## ◆ processFirstIntersection()

virtual bool Ray::Shape::processFirstIntersection | ( | const Util::Ray3D & | ray,
|  | const Util::BoundingBox1D & | range,
|  | const RayIntersectionFilter & | rFilter,
|  | const RayIntersectionKernel & | rKernel,
|  | ShapeProcessingInfo | spInfo,
|  | unsigned int | tIdx ) const
| pure virtual

This method processes the first shape which intersect the ray within the prescribed range and passing the rFilter test, invoking the rKernel kernel with the intersection information. The function returns true if there was an intersection.

Implemented in Ray::AffineShape, Ray::Box, Ray::Cone, Ray::Cylinder, Ray::Difference, Ray::FileInstance, Ray::Intersection, Ray::Scene, Ray::SceneGeometry, Ray::ShapeList, Ray::Sphere, Ray::Torus, Ray::Triangle, Ray::TriangleList, and Ray::Union.

## ◆ processOverlapping()

void Shape::processOverlapping | ( | const Filter & | filter,
|  | const Kernel & | kernel,
|  | ShapeProcessingInfo | spInfo ) const
| virtual

This method process Shapes by calling the "kernel" function on every shape whose bounding box passes the "filter" test. The tInfo parameter stores the accumulation of transformations encountered when traversing the scene-graph. Note that the bounding box is in the coordinate frame of the node.

Reimplemented in Ray::AffineShape, Ray::FileInstance, Ray::SceneGeometry, Ray::ShapeList, and Ray::TriangleList.

## ◆ updateBoundingBox()

virtual void Ray::Shape::updateBoundingBox | ( | void |  | ) |
| pure virtual

This method should be called to update the bounding boxes in the scene

Implemented in Ray::AffineShape, Ray::Box, Ray::Cone, Ray::Cylinder, Ray::Difference, Ray::FileInstance, Ray::Intersection, Ray::SceneGeometry, Ray::ShapeList, Ray::Sphere, Ray::Torus, Ray::Triangle, and Ray::Union.

## ◆ WriteInset()

void Shape::WriteInset | ( | std::ostream & | stream | ) |
| static

This static method insets for writing.

## Member Data Documentation

## ◆ _bBox

ShapeBoundingBox Ray::Shape::_bBox
| protected

This member represents the bounding box of the shape.

## ◆ _primitiveNum

size_t Ray::Shape::_primitiveNum
| protected

This member represents the number of primitives describing the shape.

## ◆ OpenGLTessellationComplexity

unsigned int Shape::OpenGLTessellationComplexity
| static

A global variable representing how finely shapes should be tessellated for rendering as triangle meshes.

## ◆ WriteInsetSize

unsigned int Shape::WriteInsetSize = 0
| static

A global variable representing how inset the next shape should be when writing to a stream.

The documentation for this class was generated from the following files:

- Assignments/Ray/shape.h
- Assignments/Ray/shape.cpp