[Insight-users] writing a mesh to a file
Ipek Oguz
ipek at cs.unc.edu
Tue Mar 8 13:41:02 EST 2005
Hi everyone,
I was trying to write a MeshSpatialObject to a file using
MetaMeshConverter, and I had problems if I didn't build the cell links
of the mesh first(it was crashing, basically). But I don't want the cell
links, because I don't need them for my application, and they make my
output file huge.
Anyway, I figured out that in the itkMetaMeshConverter.txx file(line
310), the pointer to the cell links is used without first checking if it
is null or not, and this is why the program crashes when I don't have
the cell links. Adding a simple if statement(see below) solved the
problem for me, so I thought I'd let you know, you might want to include
this change in the code.
Thanks,
-ipek
(here is the piece of code)
// Add cell links
typedef typename MeshType::CellLinksContainer CellLinksContainer;
const CellLinksContainer* links = mesh->GetCellLinks();
if ( links ) // NEW
{ // NEW
typename MeshType::CellLinksContainer::ConstIterator it_celllinks =
links->Begin();
while(it_celllinks != links->End())
{
MeshCellLink* link = new MeshCellLink();
link->m_Id = (*it_celllinks)->Index();
typename MeshType::PointCellLinksContainer::const_iterator it =
(*it_celllinks)->Value().begin();
while(it != (*it_celllinks)->Value().end())
{
link->m_Links.push_back(*it);
it++;
}
metamesh->GetCellLinks().push_back(link);
it_celllinks++;
}
} //NEW
More information about the Insight-users
mailing list