| 38 | } |
| 39 | |
| 40 | void mitk::ContourModelSetWriter::Write() |
| 41 | { |
| 42 | std::ostream *out; |
| 43 | std::ofstream outStream; |
| 44 | |
| 45 | if (this->GetOutputStream()) |
| 46 | { |
| 47 | out = this->GetOutputStream(); |
| 48 | } |
| 49 | else |
| 50 | { |
| 51 | outStream.open(this->GetOutputLocation().c_str()); |
| 52 | out = &outStream; |
| 53 | } |
| 54 | |
| 55 | if (!out->good()) |
| 56 | { |
| 57 | mitkThrow() << "Stream not good."; |
| 58 | } |
| 59 | |
| 60 | *out << "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"; |
| 61 | |
| 62 | // Use regular ContourModel writer to write each contour of the set to a single file. |
| 63 | // Just use a different file extension .cnt_set |
| 64 | |
| 65 | bool writeXMLHeader = false; |
| 66 | mitk::ContourModelWriter writer(writeXMLHeader); |
| 67 | |
| 68 | mitk::ContourModelSet::ConstPointer contourModelSet = dynamic_cast<const mitk::ContourModelSet *>(this->GetInput()); |
| 69 | |
| 70 | // |
| 71 | // for each contour object set input of writer |
| 72 | // |
| 73 | for (int i = 0; i < contourModelSet->GetSize(); ++i) |
| 74 | { |
| 75 | const mitk::ContourModel *contour = contourModelSet->GetContourModelAt(i); |
| 76 | writer.SetInput(contour); |
| 77 | writer.SetOutputStream(this->GetOutputLocation(), out); |
| 78 | writer.Write(); |
| 79 | } |
| 80 | } |
| 81 | |
| 82 | mitk::ContourModelSetWriter *mitk::ContourModelSetWriter::Clone() const |
| 83 | { |
nothing calls this directly
no test coverage detected