void ZFlyEmMisc::HackathonEvaluator::processNeuronTypeFile() { ZJsonObject jsonObject; jsonObject.load(getNeuronInfoFile()); const char *key; json_t *value; std::map<std::string, int> typeLabelMap; std::vector<int> bodyIdArray; std::vector<int> labelArray; int maxLabel = 0; ZJsonArray idJson; ZJsonArray labelJson; ZJsonObject_foreach(jsonObject, key, value) { int bodyId = ZString(key).firstInteger(); ZJsonObject bodyJson(value, ZJsonValue::SET_INCREASE_REF_COUNT); std::string type = ZJsonParser::stringValue(bodyJson["Type"]); if (typeLabelMap.count(type) == 0) { typeLabelMap[type] = ++maxLabel; } int label = typeLabelMap[type]; bodyIdArray.push_back(bodyId); labelArray.push_back(label); idJson.append(bodyId); labelJson.append(label); }
ZJsonObject ZDvidTarget::toJsonObject() const { ZJsonObject obj = m_node.toJsonObject(); obj.setNonEmptyEntry(m_commentKey, m_comment); obj.setNonEmptyEntry(m_nameKey, m_name); obj.setNonEmptyEntry(m_localKey, m_localFolder); obj.setEntry(m_bgValueKey, m_bgValue); obj.setNonEmptyEntry(m_bodyLabelNameKey, m_bodyLabelName); obj.setNonEmptyEntry(m_segmentationNameKey, m_segmentationName); obj.setEntry(m_maxLabelZoomKey, m_maxLabelZoom); obj.setEntry(m_maxGrayscaleZoomKey, getMaxGrayscaleZoom()); obj.setNonEmptyEntry(m_grayScaleNameKey, m_grayScaleName); obj.setNonEmptyEntry(m_synapseLabelszKey, m_synapseLabelszName); obj.setNonEmptyEntry(m_roiNameKey, m_roiName); obj.setNonEmptyEntry(m_todoListNameKey, m_todoListName); obj.setEntry(m_proofreadingKey, !m_readOnly); ZJsonArray jsonArray; for (std::vector<std::string>::const_iterator iter = m_roiList.begin(); iter != m_roiList.end(); ++iter) { jsonArray.append(*iter); } obj.setEntry(m_roiListKey, jsonArray); obj.setEntry(m_multiscale2dNameKey, m_multiscale2dName); if (!m_tileConfig.empty()) { /* ZJsonObject tileConfigJson; for (const auto& tg : m_tileConfig) { ZJsonObject subjson = tg.second.toJsonObject(); tileConfigJson.setEntry(tg.first.c_str(), subjson); } */ ZJsonObject tileConfigJson = MakeJsonObject(m_tileConfig); obj.setEntry(m_tileConfigKey, tileConfigJson); } /* if (!m_tileConfig.isEmpty()) { obj.setEntry(m_tileConfigKey, const_cast<ZJsonObject&>(m_tileConfig)); } */ if (!m_sourceConfig.empty()) { ZJsonObject sourceConfigJson = MakeJsonObject(m_sourceConfig); obj.setEntry(m_sourceConfigKey, sourceConfigJson); // obj.setEntry(m_sourceConfigKey, const_cast<ZJsonObject&>(m_sourceConfig)); } obj.setEntry(m_synapseNameKey, m_synapseName); obj.setEntry(m_supervisorKey, m_isSupervised); obj.setEntry(m_supervisorServerKey, m_supervisorServer); obj.setEntry(m_defaultSettingKey, usingDefaultDataSetting()); return obj; }
ZJsonObject Z3DCamera::toJsonObject() const { ZJsonObject cameraJson; ZJsonArray eyeJson; eyeJson.append(m_eye[0]); eyeJson.append(m_eye[1]); eyeJson.append(m_eye[2]); cameraJson.setEntry("eye", eyeJson); ZJsonArray centerJson; centerJson.append(m_center[0]); centerJson.append(m_center[1]); centerJson.append(m_center[2]); cameraJson.setEntry("center", centerJson); ZJsonArray upVectorJson; upVectorJson.append(m_upVector[0]); upVectorJson.append(m_upVector[1]); upVectorJson.append(m_upVector[2]); cameraJson.setEntry("up_vector", upVectorJson); switch (m_projectionType) { case Perspective: cameraJson.setEntry("projection", std::string("Perspective")); break; case Orthographic: cameraJson.setEntry("projection", std::string("Orthographic")); break; } cameraJson.setEntry("field_of_view", m_fieldOfView); cameraJson.setEntry("aspect_ratio", m_aspectRatio); cameraJson.setEntry("near_dist", m_nearDist); cameraJson.setEntry("far_dist", m_farDist); return cameraJson; }