int GroupPlace = -1;// holds the current place in alGroups
for (unsigned int i = 0; i<curVec.size(); i++) {
unsigned int Crunchy = 0;// holds the total size of curVec for the final end guard
bool NeedNewGroup = true;// the check to see if another LineGroup is needed
bool Added = false;// the check to see if something was added
vector<Coord> :: iterator it;// iterator or the insert
while (Crunchy < curVec[i].size()) {
if (NeedNewGroup == true) {// if we need a new group add one
allGroups.push_back( *(new LineGroup));// push a new plank one
GroupPlace++;// increment the place
NeedNewGroup = false;// dont need a new group anymore
}
for (unsigned int j = 0; j<curVec[i].size(); j++) {
if (allGroups[GroupPlace].coords.size() == 0) {// if this is the first go set the stuff in the LineGroup
allGroups[GroupPlace].slope=curVec[i][j].slope();
allGroups[GroupPlace].First=curVec[i][j].pt1;
allGroups[GroupPlace].Last=curVec[i][j].pt2;
allGroups[GroupPlace].coords.push_back(curVec[i][j].pt1);
allGroups[GroupPlace].coords.push_back(curVec[i][j].pt2);
curVec[i][j].slopeAdded = true;
Added = true;
Crunchy++;
}
if (curVec[i][j].slopeAdded != true) {// if it isnt added go go go!!!!
//set the shit out of the First, Last, and append the coords vector
if (curVec[i][j].pt1 == allGroups[GroupPlace].First) {
it = allGroups[GroupPlace].coords.begin();
it = allGroups[GroupPlace].coords.insert (it, curVec[i][j].pt2);
allGroups[GroupPlace].First = curVec[i][j].pt2;
curVec[i][j].slopeAdded = true;
Added = true;
Crunchy++;
}
else if (curVec[i][j].pt2 == allGroups[GroupPlace].First) {
it = allGroups[GroupPlace].coords.begin();
it = allGroups[GroupPlace].coords.insert (it, curVec[i][j].pt1);
allGroups[GroupPlace].First = curVec[i][j].pt1;
curVec[i][j].slopeAdded = true;
Added = true;
Crunchy++;
}
else if (curVec[i][j].pt1 == allGroups[GroupPlace].Last) {
allGroups[GroupPlace].coords.push_back(curVec[i][j].pt2);
allGroups[GroupPlace].Last = curVec[i][j].pt2;
curVec[i][j].slopeAdded = true;
Added = true;
Crunchy++;
}
else if (curVec[i][j].pt2 == allGroups[GroupPlace].Last) {
allGroups[GroupPlace].coords.push_back(curVec[i][j].pt1);
allGroups[GroupPlace].Last = curVec[i][j].pt1;
curVec[i][j].slopeAdded = true;
Added = true;
Crunchy++;
}
else{
Crunchy++;
}
}
if (Added == false) {// if nothing was added in a round of adds, we need a new group, also jon dont break here!!!!!!!!!! it means your doom!
NeedNewGroup = true;
}
}
}
}
}