Skip to content

Commit 2f62732

Browse files
committed
Fix C++ code formatting for #3061
1 parent ee6f060 commit 2f62732

File tree

11 files changed

+60
-50
lines changed

11 files changed

+60
-50
lines changed

cpp/cmd/mrcalc.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -993,7 +993,7 @@ void run() {
993993
else if (opt->is("force") || opt->is("info") || opt->is("debug") || opt->is("quiet"))
994994
continue;
995995
else if (opt->is("config"))
996-
n+=2;
996+
n += 2;
997997

998998
#define SECTION 3
999999
#include "mrcalc.cpp"

cpp/core/adapter/reslice.h

+15-10
Original file line numberDiff line numberDiff line change
@@ -29,24 +29,29 @@ namespace MR::Adapter {
2929
namespace {
3030
// Partial specialisation for boolean value_type in order to avoid compiler
3131
// warning regarding use of multiplication when assigning to a boolean
32-
template <typename value_type>
33-
typename std::enable_if<std::is_same<value_type, bool>::value, value_type>::type inline normalise(
34-
const default_type sum, const default_type norm) {
32+
template <typename value_type> //
33+
typename std::enable_if<std::is_same<value_type, bool>::value, //
34+
value_type>::type inline //
35+
normalise(const default_type sum, const default_type norm) { //
3536
return ((sum * norm) >= 0.5) ? true : false;
3637
}
3738

3839
// Partial specialisation to invoke round-to-nearest when taking an average of integers
39-
template <typename value_type>
40-
typename std::enable_if<!std::is_same<value_type, bool>::value && std::is_integral<value_type>::value,
41-
value_type>::type inline normalise(const default_type sum, const default_type norm) {
40+
template <typename value_type> //
41+
typename std::enable_if<!std::is_same<value_type, bool>::value && //
42+
std::is_integral<value_type>::value, //
43+
value_type>::type inline //
44+
normalise(const default_type sum, const default_type norm) { //
4245
return value_type(std::round(sum * norm));
4346
}
4447

4548
// Standard implementation for floating point (either real or complex)
46-
template <typename value_type, typename summing_type>
47-
typename std::enable_if<!std::is_same<value_type, bool>::value && !std::is_integral<value_type>::value, value_type>::type
48-
inline normalise (const summing_type sum, const default_type norm) {
49-
return value_type (sum * norm);
49+
template <typename value_type, typename summing_type> //
50+
typename std::enable_if<!std::is_same<value_type, bool>::value && //
51+
!std::is_integral<value_type>::value, //
52+
value_type>::type inline //
53+
normalise(const summing_type sum, const default_type norm) { //
54+
return value_type(sum * norm);
5055
}
5156

5257
// If summing complex numbers, use double precision complex;

cpp/core/file/mmap.cpp

+6-7
Original file line numberDiff line numberDiff line change
@@ -107,15 +107,14 @@ MMap::MMap(const Entry &entry, bool readwrite, bool preload, int64_t mapped_size
107107
delayed_writeback = true;
108108
}
109109

110-
if (fsbuf.f_type == 0xff534d42 /* CIFS */ || fsbuf.f_type == 0x6969 /* NFS */ ||
111-
fsbuf.f_type == 0x65735546 /* FUSE */ || fsbuf.f_type == 0x517b /* SMB */ ||
112-
fsbuf.f_type == 0x47504653 /* GPFS */ || fsbuf.f_type == 0xbd00bd0 /* LUSTRE */ ||
113-
fsbuf.f_type == 0x1021997 /* 9P (WSL) */
114-
110+
if (fsbuf.f_type == 0xff534d42 /* CIFS */ || fsbuf.f_type == 0x6969 /* NFS */ || //
111+
fsbuf.f_type == 0x65735546 /* FUSE */ || fsbuf.f_type == 0x517b /* SMB */ || //
112+
fsbuf.f_type == 0x47504653 /* GPFS */ || fsbuf.f_type == 0xbd00bd0 /* LUSTRE */ || //
113+
fsbuf.f_type == 0x1021997 /* 9P (WSL) */ //
115114
#ifdef MRTRIX_MACOSX
116-
|| fsbuf.f_type == 0x0017 /* OSXFUSE */
115+
|| fsbuf.f_type == 0x0017 /* OSXFUSE */ //
117116
#endif
118-
) {
117+
) { //
119118
DEBUG("\"" + Entry::name + "\" appears to reside on a networked filesystem - using delayed write-back");
120119
delayed_writeback = true;
121120
}

cpp/core/file/png.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
namespace MR::File::PNG {
3131

3232
Reader::Reader(const std::string &filename)
33-
: infile (fopen(filename.c_str(), "rb")),
33+
: infile(fopen(filename.c_str(), "rb")),
3434
png_ptr(NULL),
3535
info_ptr(NULL),
3636
width(0),
@@ -148,7 +148,7 @@ Writer::Writer(const Header &H, const std::string &filename)
148148
bit_depth(0),
149149
filename(filename),
150150
data_type(H.datatype()),
151-
multiplier (1.0),
151+
multiplier(1.0),
152152
outfile(NULL) {
153153
if (Path::exists(filename) && !App::overwrite_files)
154154
throw Exception("output file \"" + filename + "\" already exists (use -force option to force overwrite)");
@@ -162,8 +162,8 @@ Writer::Writer(const Header &H, const std::string &filename)
162162
}
163163
outfile = fopen(filename.c_str(), "wb");
164164
if (!outfile)
165-
throw Exception ("Unable to open PNG file for writing for image \"" + filename + "\": " //
166-
+ strerror (errno)); //
165+
throw Exception("Unable to open PNG file for writing for image \"" + filename + "\": " //
166+
+ strerror(errno)); //
167167
png_init_io(png_ptr, outfile);
168168
png_set_compression_level(png_ptr, Z_DEFAULT_COMPRESSION);
169169
switch (H.ndim()) {
@@ -216,14 +216,14 @@ Writer::Writer(const Header &H, const std::string &filename)
216216
break;
217217
case DataType::Float32:
218218
bit_depth = 8;
219-
multiplier = std::numeric_limits<uint8_t>::infinity(); break;
219+
multiplier = std::numeric_limits<uint8_t>::infinity();
220220
break;
221221
case DataType::UInt16:
222222
case DataType::UInt32:
223223
case DataType::UInt64:
224224
case DataType::Float64:
225225
bit_depth = 16;
226-
multiplier = std::numeric_limits<uint16_t>::infinity(); break;
226+
multiplier = std::numeric_limits<uint16_t>::infinity();
227227
break;
228228
}
229229
// Detect cases where one axis has a size of 1, and hence represents the image plane

cpp/core/file/png.h

+6-4
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,14 @@ class Writer {
8686
template <typename T>
8787
void Writer::fill(uint8_t *in_ptr, uint8_t *out_ptr, const DataType data_type, const size_t num_elements) {
8888
auto fetch_func = __set_fetch_function<default_type>(data_type);
89-
for (size_t i = 0; i != num_elements; ++i)
90-
Raw::store_BE<T> (std::min (default_type(std::numeric_limits<T>::max()), //
91-
std::max (0.0, std::round(multiplier * fetch_func (in_ptr, 0)))), //
92-
out_ptr, i); //
89+
for (size_t i = 0; i != num_elements; ++i) {
90+
Raw::store_BE<T>(std::min(default_type(std::numeric_limits<T>::max()), //
91+
std::max(0.0, std::round(multiplier * fetch_func(in_ptr, 0)))), //
92+
out_ptr, //
93+
i); //
9394
in_ptr += data_type.bytes();
9495
out_ptr += sizeof(T);
96+
}
9597
};
9698

9799
} // namespace MR::File::PNG

cpp/core/formats/pipe.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ bool Pipe::check(Header &H, size_t num_axes) const {
5454
return false;
5555

5656
if (isatty(STDOUT_FILENO))
57-
throw Exception ("cannot create output piped image: " //
58-
"no command connected at other end of pipe to receive that image"); //
57+
throw Exception("cannot create output piped image: " //
58+
"no command connected at other end of pipe to receive that image"); //
5959

6060
H.name() = File::create_tempfile(0, "mif");
6161

cpp/core/header.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -726,11 +726,11 @@ concatenate(const std::vector<Header> &headers, const size_t axis_to_concat, con
726726
Header result(headers[0]);
727727

728728
if (axis_to_concat >= result.ndim()) {
729-
Stride::symbolise (result);
729+
Stride::symbolise(result);
730730
result.ndim() = axis_to_concat + 1;
731731
result.size(axis_to_concat) = 1;
732-
result.stride(axis_to_concat) = axis_to_concat+1;
733-
Stride::actualise (result);
732+
result.stride(axis_to_concat) = axis_to_concat + 1;
733+
Stride::actualise(result);
734734
}
735735

736736
for (size_t axis = 0; axis != result.ndim(); ++axis) {

cpp/core/image_io/png.cpp

+18-14
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,18 @@
2525
namespace MR::ImageIO {
2626

2727
void PNG::load(const Header &header, size_t) {
28-
DEBUG (std::string("loading PNG image") + (files.size() > 1 ? "s" : "") + " \"" + header.name() + "\"");
29-
segsize = header.datatype().bytes() * voxel_count(header) * files.size();
30-
addresses.resize(1);
31-
segsize = (header.datatype().bits() * voxel_count (header) + 7) / 8;
32-
addresses[0].reset (new uint8_t[segsize]);
28+
DEBUG(std::string("loading PNG image") + (files.size() > 1 ? "s" : "") + " \"" + header.name() + "\"");
29+
segsize = (header.datatype().bits() * voxel_count(header) + 7) / 8;
30+
addresses[0].reset(new uint8_t[segsize]);
3331
if (is_new) {
3432
memset(addresses[0].get(), 0x00, segsize);
3533
} else {
36-
const size_t slice_bytes = (header.datatype().bits() * //
37-
header.size(0) * //
38-
header.size(1) * //
39-
(header.ndim() == 4 ? header.size(3) : 1) + 7) //
40-
/ 8; //
34+
const size_t slice_bytes = (header.datatype().bits() * //
35+
header.size(0) * //
36+
header.size(1) * //
37+
(header.ndim() == 4 ? header.size(3) : 1) //
38+
+ 7) //
39+
/ 8; //
4140
for (size_t i = 0; i != files.size(); ++i) {
4241
File::PNG::Reader png(files[i].name);
4342
if (png.get_width() != header.size(0) || png.get_height() != header.size(1) ||
@@ -59,12 +58,17 @@ void PNG::load(const Header &header, size_t) {
5958
}
6059

6160
void PNG::unload(const Header &header) {
62-
assert (addresses.size() == 1);
61+
assert(addresses.size() == 1);
6362
if (writable) {
64-
const size_t slice_bytes = (header.datatype().bits() * header.size(0) * header.size(1) * (header.ndim() == 4 ? header.size(3) : 1) + 7) / 8;
63+
const size_t slice_bytes = (header.datatype().bits() * //
64+
header.size(0) * //
65+
header.size(1) * //
66+
(header.ndim() == 4 ? header.size(3) : 1) //
67+
+ 7) //
68+
/ 8; //
6569
for (size_t i = 0; i != files.size(); i++) {
66-
File::PNG::Writer png (header, files[i].name);
67-
png.save (addresses[0].get() + (i * slice_bytes));
70+
File::PNG::Writer png(header, files[i].name);
71+
png.save(addresses[0].get() + (i * slice_bytes));
6872
}
6973
}
7074
delete[] addresses[0].release();

cpp/core/image_io/ram.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class RAM : public Base {
2626

2727
protected:
2828
virtual void load(const Header &, size_t);
29-
virtual void unload(const Header &) { }
29+
virtual void unload(const Header &) {}
3030
};
3131

3232
} // namespace MR::ImageIO

cpp/core/image_io/scratch.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class Scratch : public Base {
2828

2929
protected:
3030
virtual void load(const Header &, size_t);
31-
virtual void unload(const Header &) { }
31+
virtual void unload(const Header &) {}
3232
};
3333

3434
} // namespace MR::ImageIO

cpp/core/image_io/variable_scaling.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class VariableScaling : public Base {
3838

3939
protected:
4040
virtual void load(const Header &, size_t);
41-
virtual void unload(const Header &) { }
41+
virtual void unload(const Header &) {}
4242
};
4343

4444
} // namespace MR::ImageIO

0 commit comments

Comments
 (0)