29 #include "WMeshReaderBrainVISA.h"
46 boost::filesystem::path file )
50 std::string fileName = file.string();
51 WAssert( !fileName.empty(),
"No filename specified." );
53 std::shared_ptr< WProgress > progress(
new WProgress(
"Read Mesh", 3 ) );
54 parentProgress->addSubProgress( progress );
57 ifs.open( fileName.c_str(), std::ifstream::in );
58 if( !ifs || ifs.bad() )
61 throw std::runtime_error(
"Problem during reading file. Probably file not found." );
66 char * buffer =
new char[10];
67 ifs.read( buffer, 10 );
70 std::string fileType( buffer );
72 if( fileType !=
"binarDCBA" )
76 return std::shared_ptr< WTriangleMesh >();
78 size_t numVertices = 0;
79 size_t numNormals = 0;
80 size_t numTriangles = 0;
83 int* count =
new int[1];
84 ifs.read(
reinterpret_cast< char*
>( count ), 4 );
85 numVertices = count[0];
87 ifs.seekg( 33 + count[0] * 12 );
88 ifs.read(
reinterpret_cast< char*
>( count ), 4 );
89 numNormals = count[0];
91 ifs.seekg( 41 + numVertices * 12 + numNormals * 12 );
92 ifs.read(
reinterpret_cast< char*
>( count ), 4 );
93 numTriangles = count[0];
95 std::shared_ptr< WTriangleMesh > triMesh(
new WTriangleMesh( numVertices, numTriangles ) );
98 float *pointData =
new float[ 3 * numVertices ];
99 ifs.read(
reinterpret_cast< char*
>( pointData ), 3 *
sizeof(
float ) * numVertices );
103 ifs.seekg( 45 + numVertices * 12 + numNormals * 12 );
104 int *triData =
new int[ 3 * numTriangles ];
105 ifs.read(
reinterpret_cast< char*
>( triData ), 3 *
sizeof(
int ) * numTriangles );
107 for(
size_t i = 0; i < numVertices; ++i )
111 for(
size_t i = 0; i < numTriangles; ++i )
113 triMesh->addTriangle( triData[i * 3], triData[i * 3 + 2], triData[i * 3 + 1] );
135 parentProgress->removeSubProgress( progress );
void addLogMessage(std::string message, std::string source="", LogLevel level=LL_DEBUG)
Appends a log message to the logging queue.
static WLogger * getLogger()
Returns pointer to the currently running logger instance.
WPropInt m_propDatasetSizeY
Size of the dataset (Y)
virtual ~WMeshReaderBrainVISA()
Destructor.
WPropInt m_propDatasetSizeX
Size of the dataset (X)
WPropInt m_propDatasetSizeZ
Size of the dataset (Z)
virtual WTriangleMesh::SPtr operator()(WProgressCombiner::SPtr parentProgress, boost::filesystem::path file)
Load the dataset.
WMeshReaderBrainVISA()
Constructor.
Define the interface which is injected into an WObjectNDIP.
This is a base class for everything which has a Name,Description,Icon and Properties (=NDIP).
WProperties::SPtr m_properties
the properties of the object.
std::shared_ptr< WProgressCombiner > SPtr
Abbreviate shared_ptr for this class.
Class managing progress inside of modules.
Triangle mesh data structure allowing for convenient access of the elements.
std::shared_ptr< WTriangleMesh > SPtr
Shared pointer.
Some utilities for string manipulation and output operations.