genericinput_example_00001.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 void test00001() {
43 
44  /*
45  Creation of Generic output block to read a set of
46  point coordinates from point cloud as generic input in csv format.
47  */
48  mimmo::GenericInput * read = new mimmo::GenericInput(true, true);
49  read->setReadFromFile(true);
50  read->setReadDir("input");
51  read->setFilename("generic_input_00001.csv");
52  read->setCSV(true);
53 
54  /*
55  Creation of Generic output block to write a set of
56  point cloud coordinates as generic output in csv format.
57  */
59  write->setFilename("generic_output_00001.csv");
60  write->setCSV(true);
61 
62  /*
63  Define connection between read and write block, that is the list of point
64  coordinates.
65  */
66  mimmo::pin::addPin(read, write, M_COORDS, M_COORDS);
67 
68  /*
69  Define the execution chain and push the interested block into it.
70  */
71  mimmo::Chain ch0;
72  ch0.addObject(read);
73  ch0.addObject(write);
74 
75  /*
76  Execute the chain.
77  Use debug flag true to print out log info on execution.
78  */
79  ch0.exec(true);
80 
81 
82  /*
83  Clean up & exit;
84  */
85  delete read;
86  delete write;
87 
88 }
89 
90 // =================================================================================== //
91 
92 int main( int argc, char *argv[] ) {
93 
94  BITPIT_UNUSED(argc);
95  BITPIT_UNUSED(argv);
96 
97 #if MIMMO_ENABLE_MPI
98  MPI_Init(&argc, &argv);
99 #endif
100 
101  try{
102  test00001();
103  }
104  catch(std::exception & e){
105  std::cout<<"genericinput_example_00001 exited with an error of type : "<<e.what()<<std::endl;
106  return 1;
107  }
108 #if MIMMO_ENABLE_MPI
109  MPI_Finalize();
110 #endif
111 
112  return 0;
113 }
void setReadDir(std::string dir)
void exec(bool debug=false)
Definition: Chain.cpp:284
Chain is the class used to manage the chain execution of multiple executable blocks (manipulation obj...
Definition: Chain.hpp:48
void setFilename(std::string filename)
void setCSV(bool csv)
GenericOutput is the class that write generic data in a file output.
GenericInput is the class that set the initialization of a generic input data.
void setCSV(bool csv)
bool addPin(BaseManipulation *objSend, BaseManipulation *objRec, PortID portS, PortID portR, bool forced)
void setReadFromFile(bool readFromFile)
void setFilename(std::string filename)
int addObject(BaseManipulation *obj, int id_=-1)
Definition: Chain.cpp:170
#define M_COORDS