70 std::string category =
"Contour File";
93 std::ofstream outStream;
110 std::locale previousLocale(out->getloc());
124 assert(contourModel.IsNotNull());
125 WriteXML(contourModel.GetPointer(), *out);
127 out->imbue(previousLocale);
131 throw std::ios_base::failure(
"Some error during contour writing.");
164 for (
unsigned int i = 0; i < timecount; i++)
167 std::vector<std::string> at;
169 std::vector<std::string> val;
172 at.push_back(
"isClosed");
188 std::vector<std::string> attr;
189 attr.push_back(
"IsControlPoint");
190 std::vector<std::string> value;
237 template <
typename T>
240 std::ostringstream o;
249 return "conversion error";
254 file <<
"<?xml version=\"1.0\" encoding=\"utf-8\"?>";
261 file << '<' << tag << '>
'; 265 void mitk::ContourModelWriter::WriteStartElementWithAttribut(const char *const tag, 266 std::vector<std::string> attributes, 267 std::vector<std::string> values, 274 unsigned int attributesSize = attributes.size(); 275 unsigned int valuesSize = values.size(); 277 if (attributesSize == valuesSize) 279 auto attributesIt = attributes.begin(); 280 auto end = attributes.end(); 282 auto valuesIt = values.begin(); 284 while (attributesIt != end) 287 WriteCharacterData(*attributesIt, file); 289 WriteCharacterData(*valuesIt, file); 300 void mitk::ContourModelWriter::WriteEndElement(const char *const tag, std::ostream &file, const bool &indent) 308 file << '<
' << '/
' << tag << '>
'; 311 void mitk::ContourModelWriter::WriteCharacterData(const char *const data, std::ostream &file) 316 void mitk::ContourModelWriter::WriteStartElement(std::string &tag, std::ostream &file) 318 WriteStartElement(tag.c_str(), file); 321 void mitk::ContourModelWriter::WriteEndElement(std::string &tag, std::ostream &file, const bool &indent) 323 WriteEndElement(tag.c_str(), file, indent); 326 void mitk::ContourModelWriter::WriteCharacterData(std::string &data, std::ostream &file) 328 WriteCharacterData(data.c_str(), file); 331 void mitk::ContourModelWriter::WriteIndent(std::ostream &file) 333 std::string spaces(m_IndentDepth * m_Indent, ' '); 334 file << spaces.c_str(); ContourModel is a structure of linked vertices defining a contour in 3D space. The vertices are store...
mitk::Point3D Coordinates
Coordinates in 3D space.
void WriteIndent(std::ostream &file)
static const char * XML_DATA
void WriteGeometryInformation(const mitk::TimeGeometry *geometry, std::ostream &out)
static const char * XML_Z
void WriteStartElementWithAttribut(const char *const tag, std::vector< std::string > attributes, std::vector< std::string > values, std::ostream &file)
static const char * XML_POINT
static const char * XML_GEOMETRY_INFO
bool IsControlPoint
Treat point special.
static const char * XML_X
unsigned int m_IndentDepth
void WriteXMLHeader(std::ostream &file)
The CustomMimeType class represents a custom mime-type which may be registered as a service object...
const mitk::TimeGeometry * GetTimeGeometry() const
Return the TimeGeometry of the data as const pointer.
static const char * XML_CONTROL_POINTS
static const char * XML_TIME_STEP
static const char * XML_HEAD
void WriteStartElement(const char *const tag, std::ostream &file)
void Write() override
Write the base data to the specified location or output stream.
const BaseData * GetInput() const override
Get the input data set via SetInput().
VertexIterator IteratorEnd(int timestep=0) const
Returns a const VertexIterator at the end element of the contour.
void WriteEndElement(const char *const tag, std::ostream &file, const bool &indent=true)
bool IsClosed(int timestep=0) const
Return if the contour is closed or not.
void AddExtension(const std::string &extension)
void WriteCharacterData(const char *const data, std::ostream &file)
void SetCategory(const std::string &category)
~ContourModelWriter() override
std::ostream * GetOutputStream() const override
Get the output stream.
std::string ConvertToString(T value)
us::ServiceRegistration< IFileWriter > RegisterService(us::ModuleContext *context=us::GetModuleContext())
void SetMimeType(const CustomMimeType &mimeType)
unsigned int GetTimeSteps() const
Get the number of time steps from the TimeGeometry As the base data has not a data vector given by it...
static const char * XML_CONTOURMODEL
std::string GetOutputLocation() const override
Get the current output location.
void WriteXML(const mitk::ContourModel *contourModel, std::ostream &out)
VertexIterator IteratorBegin(int timestep=0) const
Returns a const VertexIterator at the start element of the contour.
mitk::ContourModelWriter * Clone() const override
Base class for writing mitk::BaseData objects to files or streams.
void SetDescription(const std::string &description)
Sets a human readable description of this writer.
static const char * XML_Y
Represents a single vertex of contour.