Skip to content

Commit d6eff11

Browse files
Merge pull request #1585 from KrisThielemans/reduce_compiler_warnings
Reduce compiler warnings
2 parents 4f73a6c + d8c2b2c commit d6eff11

21 files changed

+51
-26
lines changed

src/Shape_buildblock/Shape3DWithOrientation.cxx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,15 @@ Shape3DWithOrientation::set_direction_vectors(const Array<2, float>& directions)
9292
}
9393

9494
bool
95-
Shape3DWithOrientation::operator==(const Shape3DWithOrientation& s) const
95+
Shape3DWithOrientation::operator==(const Shape3D& base_s) const
9696
{
97+
auto sptr = dynamic_cast<const Shape3DWithOrientation*>(&base_s);
98+
if (!sptr)
99+
return false; // not of same type
100+
auto& s = *sptr;
97101
const float tolerance = .001F;
98-
return norm(this->get_origin() - s.get_origin()) < tolerance && norm(this->_directions[1] - s._directions[1]) < tolerance
99-
&& norm(this->_directions[2] - s._directions[2]) < tolerance && norm(this->_directions[3] - s._directions[3]) < tolerance
100-
&& base_type::operator==(s);
102+
return norm(this->_directions[1] - s._directions[1]) < tolerance && norm(this->_directions[2] - s._directions[2]) < tolerance
103+
&& norm(this->_directions[3] - s._directions[3]) < tolerance && base_type::operator==(s);
101104
}
102105

103106
float

src/buildblock/ArrayFilter2DUsingConvolution.cxx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ ArrayFilter2DUsingConvolution<elemT>::is_trivial() const
4747
|| (filter_coefficients.get_length() == 1 && filter_coefficients.get_min_index() == 0 && filter_coefficients[0][0] == 1);
4848
}
4949

50+
#if 0
51+
// commented out as it does not make sense to have a 1D IndexRange for a 2D filter
5052
template <typename elemT>
5153
Succeeded
5254
ArrayFilter2DUsingConvolution<elemT>::get_influencing_indices(IndexRange<1>& influencing_index_range,
@@ -70,6 +72,7 @@ ArrayFilter2DUsingConvolution<elemT>::get_influenced_indices(IndexRange<1>& infl
7072
output_index_range.get_max_index() + filter_coefficients.get_max_index());
7173
return Succeeded::yes;
7274
}
75+
#endif
7376

7477
template <typename elemT>
7578
void

src/buildblock/ArrayFilter3DUsingConvolution.cxx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ ArrayFilter3DUsingConvolution<elemT>::is_trivial() const
5959
&& filter_coefficients[0][0][0] == 1);
6060
}
6161

62+
#if 0
63+
// commented out as it does not make sense to have a 1D IndexRange for a 2D filter
6264
template <typename elemT>
6365
Succeeded
6466
ArrayFilter3DUsingConvolution<elemT>::get_influencing_indices(IndexRange<1>& influencing_index_range,
@@ -82,6 +84,7 @@ ArrayFilter3DUsingConvolution<elemT>::get_influenced_indices(IndexRange<1>& infl
8284
output_index_range.get_max_index() + filter_coefficients.get_max_index());
8385
return Succeeded::yes;
8486
}
87+
#endif
8588

8689
#if 1
8790
template <typename elemT>

src/buildblock/GeometryBlocksOnCylindrical.cxx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,6 @@ GeometryBlocksOnCylindrical::build_crystal_maps(const Scanner& scanner)
8585
float trans_blocks_gap = transaxial_block_spacing - num_transaxial_crystals_per_block * transaxial_crystal_spacing;
8686
float ax_blocks_gap = axial_block_spacing - (num_axial_crystals_per_block - 1) * axial_crystal_spacing;
8787
float csi_minus_csiGaps = csi - (csi / transaxial_block_spacing * 2) * (transaxial_crystal_spacing / 2 + trans_blocks_gap);
88-
// distance between the center of the scannner and the first crystal in the bucket, r=Reffective/cos(csi)
89-
float r = scanner.get_effective_ring_radius() / cos(csi_minus_csiGaps);
90-
9188
float start_z = -(axial_block_spacing * num_axial_blocks_per_bucket * num_axial_buckets - ax_blocks_gap) / 2;
9289
float start_y = -1 * scanner.get_effective_ring_radius();
9390
float start_x = -1 // the first crystal in the bucket

src/buildblock/TimeFrameDefinitions.cxx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ START_NAMESPACE_STIR
4949
double
5050
TimeFrameDefinitions::get_start_time(unsigned int frame_num) const
5151
{
52+
if (frame_num < 1)
53+
throw std::runtime_error("TimeFrameDefinitions::get_start_time called for frame " + std::to_string(frame_num)
54+
+ ", but it should be at least 1.");
5255
if (frame_num > frame_times.size())
5356
throw std::runtime_error("TimeFrameDefinitions: asked for frame " + std::to_string(frame_num) + ", but only "
5457
+ std::to_string(frame_times.size()) + " frames present.");
@@ -58,6 +61,9 @@ TimeFrameDefinitions::get_start_time(unsigned int frame_num) const
5861
double
5962
TimeFrameDefinitions::get_end_time(unsigned int frame_num) const
6063
{
64+
if (frame_num < 1)
65+
throw std::runtime_error("TimeFrameDefinitions::get_end_time called for frame " + std::to_string(frame_num)
66+
+ ", but it should be at least 1.");
6167
if (frame_num > frame_times.size())
6268
throw std::runtime_error("TimeFrameDefinitions: asked for frame " + std::to_string(frame_num) + ", but only "
6369
+ std::to_string(frame_times.size()) + " frames present.");
@@ -253,8 +259,11 @@ TimeFrameDefinitions::TimeFrameDefinitions(const TimeFrameDefinitions& org_frame
253259
}
254260

255261
void
256-
TimeFrameDefinitions::set_time_frame(const int frame_num, const double start, const double end)
262+
TimeFrameDefinitions::set_time_frame(const unsigned int frame_num, const double start, const double end)
257263
{
264+
if (frame_num < 1)
265+
throw std::runtime_error("TimeFrameDefinitions::set_time_frame called for frame " + std::to_string(frame_num)
266+
+ ", but it should be at least 1.");
258267
if (frame_num > frame_times.size())
259268
throw std::runtime_error("TimeFrameDefinitions::set_time_frame called for frame " + std::to_string(frame_num) + ", but only "
260269
+ std::to_string(frame_times.size()) + " frames present.");
@@ -265,7 +274,7 @@ TimeFrameDefinitions::set_time_frame(const int frame_num, const double start, co
265274
bool
266275
TimeFrameDefinitions::operator==(const TimeFrameDefinitions& t) const
267276
{
268-
for (int frame = 0; frame < frame_times.size(); frame++)
277+
for (int frame = 0; static_cast<unsigned>(frame) < frame_times.size(); frame++)
269278
{
270279

271280
const bool is_identical = (std::abs(frame_times.at(frame).first - t.frame_times.at(frame).first) <= 10e-5)

src/data_buildblock/SinglesRatesFromGEHDF5.cxx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ SinglesRatesFromGEHDF5::read_from_file(const std::string& rdf_filename)
6262
// GE uses unsigned int, while SinglesRateForTimeSlices uses int, so we need a copy
6363
Array<2, unsigned int> GE_singles(IndexRange2D(0, _num_time_slices - 1, 0, total_singles_units - 1));
6464

65-
while (slice < _num_time_slices)
65+
while (slice < static_cast<unsigned>(_num_time_slices))
6666
{
6767
m_input_sptr->read_singles(GE_singles[slice], slice + 1);
6868
++slice;
@@ -73,7 +73,7 @@ SinglesRatesFromGEHDF5::read_from_file(const std::string& rdf_filename)
7373
std::copy(GE_singles.begin_all(), GE_singles.end_all(), _singles.begin_all());
7474

7575
// PW Modify this bit of code too.
76-
if (slice != _num_time_slices)
76+
if (slice != static_cast<unsigned>(_num_time_slices))
7777
{
7878
error("\nSinglesRatesFromGEHDF5: Couldn't read all records in the file. Read %d of %d. Exiting\n", slice, _num_time_slices);
7979
// TODO resize singles to return array with new sizes
@@ -83,7 +83,7 @@ SinglesRatesFromGEHDF5::read_from_file(const std::string& rdf_filename)
8383
{
8484
// GE RDF9 listmode stores singles every second
8585
_singles_time_interval = 1.0;
86-
for (unsigned int slice = 0; slice < _num_time_slices; ++slice)
86+
for (unsigned int slice = 0; slice < static_cast<unsigned>(_num_time_slices); ++slice)
8787
_times[slice] = slice + _singles_time_interval; // note that this has to store the "end-time" of the slice
8888

8989
assert(_times.size() != 0);

src/include/stir/Array.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,9 @@ class Array : public NumericVectorWithOffset<Array<num_dimensions - 1, elemT>, e
328328
// Make sure that we can access init() recursively
329329
template <int num_dimensions2, class elemT2>
330330
friend class Array;
331+
332+
using base_type::grow;
333+
using base_type::resize;
331334
};
332335

333336
/**************************************************

src/include/stir/ArrayFilter2DUsingConvolution.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,12 @@ class ArrayFilter2DUsingConvolution : public ArrayFunctionObject_2ArgumentImplem
4040

4141
bool is_trivial() const override;
4242

43+
#if 0
44+
// commented out as it does not make sense to have a 1D IndexRange for a 2D filter
4345
virtual Succeeded get_influencing_indices(IndexRange<1>& influencing_indices, const IndexRange<1>& output_indices) const;
4446

4547
virtual Succeeded get_influenced_indices(IndexRange<1>& influenced_indices, const IndexRange<1>& input_indices) const;
48+
#endif
4649

4750
private:
4851
Array<2, float> filter_coefficients;

src/include/stir/ArrayFilter3DUsingConvolution.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,12 @@ class ArrayFilter3DUsingConvolution : public ArrayFunctionObject_2ArgumentImplem
4040

4141
bool is_trivial() const override;
4242

43+
#if 0
44+
// commented out as it does not make sense to have a 1D IndexRange for a 2D filter
4345
virtual Succeeded get_influencing_indices(IndexRange<1>& influencing_indices, const IndexRange<1>& output_indices) const;
4446

4547
virtual Succeeded get_influenced_indices(IndexRange<1>& influenced_indices, const IndexRange<1>& input_indices) const;
48+
#endif
4649

4750
private:
4851
Array<3, float> filter_coefficients;

src/include/stir/Shape/Shape3DWithOrientation.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class Shape3DWithOrientation : public Shape3D
6060
typedef Shape3D base_type;
6161

6262
public:
63-
bool operator==(const Shape3DWithOrientation& s) const;
63+
bool operator==(const Shape3D& s) const override;
6464
void scale(const CartesianCoordinate3D<float>& scale3D) override;
6565

6666
//! get direction vectors currently in use

0 commit comments

Comments
 (0)