Skip to content

Commit be6caf8

Browse files
committed
Reformat
1 parent f6393e9 commit be6caf8

File tree

1 file changed

+74
-81
lines changed

1 file changed

+74
-81
lines changed

src/Modules/Legacy/Matlab/Interface/InterfaceWithMatlab.cc

Lines changed: 74 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -630,13 +630,13 @@ void InterfaceWithMatlab::execute()
630630
}
631631

632632
update_state(Executing);
633-
#if 0
634-
if (!(generate_matlab_code()))
633+
634+
if (!impl_->generate_matlab_code())
635635
{
636636
error("InterfaceWithMatlab: Could not create m-file code for matlabengine");
637637
return;
638638
}
639-
639+
#if 0
640640
if (!send_matlab_job())
641641
{
642642
error("InterfaceWithMatlab: Matlab returned an error or Matlab could not be launched");
@@ -1236,94 +1236,87 @@ void InterfaceWithMatlab::execute()
12361236
}
12371237
return(true);
12381238
}
1239+
#endif
12391240

1240-
bool InterfaceWithMatlab::generate_matlab_code()
1241-
{
1242-
try
1243-
{
1244-
std::ofstream m_file;
1245-
1246-
mfile_ = std::string("scirun_code.m");
1247-
std::string filename = file_transfer_->local_file(mfile_);
1248-
m_file.open(filename.c_str(),std::ios::app);
1249-
1250-
int port = 0;
1251-
m_file << matlab_code_list_ << "\n";
1252-
for (int p = 0; p < NUM_MATRIX_PORTS; p++)
1253-
{
1254-
// Test whether the matrix port exists
1255-
if (!oport_connected(port)) { port++; continue; }
1256-
port++;
1257-
if (output_matrix_name_list_[p] == "") continue;
1258-
1259-
std::ostringstream oss;
1260-
oss << "output_matrix" << p << ".mat";
1261-
output_matrix_matfile_[p] = oss.str();
1262-
std::string cmd;
1263-
cmd = "if exist('" + output_matrix_name_list_[p] + "','var'), save " + file_transfer_->remote_file(output_matrix_matfile_[p]) + " " + output_matrix_name_list_[p] + "; end\n";
1264-
m_file << cmd;
1265-
}
1266-
1267-
for (int p = 0; p < NUM_FIELD_PORTS; p++)
1268-
{
1269-
// Test whether the matrix port exists
1270-
if (!oport_connected(port)) { port++; continue; }
1271-
port++;
1272-
if (output_field_name_list_[p] == "") continue;
1273-
1274-
std::ostringstream oss;
1275-
oss << "output_field" << p << ".mat";
1276-
output_field_matfile_[p] = oss.str();
1277-
std::string cmd;
1278-
cmd = "if exist('" + output_field_name_list_[p] + "','var'), save " + file_transfer_->remote_file(output_field_matfile_[p]) + " " + output_field_name_list_[p] + "; end\n";
1279-
m_file << cmd;
1280-
}
1281-
1282-
for (int p = 0; p < NUM_NRRD_PORTS; p++)
1283-
{
1284-
// Test whether the matrix port exists
1285-
if (!oport_connected(port)) { port++; continue; }
1286-
port++;
1287-
if (output_nrrd_name_list_[p] == "") continue;
1241+
bool InterfaceWithMatlabImpl::generate_matlab_code()
1242+
{
1243+
std::ofstream m_file;
12881244

1289-
std::ostringstream oss;
1245+
mfile_ = std::string("scirun_code.m");
1246+
std::string filename = file_transfer_->local_file(mfile_);
1247+
m_file.open(filename.c_str(), std::ios::app);
12901248

1291-
oss << "output_nrrd" << p << ".mat";
1292-
output_nrrd_matfile_[p] = oss.str();
1293-
std::string cmd;
1294-
cmd = "if exist('" + output_nrrd_name_list_[p] + "','var'), save " + file_transfer_->remote_file(output_nrrd_matfile_[p]) + " " + output_nrrd_name_list_[p] + "; end\n";
1295-
m_file << cmd;
1296-
}
1249+
int port = 0;
1250+
m_file << matlab_code_list_ << "\n";
1251+
for (int p = 0; p < NUM_MATRIX_PORTS; p++)
1252+
{
1253+
// Test whether the matrix port exists
1254+
if (!oport_connected(port)) { port++; continue; }
1255+
port++;
1256+
if (output_matrix_name_list_[p] == "") continue;
1257+
1258+
std::ostringstream oss;
1259+
oss << "output_matrix" << p << ".mat";
1260+
output_matrix_matfile_[p] = oss.str();
1261+
std::string cmd;
1262+
cmd = "if exist('" + output_matrix_name_list_[p] + "','var'), save " + file_transfer_->remote_file(output_matrix_matfile_[p]) + " " + output_matrix_name_list_[p] + "; end\n";
1263+
m_file << cmd;
1264+
}
12971265

1298-
for (int p = 0; p < NUM_STRING_PORTS; p++)
1299-
{
1300-
// Test whether the matrix port exists
1301-
if (!oport_connected(port)) { port++; continue; }
1302-
port++;
1303-
if (output_string_name_list_[p] == "") continue;
1266+
for (int p = 0; p < NUM_FIELD_PORTS; p++)
1267+
{
1268+
// Test whether the matrix port exists
1269+
if (!oport_connected(port)) { port++; continue; }
1270+
port++;
1271+
if (output_field_name_list_[p] == "") continue;
1272+
1273+
std::ostringstream oss;
1274+
oss << "output_field" << p << ".mat";
1275+
output_field_matfile_[p] = oss.str();
1276+
std::string cmd;
1277+
cmd = "if exist('" + output_field_name_list_[p] + "','var'), save " + file_transfer_->remote_file(output_field_matfile_[p]) + " " + output_field_name_list_[p] + "; end\n";
1278+
m_file << cmd;
1279+
}
13041280

1305-
std::ostringstream oss;
1281+
for (int p = 0; p < NUM_NRRD_PORTS; p++)
1282+
{
1283+
// Test whether the matrix port exists
1284+
if (!oport_connected(port)) { port++; continue; }
1285+
port++;
1286+
if (output_nrrd_name_list_[p] == "") continue;
1287+
1288+
std::ostringstream oss;
1289+
1290+
oss << "output_nrrd" << p << ".mat";
1291+
output_nrrd_matfile_[p] = oss.str();
1292+
std::string cmd;
1293+
cmd = "if exist('" + output_nrrd_name_list_[p] + "','var'), save " + file_transfer_->remote_file(output_nrrd_matfile_[p]) + " " + output_nrrd_name_list_[p] + "; end\n";
1294+
m_file << cmd;
1295+
}
13061296

1307-
oss << "output_string" << p << ".mat";
1308-
output_string_matfile_[p] = oss.str();
1309-
std::string cmd;
1310-
cmd = "if exist('" + output_string_name_list_[p] + "','var'), save " + file_transfer_->remote_file(output_string_matfile_[p]) + " " + output_string_name_list_[p] + "; end\n";
1311-
m_file << cmd;
1312-
}
1297+
for (int p = 0; p < NUM_STRING_PORTS; p++)
1298+
{
1299+
// Test whether the matrix port exists
1300+
if (!oport_connected(port)) { port++; continue; }
1301+
port++;
1302+
if (output_string_name_list_[p] == "") continue;
1303+
1304+
std::ostringstream oss;
1305+
1306+
oss << "output_string" << p << ".mat";
1307+
output_string_matfile_[p] = oss.str();
1308+
std::string cmd;
1309+
cmd = "if exist('" + output_string_name_list_[p] + "','var'), save " + file_transfer_->remote_file(output_string_matfile_[p]) + " " + output_string_name_list_[p] + "; end\n";
1310+
m_file << cmd;
1311+
}
13131312

1314-
m_file.close();
1313+
m_file.close();
13151314

1316-
if (need_file_transfer_) file_transfer_->put_file(file_transfer_->local_file(mfile_),file_transfer_->remote_file(mfile_));
1317-
}
1318-
catch(...)
1319-
{
1320-
return(false);
1321-
}
1315+
if (need_file_transfer_) file_transfer_->put_file(file_transfer_->local_file(mfile_), file_transfer_->remote_file(mfile_));
13221316

1323-
return(true);
1324-
}
1317+
return(true);
1318+
}
13251319

1326-
#endif
13271320
bool InterfaceWithMatlabImpl::save_input_matrices()
13281321
{
13291322
try

0 commit comments

Comments
 (0)