11 #include <boost/tuple/tuple.hpp>
23 RIFReader::RIFReader(
const std::string &geometryFileName) :
24 geometryFileName_(geometryFileName), rows_(0), columns_(0),
29 RIFReader::~RIFReader()
35 void RIFReader::init_()
39 in_.open(geometryFileName_.c_str(), std::ios::in);
41 throw ObservationIOError(std::string(
"Could not open file ") +
42 geometryFileName_ +
" for reading.");
45 while (std::getline(in_, line))
46 if (cleanLine(line) ==
"|")
break;
48 rows_ = columns_ = -1;
49 if ( !(in_ >> Match(
"float") >> Match(
"ascii") >> rows_ >> columns_) )
50 throw ObservationIOError(
"Non-RIF format.");
53 throw ObservationIOError(
"Non-RIF format.");
60 for (
unsigned i = 0; i < rows_*columns_; ++i)
66 for (
unsigned i = 0; i < rows_*columns_; ++i)
72 for (
unsigned i = 0; i < rows_*columns_; ++i)
78 for (
unsigned i = 0; i < rows_*columns_; ++i)
90 for (
unsigned r = 0; r < rows_; r++)
91 for (
unsigned c = 0; c < columns_; c++)
93 Vector3 rgb(.5,.5,.5);
103 void RIFReader::reset()
105 NUKLEI_TRACE_BEGIN();
111 NUKLEI_UNIQUE_PTR<Observation> RIFReader::readObservation_()
113 NUKLEI_TRACE_BEGIN();
114 if (rows_ == 0 || columns_ == 0)
NUKLEI_THROW(
"Reader does not seem inited.");
118 if (currentIndex_ >= rows_*columns_)
119 return NUKLEI_UNIQUE_PTR<Observation>();
121 unsigned index = currentIndex_;
124 if (flags_[index] ==
true)
continue;
126 NUKLEI_UNIQUE_PTR<RIFObservation> observation(
new RIFObservation);
128 Vector3 loc(x_[index], y_[index], z_[index]);
129 observation->setLoc(loc);
130 RGBColor c(rgb_[index]);
131 observation->setColor(c);
133 return NUKLEI_UNIQUE_PTR<Observation>(NUKLEI_MOVE(observation));
136 return NUKLEI_UNIQUE_PTR<Observation>();