11 #ifndef __itkFiberTractsWriter_hxx 12 #define __itkFiberTractsWriter_hxx 29 utlGlobalException(
true,
"use MeshFromTracts and itk::MeshFromFiberTractsFilter to write vtk file.");
47 int n_count = header->n_count;
54 fseek (file, offset, SEEK_SET);
56 float val[3+dim_s], val2[dim_p];
58 for (
int n = 0; n < n_count; ++n )
61 utlSAGlobalException(dim_p!=fiber->GetDimensionOfProperties())(n)(dim_p)(fiber->GetDimensionOfProperties()).msg(
"dim_p in header is different from dim_p in fiber");
62 utlSAGlobalException(dim_s!=fiber->GetDimensionOfScalarsPerPoint())(n)(dim_s)(fiber->GetDimensionOfScalarsPerPoint()).msg(
"dim_s in header is different from dim_s in fiber");
64 numPoints = fiber->GetNumberOfPoints();
65 fwrite((
char*)&numPoints,
sizeof(
int), 1, file);
67 auto tract = fiber->GetTract();
68 auto properties = fiber->GetProperties();
69 auto scalars = fiber->GetScalars();
70 auto vertexList = tract->GetVertexList();
71 for (
int i = 0; i < numPoints; ++i )
73 vertex = (*vertexList)[i];
75 for (
int j = 0; j < 3; ++j )
77 for (
int j = 0; j < dim_s; ++j )
79 fwrite((
char*)&val,
sizeof(
float)*(3+dim_s), 1, file);
81 for (
int j = 0; j < dim_p; ++j )
82 val2[j+3] = (*properties)[j];
83 fwrite((
char*)&val2,
sizeof(
float)*dim_p, 1, file);
int GetFiberTractsFormatFromFileExtension(const std::string &filename)
#define utlSAGlobalException(expr)
#define utlGlobalException(cond, expout)
FiberTractsPointer m_FiberTracts
int GetDimensionOfScalars(const TrackVisHeaderType &header)
FiberType::VertexType VertexType
void WriteTrackVisHeader(const TrackVisHeaderType &header, FILE *file)
FiberTractsType::FiberPointer FiberPointer
FiberType::STDVectorType STDVectorType
int GetDimensionOfProperties(const TrackVisHeaderType &header)