Exemple #1
0
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);
		}

	}
Exemple #3
0
void LidarFile::loadTransfo(LidarCenteringTransfo& transfo) const
{
    transfo.setTransfo(0,0);

    if(!isValid())
        return;

    if(!m_xmlData->attributes().centeringTransfo().present())
        return;

    cs::CenteringTransfoType transfoXML = m_xmlData->attributes().centeringTransfo().get();
    transfo.setTransfo(transfoXML.tx(), transfoXML.ty());

}
void Module_fullwave_center::run()
{
	shared_ptr<SelectedFullwaveData> selectedData = getSelectedFullwaveData(true);
	const SelectedFullwaveData::FullwaveData& fwData = selectedData->front();

	double x=0, y=0;
	wxTextEntryDialog dialogX(FAEventHandler::instance()->getMainFrame(), _("Transfo x"), _("Please enter text"), _("0."));
	if (dialogX.ShowModal() == wxID_OK)
	{
		wxString result = dialogX.GetValue();
		if(!result.ToDouble(&x))
		{
			wxMessageBox(_("Bad transfo value !"));
			return;
		}
	}
	else
		return;

	wxTextEntryDialog dialogY(FAEventHandler::instance()->getMainFrame(), _("Transfo y"), _("Please enter text"), _("0."));
	if (dialogY.ShowModal() == wxID_OK)
	{
		wxString result = dialogY.GetValue();
		if(!result.ToDouble(&y))
		{
			wxMessageBox(_("Bad transfo value !"));
			return;
		}
	}
	else
		return;

	LidarCenteringTransfo transfo;
	transfo.setTransfo(x,y);

	shared_ptr<Lidar::LidarDataContainer> centeredContainer = transfo.centerLidarDataContainer(fwData.m_container->getAttributeContainer(), "originX", "originY", "originZ");
	fwData.m_container->setAttributeContainer(*centeredContainer);

	std::string fileNameXML = ( boost::filesystem::path(fwData.m_path) / (fwData.m_basename + "-centering.xml") ).string();

	FullwaveFile::save(*fwData.m_container, fileNameXML, transfo);

	std::cout << "Fin centrage fw" << std::endl;
}
Exemple #5
0
	inline void helperCalculeEmprise(LidarConstIteratorEcho it, const FullwaveEchoHelper& fwHelper, std::vector<double>& stripX, std::vector<double>& stripY, const int increment, const FullwaveLidarDataContainer& fwContainer, const LidarCenteringTransfo& transfo)
	{
		const LidarConstIteratorEcho itb = fwContainer.beginEcho();
		const LidarConstIteratorEcho ite = fwContainer.endEcho();

		while(it>= itb && it<ite && !fwHelper.hasBackscatteredSequences(it))
		{
			//si le bord de bande n'a pas de retour (arrive fréquemment sur la zone accidentée du brusquet) on recherche le signal le plus proche à l'intérieur de la bande
			if(increment<0)
			{
				it -= -increment;
			}
			else
				it += increment;
		}

		if(it>= itb && it<ite && fwHelper.hasBackscatteredSequences(it))
		{
			TPoint2D<float> pt(fwHelper.originXNthSequence(it, 1), fwHelper.originYNthSequence(it, 1));
			TPoint2D<double> ptTransfo = transfo.applyTransfo(pt);
			stripX.push_back(ptTransfo.x);
			stripY.push_back(ptTransfo.y);
		}
	}