For those still working on fibermesh

13 views
Skip to first unread message

Matt Forni

unread,
Apr 13, 2010, 5:39:18 PM4/13/10
to cs224...@googlegroups.com
Just for the record ... after iterating through a the neighborhood* somehow the memory is always corrupted.
(ie. everytime you want to iterate through your neighborhood* you need to call getNeighbors(N).

--
Matt Fornaciari
Applied Math - Computer Science (Graphics)
Brown University
69 Brown St., Box 4539
Providence, RI  02912

Jordan Berg

unread,
Apr 13, 2010, 6:24:43 PM4/13/10
to cs224...@googlegroups.com
Yeah, I experienced this problem as well.  I found that once I accessed the underlying Neighborhood struct that the destructor was called on it, deleting all of the data (I confirmed this by adding printlines in the destructor).  I was able to get around this by altering the support code, such that I initialize the array before passing it off to the getNeighbors method, as opposed to it being created inside the method.  I assume it has something to do with like pointer vs. reference, which is why I didn't send it out as a bug or anything (I just kind of assumed it was me being crappy at C++).

Kevin Doo

unread,
Apr 13, 2010, 7:57:06 PM4/13/10
to cs224...@googlegroups.com
Instead of altering the support code, you can also do the following:

Neighborhood* neighbors

if(!MeshUtils::getNeighbors(mesh, &neighbors))
         return;

for(unsigned int i = 0; i < mesh->m_nVertices; ++i) {

      Neighborhood* verts = neighbors + i;

}

safeDeleteArray(neighbors);

This way you can use the verts of a neighborhood without calling the destructor.

-Kevin
Reply all
Reply to author
Forward
0 new messages