JWS C++ Library
C++ language utility library
jwscxx::graphics::Parapiped_f Class Reference

Parallelepiped: a hexahedron of which each face is a parallelegram. More...

#include <parapiped.h>

Inheritance diagram for jwscxx::graphics::Parapiped_f:
Collaboration diagram for jwscxx::graphics::Parapiped_f:

List of all members.

Public Member Functions

 Parapiped_f (float x1, float y1, float z1, float x2, float y2, float z2, float x3, float y3, float z3, float x4, float y4, float z4)
 Constructs a parallelepiped.
 Parapiped_f (const jwsc::Vector_f *p1, const jwsc::Vector_f *p2, const jwsc::Vector_f *p3, const jwsc::Vector_f *p4) throw (jwscxx::base::Arg_error)
 Constructs a parallelepiped.
 Parapiped_f (const Parapiped_f &p)
 Constructs a parallelepiped by copying another.
 Parapiped_f (const char *fname) throw (jwscxx::base::Arg_error, jwscxx::base::IO_error)
 Reads a parallelepiped from an input file.
 Parapiped_f (std::istream &in) throw (jwscxx::base::Arg_error, jwscxx::base::IO_error)
 Reads a parallelepiped from an input stream.
virtual ~Parapiped_f ()
 Deletes this parallelepiped.
virtual Parapiped_foperator= (const Parapiped_f &p)
 Copies a parallelepiped into this one.
virtual Parapiped_fclone () const
 Clones this parallelepiped.
size_t num_faces () const
 Returns the number of faces in this parallelepiped.
const jwsc::Vector_f * get_point (size_t i) const throw (jwscxx::base::Arg_error)
 Returns an indexed point defining this parapiped.
const jwsc::Vector_f * get_center () const
 Returns the center vector for this parallelepiped.
const jwscxx::graphics::Polygon_fget_face (size_t i) const throw (jwscxx::base::Arg_error)
 Returns an indexed parapiped face.
const std::vector< const
jwscxx::graphics::Polygon_f * > & 
get_faces () const
 Returns the faces of this parapiped.
void set_face_id (size_t i, uint32_t id) throw (jwscxx::base::Arg_error)
 Sets the id of a face in the parapiped.
virtual void read (std::istream &in) throw (jwscxx::base::IO_error, jwscxx::base::Arg_error)
 Reads this parallelepiped from an input stream.
virtual void write (std::ostream &out) const throw (jwscxx::base::IO_error)
 Writes this parallelepiped to an output stream.
virtual void transform (const jwsc::Matrix_f *M) throw (jwscxx::base::Arg_error)
 Applies a linear transformation to this parallelepiped.
virtual void wire_render () const
 Renders this parallelepiped with the GL as a wire-frame.
virtual void wire_occlude_render () const
 Renders this parapiped with the GL as an occluded wire-frame into the depth buffer, to hide unseen lines.
virtual void solid_render () const
 Renders this parallelepiped with the GL as a solid.
virtual void project ()
 Projects this parapiped into the current GL view.
uint32_t adjacent_face (uint32_t i, uint32_t p) const throw (jwscxx::base::Arg_error)
 Returns the face adjacent to another on a shared edge.

Protected Attributes

std::vector
< jwscxx::graphics::Polygon_f * > 
faces
 Polygons defining the parallelepiped.
std::vector< jwsc::Vector_f * > points
 Points defining this parapiped.
jwsc::Vector_f * center
 Center of this parallelepiped.
jwsc::Matrix_u32 * adjacency
 Face adjacency matrix.

Detailed Description

Parallelepiped: a hexahedron of which each face is a parallelegram.

Definition at line 79 of file parapiped.h.


Constructor & Destructor Documentation

Parapiped_f::Parapiped_f ( float  x1,
float  y1,
float  z1,
float  x2,
float  y2,
float  z2,
float  x3,
float  y3,
float  z3,
float  x4,
float  y4,
float  z4 
)

Constructs a parallelepiped.

The mapping from four input points to the defined parallelepiped is as follows:

        +------------+                             p3
        |\           |\                            |\
        |  +------------+                          |  p4
        |  |         |  |                          |           y       
        |  |         |  |    ---->                 |           |       
        |  |         |  |                          |           +--- x  
        +--|---------+  |             p1-----------p2         /        
         \ |          \ |                                    z       
           +------------+

Upon initialization, each face of this parallelepiped is parallel with one of the xy, xz, or yz-planes; the symetric pairs of faces are distinguished by the sign of their outward directed normal vector. The order (mapping) of the face indices is as follows

    i=0:  yz-plane, +x norm 
    i=1:  yz-plane, -x norm 
    i=2:  xz-plane, +y norm 
    i=3:  xz-plane, -y norm 
    i=4:  xy-plane, +z norm 
    i=5:  xy-plane, -z norm 
Parameters:
x1X-coord of the point 1.
y1Y-coord of the point 1.
z1Z-coord of the point 1.
x2X-coord of the point 2.
y2Y-coord of the point 2.
z2Z-coord of the point 2.
x3X-coord of the point 3.
y3Y-coord of the point 3.
z3Z-coord of the point 3.
x4X-coord of the point 4.
y4Y-coord of the point 4.
z4Z-coord of the point 4.

Definition at line 166 of file parapiped.cpp.

Parapiped_f::Parapiped_f ( const jwsc::Vector_f *  p1,
const jwsc::Vector_f *  p2,
const jwsc::Vector_f *  p3,
const jwsc::Vector_f *  p4 
) throw (jwscxx::base::Arg_error)

Constructs a parallelepiped.

The mapping from four input points to the defined parallelepiped is as follows:

        +------------+                             p3
        |\           |\                            |\
        |  +------------+                          |  p4
        |  |         |  |                          |           y       
        |  |         |  |    ---->                 |           |      
        |  |         |  |                          |           +--- x 
        +--|---------+  |             p1-----------p2         /       
         \ |          \ |                                    z       
           +------------+

Upon initialization, each face of this parallelepiped is parallel with one of the xy, xz, or yz-planes; the symetric pairs of faces are distinguished by the sign of their outward directed normal vector. The order (mapping) of the face indices is as follows

    i=0:  yz-plane, +x norm 
    i=1:  yz-plane, -x norm 
    i=2:  xz-plane, +y norm 
    i=3:  xz-plane, -y norm 
    i=4:  xy-plane, +z norm 
    i=5:  xy-plane, -z norm 
Parameters:
p1Point 1.
p2Point 2.
p3Point 3.
p4Point 4.
Exceptions:
jwscxx::base::Arg_errorThe vectors are not 3D.

Definition at line 293 of file parapiped.cpp.

Parapiped_f::Parapiped_f ( const Parapiped_f p)

Constructs a parallelepiped by copying another.

Parameters:
pParallelepiped to copy into this one.

Definition at line 395 of file parapiped.cpp.

Parapiped_f::Parapiped_f ( const char *  fname) throw (jwscxx::base::Arg_error, jwscxx::base::IO_error)

Reads a parallelepiped from an input file.

The file format is big-endian binary.

Parameters:
fnameInput file to read this parallelepiped from.
Exceptions:
jwscxx::base::IO_errorCould not read from in.
jwscxx::base::Arg_errorInvalid arguments in file to read from.

Definition at line 423 of file parapiped.cpp.

Parapiped_f::Parapiped_f ( std::istream &  in) throw (jwscxx::base::Arg_error, jwscxx::base::IO_error)

Reads a parallelepiped from an input stream.

The file format is big-endian binary.

Parameters:
inInput stream to read this parallelepiped from.
Exceptions:
jwscxx::base::IO_errorCould not read from in.
jwscxx::base::Arg_errorInvalid arguments in file to read from.

Definition at line 442 of file parapiped.cpp.

Parapiped_f::~Parapiped_f ( ) [virtual]

Deletes this parallelepiped.

Frees all space allocated by this parallelepiped.

Definition at line 454 of file parapiped.cpp.


Member Function Documentation

Parapiped_f & Parapiped_f::operator= ( const Parapiped_f p) [virtual]

Copies a parallelepiped into this one.

Performs a deep copy of the faces in the parallelepiped.

Parameters:
pParallelepiped to copy into this one.
Returns:
A reference to this parallelepiped.

Definition at line 478 of file parapiped.cpp.

Parapiped_f * Parapiped_f::clone ( ) const [virtual]

Clones this parallelepiped.

Returns:
A new copy of this parallelepiped.

Implements jwscxx::base::Cloneable.

Reimplemented in jwscxx::graphics::Cuboid_f.

Definition at line 502 of file parapiped.cpp.

size_t Parapiped_f::num_faces ( ) const [virtual]

Returns the number of faces in this parallelepiped.

Implements jwscxx::graphics::Polymesh_f.

Definition at line 508 of file parapiped.cpp.

const jwsc::Vector_f * Parapiped_f::get_point ( size_t  i) const throw (jwscxx::base::Arg_error)

Returns an indexed point defining this parapiped.

Definition at line 514 of file parapiped.cpp.

const jwsc::Vector_f * Parapiped_f::get_center ( ) const

Returns the center vector for this parallelepiped.

The vector is in homogeneous coordinates x, y, z, w. The coordinate w is always 1.

Definition at line 530 of file parapiped.cpp.

const jwscxx::graphics::Polygon_f * Parapiped_f::get_face ( size_t  i) const throw (jwscxx::base::Arg_error)

Returns an indexed parapiped face.

Parameters:
iIndex of the face to get; ranges 0 to 5.
Returns:
The specified parapiped face.
Exceptions:
jwscxx::base::Arg_errorInvalid face index.

Reimplemented from jwscxx::graphics::Polymesh_f.

Definition at line 543 of file parapiped.cpp.

const std::vector< const jwscxx::graphics::Polygon_f * > & Parapiped_f::get_faces ( ) const

Returns the faces of this parapiped.

Definition at line 556 of file parapiped.cpp.

void Parapiped_f::set_face_id ( size_t  i,
uint32_t  id 
) throw (jwscxx::base::Arg_error)

Sets the id of a face in the parapiped.

Parameters:
iFace index; ranges 0 to 5.
idId to set the face with.
Exceptions:
jwscxx::base::Arg_errorInvalid face index.

Definition at line 570 of file parapiped.cpp.

void Parapiped_f::read ( std::istream &  in) throw (jwscxx::base::IO_error, jwscxx::base::Arg_error) [virtual]

Reads this parallelepiped from an input stream.

Parameters:
inInput stream to read the members of this parallelepiped from.
Exceptions:
jwscxx::base::IO_errorCould not read from in.
jwscxx::base::Arg_errorInvalid argument to read from file.

Implements jwscxx::base::Readable.

Definition at line 588 of file parapiped.cpp.

void Parapiped_f::write ( std::ostream &  out) const throw (jwscxx::base::IO_error) [virtual]

Writes this parallelepiped to an output stream.

The file format is big-endian binary.

Parameters:
outOutput stream to write the members of this parallelepiped to.
Exceptions:
jwscxx::base::IO_errorCould not write to out.

Implements jwscxx::base::Writeable.

Definition at line 664 of file parapiped.cpp.

void Parapiped_f::transform ( const jwsc::Matrix_f *  M) throw (jwscxx::base::Arg_error) [virtual]

Applies a linear transformation to this parallelepiped.

Parameters:
MHomogeneous transformation matrix to transform this parallelepiped by.
Exceptions:
jwscxx::base::Arg_errorThe matrix is not in 4x4 homogeneous coordinates.

Implements jwscxx::graphics::Transformable_f.

Definition at line 729 of file parapiped.cpp.

void Parapiped_f::wire_render ( ) const [virtual]

Renders this parallelepiped with the GL as a wire-frame.

Does not set color or material effects.

Implements jwscxx::graphics::Wire_renderable.

Definition at line 748 of file parapiped.cpp.

void Parapiped_f::wire_occlude_render ( ) const [virtual]

Renders this parapiped with the GL as an occluded wire-frame into the depth buffer, to hide unseen lines.

Does not render into the color buffer, only the depth buffer.

After calling this method, call wire_render() to render the parapiped with hidden lines occluded.

Implements jwscxx::graphics::Wire_occlude_renderable.

Definition at line 763 of file parapiped.cpp.

void Parapiped_f::solid_render ( ) const [virtual]

Renders this parallelepiped with the GL as a solid.

Does not set color or material effects.

Implements jwscxx::graphics::Solid_renderable.

Definition at line 773 of file parapiped.cpp.

void Parapiped_f::project ( ) [virtual]

Projects this parapiped into the current GL view.

The parapiped faces are transformed and projected onto the view plane by the current modelview and projection matrix on the GL stack.

The origin of the view plane coordinate system is in the lower left corner and its extents are defined by the current GL viewport size.

Definition at line 789 of file parapiped.cpp.

uint32_t Parapiped_f::adjacent_face ( uint32_t  i,
uint32_t  p 
) const throw (jwscxx::base::Arg_error) [virtual]

Returns the face adjacent to another on a shared edge.

The face point index must be in the range [0,3]. To specify the edge formed by the 0th and 3rd point, set p = 3.

Parameters:
iFace index to get the adjacent face of.
pFirst point index in face of the shared edge. If set to 3, the other point forming the edge will be 0.
Exceptions:
jwscxx::base::Arg_errorIf i or p are not valid indices.

Implements jwscxx::graphics::Polymesh_f.

Definition at line 808 of file parapiped.cpp.


Member Data Documentation

Polygons defining the parallelepiped.

Definition at line 207 of file parapiped.h.

std::vector<jwsc::Vector_f*> jwscxx::graphics::Parapiped_f::points [protected]

Points defining this parapiped.

Definition at line 210 of file parapiped.h.

jwsc::Vector_f* jwscxx::graphics::Parapiped_f::center [protected]

Center of this parallelepiped.

Calculated as the average of the face centroids.

Definition at line 217 of file parapiped.h.

jwsc::Matrix_u32* jwscxx::graphics::Parapiped_f::adjacency [protected]

Face adjacency matrix.

Major index is the face, minor is the index of the first point (in increasing order) on the face forming the adjacency edge.

Definition at line 225 of file parapiped.h.


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