58 static void NormalizeBufferCoordinates(GLint size, GLfloat * buffer, GLfloat MaxSize, GLfloat& zmin, GLfloat& zmax) ;
64 static void ComputeBufferBB(GLint size, GLfloat * buffer,
65 GLfloat & xmin, GLfloat & xmax,
66 GLfloat & ymin, GLfloat & ymax,
67 GLfloat & zmin, GLfloat & zmax) ;
70 static void print3DcolorVertex(GLint size, GLint * count, GLfloat * buffer) ;
71 static void debug_printBuffer(GLint size, GLfloat *buffer) ;
73 static void NormalizePrimitiveCoordinates(GLfloat * & loc,GLfloat MaxSize,GLfloat zmin,GLfloat zmax) ;
74 static void ComputePrimitiveBB( GLfloat * & loc,
75 GLfloat & xmin,GLfloat & xmax,
76 GLfloat & ymin,GLfloat & ymax,
77 GLfloat & zmin,GLfloat & zmax);
79 static const char *nameOfToken(
int token);
87 std::vector<PtrPrimitive>& primitive_tab,
95 nb_degenerated_lines = 0 ;
96 nb_degenerated_polys = 0 ;
97 nb_degenerated_points = 0 ;
110 #ifdef DEBUGEPSRENDER 111 printf(
"Buffer bounding box: %f %f %f %f %f %f\n",xmin,xmax,ymin,ymax,zmin,zmax) ;
113 float Zdepth = max(_ymax-_ymin,_xmax-_xmin) ;
117 GLfloat *end = buffer + size;
119 GLfloat *loc = buffer ;
121 int N = size/200 + 1 ;
125 token = int(0.5f + *loc) ;
128 if((end-loc)/N >= next_step)
129 vparams.
progress((end-loc)/(
float)size, QGLViewer::tr(
"Parsing feedback buffer.")), ++next_step ;
134 case GL_LINE_RESET_TOKEN:
141 nb_degenerated_lines++ ;
148 case GL_POLYGON_TOKEN:
150 nvertices = int(0.5f + *loc) ;
153 std::vector<Feedback3DColor> verts ;
155 for(
int i=0;i<nvertices;++i)
163 nb_degenerated_polys++ ;
173 primitive_tab.push_back(Pt);
176 nb_degenerated_points++ ;
205 return checkPoint(pp) ;
215 cout <<
"unexpected case: Polygon with " << P->
nbVertices() <<
" vertices !" << endl ;
233 return checkSegment(pp) ;
240 return checkPoint(pp) ;
258 printf(
"%4.2f ", buffer[size - (*count)]);
267 int token, nvertices;
271 token = int(buffer[size - count]);
275 case GL_PASS_THROUGH_TOKEN:
276 printf(
"GL_PASS_THROUGH_TOKEN\n");
277 printf(
" %4.2f\n", buffer[size - count]);
281 printf(
"GL_POINT_TOKEN\n");
282 print3DcolorVertex(size, &count, buffer);
285 printf(
"GL_LINE_TOKEN\n");
286 print3DcolorVertex(size, &count, buffer);
287 print3DcolorVertex(size, &count, buffer);
289 case GL_LINE_RESET_TOKEN:
290 printf(
"GL_LINE_RESET_TOKEN\n");
291 print3DcolorVertex(size, &count, buffer);
292 print3DcolorVertex(size, &count, buffer);
294 case GL_POLYGON_TOKEN:
295 printf(
"GL_POLYGON_TOKEN\n");
296 nvertices = int(buffer[size - count]) ;
298 for (; nvertices > 0; nvertices--)
299 print3DcolorVertex(size, &count, buffer);
315 case GL_LINE_RESET_TOKEN:
318 for (i = 0; i < 2; i++)
319 (loc+size*i)[2] = ((loc+size*i)[2] - zmin)/(zmax-zmin)*MaxSize ;
324 case GL_POLYGON_TOKEN:
326 nvertices = int(*loc) ;
329 for (i = 0; i < nvertices; i++)
330 (loc+size*i)[2] = ((loc+size*i)[2] - zmin)/(zmax-zmin)*MaxSize ;
332 loc += nvertices * size;
337 loc[2] = (loc[2] - zmin)/(zmax-zmin)*MaxSize ;
344 #ifdef DEBUGEPSRENDER 362 case GL_LINE_RESET_TOKEN:
365 for (i = 0; i < 2; i++)
369 if(f.
x() < xmin) xmin = GLfloat(f.
x()) ;
370 if(f.
y() < ymin) ymin = GLfloat(f.
y()) ;
371 if(f.
z() < zmin) zmin = GLfloat(f.
z()) ;
372 if(f.
x() > xmax) xmax = GLfloat(f.
x()) ;
373 if(f.
y() > ymax) ymax = GLfloat(f.
y()) ;
374 if(f.
z() > zmax) zmax = GLfloat(f.
z()) ;
381 case GL_POLYGON_TOKEN:
383 nvertices = int(*loc) ;
386 for (i = 0; i < nvertices; i++)
390 if(f.
x() < xmin) xmin = GLfloat(f.
x()) ;
391 if(f.
y() < ymin) ymin = GLfloat(f.
y()) ;
392 if(f.
z() < zmin) zmin = GLfloat(f.
z()) ;
393 if(f.
x() > xmax) xmax = GLfloat(f.
x()) ;
394 if(f.
y() > ymax) ymax = GLfloat(f.
y()) ;
395 if(f.
z() > zmax) zmax = GLfloat(f.
z()) ;
398 loc += nvertices * size;
406 if(f.
x() < xmin) xmin = GLfloat(f.
x()) ;
407 if(f.
y() < ymin) ymin = GLfloat(f.
y()) ;
408 if(f.
z() < zmin) zmin = GLfloat(f.
z()) ;
409 if(f.
x() > xmax) xmax = GLfloat(f.
x()) ;
410 if(f.
y() > ymax) ymax = GLfloat(f.
y()) ;
411 if(f.
z() > zmax) zmax = GLfloat(f.
z()) ;
419 #ifdef DEBUGEPSRENDER 420 printf(
"Incomplete implementation. Unexpected token (%d).\n", token);
432 #ifdef DEBUGEPSRENDER 433 printf(
"Warning: zmin = zmax in NormalizePrimitiveCoordinates\n") ;
442 NormalizePrimitiveCoordinates(loc,MaxSize,zmin,zmax);
449 GLfloat & xmin, GLfloat & xmax,
450 GLfloat & ymin, GLfloat & ymax,
451 GLfloat & zmin, GLfloat & zmax)
459 ComputePrimitiveBB(loc,xmin,xmax,ymin,ymax,zmin,zmax);
471 case GL_PASS_THROUGH_TOKEN:
return "GL_PASS_THROUGH_TOKEN" ;
472 case GL_POINT_TOKEN:
return "GL_POINT_TOKEN" ;
473 case GL_LINE_TOKEN:
return "GL_LINE_TOKEN" ;
474 case GL_POLYGON_TOKEN:
return "GL_POLYGON_TOKEN" ;
475 case GL_BITMAP_TOKEN:
return "GL_BITMAP_TOKEN" ;
476 case GL_DRAW_PIXEL_TOKEN:
return "GL_DRAW_PIXEL_TOKEN" ;
477 case GL_COPY_PIXEL_TOKEN:
return "GL_COPY_PIXEL_TOKEN" ;
478 case GL_LINE_RESET_TOKEN:
return "GL_LINE_RESET_TOKEN" ;
480 return "(Unidentified token)" ;
virtual unsigned int nbVertices() const
static const double EGALITY_EPS
static PtrPrimitive checkPolygon(Polygone *&P)
static PtrPrimitive checkSegment(Segment *&P)
static const char * nameOfToken(int token)
const float FLAT_POLYGON_EPS
static void ComputeBufferBB(GLint size, GLfloat *buffer, GLfloat &xmin, GLfloat &xmax, GLfloat &ymin, GLfloat &ymax, GLfloat &zmin, GLfloat &zmax)
static void NormalizePrimitiveCoordinates(GLfloat *&loc, GLfloat MaxSize, GLfloat zmin, GLfloat zmax)
virtual const Vector3 & vertex(int) const
virtual const Feedback3DColor & sommet3DColor(int) const
static void NormalizeBufferCoordinates(GLint size, GLfloat *buffer, GLfloat MaxSize, GLfloat &zmin, GLfloat &zmax)
void progress(float, const QString &)
static void debug_printBuffer(GLint size, GLfloat *buffer)
virtual const Vector3 & vertex(int) const
static void ComputePrimitiveBB(GLfloat *&loc, GLfloat &xmin, GLfloat &xmax, GLfloat &ymin, GLfloat &ymax, GLfloat &zmin, GLfloat &zmax)
void parseFeedbackBuffer(GLfloat *, int size, std::vector< PtrPrimitive > &primitive_tab, VRenderParams &vparams)
static PtrPrimitive checkPoint(Point *&P)
static void print3DcolorVertex(GLint size, GLint *count, GLfloat *buffer)
virtual const Feedback3DColor & sommet3DColor(int i) const
static int sizeInBuffer()
struct _DepthIndex DepthIndex