JWS C++ Library
C++ language utility library
|
Parallelepiped: a hexahedron of which each face is a parallelegram. More...
#include <parapiped.h>
Public Member Functions | |
Parapiped_d (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. | |
Parapiped_d (const jwsc::Vector_d *p1, const jwsc::Vector_d *p2, const jwsc::Vector_d *p3, const jwsc::Vector_d *p4) throw (jwscxx::base::Arg_error) | |
Constructs a parallelepiped. | |
Parapiped_d (const Parapiped_d &p) | |
Constructs a parallelepiped by copying another. | |
Parapiped_d (const char *fname) throw (jwscxx::base::Arg_error, jwscxx::base::IO_error) | |
Reads a parallelepiped from an input file. | |
Parapiped_d (std::istream &in) throw (jwscxx::base::Arg_error, jwscxx::base::IO_error) | |
Reads a parallelepiped from an input stream. | |
virtual | ~Parapiped_d () |
Deletes this parallelepiped. | |
virtual Parapiped_d & | operator= (const Parapiped_d &p) |
Copies a parallelepiped into this one. | |
virtual Parapiped_d * | clone () const |
Clones this parallelepiped. | |
size_t | num_faces () const |
Returns the number of faces in this parallelepiped. | |
const jwsc::Vector_d * | get_point (size_t i) const throw (jwscxx::base::Arg_error) |
Returns an indexed point defining this parapiped. | |
const jwsc::Vector_d * | get_center () const |
Returns the center vector for this parallelepiped. | |
const jwscxx::graphics::Polygon_d * | get_face (size_t i) const throw (jwscxx::base::Arg_error) |
Returns an indexed parapiped face. | |
const std::vector< const jwscxx::graphics::Polygon_d * > & | 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_d *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_d * > | faces |
Polygons defining the parallelepiped. | |
std::vector< jwsc::Vector_d * > | points |
Points defining this parapiped. | |
jwsc::Vector_d * | center |
Center of this parallelepiped. | |
jwsc::Matrix_u32 * | adjacency |
Face adjacency matrix. |
Parallelepiped: a hexahedron of which each face is a parallelegram.
Definition at line 234 of file parapiped.h.
Parapiped_d::Parapiped_d | ( | 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
x1 | X-coord of the point 1. |
y1 | Y-coord of the point 1. |
z1 | Z-coord of the point 1. |
x2 | X-coord of the point 2. |
y2 | Y-coord of the point 2. |
z2 | Z-coord of the point 2. |
x3 | X-coord of the point 3. |
y3 | Y-coord of the point 3. |
z3 | Z-coord of the point 3. |
x4 | X-coord of the point 4. |
y4 | Y-coord of the point 4. |
z4 | Z-coord of the point 4. |
Definition at line 871 of file parapiped.cpp.
Parapiped_d::Parapiped_d | ( | const jwsc::Vector_d * | p1, |
const jwsc::Vector_d * | p2, | ||
const jwsc::Vector_d * | p3, | ||
const jwsc::Vector_d * | 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
p1 | Point 1. |
p2 | Point 2. |
p3 | Point 3. |
p4 | Point 4. |
jwscxx::base::Arg_error | The vectors are not 3D. |
Definition at line 998 of file parapiped.cpp.
Parapiped_d::Parapiped_d | ( | const Parapiped_d & | p | ) |
Constructs a parallelepiped by copying another.
p | Parallelepiped to copy into this one. |
Definition at line 1100 of file parapiped.cpp.
Parapiped_d::Parapiped_d | ( | 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.
fname | Input file to read this parallelepiped from. |
jwscxx::base::IO_error | Could not read from in. |
jwscxx::base::Arg_error | Invalid arguments in file to read from. |
Definition at line 1129 of file parapiped.cpp.
Parapiped_d::Parapiped_d | ( | 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.
in | Input stream to read this parallelepiped from. |
jwscxx::base::IO_error | Could not read from in. |
jwscxx::base::Arg_error | Invalid arguments in file to read from. |
Definition at line 1148 of file parapiped.cpp.
Parapiped_d::~Parapiped_d | ( | ) | [virtual] |
Deletes this parallelepiped.
Frees all space allocated by this parallelepiped.
Definition at line 1160 of file parapiped.cpp.
Parapiped_d & Parapiped_d::operator= | ( | const Parapiped_d & | p | ) | [virtual] |
Copies a parallelepiped into this one.
Performs a deep copy of the faces in the parallelepiped.
p | Parallelepiped to copy into this one. |
Definition at line 1184 of file parapiped.cpp.
Parapiped_d * Parapiped_d::clone | ( | ) | const [virtual] |
Clones this parallelepiped.
Implements jwscxx::base::Cloneable.
Reimplemented in jwscxx::graphics::Cuboid_d.
Definition at line 1208 of file parapiped.cpp.
size_t Parapiped_d::num_faces | ( | ) | const [virtual] |
Returns the number of faces in this parallelepiped.
Implements jwscxx::graphics::Polymesh_d.
Definition at line 1214 of file parapiped.cpp.
const jwsc::Vector_d * Parapiped_d::get_point | ( | size_t | i | ) | const throw (jwscxx::base::Arg_error) |
Returns an indexed point defining this parapiped.
Definition at line 1220 of file parapiped.cpp.
const jwsc::Vector_d * Parapiped_d::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 1236 of file parapiped.cpp.
const jwscxx::graphics::Polygon_d * Parapiped_d::get_face | ( | size_t | i | ) | const throw (jwscxx::base::Arg_error) [virtual] |
Returns an indexed parapiped face.
i | Index of the face to get; ranges 0 to 5. |
jwscxx::base::Arg_error | Invalid face index. |
Implements jwscxx::graphics::Polymesh_d.
Definition at line 1249 of file parapiped.cpp.
const std::vector< const jwscxx::graphics::Polygon_d * > & Parapiped_d::get_faces | ( | ) | const |
Returns the faces of this parapiped.
Definition at line 1262 of file parapiped.cpp.
void Parapiped_d::set_face_id | ( | size_t | i, |
uint32_t | id | ||
) | throw (jwscxx::base::Arg_error) |
Sets the id of a face in the parapiped.
i | Face index; ranges 0 to 5. |
id | Id to set the face with. |
jwscxx::base::Arg_error | Invalid face index. |
Definition at line 1276 of file parapiped.cpp.
void Parapiped_d::read | ( | std::istream & | in | ) | throw (jwscxx::base::IO_error, jwscxx::base::Arg_error) [virtual] |
Reads this parallelepiped from an input stream.
in | Input stream to read the members of this parallelepiped from. |
jwscxx::base::IO_error | Could not read from in. |
jwscxx::base::Arg_error | Invalid argument to read from file. |
Implements jwscxx::base::Readable.
Definition at line 1294 of file parapiped.cpp.
void Parapiped_d::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.
out | Output stream to write the members of this parallelepiped to. |
jwscxx::base::IO_error | Could not write to out. |
Implements jwscxx::base::Writeable.
Definition at line 1370 of file parapiped.cpp.
void Parapiped_d::transform | ( | const jwsc::Matrix_d * | M | ) | throw (jwscxx::base::Arg_error) [virtual] |
Applies a linear transformation to this parallelepiped.
M | Homogeneous transformation matrix to transform this parallelepiped by. |
jwscxx::base::Arg_error | The matrix is not in 4x4 homogeneous coordinates. |
Implements jwscxx::graphics::Transformable_d.
Definition at line 1435 of file parapiped.cpp.
void Parapiped_d::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 1454 of file parapiped.cpp.
void Parapiped_d::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 1469 of file parapiped.cpp.
void Parapiped_d::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 1479 of file parapiped.cpp.
void Parapiped_d::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 1495 of file parapiped.cpp.
uint32_t Parapiped_d::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.
i | Face index to get the adjacent face of. |
p | First point index in face of the shared edge. If set to 3, the other point forming the edge will be 0. |
jwscxx::base::Arg_error | If i or p are not valid indices. |
Implements jwscxx::graphics::Polymesh_d.
Definition at line 1514 of file parapiped.cpp.
std::vector<jwscxx::graphics::Polygon_d*> jwscxx::graphics::Parapiped_d::faces [protected] |
Polygons defining the parallelepiped.
Definition at line 362 of file parapiped.h.
std::vector<jwsc::Vector_d*> jwscxx::graphics::Parapiped_d::points [protected] |
Points defining this parapiped.
Definition at line 365 of file parapiped.h.
jwsc::Vector_d* jwscxx::graphics::Parapiped_d::center [protected] |
Center of this parallelepiped.
Calculated as the average of the face centroids.
Definition at line 372 of file parapiped.h.
jwsc::Matrix_u32* jwscxx::graphics::Parapiped_d::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 380 of file parapiped.h.