------------------------------------------------------------------------------
| 106 | |
| 107 | //------------------------------------------------------------------------------ |
| 108 | void vtkJSONRenderWindowExporter::WriteData() |
| 109 | { |
| 110 | if (this->GetSerializer() == nullptr) |
| 111 | { |
| 112 | vtkErrorMacro(<< "No scene!"); |
| 113 | return; |
| 114 | } |
| 115 | this->GetSerializer()->Reset(); |
| 116 | |
| 117 | if (this->GetArchiver() == nullptr) |
| 118 | { |
| 119 | vtkErrorMacro(<< "No archiver!"); |
| 120 | return; |
| 121 | } |
| 122 | |
| 123 | if (this->GetArchiver()->GetArchiveName() == nullptr) |
| 124 | { |
| 125 | vtkErrorMacro(<< "Please specify Archive Name to use"); |
| 126 | return; |
| 127 | } |
| 128 | |
| 129 | // Populate the scene instance |
| 130 | { |
| 131 | // Construct a top-level node for the render window |
| 132 | vtkViewNode* vn = this->Factory->CreateNode(this->RenderWindow); |
| 133 | |
| 134 | // Build the scene graph |
| 135 | vn->Traverse(vtkViewNode::build); |
| 136 | |
| 137 | // Construct the vtk-js representation of the scene graph |
| 138 | vn->Traverse(vtkViewNode::synchronize); |
| 139 | |
| 140 | // Update the datasets associated with the scene graph |
| 141 | vn->Traverse(vtkViewNode::render); |
| 142 | |
| 143 | // Delete the top level node |
| 144 | vn->Delete(); |
| 145 | } |
| 146 | |
| 147 | // Open the archive for writing |
| 148 | this->GetArchiver()->OpenArchive(); |
| 149 | |
| 150 | // Write the top-level index file describing the scene elements and their |
| 151 | // topology. |
| 152 | { |
| 153 | std::stringstream stream; |
| 154 | Json::StreamWriterBuilder builder; |
| 155 | builder["commentStyle"] = "None"; |
| 156 | builder["indentation"] = this->CompactOutput ? "" : " "; |
| 157 | std::unique_ptr<Json::StreamWriter> writer(builder.newStreamWriter()); |
| 158 | writer->write(this->GetSerializer()->GetRoot(), &stream); |
| 159 | |
| 160 | std::string index = stream.str(); |
| 161 | this->GetArchiver()->InsertIntoArchive("index.json", index.c_str(), index.size()); |
| 162 | } |
| 163 | |
| 164 | // Write the associated data arrays into the archive |
| 165 | { |
nothing calls this directly
no test coverage detected