| 148 | } |
| 149 | |
| 150 | Json::ArrayIndex vtkVtkJSSceneGraphSerializer::Internal::uniqueId(void* ptr) |
| 151 | { |
| 152 | Json::ArrayIndex id; |
| 153 | if (ptr == nullptr) |
| 154 | { |
| 155 | // There is no associated address for this unique id. |
| 156 | id = Json::ArrayIndex(UniqueIdCount++); |
| 157 | } |
| 158 | else |
| 159 | { |
| 160 | // There is an associated address for this unique id, so we use it to ensure |
| 161 | // that subsequent calls will return the same id. |
| 162 | auto search = UniqueIds.find(ptr); |
| 163 | if (search != UniqueIds.end()) |
| 164 | { |
| 165 | id = search->second; |
| 166 | } |
| 167 | else |
| 168 | { |
| 169 | id = Json::ArrayIndex(UniqueIdCount++); |
| 170 | UniqueIds[ptr] = id; |
| 171 | } |
| 172 | } |
| 173 | return id; |
| 174 | } |
| 175 | |
| 176 | //------------------------------------------------------------------------------ |
| 177 | vtkStandardNewMacro(vtkVtkJSSceneGraphSerializer); |