Hi, Im currently implimenting a nested for loop, but there seems to have some known bugs and i dont know whats causing it , how to fix it, etc.
Heres part of my code:
//using some of vector<structs> below:
void Profile()
{
int wire = 1;
int face = 1;
int i = 0;
int j = 0;
int index;
bool startcheck = true;
gp_Pnt end; //a sort of struct like, have x, y and z member.
gp_Pnt2d start; //similar above, but 2 members
end.SetCoord(0,0,0);//initialize the pnt. ie. set all member values to 0
//for(int i = 0; i < urange.size();i++)//urange is just a vector struct
while(i < urange.size())
{
if (startcheck == true)//check if is first time entering
{
start.SetCoord( Contour[urange[end.Z()].EdgeStartIndex].u, //save
Contour[urange[end.Z()].EdgeStartIndex].v);
startcheck = false;
}
for(int j= 0; j < urange[end.Z()].NbPoints; j++)//the number of time
{//this loop loops is varying depending on what is in variable end
ProfileStore(j, wire, face);//store some information
if((start.X()==end.X())&&(start.Y()==end.Y()))//test condition
{//condition:check if two values match.if match, wanna go back to the while loop but with i incremented.
wire++;
startcheck == true;
i++;
continue;
}
else if (j == (urange[end.Z()].NbPoints - 1))//the last value
{//the ProfileFindNextStart(a,b) function will return values that determines how many times the for loop will be looped
index = urange[end.Z()].EdgeStartIndex + j;
end = ProfileFindNextStart(Contour[index].u, Contour[index].v);
//continue;
i++;
}
}
}
}
Im pretty sure i have check the variables are passed correctly,
the problem now is that everything is good when the first time the for loop is entered. but when second time the for loop is entered. THE COUNT OF J IS NOT STARTING FROM ZERO!!! it seems like the j didnt got set.
i.e. for loop looped 4 times when i = 0; gud. nothing wrong with that.
but looped 11-4=7 times when i =1; which is supposed to loop 11 times, but looped 7 times instead and it shows that the count starts from 4 when i was trying to print out to screen.
Anyone know whats causing it? and how to fix it?
Thanks
Kent