Skip to content
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

vtkext: Fix a small issue with CollapseFullPath usage in hdri-file an… #1844

Merged
merged 1 commit into from
Dec 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions vtkext/private/module/vtkF3DRenderer.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -637,8 +637,8 @@ void vtkF3DRenderer::ConfigureGridUsingCurrentActors()
void vtkF3DRenderer::SetHDRIFile(const std::optional<std::string>& hdriFile)
{
// Check HDRI is different than current one
std::optional<std::string> collapsedHdriFile;
if (hdriFile.has_value())
std::string collapsedHdriFile;
if (hdriFile.has_value() && !hdriFile.value().empty())
{
collapsedHdriFile = vtksys::SystemTools::CollapseFullPath(hdriFile.value());
}
Expand Down Expand Up @@ -770,25 +770,25 @@ void vtkF3DRenderer::ConfigureHDRIReader()
{
this->UseDefaultHDRI = false;
this->HDRIReader = nullptr;
if (this->HDRIFile.has_value())
if (!this->HDRIFile.empty())
{
if (!vtksys::SystemTools::FileExists(this->HDRIFile.value(), true))
if (!vtksys::SystemTools::FileExists(this->HDRIFile, true))
{
F3DLog::Print(
F3DLog::Severity::Warning, std::string("HDRI file does not exist ") + this->HDRIFile.value());
F3DLog::Severity::Warning, std::string("HDRI file does not exist ") + this->HDRIFile);
}
else
{
this->HDRIReader = vtkSmartPointer<vtkImageReader2>::Take(
vtkImageReader2Factory::CreateImageReader2(this->HDRIFile.value().c_str()));
vtkImageReader2Factory::CreateImageReader2(this->HDRIFile.c_str()));
if (this->HDRIReader)
{
this->HDRIReader->SetFileName(this->HDRIFile.value().c_str());
this->HDRIReader->SetFileName(this->HDRIFile.c_str());
}
else
{
F3DLog::Print(F3DLog::Severity::Warning,
std::string("Cannot open HDRI file ") + this->HDRIFile.value() +
std::string("Cannot open HDRI file ") + this->HDRIFile +
std::string(". Using default HDRI"));
}
}
Expand Down Expand Up @@ -821,8 +821,8 @@ void vtkF3DRenderer::ConfigureHDRIHash()
}
else
{
// Compute HDRI MD5, here we know the HDRIFile has a value
this->HDRIHash = ::ComputeFileHash(this->HDRIFile.value());
// Compute HDRI MD5, here we know the HDRIFile is not empty
this->HDRIHash = ::ComputeFileHash(this->HDRIFile);
}
this->HasValidHDRIHash = true;
this->CreateCacheDirectory();
Expand Down Expand Up @@ -1080,7 +1080,7 @@ void vtkF3DRenderer::ConfigureTextActors()

// Font
this->DropZoneActor->GetTextProperty()->SetFontFamilyToCourier();
if (this->FontFile.has_value())
if (this->FontFile.has_value() && !this->FontFile.value().empty())
{
std::string tmpFontFile = vtksys::SystemTools::CollapseFullPath(this->FontFile.value());
if (vtksys::SystemTools::FileExists(tmpFontFile, true))
Expand Down
2 changes: 1 addition & 1 deletion vtkext/private/module/vtkF3DRenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ class vtkF3DRenderer : public vtkOpenGLRenderer
int GridSubdivisions = 10;
double GridColor[3] = { 0.0, 0.0, 0.0 };

std::optional<std::string> HDRIFile;
std::string HDRIFile;
vtkSmartPointer<vtkImageReader2> HDRIReader;
bool HasValidHDRIReader = false;
bool UseDefaultHDRI = false;
Expand Down
Loading