bool Contour::findNextTriangle( double z, int t1, int e1, int& t2, int& e2, DT_Point& p ) { // 已达到边界 if( t1 == -1 ) return false; // 对第i个三角形的另外2条边进行检查并插值 e2 = getNextEdge( t1, e1 ); if( isNextTriangleUsed( t1, e2 ) || !hasContourPoint( z, e2 ) ) { e2 = getNextEdge( t1, e2 ); if( isNextTriangleUsed( t1, e2 ) || !hasContourPoint( z, e2 ) ) { return false; } } // 将当前的三角形的标记为已使用 getTriangleObject( t1 )->used = true; // 将三角形的编号进行转换 t2 = getNextTriangle( e2, t1 ); // 对边e2线性插值 linearInterpolate( z, e2, p ); return true; }
bool Contour::isNextTriangleUsed( int ti, int ei ) const { //if(getTriangleObject(ti)->used) return false; ti = getNextTriangle( ei, ti ); if( ti == -1 ) return false; else return ( getTriangleObject( ti )->used ); }
Triangle *getNextTriangle() { if (curface == input_mesh->totface) return 0; Triangle *t = new Triangle(); unsigned int *f = GET_FACE(input_mesh, curface); if (offset == 0) { veccopy(t->vt[0], GET_CO(input_mesh, f[0])); veccopy(t->vt[1], GET_CO(input_mesh, f[1])); veccopy(t->vt[2], GET_CO(input_mesh, f[2])); } else { veccopy(t->vt[0], GET_CO(input_mesh, f[2])); veccopy(t->vt[1], GET_CO(input_mesh, f[3])); veccopy(t->vt[2], GET_CO(input_mesh, f[0])); } if (offset == 0 && f[3]) offset++; else { offset = 0; curface++; } /* remove triangle if it contains invalid coords */ for (int i = 0; i < 3; i++) { const float *co = t->vt[i]; if (isnan(co[0]) || isnan(co[1]) || isnan(co[2])) { delete t; return getNextTriangle(); } } return t; }