/***************************************************************************************** * * * OpenSpace * * * * Copyright (c) 2014-2025 * * * * Permission is hereby granted, free of charge, to any person obtaining a copy of this * * software and associated documentation files (the "Software"), to deal in the Software * * without restriction, including without limitation the rights to use, copy, modify, * * merge, publish, distribute, sublicense, and/or sell copies of the Software, and to * * permit persons to whom the Software is furnished to do so, subject to the following * * conditions: * * * * The above copyright notice and this permission notice shall be included in all copies * * or substantial portions of the Software. * * * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, * * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT * * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF * * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE * * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ #include #include #include #include #include #include #include namespace openspace { documentation::Documentation MilkywayPointsConversionTask::Documentation() { return { "MilkywayPointsConversionTask", "galaxy_milkywaypointsconversiontask", "", {} }; } MilkywayPointsConversionTask::MilkywayPointsConversionTask(const ghoul::Dictionary&) {} std::string MilkywayPointsConversionTask::description() { return std::string(); } void MilkywayPointsConversionTask::perform(const Task::ProgressCallback& progressCallback) { std::ifstream in = std::ifstream(_inFilename, std::ios::in); std::ofstream out = std::ofstream(_outFilename, std::ios::out | std::ios::binary); std::string format; int64_t nPoints = 0; in >> format >> nPoints; const size_t nFloats = nPoints * 7; std::vector pointData(nFloats); float x = 0.f; float y = 0.f; float z = 0.f; float r = 0.f; float g = 0.f; float b = 0.f; float a = 0.f; for (int64_t i = 0; i < nPoints; i++) { in >> x >> y >> z >> r >> g >> b >> a; if (in.good()) { pointData[i * 7 + 0] = x; pointData[i * 7 + 1] = y; pointData[i * 7 + 2] = z; pointData[i * 7 + 3] = r; pointData[i * 7 + 4] = g; pointData[i * 7 + 5] = b; pointData[i * 7 + 6] = a; progressCallback(static_cast(i + 1) / nPoints); } else { std::cout << "Failed to convert point data"; return; } } out.write(reinterpret_cast(&nPoints), sizeof(int64_t)); out.write(reinterpret_cast(pointData.data()), nFloats * sizeof(float)); } } // namespace openspace