From 363633a81d92a312c86a7e296dbaabbf33a13372 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Thu, 6 Dec 2012 19:09:17 +0000 Subject: [PATCH] Intial shell of .trk plugin --- src/osgPlugins/CMakeLists.txt | 2 + src/osgPlugins/trk/CMakeLists.txt | 4 + src/osgPlugins/trk/ReaderWriterTRK.cpp | 105 +++++++++++++++++++++++++ 3 files changed, 111 insertions(+) create mode 100644 src/osgPlugins/trk/CMakeLists.txt create mode 100644 src/osgPlugins/trk/ReaderWriterTRK.cpp diff --git a/src/osgPlugins/CMakeLists.txt b/src/osgPlugins/CMakeLists.txt index 5c8b1706a..ad3fd41b3 100644 --- a/src/osgPlugins/CMakeLists.txt +++ b/src/osgPlugins/CMakeLists.txt @@ -255,7 +255,9 @@ IF(LIBVNCSERVER_FOUND) ENDIF() ADD_SUBDIRECTORY(pvr) + ADD_SUBDIRECTORY(osc) +ADD_SUBDIRECTORY(trk) #################################################### # diff --git a/src/osgPlugins/trk/CMakeLists.txt b/src/osgPlugins/trk/CMakeLists.txt new file mode 100644 index 000000000..f3501d027 --- /dev/null +++ b/src/osgPlugins/trk/CMakeLists.txt @@ -0,0 +1,4 @@ +SET(TARGET_SRC ReaderWriterTRK.cpp ) + +#### end var setup ### +SETUP_PLUGIN(trk) diff --git a/src/osgPlugins/trk/ReaderWriterTRK.cpp b/src/osgPlugins/trk/ReaderWriterTRK.cpp new file mode 100644 index 000000000..ae034f13f --- /dev/null +++ b/src/osgPlugins/trk/ReaderWriterTRK.cpp @@ -0,0 +1,105 @@ +// Released under the OSGPL license, as part of the OpenSceneGraph distribution. +// +// specification : http://www.trackvis.org/docs/?subsect=fileformat +#include + +#include + +#include +#include +#include + +struct TrkHeader +{ + char id_string[6]; + short dim[3]; + float voxel_size[3]; + float origin[3]; + short n_scalars; + char scalar_name[10][20]; + short n_properties; + char property_name[10][20]; + float vox_to_ras[4][4]; + char reserved[444]; + char voxel_order[4]; + char pad2[4]; + float image_orientation_patient[6]; + char pad1[2]; + unsigned char invert_x; + unsigned char invert_y; + unsigned char invert_z; + unsigned char swap_xy; + unsigned char swap_yz; + unsigned char swap_zx; + int n_count; + int version; + int hdr_size; +}; + + +class ReaderWriterTRK : public osgDB::ReaderWriter +{ + public: + + ReaderWriterTRK() + { + supportsExtension("trk","Track file format"); + + OSG_NOTICE<<"sizeof(TrkHeader)="<(&header), sizeof(TrkHeader)); + + if (fin.fail()) return ReadResult::ERROR_IN_READING_FILE; + + OSG_NOTICE<<"Read header successfuly ["<