⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 slicer.cc

📁 Mesa is an open-source implementation of the OpenGL specification - a system for rendering interacti
💻 CC
📖 第 1 页 / 共 3 页
字号:
	for(i=0; i<left->npts; i++){	  OPT_OUTVERT(left->pts[i], backend);	}	backend.endtfan();      }      else { //both top and bot have >=3 points		backend.bgntfan();		OPT_OUTVERT(top->pts[top->npts-2], backend);		for(i=0; i<=d; i++)	  {	    OPT_OUTVERT(left->pts[i], backend);	  	  }	backend.endtfan();		backend.bgntfan();		OPT_OUTVERT(bot->pts[1], backend);		OPT_OUTVERT(top->pts[top->npts-2], backend);		for(i=d; i< left->npts; i++)	  {      	    OPT_OUTVERT(left->pts[i], backend);      	  }	backend.endtfan();	d = right->npts/2;	//output only when d<right->npts-1 and	//	if(d<right->npts-1)	  {		    backend.bgntfan();	    //      backend.tmeshvert(& top->pts[1]);	    OPT_OUTVERT(top->pts[1], backend);	    for(i=d; i< right->npts; i++)	      {		//	  backend.tmeshvert(& right->pts[i]);				OPT_OUTVERT(right->pts[i], backend);			      }	    backend.endtfan();	  }		backend.bgntfan();	//      backend.tmeshvert(& bot->pts[bot->npts-2]);	OPT_OUTVERT( bot->pts[bot->npts-2], backend);	for(i=0; i<=d; i++)	  {	    //	  backend.tmeshvert(& right->pts[i]);	    OPT_OUTVERT(right->pts[i], backend);	    	  }		//      backend.tmeshvert(& top->pts[1]);	OPT_OUTVERT(top->pts[1], backend);      		backend.endtfan();	topd_left = top->npts-2;	topd_right = 1; //topd_left>= topd_right	botd_left = 1;	botd_right = bot->npts-2; //botd_left<= bot_dright		if(top->npts < bot->npts)	  {	    int delta=bot->npts - top->npts;	    int u = delta/2;	    botd_left = 1+ u;	    botd_right = bot->npts-2-( delta-u);	    		    if(botd_left >1)	      {		backend.bgntfan();		//	  backend.tmeshvert(& top->pts[top->npts-2]);		OPT_OUTVERT(top->pts[top->npts-2], backend);		for(i=1; i<= botd_left; i++)		  {		    //	      backend.tmeshvert(& bot->pts[i]);		    OPT_OUTVERT(bot->pts[i] , backend);		  }		backend.endtfan();	      }	    if(botd_right < bot->npts-2)	      {		backend.bgntfan();		OPT_OUTVERT(top->pts[1], backend);		for(i=botd_right; i<= bot->npts-2; i++)		  OPT_OUTVERT(bot->pts[i], backend);		backend.endtfan();	      }	  }	else if(top->npts> bot->npts)	  {	    int delta=top->npts-bot->npts;	    int u = delta/2;	    topd_left = top->npts-2 - u;	    topd_right = 1+delta-u;	    	    if(topd_left < top->npts-2)	      {		backend.bgntfan();		//	  backend.tmeshvert(& bot->pts[1]);		OPT_OUTVERT(bot->pts[1], backend);		for(i=topd_left; i<= top->npts-2; i++)		  {		    //	      backend.tmeshvert(& top->pts[i]);		    OPT_OUTVERT(top->pts[i], backend);		  }		backend.endtfan();	      }	    if(topd_right > 1)	      {		backend.bgntfan();		OPT_OUTVERT(bot->pts[bot->npts-2], backend);		for(i=1; i<= topd_right; i++)		  OPT_OUTVERT(top->pts[i], backend);		backend.endtfan();	      }	  }		if(topd_left <= topd_right) 	  return;	backend.bgnqstrip();	for(j=botd_left, i=topd_left; i>=topd_right; i--,j++)	  {	    //	  backend.tmeshvert(& top->pts[i]);	    //	  backend.tmeshvert(& bot->pts[j]);	    OPT_OUTVERT(top->pts[i], backend);	    OPT_OUTVERT(bot->pts[j], backend);	  }	backend.endqstrip();	      }    }}  static void triangulateRectCenter(int n_ulines, REAL* u_val, 				  int n_vlines, REAL* v_val,				  Backend& backend){  // XXX this code was patched by Diego Santa Cruz <Diego.SantaCruz@epfl.ch>  // to fix a problem in which glMapGrid2f() was called with bad parameters.  // This has beens submitted to SGI but not integrated as of May 1, 2001.  if(n_ulines>1 && n_vlines>1) {    backend.surfgrid(u_val[0], u_val[n_ulines-1], n_ulines-1,                      v_val[n_vlines-1], v_val[0], n_vlines-1);    backend.surfmesh(0,0,n_ulines-1,n_vlines-1);  }  return;  /*  for(i=0; i<n_vlines-1; i++)    {      backend.bgnqstrip();      for(j=0; j<n_ulines; j++)	{	  trimVert.param[0] = u_val[j];	  trimVert.param[1] = v_val[i+1];	  backend.tmeshvert(& trimVert);	  	  trimVert.param[1] = v_val[i];	  backend.tmeshvert(& trimVert);	  	}      backend.endqstrip();    }    */}//it works for top, bot, left ad right, you need ot select correct argumentsstatic void triangulateRectTopGen(Arc_ptr arc, int n_ulines, REAL* u_val, Real v, int dir, int is_u, Backend& backend){  if(is_u)    {      int i,k;      REAL* upper_val = (REAL*) malloc(sizeof(REAL) * arc->pwlArc->npts);      assert(upper_val);      if(dir)	{	  for(k=0,i=arc->pwlArc->npts-1; i>=0; i--,k++)	    {	      upper_val[k] = arc->pwlArc->pts[i].param[0];	    }		  backend.evalUStrip(arc->pwlArc->npts, arc->pwlArc->pts[0].param[1],			     upper_val,			     n_ulines, v, u_val);	}      else	{	  for(k=0,i=0;  i<arc->pwlArc->npts; i++,k++)	    {	      upper_val[k] = arc->pwlArc->pts[i].param[0];	    }		  	  backend.evalUStrip(			     n_ulines, v, u_val,			     arc->pwlArc->npts, arc->pwlArc->pts[0].param[1], upper_val			     );	 	}      free(upper_val);      return;    }  else //is_v    {      int i,k;      REAL* left_val = (REAL*) malloc(sizeof(REAL) * arc->pwlArc->npts);      assert(left_val);         if(dir)	{	  for(k=0,i=arc->pwlArc->npts-1; i>=0; i--,k++)	    {	      left_val[k] = arc->pwlArc->pts[i].param[1];	    }	  backend.evalVStrip(arc->pwlArc->npts, arc->pwlArc->pts[0].param[0],			     left_val,			     n_ulines, v, u_val);	}      else 	{	  for(k=0,i=0;  i<arc->pwlArc->npts; i++,k++)	    {	      left_val[k] = arc->pwlArc->pts[i].param[1];	    }	   backend.evalVStrip(			     n_ulines, v, u_val,			     arc->pwlArc->npts, arc->pwlArc->pts[0].param[0], left_val			     );		}      free(left_val);      return;    }	  //the following is a different version of the above code. If you comment  //the above code, the following code will still work. The reason to leave  //the folliwng code here is purely for testing purpose.  /*  int i,j;  PwlArc* parc = arc->pwlArc;  int d1 = parc->npts-1;  int d2 = 0;  TrimVertex trimVert;  trimVert.nuid = 0;//????  REAL* temp_u_val = u_val;  if(dir ==0) //have to reverse u_val    {      temp_u_val = (REAL*) malloc(sizeof(REAL) * n_ulines);      assert(temp_u_val);      for(i=0; i<n_ulines; i++)	temp_u_val[i] = u_val[n_ulines-1-i];    }  u_val = temp_u_val;  if(parc->npts > n_ulines)    {      d1 = n_ulines-1;      backend.bgntfan();      if(is_u){	trimVert.param[0] = u_val[0];	trimVert.param[1] = v;      }      else	{	trimVert.param[1] = u_val[0];	trimVert.param[0] = v;      }	        backend.tmeshvert(& trimVert);      for(i=d1; i< parc->npts; i++)	backend.tmeshvert(& parc->pts[i]);      backend.endtfan();    }  else if(parc->npts < n_ulines)    {      d2 = n_ulines-parc->npts;      backend.bgntfan();      backend.tmeshvert(& parc->pts[parc->npts-1]);      for(i=0; i<= d2; i++)	{	  if(is_u){	    trimVert.param[0] = u_val[i];	    trimVert.param[1] = v;	  }	  else	    {	      trimVert.param[1] = u_val[i];	      trimVert.param[0] = v;	    }	  backend.tmeshvert(&trimVert);	}      backend.endtfan();    }  if(d1>0){    backend.bgnqstrip();    for(i=d1, j=d2; i>=0; i--, j++)      {	backend.tmeshvert(& parc->pts[i]);	if(is_u){	  trimVert.param[0] = u_val[j];	  trimVert.param[1] = v;	}	else{	  trimVert.param[1] = u_val[j];	  trimVert.param[0] = v;	}	backend.tmeshvert(&trimVert);	      }    backend.endqstrip();  }  if(dir == 0)  //temp_u_val was mallocated    free(temp_u_val); */}//n_ulines is the number of ulines inside, and n_vlines is the number of vlines//inside, different from meanings elsewhere!!!static void triangulateRectGen(Arc_ptr loop, int n_ulines, int n_vlines, Backend& backend){  int i;  //we know the loop is a rectangle, but not sure which is top  Arc_ptr top, bot, left, right;  if(equalRect(loop->tail()[1] ,  loop->head()[1]))    {      if(loop->tail()[1] > loop->prev->prev->tail()[1])	{	top = loop;	}      else{	top = loop->prev->prev;	}    }  else     {      if(loop->tail()[0] > loop->prev->prev->tail()[0])	{	  //loop is the right arc	  top = loop->next;	}      else	{	  top = loop->prev;	}    }  left = top->next;  bot  = left->next;  right= bot->next;#ifdef COUNT_TRIANGLES  num_triangles += loop->pwlArc->npts +                  left->pwlArc->npts +                  bot->pwlArc->npts + 		  right->pwlArc->npts 		      + 2*n_ulines + 2*n_vlines 			-8;  num_quads += (n_ulines-1)*(n_vlines-1);#endif/*  backend.surfgrid(left->tail()[0], right->tail()[0], n_ulines+1, 		   top->tail()[1], bot->tail()[1], n_vlines+1);//  if(n_ulines>1 && n_vlines>1)    backend.surfmesh(0,0,n_ulines+1,n_vlines+1);return;*/  REAL* u_val=(REAL*) malloc(sizeof(REAL)*n_ulines);  assert(u_val);  REAL* v_val=(REAL*)malloc(sizeof(REAL) * n_vlines);  assert(v_val);  REAL u_stepsize = (right->tail()[0] - left->tail()[0])/( (REAL) n_ulines+1);  REAL v_stepsize = (top->tail()[1] - bot->tail()[1])/( (REAL) n_vlines+1);  Real temp=left->tail()[0]+u_stepsize;  for(i=0; i<n_ulines; i++)    {      u_val[i] = temp;      temp += u_stepsize;    }  temp = bot->tail()[1] + v_stepsize;  for(i=0; i<n_vlines; i++)    {      v_val[i] = temp;      temp += v_stepsize;    }  triangulateRectTopGen(top, n_ulines, u_val, v_val[n_vlines-1], 1,1, backend);  triangulateRectTopGen(bot, n_ulines, u_val, v_val[0], 0, 1, backend);  triangulateRectTopGen(left, n_vlines, v_val, u_val[0], 1, 0, backend);  triangulateRectTopGen(right, n_vlines, v_val, u_val[n_ulines-1], 0,0, backend);  //triangulate the center  triangulateRectCenter(n_ulines, u_val, n_vlines, v_val, backend);  free(u_val);  free(v_val);  }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -