123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- #include "draw_point.h"
- #include "../opengl/OpenGL_convenience.h"
- #include <cassert>
- #include <cmath>
- IGL_INLINE void igl::opengl2::draw_point(
- const double x,
- const double y,
- const double z,
- const double requested_r,
- const bool selected)
- {
-
- glPushAttrib(GL_ENABLE_BIT | GL_LIGHTING_BIT);
- float f;
- glGetFloatv(GL_POINT_SIZE_MAX,&f);
-
-
-
- double r = (requested_r<0.5*f?requested_r:0.5*f);
-
- glDisable(GL_LIGHTING);
-
- float color[4];
- glGetFloatv(GL_CURRENT_COLOR,color);
- double outline_size = (r>7 ? sqrt(r/7.0) : 1.0);
-
- glColor4f(1,1,1,color[3]);
- glPointSize(2*r);
- glBegin(GL_POINTS);
- glVertex3d(x,y,z);
- glEnd();
-
- glColor4f(0,0,0,color[3]);
- glPointSize(2*r-2*outline_size);
- glBegin(GL_POINTS);
- glVertex3d(x,y,z);
- glEnd();
-
-
- glColor4fv(color);
- glPointSize(2*r-4*outline_size);
- glBegin(GL_POINTS);
- glVertex3d(x,y,z);
- glEnd();
-
- if(selected)
- {
- glColor4f(0,0,0,color[3]);
- double selected_size = 2*r-7*outline_size;
- selected_size = (selected_size>3?selected_size:3);
- glPointSize(selected_size);
- glBegin(GL_POINTS);
- glVertex3d(x,y,z);
- glEnd();
- }
-
- glColor4fv(color);
-
- glPopAttrib();
- }
- template <typename DerivedP>
- IGL_INLINE void igl::opengl2::draw_point(
- const Eigen::PlainObjectBase<DerivedP> & P,
- const double requested_r,
- const bool selected)
- {
- switch(P.size())
- {
- case 2:
- return draw_point(P(0),P(1),0,requested_r,selected);
- default:
- return draw_point(P(0),P(1),P(2),requested_r,selected);
- }
- }
- #ifdef IGL_STATIC_LIBRARY
- template void igl::opengl2::draw_point<Eigen::Matrix<double, 3, 1, 0, 3, 1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, 3, 1, 0, 3, 1> > const&, double, bool);
- template void igl::opengl2::draw_point<Eigen::Matrix<double, 2, 1, 0, 2, 1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, 2, 1, 0, 2, 1> > const&, double, bool);
- #endif
|