www.pudn.com > tr4all.rar > lines3h.h
//Copyright(c)2004 Alexander Kadyrov // different form line2h.h by using Peano indexing at the end: // see comments "the 1st only difference from line2h.h" // "the 2nd only difference from line2h.h" const int dg=12,BN=1<it_end Count1=it_end-it_beg; // Going to fine coordinates: xB=round((cX+xbase)*BN)+xB_inc*it_beg+BN2; yB=round((cY+ybase)*BN)+yB_inc*it_beg+BN2; (*Ends++)=it_beg; (*Ends++)=it_end; (*Ends++)=xB; (*Ends++)=yB; ends[e++]=xB+xB_inc*Count1; ends[e++]=yB+yB_inc*Count1; ends[e++]=it_beg; ends[e++]=it_end; } np=0; {xbase=0,ybase=0; //the nearest point in the track line to the center of the image // the track line equations: x=xbase+t*ort1;y=ybase+t*ort2; // track line intercects vertical lines x= (+-)xszHeps : t_vert_2=(-xszHe-xbase)/ort1;t_vert_1=(xszHe-xbase)/ort1; // track line intercects horizontal lines y= (+-)yszH : t_hori_1=(-yszHe-ybase)/ort2;t_hori_2=(yszHe-ybase)/ort2; t1=maxD(t_vert_1,t_hori_1),t2=minD(t_vert_2,t_hori_2); //- from t1 to t2 real track line goes. it_beg=int (ceil(t1/dt)),it_end=int (floor(t2/dt));//it may happen it_beg>it_end //Count1=it_end-it_beg; // Going to fine coordinates: xB=round((cX+xbase)*BN)+xB_inc*it_beg+BN2; yB=round((cY+ybase)*BN)+yB_inc*it_beg+BN2; (*Ends++)=it_beg; (*Ends++)=it_end; (*Ends++)=xB; (*Ends++)=yB; } for (np=1;np<=Np;np++) { (*Ends++)=it_beg=-ends[--e]; (*Ends++)=it_end=-ends[--e]; //Count1=it_end-it_beg; yB= ySizeBN-ends[--e]; xB= xSizeBN-ends[--e];//"+BN" =+2*BN2, it is due to rounding (*Ends++)=xB; (*Ends++)=yB; } }///for (nfi=1;nfi it_end yB=round((cY+ybase)*BN)+rem2; // -going to fine coordinates (*Ends++)=it_beg; (*Ends++)=it_end; (*Ends++)=xB; (*Ends++)=yB; } Ends=EndsTemp; return Ends; }//END.int *allEnds( ///************** MAKE SET OF ALL TRACING LINES //Format (int or unsigned short int)*rulelines: // nfi=0,number_of_trace_lines_for_this_nfi, // first_line_start_index_t,first_line_finish_index_t, //Format int*lines: coordinate1,coordinate2,.. //Format (int or unsigned short int)*rulelines: // second_line_start_index_t,second_line_finish_index_t, //Format int*lines: coordinate1,coordinate2,.. // ... // nfi=1,... // nfi=Npi4*2-1,... //******************************************************************* #define comment_alllines #ifndef comment_alllines void alllines(int *Ends,int Nfi4,int xSize, int *rulelines,int *lines,int Enfi1) { // if not USEPEANO or ROTATING_BOX, this must be reconsidere // By now we do not use this function since it seems does not speed up (as it was intended) int E=0,rl=0,l=0,nfi,NP,it_beg,it_end,xB,yB,Count,it,xSizeBN=xSize*BN, xB_inc,yB_inc,np; for (nfi=0;nfi<=Nfi4;nfi++) { rulelines[rl++]=Ends[E++];// - nfi here NP=rulelines[rl++]=Ends[E++];// - NP=2*Np+1 - number of lines for given fi xB_inc=Ends[E++];yB_inc=Ends[E++]; for (np=0;np 0;it--) // line is traced: { //lines[l++]=(xB>>dg)+xSize*(yB>>dg); /* NPV(xB)PVN(dg)PS("check : xB>0?")PAU int X=xB>>dg,Y=yB>>dg;if ((X<0)||(X>400)||(Y<0)||(Y>200)) PAUSE(" ???lines3h,1Quad Wants a pixel out of image"); */ lines[l++]=dilute[xB>>dg]+dilute0[yB>>dg]; //"the 1st only difference from line2h.h" // the coordinated are X=xB>>dg;Y=yB>>dg; xB += xB_inc; yB += yB_inc; } }//for (np }//for (nfi= E=Enfi1; int Nfi=2*Nfi4; for (nfi=Nfi-1;nfi>Nfi4;nfi--)//nfi is in reverse order { rulelines[rl++]=Nfi-Ends[E++]; // should be nfi NP=rulelines[rl++]=Ends[E++]; // should be NP=2*Np+1 xB_inc=Ends[E++];yB_inc=-Ends[E++]; for (np=0;np 0;it--) // line is traced: { //NPV(NP)PV(Count)PV(xB)PV(yB)PVN(dg)PAU PAUSE("check lines3h 2Quad"); // int X=xB>>dg,Y=yB>>dg;if ((X<0)||(X>400)||(Y<0)||(Y>200)) // PAUSE(" ???lines3h,2Quad Wants a pixel out of image"); //lines[l++]=(xB>>dg)+xSize*(yB>>dg); lines[l++]=dilute[xB>>dg]+dilute0[yB>>dg]; //"the 2nd only difference from line2h.h" // the coordinated are X=xB>>dg;Y=yB>>dg; xB += xB_inc; yB += yB_inc; } }//for (p }//for (nfi= }//END. #endif //comment ////////////////////////////////allEndsRotatingBox //the same: const int dg=12,BN=1<