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

📄 poly2.c

📁 这是一个新的用于图像处理的工具箱
💻 C
📖 第 1 页 / 共 5 页
字号:
              errfacet1= facet;              errfacet2= neighbor;              waserror= True;	    }	  }else {                          zzinc_(Zcoplanarridges);            trace0((qh ferr, "qhull precision error: f%d may be coplanar to f%d, since p%d (v%d) is within %6.4g during p%d\n",              facet->id, neighbor->id, qh_pointid(vertex->point), vertex->id, dist, qh furthest_id));          }        }      }    }    if (!allsimplicial) {      if (qh CENTERtype == qh_AScentrum) {        if (!facet->center)          facet->center= qh_getcentrum (facet);        centrum= facet->center;      }else {        centrum= qh_getcentrum(facet);        tempcentrum= True;      }      FOREACHneighbor_(facet) {	if (qh ZEROcentrum && facet->simplicial && neighbor->simplicial)	  continue;        zzinc_(Zdistconvex);        qh_distplane (centrum, neighbor, &dist);        if (dist > qh DISTround) {          zzinc_(Zconcaveridges);          fprintf (qh ferr, "qhull precision error: f%d is concave to f%d.  Centrum of f%d is %6.4g above f%d\n",            facet->id, neighbor->id, facet->id, dist, neighbor->id);          errfacet1= facet;          errfacet2= neighbor;          waserror= True;        }else if (dist >= 0.0) {   /* if arithmetic always rounds the same,				     can test against centrum radius instead */          zzinc_(Zcoplanarridges);          fprintf (qh ferr, "qhull precision error: f%d is coplanar or concave to f%d.  Centrum of f%d is %6.4g above f%d\n",            facet->id, neighbor->id, facet->id, dist, neighbor->id);	  errfacet1= facet;	  errfacet2= neighbor;	  waserror= True;        }      }      if (tempcentrum)        qh_memfree(centrum, qh normal_size);    }  }  if (waserror && !qh FORCEoutput)    qh_errexit2 (qh_ERRprec, errfacet1, errfacet2);} /* checkconvex *//*--------------------------------------------------checkfacet- checks for consistency errors in facet (called from merge.c)    vertex ids are inverse sorted    unless newmerge, at least hull_dim neighbors and vertices (exactly if simplicial)    if non-simplicial, at least as many ridges as neighbors    neighbors are not duplicated    ridges are not duplicated    in 3-d, ridges=verticies    (hull_dim-1) ridge vertices    neighbors are reciprocated    ridge neighbors are facet neighbors and a ridge for every neighbor    simplicial neighbors match facetintersect    vertex intersection matches vertices of common ridges     vertex neighbors and facet vertices agree    all ridges have distinct vertex sets  sets waserror if any error occurs  uses neighbor->seen*/void qh_checkfacet(facetT *facet, boolT newmerge, boolT *waserrorp) {  facetT *neighbor, **neighborp, *errother=NULL;  ridgeT *ridge, **ridgep, *errridge= NULL, *ridge2;  vertexT *vertex, **vertexp;  unsigned previousid= INT_MAX;  int numneighbors, numvertices, numridges=0, numRvertices=0;  boolT waserror= False;  int skipA, skipB, ridge_i, ridge_n, i;  setT *intersection;  if (facet->visible) {    fprintf (qh ferr, "qhull internal error (qh_checkfacet): facet f%d is on the visible_list\n",      facet->id);    qh_errexit (qh_ERRqhull, facet, NULL);  }  if (!facet->normal) {    fprintf (qh ferr, "qhull internal error (qh_checkfacet): facet f%d does not have  a normal\n",      facet->id);    waserror= True;  }  qh_setcheck (facet->vertices, "vertices for f", facet->id);  qh_setcheck (facet->ridges, "ridges for f", facet->id);  qh_setcheck (facet->outsideset, "outsideset for f", facet->id);  qh_setcheck (facet->coplanarset, "coplanarset for f", facet->id);  qh_setcheck (facet->neighbors, "neighbors for f", facet->id);  FOREACHvertex_(facet->vertices) {    if (vertex->deleted) {      fprintf(qh ferr, "qhull internal error (qh_checkfacet): deleted vertex v%d in f%d\n", vertex->id, facet->id);      qh_errprint ("ERRONEOUS", NULL, NULL, NULL, vertex);      waserror= True;    }    if (vertex->id >= previousid) {      fprintf(qh ferr, "qhull internal error (qh_checkfacet): vertices of f%d are not in descending id order at v%d\n", facet->id, vertex->id);      waserror= True;      break;    }    previousid= vertex->id;  }  numneighbors= qh_setsize(facet->neighbors);  numvertices= qh_setsize(facet->vertices);  numridges= qh_setsize(facet->ridges);  if (facet->simplicial) {    if (numvertices+numneighbors != 2*qh hull_dim     && !facet->degenerate && !facet->redundant) {      fprintf(qh ferr, "qhull internal error (qh_checkfacet): for simplicial facet f%d, #vertices %d + #neighbors %d != 2*qh hull_dim\n",                 facet->id, numvertices, numneighbors);      qh_setprint (qh ferr, "", facet->neighbors);      waserror= True;    }  }else { /* non-simplicial */    if (!newmerge     &&(numvertices < qh hull_dim || numneighbors < qh hull_dim)    && !facet->degenerate && !facet->redundant) {      fprintf(qh ferr, "qhull internal error (qh_checkfacet): for facet f%d, #vertices %d or #neighbors %d < qh hull_dim\n",         facet->id, numvertices, numneighbors);       waserror= True;    }    if (numridges < numneighbors    ||(qh hull_dim == 3 && numvertices != numridges && !qh NEWfacets)    ||(qh hull_dim == 2 && numridges + numvertices + numneighbors != 6)) {      if (!facet->degenerate && !facet->redundant) {	fprintf(qh ferr, "qhull internal error (qh_checkfacet): for facet f%d, #ridges %d < #neighbors %d or (3-d) != #vertices %d or (2-d) not all 2\n",	    facet->id, numridges, numneighbors, numvertices);	waserror= True;      }    }  }  FOREACHneighbor_(facet) {    if (neighbor == qh_MERGEridge || neighbor == qh_DUPLICATEridge) {      fprintf(qh ferr, "qhull internal error (qh_checkfacet): facet f%d still has a MERGE or DUP neighbor\n", facet->id);      qh_errexit (qh_ERRqhull, facet, NULL);    }    neighbor->seen= True;  }  FOREACHneighbor_(facet) {    if (!qh_setin(neighbor->neighbors, facet)) {      fprintf(qh ferr, "qhull internal error (qh_checkfacet): facet f%d has neighbor f%d, but f%d does not have neighbor f%d\n",	      facet->id, neighbor->id, neighbor->id, facet->id);      errother= neighbor;      waserror= True;    }    if (!neighbor->seen) {      fprintf(qh ferr, "qhull internal error (qh_checkfacet): facet f%d has a duplicate neighbor f%d\n",	      facet->id, neighbor->id);      errother= neighbor;      waserror= True;    }        neighbor->seen= False;  }  FOREACHridge_(facet->ridges) {    qh_setcheck (ridge->vertices, "vertices for r", ridge->id);    ridge->seen= False;  }  FOREACHridge_(facet->ridges) {    if (ridge->seen) {      fprintf(qh ferr, "qhull internal error (qh_checkfacet): facet f%d has a duplicate ridge r%d\n",	      facet->id, ridge->id);      errridge= ridge;      waserror= True;    }        ridge->seen= True;    numRvertices= qh_setsize(ridge->vertices);    if (numRvertices != qh hull_dim - 1) {      fprintf(qh ferr, "qhull internal error (qh_checkfacet): ridge between f%d and f%d has %d vertices\n",                 ridge->top->id, ridge->bottom->id, numRvertices);      errridge= ridge;      waserror= True;    }    neighbor= otherfacet_(ridge, facet);    neighbor->seen= True;    if (!qh_setin(facet->neighbors, neighbor)) {      fprintf(qh ferr, "qhull internal error (qh_checkfacet): for facet f%d, neighbor f%d of ridge r%d not in facet\n",           facet->id, neighbor->id, ridge->id);      errridge= ridge;      waserror= True;    }  }  if (!facet->simplicial) {    FOREACHneighbor_(facet) {      if (!neighbor->seen) {        fprintf(qh ferr, "qhull internal error (qh_checkfacet): facet f%d does not have a ridge for neighbor f%d\n",	      facet->id, neighbor->id);	errother= neighbor;        waserror= True;      }      intersection= qh_vertexintersect_new(facet->vertices, neighbor->vertices);      qh_settemppush (intersection);      FOREACHvertex_(facet->vertices) {	vertex->seen= False;	vertex->seen2= False;      }      FOREACHvertex_(intersection)	vertex->seen= True;      FOREACHridge_(facet->ridges) {	if (neighbor != otherfacet_(ridge, facet))	    continue;	FOREACHvertex_(ridge->vertices) {	  if (!vertex->seen) {	    fprintf (qh ferr, "qhull internal error (qh_checkfacet): vertex v%d in r%d not in f%d intersect f%d\n",  	          vertex->id, ridge->id, facet->id, neighbor->id);	    qh_errexit (qh_ERRqhull, facet, ridge);	  }	  vertex->seen2= True;	}      }      if (!newmerge) {	FOREACHvertex_(intersection) {	  if (!vertex->seen2) {	    if (qh IStracing >=3 || !qh MERGING) {	      fprintf (qh ferr, "qhull precision error (qh_checkfacet): vertex v%d in f%d intersect f%d but\n\ not in a ridge.  This is ok under merging.  Last point was p%d\n",		     vertex->id, facet->id, neighbor->id, qh furthest_id);	      if (!qh FORCEoutput && !qh MERGING) {		qh_errprint ("ERRONEOUS", facet, neighbor, NULL, vertex);		if (!qh MERGING)		  qh_errexit (qh_ERRqhull, NULL, NULL);	      }	    }	  }	}      }            qh_settempfree (&intersection);    }  }else { /* simplicial */    FOREACHneighbor_(facet) {      if (neighbor->simplicial) {    	skipA= SETindex_(facet->neighbors, neighbor);	skipB= qh_setindex (neighbor->neighbors, facet);	if (!qh_setequal_skip (facet->vertices, skipA, neighbor->vertices, skipB)) {	  fprintf (qh ferr, "qhull internal error (qh_checkfacet): facet f%d skip %d and neighbor f%d skip %d do not match \n",		   facet->id, skipA, neighbor->id, skipB);	  errother= neighbor;	  waserror= True;	}      }    }  }  if (qh hull_dim < 5 && (qh IStracing > 2 || qh CHECKfrequently)) {    FOREACHridge_i_(facet->ridges) {           /* expensive */      for (i= ridge_i+1; i < ridge_n; i++) {	ridge2= SETelem_(facet->ridges, i);	if (qh_setequal (ridge->vertices, ridge2->vertices)) {	  fprintf (qh ferr, "qh_checkfacet: ridges r%d and r%d have the same vertices\n",		  ridge->id, ridge2->id);	  errridge= ridge;	  waserror= True;	}      }    }  }  if (waserror) {    qh_errprint("ERRONEOUS", facet, errother, errridge, NULL);    *waserrorp= True;  }} /* checkfacet *//*--------------------------------------------------checkflipped_all- checks orientation of facets in list against interior point*/void qh_checkflipped_all (facetT *facetlist) {  facetT *facet;  boolT waserror= False;  realT dist;  if (facetlist == qh facet_list)    zzval_(Zflippedfacets)= 0;  FORALLfacet_(facetlist) {    if (facet->normal && !qh_checkflipped (facet, &dist, !qh_ALL)) {      fprintf(qh ferr, "qhull precision error: facet f%d is flipped, distance= %6.12g\n",	      facet->id, dist);      if (!qh FORCEoutput) {	qh_errprint("ERRONEOUS", facet, NULL, NULL, NULL);	waserror= True;      }    }  }  if (waserror) {    fprintf (qh ferr, "\n\A flipped facet occurs when its distance to the interior point is\n\greater than %2.2g, the maximum round-off error.\n", -qh DISTround);    qh_errexit(qh_ERRprec, NULL, NULL);  }} /* checkflipped_all *//*--------------------------------------------------checkpolygon- checks the correctness of the structure  check num_facets and num_vertices if qh facet_list  call with either qh facet_list or qh newfacet_list*/void qh_checkpolygon(facetT *facetlist) {  facetT *facet;  vertexT *vertex, **vertexp, *vertexlist;  int numfacets= 0, numvertices= 0, numridges= 0;  int totvneighbors= 0, totvertices= 0;  boolT waserror= False, nextseen= False, visibleseen= False;    trace1((qh ferr, "qh_checkpolygon: check all facets from f%d\n", facetlist->id));  if (facetlist != qh facet_list || qh ONLYgood)    nextseen= True;  FORALLfacet_(facetlist) {    if (facet == qh visible_list)      visibleseen= True;    if (!facet->visible) {      if (!nextseen) {	if (facet == qh facet_next)	  nextseen= True;	else if (qh_setsize (facet->outsideset)) {	  fprintf (qh ferr, "qhull internal error (qh_checkpolygon): f%d has outside set before qh facet_next\n",		   facet->id);	  qh_errexit (qh_ERRqhull, facet, NULL);	}      }      numfacets++;      qh_checkfacet(facet, False, &waserror);    }  }  if (qh visible_list && !visibleseen && facetlist == qh facet_list) {    fprintf (qh ferr, "qhull internal error (qh_checkpolygon): visible list f%d no longer on facet list\n", qh visible_list->id);    qh_printlists();    qh_errexit (qh_ERRqhull, qh visible_list, NULL);  }  if (facetlist == qh facet_list)    vertexlist= qh vertex_list;  else if (facetlist == qh newfacet_list)    vertexlist= qh newvertex_list;  else    vertexlist= NULL;  FORALLvertex_(vertexlist) {    vertex->seen= False;    vertex->visitid= 0;  }    FORALLfacet_(facetlist) {    if (facet->visible)      continue;    if (facet->simplicial)      numridges += qh hull_dim;    else      numridges += qh_setsize (facet->ridges);    FOREACHvertex_(facet->vertices) {      vertex->visitid++;      if (!vertex->seen) {	vertex->seen= True;	numvertices++;	if (qh_pointid (vertex->point) == -1) {	  fprintf (qh ferr, "qhull internal error (qh_checkpolygon): unknown point %p for vertex v%d first_point %p\n",		   vertex->point, vertex->id, qh first_point);	  waserror= True;	}      }    }  }  qh vertex_visit += numfacets;  if (facetlist == qh facet_list) {    if (numfacets != qh num_facets - qh num_visible) {      fprintf(qh ferr, "qhull internal error (qh_checkpolygon): actual number of facets is %d, cumulative facet count is %d\n",	      numfacets, qh num_facets- qh num_visible);      waserror= True;    }    qh vertex_visit++;    if (qh VERTEXneighbors) {      FORALLvertices {	qh_setcheck (vertex->neighbors, "neighbors for v", vertex->id);	if (vertex->deleted)	  continue;

⌨️ 快捷键说明

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