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

📄 geompack_insfac.cxx

📁 hl2 source code. Do not use it illegal.
💻 CXX
📖 第 1 页 / 共 2 页
字号:
    for (i__ = 1; i__ <= i__1; ++i__) {
	a = cedge[(i__ << 1) + 2];
	la = faceverticeslist[a * 6 + 1];
	lb = faceverticeslist[faceverticeslist[a * 6 + 3] * 6 + 1];
	if ((lb - la) * cdang[i__] > 0.) {
	    cedge[(i__ << 1) + 1] = faceverticeslist[a * 6 + 6];
	} else {
	    cedge[(i__ << 1) + 1] = faceverticeslist[a * 6 + 5];
	}
/* L50: */
    }

/*     Determine which faces of old P belong to new P or other new polyh, */
/*     and update POLYHEDRONFIRSTFACEOFFSET, POLYHEDRONFACEINDICES. NP1 is used as a temporary polyhedron index. */
/*     Faces of old P are put into FACESDATA(2,*) field. */
/*     FACESTYPE(F) is set to -1 for double occurring faces. */

    dof = 0;
    np1 = this->npolh + 1;
    j = polyhedronfirstfaceoffset[*p];
L60:
    f = (i__1 = polyhedronfaceindices[(j << 1) + 1], abs(i__1));
    if ((i__1 = facesdata[f * 3 + 2], abs(i__1)) == (i__2 = facesdata[f * 3 + 3], abs(
	    i__2))) {
	facesdata[f * 3 + 2] = np1;
	facesdata[f * 3 + 3] = -np1;
	facestype[f] = -1;
	dof = 1;
    } else if ((i__1 = facesdata[f * 3 + 2], abs(i__1)) == *p) {
	facesdata[f * 3 + 2] = i_sign(np1, facesdata[f * 3 + 2]);
    } else {
	i__ = facesdata[f * 3 + 2];
	facesdata[f * 3 + 2] = i_sign(np1, facesdata[f * 3 + 3]);
	facesdata[f * 3 + 3] = i__;
	normals[f * 3 + 1] = -normals[f * 3 + 1];
	normals[f * 3 + 2] = -normals[f * 3 + 2];
	normals[f * 3 + 3] = -normals[f * 3 + 3];
    }
    j = polyhedronfaceindices[(j << 1) + 2];
    if (j != polyhedronfirstfaceoffset[*p]) {
	goto L60;
    }
    i__1 = *nce;
    for (i__ = 1; i__ <= i__1; ++i__) {
	j = 2;
	f = faceverticeslist[cedge[(i__ << 1) + 1] * 6 + 2];
	if (facestype[f] == -1) {
	    if (faceverticeslist[cedge[(i__ << 1) + 1] * 6 + 1] != faceverticeslist[(nv + i__) * 6 + 1])
		     {
		j = 3;
	    }
	}
	facesdata[j + f * 3] = i_sign(this->npolh, facesdata[j + f * 3]);
	j = 2;
	f = faceverticeslist[cedge[(i__ << 1) + 2] * 6 + 2];
	if (facestype[f] == -1) {
	    if (cdang[i__] < 0.) {
		j = 3;
	    }
	}
	facesdata[j + f * 3] = i_sign(*p, facesdata[j + f * 3]);
/* L70: */
    }
    polyhedronfaceindices[((this->n_polyhedronfaces-1) << 1) + 1] = this->nface;
    polyhedronfaceindices[(this->n_polyhedronfaces << 1) + 1] = -(this->nface);
    tailp = this->n_polyhedronfaces - 1;
    tailn = this->n_polyhedronfaces;
    tailt = polyhedronfirstfaceoffset[*p];
    ptr = polyhedronfaceindices[(tailt << 1) + 2];
    polyhedronfaceindices[(tailt << 1) + 2] = 0;
    polyhedronfirstfaceoffset[*p] = this->n_polyhedronfaces - 1;
    polyhedronfirstfaceoffset[this->npolh] = this->n_polyhedronfaces;

L80:
    if (ptr == 0) {
	goto L110;
    }
    j = ptr;
    sp = polyhedronfaceindices[(ptr << 1) + 1];
    f = abs(sp);
    ptr = polyhedronfaceindices[(ptr << 1) + 2];
    if (facestype[f] != -1 || sp > 0) {
	k = 2;
    } else {
	k = 3;
    }
    sf = facesdata[k + f * 3];
    if (abs(sf) == *p) {
	polyhedronfaceindices[(tailp << 1) + 2] = j;
	tailp = j;
    } else if (abs(sf) == this->npolh) {
	polyhedronfaceindices[(tailn << 1) + 2] = j;
	tailn = j;
    } else {
	a = facesdata[f * 3 + 1];
	la = faceverticeslist[a * 6 + 1];
L90:
	b = faceverticeslist[a * 6 + 3];
	lb = faceverticeslist[b * 6 + 1];
	if ((lb - la) * sp > 0) {
	    c__ = faceverticeslist[a * 6 + 6];
	} else {
	    c__ = faceverticeslist[a * 6 + 5];
	}
	g = faceverticeslist[c__ * 6 + 2];
	i__ = 2;
	if (facestype[g] == -1) {
	    if (faceverticeslist[c__ * 6 + 1] == la) {
		if (sp > 0) {
		    i__ = 3;
		}
	    } else {
		if (sp < 0) {
		    i__ = 3;
		}
	    }
	}
	if ((i__1 = facesdata[i__ + g * 3], abs(i__1)) == *p) {
	    polyhedronfaceindices[(tailp << 1) + 2] = j;
	    tailp = j;
	    facesdata[k + f * 3] = i_sign(*p, facesdata[k + f * 3]);
	    goto L100;
	} else if ((i__1 = facesdata[i__ + g * 3], abs(i__1)) == this->npolh) {
	    polyhedronfaceindices[(tailn << 1) + 2] = j;
	    tailn = j;
	    facesdata[k + f * 3] = i_sign(this->npolh, facesdata[k + f * 3]);
	    goto L100;
	}
	a = b;
	la = lb;
	if (a != facesdata[f * 3 + 1]) {
	    goto L90;
	}
	polyhedronfaceindices[(tailt << 1) + 2] = j;
	polyhedronfaceindices[(j << 1) + 2] = 0;
	tailt = j;
L100:
	;
    }
    goto L80;
L110:
    polyhedronfaceindices[(tailp << 1) + 2] = this->n_polyhedronfaces - 1;
    polyhedronfaceindices[(tailn << 1) + 2] = this->n_polyhedronfaces;

/*     Check whether cut face occurs twice in same polyhedron. */
/*     Temporarily modify PRED field of edges of cut face. */

    docf = 0;
    i__1 = *nce;
    for (i__ = 1; i__ <= i__1; ++i__) {
	for (j = 1; j <= 2; ++j) {
	    a = cedge[j + (i__ << 1)];
	    faceverticeslist[a * 6 + 4] = -faceverticeslist[a * 6 + 4];
/* L120: */
	}
/* L130: */
    }
    for (i__ = 1; i__ <= 2; ++i__) {
	if (i__ == 1) {
	    head = this->n_polyhedronfaces - 1;
	    pind = *p;
	} else {
	    head = this->n_polyhedronfaces;
	    pind = this->npolh;
	}
	ptr = polyhedronfaceindices[(head << 1) + 2];
L140:
	sf = polyhedronfaceindices[(ptr << 1) + 1];
	f = abs(sf);
	a = facesdata[f * 3 + 1];
	la = faceverticeslist[a * 6 + 1];
L150:
	b = faceverticeslist[a * 6 + 3];
	lb = faceverticeslist[b * 6 + 1];
	if (faceverticeslist[a * 6 + 4] > 0) {
	    if ((lb - la) * sf > 0) {
		c__ = faceverticeslist[a * 6 + 6];
	    } else {
		c__ = faceverticeslist[a * 6 + 5];
	    }
	    g = faceverticeslist[c__ * 6 + 2];
	    k = 2;
	    if (facestype[g] == -1) {
		if (faceverticeslist[c__ * 6 + 1] == la) {
		    if (sf > 0) {
			k = 3;
		    }
		} else {
		    if (sf < 0) {
			k = 3;
		    }
		}
	    }
	    if ((i__1 = facesdata[k + g * 3], abs(i__1)) != pind) {
		docf = 1;
		goto L170;
	    }
	}
	a = b;
	la = lb;
	if (a != facesdata[f * 3 + 1]) {
	    goto L150;
	}
	ptr = polyhedronfaceindices[(ptr << 1) + 2];
	if (ptr != head) {
	    goto L140;
	}
/* L160: */
    }

/*     Reset PRED field of edges of cut face. */

L170:
    i__1 = *nce;
    for (i__ = 1; i__ <= i__1; ++i__) {
	for (j = 1; j <= 2; ++j) {
	    a = cedge[j + (i__ << 1)];
	    faceverticeslist[a * 6 + 4] = -faceverticeslist[a * 6 + 4];
/* L180: */
	}
/* L190: */
    }

/*     Update EDGA, EDGC, and EDGE_ANGLES fields. */

    i__1 = *nce;
    for (i__ = 1; i__ <= i__1; ++i__) {
	a = cedge[(i__ << 1) + 2];
	c__ = cedge[(i__ << 1) + 1];
	la = faceverticeslist[a * 6 + 1];
	lb = faceverticeslist[faceverticeslist[a * 6 + 3] * 6 + 1];
	ang = (d__1 = cdang[i__], abs(d__1));
	if ((lb - la) * cdang[i__] > 0.) {
	    faceverticeslist[a * 6 + 6] = nv + i__;
	    faceverticeslist[c__ * 6 + 5] = nv + i__;
	    faceverticeslist[(nv + i__) * 6 + 6] = c__;
	    faceverticeslist[(nv + i__) * 6 + 5] = a;
	    edge_angles[a] -= ang;
	    edge_angles[nv + i__] = ang;
	} else {
	    faceverticeslist[c__ * 6 + 6] = nv + i__;
	    faceverticeslist[a * 6 + 5] = nv + i__;
	    faceverticeslist[(nv + i__) * 6 + 6] = a;
	    faceverticeslist[(nv + i__) * 6 + 5] = c__;
	    edge_angles[nv + i__] = edge_angles[c__] - ang;
	    edge_angles[c__] = ang;
	}
/* L200: */
    }

/*     If DOF, reset FACESTYPE values of -1 to 0. */

    if (dof) {
	for (i__ = 1; i__ <= 2; ++i__) {
	    if (i__ == 1) {
		head = this->n_polyhedronfaces - 1;
	    } else {
		head = this->n_polyhedronfaces;
	    }
	    ptr = polyhedronfaceindices[(head << 1) + 2];
L210:
	    f = (i__1 = polyhedronfaceindices[(ptr << 1) + 1], abs(i__1));
	    if (facestype[f] == -1) {
		facestype[f] = 0;
	    }
	    ptr = polyhedronfaceindices[(ptr << 1) + 2];
	    if (ptr != head) {
		goto L210;
	    }
/* L220: */
	}
    }

/*     If cut face is double occurring, set all faces to belong to */
/*     polyhedron P. */

    if (! docf) {
	goto L240;
    }
    this->npolh--;
    facesdata[this->nface * 3 + 3] = -(*p);
    tailp = polyhedronfaceindices[((this->n_polyhedronfaces-1) << 1) + 2];
    polyhedronfaceindices[((this->n_polyhedronfaces-1) << 1) + 2] = this->n_polyhedronfaces;
    ptr = this->n_polyhedronfaces;
L230:
    sf = polyhedronfaceindices[(ptr << 1) + 1];
    f = abs(sf);
    if (sf * facesdata[f * 3 + 2] > 0) {
	facesdata[f * 3 + 2] = i_sign(*p, sf);
    } else {
	facesdata[f * 3 + 3] = -(*p);
    }
    if (polyhedronfaceindices[(ptr << 1) + 2] != this->n_polyhedronfaces) {
	ptr = polyhedronfaceindices[(ptr << 1) + 2];
	goto L230;
    } else {
	polyhedronfaceindices[(ptr << 1) + 2] = tailp;
    }

L240:
    IVP_IF(1) {
	IVP_IFDEBUG(IVP_DM_GEOMPACK_LEVEL2) {
	    ivp_debugmanager.dprint(IVP_DM_GEOMPACK_LEVEL2, "Cut face: #edges, polyh(1:2) = %d %d %d\n", (*nce), facesdata[this->nface * 3 + 2], facesdata[this->nface * 3 + 3]);
	    i__1 = *nce;
	    for (i__ = 1; i__ <= i__1; ++i__) {
		la = faceverticeslist[(nv + i__) * 6 + 1];
		ivp_debugmanager.dprint(IVP_DM_GEOMPACK_LEVEL2, " %d %d ", i__, la);
		for (j = 1; j <= 3; ++j) {
		    ivp_debugmanager.dprint(IVP_DM_GEOMPACK_LEVEL2, "%f ", vcl[j + la * 3]);
		}
		ivp_debugmanager.dprint(IVP_DM_GEOMPACK_LEVEL2, "\n");

	    }
	    ivp_debugmanager.dprint(IVP_DM_GEOMPACK_LEVEL2, "\n");
	}
    }

    return;
}

⌨️ 快捷键说明

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