void ZDvidTile::update(int z) { if (m_z != z || m_image == NULL) { #if defined(_ENABLE_LIBDVIDCPP_2) std::vector<int> offset(3); offset[0] = m_ix; offset[1] = m_iy; offset[2] = z; tic(); try { libdvid::DVIDNodeService service(getDvidTarget().getAddressWithPort(), getDvidTarget().getUuid()); libdvid::BinaryDataPtr data = service.get_tile_slice_binary( "tiles", libdvid::XY, m_res.getLevel(), offset); if (data->length() > 0) { loadDvidSlice(data->get_raw(), data->length(), z); m_image->setScale(1.0 / m_res.getScale(), 1.0 / m_res.getScale()); m_image->setOffset(-getX(), -getY()); } } catch (std::exception &e) { std::cout << e.what() << std::endl; } std::cout << "Tile level: " << m_res.getLevel() << std::endl; std::cout << "Tile reading time: " << toc() << std::endl; #else ZDvidUrl dvidUrl(getDvidTarget()); ZDvidBufferReader bufferReader; /* QFuture<void> result = QtConcurrent::run( &bufferReader, &ZDvidBufferReader::read, QString(dvidUrl.getTileUrl("graytiles", m_res.getLevel(), m_ix, m_iy, z).c_str())); result.waitForFinished(); */ tic(); bufferReader.read( dvidUrl.getTileUrl(getDvidTarget().getMultiscale2dName(), m_res.getLevel(), m_ix, m_iy, z).c_str()); QByteArray buffer = bufferReader.getBuffer(); std::cout << "Tile reading time: " << toc() << std::endl; // ZDvidTileInfo tileInfo = readTileInfo("graytiles"); if (!buffer.isEmpty()) { loadDvidSlice(buffer, z); // m_image->setScale(1.0 / m_res.getScale(), 1.0 / m_res.getScale()); // m_image->setOffset(-getX(), -getY()); // setResolutionLevel(m_res.getLevel()); } #endif } //m_z = z; }
int ZSplitTaskUploadCommand::run( const std::vector<std::string> &input, const std::string &/*output*/, const ZJsonObject &config) { ZJsonObject dvidJson(config.value("dvid")); if (dvidJson.isEmpty()) { std::cerr << "No dvid server specified. Abort." << std::endl; return 1; } if (input.empty()) { std::cerr << "No input file specified. Abort." << std::endl; return 1; } ZDvidTarget target; target.loadJsonObject(dvidJson); if (!target.isValid()) { std::cerr << "No valide dvid server specified. Abort." << std::endl; return 1; } if (target.getBodyLabelName().empty()) { std::cerr << "No sparsevol data specified. Abort." << std::endl; return 1; } ZJsonObject docJson; docJson.load(input.front()); ZJsonArray rootObj(docJson.value("meshReview")); if (rootObj.isEmpty()) { std::cerr << "Unrecognized input format. Abort." << std::endl; return 1; } ZDvidWriter *writer = ZGlobal::GetInstance().getDvidWriterFromUrl( GET_FLYEM_CONFIG.getTaskServer()); if (writer == NULL) { std::cerr << "Unable to Initialize the task server: " << GET_FLYEM_CONFIG.getTaskServer() << std::endl; std::cerr << "Abort" << std::endl; return 1; } else { std::cout << "Task server: " << writer->getDvidTarget().getSourceString() << std::endl; } ZDvidUrl dvidUrl(target); std::cout << std::endl; std::cout << "Uploading tasks: " << std::endl << std::endl; int count = 0; for (size_t i = 0; i < rootObj.size(); ++i) { ZJsonObject obj(rootObj.value(i)); ZJsonArray markerJson(obj.value("pointMarkers")); #ifdef _DEBUG_2 std::cout << "Here"; #endif if (!markerJson.isEmpty()) { uint64_t bodyId = ZString(obj.value("file").toString()).firstUint64(); if (bodyId > 0) { ZJsonObject taskJson; ZFlyEmMisc::SetSplitTaskSignalUrl(taskJson, bodyId, target); for (size_t i = 0; i < markerJson.size(); ++i) { ZJsonObject markerObj(markerJson.value(i)); ZStroke2d stroke = ZFlyEmMisc::SyGlassSeedToStroke(markerObj); ZFlyEmMisc::AddSplitTaskSeed(taskJson, stroke); } std::string location = writer->writeServiceTask("split", taskJson); ZJsonObject entryJson; entryJson.setEntry(neutube::json::REF_KEY, location); QString taskKey = dvidUrl.getSplitTaskKey(bodyId).c_str(); writer->writeSplitTask(taskKey, taskJson); std::cout << "* Task for " << bodyId << " is saved @ " << taskKey.toStdString() << "->" << location << std::endl; ++count; } } } std::cout << std::endl; std::cout << count << " tasks uploaded." << std::endl; return 0; }