KJB
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
kjb::Parapiped Class Reference

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

#include <gr_parapiped.h>

Inheritance diagram for kjb::Parapiped:
kjb::Polymesh kjb::Abstract_renderable kjb::Rigid_object kjb::Readable kjb::Writeable kjb::Renderable kjb::Solid_renderable kjb::Wire_renderable kjb::Wire_occlude_renderable kjb::Transformable kjb::Cloneable

Public Member Functions

 Parapiped (double x1, double y1, double z1, double x2, double y2, double z2, double x3, double y3, double z3, double x4, double y4, double z4)
 Constructs a parallelepiped. More...
 
 Parapiped (const kjb::Vector &p1, const kjb::Vector &p2, const kjb::Vector &p3, const kjb::Vector &p4) throw (kjb::Illegal_argument)
 Constructs a parallelepiped. More...
 
 Parapiped (const Parapiped &p)
 Constructs a parallelepiped by copying another. More...
 
 Parapiped (const char *fname) throw (kjb::Illegal_argument, kjb::IO_error)
 Reads a parallelepiped from an input file. More...
 
 Parapiped (std::istream &in) throw (kjb::Illegal_argument, kjb::IO_error)
 Reads a parallelepiped from an input stream. More...
 
virtual ~Parapiped ()
 Deletes this parallelepiped. More...
 
virtual Parapipedoperator= (const Parapiped &p)
 Copies a parallelepiped into this one. More...
 
virtual Parapipedclone () const
 Clones this parallelepiped. More...
 
virtual void transform (const kjb::Matrix &M) throw (kjb::Illegal_argument)
 Transforms this parallelepiped. More...
 
const kjb::Vectorget_point (size_t i) const throw (kjb::Illegal_argument)
 Returns an indexed point defining this parapiped. More...
 
const kjb::Vectorget_center () const
 Returns the center vector for this parallelepiped. More...
 
virtual void add_face (const Polygon &face) throw (kjb::Illegal_argument)
 Adds a face to this parapiped -> Not implemented here, it will throw an exception, because the use of this method will violate the constraints defining this parapiped. More...
 
virtual void read (std::istream &in) throw (kjb::IO_error, kjb::Illegal_argument)
 Reads this parallelepiped from an input stream. More...
 
virtual void write (std::ostream &out) const throw (kjb::IO_error)
 Writes this parallelepiped to an output stream. More...
 
void set_points (double x1, double y1, double z1, double x2, double y2, double z2, double x3, double y3, double z3, double x4, double y4, double z4)
 reset the points of this parapiped More...
 
virtual unsigned int adjacent_face (unsigned int f, unsigned int e) const throw (Index_out_of_bounds,KJB_error)
 returns the index of the face adjacent to face f along edge e This is an efficient implementation to be used only in the context of the parallelepiped More...
 
void draw_orientation_map () const
 
void draw_left_right_orientation_map () const
 
void draw_CMU_orientation_map () const
 
void draw_geometric_context_map () const
 
- Public Member Functions inherited from kjb::Polymesh
 Polymesh ()
 Constructs a triangular mesh. More...
 
 Polymesh (unsigned int n)
 
 Polymesh (const char *fname) throw (kjb::Illegal_argument, kjb::IO_error)
 Reads a triangular mesh from an input file. More...
 
 Polymesh (std::istream &in) throw (kjb::Illegal_argument, kjb::IO_error)
 Reads a triangular mesh from an input file. More...
 
 Polymesh (const Polymesh &t)
 Copy constructor. More...
 
virtual Polymeshoperator= (const Polymesh &t)
 Copies a triangular mesh into this one. More...
 
virtual ~Polymesh ()
 Deletes this Polymesh. More...
 
unsigned int num_faces () const
 Returns the number of faces in this mesh. More...
 
const std::vector< kjb::Polygon > & get_faces () const
 Returns the faces of this mesh. More...
 
const kjb::Polygonget_face (unsigned int i) const throw (kjb::Index_out_of_bounds)
 Returns an indexed face. More...
 
kjb::Polygonget_face_ref (unsigned int i) throw (kjb::Index_out_of_bounds)
 Returns an indexed face. More...
 
virtual void write (const char *filename) const throw (IO_error)
 Writes this mesh to an output stream. More...
 
virtual void translate (double x, double y, double z)
 Translates this rigid object. More...
 
virtual void rotate (double phi, double x, double y, double z)
 
virtual void rotate (double dpitch, double dyaw, double droll)
 rotate this object around its x-axis by dpitch, the y-axis by dyaw, and its z-axis by droll (in this order, starting from the object's current position) More...
 
virtual void scale (double scale_x, double scale_y, double scale_z)
 
void get_faces (std::vector< const Polygon * > &ifaces) const
 
virtual void wire_render () const
 Renders this mesh as a wire frame. More...
 
unsigned int wire_render_with_sequential_ids (unsigned int start_id=1) const
 Render each edge of this polymesh with a different color. The first edge will be rendered using the input id as a color, the following edges will be rendered with an id sequentially increasing. Returns the id (color) used to render the last edge of the polygon. More...
 
unsigned int solid_render_with_sequential_ids (unsigned int start_id=1) const
 Render each polygon of this polymesh with a different color. The first polygon will be rendered using the input id as a color, the following ones will be rendered with an id sequentially increasing. Returns the id (color) used to render the last polygon. More...
 
virtual void wire_occlude_render () const
 Renders this mesh as a wire frame into the depth buffer. Use wire_render after this to render this mesh as a wire frame by not drawing occluded edges. More...
 
virtual void solid_render () const
 Renders this object with GL as a wire-frame. More...
 
virtual void silhouette_render (const kjb::Base_gl_interface &camera, double iwidth=1.0) const
 
virtual void project ()
 
double compute_surface_area () const
 Returns the surface area of the mesh. More...
 
void get_all_vertices (std::vector< Vector > &vertices) const
 Stores the vertices of the mesh in a vector. More...
 
void get_all_edges (std::vector< std::vector< Vector > > &edges) const
 Stores all of the unique pairs of points that make up the edges of the polymesh in a vector. More...
 
void get_lines (std::vector< Line3d > &lines)
 
void find_bounds ()
 
kjb::Vector get_center ()
 
double get_largest_z_bound ()
 
kjb::Vector get_largest_bounds () const
 
kjb::Vector get_smallest_bounds () const
 
- Public Member Functions inherited from kjb::Abstract_renderable
virtual ~Abstract_renderable ()
 Deletes this Solid_renderable. More...
 
virtual void render () const
 Renders this object with GL. More...
 
virtual void render_occluded_wireframe () const
 Renders this object with GL as an occluded wire-frame into the depth buffer, to hide unseen lines. More...
 
- Public Member Functions inherited from kjb::Renderable
virtual ~Renderable ()
 Deletes this Renderable. More...
 
- Public Member Functions inherited from kjb::Solid_renderable
virtual ~Solid_renderable ()
 Deletes this Wire_renderable. More...
 
- Public Member Functions inherited from kjb::Wire_renderable
virtual ~Wire_renderable ()
 Deletes this Wire_renderable. More...
 
- Public Member Functions inherited from kjb::Wire_occlude_renderable
virtual ~Wire_occlude_renderable ()
 Deletes this Wire_occlude_renderable. More...
 
- Public Member Functions inherited from kjb::Rigid_object
 Rigid_object ()
 
 Rigid_object (const Rigid_object &ro)
 
virtual Rigid_objectoperator= (const Rigid_object &src)
 
virtual ~Rigid_object ()
 
virtual void swap (Self &other)
 
virtual void compute_new_euler_angles_on_rotations (double dpitch, double dyaw, double droll, kjb::Vector &angles) const
 computes the new values for the object's euler angles, after a rotation of dpitch around the object's x-axis, a rotation of dyaw around the object's y axis, and a rotation of droll around the object's z axis (in this order, starting from the object's current position). The state of this rigid object is not changed More...
 
virtual void set_rotations (double pitch, double yaw, double roll)
 rotate this object so that its pitch, yaw and roll match the input values More...
 
virtual void set_rotations_and_translate (double pitch, double yaw, double roll, double dx, double dy, double dz)
 rotate this object so that its pitch, yaw and roll match the input values, and translates it More...
 
const Matrixget_rotations () const
 Returns the current transformation matrix, that is used to store the rotation to be applied to the object. More...
 
const Vectorget_euler_angles () const
 returns vector [pitch, yaw, roll] More...
 
void set_rotation_mode (kjb::Quaternion::Euler_mode imode)
 
const kjb::Quaternionget_orientation () const
 returns the quaternion defining this object's orientation More...
 
void set_orientation (const Quaternion &orientation)
 sets the orientation of this object from an input quaternion More...
 
- Public Member Functions inherited from kjb::Transformable
virtual ~Transformable ()
 Deletes this Transformable. More...
 
virtual ~Transformable ()
 Deletes this Transformable_d. More...
 
- Public Member Functions inherited from kjb::Cloneable
virtual ~Cloneable ()
 Deletes this Cloneable. More...
 
- Public Member Functions inherited from kjb::Readable
virtual ~Readable ()
 Deletes this Readable. More...
 
virtual void read (const char *fname)
 Reads this Readable from a file. More...
 
- Public Member Functions inherited from kjb::Writeable
virtual ~Writeable ()
 Deletes this Writeable. More...
 

Static Public Member Functions

static int get_num_edges ()
 
static void get_edge_indexes (std::vector< int > &base_edge_indexes, std::vector< int > &vertical_edge_indexes, std::vector< int > &top_edge_indexes)
 
- Static Public Member Functions inherited from kjb::Abstract_renderable
static double get_rendering_framework ()
 returns the rendering framework used to render. The only one implemented up to now is OpenGL More...
 
static void set_rendering_framework (unsigned int irf)
 sets the rendering framework used to render. The only one implemented up to now is OpenGL More...
 
- Static Public Member Functions inherited from kjb::Readable
static const char * read_field_value (std::istream &in, const char *field_name, char *field_buf, size_t buf_len, char separator=':')
 Reads a line off in into a buffer and returns a pointer to the field value in the buffer. More...
 
static const char * read_field_value (std::istream &in, const char *field_name, char separator=':')
 Reads a line off in into an internal buffer and returns a pointer to the field value in the buffer. More...
 

Protected Attributes

std::vector< kjb::Vectorpoints
 Points defining this parapiped. More...
 
kjb::Vector center
 Center of this parallelepiped. More...
 
- Protected Attributes inherited from kjb::Polymesh
std::vector< kjb::Polygon_faces
 Polygons defining the mesh. More...
 
Vector smallest_bounds
 
Vector largest_bounds
 

Additional Inherited Members

- Protected Types inherited from kjb::Abstract_renderable
enum  Rendering_frameworks { RI_OPENGL }
 
- Protected Member Functions inherited from kjb::Polymesh
bool is_same_vertex (const kjb::Vector &p1, const kjb::Vector &p2) const
 Compares two points. More...
 
bool is_shared_edge (const Polygon &f1, unsigned int e1, const Polygon &f2, unsigned int e2) const throw (Index_out_of_bounds)
 Checks whether edge e1 on face f1 is the same as edge e2 on face f2. More...
 
bool edge_index_in_polygon (const Polygon &f1, unsigned int e, const Polygon &f2, unsigned int &index) throw (Index_out_of_bounds)
 
- Static Protected Attributes inherited from kjb::Abstract_renderable
static unsigned int _rendering_framework = kjb::Abstract_renderable::RI_OPENGL
 

Detailed Description

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

Constructor & Destructor Documentation

Parapiped::Parapiped ( double  x1,
double  y1,
double  z1,
double  x2,
double  y2,
double  z2,
double  x3,
double  y3,
double  z3,
double  x4,
double  y4,
double  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.
Parapiped::Parapiped ( const kjb::Vector p1,
const kjb::Vector p2,
const kjb::Vector p3,
const kjb::Vector p4 
)
throw (kjb::Illegal_argument
)

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
kjb::Illegal_argumentThe vectors are not 3D.
Parapiped::Parapiped ( const Parapiped p)

Constructs a parallelepiped by copying another.

Parameters
pParallelepiped to copy into this one.
Parapiped::Parapiped ( const char *  fname)
throw (kjb::Illegal_argument,
kjb::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
kjb::IO_errorCould not read from in.
kjb::Illegal_argumentInvalid arguments in file to read from.
Parapiped::Parapiped ( std::istream &  in)
throw (kjb::Illegal_argument,
kjb::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
kjb::IO_errorCould not read from in.
kjb::Illegal_argumentInvalid arguments in file to read from.
virtual kjb::Parapiped::~Parapiped ( )
inlinevirtual

Deletes this parallelepiped.

Member Function Documentation

void Parapiped::add_face ( const Polygon face)
throw (kjb::Illegal_argument
)
virtual

Adds a face to this parapiped -> Not implemented here, it will throw an exception, because the use of this method will violate the constraints defining this parapiped.

Adds a face to this parapiped -> Not implemented here, it will throw an exception, because the use of this method will violate the constraints defining this parapiped

Parameters
faceThe face to be added

Reimplemented from kjb::Polymesh.

unsigned int Parapiped::adjacent_face ( unsigned int  f,
unsigned int  e 
) const
throw (Index_out_of_bounds,
KJB_error
)
virtual

returns the index of the face adjacent to face f along edge e This is an efficient implementation to be used only in the context of the parallelepiped

Parameters
fwe want to find the face adjacent to this face f along edge e
ethe edge along which to look for the adjacent face
Returns
the index of the face adjacent to face f along edge e

This is an efficient implementation to be used only in the context of the parallelepiped

Reimplemented from kjb::Polymesh.

Parapiped * Parapiped::clone ( ) const
virtual

Clones this parallelepiped.

Returns
A new copy of this parallelepiped.

Reimplemented from kjb::Polymesh.

void Parapiped::draw_CMU_orientation_map ( ) const
void Parapiped::draw_geometric_context_map ( ) const
void Parapiped::draw_left_right_orientation_map ( ) const
void Parapiped::draw_orientation_map ( ) const
const kjb::Vector & Parapiped::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.

static void kjb::Parapiped::get_edge_indexes ( std::vector< int > &  base_edge_indexes,
std::vector< int > &  vertical_edge_indexes,
std::vector< int > &  top_edge_indexes 
)
inlinestatic
static int kjb::Parapiped::get_num_edges ( )
inlinestatic
const kjb::Vector & Parapiped::get_point ( size_t  i) const
throw (kjb::Illegal_argument
)

Returns an indexed point defining this parapiped.

Returns
The ith point of this parapiped using the convention described in the constructor
Parameters
ithe index of the point to be returned
Parapiped & Parapiped::operator= ( const Parapiped 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.
void Parapiped::read ( std::istream &  in)
throw (kjb::IO_error,
kjb::Illegal_argument
)
virtual

Reads this parallelepiped from an input stream.

Parameters
inInput stream to read the members of this parallelepiped from.
Exceptions
kjb::IO_errorCould not read from in.
kjb::Illegal_argumentInvalid argument to read from file.

Reimplemented from kjb::Polymesh.

void Parapiped::set_points ( double  x1,
double  y1,
double  z1,
double  x2,
double  y2,
double  z2,
double  x3,
double  y3,
double  z3,
double  x4,
double  y4,
double  z4 
)

reset the points of this parapiped

Resets the points of this parapiped

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.
void Parapiped::transform ( const kjb::Matrix M)
throw (kjb::Illegal_argument
)
virtual

Transforms this parallelepiped.

Parameters
MHomogeneous transformation matrix to transform this parallelepiped by.
Exceptions
kjb::Illegal_argumentThe matrix is not in 4x4 homogeneous coordinates.

Reimplemented from kjb::Polymesh.

void Parapiped::write ( std::ostream &  out) const
throw (kjb::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
kjb::IO_errorCould not write to out.

Reimplemented from kjb::Polymesh.

Member Data Documentation

kjb::Vector kjb::Parapiped::center
protected

Center of this parallelepiped.

Calculated as the average of the face centroids.

std::vector<kjb::Vector > kjb::Parapiped::points
protected

Points defining this parapiped.


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