2 #include <vtkTransformPolyDataFilter.h>
14 for(
int i=0; i<3 ;i++)
53 m_FilePointer = fopen(filename.c_str(),
"w+b");
54 if (m_FilePointer ==
nullptr)
56 printf(
"[ERROR] Unable to create file '%s'\n",filename.c_str());
60 if (fwrite((
char*)&
m_Header, 1, 1000, m_FilePointer) != 1000)
61 MITK_ERROR <<
"TrackVis::create : Error occurding during writing fiber.";
74 m_FilePointer = fopen(filename.c_str(),
"r+b");
75 if (m_FilePointer ==
nullptr)
77 printf(
"[ERROR] Unable to open file '%s'\n",filename.c_str());
82 return fread((
char*)(&
m_Header), 1, 1000, m_FilePointer);
94 vtkCell* cell = poly->GetCell(i);
95 int numPoints = cell->GetNumberOfPoints();
96 vtkPoints* points = cell->GetPoints();
98 unsigned int numSaved, pos = 0;
100 std::vector< float > tmp;
101 tmp.reserve(3*numPoints);
103 numSaved = numPoints;
104 for(
unsigned int i=0; i<numSaved ;i++)
106 double* p = points->GetPoint(i);
114 if ( fwrite((
char*)&numSaved, 1, 4, m_FilePointer) != 4 )
116 printf(
"[ERROR] Problems saving the fiber!\n" );
119 if ( fwrite((
char*)&(tmp.front()), 1, 4*pos, m_FilePointer) != 4*pos )
121 printf(
"[ERROR] Problems saving the fiber!\n" );
137 while (fread((
char*)&numPoints, 1, 4, m_FilePointer)==4)
139 if ( numPoints <= 0 )
141 printf(
"[ERROR] Trying to read a fiber with %d points!\n", numPoints );
147 for(
int i=0; i<numPoints; i++)
149 if (fread((
char*)tmp, 1, 12, m_FilePointer) == 0)
150 MITK_ERROR <<
"TrackVis::read: Error during read.";
152 vtkIdType
id = vtkNewPoints->InsertNextPoint(tmp);
153 container->GetPointIds()->InsertNextId(
id);
155 vtkNewCells->InsertNextCell(container);
159 fiberPolyData->SetPoints(vtkNewPoints);
160 fiberPolyData->SetLines(vtkNewCells);
169 matrix->SetElement(0,0,-matrix->GetElement(0,0));
171 matrix->SetElement(1,1,-matrix->GetElement(1,1));
173 matrix->SetElement(2,2,-matrix->GetElement(2,2));
175 geometry->SetIndexToWorldTransformByVtkMatrix(matrix);
178 transformFilter->SetInputData(fiberPolyData);
179 transformFilter->SetTransform(geometry->GetVtkTransform());
180 transformFilter->Update();
187 geometry->SetOrigin(origin);
193 geometry->SetSpacing(spacing);
210 fseek(m_FilePointer, 1000-12, SEEK_SET);
211 if (fwrite((
char*)&totFibers, 1, 4, m_FilePointer) != 4)
212 MITK_ERROR <<
"[ERROR] Problems saving the fiber!";
218 fseek(m_FilePointer, 0, SEEK_SET);
219 if (fwrite((
char*)&
m_Header, 1, 1000, m_FilePointer) != 1000)
220 MITK_ERROR <<
"[ERROR] Problems saving the fiber!";
228 fclose(m_FilePointer);
229 m_FilePointer =
nullptr;
ScalarType GetExtent(unsigned int direction) const
Set the time bounds (in ms)
const Point3D GetOrigin() const
Get the origin, e.g. the upper-left corner of the plane.
short open(string m_Filename)
virtual mitk::BaseGeometry::Pointer GetReferenceGeometry() const
const mitk::Vector3D GetSpacing() const
Get the spacing (size of a pixel).
short append(const mitk::FiberBundle *fib)
vtkSmartPointer< vtkPolyData > GetFiberPolyData() const
static const std::string filename
short create(string m_Filename, const mitk::FiberBundle *fib)
Base Class for Fiber Bundles;.
short read(mitk::FiberBundle *fib)
virtual void SetReferenceGeometry(mitk::BaseGeometry::Pointer _arg)
mitk::BaseGeometry * GetGeometry(int t=0) const
Return the geometry, which is a TimeGeometry, of the data as non-const pointer.
void updateTotal(int totFibers)
virtual int GetNumFibers()
void SetFiberPolyData(vtkSmartPointer< vtkPolyData >, bool updateGeometry=true)
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.