Sign in to follow this  
Antonym

Resize Quirk

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
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this