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

📄 geompack_cutfac.cxx

📁 hl2 source code. Do not use it illegal.
💻 CXX
📖 第 1 页 / 共 3 页
字号:
		    imin = e;
		    dsave[0] = dir1[0];
		    dsave[1] = dir1[1];
		    dsave[2] = dir1[2];
		}
	    }
	}

	if (e == estop) {
	    goto L40;
	}
	la = faceverticeslist[e * 6 + 1];
	lb = faceverticeslist[faceverticeslist[e * 6 + 3] * 6 + 1];
	if ((lb - la) * sf > 0) {
	    e = faceverticeslist[e * 6 + 6];
	} else {
	    e = faceverticeslist[e * 6 + 5];
	}
	f = faceverticeslist[e * 6 + 2];
	dof = (i__1 = facesdata[f * 3 + 2], abs(i__1)) == (i__2 = facesdata[f * 3 + 3]
		, abs(i__2));
	if (dof) {
	    l = faceverticeslist[e * 6 + 1];
	    if (l == la) {
		sf = -sf;
	    }
	} else if ((i__1 = facesdata[f * 3 + 2], abs(i__1)) == *p) {
	    sf = facesdata[f * 3 + 2];
	} else {
	    sf = facesdata[f * 3 + 3];
	}
	if (sf > 0) {
	    ee = faceverticeslist[e * 6 + 4];
	    la = faceverticeslist[faceverticeslist[e * 6 + 3] * 6 + 1];
	    lb = faceverticeslist[ee * 6 + 1];
	} else {
	    ee = faceverticeslist[e * 6 + 3];
	    la = faceverticeslist[e * 6 + 1];
	    lb = faceverticeslist[faceverticeslist[ee * 6 + 3] * 6 + 1];
	}
	dir1[0] = nrmlc[2] * normals[f * 3 + 3] - nrmlc[3] * normals[f * 3 + 2];
	dir1[1] = nrmlc[3] * normals[f * 3 + 1] - nrmlc[1] * normals[f * 3 + 3];
	dir1[2] = nrmlc[1] * normals[f * 3 + 2] - nrmlc[2] * normals[f * 3 + 1];
/* Computing MAX */
	d__1 = abs(dir1[0]), d__2 = abs(dir1[1]), d__1 = max(d__1,d__2), d__2 
		= abs(dir1[2]);
	if (max(d__1,d__2) <= this->tolerance) {
	    goto L30;
	}
	sgn = 1;
	if ((i__1 = facesdata[f * 3 + 2], abs(i__1)) != *p || dof && sf < 0) {
	    dir1[0] = -dir1[0];
	    dir1[1] = -dir1[1];
	    dir1[2] = -dir1[2];
	    sgn = -1;
	}
	k = 1;
	if ((d__1 = normals[f * 3 + 2], abs(d__1)) > (d__2 = normals[f * 3 + 1], 
		abs(d__2))) {
	    k = 2;
	}
	if ((d__1 = normals[f * 3 + 3], abs(d__1)) > (d__2 = normals[k + f * 3], 
		abs(d__2))) {
	    k = 3;
	}
	nmax = sgn * normals[k + f * 3];
	de[0] = vcl[la * 3 + 1] - vcl[lw1 * 3 + 1];
	de[1] = vcl[la * 3 + 2] - vcl[lw1 * 3 + 2];
	de[2] = vcl[la * 3 + 3] - vcl[lw1 * 3 + 3];
	dee[0] = vcl[lb * 3 + 1] - vcl[lw1 * 3 + 1];
	dee[1] = vcl[lb * 3 + 2] - vcl[lw1 * 3 + 2];
	dee[2] = vcl[lb * 3 + 3] - vcl[lw1 * 3 + 3];
/* Computing MAX */
	d__1 = abs(de[0]), d__2 = abs(de[1]), d__1 = max(d__1,d__2), d__2 = 
		abs(de[2]), d__1 = max(d__1,d__2), d__2 = abs(dee[0]), d__1 = 
		max(d__1,d__2), d__2 = abs(dee[1]), d__1 = max(d__1,d__2), 
		d__2 = abs(dee[2]);
	ntol = this->tolerance * max(d__1,d__2);
	if (k == 1) {
	    cp[0] = de[1] * dee[2] - de[2] * dee[1];
	} else if (k == 2) {
	    cp[1] = de[2] * dee[0] - de[0] * dee[2];
	} else {
	    cp[2] = de[0] * dee[1] - de[1] * dee[0];
	}
	if ((d__1 = cp[k - 1], abs(d__1)) <= ntol || cp[k - 1] * nmax > 0.) {
	    if (k == 1) {
		cp[0] = de[1] * dir1[2] - de[2] * dir1[1];
	    }
	    if (k == 2) {
		cp[1] = de[2] * dir1[0] - de[0] * dir1[2];
	    }
	    if (k == 3) {
		cp[2] = de[0] * dir1[1] - de[1] * dir1[0];
	    }
	    if ((d__1 = cp[k - 1], abs(d__1)) <= ntol || cp[k - 1] * nmax < 
		    0.) {
		goto L30;
	    }
	    if (k == 1) {
		cp[0] = dir1[1] * dee[2] - dir1[2] * dee[1];
	    }
	    if (k == 2) {
		cp[1] = dir1[2] * dee[0] - dir1[0] * dee[2];
	    }
	    if (k == 3) {
		cp[2] = dir1[0] * dee[1] - dir1[1] * dee[0];
	    }
	    if ((d__1 = cp[k - 1], abs(d__1)) <= ntol || cp[k - 1] * nmax < 
		    0.) {
		goto L30;
	    }
	} else {
	    if (k == 1) {
		cp[0] = dir1[1] * de[2] - dir1[2] * de[1];
	    }
	    if (k == 2) {
		cp[1] = dir1[2] * de[0] - dir1[0] * de[2];
	    }
	    if (k == 3) {
		cp[2] = dir1[0] * de[1] - dir1[1] * de[0];
	    }
	    if ((d__1 = cp[k - 1], abs(d__1)) <= ntol || cp[k - 1] * nmax > 
		    0.) {
		if (k == 1) {
		    cp[0] = dee[1] * dir1[2] - dee[2] * dir1[1];
		}
		if (k == 2) {
		    cp[1] = dee[2] * dir1[0] - dee[0] * dir1[2];
		}
		if (k == 3) {
		    cp[2] = dee[0] * dir1[1] - dee[1] * dir1[0];
		}
		if ((d__1 = cp[k - 1], abs(d__1)) <= ntol || cp[k - 1] * nmax 
			> 0.) {
		    goto L30;
		}
	    }
	}
/* Computing 2nd power */
	d__1 = dir1[0];
/* Computing 2nd power */
	d__2 = dir1[1];
/* Computing 2nd power */
	d__3 = dir1[2];
	dir1sq = d__1 * d__1 + d__2 * d__2 + d__3 * d__3;
	dotp = -(dir[0] * dir1[0] + dir[1] * dir1[1] + dir[2] * dir1[2]) / 
		sqrt(dirsq * dir1sq);
	if (abs(dotp) > 1. - this->tolerance) {
	    dotp = d_sign(1.0, dotp);
	}
	if (kmax == 1) {
	    cp[0] = dir[1] * dir1[2] - dir[2] * dir1[1];
	} else if (kmax == 2) {
	    cp[1] = dir[2] * dir1[0] - dir[0] * dir1[2];
	} else {
	    cp[2] = dir[0] * dir1[1] - dir[1] * dir1[0];
	}
/* Computing MAX */
	d__2 = abs(dir[0]), d__3 = abs(dir[1]), d__2 = max(d__2,d__3), d__3 = 
		abs(dir[2]), d__2 = max(d__2,d__3), d__3 = abs(dir1[0]), d__2 
		= max(d__2,d__3), d__3 = abs(dir1[1]), d__2 = max(d__2,d__3), 
		d__3 = abs(dir1[2]);
	if ((d__1 = cp[kmax - 1], abs(d__1)) <= this->tolerance * max(d__2,d__3))
		 {
	    intang = IVP_PI;
	} else if (cp[kmax - 1] * nrmlc[kmax] > 0.) {
	    intang = acos(dotp);
	} else {
	    intang = pi2 - acos(dotp);
	}
	if (intang < iamin) {
	    iamin = intang;
	    imin = -f;
	    ccwfl = sf;
	    dsave[0] = dir1[0];
	    dsave[1] = dir1[1];
	    dsave[2] = dir1[2];
	}
L30:
	e = ee;
	goto L20;

L40:
	if (imin == 0) {
/* 	       IERR = 325 */
	    return;
	} else if (imin > 0) {
	    dir[0] = dsave[0];
	    dir[1] = dsave[1];
	    dir[2] = dsave[2];
	    lw = lw1;
	    la = faceverticeslist[imin * 6 + 1];
	    lb = faceverticeslist[faceverticeslist[imin * 6 + 3] * 6 + 1];
	    if (la == lw1) {
		lw1 = lb;
	    } else {
		lw1 = la;
	    }
	    ++(*nce);
	    cedge[(*nce << 1) + 1] = lw1;
	    cedge[(*nce << 1) + 2] = imin;
	    fl = faceverticeslist[imin * 6 + 2];
	    dof = (i__1 = facesdata[fl * 3 + 2], abs(i__1)) == (i__2 = facesdata[fl * 
		    3 + 3], abs(i__2));
	    if (dof) {
		if (la == lw) {
		    ccwfl = -(*p);
		} else {
		    ccwfl = *p;
		}
	    } else if ((i__1 = facesdata[fl * 3 + 2], abs(i__1)) == *p) {
		ccwfl = facesdata[fl * 3 + 2];
	    } else {
		ccwfl = facesdata[fl * 3 + 3];
	    }
	    if ((lb - la) * ccwfl > 0) {
		fr = faceverticeslist[faceverticeslist[imin * 6 + 6] * 6 + 2];
	    } else {
		fr = faceverticeslist[faceverticeslist[imin * 6 + 5] * 6 + 2];
	    }
	    k = 1;
L50:
	    if (pedge[k * 3 + 1] == imin || pedge[k * 3 + 2] == imin) {
		for (i__ = 1; i__ <= 3; ++i__) {
		    j = pedge[i__ + k * 3];
		    pedge[i__ + k * 3] = pedge[i__ + *nedgc * 3];
		    pedge[i__ + *nedgc * 3] = j;
/* L60: */
		}
		--(*nedgc);
	    } else {
		++k;
		goto L50;
	    }
	    goto L110;
	} else {
	    dir[0] = dsave[0];
	    dir[1] = dsave[1];
	    dir[2] = dsave[2];
	    fl = -imin;
	    goto L70;
	}
    }

/*        Determine LW1 from direction DIR in interior of face FL. */

L70:
    lw = lw1;
    fr = 0;
    imin = 0;
    tmin = 0.;
    k = 1;
    if (abs(dir[1]) > abs(dir[0])) {
	k = 2;
    }
    if (abs(dir[2]) > (d__1 = dir[k - 1], abs(d__1))) {
	k = 3;
    }
    ntol = this->tolerance * (d__1 = dir[k - 1], abs(d__1));
    i__1 = *nedgc;
    for (i__ = 1; i__ <= i__1; ++i__) {
	e = pedge[i__ * 3 + 1];
	ee = pedge[i__ * 3 + 2];
	if (faceverticeslist[e * 6 + 2] == fl) {
	    a = e;
	} else if (faceverticeslist[ee * 6 + 2] == fl) {
	    a = ee;
	} else {
	    goto L80;
	}
	ca = pedge[i__ * 3 + 3] / 10;
	cb = pedge[i__ * 3 + 3] % 10;
	if (ca == 2) {
	    la = faceverticeslist[a * 6 + 1];
	    if (cb == 2) {
		lb = faceverticeslist[faceverticeslist[a * 6 + 3] * 6 + 1];
		s = (vcl[k + la * 3] - vcl[k + lw * 3]) / dir[k - 1];
		t = (vcl[k + lb * 3] - vcl[k + lw * 3]) / dir[k - 1];
		if (s > 0.) {
		    if (min(s,t) < tmin || imin == 0) {
			if (s < t) {
			    if (ccwfl < 0) {
				imin = a;
				lw1 = la;
				tmin = s;
			    }
			} else {
			    if (ccwfl > 0) {
				imin = a;
				lw1 = lb;
				tmin = t;
			    }
			}
		    }
		}
	    } else {
		l = faceverticeslist[e * 6 + 1];
		if (l == la && ccwfl < 0 || l != la && ccwfl > 0) {
		    t = (vcl[k + l * 3] - vcl[k + lw * 3]) / dir[k - 1];
		    if (t > ntol) {
			if (t < tmin || imin == 0) {
			    lw1 = l;
			    imin = a;
			    tmin = t;
			}
		    }
		}
	    }
	} else if (cb == 2) {
	    la = faceverticeslist[a * 6 + 1];
	    l = faceverticeslist[faceverticeslist[e * 6 + 3] * 6 + 1];
	    if (l == la && ccwfl < 0 || l != la && ccwfl > 0) {
		t = (vcl[k + l * 3] - vcl[k + lw * 3]) / dir[k - 1];
		if (t > ntol) {
		    if (t < tmin || imin == 0) {
			lw1 = l;
			imin = a;
			tmin = t;
		    }
		}
	    }
	} else {
	    la = faceverticeslist[e * 6 + 1];
	    lb = faceverticeslist[faceverticeslist[e * 6 + 3] * 6 + 1];
	    dir1[0] = vcl[la * 3 + 1] - vcl[lb * 3 + 1];
	    dir1[1] = vcl[la * 3 + 2] - vcl[lb * 3 + 2];
	    dir1[2] = vcl[la * 3 + 3] - vcl[lb * 3 + 3];
	    rhs[0] = vcl[la * 3 + 1] - vcl[lw * 3 + 1];
	    rhs[1] = vcl[la * 3 + 2] - vcl[lw * 3 + 2];
	    rhs[2] = vcl[la * 3 + 3] - vcl[lw * 3 + 3];
	    cp[0] = dir[1] * dir1[2] - dir[2] * dir1[1];
	    cp[1] = dir[2] * dir1[0] - dir[0] * dir1[2];
	    cp[2] = dir[0] * dir1[1] - dir[1] * dir1[0];
	    l = 1;
	    if (abs(cp[1]) > abs(cp[0])) {
		l = 2;
	    }
	    if (abs(cp[2]) > (d__1 = cp[l - 1], abs(d__1))) {
		l = 3;
	    }
	    if (l == 1) {
		t = (rhs[1] * dir1[2] - rhs[2] * dir1[1]) / cp[0];
	    } else if (l == 2) {
		t = (rhs[2] * dir1[0] - rhs[0] * dir1[2]) / cp[1];
	    } else {
		t = (rhs[0] * dir1[1] - rhs[1] * dir1[0]) / cp[2];
	    }
	    if (t > ntol) {
		if (t < tmin || imin == 0) {
		    imin = -a;
		    tmin = t;
		    isave = i__;
		}
	    }
	}

⌨️ 快捷键说明

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