Skip to content

Commit

Permalink
run clang-format
Browse files Browse the repository at this point in the history
  • Loading branch information
web-flow authored and KrisThielemans committed Feb 5, 2024
1 parent d38d7b7 commit 2a9fe54
Show file tree
Hide file tree
Showing 1,181 changed files with 108,941 additions and 117,090 deletions.
52 changes: 23 additions & 29 deletions examples/C++/General_Reconstruction/General_Reconstruction.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -5,53 +5,47 @@
#include <iostream>
START_NAMESPACE_STIR

General_Reconstruction::
General_Reconstruction()
{
this->set_defaults();
}
General_Reconstruction::General_Reconstruction() { 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
61 changes: 30 additions & 31 deletions examples/C++/using_STIR_LOCAL/demo3.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,23 @@
\brief A modification of demo2.cxx that parses all parameters from a parameter file.
It illustrates
- basic class derivation principles
- how to use ParsingObject to have automatic capabilities of parsing
parameters files (and interactive questions to the user)
- how most STIR programs parse the parameter files.
- basic class derivation principles
- how to use ParsingObject to have automatic capabilities of parsing
parameters files (and interactive questions to the user)
- how most STIR programs parse the parameter files.
Note that the same functionality could be provided without deriving
a new class from ParsingObject. One could have a KeyParser object
in main() and fill it in directly.
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 @@ -39,9 +39,10 @@
#include "stir/display.h"
#include <stdio.h>

namespace stir {
namespace stir
{

class MyStuff: public ParsingObject
class MyStuff : public ParsingObject
{
public:
void set_defaults();
Expand All @@ -52,18 +53,18 @@ class MyStuff: public ParsingObject
std::string input_filename;
std::string template_filename;
shared_ptr<BackProjectorByBin> back_projector_sptr;
shared_ptr<OutputFileFormat<DiscretisedDensity<3,float> > > output_file_format_sptr;
shared_ptr<OutputFileFormat<DiscretisedDensity<3, float>>> output_file_format_sptr;
};

void
MyStuff::set_defaults()
{
auto projection_matrix_sptr = std::make_shared<ProjMatrixByBinUsingRayTracing>();
back_projector_sptr = std::make_shared<BackProjectorByBinUsingProjMatrixByBin>(projection_matrix_sptr);
output_file_format_sptr = OutputFileFormat<DiscretisedDensity<3,float> >::default_sptr();
output_file_format_sptr = OutputFileFormat<DiscretisedDensity<3, float>>::default_sptr();
}

void
void
MyStuff::initialise_keymap()
{
parser.add_start_key("MyStuff parameters");
Expand All @@ -78,13 +79,10 @@ void
MyStuff::run(const bool display_off)
{

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());

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 All @@ -100,28 +98,29 @@ MyStuff::run(const bool display_off)
display(*density_sptr, density_sptr->find_max(), "Output");
}

}// end of namespace stir
} // end of namespace stir

int main(int argc, char **argv)
int
main(int argc, char** argv)
{
using namespace stir;

MyStuff my_stuff;
my_stuff.set_defaults();
bool display_off = false;
if (argc<2)
{
std::cerr << "Normal usage: " << argv[0] << " parameter-file [--display_off]\n";
std::cerr << "I will now ask you the questions interactively\n";
my_stuff.ask_parameters();
}
if (argc < 2)
{
std::cerr << "Normal usage: " << argv[0] << " parameter-file [--display_off]\n";
std::cerr << "I will now ask you the questions interactively\n";
my_stuff.ask_parameters();
}
else
{
my_stuff.parse(argv[1]);
if (argc>=3)
// Set the display_off to true if the second argument is "--display_off"
display_off = (strcmp(argv[2], "--display_off")==0);
}
{
my_stuff.parse(argv[1]);
if (argc >= 3)
// Set the display_off to true if the second argument is "--display_off"
display_off = (strcmp(argv[2], "--display_off") == 0);
}
my_stuff.run(display_off);
return EXIT_SUCCESS;
}
Loading

0 comments on commit 2a9fe54

Please sign in to comment.