[ITK] [ITK-users] Do any of the mesh file formats store CellData?
DVigneault
davis.vigneault at gmail.com
Thu Aug 13 13:55:04 EDT 2015
All--
Do any of the mesh file formats supported by ITK store CellData information?
I've done a test where I've (a) created a mesh, (b) associated a value with
each cell, (c) written it to file, (d) read it back in, and (e) attempted to
read the associated value. I did this for each file format. When I ask for
the cell's data, .vtk and .gii formats return uninitialized data, whereas
.obj, .byu, .fcv, .fsa, .fsb, and .off segfault.
I looked through itk::MeshFileWriter to see whether there were an option
(such as WriteCellDataOn()), and there is a method WriteCellData() [1], but
it is protected. Looking at the header files of some of the individual
writer objects (itkVTKPolyDataMeshIO, itkOBJMeshIO, etc), it looks like the
WriteCellData(void *buffer) method is abstract.
[1]
http://www.itk.org/Doxygen/html/classitk_1_1MeshFileWriter.html#a1819df60ed20493f64a84c1728ddf26b
I've pasted below the test program, in case the problem is due to a mistake
I've made there.
Best, and thanks!
--Davis
#include "itkMesh.h"
#include "itkMeshFileReader.h"
#include "itkMeshFileWriter.h"
#include "itkRegularSphereMeshSource.h"
const unsigned int Dimension = 3;
typedef float TCoordinate;
typedef itk::Mesh< TCoordinate, Dimension > TMesh;
typedef itk::RegularSphereMeshSource< TMesh > TSphere;
typedef itk::MeshFileReader< TMesh > TMeshReader;
typedef itk::MeshFileWriter< TMesh > TMeshWriter;
int main( int argc, char* argv[] )
{
auto sphere = TSphere::New();
sphere->Update();
auto mesh = sphere->GetOutput();
double value = 10;
for (unsigned int i = 0; i < mesh->GetNumberOfCells(); ++i)
mesh->SetCellData( i, value);
std::cout << mesh->GetCellData()->ElementAt(0) << std::endl; // 10
auto meshWriter = TMeshWriter::New();
meshWriter->SetFileName( argv[1] );
meshWriter->SetInput( mesh );
meshWriter->Update();
auto reader = TMeshReader::New();
reader->SetFileName( argv[1] );
reader->ReadPointData();
reader->Update();
float value2;
auto mesh2 = reader->GetOutput();
mesh2->SetCellData(0, value2);
mesh2->GetCellData()->ElementAt(0);
std::cout << value2 << std::endl; // Segfault or uninitialized
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-tp7587666.html
Sent from the ITK Insight Users mailing list archive at Nabble.com.
_____________________________________
Powered by www.kitware.com
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
Kitware offers ITK Training Courses, for more information visit:
http://www.kitware.com/products/protraining.php
Please keep messages on-topic and check the ITK FAQ at:
http://www.itk.org/Wiki/ITK_FAQ
Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/insight-users
More information about the Community
mailing list