Path Tracer
Public Member Functions | Protected Attributes | List of all members
Object3D Class Referenceabstract

Abstract class for a three-dimentional object. More...

#include <Object3D.h>

Inheritance diagram for Object3D:
[legend]

Public Member Functions

 Object3D ()
 Default constructor. More...
 
 Object3D (Material *material)
 Main constructor. More...
 
 Object3D (const Object3D &obj)
 Copy constructor. More...
 
 ~Object3D ()
 Destructor. More...
 
MaterialgetMaterial () const
 Getter for the Material. More...
 
double getArea () const
 Getter for this object's area. More...
 
void setMaterial (Material *material)
 Setter for the Material. More...
 
virtual void computeArea ()=0
 Computes this object area. More...
 
virtual Object3DdeepCopy () const =0
 Makes a deep copy of this object. More...
 
virtual double smallestPositiveIntersection (const Ray &ray) const =0
 Computes the smallest positive intersection between the ray and this object. More...
 
virtual DoubleUnitVec3D getNormal (const DoubleVec3D &point) const =0
 Computes the normal at a point on the object. More...
 
virtual DoubleVec3D getRandomPoint () const =0
 Computes a random point on the object. More...
 
virtual std::ostream & getDescription (std::ostream &stream) const =0
 Returns this object's description. More...
 
virtual DoubleVec3D getCenter () const =0
 Returns this object's center. More...
 
virtual DoubleVec3D getMinCoord () const =0
 Returns the minimum coordinate of a cuboid containing this object. More...
 
virtual DoubleVec3D getMaxCoord () const =0
 Returns the maximum coordinate of a cuboid containing this object. More...
 
virtual std::string getType () const =0
 Returns this object type. More...
 
virtual json getLocationJson () const =0
 Converts this objects's location to json. More...
 
virtual void setLocationJson (const json &j)=0
 Sets this object's location according to json. More...
 
Object3Doperator= (const Object3D &otherObject)
 Assignment operator. More...
 

Protected Attributes

double area
 Stores the area of this object. More...
 

Detailed Description

Abstract class for a three-dimentional object.

Constructor & Destructor Documentation

◆ Object3D() [1/3]

Object3D::Object3D ( )

Default constructor.

The default material is a diffuse one.

◆ Object3D() [2/3]

Object3D::Object3D ( Material material)

Main constructor.

Parameters
materialThe material of this object.

◆ Object3D() [3/3]

Object3D::Object3D ( const Object3D obj)

Copy constructor.

Calls Object3D::operator=().

Parameters
objThe object that will be copied.
See also
Object3D::operator=().

◆ ~Object3D()

Object3D::~Object3D ( )

Destructor.

Member Function Documentation

◆ computeArea()

void Object3D::computeArea ( )
pure virtual

Computes this object area.

Modifies Object3D::area.

See also
Object3D::area, Object3D::getArea()

Implemented in Triangle, and Sphere.

◆ deepCopy()

Object3D * Object3D::deepCopy ( ) const
pure virtual

Makes a deep copy of this object.

Returns
A pointer to a deeply copied version of this object.

Implemented in Triangle, and Sphere.

◆ getArea()

double Object3D::getArea ( ) const

Getter for this object's area.

Returns
This object's area.
See also
Object3D::area, Object3D::computeArea()

◆ getCenter()

DoubleVec3D Object3D::getCenter ( ) const
pure virtual

Returns this object's center.

Returns
The center of this object.

Implemented in Triangle, and Sphere.

◆ getDescription()

std::ostream & Object3D::getDescription ( std::ostream &  stream) const
pure virtual

Returns this object's description.

Parameters
streamThe current stream.
Returns
The stream with the description.
See also
operator<<(std::ostream& stream, const Object3D& object)

Implemented in Triangle, and Sphere.

◆ getLocationJson()

json Object3D::getLocationJson ( ) const
pure virtual

Converts this objects's location to json.

Returns
This object's location converted to json.

Implemented in Triangle, and Sphere.

◆ getMaterial()

Material * Object3D::getMaterial ( ) const

Getter for the Material.

Returns
A pointer to this object's material.

◆ getMaxCoord()

DoubleVec3D Object3D::getMaxCoord ( ) const
pure virtual

Returns the maximum coordinate of a cuboid containing this object.

Returns
The maximum coordinate of a cuboid containing this object.
See also
getMaxPoint(std::vector<Object3D*> objects)

Implemented in Triangle, and Sphere.

◆ getMinCoord()

DoubleVec3D Object3D::getMinCoord ( ) const
pure virtual

Returns the minimum coordinate of a cuboid containing this object.

Returns
The minimum coordinate of a cuboid containing this object.
See also
getMinPoint(std::vector<Object3D*> objects)

Implemented in Triangle, and Sphere.

◆ getNormal()

DoubleUnitVec3D Object3D::getNormal ( const DoubleVec3D point) const
pure virtual

Computes the normal at a point on the object.

Parameters
pointThe point on the object at which we want to compute the normal.
Returns
The normal at this point.

Implemented in Triangle, and Sphere.

◆ getRandomPoint()

DoubleVec3D Object3D::getRandomPoint ( ) const
pure virtual

Computes a random point on the object.

Every point has the same probability to show up.

Returns
A random point on this object.

Implemented in Triangle, and Sphere.

◆ getType()

std::string Object3D::getType ( ) const
pure virtual

Returns this object type.

Returns
Returns "Sphere" or "Triangle", depending on the object instance.

Implemented in Triangle, and Sphere.

◆ operator=()

Object3D & Object3D::operator= ( const Object3D otherObject)

Assignment operator.

Makes a deepcopy of the material before copying it.

Parameters
otherObjectThe object to which this will be equal.
See also
Object3D::Object3D(const Object3D& obj)

◆ setLocationJson()

void Object3D::setLocationJson ( const json j)
pure virtual

Sets this object's location according to json.

Parameters
jThe json input.

Implemented in Triangle, and Sphere.

◆ setMaterial()

void Object3D::setMaterial ( Material material)

Setter for the Material.

Parameters
materialThe new material of this object.

◆ smallestPositiveIntersection()

double Object3D::smallestPositiveIntersection ( const Ray ray) const
pure virtual

Computes the smallest positive intersection between the ray and this object.

Parameters
rayThe ray with wich we want to compute the intersection.
Returns
The distance between the ray origin and the intersection (the smallest one if there is more than one intersection). Returns -1 if the ray does not intersect with this object.

Implemented in Triangle, and Sphere.

Member Data Documentation

◆ area

double Object3D::area
protected

Stores the area of this object.

It is computed every time the object coordinates are modified.

See also
Object3D::getArea(), Object3D::computeArea()

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