Commit 23a15753 authored by Patrick Avery's avatar Patrick Avery
Browse files

Do not re-write textures in vtkJSONSceneExporter



If a texture has already been written out once, re-use it rather than
writing it out again. This goes for texture LODs as well.

Signed-off-by: Patrick Avery's avatarPatrick Avery <patrick.avery@kitware.com>
parent a3052474
......@@ -77,10 +77,6 @@ void vtkJSONSceneExporter::WriteDataObject(ostream& os, vtkDataObject* dataObjec
// Handle Dataset
if (dataObject->IsA("vtkDataSet"))
{
// TODO: for composite data sets, the textures and texture LODs
// would be written out multiple times here. Perhaps we should
// re-think this? Or, if composite data sets normally don't have
// textures, this is probably fine...
std::string texturesString;
if (this->WriteTextures && actor->GetTexture())
{
......@@ -289,6 +285,8 @@ void vtkJSONSceneExporter::WriteLookupTable(const char* name, vtkScalarsToColors
void vtkJSONSceneExporter::WriteData()
{
this->DatasetCount = 0;
this->TextureStrings.clear();
this->TextureLODStrings.clear();
// make sure the user specified a FileName or FilePointer
if (this->FileName == nullptr)
......@@ -403,6 +401,13 @@ size_t getFileSize(const std::string& path)
std::string vtkJSONSceneExporter::WriteTexture(vtkTexture* texture)
{
// If this texture has already been written, just re-use the one
// we have.
if (this->TextureStrings.find(texture) != this->TextureStrings.end())
{
return this->TextureStrings[texture];
}
std::string path = this->CurrentDataSetPath();
// Make sure it exists
......@@ -425,6 +430,7 @@ std::string vtkJSONSceneExporter::WriteTexture(vtkTexture* texture)
const char* INDENT = " ";
std::stringstream config;
config << ",\n" << INDENT << "\"texture\": \"" << this->DatasetCount + 1 << "/texture.jpg\"";
this->TextureStrings[texture] = config.str();
return config.str();
}
......@@ -432,6 +438,13 @@ std::string vtkJSONSceneExporter::WriteTexture(vtkTexture* texture)
std::string vtkJSONSceneExporter::WriteTextureLODSeries(vtkTexture* texture)
{
// If this texture has already been written, just re-use the one
// we have.
if (this->TextureLODStrings.find(texture) != this->TextureLODStrings.end())
{
return this->TextureLODStrings[texture];
}
std::vector<std::string> files;
std::string name = "texture";
......@@ -508,6 +521,7 @@ std::string vtkJSONSceneExporter::WriteTextureLODSeries(vtkTexture* texture)
config << INDENT << " ]\n" << INDENT << "}";
this->TextureLODStrings[texture] = config.str();
return config.str();
}
......
......@@ -119,6 +119,8 @@ protected:
char* TextureLODsBaseUrl;
int DatasetCount;
std::map<std::string, std::string> LookupTables;
std::map<vtkTexture*, std::string> TextureStrings;
std::map<vtkTexture*, std::string> TextureLODStrings;
private:
vtkJSONSceneExporter(const vtkJSONSceneExporter&) = delete;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment