MCPcopy Create free account
hub / github.com/OctoMap/octomap / readHeader

Method readHeader

octomap/src/AbstractOcTree.cpp:119–182  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

117 }
118
119 bool AbstractOcTree::readHeader(std::istream& s, std::string& id, unsigned& size, double& res){
120 id = "";
121 size = 0;
122 res = 0.0;
123
124 std::string token;
125 bool headerRead = false;
126 while(s.good() && !headerRead) {
127 s >> token;
128 if (token == "data"){
129 headerRead = true;
130 // skip forward until end of line:
131 char c;
132 do {
133 c = s.get();
134 } while(s.good() && (c != '\n'));
135 }
136 else if (token.compare(0,1,"#") == 0){
137 // comment line, skip forward until end of line:
138 char c;
139 do {
140 c = s.get();
141 } while(s.good() && (c != '\n'));
142 }
143 else if (token == "id")
144 s >> id;
145 else if (token == "res")
146 s >> res;
147 else if (token == "size")
148 s >> size;
149 else{
150 OCTOMAP_WARNING_STR("Unknown keyword in OcTree header, skipping: "<<token);
151 char c;
152 do {
153 c = s.get();
154 } while(s.good() && (c != '\n'));
155
156 }
157
158 }
159
160 if (!headerRead) {
161 OCTOMAP_ERROR_STR("Error reading OcTree header");
162 return false;
163 }
164
165 if (id == "") {
166 OCTOMAP_ERROR_STR("Error reading OcTree header, ID not set");
167 return false;
168 }
169
170 if (res <= 0.0) {
171 OCTOMAP_ERROR_STR("Error reading OcTree header, res <= 0.0");
172 return false;
173 }
174 // fix deprecated id value:
175 if (id == "1"){
176 OCTOMAP_WARNING("You are using a deprecated id \"%s\", changing to \"OcTree\" (you should update your file header)\n", id.c_str());

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected