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

Method WriteToStreamMultiBlock

IO/Geometry/vtkGLTFWriter.cxx:900–1134  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

898}
899
900void vtkGLTFWriter::WriteToStreamMultiBlock(ostream& output, vtkMultiBlockDataSet* mb)
901{
902 nlohmann::json cameras;
903 nlohmann::json bufferViews;
904 nlohmann::json buffers;
905 nlohmann::json accessors;
906 nlohmann::json nodes;
907 nlohmann::json meshes;
908 nlohmann::json textures;
909 nlohmann::json images;
910 nlohmann::json samplers;
911 nlohmann::json materials;
912 std::vector<size_t> topNodes;
913
914 // support sharing texture maps
915 std::map<std::string, size_t> textureMap;
916
917 vtkNew<vtkRenderer> ren;
918 double bounds[6];
919 mb->GetBounds(bounds);
920 ren->ResetCamera(bounds);
921
922 // setup the camera data in case we need to use it later
923 nlohmann::json anode;
924 anode["camera"] = cameras.size(); // camera node
925 vtkMatrix4x4* mat = ren->GetActiveCamera()->GetModelViewTransformMatrix();
926 for (int i = 0; i < 4; ++i)
927 {
928 for (int j = 0; j < 4; ++j)
929 {
930 anode["matrix"].emplace_back(mat->GetElement(j, i));
931 }
932 }
933 anode["name"] = "Camera Node";
934
935 // setup renderer group node
936 nlohmann::json rendererNode;
937 rendererNode["name"] = "Renderer Node";
938
939 nlohmann::json extensions;
940 if (this->PropertyTextureFile)
941 {
942 vtksys::ifstream propertyTextureStream(this->PropertyTextureFile, ios::binary);
943 if (propertyTextureStream.good())
944 {
945 try
946 {
947 extensions = nlohmann::json::parse(propertyTextureStream);
948 }
949 catch (nlohmann::json::parse_error& ex)
950 {
951 vtkLog(ERROR, << "Parse error " << this->PropertyTextureFile << "at byte " << ex.byte);
952 }
953 }
954 else
955 {
956 vtkLog(WARNING, "Error: Cannot open property texture file: " << this->PropertyTextureFile);
957 }

Callers

nothing calls this directly

Calls 15

GetPaddingAt4BytesFunction · 0.85
CopyStreamFunction · 0.85
GetActiveCameraMethod · 0.80
NewTreeIteratorMethod · 0.80
dumpMethod · 0.80
SetTypeJSONMethod · 0.80
SetTypeBINMethod · 0.80
WriteMeshFunction · 0.70
WriteTextureFunction · 0.70
WriteMaterialFunction · 0.70
WriteCameraFunction · 0.70
parseFunction · 0.50

Tested by

no test coverage detected