Revision: 65296
http://sourceforge.net/p/brlcad/code/65296
Author: ejno
Date: 2015-06-15 13:32:52 +0000 (Mon, 15 Jun 2015)
Log Message:
-----------
write Sections at end of output file
Modified Paths:
--------------
brlcad/trunk/src/libgcv/conv/fastgen4/fastgen4_write.cpp
Modified: brlcad/trunk/src/libgcv/conv/fastgen4/fastgen4_write.cpp
===================================================================
--- brlcad/trunk/src/libgcv/conv/fastgen4/fastgen4_write.cpp 2015-06-15
13:19:25 UTC (rev 65295)
+++ brlcad/trunk/src/libgcv/conv/fastgen4/fastgen4_write.cpp 2015-06-15
13:32:52 UTC (rev 65296)
@@ -429,7 +429,9 @@
SectionID take_next_section_id();
+ RecordWriter &get_section_writer();
+
protected:
virtual std::ostream &get_ostream();
@@ -439,11 +441,13 @@
static const std::size_t MAX_SECTION_ID = 999;
std::size_t m_next_section_id[MAX_GROUP_ID + 1];
+ StringBuffer m_sections;
std::ofstream m_ostream, m_colors_ostream;
};
FastgenWriter::FastgenWriter(const std::string &path) :
+ m_sections(),
m_ostream(path.c_str(), std::ofstream::out),
m_colors_ostream((path + ".colors").c_str(), std::ofstream::out)
{
@@ -458,6 +462,7 @@
inline
FastgenWriter::~FastgenWriter()
{
+ m_sections.write(*this);
Record(*this) << "ENDDATA";
}
@@ -482,6 +487,13 @@
}
+inline RecordWriter &
+FastgenWriter::get_section_writer()
+{
+ return m_sections;
+}
+
+
void
FastgenWriter::write_section_color(const SectionID §ion_id,
const Color &color)
@@ -709,6 +721,9 @@
inline Color
Section::get_color() const
{
+ if (!has_color())
+ throw std::logic_error("no color information for this Section");
+
return m_color.second;
}
@@ -724,28 +739,30 @@
void
Section::write(FastgenWriter &writer, const FastgenWriter::SectionID &id) const
{
+ RecordWriter §ions = writer.get_section_writer();
+
+ if (has_color())
+ writer.write_section_color(id, get_color());
+
{
std::string new_name = m_name;
if (new_name.size() > MAX_NAME_SIZE) {
- writer.write_comment(new_name);
+ sections.write_comment(new_name);
new_name = "..." + new_name.substr(new_name.size() - MAX_NAME_SIZE
+ 3);
}
- RecordWriter::Record record(writer);
+ RecordWriter::Record record(sections);
record << "$NAME" << id.first << id.second;
record << "" << "" << "" << "";
record.text(new_name);
}
- RecordWriter::Record(writer) << "SECTION" << id.first << id.second <<
- (m_volume_mode ? 2 : 1);
+ RecordWriter::Record(sections)
+ << "SECTION" << id.first << id.second << (m_volume_mode ? 2 : 1);
- if (has_color())
- writer.write_section_color(id, get_color());
-
- m_grids.write(writer);
- m_elements.write(writer);
+ m_grids.write(sections);
+ m_elements.write(sections);
}
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits