Skip to content

Commit 1967bc3

Browse files
committed
fix
1 parent ba3ae90 commit 1967bc3

File tree

3 files changed

+50
-55
lines changed

3 files changed

+50
-55
lines changed

application/testing/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1632,8 +1632,6 @@ set_tests_properties(f3d::TestNoFileFileNameTemplate PROPERTIES PASS_REGULAR_EXP
16321632
set_tests_properties(f3d::TestNoFileFileNameTemplate PROPERTIES ENVIRONMENT "CTEST_F3D_NO_DATA_FORCE_RENDER=1")
16331633

16341634
if(NOT WIN32)
1635-
f3d_test(NAME TestInvalidCache ENV "HOME=" REGEXP "Could not use default cache directory" NO_BASELINE)
1636-
16371635
add_test(NAME f3d::TestHOMEOutput COMMAND $<TARGET_FILE:f3d> ${F3D_SOURCE_DIR}/testing/data/suzanne.stl --output=~/Testing/Temporary/TestHOMEOutput.png --resolution=300,300 --no-config)
16381636
set_tests_properties(f3d::TestHOMEOutput PROPERTIES ENVIRONMENT "HOME=${CMAKE_BINARY_DIR}")
16391637
set_tests_properties(f3d::TestHOMEOutput PROPERTIES FIXTURES_SETUP f3d::TestHOMEOutput_FIXTURE)

library/testing/TestSDKEngineExceptions.cxx

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,5 @@ int TestSDKEngineExceptions([[maybe_unused]] int argc, [[maybe_unused]] char* ar
7272
test.expect<f3d::engine::plugin_exception>("load plugin with invalid long name",
7373
[&]() { f3d::engine::loadPlugin("/" + std::string(257, 'x') + "/file.ext"); });
7474

75-
#if defined(__linux__) || defined(__FreeBSD__)
76-
// Test error handling without "HOME" set
77-
unsetenv("HOME");
78-
test.expect<f3d::engine::cache_exception>(
79-
"Create engine without HOME set", [&]() { std::ignore = f3d::engine::createNone(); });
80-
#endif
81-
8275
return test.result();
8376
}

vtkext/private/module/vtkF3DRenderer.cxx

Lines changed: 50 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,6 @@ std::string ComputeFileHash(const std::string& filepath)
149149
return md5Hash;
150150
}
151151

152-
#ifndef __EMSCRIPTEN__
153152
//----------------------------------------------------------------------------
154153
// Download texture from the GPU to a vtkImageData
155154
vtkSmartPointer<vtkImageData> SaveTextureToImage(
@@ -174,7 +173,6 @@ vtkSmartPointer<vtkImageData> SaveTextureToImage(
174173

175174
return img;
176175
}
177-
#endif
178176

179177
//----------------------------------------------------------------------------
180178
// TODO : add this function in a utils file for rendering in VTK directly
@@ -1312,16 +1310,17 @@ void vtkF3DRenderer::ConfigureHDRILUT()
13121310
}
13131311
assert(lut->GetTextureObject());
13141312

1315-
#ifndef __EMSCRIPTEN__
1316-
vtkSmartPointer<vtkImageData> img = ::SaveTextureToImage(
1317-
lut->GetTextureObject(), GL_TEXTURE_2D, 0, lut->GetLUTSize(), VTK_UNSIGNED_SHORT);
1318-
assert(img);
1313+
if (!this->CachePath.empty())
1314+
{
1315+
vtkSmartPointer<vtkImageData> img = ::SaveTextureToImage(
1316+
lut->GetTextureObject(), GL_TEXTURE_2D, 0, lut->GetLUTSize(), VTK_UNSIGNED_SHORT);
1317+
assert(img);
13191318

1320-
vtkNew<vtkXMLImageDataWriter> writer;
1321-
writer->SetFileName(lutCachePath.c_str());
1322-
writer->SetInputData(img);
1323-
writer->Write();
1324-
#endif
1319+
vtkNew<vtkXMLImageDataWriter> writer;
1320+
writer->SetFileName(lutCachePath.c_str());
1321+
writer->SetInputData(img);
1322+
writer->Write();
1323+
}
13251324
}
13261325
this->HasValidHDRILUT = true;
13271326
}
@@ -1356,16 +1355,17 @@ void vtkF3DRenderer::ConfigureHDRISphericalHarmonics()
13561355
vtkTable::SafeDownCast(sh->GetOutputDataObject(0))->GetColumn(0));
13571356
}
13581357

1359-
#ifndef __EMSCRIPTEN__
1360-
// Create spherical harmonics cache file
1361-
vtkNew<vtkTable> table;
1362-
table->AddColumn(this->SphericalHarmonics);
1363-
1364-
vtkNew<vtkXMLTableWriter> writer;
1365-
writer->SetInputData(table);
1366-
writer->SetFileName(shCachePath.c_str());
1367-
writer->Write();
1368-
#endif
1358+
if (!this->CachePath.empty())
1359+
{
1360+
// Create spherical harmonics cache file
1361+
vtkNew<vtkTable> table;
1362+
table->AddColumn(this->SphericalHarmonics);
1363+
1364+
vtkNew<vtkXMLTableWriter> writer;
1365+
writer->SetInputData(table);
1366+
writer->SetFileName(shCachePath.c_str());
1367+
writer->Write();
1368+
}
13691369
}
13701370
this->HasValidHDRISH = true;
13711371
}
@@ -1398,30 +1398,31 @@ void vtkF3DRenderer::ConfigureHDRISpecular()
13981398
}
13991399
assert(spec->GetTextureObject());
14001400

1401-
#ifndef __EMSCRIPTEN__
1402-
unsigned int nbLevels = spec->GetPrefilterLevels();
1403-
unsigned int size = spec->GetPrefilterSize();
1401+
if (!this->CachePath.empty())
1402+
{
1403+
unsigned int nbLevels = spec->GetPrefilterLevels();
1404+
unsigned int size = spec->GetPrefilterSize();
14041405

1405-
vtkNew<vtkMultiBlockDataSet> mb;
1406-
mb->SetNumberOfBlocks(nbLevels);
1406+
vtkNew<vtkMultiBlockDataSet> mb;
1407+
mb->SetNumberOfBlocks(nbLevels);
14071408

1408-
for (unsigned int i = 0; i < nbLevels; i++)
1409-
{
1410-
vtkSmartPointer<vtkImageData> img = ::SaveTextureToImage(
1411-
spec->GetTextureObject(), GL_TEXTURE_CUBE_MAP_POSITIVE_X, i, size >> i, VTK_FLOAT);
1412-
assert(img);
1413-
mb->SetBlock(i, img);
1414-
}
1409+
for (unsigned int i = 0; i < nbLevels; i++)
1410+
{
1411+
vtkSmartPointer<vtkImageData> img = ::SaveTextureToImage(
1412+
spec->GetTextureObject(), GL_TEXTURE_CUBE_MAP_POSITIVE_X, i, size >> i, VTK_FLOAT);
1413+
assert(img);
1414+
mb->SetBlock(i, img);
1415+
}
14151416

1416-
vtkNew<vtkXMLMultiBlockDataWriter> writer;
1417-
writer->SetCompressorTypeToNone();
1418-
writer->SetDataModeToAppended();
1419-
writer->EncodeAppendedDataOff();
1420-
writer->SetHeaderTypeToUInt64();
1421-
writer->SetFileName(specCachePath.c_str());
1422-
writer->SetInputData(mb);
1423-
writer->Write();
1424-
#endif
1417+
vtkNew<vtkXMLMultiBlockDataWriter> writer;
1418+
writer->SetCompressorTypeToNone();
1419+
writer->SetDataModeToAppended();
1420+
writer->EncodeAppendedDataOff();
1421+
writer->SetHeaderTypeToUInt64();
1422+
writer->SetFileName(specCachePath.c_str());
1423+
writer->SetInputData(mb);
1424+
writer->Write();
1425+
}
14251426
}
14261427
this->HasValidHDRISpec = true;
14271428
}
@@ -2071,11 +2072,14 @@ void vtkF3DRenderer::CreateCacheDirectory()
20712072
{
20722073
assert(this->HasValidHDRIHash);
20732074

2074-
// Cache folder for this HDRI
2075-
std::string currentCachePath = this->CachePath + "/" + this->HDRIHash;
2075+
if (!this->CachePath.empty())
2076+
{
2077+
// Cache folder for this HDRI
2078+
std::string currentCachePath = this->CachePath + "/" + this->HDRIHash;
20762079

2077-
// Create the folder if it does not exists
2078-
vtksys::SystemTools::MakeDirectory(currentCachePath);
2080+
// Create the folder if it does not exists
2081+
vtksys::SystemTools::MakeDirectory(currentCachePath);
2082+
}
20792083
}
20802084

20812085
//----------------------------------------------------------------------------

0 commit comments

Comments
 (0)