| 88 | } |
| 89 | |
| 90 | void mitk::ContourModelWriter::Write() |
| 91 | { |
| 92 | std::ostream *out; |
| 93 | std::ofstream outStream; |
| 94 | |
| 95 | if (this->GetOutputStream()) |
| 96 | { |
| 97 | out = this->GetOutputStream(); |
| 98 | } |
| 99 | else |
| 100 | { |
| 101 | outStream.open(this->GetOutputLocation().c_str()); |
| 102 | out = &outStream; |
| 103 | } |
| 104 | |
| 105 | if (!out->good()) |
| 106 | { |
| 107 | mitkThrow() << "Stream not good."; |
| 108 | } |
| 109 | |
| 110 | std::locale previousLocale(out->getloc()); |
| 111 | out->imbue(std::locale::classic()); |
| 112 | |
| 113 | /*+++++++++++ Here the actual xml writing begins +++++++++*/ |
| 114 | |
| 115 | /*++++ <?xml version="1.0" encoding="utf-8"?> ++++*/ |
| 116 | if (m_WriteXMLHeader) |
| 117 | WriteXMLHeader(*out); |
| 118 | |
| 119 | // |
| 120 | // for each input object write its xml representation to |
| 121 | // the stream |
| 122 | // |
| 123 | mitk::ContourModel::ConstPointer contourModel = dynamic_cast<const mitk::ContourModel *>(this->GetInput()); |
| 124 | assert(contourModel.IsNotNull()); |
| 125 | WriteXML(contourModel.GetPointer(), *out); |
| 126 | |
| 127 | out->imbue(previousLocale); |
| 128 | |
| 129 | if (!out->good()) // some error during output |
| 130 | { |
| 131 | throw std::ios_base::failure("Some error during contour writing."); |
| 132 | } |
| 133 | } |
| 134 | |
| 135 | mitk::ContourModelWriter *mitk::ContourModelWriter::Clone() const |
| 136 | { |
no test coverage detected