Hi.
Actually this is a function which takes in points, triangulates them, makes faces and then copies it into the vector which is a private member of mesh.
Hence to copy in vector using push_back (which is a reference copy) i need to create a new object of face and then copy it into the vector. Thats the reason I was using "new".
Yes, though i create a pointer , i copy the value , which, according to my meagre knowledge, should work because its just copying the reference.
1 2 3 4 5 6 7 8 9 10 11 12 13
|
int Mesh::triangulatePtsAddFace(int pointCnt, vector<DsPoint> allPoints)
{
vector<DsPoint>::iterator cntr;
int faceCount = 0;
for (cntr = allPoints.begin(); cntr < allPoints.end() - 2; cntr++)
{
Face *newFace;
newFace = new Face(*allPoints.begin(), *(cntr+1), *(cntr+2));
this->addFace(*newFace);
faceCount++;
}
return faceCount;
}
|
So, I try to delete all the objects created using "new" in the destructor of Mesh.
Is there any other way anyone can think of , of creating these faces other than new in this situation ? I don't want to end up returning values from the function. I already have the no. of faces being returned.
@Disch
The first option seems right. But when i create that Face in a function, does it not get deleted? push_back being reference copy will again give me error. Kindly correct me if I am wrong.
I'll try looking into boost libraries.
Thanks a ton!
navderm