62 cout <<
"Optimizing visibility." << endl ;
64 unsigned int N = primitives.size()/200 + 1 ;
66 #ifdef DEBUG_EPSRENDER__SHOW1 74 for(
unsigned int i=0;i<primitives.size();++i)
75 for(
int j=0;j<primitives[i]->nbVertices();++j)
77 if(maxx < primitives[i]->vertex(j).x()) maxx = primitives[i]->vertex(j).x() ;
78 if(maxy < primitives[i]->vertex(j).y()) maxy = primitives[i]->vertex(j).y() ;
79 if(minx > primitives[i]->vertex(j).x()) minx = primitives[i]->vertex(j).x() ;
80 if(miny > primitives[i]->vertex(j).y()) miny = primitives[i]->vertex(j).y() ;
83 glMatrixMode(GL_PROJECTION) ;
85 glOrtho(minx,maxx,miny,maxy,-1,1) ;
86 glMatrixMode(GL_MODELVIEW) ;
89 cout <<
"Window set to " << minx <<
" " << maxx <<
" " << miny <<
" " << maxy << endl ;
90 glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT) ;
100 cumulated_union.
hole = NULL ;
101 cumulated_union.
contour = NULL ;
102 int nboptimised = 0 ;
104 for(
int pindex = (
int)(primitives.size()) - 1; pindex >= 0;--pindex,++nboptimised)
105 if(primitives[pindex] != NULL)
108 percentage_finished = pindex / (float)primitives.size() ;
111 if(primitives[pindex]->nbVertices() > 1)
117 sprintf(buff,
"Left: % 6ld - Culled: % 6ld", (
long)pindex,(
long)nb_culled) ;
118 fprintf(stdout,buff);
120 for(
unsigned int j=0;j<strlen(buff);++j)
121 fprintf(stdout,
"\b") ;
134 new_poly.
hole = NULL ;
137 new_poly_reduced.
hole = NULL ;
138 new_poly_reduced.
contour = NULL ;
155 double deps = 0.001 ;
158 double n = sqrt(du*du+dv*dv) ;
199 new_poly_reduced_verts->
vertex[j].
x = mx + (p->
vertex(j).
x() - mx)*0.999 ;
200 new_poly_reduced_verts->
vertex[j].
y = my + (p->
vertex(j).
y() - my)*0.999 ;
218 primitives[pindex] = NULL ;
229 cumulated_union_tmp.
hole = NULL ;
230 cumulated_union_tmp.
contour = NULL ;
235 cumulated_union = cumulated_union_tmp ;
241 #ifdef DEBUG_EPSRENDER__SHOW1 242 glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT) ;
244 glColor3f(1.0,0.0,0.0) ;
248 glBegin(GL_LINE_LOOP) ;
255 glXSwapBuffers(glXGetCurrentDisplay(),glXGetCurrentDrawable()) ;
265 vparams.
progress(nboptimised/(
float)primitives.size(), QGLViewer::tr(
"Visibility optimization")) ;
269 cout << nb_culled <<
" primitives culled over " << primitives.size() <<
"." << endl ;
virtual void optimize(std::vector< PtrPrimitive > &, VRenderParams &)
gpc_vertex_list * contour
void gpc_polygon_clip(gpc_op op, gpc_polygon *subj, gpc_polygon *clip, gpc_polygon *result)
void progress(float, const QString &)
virtual const Vector3 & vertex(int) const =0
void gpc_free_polygon(gpc_polygon *p)
virtual unsigned int nbVertices() const =0
void gpc_add_contour(gpc_polygon *p, gpc_vertex_list *new_contour, int hole)