Jump to content
  • Advertisement
Sign in to follow this  
Antonym

Resize Quirk

This topic is 3208 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I get a vector iterator outside of range on the following line of code. iPEQuantity's size is 4.
	m_kSPositions.resize(iPEQuantity);

These are the definitions.
std::vector<Vector2<Real> >m_kSPositions;


namespace Wm4
{

template <class Real>
class Vector2
{
public:
    // construction
    Vector2 ();  // uninitialized
    Vector2 (Real fX, Real fY);
    Vector2 (const Real* afTuple);
    Vector2 (const Vector2& rkV);
//Other functions..

Should mCount be 1238684?
	void _Insert_n(const_iterator _Where,
		size_type _Count, const _Ty& _Val)
		{	// insert _Count * _Val at _Where

Share this post


Link to post
Share on other sites
Advertisement
The value of simplePolygon is [0]() which is odd. If I try to retrieve the values it works though.

Wm4::TriangulateEC<Real>::Positions simplePolygon;

Wm4::Vector2<Real> vec2(1,0);
simplePolygon.push_back(vec2);
Wm4::Vector2<Real> vec3(0,-1);
simplePolygon.push_back(vec3);
Wm4::Vector2<Real> vec4(1,-1);
simplePolygon.push_back(vec4);
Wm4::Vector2<Real> vec5(3,1);
simplePolygon.push_back(vec5);

Wm4::TriangulateEC<Real>::Indices tIndices;

Wm4::TriangulateEC<Real>::TriangulateEC(simplePolygon,Wm4::Query::QT_RATIONAL,0,tIndices);







TriangulateEC<Real>::TriangulateEC (const Positions& rkPositions,
Query::Type eQueryType, Real fEpsilon, Indices& rkTriangles)
{
// No extra elements are needed for triangulating a simple polygon.
InitializePositions(rkPositions,eQueryType,fEpsilon,0);

// Triangulate the unindexed polygon.
int iVQuantity = (int)rkPositions.size();
const int* aiIndex = 0;
InitializeVertices(iVQuantity,aiIndex);
DoEarClipping(iVQuantity,aiIndex,rkTriangles);
}







template <class Real>
void TriangulateEC<Real>::InitializePositions (const Positions& rkPositions,
Query::Type eQueryType, Real fEpsilon, int iExtraElements)
{
int iPQuantity = (int)rkPositions.size();
assert(iPQuantity >= 3);
int iPEQuantity = iPQuantity + iExtraElements;
m_kSPositions.resize(iPEQuantity);//ERROR

if (eQueryType == Query::QT_FILTERED)
{
assert((Real)0.0 <= fEpsilon && fEpsilon <= (Real)1.0);
}

Vector2<Real> kMin, kMax, kRange;
Real fScale, fRMax;
int i;





[/source]

Share this post


Link to post
Share on other sites
What are you talking about? That doesn't look like remotely related code. (Your variable names don't really help.)

Quote:
Show the code where you use the vector of Vector2 objects.


I thought it was clear that I was talking about std::vector<Vector2<Real> >m_kSPositions;. I'm sure you do something with it other than just attempt to .resize() it - it'd be pretty useless that way.

Also, this:

Wm4::TriangulateEC<Real> triangulate(simplePolygon,Wm4::Query::QT_RATIONAL,0,tIndices);


is not a function call. It's either a function declaration, or a constructor call (but why would you have a variable named "triangulate"?).

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!