Public Group

# Resize Quirk

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

## 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 on other sites
Show the code where you use the vector of Vector2 objects.

##### 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 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"?).

Code updated.

##### Share on other sites
So you're only constructing m_kSPositions and then resizing it? If so, I would just get rid of it.

1. 1
2. 2
3. 3
Rutin
18
4. 4
5. 5
JoeJ
13

• 9
• 14
• 10
• 25
• 9
• ### Forum Statistics

• Total Topics
632645
• Total Posts
3007628
• ### Who's Online (See full list)

There are no registered users currently online

×