[ITK-users] Do any of the mesh file formats store CellData?

DVigneault davis.vigneault at gmail.com
Fri Aug 14 08:53:11 EDT 2015


Thanks very much for the help, Arnaud--sometimes I think I shouldn't be
allowed to post after 5pm.  :-)

However, unless I'm making another silly mistake, that doesn't appear to be
the only problem.  If I open the mesh.vtk file, I don't see where any
CellData has been written.  Moreover, if I std::cout the size of CellData
*before* writing to disk I get 128, whereas immediately after I get 0.

I tried stepping through the itk::MeshFileWriter::Write() method in gdb
(itkMeshFileWriter.hxx:80), and found that p input->GetCellData()->Size()
returns 128 until nonConstInput->Update() is called (b
itkMeshFileWriter.hxx:148), after which p input->GetCellData()->Size()
returns 0.  As a result, the condition if (input->GetCells() &&
input->GetNumberOfCells() ) fails, and the CellData appears not to be
written.  Unfortunately I built ITK in release mode so I can't step into
Update() at the minute, but I'll rebuild and see if I can get more
information.

Thanks again Arnaud et al for your help (and your patience)!

--Davis

////
//// Here's what I'm seeing in GDB:
////

$ gdb ./dv-mesh-test
(gdb) b itkMeshFileWriter.hxx:148
(gdb) b itkMeshFileWriter.hxx:207 // Never triggered
(gdb) b itkMeshFileWriter.hxx:240 // Never triggered
(gdb) r
(gdb) p input->GetCellData() // 0x91b3a0
(gdb) p input->GetCellData()->Size() // 128
(gdb) n
(gdb) p input->GetCellData() // 0x91b3f0 (different pointer)
(gdb) p input->GetCellData()->Size() // 0
(gdb) c // Exits normally, but the size of the mesh's CellData container is
now 0

////
//// And here's the new test file:
////

#include "itkMesh.h"
#include "itkRegularSphereMeshSource.h"
#include "itkMeshFileWriter.h"

const unsigned int Dimension = 3;
typedef float      TCoordinate;

typedef itk::Mesh< TCoordinate, Dimension >   TMesh;
typedef itk::RegularSphereMeshSource< TMesh > TSphere;
typedef itk::MeshFileWriter< TMesh >          TMeshWriter;

int main()
{

  auto sphere = TSphere::New();
  sphere->Update();

  auto mesh = sphere->GetOutput();
  double value = 10;
//  mesh->GetCellData()->Reserve(mesh->GetNumberOfCells()); // No change
//  mesh->SetRequestedRegionToLargestPossibleRegion(); // No change
  for (unsigned int i = 0; i < mesh->GetNumberOfCells(); ++i)
    mesh->SetCellData( i, value);

  std::cout << mesh->GetNumberOfCells() << std::endl; // 128
  std::cout << mesh->GetCellData() << std::endl; // 0x1be13a0
  std::cout << mesh->GetCellData()->Size() << std::endl << std::endl; // 128

  auto meshWriter = TMeshWriter::New();
  meshWriter->SetFileName( "mesh.vtk" );
  meshWriter->SetInput( mesh );
  meshWriter->Update();

  std::cout << mesh->GetNumberOfCells() << std::endl; // 128
  std::cout << mesh->GetCellData() << std::endl; // 0x1be13a0
  std::cout << mesh->GetCellData()->Size() << std::endl << std::endl; // 0

  return EXIT_SUCCESS;

}




--
View this message in context: http://itk-insight-users.2283740.n2.nabble.com/Do-any-of-the-mesh-file-formats-store-CellData-tp7587666p7587675.html
Sent from the ITK Insight Users mailing list archive at Nabble.com.


More information about the Insight-users mailing list