Esempio n. 1
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());

}
Esempio n. 2
0
	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);
		}

	}
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;
}