bool restoringTest(const vector<int>& bfs, const vector<int>& dfs) { Tree tree = buildTree(bfs, dfs); cout << tree; Tree::Iterator dfsIterator = tree.getDFSIterator(); Tree::Iterator bfsIterator = tree.getBFSIterator(); vector<int> bfsTraverse, dfsTraverse; while(true) { if(*dfsIterator < 0) break; bfsTraverse.push_back(*bfsIterator); dfsTraverse.push_back(*dfsIterator); dfsIterator++; bfsIterator++; } cout << "new bfs: "; p_v(bfsTraverse); cout << "new dfs: "; p_v(dfsTraverse); return (bfs == bfsTraverse) && (dfs == dfsTraverse); }
void gouradFill(int s, int e, int y, Edge line1, Edge line2, int oct, int plane, Surface ob, Point view, float* buffer) { Vector3 tempcolor(1,1,1); Vector3 inten_left, inten_right, i1, i2, color; float y1, y2, x1, x2; int start, end; if (s > e) { start = e; end = s; if (plane == XY) { y1 = flatlist[oct].pl[line2.p1 - 1].y; y2 = flatlist[oct].pl[line2.p2 - 1].y; } else if (plane == XZ) { y1 = flatlist[oct].pl[line2.p1 - 1].z; y2 = flatlist[oct].pl[line2.p2 - 1].z; } else if (plane == YZ) { y1 = flatlist[oct].pl[line2.p1 - 1].z; y2 = flatlist[oct].pl[line2.p2 - 1].z; } i1 = flatlist[oct].pl[line2.p1 - 1].ip; i2 = flatlist[oct].pl[line2.p2 - 1].ip; inten_left = i1 * ((y - y2) / (y1 - y2)) + i2 * ((y - y1) / (y2 - y1)); //if (oct == 1) cout << i1 << " " << i2 << " "; if (plane == XY) { y1 = flatlist[oct].pl[line1.p1 - 1].y; y2 = flatlist[oct].pl[line1.p2 - 1].y; } else if (plane == XZ) { y1 = flatlist[oct].pl[line1.p1 - 1].z; y2 = flatlist[oct].pl[line1.p2 - 1].z; } else if (plane == YZ) { y1 = flatlist[oct].pl[line1.p1 - 1].z; y2 = flatlist[oct].pl[line1.p2 - 1].z; } i1 = flatlist[oct].pl[line1.p1 - 1].ip; i2 = flatlist[oct].pl[line1.p2 - 1].ip; inten_right = i1 * ((y - y2) / (y1 - y2)) + i2 * ((y - y1) / (y2 - y1)); } else { start = s; end = e; if (plane == XY) { y1 = flatlist[oct].pl[line1.p1 - 1].y; y2 = flatlist[oct].pl[line1.p2 - 1].y; } else if (plane == XZ) { y1 = flatlist[oct].pl[line1.p1 - 1].z; y2 = flatlist[oct].pl[line1.p2 - 1].z; } else if (plane == YZ) { y1 = flatlist[oct].pl[line1.p1 - 1].z; y2 = flatlist[oct].pl[line1.p2 - 1].z; } i1 = flatlist[oct].pl[line1.p1 - 1].ip; i2 = flatlist[oct].pl[line1.p2 - 1].ip; inten_left = i1 * ((y - y2) / (y1 - y2)) + i2 * ((y - y1) / (y2 - y1)); if (plane == XY) { y1 = flatlist[oct].pl[line2.p1 - 1].y; y2 = flatlist[oct].pl[line2.p2 - 1].y; } else if (plane == XZ) { y1 = flatlist[oct].pl[line2.p1 - 1].z; y2 = flatlist[oct].pl[line2.p2 - 1].z; } else if (plane == YZ) { y1 = flatlist[oct].pl[line2.p1 - 1].z; y2 = flatlist[oct].pl[line2.p2 - 1].z; } i1 = flatlist[oct].pl[line2.p1 - 1].ip; i2 = flatlist[oct].pl[line2.p2 - 1].ip; inten_right = i1 * ((y - y2) / (y1 - y2)) + i2 * ((y - y1) / (y2 - y1)); } float ndotv, ndotl; Vector3 normal(ob.normx, ob.normy, ob.normz); Vector3 p_v(0,0,0); Vector3 v_v; Vector3 l_v; for (int x = start; x < end; x++) { x1 = start; x2 = end; color = inten_left * ((x - x2) / (x1 - x2)) + inten_right * ((x - x1) / (x2 - x1)); if ((ndotl > 0 && ndotv > 0) || (ndotl < 0 && ndotv < 0)) { colorPoint(x, y, color, buffer); } else { colorPoint(x, y, color, buffer); } } }