Skip to content

Commit

Permalink
Merge pull request #1368 from KrisThielemans/clangformat
Browse files Browse the repository at this point in the history
update and run clang-format
  • Loading branch information
KrisThielemans authored Feb 6, 2024
2 parents b486fc8 + 88f4ce7 commit 0dc76e5
Show file tree
Hide file tree
Showing 1,186 changed files with 109,193 additions and 116,805 deletions.
3 changes: 3 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,15 @@ BraceWrapping:
SplitEmptyFunction: false
SplitEmptyRecord: true
SplitEmptyNamespace: true
BinPackParameters: false
BinPackArguments: false
ColumnLimit: 130
IndentPPDirectives: AfterHash
PointerAlignment: Left
SortIncludes: false
SortUsingDeclarations: false
SpaceBeforeParens: ControlStatements
PackConstructorInitializers: Never
AllowShortFunctionsOnASingleLine: InlineOnly
Standard: Cpp11
...
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
repos:
- repo: git://github.com/doublify/pre-commit-clang-format
- repo: https://github.com/doublify/pre-commit-clang-format
rev: '62302476'
hooks:
- id: clang-format
Expand Down
20 changes: 11 additions & 9 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,25 @@ This is our recommended process. If it sounds too daunting, ask for help.
3. Create a branch in your fork with a descriptive name and put your fixes there. If your fix is
simple you could do it on github by editing a file, otherwise clone your project (or add a remote
to your current git clone) and work as usual.
4. If your change is important, add it to the release notesfor the upcoming version, [see](https://github.com/UCL/STIR/blob/master/documentation/)
4. Configure your editor and potentially even [pre-commit](https://pre-commit.com/), see
[documentation/devel/README.md](documentation/devel/README.md).
5. If your change is important, add it to the release notes for the upcoming version in the [documentation folder](https://github.com/UCL/STIR/tree/master/documentation/)
and even the [User's Guide](https://github.com/UCL/STIR/blob/master/documentation/STIR-UsersGuide.tex) or other documentation files.
5. Use [well-formed commit messages](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html)
6. Use [well-formed commit messages](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html)
for each change (in particular with a single "subject" line
followed by an empty line and then more details). If the change affects comments only, it is recommended to put `[ci skip]` in your subject line. This avoids unnecessary computation, and clogging our Travis/Appveyor queues.
6. Push the commits to your fork and submit a [pull request (PR)](https://help.github.com/articles/creating-a-pull-request)
(enable changes by project admins.) Give your pull request a descriptive name (i.e. don't call if *Fix #issuenumber*. Be prepared to add further commits to your branch after discussion.
In the description of the PR, add a statement about which Issue this applies to
using [a phrase such that github auto-closes the issue when merged to master](https://help.github.com/articles/closing-issues-using-keywords/).
7. Be prepared to add further commits to your branch after discussion.
followed by an empty line and then more details).
Please by mindful about the resources used by our Continuous Integration (CI) workflows:
- Group your commits and only push once your code compiles and tests succeed on your machine (ideally you have sensible commit messages at every stage)
- Use specific keywords in the first line of the last commit that you push to prevent CI being run:
- `[ci skip]` skips all CI runs (e.g. when you only change documentation, or when your update isn't ready yet)
- `[actions skip]` does not run GitHub Actions, see [here](https://github.blog/changelog/2021-02-08-github-actions-skip-pull-request-and-push-workflows-with-skip-ci/). Note: this can be in the main commit message.
- `[skip appveyor]` does not run Appveyor, see [here](https://www.appveyor.com/docs/how-to/filtering-commits/#skip-directive-in-commit-message)
8. After acceptance of your PR, go home with a nice warm feeling.
7. Push the commits to your fork and submit a [pull request (PR)](https://help.github.com/articles/creating-a-pull-request)
(enable changes by project admins.) Give your pull request a descriptive name (i.e. don't call if *Fix #issuenumber*. Be prepared to add further commits to your branch after discussion.
In the description of the PR, add a statement about which Issue this applies to
using [a phrase such that github auto-closes the issue when merged to master](https://help.github.com/articles/closing-issues-using-keywords/).
8. Be prepared to add further commits to your branch after discussion.
9. After acceptance of your PR, go home with a nice warm feeling.

Suggested reading:
https://help.github.com/articles/fork-a-repo/, https://git-scm.com/book/en/v2/GitHub-Contributing-to-a-Project or https://guides.github.com/activities/forking/.
Expand Down
5 changes: 4 additions & 1 deletion documentation/STIR-developers-overview.tex
Original file line number Diff line number Diff line change
Expand Up @@ -1331,7 +1331,10 @@ \section{

\section{Contributing to STIR}
See
\R2Lurl{https://github.com/UCL/STIR/blob/master/CONTRIBUTING.md}{STIR/CONTRIBUTING.md}.
\R2Lurl{https://github.com/UCL/STIR/blob/master/CONTRIBUTING.md}{STIR/CONTRIBUTING.md}
and
\R2Lurl{https://github.com/UCL/STIR/blob/master/documentation/devel/README.md}{documentation/devel/README.md}
for more information on editor settings etc.

\subsection{Continuous integration testing}
We use GitHub Actions and Appveyor for testing of every pull-request that was submitted on GitHub. PRs
Expand Down
14 changes: 13 additions & 1 deletion documentation/release_6.0.htm
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ <h1>Summary of changes in STIR release 6.0</h1>

<p>This version is 99% backwards compatible with STIR 5.x for the user (see below).
Developers might need to make code changes as
detailed below. Note though that the location of installed files have changed.
detailed below. Note though that the <strong>locations of installed files have changed</strong>.
Developers of other software that uses STIR via CMake will need to adapt (see below).
</p>
<h2>Overall summary</h2>
Expand Down Expand Up @@ -285,6 +285,18 @@ <h2>New deprecations for future versions</h2>
<H2>What's new for developers (aside from what should be obvious
from the above):</H2>

<h3>White-space and style enforcement</h3>
<ul>
<li>We now use <tt>clang-format</tt> to enforce C++-style, including white-space settings, line-breaks
etc. This uses the <tt>.clang-format</tt> file in the root directory of STIR. Developers should
configure their editor encordingly, and ideally use <tt>pre-commit</tt>. It also has
consequences for existing branches as you might experience more conflicts than usual
during a merge. More detail is in
<a href="https://github.com/UCL/STIR/blob/master/documentation/devel/README.md">documentation/devel/README.md</a>.<br>
<a href="https://github.com/UCL/STIR/pull/1368">PR #1368</a>.
</li>
</ul>

<h3>Backward incompatibities</h3>
<ul>
<li>
Expand Down
51 changes: 24 additions & 27 deletions examples/C++/General_Reconstruction/General_Reconstruction.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -5,53 +5,50 @@
#include <iostream>
START_NAMESPACE_STIR

General_Reconstruction::
General_Reconstruction()
General_Reconstruction::General_Reconstruction()
{
this->set_defaults();
this->set_defaults();
}

void
General_Reconstruction::set_defaults()
{

}
{}

void
General_Reconstruction::initialise_keymap()
{
this->parser.add_start_key("General reconstruction");
this->parser.add_stop_key("End General reconstruction");
this->parser.add_start_key("General reconstruction");
this->parser.add_stop_key("End General reconstruction");

this->parser.add_parsing_key("reconstruction method", &this->reconstruction_method_sptr);
this->parser.add_parsing_key("reconstruction method", &this->reconstruction_method_sptr);
}

bool
General_Reconstruction::post_processing()
{
return false;
return false;
}

Succeeded
General_Reconstruction::process_data()
{
HighResWallClockTimer t;
t.reset();
t.start();

//return reconstruction_object.reconstruct() == Succeeded::yes ?
// EXIT_SUCCESS : EXIT_FAILURE;
if (reconstruction_method_sptr->reconstruct() == Succeeded::yes)
{
t.stop();
std::cout << "Total Wall clock time: " << t.value() << " seconds" << std::endl;
return Succeeded::yes;
}
else
{
t.stop();
return Succeeded::no;
}
HighResWallClockTimer t;
t.reset();
t.start();

// return reconstruction_object.reconstruct() == Succeeded::yes ?
// EXIT_SUCCESS : EXIT_FAILURE;
if (reconstruction_method_sptr->reconstruct() == Succeeded::yes)
{
t.stop();
std::cout << "Total Wall clock time: " << t.value() << " seconds" << std::endl;
return Succeeded::yes;
}
else
{
t.stop();
return Succeeded::no;
}
}

END_NAMESPACE_STIR
24 changes: 10 additions & 14 deletions examples/C++/General_Reconstruction/General_Reconstruction.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,31 +16,27 @@
#include "stir/CartesianCoordinate3D.h"
#include "Reconstruction.h"


START_NAMESPACE_STIR

class Succeeded;

class General_Reconstruction : public ParsingObject
{
public:
//!
//! \brief General_Reconstuction
//! \details Default constructor
General_Reconstruction();
//!
//! \brief General_Reconstuction
//! \details Default constructor
General_Reconstruction();

virtual Succeeded process_data();
protected:
virtual Succeeded process_data();

void set_defaults();
void initialise_keymap();
bool post_processing();
protected:
void set_defaults();
void initialise_keymap();
bool post_processing();

private:

shared_ptr < Reconstruction < DiscretisedDensity < 3, float > > >
reconstruction_method_sptr;

shared_ptr<Reconstruction<DiscretisedDensity<3, float>>> reconstruction_method_sptr;
};

END_NAMESPACE_STIR
Expand Down
34 changes: 15 additions & 19 deletions examples/C++/using_STIR_LOCAL/demo1.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,20 @@
\brief A simple program that backprojects some projection data.
It illustrates
- basic interaction with the user,
- reading of images and projection data
- construction of a specified type of back-projector,
- how to use back-project all projection data
- output of images
- basic interaction with the user,
- reading of images and projection data
- construction of a specified type of back-projector,
- how to use back-project all projection data
- output of images
See README.txt in the directory where this file is located.
\author Kris Thielemans
\author Kris Thielemans
*/
/*
Copyright (C) 2004- 2011, Hammersmith Imanet Ltd
This software is distributed under the terms
This software is distributed under the terms
of the GNU General Public Licence (GPL)
See STIR/LICENSE.txt for details
*/
Expand All @@ -35,25 +35,21 @@
#include "stir/utilities.h"
#include "stir/Succeeded.h"

int main()
int
main()
{
using namespace stir;

/////////////// input sinogram
const std::string input_filename =
ask_filename_with_extension("Input file",".hs");
const std::string input_filename = ask_filename_with_extension("Input file", ".hs");

shared_ptr<ProjData>
proj_data_sptr(ProjData::read_from_file(input_filename));
shared_ptr<ProjDataInfo>
proj_data_info_sptr(proj_data_sptr->get_proj_data_info_sptr()->clone());
shared_ptr<ProjData> proj_data_sptr(ProjData::read_from_file(input_filename));
shared_ptr<ProjDataInfo> proj_data_info_sptr(proj_data_sptr->get_proj_data_info_sptr()->clone());

/////////////// template image (for sizes etc)
const std::string template_filename =
ask_filename_with_extension("Template image file",".hv");
const std::string template_filename = ask_filename_with_extension("Template image file", ".hv");

shared_ptr<DiscretisedDensity<3,float> >
density_sptr(read_from_file<DiscretisedDensity<3,float> >(template_filename));
shared_ptr<DiscretisedDensity<3, float>> density_sptr(read_from_file<DiscretisedDensity<3, float>>(template_filename));

density_sptr->fill(0);

Expand Down
39 changes: 17 additions & 22 deletions examples/C++/using_STIR_LOCAL/demo2.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,23 @@
\file
\ingroup examples
\brief A small modification of demo1.cxx to ask the user for the
back projector she wants to use.
back projector she wants to use.
It illustrates
- how to ask the user for objects for which different types
exist (e.g. back-projector, forward-projectors, image processors
etc), anything based on the RegisteredObject hierarchy.
- that STIR is able to select basic processing units at run-time
- how to use the (very) basic display facilities in STIR
- how to ask the user for objects for which different types
exist (e.g. back-projector, forward-projectors, image processors
etc), anything based on the RegisteredObject hierarchy.
- that STIR is able to select basic processing units at run-time
- how to use the (very) basic display facilities in STIR
See README.txt in the directory where this file is located.
\author Kris Thielemans
\author Kris Thielemans
*/
/*
Copyright (C) 2004- 2012, Hammersmith Imanet Ltd
This software is distributed under the terms
This software is distributed under the terms
of the GNU General Public Licence (GPL)
See STIR/LICENSE.txt for details
*/
Expand All @@ -34,31 +34,26 @@
#include "stir/Succeeded.h"
#include "stir/display.h"

int main()
int
main()
{
using namespace stir;

/////////////// input sinogram
const std::string input_filename =
ask_filename_with_extension("Input file",".hs");
const std::string input_filename = ask_filename_with_extension("Input file", ".hs");

shared_ptr<ProjData>
proj_data_sptr(ProjData::read_from_file(input_filename));
shared_ptr<ProjDataInfo>
proj_data_info_sptr(proj_data_sptr->get_proj_data_info_sptr()->clone());
shared_ptr<ProjData> proj_data_sptr(ProjData::read_from_file(input_filename));
shared_ptr<ProjDataInfo> proj_data_info_sptr(proj_data_sptr->get_proj_data_info_sptr()->clone());

/////////////// template image (for sizes etc)
const std::string template_filename =
ask_filename_with_extension("Template image file",".hv");
const std::string template_filename = ask_filename_with_extension("Template image file", ".hv");

shared_ptr<DiscretisedDensity<3,float> >
density_sptr(read_from_file<DiscretisedDensity<3,float> >(template_filename));
shared_ptr<DiscretisedDensity<3, float>> density_sptr(read_from_file<DiscretisedDensity<3, float>>(template_filename));

density_sptr->fill(0);

/////////////// back project
shared_ptr<BackProjectorByBin> back_projector_sptr
(BackProjectorByBin::ask_type_and_parameters());
shared_ptr<BackProjectorByBin> back_projector_sptr(BackProjectorByBin::ask_type_and_parameters());

back_projector_sptr->set_up(proj_data_info_sptr, density_sptr);

Expand Down
Loading

0 comments on commit 0dc76e5

Please sign in to comment.