MCPcopy Create free account
hub / github.com/Kitware/VTK / WriteTexture

Method WriteTexture

IO/Export/vtkJSONSceneExporter.cxx:794–827  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

792
793//------------------------------------------------------------------------------
794std::string vtkJSONSceneExporter::WriteTexture(vtkTexture* texture)
795{
796 // If this texture has already been written, just reuse the one
797 // we have.
798 if (this->TextureStrings.find(texture) != this->TextureStrings.end())
799 {
800 return this->TextureStrings[texture];
801 }
802
803 std::string path = this->CurrentDataSetPath();
804
805 // Make sure it exists
806 if (!vtksys::SystemTools::MakeDirectory(path))
807 {
808 vtkErrorMacro(<< "Cannot create directory " << path);
809 return "";
810 }
811
812 path += "/texture.jpg";
813 path = vtksys::SystemTools::ConvertToOutputPath(path);
814
815 vtkSmartPointer<vtkImageData> image = texture->GetInput();
816
817 vtkNew<vtkJPEGWriter> writer;
818 writer->SetFileName(path.c_str());
819 writer->SetInputDataObject(image);
820 writer->Write();
821
822 constexpr const char* INDENT = " ";
823 std::stringstream config;
824 config << ",\n" << INDENT << "\"texture\": \"" << this->DatasetCount + 1 << "/texture.jpg\"";
825 this->TextureStrings[texture] = config.str();
826 return config.str();
827}
828
829//------------------------------------------------------------------------------
830std::string vtkJSONSceneExporter::WriteTextureLODSeries(vtkTexture* texture)

Callers 1

WriteDataObjectMethod · 0.95

Calls 9

CurrentDataSetPathMethod · 0.95
findMethod · 0.45
endMethod · 0.45
GetInputMethod · 0.45
SetFileNameMethod · 0.45
c_strMethod · 0.45
SetInputDataObjectMethod · 0.45
WriteMethod · 0.45
strMethod · 0.45

Tested by

no test coverage detected