KJB
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
st_draw_shape.h
Go to the documentation of this file.
1 /* $Id: st_draw_shape.h 18278 2014-11-25 01:42:10Z ksimek $ */
35 /* =========================================================================== *
36 |
37 | Copyright (c) 1994-2008 by Kobus Barnard (author).
38 |
39 | Personal and educational use of this code is granted, provided that this
40 | header is kept intact, and that the authorship is not misrepresented, that
41 | its use is acknowledged in publications, and relevant papers are cited.
42 |
43 | For other use contact the author (kobus AT cs DOT arizona DOT edu).
44 |
45 | Please note that the code in this file has not necessarily been adequately
46 | tested. Naturally, there is no guarantee of performance, support, or fitness
47 | for any particular task. Nonetheless, I am interested in hearing about
48 | problems that you encounter.
49 |
50 | Authors:
51 | Emily Hartley
52 |
53 * =========================================================================== */
54 
55 #ifndef KJB_DRAW_SHAPE_H
56 #define KJB_DRAW_SHAPE_H
57 
58 #include <m_cpp/m_vector.h>
59 #include <gr_cpp/gr_opengl.h>
61 #include <gr_cpp/gr_camera.h>
62 #include <gr_cpp/gr_polymesh.h>
64 #include <g_cpp/g_cylinder.h>
66 
67 #define rad_to_deg 57.2957795
68 // rad_to_deg = 180.0 / M_PI;
69 
70 namespace kjb {
71 
76 int draw_cylinder(GLUquadricObj* myQuadric, const Vector& p1, const Vector& p2, double r);
77 
78 int draw_cylinder(Perspective_camera& c, GLUquadricObj* myQuadric, const Vector& p1, const Vector& p2, double r);
79 
80 int draw_cylinder(GLUquadricObj* myQuadric, const Cylinder cyl);
81 
82 int draw_cylinder(Perspective_camera& c, GLUquadricObj* myQuadric, const std::vector<Cylinder> cylinders);
83 
87 int draw_cylinder_section(GLUquadricObj* myQuadric, const Vector& p1, const Vector& p2, double radius, double angle, const Vector& angle_startpt, const Vector& angle_endpt, GLuint& MY_CLIP_PLANE, GLuint& MY_CLIP_PLANE1);
88 
89 int draw_cylinder_section(Perspective_camera& c, GLUquadricObj* myQuadric, const std::vector<Cylinder_section> cylinders);
90 
91 
92 // Perspective_camera_gl_interface
93 
94 
95 void compute_cylinder_rotation_angles(const Vector& p1, const Vector& p2, Vector& top, Vector& bottom, double& magnitude, double& angle_y, double& angle_x);
96 
97 void draw_translated_and_rotated_cylinder(GLUquadricObj* myQuadric, const Vector& bottom, const double angle_y, const double angle_x, const double radius, const double magnitude);
98 
100 
106 void build_cylinder(std::vector<Vector>& vlist, std::vector<Vector>& nlist, int facets, int ribs, float radius, float length);
107 
113 void build_frustum(std::vector<Vector>& vlist, std::vector<Vector>& nlist, int facets, int ribs, float radius_bottom, float radius_top, float length);
114 
115 /*
116  * @brief Transforms the vertices of a cylinder on the +z-axis and with a base centered at the
117  * origin back to their real-world position.
118  */
119 void untransform_points(std::vector<Vector>& vlist, const Vector& bottom, const double angle_y, const double angle_x, std::vector<Vector>& vlist_tr);
120 
121 /*
122  * @brief Draws the top and bottom circles and the outermost edges of the body (with respect to
123  * the camera position) of the cylinder.
124  */
125 void draw_cylinder_edges(std::vector<Vector>& vlist, int facets, int ribs, const Vector& bottom, const double angle_y, const double angle_x, const Perspective_camera* camera);
126 
127 /*
128  * @brief Draws the edges for all of the facets of the cylinder.
129  */
130 void draw_cylinder_facets(std::vector<Vector>& vlist, int facets, int ribs);
131 
132 void render_cylinder_silhouette(const Polymesh* polymesh, const Perspective_camera* camera);
133 
134 void render_occlude_cylinder_silhouette(const Polymesh* polymesh, const Perspective_camera* camera);
135 
136 void render_frustum_silhouette(const Polymesh* polymesh, Perspective_camera* camera);
137 
138 void render_occlude_frustum_silhouette(const Polymesh* polymesh, Perspective_camera* camera);
139 
140 }
141 
142 #endif
void render_cylinder_silhouette(const Polymesh *polymesh, const Perspective_camera *camera)
Definition: st_draw_shape.cpp:908
void build_cylinder(std::vector< Vector > &vlist, std::vector< Vector > &nlist, int facets, int ribs, float radius, float length)
Creates a list of vertices for a cylinder with the given height and radius on the z-axis with the bot...
Definition: st_draw_shape.cpp:556
void draw_cylinder_facets(std::vector< Vector > &vlist, int facets, int ribs)
Definition: st_draw_shape.cpp:858
void render_frustum_silhouette(const Polymesh *polymesh, Perspective_camera *camera)
Definition: st_draw_shape.cpp:1074
void render_occlude_frustum_silhouette(const Polymesh *polymesh, Perspective_camera *camera)
Definition: st_draw_shape.cpp:1146
classes to interface camera models to opengl for rendering
void draw_cylinder_edges(std::vector< Vector > &vlist, int facets, int ribs, const Vector &bottom, const double angle_y, const double angle_x, const Perspective_camera *camera)
Definition: st_draw_shape.cpp:755
int draw_cylinder_section(GLUquadricObj *myQuadric, const Vector &p1, const Vector &p2, double radius, double angle, const Vector &angle_startpt, const Vector &angle_endpt, GLuint &MY_CLIP_PLANE, GLuint &MY_CLIP_PLANE1)
Uses opengl to draw a cylinder section.
Definition: st_draw_shape.cpp:272
r
Definition: APPgetLargeConnectedEdges.m:127
void draw_translated_and_rotated_cylinder(GLUquadricObj *myQuadric, const Vector &bottom, const double angle_y, const double angle_x, const double radius, const double magnitude)
Definition: st_draw_shape.cpp:148
size_t length(const C &cner)
Counts the total number of elements in a 2D STL-style container.
Definition: l_util.h:17
void compute_cylinder_rotation_angles(const Vector &p1, const Vector &p2, Vector &top, Vector &bottom, double &magnitude, double &angle_y, double &angle_x)
Definition: st_draw_shape.cpp:76
Abstract class of connected polygons (faces) forming a mesh.
void untransform_points(std::vector< Vector > &vlist, const Vector &bottom, const double angle_y, const double angle_x, std::vector< Vector > &vlist_tr)
Definition: st_draw_shape.cpp:655
int GLuint
Definition: gr_opengl_headers.h:64
Cylinder_section: a section of a geometric cylinder.
void build_frustum(std::vector< Vector > &vlist, std::vector< Vector > &nlist, int facets, int ribs, float radius_bottom, float radius_top, float length)
Creates a list of vertices for a frustum with the given height and radius of bottom and top faces on ...
Definition: st_draw_shape.cpp:601
void render_occlude_cylinder_silhouette(const Polymesh *polymesh, const Perspective_camera *camera)
Definition: st_draw_shape.cpp:982
Definition for the Vector class, a thin wrapper on the KJB Vector struct and its related functionalit...
int GLUquadricObj
Definition: gr_opengl_headers.h:63
int draw_cylinder(GLUquadricObj *myQuadric, const Vector &p1, const Vector &p2, double r)
Uses opengl to draw a cylinder with the given points as the centers of the top and bottom of the cyli...
Definition: st_draw_shape.cpp:182