Esempio n. 1
0
void CttView::ADTFill(const COLORREF color){
	if (m_point.size() <= 2)return;
	CDC* pDC = GetWindowDC();
	CPen pen1(0, 0, color);
	pDC->SelectObject(&pen1);
	int start, end, msz=m_point.size();
	start = 10000;
	end = 0;
	for (int i = 0; i < msz; i++){
		start = min(start, m_point[i].y);
		end = max(end, m_point[i].y);
	}
	vector<EdgeTable> net(end+1);
	net.assign(end + 1, EdgeTable());
	Edge te;
	int miny;
	for (int i = 0; i < msz-1; i++){
		te = Edge(m_point[i], m_point[i + 1], miny);
		net[miny].Add(te);
	}
	te = Edge(m_point[msz-1], m_point[0], miny);
	net[miny].Add(te);
	
	EdgeTable adt = EdgeTable(start);
	for (int i = start; i <= end; i++){
		for (int j = 0; j < net[i].e.size(); j++)
			adt.Add(net[i].e[j]);
		for (int j = 1; j < adt.e.size(); j += 2){
			pDC->MoveTo((int)adt.e[j-1].x0, i);
			pDC->LineTo((int)adt.e[j].x0, i);
		}
		adt.Update();
	}
}
Esempio n. 2
0
void SCANLINE::pixelCompute()
{
    ///------------Illumination Model-------------------------
    Compute_Poly_Normal(); //compute normal of all polygon

    ///-------------------------------------

    vector< vector<float> > Ycompare;
    vector< vector<float> > nearVertex;
    vector< vector<float> > startVertex;
    for(int poly_num = 0; poly_num< (int)front_Poly.size();poly_num++)
    {
        Ycompare.clear();
        nearVertex.clear();
        startVertex.clear();
        //compute edge table
        //put y value and vertex index in Ycompare
        //sort by y value - buble sort
        get_Ycompare(Ycompare,poly_num);
        //find near vertices around start vertices

        find_near_vertex(nearVertex,startVertex,Ycompare,poly_num);

        EdgeTable(startVertex,nearVertex,
                       front_Poly,poly_num);
    }//end poly_num loop

    Compute_pixel_intensity();//compute Intensity on each pixel

}