MCPcopy Create free account
hub / github.com/OGRECave/ogre / HalfFloatGridSource

Method HalfFloatGridSource

Components/Volume/src/OgreVolumeHalfFloatGridSource.cpp:63–111  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

61 //-----------------------------------------------------------------------
62
63 HalfFloatGridSource::HalfFloatGridSource(const String &serializedVolumeFile, const bool trilinearValue, const bool trilinearGradient, const bool sobelGradient) :
64 GridSource(trilinearValue, trilinearGradient, sobelGradient)
65 {
66
67 Timer t;
68 DataStreamPtr streamRead = Root::getSingleton().openFileStream(serializedVolumeFile);
69#if OGRE_NO_ZIP_ARCHIVE == 0
70 DataStreamPtr uncompressStream(OGRE_NEW DeflateStream(serializedVolumeFile, streamRead));
71 StreamSerialiser ser(uncompressStream);
72#else
73 StreamSerialiser ser(streamRead);
74#endif
75 if (!ser.readChunkBegin(VOLUME_CHUNK_ID, VOLUME_CHUNK_VERSION))
76 {
77 OGRE_EXCEPT(Exception::ERR_INVALID_STATE, "Invalid volume file given!");
78 }
79
80 // Read header
81 Vector3 readFrom, readTo;
82 ser.read(&readFrom);
83 ser.read(&readTo);
84 float voxelWidth;
85 ser.read<float>(&voxelWidth);
86 size_t width, height, depth;
87 ser.read<size_t>(&width);
88 ser.read<size_t>(&height);
89 ser.read<size_t>(&depth);
90 mWidth = static_cast<int>(width);
91 mHeight = static_cast<int>(height);
92 mDepth = static_cast<int>(depth);
93 mDepthTimesHeight = static_cast<int>(mDepth * mHeight);
94
95 Vector3 worldDimension = readTo - readFrom;
96 mPosXScale = (Real)1.0 / (Real)worldDimension.x * (Real)mWidth;
97 mPosYScale = (Real)1.0 / (Real)worldDimension.y * (Real)mHeight;
98 mPosZScale = (Real)1.0 / (Real)worldDimension.z * (Real)mDepth;
99
100 mVolumeSpaceToWorldSpaceFactor = (Real)worldDimension.x * (Real)mWidth;
101 mMaxClampedAbsoluteDensity = 0;
102
103 // Read data
104 size_t elementCount = mWidth * mHeight * mDepth;
105 mData = OGRE_ALLOC_T(uint16, elementCount, MEMCATEGORY_GENERAL);
106 ser.read(mData, elementCount);
107
108 ser.readChunkEnd(VOLUME_CHUNK_ID);
109
110 LogManager::getSingleton().stream() << "Processed serialization in " << t.getMilliseconds() << "ms.";
111 }
112
113 //-----------------------------------------------------------------------
114

Callers

nothing calls this directly

Calls 6

openFileStreamMethod · 0.80
readChunkBeginMethod · 0.80
readChunkEndMethod · 0.80
getMillisecondsMethod · 0.80
readMethod · 0.45
streamMethod · 0.45

Tested by

no test coverage detected