|
| 1 | +/*========================================================================= |
| 2 | +
|
| 3 | + * Copyright NumFOCUS |
| 4 | + * |
| 5 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | + * you may not use this file except in compliance with the License. |
| 7 | + * You may obtain a copy of the License at |
| 8 | + * |
| 9 | + * https://www.apache.org/licenses/LICENSE-2.0.txt |
| 10 | + * |
| 11 | + * Unless required by applicable law or agreed to in writing, software |
| 12 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | + * See the License for the specific language governing permissions and |
| 15 | + * limitations under the License. |
| 16 | + * |
| 17 | + *=========================================================================*/ |
| 18 | + |
| 19 | +#include "itkPipeline.h" |
| 20 | +#include "itkOutputTextStream.h" |
| 21 | + |
| 22 | +#include "rapidjson/document.h" |
| 23 | +#include "rapidjson/stringbuffer.h" |
| 24 | +#include "rapidjson/writer.h" |
| 25 | + |
| 26 | +int main(int argc, char *argv[]) |
| 27 | +{ |
| 28 | + itk::wasm::Pipeline pipeline("sort-dicom-series", "Group DICOM files into volumes", argc, argv); |
| 29 | + |
| 30 | + std::vector<std::string> files; |
| 31 | + pipeline.add_option("--files", files, "DICOM files to group")->required()->check(CLI::ExistingFile)->type_size(1, -1)->type_name("INPUT_BINARY_FILE"); |
| 32 | + |
| 33 | + itk::wasm::OutputTextStream volumes; |
| 34 | + pipeline.add_option("volumes", volumes, "Files grouped into volumes")->required()->type_name("OUTPUT_JSON"); |
| 35 | + |
| 36 | + ITK_WASM_PARSE(pipeline); |
| 37 | + |
| 38 | + rapidjson::Document volumesJson; |
| 39 | + volumesJson.SetObject(); |
| 40 | + rapidjson::Document::AllocatorType &allocator = volumesJson.GetAllocator(); |
| 41 | + |
| 42 | + rapidjson::Value almostEqualValue; |
| 43 | + almostEqualValue.SetBool(false); |
| 44 | + volumesJson.AddMember("almostEqual", almostEqualValue, allocator); |
| 45 | + |
| 46 | + rapidjson::StringBuffer stringBuffer; |
| 47 | + rapidjson::Writer<rapidjson::StringBuffer> writer(stringBuffer); |
| 48 | + volumesJson.Accept(writer); |
| 49 | + volumes.Get() << stringBuffer.GetString(); |
| 50 | + |
| 51 | + return EXIT_SUCCESS; |
| 52 | +} |
0 commit comments