root/OpenSceneGraph/trunk/src/osgPlugins/ply/typedefs.h
@
10012
| Revision 10012, 2.4 kB (checked in by robert, 4 years ago) |
|---|
| Line | |
|---|---|
| 1 | /* |
| 2 | typedefs.h |
| 3 | Copyright (c) 2007, Tobias Wolf <twolf@access.unizh.ch> |
| 4 | All rights reserved. |
| 5 | |
| 6 | Type definitions for the mesh classes. |
| 7 | */ |
| 8 | |
| 9 | /** note, derived from Equalizer LGPL source.*/ |
| 10 | |
| 11 | |
| 12 | #ifndef MESH_TYPEDEFS_H |
| 13 | #define MESH_TYPEDEFS_H |
| 14 | |
| 15 | # ifdef WIN32 |
| 16 | # include <Winsock2.h> |
| 17 | # include <Windows.h> |
| 18 | # endif |
| 19 | |
| 20 | # include <osg/Notify> |
| 21 | # include <cassert> |
| 22 | # define MESHASSERT assert |
| 23 | # define MESHERROR osg::notify(osg::WARN) |
| 24 | # define MESHWARN osg::notify(osg::WARN) |
| 25 | # define MESHINFO osg::notify(osg::INFO) |
| 26 | |
| 27 | #ifdef WIN32 |
| 28 | typedef int socklen_t; |
| 29 | |
| 30 | typedef UINT64 uint64_t; |
| 31 | typedef INT64 int64_t; |
| 32 | typedef UINT32 uint32_t; |
| 33 | typedef INT32 int32_t; |
| 34 | typedef UINT16 uint16_t; |
| 35 | typedef UINT8 uint8_t; |
| 36 | # ifndef HAVE_SSIZE_T |
| 37 | typedef SSIZE_T ssize_t; |
| 38 | # endif |
| 39 | |
| 40 | #endif // Win32 |
| 41 | |
| 42 | #include <exception> |
| 43 | #include <iostream> |
| 44 | #include <string> |
| 45 | |
| 46 | namespace ply |
| 47 | { |
| 48 | |
| 49 | |
| 50 | |
| 51 | typedef size_t Index; |
| 52 | // typedef unsigned short ShortIndex; |
| 53 | |
| 54 | |
| 55 | // mesh exception |
| 56 | struct MeshException : public std::exception |
| 57 | { |
| 58 | explicit MeshException( const std::string& msg ) : _message( msg ) {} |
| 59 | virtual ~MeshException() throw() {} |
| 60 | virtual const char* what() const throw() { return _message.c_str(); } |
| 61 | private: |
| 62 | std::string _message; |
| 63 | }; |
| 64 | |
| 65 | // null output stream that discards everything written to it |
| 66 | struct NullOStream : std::ostream |
| 67 | { |
| 68 | struct NullStreamBuf : std::streambuf |
| 69 | { |
| 70 | int overflow( int c ) { return traits_type::not_eof( c ); } |
| 71 | } _nullBuf; |
| 72 | |
| 73 | NullOStream() : std::ios( &_nullBuf ), std::ostream( &_nullBuf ) {} |
| 74 | }; |
| 75 | |
| 76 | // wrapper to enable array use where arrays would not be allowed otherwise |
| 77 | template< class T, size_t d > |
| 78 | struct ArrayWrapper |
| 79 | { |
| 80 | T& operator[]( const size_t i ) |
| 81 | { |
| 82 | MESHASSERT( i < d ); |
| 83 | return data[i]; |
| 84 | } |
| 85 | |
| 86 | const T& operator[]( const size_t i ) const |
| 87 | { |
| 88 | MESHASSERT( i < d ); |
| 89 | return data[i]; |
| 90 | } |
| 91 | |
| 92 | private: |
| 93 | T data[d]; |
| 94 | }; |
| 95 | |
| 96 | |
| 97 | // binary mesh file version, increment if changing the file format |
| 98 | const unsigned short FILE_VERSION ( 0x0114 ); |
| 99 | |
| 100 | |
| 101 | // enumeration for the sort axis |
| 102 | enum Axis |
| 103 | { |
| 104 | AXIS_X, |
| 105 | AXIS_Y, |
| 106 | AXIS_Z |
| 107 | }; |
| 108 | |
| 109 | } |
| 110 | |
| 111 | |
| 112 | #endif // MESH_TYPEDEFS_H |
Note: See TracBrowser
for help on using the browser.
