<div class="gmail_quote">On Fri, Nov 6, 2009 at 8:27 AM, Bill Lorensen <span dir="ltr"><<a href="mailto:bill.lorensen@gmail.com">bill.lorensen@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
David,<br>
<br>
<br>
Try printing the reference count of each LidarPoint before and after<br>
std::cout << "Ref Before: " << LidarPoint->GetReferenceCount() << std::endl;<br>
Column[phiCounter] = LidarPoint;<br>
std::cout << "Ref After: " << LidarPoint->GetReferenceCount() << std::endl;<br>
<br>
And outside the end of the inner loop:<br>
std::cout << "Ref outside loop: " <<<br>
OutputGrid[0]-.GetReferenceCount() << std::endl;<br>
<div><div></div><div class="h5"><br>
</div></div></blockquote><div><br>Both before and after
Column[phiCounter] = LidarPoint;, the reference count is 1. <br><br>I changed<br>vtkstd::vector<vtkLidarPoint*> Column;<br>to<br>vtkstd::vector<vtkSmartPointer<vtkLidarPoint> > Column;<br>so that the reference count increases to 2 after Column[phiCounter] = LidarPoint;<br>
<br>I also changed<br>vtkstd::vector<vtkstd::vector<vtkLidarPoint*> > OutputGrid;<br>to<br>vtkstd::vector<vtkstd::vector<vtkSmartPointer<vtkLidarPoint> > > OutputGrid;<br>based on the same logic.<br>
<br>I now get many less errors, but I still get a single <br>Deleting unknown object: vtkObject<br>every time the inner loop is entered.<br><br>I'm assuming it is because the vtkRay is going out of scope at the end of the loop and I haven't made LidarPoint::SetRay accept a smart pointer? <br>
<br>Is all of this the correct way to approach storing these objects?<br><br clear="all">Thanks,<br><br>David <br></div></div>