[vtkusers] vtkLineSource::SetPoint not persisting

Charlotte Curtis c.f.curtis at gmail.com
Tue Aug 17 14:04:08 EDT 2010


Hi list,

I've got an odd problem with what *should* be a really simple
operation.  Basically, I've written a series of callbacks in a
wxWidgets/VTK application that is supposed to draw four lines in a
square representing the boundaries of a cropping region.  The actual
cropping process works - I can click and drag a square, hit Enter, and
my image is cropped nicely.  The only glitch is that the lines
themselves don't show up properly.

I've narrowed it down to a problem in setting the points of my four
lines (I'm using a std::vector of vtkLineSource smart pointers).
Here's the problematic code:

int xloop[5] = {0, 2, 2, 0, 0};
int yloop[5] = {1, 1, 3, 3, 1};
double zval = m_bounds[4]-1.0;

for (int i = 0; i < 4; i++)
{
	double pt1[3] = {corners[xloop[i]], corners[yloop[i]], zval};
	double pt2[3] = {corners[xloop[i+1]], corners[yloop[i+1]], zval};
	m_croplines[i]->SetPoint1(pt1);
	m_croplines[i]->SetPoint2(pt2);
	
	m_croplines[i]->Print(std::cout); // correct
}

for (int i = 0; i < 4; i++)
	m_croplines[i]->Print(std::cout); // incorrect!

where "corners" is an array of doubles containing the left, top,
right, and bottom coordinates, and the xloop and yloops just tell me
which coordinates to put in the points of each line.

At the first Print statement (inside the loop), all of the croplines
are set to the correct points.  However, at the second Print
statement, all of the lines are identical (equal to the last set
line).

I've been trying to figure out what's going on here for a while, but
I'm going around in circles.  There's a few other incidental oddities:
1) If I use the SetPoint(double, double, double) method directly
instead of copying the values into the temp values pt1 and pt2, I get
a seg fault when setting Point2 of the last line
2) The lines have an unusually high reference count (5)

I've tried regular pointers instead of smartpointers, and it doesn't
seem to make a difference.

I'd appreciate any thoughts on this, thank you!

Charlotte



More information about the vtkusers mailing list