mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-05 18:16:23 +03:00
0031333: Data Exchange - RWGltf_TriangulationReader::readBuffer() fails to read interleaved buffer at the end of file
Standard_ReadBuffer has been extended with a flag for reading an interleaved data. RWGltf_TriangulationReader::readBuffer() uses new flag for reading vertex attributes.
This commit is contained in:
parent
62beabff7c
commit
e2550e48f1
@ -283,7 +283,7 @@ bool RWGltf_TriangulationReader::readBuffer (std::istream& theStream,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Standard_ReadBuffer aBuffer (theAccessor.Count * aStride, aStride);
|
Standard_ReadBuffer aBuffer (theAccessor.Count * aStride - (aStride - sizeof(Graphic3d_Vec3)), aStride, true);
|
||||||
if (!myCoordSysConverter.IsEmpty())
|
if (!myCoordSysConverter.IsEmpty())
|
||||||
{
|
{
|
||||||
for (Standard_Integer aVertIter = 0; aVertIter < aNbNodes; ++aVertIter)
|
for (Standard_Integer aVertIter = 0; aVertIter < aNbNodes; ++aVertIter)
|
||||||
@ -336,7 +336,7 @@ bool RWGltf_TriangulationReader::readBuffer (std::istream& theStream,
|
|||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Standard_ReadBuffer aBuffer (theAccessor.Count * aStride, aStride);
|
Standard_ReadBuffer aBuffer (theAccessor.Count * aStride - (aStride - sizeof(Graphic3d_Vec3)), aStride, true);
|
||||||
if (!myCoordSysConverter.IsEmpty())
|
if (!myCoordSysConverter.IsEmpty())
|
||||||
{
|
{
|
||||||
for (Standard_Integer aVertIter = 0; aVertIter < aNbNodes; ++aVertIter)
|
for (Standard_Integer aVertIter = 0; aVertIter < aNbNodes; ++aVertIter)
|
||||||
@ -402,7 +402,7 @@ bool RWGltf_TriangulationReader::readBuffer (std::istream& theStream,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Standard_ReadBuffer aBuffer (theAccessor.Count * aStride, aStride);
|
Standard_ReadBuffer aBuffer (theAccessor.Count * aStride - (aStride - sizeof(Graphic3d_Vec2)), aStride, true);
|
||||||
for (int aVertIter = 0; aVertIter < aNbNodes; ++aVertIter)
|
for (int aVertIter = 0; aVertIter < aNbNodes; ++aVertIter)
|
||||||
{
|
{
|
||||||
Graphic3d_Vec2* aVec2 = aBuffer.ReadChunk<Graphic3d_Vec2> (theStream);
|
Graphic3d_Vec2* aVec2 = aBuffer.ReadChunk<Graphic3d_Vec2> (theStream);
|
||||||
|
@ -25,7 +25,8 @@ public:
|
|||||||
|
|
||||||
//! Constructor with initialization.
|
//! Constructor with initialization.
|
||||||
Standard_ReadBuffer (int64_t theDataLen,
|
Standard_ReadBuffer (int64_t theDataLen,
|
||||||
size_t theChunkLen)
|
size_t theChunkLen,
|
||||||
|
bool theIsPartialPayload = false)
|
||||||
: myBufferPtr(NULL),
|
: myBufferPtr(NULL),
|
||||||
myBufferEnd(NULL),
|
myBufferEnd(NULL),
|
||||||
myDataLen (0),
|
myDataLen (0),
|
||||||
@ -34,17 +35,28 @@ public:
|
|||||||
myNbChunks (0),
|
myNbChunks (0),
|
||||||
myBufferLen(0)
|
myBufferLen(0)
|
||||||
{
|
{
|
||||||
Init (theDataLen, theChunkLen);
|
Init (theDataLen, theChunkLen, theIsPartialPayload);
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Initialize the buffer.
|
//! Initialize the buffer.
|
||||||
//! @param theDataLen the full length of input data to read from stream.
|
//! @param theDataLen [in] the full length of input data to read from stream.
|
||||||
//! @param theChunkLen the length of single chunk to read
|
//! @param theChunkLen [in] the length of single chunk to read
|
||||||
|
//! @param theIsPartialPayload [in] when FALSE, theDataLen will be automatically aligned to the multiple of theChunkLen;
|
||||||
|
//! when TRUE, last chunk will be read from stream exactly till theDataLen
|
||||||
|
//! allowing portion of chunk to be uninitialized (useful for interleaved data)
|
||||||
void Init (int64_t theDataLen,
|
void Init (int64_t theDataLen,
|
||||||
size_t theChunkLen)
|
size_t theChunkLen,
|
||||||
|
bool theIsPartialPayload = false)
|
||||||
{
|
{
|
||||||
myDataRead = 0;
|
myDataRead = 0;
|
||||||
|
if (theIsPartialPayload)
|
||||||
|
{
|
||||||
|
myDataLen = theDataLen;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
myDataLen = theDataLen - theDataLen % int64_t(theChunkLen);
|
myDataLen = theDataLen - theDataLen % int64_t(theChunkLen);
|
||||||
|
}
|
||||||
myChunkLen = theChunkLen;
|
myChunkLen = theChunkLen;
|
||||||
myNbChunks = sizeof(myBuffer) / theChunkLen;
|
myNbChunks = sizeof(myBuffer) / theChunkLen;
|
||||||
myBufferLen = theChunkLen * myNbChunks;
|
myBufferLen = theChunkLen * myNbChunks;
|
||||||
@ -95,7 +107,7 @@ private:
|
|||||||
}
|
}
|
||||||
|
|
||||||
const int64_t aDataLeft = myDataLen - myDataRead;
|
const int64_t aDataLeft = myDataLen - myDataRead;
|
||||||
if (aDataLeft == 0) // myDataLen should be multiple of myChunkLen
|
if (aDataLeft <= 0) // myDataLen is normally multiple of myChunkLen, but can be smaller in interleaved data
|
||||||
{
|
{
|
||||||
myBufferPtr = NULL;
|
myBufferPtr = NULL;
|
||||||
return NULL;
|
return NULL;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user