MCPcopy Create free account
hub / github.com/MITK/MITK / Write

Method Write

Modules/ContourModel/src/IO/mitkContourModelSetWriter.cpp:40–80  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

38}
39
40void 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
82mitk::ContourModelSetWriter *mitk::ContourModelSetWriter::Clone() const
83{

Callers

nothing calls this directly

Calls 8

GetOutputStreamMethod · 0.80
GetOutputLocationMethod · 0.80
GetContourModelAtMethod · 0.80
SetOutputStreamMethod · 0.80
openMethod · 0.45
GetInputMethod · 0.45
GetSizeMethod · 0.45
SetInputMethod · 0.45

Tested by

no test coverage detected