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
00024
00025 #include "glc_point.h"
00026 #include "../glc_openglexception.h"
00027
00028 using namespace glc;
00030
00032
00033
00034 GLC_Point::GLC_Point(const GLC_Point3d &setCoord)
00035 :GLC_Geometry("Point", true)
00036 , m_Coordinate(setCoord)
00037 , m_Size(1.0f)
00038 {
00039
00040 }
00042 GLC_Point::GLC_Point(double x, double y, double z)
00043 :GLC_Geometry("Point", true)
00044 , m_Coordinate(x, y, z)
00045 , m_Size(1.0f)
00046 {
00047 }
00048
00050
00052
00053
00054 GLC_Point3d GLC_Point::coordinate(void) const
00055 {
00056 return m_Coordinate;
00057 }
00058
00059
00060 const GLC_BoundingBox& GLC_Point::boundingBox(void)
00061 {
00062
00063 if (NULL == m_pBoundingBox)
00064 {
00065 m_pBoundingBox= new GLC_BoundingBox();
00066 const double delta= 1e-2;
00067 GLC_Point3d lower(m_Coordinate.x() - delta,
00068 m_Coordinate.y() - delta,
00069 m_Coordinate.z() - delta);
00070 GLC_Point3d upper(m_Coordinate.x() + delta,
00071 m_Coordinate.y() + delta,
00072 m_Coordinate.z() + delta);
00073 m_pBoundingBox->combine(lower);
00074 m_pBoundingBox->combine(upper);
00075 }
00076 return *m_pBoundingBox;
00077 }
00078
00079
00080 GLC_Geometry* GLC_Point::clone() const
00081 {
00082 return new GLC_Point(*this);
00083 }
00084
00086
00088
00089
00090 void GLC_Point::setCoordinate(const GLC_Point3d &point)
00091 {
00092 m_Coordinate= point;
00093 }
00094
00095 void GLC_Point::setCoordinate(double x, double y, double z)
00096 {
00097 m_Coordinate.setVect(x, y, z);
00098 }
00099
00101
00103
00104 void GLC_Point::glDraw(const GLC_RenderProperties&)
00105 {
00106 glPointSize(m_Size);
00107
00108 glBegin(GL_POINTS);
00109 glVertex3dv(m_Coordinate.data());
00110 glEnd();
00111 glPointSize(1.0f);
00112
00113
00114 GLenum error= glGetError();
00115 if (error != GL_NO_ERROR)
00116 {
00117 GLC_OpenGlException OpenGlException("GLC_Point::GlDraw ", error);
00118 throw(OpenGlException);
00119 }
00120 }
00121