<div dir="ltr"><div><div><div><div>Hi Davis,<br><br>First of all, you do not need to call ReadPointData, especially if you want to read cell data... Anyway, even if you make the change, it is not required...<br><br>Then, if you look carefully at your code, it is normal that it segfault:<br><br> float value2;<br> auto mesh2 = reader->GetOutput();<br> mesh2->SetCellData(0, value2);<br> mesh2->GetCellData()->ElementAt(0);<br> std::cout << value2 << std::endl; // Segfault or uninitialized<br><br>Right after reading the file, you set the data of the cell 0 to an uninitialized value, then you get that value back but you do not store in any variable. Finally, you print the uninitialzed value...<br><br>Best,<br>Arnaud<br><br></div></div></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Aug 13, 2015 at 7:55 PM, DVigneault <span dir="ltr"><<a href="mailto:davis.vigneault@gmail.com" target="_blank">davis.vigneault@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">All--<br>
<br>
Do any of the mesh file formats supported by ITK store CellData information?<br>
I've done a test where I've (a) created a mesh, (b) associated a value with<br>
each cell, (c) written it to file, (d) read it back in, and (e) attempted to<br>
read the associated value. I did this for each file format. When I ask for<br>
the cell's data, .vtk and .gii formats return uninitialized data, whereas<br>
.obj, .byu, .fcv, .fsa, .fsb, and .off segfault.<br>
<br>
I looked through itk::MeshFileWriter to see whether there were an option<br>
(such as WriteCellDataOn()), and there is a method WriteCellData() [1], but<br>
it is protected. Looking at the header files of some of the individual<br>
writer objects (itkVTKPolyDataMeshIO, itkOBJMeshIO, etc), it looks like the<br>
WriteCellData(void *buffer) method is abstract.<br>
<br>
[1]<br>
<a href="http://www.itk.org/Doxygen/html/classitk_1_1MeshFileWriter.html#a1819df60ed20493f64a84c1728ddf26b" rel="noreferrer" target="_blank">http://www.itk.org/Doxygen/html/classitk_1_1MeshFileWriter.html#a1819df60ed20493f64a84c1728ddf26b</a><br>
<br>
I've pasted below the test program, in case the problem is due to a mistake<br>
I've made there.<br>
<br>
Best, and thanks!<br>
<br>
--Davis<br>
<br>
#include "itkMesh.h"<br>
#include "itkMeshFileReader.h"<br>
#include "itkMeshFileWriter.h"<br>
#include "itkRegularSphereMeshSource.h"<br>
<br>
const unsigned int Dimension = 3;<br>
typedef float TCoordinate;<br>
<br>
typedef itk::Mesh< TCoordinate, Dimension > TMesh;<br>
typedef itk::RegularSphereMeshSource< TMesh > TSphere;<br>
typedef itk::MeshFileReader< TMesh > TMeshReader;<br>
typedef itk::MeshFileWriter< TMesh > TMeshWriter;<br>
<br>
int main( int argc, char* argv[] )<br>
{<br>
<br>
auto sphere = TSphere::New();<br>
sphere->Update();<br>
<br>
auto mesh = sphere->GetOutput();<br>
double value = 10;<br>
for (unsigned int i = 0; i < mesh->GetNumberOfCells(); ++i)<br>
mesh->SetCellData( i, value);<br>
std::cout << mesh->GetCellData()->ElementAt(0) << std::endl; // 10<br>
<br>
auto meshWriter = TMeshWriter::New();<br>
meshWriter->SetFileName( argv[1] );<br>
meshWriter->SetInput( mesh );<br>
meshWriter->Update();<br>
<br>
auto reader = TMeshReader::New();<br>
reader->SetFileName( argv[1] );<br>
reader->ReadPointData();<br>
reader->Update();<br>
<br>
float value2;<br>
auto mesh2 = reader->GetOutput();<br>
mesh2->SetCellData(0, value2);<br>
mesh2->GetCellData()->ElementAt(0);<br>
std::cout << value2 << std::endl; // Segfault or uninitialized<br>
<br>
return EXIT_SUCCESS;<br>
<br>
}<br>
<br>
<br>
<br>
<br>
--<br>
View this message in context: <a href="http://itk-insight-users.2283740.n2.nabble.com/Do-any-of-the-mesh-file-formats-store-CellData-tp7587666.html" rel="noreferrer" target="_blank">http://itk-insight-users.2283740.n2.nabble.com/Do-any-of-the-mesh-file-formats-store-CellData-tp7587666.html</a><br>
Sent from the ITK Insight Users mailing list archive at Nabble.com.<br>
_____________________________________<br>
Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at<br>
<a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Kitware offers ITK Training Courses, for more information visit:<br>
<a href="http://www.kitware.com/products/protraining.php" rel="noreferrer" target="_blank">http://www.kitware.com/products/protraining.php</a><br>
<br>
Please keep messages on-topic and check the ITK FAQ at:<br>
<a href="http://www.itk.org/Wiki/ITK_FAQ" rel="noreferrer" target="_blank">http://www.itk.org/Wiki/ITK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://public.kitware.com/mailman/listinfo/insight-users" rel="noreferrer" target="_blank">http://public.kitware.com/mailman/listinfo/insight-users</a><br>
</blockquote></div><br></div>