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 ;
226 for(
size_t i=0;i<n;++i)
233 return checkSegment(pp) ;
240 return checkPoint(pp) ;
256 printf(
"%4.2f ", buffer[size - (*count)]);
265 int token, nvertices;
269 token = int(buffer[size - count]);
273 case GL_PASS_THROUGH_TOKEN:
274 printf(
"GL_PASS_THROUGH_TOKEN\n");
275 printf(
" %4.2f\n", buffer[size - count]);
279 printf(
"GL_POINT_TOKEN\n");
280 print3DcolorVertex(size, &count, buffer);
283 printf(
"GL_LINE_TOKEN\n");
284 print3DcolorVertex(size, &count, buffer);
285 print3DcolorVertex(size, &count, buffer);
287 case GL_LINE_RESET_TOKEN:
288 printf(
"GL_LINE_RESET_TOKEN\n");
289 print3DcolorVertex(size, &count, buffer);
290 print3DcolorVertex(size, &count, buffer);
292 case GL_POLYGON_TOKEN:
293 printf(
"GL_POLYGON_TOKEN\n");
294 nvertices = int(buffer[size - count]) ;
296 for (; nvertices > 0; nvertices--)
297 print3DcolorVertex(size, &count, buffer);
313 case GL_LINE_RESET_TOKEN:
316 for (i = 0; i < 2; i++)
317 (loc+size*i)[2] = ((loc+size*i)[2] - zmin)/(zmax-zmin)*MaxSize ;
322 case GL_POLYGON_TOKEN:
324 nvertices = int(*loc) ;
327 for (i = 0; i < nvertices; i++)
328 (loc+size*i)[2] = ((loc+size*i)[2] - zmin)/(zmax-zmin)*MaxSize ;
330 loc += nvertices * size;
335 loc[2] = (loc[2] - zmin)/(zmax-zmin)*MaxSize ;
342 #ifdef DEBUGEPSRENDER 360 case GL_LINE_RESET_TOKEN:
363 for (i = 0; i < 2; i++)
367 if(f.
x() < xmin) xmin = GLfloat(f.
x()) ;
368 if(f.
y() < ymin) ymin = GLfloat(f.
y()) ;
369 if(f.
z() < zmin) zmin = GLfloat(f.
z()) ;
370 if(f.
x() > xmax) xmax = GLfloat(f.
x()) ;
371 if(f.
y() > ymax) ymax = GLfloat(f.
y()) ;
372 if(f.
z() > zmax) zmax = GLfloat(f.
z()) ;
379 case GL_POLYGON_TOKEN:
381 nvertices = int(*loc) ;
384 for (i = 0; i < nvertices; i++)
388 if(f.
x() < xmin) xmin = GLfloat(f.
x()) ;
389 if(f.
y() < ymin) ymin = GLfloat(f.
y()) ;
390 if(f.
z() < zmin) zmin = GLfloat(f.
z()) ;
391 if(f.
x() > xmax) xmax = GLfloat(f.
x()) ;
392 if(f.
y() > ymax) ymax = GLfloat(f.
y()) ;
393 if(f.
z() > zmax) zmax = GLfloat(f.
z()) ;
396 loc += nvertices * size;
404 if(f.
x() < xmin) xmin = GLfloat(f.
x()) ;
405 if(f.
y() < ymin) ymin = GLfloat(f.
y()) ;
406 if(f.
z() < zmin) zmin = GLfloat(f.
z()) ;
407 if(f.
x() > xmax) xmax = GLfloat(f.
x()) ;
408 if(f.
y() > ymax) ymax = GLfloat(f.
y()) ;
409 if(f.
z() > zmax) zmax = GLfloat(f.
z()) ;
417 #ifdef DEBUGEPSRENDER 418 printf(
"Incomplete implementation. Unexpected token (%d).\n", token);
430 #ifdef DEBUGEPSRENDER 431 printf(
"Warning: zmin = zmax in NormalizePrimitiveCoordinates\n") ;
440 NormalizePrimitiveCoordinates(loc,MaxSize,zmin,zmax);
447 GLfloat & xmin, GLfloat & xmax,
448 GLfloat & ymin, GLfloat & ymax,
449 GLfloat & zmin, GLfloat & zmax)
457 ComputePrimitiveBB(loc,xmin,xmax,ymin,ymax,zmin,zmax);
469 case GL_PASS_THROUGH_TOKEN:
return "GL_PASS_THROUGH_TOKEN" ;
470 case GL_POINT_TOKEN:
return "GL_POINT_TOKEN" ;
471 case GL_LINE_TOKEN:
return "GL_LINE_TOKEN" ;
472 case GL_POLYGON_TOKEN:
return "GL_POLYGON_TOKEN" ;
473 case GL_BITMAP_TOKEN:
return "GL_BITMAP_TOKEN" ;
474 case GL_DRAW_PIXEL_TOKEN:
return "GL_DRAW_PIXEL_TOKEN" ;
475 case GL_COPY_PIXEL_TOKEN:
return "GL_COPY_PIXEL_TOKEN" ;
476 case GL_LINE_RESET_TOKEN:
return "GL_LINE_RESET_TOKEN" ;
478 return "(Unidentified token)" ;
virtual const Vector3 & vertex(size_t) const
static const double EGALITY_EPS
static size_t sizeInBuffer()
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)
static void NormalizeBufferCoordinates(GLint size, GLfloat *buffer, GLfloat MaxSize, GLfloat &zmin, GLfloat &zmax)
void progress(float, const QString &)
virtual const Feedback3DColor & sommet3DColor(size_t) const
static void debug_printBuffer(GLint size, GLfloat *buffer)
virtual size_t nbVertices() 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(size_t i) const
virtual const Vector3 & vertex(size_t) const
struct _DepthIndex DepthIndex