1 /*=========================================================================
7 =========================================================================*/
9 /* ---------------------------------------------------------------------
11 * Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale)
12 * Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux
14 * This software is governed by the CeCILL-B license under French law and
15 * abiding by the rules of distribution of free software. You can use,
16 * modify and/ or redistribute the software under the terms of the CeCILL-B
17 * license as circulated by CEA, CNRS and INRIA at the following URL
18 * http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
19 * or in the file LICENSE.txt.
21 * As a counterpart to the access to the source code and rights to copy,
22 * modify and redistribute granted by the license, users are provided only
23 * with a limited warranty and the software's author, the holder of the
24 * economic rights, and the successive licensors have only limited
27 * The fact that you are presently reading this means that you have had
28 * knowledge of the CeCILL-B license and that you accept its terms.
29 * ------------------------------------------------------------------------ */
33 * \brief Class bbtk::GBlackBox
37 #include "GBlackBoxModel.h"
41 //=========================================================================
43 GBlackBoxModel::GBlackBoxModel()
45 _isExecutable = false;
48 //=========================================================================
50 GBlackBoxModel::~GBlackBoxModel()
54 //=========================================================================
56 std::string GBlackBoxModel::getBBTKPackage()
61 //=========================================================================
63 void GBlackBoxModel::setBBTKPackage(std::string obpackage)
65 _bbtkPackage = obpackage;
68 //=========================================================================
70 bool GBlackBoxModel::isExecutable()
75 //=========================================================================
77 void GBlackBoxModel::setExecutable(bool executable)
79 _isExecutable = executable;
82 //=========================================================================
84 std::string GBlackBoxModel::getStatusText()
86 std::string temp = "";
96 //=========================================================================
98 void GBlackBoxModel::setValueToInputPort(int pos,std::string value)
100 _inputs[pos]->setValue(value);
103 //=========================================================================
105 void GBlackBoxModel::save(std::string &content)
109 content+=_bbtkPackage;
129 sprintf (buffer, "%f", _xInic);
132 sprintf (buffer, "%f", _yInic);
135 sprintf (buffer, "%f", _zInic);
139 sprintf (buffer, "%f", _xFin);
142 sprintf (buffer, "%f", _yFin);
145 sprintf (buffer, "%f", _zFin);
150 for(int i = 0; i<_inputs.size();i++)
152 if(_inputs[i]->isValueSet())
154 _inputs[i]->save(content);
157 content+="FIN_BOX\n";
161 //=========================================================================
163 void GBlackBoxModel::setValueToInput(std::string name,std::string value)
165 for(int i = 0; i<_inputs.size();i++)
167 if(_inputs[i]->getBBTKName()==name)
169 _inputs[i]->setValue(value);
174 //=========================================================================
176 std::string GBlackBoxModel::getValueInputPort(int pos)
178 return _inputs[pos]->getValue();
181 //=========================================================================
183 std::string GBlackBoxModel::getValueInput(std::string name)
185 for(int i = 0; i<_inputs.size();i++)
187 if(_inputs[i]->getBBTKName()==name)
189 return _inputs[i]->getValue();
195 //=========================================================================
197 std::vector<int> GBlackBoxModel::getConnectedInputs()
199 std::vector<int> connected;
200 for(int i = 0; i<_inputs.size();i++)
202 if(_inputs[i]->isConnected())
204 connected.push_back(i);
210 //=========================================================================
212 std::vector<int> GBlackBoxModel::getConnectedOutputs()
214 std::vector<int> connected;
215 for(int i = 0; i<_outputs.size();i++)
217 if(_outputs[i]->isConnected())
219 connected.push_back(i);
225 //=========================================================================
228 } // EO namespace bbtk