shared_ptr<cs::LidarDataType> LidarFile::createXMLStructure( const LidarDataContainer& lidarContainer, const std::string& dataFileName, const LidarCenteringTransfo& transfo, const cs::DataFormatType format) { // generate xml file cs::LidarDataType::AttributesType attributes(lidarContainer.size(), format); // insert attributes in the xml (with their names and types) const AttributeMapType& attributeMap = lidarContainer.getAttributeMap(); for(AttributeMapType::const_iterator it=attributeMap.begin(); it!=attributeMap.end(); ++it) { attributes.attribute().push_back(it->second); } // add transfo if(transfo.isSet()) { attributes.centeringTransfo(cs::CenteringTransfoType(transfo.x(), transfo.y())); } // add dataFilename attributes.dataFileName() = dataFileName; shared_ptr<cs::LidarDataType> xmlStructure(new cs::LidarDataType(attributes)); return xmlStructure; }
void operator()(const LidarDataContainer& lidarContainer, shared_ptr<LidarDataContainer>& centeredContainer, LidarCenteringTransfo& transfo, const char* const x, const char* const y, const char* const z) { LidarEcho echo = centeredContainer->createEcho(); LidarConstIteratorEcho itb = lidarContainer.begin(); const LidarConstIteratorEcho ite = lidarContainer.end(); const unsigned int decalageX = centeredContainer->getDecalage(x); const unsigned int decalageY = centeredContainer->getDecalage(y); const unsigned int decalageZ = centeredContainer->getDecalage(z); const unsigned int decalageX_initial = lidarContainer.getDecalage(x); const unsigned int decalageY_initial = lidarContainer.getDecalage(y); const unsigned int decalageZ_initial = lidarContainer.getDecalage(z); //si la transfo vaut 0, elle est calculée automatiquement if(transfo.x()==0 && transfo.y()==0) { const float quotient = 1000.; LidarEcho echoInitial(*itb); double x = std::floor(echoInitial.value<AttributeType>(decalageX_initial)/quotient)*quotient; double y = std::floor(echoInitial.value<AttributeType>(decalageY_initial)/quotient)*quotient; transfo.setTransfo(x,y); } for(;itb!=ite; ++itb) { LidarEcho echoInitial(*itb); echo.value<float>(decalageX) = (float)( echoInitial.value<AttributeType>(decalageX_initial) - transfo.x() ); echo.value<float>(decalageY) = (float)( echoInitial.value<AttributeType>(decalageY_initial) - transfo.y() ); echo.value<float>(decalageZ) = (float)echoInitial.value<AttributeType>(decalageZ_initial); AttributeMapType::const_iterator itbAttribute = centeredContainer->getAttributeMap().begin(); const AttributeMapType::const_iterator iteAttribute = centeredContainer->getAttributeMap().end(); AttributeMapType::const_iterator itbAttributeInitial = lidarContainer.getAttributeMap().begin(); for(; itbAttribute != iteAttribute; ++itbAttribute, ++itbAttributeInitial) { if(itbAttribute->first!=x && itbAttribute->first!=y && itbAttribute->first!=z) { apply<ReadValueFunctor, void, LidarEcho&, const unsigned int, LidarEcho&,const unsigned int>( itbAttribute->second.dataType(), echo, itbAttribute->second.decalage, echoInitial, itbAttributeInitial->second.decalage); } } centeredContainer->push_back(echo); } }