genericinput_example_00002.cpp

Example of reading/writing a generic csv file of MimmoPiercedVector data.Using: GenericInputMPVData, GenericOutputMPVData, Chain

To run : ./genericinput_example_00002
To run (MPI version): mpirun -np X genericinput_example_00002
visit: mimmo website

/*---------------------------------------------------------------------------*\
*
* mimmo
*
* Copyright (C) 2015-2021 OPTIMAD engineering Srl
*
* -------------------------------------------------------------------------
* License
* This file is part of mimmo.
*
* mimmo is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License v3 (LGPL)
* as published by the Free Software Foundation.
*
* mimmo is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with mimmo. If not, see <http://www.gnu.org/licenses/>.
*
\ *---------------------------------------------------------------------------*/
#include "mimmo_iogeneric.hpp"
// =================================================================================== //
void test00002() {
/*
Creation of input reading block to read a set of
point cloud coordinates. The file format is csv, but data structure
reported in it is suitable to be tranferred into a MimmoPiercedVector container.
Take a look to the sample file for info on such data structure.
*/
read->setReadDir("input");
read->setFilename("generic_inputMPVData_00002.csv");
read->setBinary(false);
/*
Creation of output writing block to write a set of
point cloud coordinates passed from a MimmoPiercedVector container.
Take a look to the final written file for info on how this data are written.
*/
write->setWriteDir("./");
write->setFilename("generic_outputMPVData_00002.csv");
write->setCSV(true);
write->setBinary(false);
/*
Define connection between read an write block, that is the
list of point coordinates stored into a MimmoPiercedVector container.
*/
/*
Define execution chain and push blocks into it.
*/
ch0.addObject(read);
ch0.addObject(write);
/*
Execute the chain.
Use debug flag true to print out log info on execution.
*/
ch0.exec(true);
/*
Clean up & exit;
*/
delete read;
delete write;
}
// =================================================================================== //
int main( int argc, char *argv[] ) {
BITPIT_UNUSED(argc);
BITPIT_UNUSED(argv);
#if MIMMO_ENABLE_MPI
MPI_Init(&argc, &argv);
#endif
try{
test00002();
}
catch(std::exception & e){
std::cout<<"genericinput_example_00002 exited with an error of type : "<<e.what()<<std::endl;
return 1;
}
#if MIMMO_ENABLE_MPI
MPI_Finalize();
#endif
return 0;
}
void exec(bool debug=false)
Definition: Chain.cpp:284
GenericOutputMPVData is the class that write a generic data to file output as mimmo::MimmoPiercedVect...
void setFilename(std::string filename)
GenericInputMPVData is the class that set a generic input data as mimmo::MimmoPiercedVector.
Chain is the class used to manage the chain execution of multiple executable blocks (manipulation obj...
Definition: Chain.hpp:48
void setReadDir(std::string dir)
#define M_VECTORFIELD
void setBinary(bool binary)
void setFilename(std::string filename)
bool addPin(BaseManipulation *objSend, BaseManipulation *objRec, PortID portS, PortID portR, bool forced)
void setWriteDir(std::string dir)
int addObject(BaseManipulation *obj, int id_=-1)
Definition: Chain.cpp:170