当前位置: 首页>>代码示例>>C++>>正文


C++ VRenderParams::progress方法代码示例

本文整理汇总了C++中VRenderParams::progress方法的典型用法代码示例。如果您正苦于以下问题:C++ VRenderParams::progress方法的具体用法?C++ VRenderParams::progress怎么用?C++ VRenderParams::progress使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在VRenderParams的用法示例。


在下文中一共展示了VRenderParams::progress方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: exportToFile

void Exporter::exportToFile(const QString& filename,
							const vector<PtrPrimitive>& primitive_tab,
							VRenderParams& vparams)
{
	QFile file(filename);

	if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
		QMessageBox::warning(NULL, QGLViewer::tr("Exporter error", "Message box window title"), QGLViewer::tr("Unable to open file %1.").arg(filename));
		return;
	}

	QTextStream out(&file);

	writeHeader(out) ;

		unsigned int N = primitive_tab.size()/200 + 1 ;

	for(unsigned int i=0;i<primitive_tab.size();++i)
	{
		Point *p = dynamic_cast<Point *>(primitive_tab[i]) ;
		Segment *s = dynamic_cast<Segment *>(primitive_tab[i]) ;
		Polygone *P = dynamic_cast<Polygone *>(primitive_tab[i]) ;

		if(p != NULL) spewPoint(p,out) ;
		if(s != NULL) spewSegment(s,out) ;
		if(P != NULL) spewPolygone(P,out) ;

		if(i%N == 0)
			vparams.progress(i/(float)primitive_tab.size(),QGLViewer::tr("Exporting to file %1").arg(filename)) ;
	}

	writeFooter(out) ;

	file.close();
}
开发者ID:harry75369,项目名称:ZBuffer,代码行数:35,代码来源:Exporter.cpp

示例2: sortPrimitives

void BSPSortMethod::sortPrimitives(std::vector<PtrPrimitive>& primitive_tab,VRenderParams& vparams)
{
	// 1 - build BSP using polygons only

	BSPTree tree;
	Polygone *P;

	int N = primitive_tab.size()/200 +1;
	int nbinserted = 0;

	vector<PtrPrimitive> segments_and_points;	// Store segments and points for pass 2, because polygons are deleted
																// by the insertion and can not be dynamic_casted anymore.
	for(unsigned int i=0;i<primitive_tab.size();++i,++nbinserted)
	{
		if((P = dynamic_cast<Polygone *>(primitive_tab[i])) != NULL)
			tree.insert(P);
		else
			segments_and_points.push_back(primitive_tab[i]);

		if(nbinserted%N==0)
			vparams.progress(nbinserted/(float)primitive_tab.size(), QGLViewer::tr("BSP Construction"));
	}

	// 2 - insert points and segments into the BSP

	Segment *S;
	Point *p;

	for(unsigned int j=0;j<segments_and_points.size();++j,++nbinserted)
	{
		if((S = dynamic_cast<Segment *>(segments_and_points[j])) != NULL)
			tree.insert(S);
		else if((p = dynamic_cast<Point *>(segments_and_points[j])) != NULL)
			tree.insert(p);

		if(nbinserted%N==0)
			vparams.progress(nbinserted/(float)primitive_tab.size(), QGLViewer::tr("BSP Construction"));
	}

	// 3 - refill the array with the content of the BSP

	primitive_tab.resize(0);
	tree.recursFillPrimitiveArray(primitive_tab);
}
开发者ID:SoumyajitG,项目名称:VolRoverN,代码行数:44,代码来源:BSPSortMethod.cpp

示例3: recursTopologicalSort

void TopologicalSortUtils::recursTopologicalSort(	vector< vector<int> >& precedence_graph,
																	vector<PtrPrimitive>& primitive_tab,
																	vector<bool>& already_rendered,
																	vector<bool>& already_visited,
																	vector<PtrPrimitive>& new_pr_tab,
																	int indx,
																	int& nb_cycles,
																	VRenderParams& vparams,
																	int info_cnt,int& nbrendered)
{
	// One must first render the primitives indicated by the precedence graph,
	// then render the current primitive. Skews are detected, but and treated.

	already_visited[indx] = true ;

	for(unsigned int j=0;j<precedence_graph[indx].size();++j)
	{
		// Both tests are important. If we ommit the second one, the recursion is
		// always performed down to the next cycle, although this is useless if
		// the current primitive was rendered already.

		if(!already_visited[precedence_graph[indx][j]])
		{
			if(!already_rendered[precedence_graph[indx][j]])
				recursTopologicalSort(	precedence_graph,primitive_tab,already_rendered,already_visited,
												new_pr_tab,precedence_graph[indx][j],nb_cycles,vparams,info_cnt,nbrendered) ;
		}
		else //  A cycle is detected, but in this version, it is not broken.
			++nb_cycles ;
	}

	if(!already_rendered[indx])
	{
		new_pr_tab.push_back(primitive_tab[indx]) ;

		if((++nbrendered)%info_cnt==0)
			vparams.progress(nbrendered/(float)primitive_tab.size(), QGLViewer::tr("Topological sort")) ;
	}

	already_rendered[indx] = true ;
	already_visited[indx] = false ;
}
开发者ID:billhj,项目名称:spheremesh,代码行数:42,代码来源:TopologicalSortMethod.cpp

示例4: parseFeedbackBuffer

void ParserGL::parseFeedbackBuffer(	GLfloat *buffer,int size,
												std::vector<PtrPrimitive>& primitive_tab,
												VRenderParams& vparams)
{
	int token;
	int nvertices = 0 ;
	nb_lines = 0 ;
	nb_polys = 0 ;
	nb_points = 0 ;
	nb_degenerated_lines = 0 ;
	nb_degenerated_polys = 0 ;
	nb_degenerated_points = 0 ;

	// pre-treatment of coordinates so as to get something more consistent

	_xmin = FLT_MAX ;
	_ymin = FLT_MAX ;
	_zmin = FLT_MAX ;
	_xmax = -FLT_MAX ;
	_ymax = -FLT_MAX ;
	_zmax = -FLT_MAX ;

	ParserUtils::ComputeBufferBB(size, buffer, _xmin,_xmax,_ymin,_ymax,_zmin,_zmax) ;

#ifdef DEBUGEPSRENDER
	printf("Buffer bounding box: %f %f %f %f %f %f\n",xmin,xmax,ymin,ymax,zmin,zmax) ;
#endif
	float Zdepth = max(_ymax-_ymin,_xmax-_xmin) ;
	ParserUtils::NormalizeBufferCoordinates(size,buffer,Zdepth,_zmin,_zmax) ;

	// now, read buffer
	GLfloat *end = buffer + size;

	GLfloat *loc = buffer ;
	int next_step = 0 ;
	int N = size/200 + 1 ;

	while (loc < end)
	{
		token = int(0.5f + *loc) ;
		loc++;

		if((end-loc)/N >= next_step)
			vparams.progress((end-loc)/(float)size, QGLViewer::tr("Parsing feedback buffer.")), ++next_step ;

		switch (token)
		{
			case GL_LINE_TOKEN:
			case GL_LINE_RESET_TOKEN:
				{
					Segment *S = new Segment(Feedback3DColor(loc),Feedback3DColor(loc+Feedback3DColor::sizeInBuffer())) ;

					primitive_tab.push_back(ParserUtils::checkSegment(S)) ;

					if(S == NULL)
						nb_degenerated_lines++ ;

					nb_lines++ ;
					loc += 2*Feedback3DColor::sizeInBuffer();
				}
				break;

			case GL_POLYGON_TOKEN:
				{
					nvertices = int(0.5f + *loc) ;
					loc++;

					std::vector<Feedback3DColor> verts ;

					for(int i=0;i<nvertices;++i)
						verts.push_back(Feedback3DColor(loc)),loc+=Feedback3DColor::sizeInBuffer() ;

					Polygone *P = new Polygone(verts) ;

					primitive_tab.push_back(ParserUtils::checkPolygon(P)) ;

					if(P == NULL)
						nb_degenerated_polys++ ;

					nb_polys++ ;
				}
				break ;

			case GL_POINT_TOKEN:
				{
					Point *Pt = new Point(Feedback3DColor(loc)) ;

					primitive_tab.push_back(Pt);//ParserUtils::checkPoint(Pt)) ;

					if(Pt == NULL)
						nb_degenerated_points++ ;

					nb_points++ ;
					loc += Feedback3DColor::sizeInBuffer();
				}
				break;
			default:
				break;
		}
	}
//.........这里部分代码省略.........
开发者ID:abletterer,项目名称:CGoGN-1,代码行数:101,代码来源:ParserGL.cpp

示例5: VectorialRender

void vrender::VectorialRender(RenderCB render_callback, void *callback_params, VRenderParams& vparams)
{
    GLfloat *feedbackBuffer = NULL ;
    SortMethod *sort_method = NULL ;
    Exporter *exporter = NULL ;

    try
    {
        GLint returned = -1 ;

        vparams.error() = 0 ;

        int nb_renders = 0 ;

        vparams.progress(0.0, QGLViewer::tr("Rendering...")) ;

        while(returned < 0)
        {
            if(feedbackBuffer != NULL)
                delete[] feedbackBuffer ;

            feedbackBuffer = new GLfloat[vparams.size()] ;

            if(feedbackBuffer == NULL)
                throw std::runtime_error("Out of memory during feedback buffer allocation.") ;

            glFeedbackBuffer(vparams.size(), GL_3D_COLOR, feedbackBuffer);
            glRenderMode(GL_FEEDBACK);
            render_callback(callback_params);
            returned = glRenderMode(GL_RENDER);

            nb_renders++ ;

            if(returned < 0)
                vparams.size() *= 2 ;
        }

#ifdef A_VOIR
        if(SortMethod != EPS_DONT_SORT)
        {
            GLint depth_bits ;
            glGetIntegerv(GL_DEPTH_BITS, &depth_bits) ;

            EGALITY_EPS 		= 2.0/(1 << depth_bits) ;
            LINE_EGALITY_EPS 	= 2.0/(1 << depth_bits) ;
        }
#endif
        if (returned > vparams.size())
            vparams.size() = returned;
#ifdef _VRENDER_DEBUG
        cout << "Size = " << vparams.size() << ", returned=" << returned << endl ;
#endif

        //  On a un beau feedback buffer tout plein de saloperies. Faut aller
        // defricher tout ca. Ouaiiiis !

        vector<PtrPrimitive> primitive_tab ;

        ParserGL parserGL ;
        parserGL.parseFeedbackBuffer(feedbackBuffer,returned,primitive_tab,vparams) ;

        if(feedbackBuffer != NULL)
        {
            delete[] feedbackBuffer ;
            feedbackBuffer = NULL ;
        }

        if(vparams.isEnabled(VRenderParams::OptimizeBackFaceCulling))
        {
            BackFaceCullingOptimizer bfopt ;
            bfopt.optimize(primitive_tab,vparams) ;
        }

        // Lance la methode de sorting

        switch(vparams.sortMethod())
        {
        case VRenderParams::AdvancedTopologicalSort:
        case VRenderParams::TopologicalSort: {
            TopologicalSortMethod *tsm = new TopologicalSortMethod() ;
            tsm->setBreakCycles(vparams.sortMethod() == VRenderParams::AdvancedTopologicalSort) ;
            sort_method = tsm ;
        }
        break ;

        case VRenderParams::BSPSort:
            sort_method = new BSPSortMethod() ;
            break ;

        case VRenderParams::NoSorting:
            sort_method = new DontSortMethod() ;
            break ;
        default:
            throw std::runtime_error("Unknown sorting method.") ;
        }

        sort_method->sortPrimitives(primitive_tab,vparams) ;

        // Lance les optimisations. L'ordre est important.

//.........这里部分代码省略.........
开发者ID:harry75369,项目名称:ZBuffer,代码行数:101,代码来源:VRender.cpp

示例6: optimize


//.........这里部分代码省略.........
						new_poly_reduced_verts->vertex[2].x = p->vertex(1).x() - du ;
						new_poly_reduced_verts->vertex[2].y = p->vertex(1).y() - dv ;
						new_poly_reduced_verts->vertex[3].x = p->vertex(0).x() - du ;
						new_poly_reduced_verts->vertex[3].y = p->vertex(0).y() - dv ;
					}
					else
					{
						new_poly_verts->num_vertices = p->nbVertices() ;
						new_poly_verts->vertex = new gpc_vertex[p->nbVertices()] ;

						for(int i=0;i<p->nbVertices();++i)
						{
							new_poly_verts->vertex[i].x = p->vertex(i).x() ;
							new_poly_verts->vertex[i].y = p->vertex(i).y() ;
							mx += p->vertex(i).x() ;
							my += p->vertex(i).y() ;
						}
						mx /= p->nbVertices() ;
						my /= p->nbVertices() ;

						new_poly_reduced_verts->num_vertices = p->nbVertices() ;
						new_poly_reduced_verts->vertex = new gpc_vertex[p->nbVertices()] ;

						for(int j=0;j<p->nbVertices();++j)
						{
							new_poly_reduced_verts->vertex[j].x = mx + (p->vertex(j).x() - mx)*0.999 ;
							new_poly_reduced_verts->vertex[j].y = my + (p->vertex(j).y() - my)*0.999 ;
						}
					}
					gpc_add_contour(&new_poly,new_poly_verts,false) ;
					gpc_add_contour(&new_poly_reduced,new_poly_reduced_verts,false) ;

					// 2 - computes the difference between this polygon, and the union of the
					// 	preceeding ones.

					gpc_polygon_clip(GPC_DIFF,&new_poly_reduced,&cumulated_union,&difference) ;

					// 3 - checks the difference. If void, the primitive is not visible: skip it
					// 	and go to next primitive.

					if(difference.num_contours == 0)
					{
						++nb_culled ;
						delete p ;
						primitives[pindex] = NULL ;
						continue ;
					}

					// 4 - The primitive is visible. Let's add it to the cumulated union of
					// 	primitives.

					if(p->nbVertices() > 2)
					{
						gpc_polygon cumulated_union_tmp ;
						cumulated_union_tmp.num_contours = 0 ;
						cumulated_union_tmp.hole = NULL ;
						cumulated_union_tmp.contour = NULL ;

						gpc_polygon_clip(GPC_UNION,&new_poly,&cumulated_union,&cumulated_union_tmp) ;

						gpc_free_polygon(&cumulated_union) ;
						cumulated_union = cumulated_union_tmp ;
					}

					gpc_free_polygon(&new_poly) ;
					gpc_free_polygon(&new_poly_reduced) ;
					gpc_free_polygon(&difference) ;
#ifdef DEBUG_EPSRENDER__SHOW1
					glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT) ;

					glColor3f(1.0,0.0,0.0) ;

					for(int i=0;i<cumulated_union.num_contours;++i)
					{
						glBegin(GL_LINE_LOOP) ;
						for(int j=0;j<cumulated_union.contour[i].num_vertices;++j)
							glVertex2f(cumulated_union.contour[i].vertex[j].x,cumulated_union.contour[i].vertex[j].y) ;
						glEnd() ;
					}

					glFlush() ;
					glXSwapBuffers(glXGetCurrentDisplay(),glXGetCurrentDrawable()) ;
#endif
				}
				catch(exception& )
				{
					; // std::cout << "Could not treat primitive " << pindex << ": internal gpc error." << endl ;
				}
			}

			if(nboptimised%N==0)
				vparams.progress(nboptimised/(float)primitives.size(), QGLViewer::tr("Visibility optimization")) ;
		}

#ifdef DEBUG_VO
	cout << nb_culled << " primitives culled over " << primitives.size() << "." << endl ;
#endif

	gpc_free_polygon(&cumulated_union) ;
}
开发者ID:conanhung,项目名称:sofa_rc1,代码行数:101,代码来源:VisibilityOptimizer.cpp


注:本文中的VRenderParams::progress方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。