KJB
|
frustum: a polyhedron of which each torso face is a trapezoid and the top and bottom surfaces are polygons. More...
#include <gr_parametric_frustum.h>
Public Member Functions | |
Frustum (unsigned int inv, double ix, double iy, double iz, double iw, double il, double iratio_top_bottom, double ih, double ipitch, double iyaw, double iroll) | |
Constructs a frustum. More... | |
Frustum (const std::vector< kjb::Vector > &p) throw (kjb::Illegal_argument) | |
Constructs a. More... | |
Frustum (const Frustum &p) | |
Constructs a frustum by copying another. More... | |
Frustum (const char *fname, unsigned int inv) throw (kjb::Illegal_argument, kjb::IO_error) | |
Reads a frustum from an input file. More... | |
Frustum (std::istream &in, unsigned int inv) throw (kjb::Illegal_argument, kjb::IO_error) | |
Reads a frustum from an input stream. More... | |
virtual | ~Frustum () |
Deletes this frustum. More... | |
virtual Frustum & | operator= (const Frustum &p) |
Copies a frustum into this one. More... | |
virtual Frustum * | clone () const |
Clones this frustum. More... | |
virtual void | transform (const kjb::Matrix &M) throw (kjb::Illegal_argument) |
Transforms this frustum. More... | |
const kjb::Vector & | get_point (size_t i) const throw (kjb::Illegal_argument) |
Returns an indexed point defining this Frustum. More... | |
const kjb::Vector & | get_center () const |
Returns the center vector for this frustum. More... | |
virtual void | add_face (const Polygon &face) throw (kjb::Illegal_argument) |
Adds a face to this Frustum -> Not implemented here, it will throw an exception, because the use of this method will violate the constraints defining this Frustum. More... | |
virtual void | read (std::istream &in) throw (kjb::IO_error, kjb::Illegal_argument) |
Reads this frustum from an input stream. More... | |
virtual void | write (std::ostream &out) const throw (kjb::IO_error) |
Writes this frustum to an output stream. More... | |
void | set_points (unsigned int inv, double ix, double iy, double iz, double iw, double il, double iratio_top_bottom, double ih) |
reset the points of this Frustum 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 frustum More... | |
void | draw_orientation_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 Polymesh & | operator= (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::Polygon & | get_face (unsigned int i) const throw (kjb::Index_out_of_bounds) |
Returns an indexed face. More... | |
kjb::Polygon & | get_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_object & | operator= (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 Matrix & | get_rotations () const |
Returns the current transformation matrix, that is used to store the rotation to be applied to the object. More... | |
const Vector & | get_euler_angles () const |
returns vector [pitch, yaw, roll] More... | |
void | set_rotation_mode (kjb::Quaternion::Euler_mode imode) |
const kjb::Quaternion & | get_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 (int num_facets) |
static int | get_edge_indexes (std::vector< int > &base_edge_indexes, std::vector< int > &vertical_edge_indexes, std::vector< int > &top_edge_indexes, int num_facets) |
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 | |
unsigned int | nv |
number of vertices for the top(bottom) surface. More... | |
std::vector< kjb::Vector > | points |
Points defining this Frustum. More... | |
kjb::Vector | center |
Center of this frustum. 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 |
frustum: a polyhedron of which each torso face is a trapezoid and the top and bottom surfaces are polygons.
Frustum::Frustum | ( | unsigned int | inv, |
double | ix, | ||
double | iy, | ||
double | iz, | ||
double | iw, | ||
double | il, | ||
double | iratio_top_bottom, | ||
double | ih, | ||
double | ipitch, | ||
double | iyaw, | ||
double | iroll | ||
) |
Constructs a frustum.
The mapping from the input center point together with the height, top radius and bottom radius to the defined frustum
Upon initialization, the top face and the bottom face are parallel to the xz-planes. Each of these two faces has nv vertices, indexed by 0:nv-1 and nv:2nv-1, respectively. The vertices are placed in the clockwise order, while the 0-th vertice is placed on the +x axis.
The torso faces are formed by connecting the i-th vertice to the (i+nv)-th vertice, i belongs to 0:nv-1. Each torso face has 4 vertices, which are (i, (i+1)nv, (i+1)nv+nv, i+nv).
The indexes of the faces:
nv | number of vertices of the top surface. |
ix | X-coord of the center point. |
iy | Y-coord of the center point. |
iz | Z-coord of the center point. |
iw | diameter of the bottom face along the x-axis. |
il | diameter of the bottom face along the z-axis. |
iratio_top_bottom | ratio of the diameters of the top and bottom face |
ih | height of the frustum. |
ipitch | pitch angle. |
iyaw | yaw angle. |
iroll | roll angle. |
Frustum::Frustum | ( | const std::vector< kjb::Vector > & | p | ) | |
throw | ( | kjb::Illegal_argument | |||
) |
Constructs a.
The mapping from 2*nv points to the defined parallelepiped, while those points should come from the vertices of a frustum
p | the vector of vertices. |
kjb::Illegal_argument | The vectors are not 3D. |
Frustum::Frustum | ( | const Frustum & | p | ) |
Constructs a frustum by copying another.
p | Frustum to copy into this one. |
Frustum::Frustum | ( | const char * | fname, |
unsigned int | inv | ||
) | |||
throw | ( | kjb::Illegal_argument, | |
kjb::IO_error | |||
) |
Reads a frustum from an input file.
The file format is big-endian binary.
fname | Input file to read this parallelepiped from. |
kjb::IO_error | Could not read from in. |
kjb::Illegal_argument | Invalid arguments in file to read from. |
Frustum::Frustum | ( | std::istream & | in, |
unsigned int | inv | ||
) | |||
throw | ( | kjb::Illegal_argument, | |
kjb::IO_error | |||
) |
Reads a frustum from an input stream.
The file format is big-endian binary.
in | Input stream to read this parallelepiped from. |
kjb::IO_error | Could not read from in. |
kjb::Illegal_argument | Invalid arguments in file to read from. |
|
inlinevirtual |
Deletes this frustum.
|
virtual |
Adds a face to this Frustum -> Not implemented here, it will throw an exception, because the use of this method will violate the constraints defining this Frustum.
Adds a face to this frustum -> Not implemented here, it will throw an exception, because the use of this method will violate the constraints defining this frustum
face | The face to be added |
Reimplemented from kjb::Polymesh.
|
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 frustum
f | we want to find the face adjacent to this face f along edge e |
e | the edge along which to look for the adjacent face |
This is an efficient implementation to be used only in the context of the parallelepiped
Reimplemented from kjb::Polymesh.
|
virtual |
void kjb::Frustum::draw_orientation_map | ( | ) | const |
const kjb::Vector & Frustum::get_center | ( | ) | const |
Returns the center vector for this frustum.
The vector is in homogeneous coordinates x, y, z, w. The coordinate w is always 1.
|
inlinestatic |
|
inlinestatic |
const kjb::Vector & Frustum::get_point | ( | size_t | i | ) | const |
throw | ( | kjb::Illegal_argument | |||
) |
Returns an indexed point defining this Frustum.
i | the index of the point to be returned |
Copies a frustum into this one.
Performs a deep copy of the faces in the parallelepiped.
p | Parallelepiped to copy into this one. |
|
virtual |
Reads this frustum from an input stream.
in | Input stream to read the members of this frustum from. |
kjb::IO_error | Could not read from in. |
kjb::Illegal_argument | Invalid argument to read from file. |
Reimplemented from kjb::Polymesh.
void Frustum::set_points | ( | unsigned int | inv, |
double | ix, | ||
double | iy, | ||
double | iz, | ||
double | iw, | ||
double | il, | ||
double | iratio_top_bottom, | ||
double | ih | ||
) |
reset the points of this Frustum
Resets the points of this frustum
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. |
|
virtual |
Transforms this frustum.
M | Homogeneous transformation matrix to transform this frustum by. |
kjb::Illegal_argument | The matrix is not in 4x4 homogeneous coordinates. |
Reimplemented from kjb::Polymesh.
|
virtual |
Writes this frustum to an output stream.
The file format is big-endian binary.
out | Output stream to write the members of this parallelepiped to. |
kjb::IO_error | Could not write to out. |
Reimplemented from kjb::Polymesh.
|
protected |
Center of this frustum.
Calculated as the average of the face centroids.
|
protected |
number of vertices for the top(bottom) surface.
|
protected |
Points defining this Frustum.