15 #include <QGLPixelBuffer>
19 #include <OpenGL/glu.h>
28 static inline void glVertex3v(
const float* v) { glVertex3fv(v); }
29 static inline void glVertex3v(
const double* v) { glVertex3dv(v); }
33 glTranslatef(x, y, z);
35 static inline void glTranslate(
double x,
double y,
double z) {
36 glTranslated(x, y, z);
40 static inline void glScale(
float x,
float y,
float z) { glScalef(x, y, z); }
41 static inline void glScale(
double x,
double y,
double z) { glScaled(x, y, z); }
43 using namespace CVLib;
58 m_meshIsClosed(false) {
71 CVLib::GenericCloud* cloud,
72 CVLib::GenericMesh* mesh ,
74 if (!QGLPixelBuffer::hasOpenGLPbuffers())
return false;
81 unsigned size = W * H;
251 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
252 glDepthRange(2.0f *
ZTWIST, 1.0f);
255 glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
257 glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
265 glCullFace(GL_FRONT);
273 if (
m_meshIsClosed) glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
275 glDepthRange(0, 1.0f - 2.0f *
ZTWIST);
277 glGetDoublev(GL_MODELVIEW_MATRIX, MM);
279 glGetDoublev(GL_PROJECTION_MATRIX, MP);
281 glGetIntegerv(GL_VIEWPORT, VP);
288 for (
unsigned i = 0; i < nVert; ++i) {
292 gluProject(P->
x, P->
y, P->
z, MM, MP, VP, &tx, &ty, &tz);
294 int txi =
static_cast<int>(
floor(tx));
295 int tyi =
static_cast<int>(
floor(ty));
296 if (txi >= 0 && txi <
static_cast<int>(
m_width) && tyi >= 0 &&
298 int dec = txi + tyi *
static_cast<int>(
m_width);
304 const unsigned char* pix =
m_snapC + (dec << 2);
312 if (tz <
static_cast<double>(
m_snapZ[dec])) {
313 assert(i < visibilityCount.size());
314 ++visibilityCount[i];
constexpr double ZERO_TOLERANCE
Numerical threshold for considering a value as "zero".
constexpr PointCoordinateType PC_ONE
'1' as a PointCoordinateType value
float PointCoordinateType
Type of the coordinates of a (N-D) point.
filament::Texture::InternalFormat format
void openGLSnapshot(GLenum format, GLenum type, void *buffer)
static void glScale(float x, float y, float z)
static void glTranslate(float x, float y, float z)
static void glVertex3v(const float *v)
bool init(unsigned W, unsigned H, cloudViewer::GenericCloud *cloud, cloudViewer::GenericMesh *mesh=0, bool closedMesh=true)
Initialization.
void setViewDirection(const CCVector3 &V)
Set the viewing directions.
void associateToEntity(cloudViewer::GenericCloud *cloud, cloudViewer::GenericMesh *mesh=0)
PointCoordinateType m_zoom
unsigned m_height
Pixel buffer height (pixels)
float * m_snapZ
Depth buffer.
virtual ~PCVContext()
Destructor.
float m_viewMat[OPENGL_MATRIX_SIZE]
Current model view matrix.
QGLPixelBuffer * m_pixBuffer
cloudViewer::GenericCloud * m_vertices
Displayed entity (cloud or mesh vertices)
static const unsigned OPENGL_MATRIX_SIZE
Model view matrix size (OpenGL)
bool m_meshIsClosed
Whether displayed mesh is closed or not.
int GLAccumPixel(std::vector< int > &visibilityCount)
unsigned char * m_snapC
Color buffer.
PCVContext()
Default constructor.
unsigned m_width
Pixel buffer width (pixels)
cloudViewer::GenericMesh * m_mesh
Displayed entity (mesh - optional)
virtual void getBoundingBox(CCVector3 &bbMin, CCVector3 &bbMax)=0
Returns the cloud bounding box.
virtual void placeIteratorAtBeginning()=0
Sets the cloud iterator at the beginning.
virtual const CCVector3 * getNextPoint()=0
Returns the next point (relatively to the global iterator position)
virtual unsigned size() const =0
Returns the number of points.
MiniVec< float, N > floor(const MiniVec< float, N > &a)