genericinput_example_00002.cpp
1 /*---------------------------------------------------------------------------*\
2  *
3  * mimmo
4  *
5  * Copyright (C) 2015-2021 OPTIMAD engineering Srl
6  *
7  * -------------------------------------------------------------------------
8  * License
9  * This file is part of mimmo.
10  *
11  * mimmo is free software: you can redistribute it and/or modify it
12  * under the terms of the GNU Lesser General Public License v3 (LGPL)
13  * as published by the Free Software Foundation.
14  *
15  * mimmo is distributed in the hope that it will be useful, but WITHOUT
16  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
17  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
18  * License for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public License
21  * along with mimmo. If not, see <http://www.gnu.org/licenses/>.
22  *
23  \ *---------------------------------------------------------------------------*/
24 
25 #include "mimmo_iogeneric.hpp"
26 
40 // =================================================================================== //
41 
42 
43 void test00002() {
44 
45  /*
46  Creation of input reading block to read a set of
47  point cloud coordinates. The file format is csv, but data structure
48  reported in it is suitable to be tranferred into a MimmoPiercedVector container.
49  Take a look to the sample file for info on such data structure.
50  */
52  read->setReadDir("input");
53  read->setFilename("generic_inputMPVData_00002.csv");
54  read->setBinary(false);
55 
56  /*
57  Creation of output writing block to write a set of
58  point cloud coordinates passed from a MimmoPiercedVector container.
59  Take a look to the final written file for info on how this data are written.
60  */
62  write->setWriteDir("./");
63  write->setFilename("generic_outputMPVData_00002.csv");
64  write->setCSV(true);
65  write->setBinary(false);
66 
67  /*
68  Define connection between read an write block, that is the
69  list of point coordinates stored into a MimmoPiercedVector container.
70  */
72 
73  /*
74  Define execution chain and push blocks into it.
75  */
76  mimmo::Chain ch0;
77  ch0.addObject(read);
78  ch0.addObject(write);
79 
80  /*
81  Execute the chain.
82  Use debug flag true to print out log info on execution.
83  */
84  ch0.exec(true);
85 
86  /*
87  Clean up & exit;
88  */
89  delete read;
90  delete write;
91 
92 }
93 
94 // =================================================================================== //
95 
96 int main( int argc, char *argv[] ) {
97 
98  BITPIT_UNUSED(argc);
99  BITPIT_UNUSED(argv);
100 
101 #if MIMMO_ENABLE_MPI
102  MPI_Init(&argc, &argv);
103 #endif
104 
105  try{
106  test00002();
107  }
108  catch(std::exception & e){
109  std::cout<<"genericinput_example_00002 exited with an error of type : "<<e.what()<<std::endl;
110  return 1;
111  }
112 #if MIMMO_ENABLE_MPI
113  MPI_Finalize();
114 #endif
115 
116  return 0;
117 }
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