Thanks for replying guys,
Yeah, I agree that my while-loop is unnecessarily complicated.
I had the a for-loop like the first first reply, but that wasn't working. I was thinking that maybe my indexing was going outside of the number of elements, so I changed it to only access the 0th element because that should always be there, but I hit the same problem either way.
I also tried inserting all the faces at once, but I hit the same error.
The error that I get while running it refers me to this:
if (size() <= _Pos)
{ // report error
_DEBUG_ERROR("vector subscript out of range");
////error told me to refer the above line.
_SCL_SECURE_OUT_OF_RANGE;
}
It doesn't tell me which line causes the error but I limited it down to the original problem line (line 3 in my original post), whether I use the for-loop, while-loop, or the temp.insert line when I tried that outside of the loop.
And with all of the attempts, it's the same scenario: there's only an error if the number of faces in the DetectedFaces vector is over one.