glc_point.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00026
00027 #include "glc_point.h"
00028 #include "../glc_openglexception.h"
00029
00030 using namespace glc;
00032
00034
00035
00036 GLC_Point::GLC_Point(const GLC_Point3d &setCoord)
00037 :GLC_Geometry("Point", true), m_Coordinate(setCoord)
00038 {
00039
00040 }
00042 GLC_Point::GLC_Point(double x, double y, double z)
00043 :GLC_Geometry("Point", true), m_Coordinate(x, y, z)
00044 {
00045 }
00046
00048
00050
00051
00052 GLC_Point3d GLC_Point::coordinate(void) const
00053 {
00054 return m_Coordinate;
00055 }
00056
00057
00058 const GLC_BoundingBox& GLC_Point::boundingBox(void)
00059 {
00060
00061 if (NULL == m_pBoundingBox)
00062 {
00063 m_pBoundingBox= new GLC_BoundingBox();
00064 const double delta= 1e-2;
00065 GLC_Point3d lower(m_Coordinate.x() - delta,
00066 m_Coordinate.y() - delta,
00067 m_Coordinate.z() - delta);
00068 GLC_Point3d upper(m_Coordinate.x() + delta,
00069 m_Coordinate.y() + delta,
00070 m_Coordinate.z() + delta);
00071 m_pBoundingBox->combine(lower);
00072 m_pBoundingBox->combine(upper);
00073 }
00074 return *m_pBoundingBox;
00075 }
00076
00077
00078 GLC_Geometry* GLC_Point::clone() const
00079 {
00080 return new GLC_Point(*this);
00081 }
00082
00084
00086
00087
00088 void GLC_Point::setCoordinate(const GLC_Point3d &point)
00089 {
00090 m_Coordinate= point;
00091 }
00092
00093 void GLC_Point::setCoordinate(double x, double y, double z)
00094 {
00095 m_Coordinate.setVect(x, y, z);
00096 }
00097
00099
00101
00102 void GLC_Point::glDraw(const GLC_RenderProperties&)
00103 {
00104
00105 glBegin(GL_POINTS);
00106 glVertex3dv(m_Coordinate.data());
00107 glEnd();
00108
00109
00110 GLenum error= glGetError();
00111 if (error != GL_NO_ERROR)
00112 {
00113 GLC_OpenGlException OpenGlException("GLC_Point::GlDraw ", error);
00114 throw(OpenGlException);
00115 }
00116 }
00117