geohandlers_example_00000.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_geohandlers.hpp"
26 #include <bitpit_common.hpp>
27 
28 // =================================================================================== //
43 // =================================================================================== //
44 
45 void test00001() {
46 
47  /*
48  Read a STL geometry (namely a plane). Convert mode will also write the just read geometry
49  in the new stl file (specified with setWriteFilename)
50  */
52  mimmo0->setName("mimmo0");
53  mimmo0->setReadDir("./geodata");
54  mimmo0->setReadFileType(FileType::STL);
55  mimmo0->setReadFilename("plane3");
56  mimmo0->setWriteDir("./");
57  mimmo0->setWriteFileType(FileType::STL);
58  mimmo0->setWriteFilename("geohandlers_output_00000.0000");
59 
60  /*
61  Write a STL geometry.
62  */
64  mimmo1->setWriteDir(".");
65  mimmo1->setWriteFileType(FileType::STL);
66  mimmo1->setWriteFilename("geohandlers_output_00000.0001");
67 
68  /*
69  Select a subportion of geometry using a cylinder shape
70  */
72  sel3->setOrigin({{0.5, 0.0, 0.0}});
73  sel3->setSpan({{0.75, 2.0*BITPIT_PI, 0.4}});
74  sel3->setInfLimits({{0.25, 0.0, 0.0}});
75  sel3->setRefSystem({{0,1,0}}, {{0,0,1}}, {{1,0,0}});
76  sel3->setPlotInExecution(true);
77 
78  /*
79  Define block pin connections.
80  */
81  mimmo::pin::addPin(mimmo0, sel3, M_GEOM, M_GEOM);
82  mimmo::pin::addPin(sel3, mimmo1, M_GEOM, M_GEOM);
83 
84  /*
85  Setup execution chain.
86  */
87  mimmo::Chain ch0;
88  ch0.addObject(mimmo0);
89  ch0.addObject(sel3);
90  ch0.addObject(mimmo1);
91 
92  /*
93  Execute the chain.
94  Use debug flag true to to print out the execution steps.
95  */
96  ch0.exec(true);
97 
98  /* Clean up & exit;
99  */
100  delete sel3;
101  delete mimmo0;
102  delete mimmo1;
103 
104  return;
105 }
106 
107 // =================================================================================== //
108 
109 int main( int argc, char *argv[] ) {
110 
111  BITPIT_UNUSED(argc);
112  BITPIT_UNUSED(argv);
113 
114 #if MIMMO_ENABLE_MPI
115  MPI_Init(&argc, &argv);
116 #endif
117  try{
119  test00001();
120  }
121  catch(std::exception & e){
122  std::cout<<"geohandlers_example_00000 exited with an error of type : "<<e.what()<<std::endl;
123  return 1;
124  }
125 #if MIMMO_ENABLE_MPI
126  MPI_Finalize();
127 #endif
128 
129  return 0;
130 }
void setOrigin(darray3E)
void exec(bool debug=false)
Definition: Chain.cpp:284
void setInfLimits(double val, int dir)
Chain is the class used to manage the chain execution of multiple executable blocks (manipulation obj...
Definition: Chain.hpp:48
#define M_GEOM
void setWriteFileType(FileType type)
void setName(std::string name)
void setWriteDir(std::string dir)
void setWriteFilename(std::string filename)
Selection through cylinder primitive.
void setRefSystem(darray3E, darray3E, darray3E)
void setReadFilename(std::string filename)
bool addPin(BaseManipulation *objSend, BaseManipulation *objRec, PortID portS, PortID portR, bool forced)
MimmoGeometry is an executable block class wrapping(linking or internally instantiating) a Mimmo Obje...
void setReadFileType(FileType type)
void setSpan(double, double, double)
void setReadDir(std::string dir)
int addObject(BaseManipulation *obj, int id_=-1)
Definition: Chain.cpp:170