-
-
Notifications
You must be signed in to change notification settings - Fork 207
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/1187 Read EXR files from memory #1448
base: master
Are you sure you want to change the base?
Changes from 1 commit
a9d19fa
ec8dc6c
e38c111
2e0ab33
35e9c9f
5f9ae1a
c4a65f0
6d66a8f
69dc5e8
d15f044
88622bc
4ea8564
a9a6c81
ef76977
82e2b40
767eec2
e513d7a
0f910f8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,7 +25,6 @@ | |
: Imf::IStream(name) | ||
, buffer(static_cast<const char*>(buff)) | ||
, bufflen(static_cast<size_t>(bufferLen)) | ||
, pos(0) | ||
{ | ||
} | ||
|
||
|
@@ -37,16 +36,16 @@ | |
pos += n; | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
/** | ||
* returns the current reading position, in bytes, from the beginning of the file. | ||
* The next read() call will begin reading at the indicated position | ||
*/ | ||
uint64_t tellg() override | ||
{ | ||
return pos; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why isn't this line covered? Do we need to override this function if it's not called? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. from this page There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not sure to follow that answer There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if that method is not used you can just remove it ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it is a pure virtual function in the base class so i believe it needs an implementation. I can try removing it and see what happens. In the documentation i posted it says it needs an implementation. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok lets try that. Maybe its needed in some case, but not in our case. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it does not build without that function being implemented error: cannot declare variable ‘memoryStream’ to be of abstract type ‘MemStream’ There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok, lets keep it in for now. |
||
} | ||
|
||
/** | ||
|
@@ -86,13 +85,10 @@ | |
|
||
// Setup filename to read the header | ||
this->ComputeInternalFileName(this->DataExtent[4]); | ||
if (this->InternalFileName == nullptr || this->InternalFileName[0] == '\0') | ||
if ((this->InternalFileName == nullptr || this->InternalFileName[0] == '\0') && | ||
!this->MemoryBuffer) | ||
{ | ||
// If we have no file then maybe we have the file in memory | ||
if (!this->MemoryBuffer) | ||
{ | ||
return; | ||
} | ||
return; | ||
} | ||
|
||
auto execute = [&](Imf::RgbaInputFile& file) | ||
|
@@ -201,7 +197,6 @@ | |
|
||
try | ||
{ | ||
assert(this->InternalFileName); | ||
Imf::setGlobalThreadCount(std::thread::hardware_concurrency()); | ||
|
||
if (this->MemoryBuffer) | ||
|
@@ -212,6 +207,10 @@ | |
} | ||
else | ||
{ | ||
if (!(this->InternalFileName)) | ||
{ | ||
throw std::invalid_argument("Not filename in EXR Reader when no Memory Buffer is set."); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can this happen ? Do you really need to throw here ? you could just error out ? |
||
} | ||
Imf::RgbaInputFile file(this->InternalFileName); | ||
execute(file); | ||
} | ||
|
@@ -223,24 +222,6 @@ | |
} | ||
} | ||
|
||
//------------------------------------------------------------------------------ | ||
/** | ||
* Read from memory instead of file | ||
*/ | ||
void vtkF3DEXRReader::SetMemoryBuffer(const void* buff) | ||
{ | ||
MemoryBuffer = buff; | ||
} | ||
|
||
//------------------------------------------------------------------------------ | ||
/** | ||
* Specify the in memory image buffer length. | ||
*/ | ||
void vtkF3DEXRReader::SetMemoryBufferLength(vtkIdType bufferLen) | ||
{ | ||
MemoryBufferLength = bufferLen; | ||
} | ||
|
||
//------------------------------------------------------------------------------ | ||
int vtkF3DEXRReader::GetWidth() const | ||
{ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please also add `small.usdz: Copyright USD contributors: CC-BY 4.0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
with the links please