Skip to content

Commit 92ba7ff

Browse files
committed
SAR: smaller improvements and CI MSVC fix
1 parent 83f7073 commit 92ba7ff

3 files changed

Lines changed: 10 additions & 22 deletions

File tree

tools/hdf5_file_reader.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -713,9 +713,8 @@ bool HDF5_File_Reader::GetDataSetNameByIndex(hid_t &group, unsigned int idx, std
713713
if (len<=0)
714714
return false;
715715

716-
char c_name[len+1];
717-
len = H5Gget_objname_by_idx(group, idx, c_name, len+1);
718-
name = c_name;
716+
name.resize(len);
717+
len = H5Gget_objname_by_idx(group, idx, &name[0], len+1);
719718
return true;
720719
}
721720

tools/sar_calculation.cpp

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -974,7 +974,7 @@ void SAR_Calculation::AssignUsedSAR(double* vx_sar, unsigned int start[3], unsig
974974
return;
975975
}
976976

977-
bool SAR_Calculation::CalcAvgStep1SAR(unsigned int t_id, ArrayLib::ArrayIJK<bool> &Vx_Valid, ArrayLib::ArrayIJK<bool> &Vx_Used)
977+
bool SAR_Calculation::CalcAvgStep1SAR(ArrayLib::ArrayIJK<bool> &Vx_Valid, ArrayLib::ArrayIJK<bool> &Vx_Used)
978978
{
979979
unsigned int pos[3];
980980

@@ -1005,11 +1005,6 @@ bool SAR_Calculation::CalcAvgStep1SAR(unsigned int t_id, ArrayLib::ArrayIJK<bool
10051005
size_t todo = Vx_Valid.size();
10061006
size_t prog_N = max(1,(int)(todo/100));
10071007
double* vx_sar = new double[m_SAR.size()];
1008-
if ((m_progress) && (t_id==0))
1009-
{
1010-
std::lock_guard<std::mutex> lock(m_resultMutex);
1011-
std::cout << "Step-1: ";
1012-
}
10131008

10141009
unsigned int i=0;
10151010
size_t prog_cnt;
@@ -1094,7 +1089,7 @@ bool SAR_Calculation::CalcAvgStep1SAR(unsigned int t_id, ArrayLib::ArrayIJK<bool
10941089
return true;
10951090
}
10961091

1097-
bool SAR_Calculation::CalcAvgStep2SAR(unsigned int t_id, ArrayLib::ArrayIJK<bool> &Vx_Valid, ArrayLib::ArrayIJK<bool> &Vx_Used)
1092+
bool SAR_Calculation::CalcAvgStep2SAR(ArrayLib::ArrayIJK<bool> &Vx_Valid, ArrayLib::ArrayIJK<bool> &Vx_Used)
10981093
{
10991094
unsigned int pos[3];
11001095

@@ -1114,19 +1109,11 @@ bool SAR_Calculation::CalcAvgStep2SAR(unsigned int t_id, ArrayLib::ArrayIJK<bool
11141109
size_t loc = 0;
11151110
size_t out_loc = 0;
11161111
size_t todo = Vx_Valid.size() - m_Valid - m_Used - m_AirVoxel;
1117-
if ((t_id==0) && (m_DebugLevel>0))
1118-
cout << todo << " voxel todo in step 2." << endl;
11191112
size_t prog_N = max(1,(int)(todo/100));
11201113

11211114
ArrayLib::ArrayIJK<float> dummy_SAR;
11221115
// count all used and unused etc. + special handling of unused voxels!!
11231116
loc = 0;
1124-
if ((m_progress) && (t_id==0))
1125-
{
1126-
std::lock_guard<std::mutex> lock(m_resultMutex);
1127-
std::cout << "Step-2: ";
1128-
}
1129-
11301117
size_t unused=0;
11311118
size_t prog_cnt = 0;
11321119

@@ -1264,7 +1251,7 @@ bool SAR_Calculation::CalcAveragedSAR(unsigned int numThreads)
12641251
m_nextStepChunk = 0;
12651252
std::vector<std::future<bool>> futures;
12661253
for (unsigned int t = 0; t < numThreads; ++t) {
1267-
futures.push_back(std::async(std::launch::async, [this, t, &Vx_Valid, &Vx_Used]() {return this->CalcAvgStep1SAR(t, Vx_Valid, Vx_Used);}));
1254+
futures.push_back(std::async(std::launch::async, [this, &Vx_Valid, &Vx_Used]() {return this->CalcAvgStep1SAR(Vx_Valid, Vx_Used);}));
12681255
}
12691256

12701257
bool successStep=true;
@@ -1297,13 +1284,15 @@ bool SAR_Calculation::CalcAveragedSAR(unsigned int numThreads)
12971284
cerr << "Number of invalid cubes (case 1): " << m_step1_case1 << endl;
12981285
cerr << "Number of invalid cubes (case 2): " << m_step1_case2 << endl;
12991286
cerr << "Number of invalid cubes (failed to converge): " << m_step1_no_conv << endl;
1287+
size_t todo = Vx_Valid.size() - m_Valid - m_Used - m_AirVoxel;
1288+
cout << "Step-2: " << todo << " voxel todo." << endl;
13001289
}
13011290

13021291
m_nextStepChunk = 0;
13031292
t_start = std::chrono::high_resolution_clock::now();
13041293
m_progressCounter = 0;
13051294
for (unsigned int t = 0; t < numThreads; ++t) {
1306-
futures.push_back(std::async(std::launch::async, [this, t, &Vx_Valid, &Vx_Used]() {return this->CalcAvgStep2SAR(t, Vx_Valid, Vx_Used);}));
1295+
futures.push_back(std::async(std::launch::async, [this, &Vx_Valid, &Vx_Used]() {return this->CalcAvgStep2SAR(Vx_Valid, Vx_Used);}));
13071296
}
13081297

13091298
for (auto& f : futures)

tools/sar_calculation.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,8 @@ class SAR_EXPORT SAR_Calculation
176176
std::mutex m_planeLocks[128];
177177
std::atomic<size_t> m_nextStepChunk{0};
178178
size_t m_step1_case1, m_step1_case2, m_step1_no_conv;
179-
bool CalcAvgStep1SAR(unsigned int t_id, ArrayLib::ArrayIJK<bool> &Vx_Valid, ArrayLib::ArrayIJK<bool> &Vx_Used);
180-
bool CalcAvgStep2SAR(unsigned int t_id, ArrayLib::ArrayIJK<bool> &Vx_Valid, ArrayLib::ArrayIJK<bool> &Vx_Used);
179+
bool CalcAvgStep1SAR(ArrayLib::ArrayIJK<bool> &Vx_Valid, ArrayLib::ArrayIJK<bool> &Vx_Used);
180+
bool CalcAvgStep2SAR(ArrayLib::ArrayIJK<bool> &Vx_Valid, ArrayLib::ArrayIJK<bool> &Vx_Used);
181181
bool CalcAveragedSAR(unsigned int numThreads=0);
182182

183183
int FindFittingCubicalMass(unsigned int pos[3], float box_size, unsigned int start[3], unsigned int stop[3],

0 commit comments

Comments
 (0)