genericinput_example_00005.cpp
1 /*----------------------------------------------------------------------------*\
2  *
3  * mimmo
4  *
5  * Optimad Engineering S.r.l. ("COMPANY") CONFIDENTIAL
6  * Copyright (c) 2015-2021 Optimad Engineering S.r.l., All Rights Reserved.
7  *
8  * --------------------------------------------------------------------------
9  *
10  * NOTICE: All information contained herein is, and remains the property
11  * of COMPANY. The intellectual and technical concepts contained herein are
12  * proprietary to COMPANY and may be covered by Italian and Foreign Patents,
13  * patents in process, and are protected by trade secret or copyright law.
14  * Dissemination of this information or reproduction of this material is
15  * strictly forbidden unless prior written permission is obtained from
16  * COMPANY. Access to the source code contained herein is hereby forbidden
17  * to anyone except current COMPANY employees, managers or contractors who
18  * have executed Confidentiality and Non-disclosure agreements explicitly
19  * covering such access.
20  *
21  * The copyright notice above does not evidence any actual or intended
22  * publication or disclosure of this source code, which includes information
23  * that is confidential and/or proprietary, and is a trade secret, of
24  * COMPANY. ANY REPRODUCTION, MODIFICATION, DISTRIBUTION, PUBLIC PERFORMANCE,
25  * OR PUBLIC DISPLAY OF OR THROUGH USE OF THIS SOURCE CODE WITHOUT THE
26  * EXPRESS WRITTEN CONSENT OF COMPANY IS STRICTLY PROHIBITED, AND IN
27  * VIOLATION OF APPLICABLE LAWS AND INTERNATIONAL TREATIES. THE RECEIPT OR
28  * POSSESSION OF THIS SOURCE CODE AND/OR RELATED INFORMATION DOES NOT CONVEY
29  * OR IMPLY ANY RIGHTS TO REPRODUCE, DISCLOSE OR DISTRIBUTE ITS CONTENTS, OR
30  * TO MANUFACTURE, USE, OR SELL ANYTHING THAT IT MAY DESCRIBE, IN WHOLE OR
31  * IN PART.
32  *
33 \*----------------------------------------------------------------------------*/
34 
35 #include <mimmo_iogeneric.hpp>
36 #include <mimmo_geohandlers.hpp>
37 #include <mimmo_manipulators.hpp>
38 #include <mimmo_utils.hpp>
39 
40 
56 int genericinput00005() {
57 
58  /*
59  * Set expert mode true
60  */
62 
63  /*
64  Create a block to parse an OBJ mesh from file.
65  */
67  mimmo0->setDir("geodata");
68  mimmo0->setFilename("eyeball");
69  mimmo0->printResumeFile(false);
70 
71  /*
72  Create a block to write an OBJ mesh to file.
73  */
75  mimmo1->setFilename("iogeneric_output_00001.0001");
76  mimmo1->printResumeFile(false);
77  mimmo1->setTextureUVMode(true);
78 
79  /*
80  Define a single node position with its displacement to
81  build up the input needed by the RBF manipulator
82  */
83  std::array<double,3>node({{0.0,0.0,2.0}});
84  dvecarr3E displ(1);
85  displ[0] = {{0.0,0.0,1.0}};
86 
87  /*
88  Create the RBF manipulator.
89  */
90  mimmo::MRBF * rbf = new mimmo::MRBF();
91  rbf->addNode(node);
92  rbf->setDisplacements(displ);
93  rbf->setFunction(bitpit::RBFBasisFunction::C0C2);
94  rbf->setSupportRadiusReal(1.0);
95  rbf->setPlotInExecution(true);
96 
97  /*
98  Create the applier block.
99  * It applies the deformation displacements from rbf block to the original input geometry.
100  */
101  mimmo::Apply * applier = new mimmo::Apply();
102 
103 
104  /*
105  Define block pin connections.
106  */
107  mimmo::pin::addPin(mimmo0, mimmo1, M_GEOM, M_GEOM);
109  mimmo::pin::addPin(mimmo0, rbf, M_GEOM, M_GEOM);
110 
111  mimmo::pin::addPin(rbf, applier, M_GDISPLS, M_GDISPLS);
112  mimmo::pin::addPin(mimmo0, applier, M_GEOM, M_GEOM);
113 
114  mimmo::pin::addPin(applier, mimmo1, M_GEOM, M_GEOM);
115 
116  /*
117  Setup execution chain.
118  */
119  mimmo::Chain ch0;
120  ch0.addObject(mimmo0);
121  ch0.addObject(mimmo1);
122  ch0.addObject(rbf);
123  ch0.addObject(applier);
124 
125  /*
126  Execute the chain.
127  * Use debug flag true to to print out the execution steps.
128  */
129  ch0.exec(true);
130 
131  /* Clean up & exit;
132  */
133  delete mimmo0;
134  delete mimmo1;
135  delete rbf;
136  delete applier;
137 
138  return 0;
139 
140 }
141 
142 // =================================================================================== //
143 
144 int main( int argc, char *argv[] ) {
145  BITPIT_UNUSED(argc);
146  BITPIT_UNUSED(argv);
147 
148 #if MIMMO_ENABLE_MPI
149  MPI_Init(&argc, &argv);
150 #endif
151 
152  int err = 1;
153  try{
154  err = genericinput00005() ;
155  }catch(std::exception & e){
156  std::cout<<"genericinput_example_00005 exited with an error of type : "<<e.what()<<std::endl;
157  return 0;
158  }
159 #if MIMMO_ENABLE_MPI
160  MPI_Finalize();
161 #endif
162 
163  return err;
164 }
void exec(bool debug=false)
Definition: Chain.cpp:284
#define M_GDISPLS
void setDir(const std::string &pathdir)
void setTextureUVMode(bool UVmode)
Chain is the class used to manage the chain execution of multiple executable blocks (manipulation obj...
Definition: Chain.hpp:48
#define M_GEOM
Apply is the class that applies the deformation resulting from a manipulation object to the geometry.
Definition: Apply.hpp:89
void setDisplacements(dvecarr3E displ)
Definition: MRBF.cpp:514
std::vector< darray3E > dvecarr3E
void setSupportRadiusReal(double suppR_)
Definition: MRBF.cpp:436
Executable block handling io of 3D surface polygonal mesh in *.obj format.
void setFilename(const std::string &name)
bool addPin(BaseManipulation *objSend, BaseManipulation *objRec, PortID portS, PortID portR, bool forced)
#define M_WAVEFRONTDATA
void setExpertMode(bool flag)
int addNode(darray3E)
Definition: MRBF.cpp:311
Radial Basis Function evaluation from clouds of control points.
Definition: MRBF.hpp:146
void printResumeFile(bool print)
int addObject(BaseManipulation *obj, int id_=-1)
Definition: Chain.cpp:170
void setFunction(const MRBFBasisFunction &funct, bool isCompact=false)
Definition: MRBF.cpp:594