From ad212791465402dfa7acd59f4cfaa0503ad7e5e4 Mon Sep 17 00:00:00 2001 From: Ewelina Rupnik-Admin Date: Thu, 18 Jan 2024 11:17:38 +0100 Subject: [PATCH] Add read RPC xml start --- MMVII/include/MMVII_DeclareAllCmd.h | 1 + MMVII/src/Appli/cSpecMMVII_Appli.cpp | 2 + MMVII/src/MMV1/cImportPushbroom.cpp | 121 +++++++++++++++++++++++++++ MMVII/src/Serial/Serial.h | 9 +- MMVII/src/Serial/SerialByTree.cpp | 53 +++++++++++- 5 files changed, 184 insertions(+), 2 deletions(-) create mode 100755 MMVII/src/MMV1/cImportPushbroom.cpp diff --git a/MMVII/include/MMVII_DeclareAllCmd.h b/MMVII/include/MMVII_DeclareAllCmd.h index f6dfc06118..855c362c6e 100755 --- a/MMVII/include/MMVII_DeclareAllCmd.h +++ b/MMVII/include/MMVII_DeclareAllCmd.h @@ -88,6 +88,7 @@ extern cSpecMMVII_Appli TheSpec_SimulDispl; extern cSpecMMVII_Appli TheSpec_CreateRTL; extern cSpecMMVII_Appli TheSpec_ChSysCo; extern cSpecMMVII_Appli TheSpec_CreateCalib; +extern cSpecMMVII_Appli TheSpecImportPushbroom; }; #endif // _MMVII_DeclareAllCmd_H_ diff --git a/MMVII/src/Appli/cSpecMMVII_Appli.cpp b/MMVII/src/Appli/cSpecMMVII_Appli.cpp index 889eb2b259..765a166f3c 100755 --- a/MMVII/src/Appli/cSpecMMVII_Appli.cpp +++ b/MMVII/src/Appli/cSpecMMVII_Appli.cpp @@ -232,6 +232,8 @@ std::vector & cSpecMMVII_Appli::InternVecAll() TheVecAll.push_back(&TheSpec_CreateCalib); TheVecAll.push_back(&TheSpec_ImportTiePMul); TheVecAll.push_back(&TheSpec_ImportMesImGCP); + TheVecAll.push_back(&TheSpecImportPushbroom); + std::sort(TheVecAll.begin(),TheVecAll.end(),CmpCmd); } diff --git a/MMVII/src/MMV1/cImportPushbroom.cpp b/MMVII/src/MMV1/cImportPushbroom.cpp new file mode 100755 index 0000000000..d3b77f9fd1 --- /dev/null +++ b/MMVII/src/MMV1/cImportPushbroom.cpp @@ -0,0 +1,121 @@ +#include "StdAfx.h" +#include "V1VII.h" +#include "cMMVII_Appli.h" +#include "MMVII_DeclareCste.h" +#include "MMVII_Geom3D.h" +#include "MMVII_Sensor.h" + +namespace MMVII +{ + +extern void TestReadXML(const std::string&); + +/* =============================================== */ +/* */ +/* cPushbroomSensor */ +/* */ +/* =============================================== */ + +/** Class for XXX */ + +class cPushbroomSensor : public cSensorImage +{ + public : + cPushbroomSensor(); + + private: + + +}; +/* + * + * + * + * + RatioPolyn 40 coeffs et les bornes + ??inherit from mapping non inversible?? + + DataRPC contains 2 obj of RatioPolyn, as well as validity + + constructor par def qui fait rien + function ReadXML qui lit +*/ + +/* =============================================== */ +/* */ +/* cAppliImportPushbroom */ +/* */ +/* =============================================== */ + +/** A basic application for */ + +class cAppliImportPushbroom : public cMMVII_Appli +{ + public : + + cAppliImportPushbroom(const std::vector & aVArgs,const cSpecMMVII_Appli & aSpec); + + private : + int Exe() override; + cCollecSpecArg2007 & ArgObl(cCollecSpecArg2007 & anArgObl) override ; + cCollecSpecArg2007 & ArgOpt(cCollecSpecArg2007 & anArgOpt) override ; + + // --- Mandatory ---- + std::string mNameSensorIn; + + // --- Optionnal ---- + std::string mNameSensorOut; + + // --- Internal ---- +}; + +cAppliImportPushbroom::cAppliImportPushbroom(const std::vector & aVArgs,const cSpecMMVII_Appli & aSpec) : + cMMVII_Appli (aVArgs,aSpec) +{ +} + + +cCollecSpecArg2007 & cAppliImportPushbroom::ArgObl(cCollecSpecArg2007 & anArgObl) +{ + return anArgObl + << Arg2007(mNameSensorIn,"Name of input sensor gile", {eTA2007::FileDirProj,eTA2007::Orient}) + ; +} + +cCollecSpecArg2007 & cAppliImportPushbroom::ArgOpt(cCollecSpecArg2007 & anArgOpt) +{ + return anArgOpt + << AOpt2007(mNameSensorOut,CurOP_Out,"Name of output file if correction are done") + ; +} + +int cAppliImportPushbroom::Exe() +{ + + TestReadXML(mNameSensorIn); + + + return EXIT_SUCCESS; +} + + /* =============================================== */ + /* :: */ + /* =============================================== */ + +tMMVII_UnikPApli Alloc_ImportPushbroom(const std::vector & aVArgs,const cSpecMMVII_Appli & aSpec) +{ + return tMMVII_UnikPApli(new cAppliImportPushbroom(aVArgs,aSpec)); +} + +cSpecMMVII_Appli TheSpecImportPushbroom +( + "ImportPushbroom", + Alloc_ImportPushbroom, + "Import a pushbroom sensor", + {eApF::Ori}, + {eApDT::Ori}, + {eApDT::Ori}, + __FILE__ +); + +}; diff --git a/MMVII/src/Serial/Serial.h b/MMVII/src/Serial/Serial.h index 72b559daa4..aca4fd4799 100755 --- a/MMVII/src/Serial/Serial.h +++ b/MMVII/src/Serial/Serial.h @@ -214,6 +214,11 @@ class cSerialTree : public cMemCheck void Raw_PrettyPrint(cMMVII_Ofs& anOfs) const; /// Tagt-pretty print void CSV_PrettyPrint(std::vector& aRes,bool IsSpecif) const; /// print + /// Extract a descendant from its name + std::vector GetAllDescFromName(const std::string &) const; + /// Test if there is a one and only one descendant + const cSerialTree * GetUniqueDescFromName(const std::string &) const; + /// Assert that there is only 1 son and return it const cSerialTree & UniqueSon() const; @@ -226,7 +231,9 @@ class cSerialTree : public cMemCheck const std::vector& Sons() const; /// acessor const std::string & Value() const ; /// accessor private : - void RecursSetFather(cSerialTree *); + void RecGetAllDescFromName(std::vector&,const std::string &) const; + + void RecursSetFather(cSerialTree *); // cSerialTree(const cSerialTree &) ; /// Implement using exception void Rec_AnalyseDiffTree(const cSerialTree &,const std::string & aSkeep) const; diff --git a/MMVII/src/Serial/SerialByTree.cpp b/MMVII/src/Serial/SerialByTree.cpp index cccf55bd16..9f49c8727e 100755 --- a/MMVII/src/Serial/SerialByTree.cpp +++ b/MMVII/src/Serial/SerialByTree.cpp @@ -390,7 +390,12 @@ cResLex cXmlSerialTokenParser::AnalysePonctuation(char aC) void cXmlSerialTokenParser::CheckOnClose(const cSerialTree & aTree,const std::string & aStr) const { - MMVII_INTERNAL_ASSERT_tiny(aTree.Value() == aStr,"Close tag unexpected"); + if (aTree.Value() != aStr) + { + StdOut()<< "Expected : [" << aStr << "], Got : [" << aTree.Value()<< "] " << std::endl; + MMVII_INTERNAL_ASSERT_tiny(false,"Close tag unexpected"); + } + } /*============================================================*/ @@ -514,6 +519,31 @@ cSerialTree* cSerialTree::AllocSimplify(const std::string & aNameFile) return aRes; } +void cSerialTree::RecGetAllDescFromName(std::vector& aRes,const std::string & aTag) const +{ + if (!IsTerminalNode() && (aTag==mValue)) + aRes.push_back(this); + + for (const auto & aSon : mSons) + aSon.RecGetAllDescFromName(aRes,aTag); +} + +/// Extract a descendant from its name +std::vector cSerialTree::GetAllDescFromName(const std::string & aTag) const +{ + std::vector aRes; + RecGetAllDescFromName(aRes,aTag); + return aRes; +} +/// Test if there is a one and only one descendant +const cSerialTree * cSerialTree::GetUniqueDescFromName(const std::string & aTag) const +{ + std::vector aRes = GetAllDescFromName(aTag); + MMVII_INTERNAL_ASSERT_tiny(aRes.size()==1,"cSerialTree::GetUniqueDescFromName, size="+ToStr(aRes.size())); + + return aRes.at(0); +} + bool cSerialTree::IsTerminalNode() const { @@ -1426,6 +1456,27 @@ void PutLineCSV(cMMVII_Ofs & anOfs,const std::vector & aVS) anOfs.Ofs() << "\n"; } +/* ==================================================================== */ +/* */ +/* :: */ +/* */ +/* ==================================================================== */ + +void TestReadXML(const std::string& aNameFile) +{ + cSerialFileParser * aSFP = cSerialFileParser::Alloc(aNameFile,eTypeSerial::exml); + cSerialTree aTree(*aSFP); + const cSerialTree * aDirect = aTree.GetUniqueDescFromName("Direct_Model"); + const cSerialTree * aSNC6 = aDirect->GetUniqueDescFromName("SAMP_NUM_COEFF_6"); + + + StdOut() << "TEST COEFF" << aSNC6->UniqueSon().Value() << "\n"; + + delete aSFP; + + + StdOut() << "Bonjour World!" << std::endl; +} };