Definition at line 268 of file InterestPointListIO.h. References Impala::Core::Vector::VectorTem< ElemT >::GetData(), ILOG_DEBUG, ILOG_ERROR, ILOG_VAR, and Impala::Util::IOBuffer::Read(). Referenced by ReadPointListFromFile(). 00271 { 00272 ILOG_VAR(Sandbox.koen.ReadRegionsFromBuffer); 00273 /* Format BINDESC1 00274 ----------------------- 00275 First 8 bytes: BINDESC1 00276 Second 8 bytes: data type (CIRCLE is typical) 00277 Next 16 bytes: 4 integers: 00278 elementsPerPoint = values[0] 00279 dimensionCount = values[1] 00280 pointCount = values[2] 00281 bytesPerElement = values[3] 00282 */ 00283 int elementsPerPoint = 0; 00284 int dimensionCount = 0; 00285 int pointCount = 0; 00286 int bytesPerElement = 8; 00287 00288 String magic = "BINDESC1"; 00289 String dataType = "UNKNOWN "; 00290 String geometry = ""; 00291 00292 char buf[9]; 00293 for (int i=0 ; i<9 ; i++) 00294 buf[i] = 0; 00295 00296 ILOG_DEBUG("Reading header..."); 00297 // read magic 00298 buffer->Read(buf, 8); 00299 if(String(buf) != magic) 00300 { 00301 ILOG_ERROR("ReadPointListFromBuffer invalid magic"); 00302 return; 00303 } 00304 00305 // read dataType 00306 buffer->Read(buf, 8); 00307 dataType = String(buf); 00308 if(dataType == "CIRCLE ") 00309 { 00310 geometry = "CircleZ"; 00311 } 00312 else if(dataType == "RECT ") 00313 { 00314 geometry = "RectangleZ"; 00315 } 00316 00317 buffer->Read(&elementsPerPoint, 4); 00318 buffer->Read(&dimensionCount, 4); 00319 buffer->Read(&pointCount, 4); 00320 buffer->Read(&bytesPerElement, 4); 00321 ILOG_DEBUG("Read full header"); 00322 if(bytesPerElement != 8) 00323 { 00324 ILOG_ERROR("Can only read BINDESC1 with 8 bytes per element (double)"); 00325 return; 00326 } 00327 00328 // read the points 00329 Core::Vector::VectorTem<Real64> pointVector = 00330 Core::Vector::VectorTem<Real64>(elementsPerPoint); 00331 for(int i = 0; i < pointCount; i++) 00332 { 00333 buffer->Read(pointVector.GetData(), sizeof(Real64) * elementsPerPoint); 00334 if(geometry == "CircleZ") 00335 { 00336 InterestCircle* point = 00337 new InterestCircle(pointVector, borderOffset+1, borderOffset+1); 00338 pointList.push_back(point); 00339 } 00340 else if(geometry == "RectangleZ") 00341 { 00342 ILOG_ERROR("Cannot deserialize rectangles: code not written"); 00343 //InterestRectangleZ* point = 00344 // new InterestRectangleZ(pointVector, borderOffset+1, 00345 // borderOffset+1); 00346 //pointList.push_back(point); 00347 } 00348 } 00349 00350 if(dimensionCount == 0) return; 00351 if(!readDescriptors) return; 00352 00353 Core::Vector::VectorTem<Real64> v = 00354 Core::Vector::VectorTem<Real64>(dimensionCount); 00355 for(InterestPointList::iterator iter = pointList.begin(); iter != pointList.end(); iter++) 00356 { 00357 InterestPoint* point = *iter; 00358 buffer->Read(v.GetData(), sizeof(Real64) * dimensionCount); 00359 point->mDescriptor.reserve(dimensionCount); 00360 for(int i = 0; i < dimensionCount; i++) 00361 { 00362 point->mDescriptor.push_back(v[i]); 00363 } 00364 } 00365 }
Here is the call graph for this function:
|