Skip to content

Commit

Permalink
Merge pull request #49 from INSIGNEO/pfire_next
Browse files Browse the repository at this point in the history
basis free rework
  • Loading branch information
ptooley authored Jun 20, 2019
2 parents 5c3520f + 3a4ac4a commit 282f766
Show file tree
Hide file tree
Showing 82 changed files with 3,762 additions and 3,475 deletions.
14 changes: 7 additions & 7 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Language: Cpp
BasedOnStyle: LLVM
AccessModifierOffset: -2
AlignAfterOpenBracket: DontAlign
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignEscapedNewlines: Left
Expand Down Expand Up @@ -44,7 +44,7 @@ BreakBeforeTernaryOperators: true
BreakConstructorInitializers: BeforeColon
BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: true
ColumnLimit: 99
ColumnLimit: 109
CommentPragmas: '^ IWYU pragma:'
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: false
Expand Down Expand Up @@ -82,15 +82,15 @@ ObjCBinPackProtocolList: Auto
ObjCBlockIndentWidth: 2
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
PenaltyBreakAssignment: 30
PenaltyBreakBeforeFirstCallParameter: 10
PenaltyBreakComment: 1
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 1000000
PenaltyExcessCharacter: 100
PenaltyReturnTypeOnItsOwnLine: 60
PointerAlignment: Right
PointerAlignment: Left
ReflowComments: true
SortIncludes: true
SortUsingDeclarations: true
Expand Down
7 changes: 5 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,11 @@ endif(OPENIMAGEIO_FOUND)

add_subdirectory(${pFIRE_SOURCE_DIR}/src)

enable_testing()
add_subdirectory(test)
option(BUILD_TESTS "Built pFIRE unit tests" ON)
if(BUILD_TESTS)
enable_testing()
add_subdirectory(unit_test)
endif(BUILD_TESTS)

include(FeatureSummary)
feature_summary(WHAT ALL)
Binary file modified doc/tutorial_files/faces_1/comparison.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified doc/tutorial_files/faces_1/sad2happy_map_render.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion src/baseconfiguration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ const config_map ConfigurationBase::arg_options = {{"fixed", ""}, {"moved", ""},
{"intermediate_directory", "intermediates"}, {"max_iterations", "100"}};

const config_map ConfigurationBase::bool_options = {
{"verbose", "false"}, {"with_memory", "true"}, {"save_intermediate_frames", "false"}};
{"verbose", "false"}, {"with_memory", "true"}, {"save_intermediate_frames", "false"},
{"memory_report", "true"}};

const std::vector<std::string> ConfigurationBase::required_options = {
"fixed", "moved", "nodespacing"};
Expand Down
4 changes: 2 additions & 2 deletions src/baseconfiguration.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class ConfigurationBase {
public:

template <typename T>
typename std::enable_if<std::is_same<T, bool>::value, T>::type grab(const std::string key) const
typename std::enable_if<std::is_same<T, bool>::value, T>::type grab(const std::string &key) const
{
try
{
Expand All @@ -56,7 +56,7 @@ class ConfigurationBase {

template <typename T>
typename std::enable_if<std::is_integral<T>::value && !std::is_same<T, bool>::value, T>::type
grab(const std::string key) const
grab(const std::string &key) const
{
try
{
Expand Down
34 changes: 16 additions & 18 deletions src/baseloader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,42 +24,40 @@
class BaseLoader {
public:
using loader_creator =
std::function<BaseLoader_unique(const std::string &filename, MPI_Comm comm)>;
std::function<BaseLoader_unique(const std::string& filename, MPI_Comm comm)>;

using loader_map = std::map<std::string, loader_creator>;

BaseLoader(const std::string &path, MPI_Comm comm = PETSC_COMM_WORLD)
: _comm(comm), _path(path), _shape(intvector(3, 0)){};
BaseLoader(const std::string& path, MPI_Comm comm = MPI_COMM_WORLD) : _comm(comm), _path(path) {}

virtual ~BaseLoader() = default;

const intvector &shape() const
{
return this->_shape;
};
static const loader_map &loaders()
{
return *_loaders;
};
const intcoord& shape() const { return _shape;}
const std::string& path() const { return _path;}
MPI_Comm comm() const { return _comm;}

static const loader_map& loaders() { return *_loaders; }

virtual void
copy_scaled_chunk(floating ***data, const intvector &size, const intvector &offset) const = 0;
virtual void copy_scaled_chunk(floating*** data, const intvector& size,
const intvector& offset) const = 0;

static bool register_loader(const std::string &name, loader_creator loader);
static bool register_loader(const std::string& name, loader_creator loader);

static BaseLoader_unique find_loader(const std::string &name, MPI_Comm comm = PETSC_COMM_WORLD);
static BaseLoader_unique find_loader(const std::string& name, MPI_Comm comm = MPI_COMM_WORLD);

protected:
void set_shape(const intcoord& shape){ _shape = shape;};

private:
MPI_Comm _comm;
std::string _path;
intvector _shape;
intcoord _shape;

private:
static std::unique_ptr<loader_map> _loaders;
};

template <class T, class U>
void norm_convert(U *outptr, const T *inptr, uinteger size, double min, double max)
void norm_convert(U* outptr, const T* inptr, uinteger size, double min, double max)
{
U fscale = (U)(max - min);
U fofs = (U)min;
Expand Down
28 changes: 14 additions & 14 deletions src/basewriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ const std::string BaseWriter::writer_name = "Basewriter";
const std::vector<std::string> BaseWriter::extensions({});

BaseWriter::BaseWriter(const std::string &filespec, const MPI_Comm &comm)
: filename(BaseWriter::split_filespec(filespec).first),
extra_path(BaseWriter::split_filespec(filespec).second), _comm(comm)
: _filename(BaseWriter::split_filespec(filespec).first),
_extra_path(BaseWriter::split_filespec(filespec).second), _comm(comm)
{
}

Expand All @@ -42,11 +42,11 @@ std::unique_ptr<BaseWriter::extension_map> BaseWriter::_extension_handlers =

std::unique_ptr<stringset> BaseWriter::_truncated_files = std::make_unique<stringset>();

std::string BaseWriter::find_writer_for_filename(const std::string &filename)
std::string BaseWriter::find_writer_for_filename(const std::string &_filename)
{
// Do it by lookup.
string_pair pp = split_filespec(filename);
std::string extension = bf::extension(split_filespec(filename).first);
string_pair pp = split_filespec(_filename);
std::string extension = bf::extension(split_filespec(_filename).first);
auto creatorname = BaseWriter::_extension_handlers->find(extension);
if (creatorname != BaseWriter::_extension_handlers->end())
{
Expand All @@ -58,30 +58,30 @@ std::string BaseWriter::find_writer_for_filename(const std::string &filename)
}

BaseWriter_unique BaseWriter::get_writer_by_name(
const std::string &name, const std::string &filename, MPI_Comm comm)
const std::string &name, const std::string &_filename, MPI_Comm comm)
{
// Do it by lookup.
auto creator = BaseWriter::_creators->find(name);
if (creator != BaseWriter::_creators->end())
{
return creator->second(filename, comm);
return creator->second(_filename, comm);
}
std::ostringstream err;
err << "No registered writer named \"" << name << "\".";
throw InvalidWriterError(err.str());
}

BaseWriter_unique BaseWriter::get_writer_for_filename(const std::string &filename, MPI_Comm comm)
BaseWriter_unique BaseWriter::get_writer_for_filename(const std::string &_filename, MPI_Comm comm)
{
try
{
return BaseWriter::get_writer_by_name(
BaseWriter::find_writer_for_filename(filename), filename, comm);
BaseWriter::find_writer_for_filename(_filename), _filename, comm);
}
catch (const pFIREExpectedError &errstr)
{
std::ostringstream err;
err << "No suitable writer available for file \"" << filename << "\"."
err << "No suitable writer available for file \"" << _filename << "\"."
<< "\n(" << errstr.what() << ")\n";
throw InvalidWriterError(err.str());
}
Expand All @@ -99,20 +99,20 @@ BaseWriter::string_pair BaseWriter::split_filespec(std::string input)
return std::make_pair(input, std::string(""));
}

bool BaseWriter::check_truncated(const std::string &filename)
bool BaseWriter::check_truncated(const std::string &_filename)
{
if (!BaseWriter::_truncated_files)
{
_truncated_files = std::make_unique<stringset>();
}
return (_truncated_files->find(filename) != _truncated_files->end());
return (_truncated_files->find(_filename) != _truncated_files->end());
}

void BaseWriter::mark_truncated(std::string filename)
void BaseWriter::mark_truncated(std::string _filename)
{
if (!BaseWriter::_truncated_files)
{
_truncated_files = std::make_unique<stringset>();
}
_truncated_files->emplace(std::move(filename));
_truncated_files->emplace(std::move(_filename));
}
25 changes: 15 additions & 10 deletions src/basewriter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,44 +41,49 @@ class BaseWriter {
virtual ~BaseWriter() = default;

virtual std::string write_image(const Image& image) = 0;
virtual std::string write_map(const Map& map) = 0;
virtual std::string write_map(const MapBase& map) = 0;

template <typename WriterClass>
static BaseWriter_unique create_writer(const std::string &path, MPI_Comm comm)
{
return BaseWriter_unique(new WriterClass(path, comm));
}

const std::string& filename() const { return _filename; }
const std::string& extra_path() const { return _extra_path; }
const MPI_Comm& comm() const { return _comm;}

static const std::vector<std::string>& components() { return _components;}

template <typename WriterClass>
static bool
//typename std::enable_if<std::is_convertible<WriterClass*, BaseWriter*>::value, bool>::type
register_writer();

static std::string find_writer_for_filename(const std::string& filename);
static std::string find_writer_for_filename(const std::string& _filename);

static BaseWriter_unique get_writer_by_name(const std::string& name,
const std::string& filename,
const std::string& _filename,
MPI_Comm comm = PETSC_COMM_WORLD);

static BaseWriter_unique get_writer_for_filename(const std::string& filename,
static BaseWriter_unique get_writer_for_filename(const std::string& _filename,
MPI_Comm comm = PETSC_COMM_WORLD);

static string_pair split_filespec(std::string input);

static bool check_truncated(const std::string& filename);
static void mark_truncated(std::string filename);
static bool check_truncated(const std::string& _filename);
static void mark_truncated(std::string _filename);

static const std::string writer_name;
static const std::vector<std::string> extensions;

protected:
std::string filename;
std::string extra_path;
private:
std::string _filename;
std::string _extra_path;
MPI_Comm _comm;

static const std::vector<std::string> _components;

private:
static std::unique_ptr<creator_map> _creators;
static std::unique_ptr<extension_map> _extension_handlers;
static std::unique_ptr<stringset> _truncated_files;
Expand Down
Loading

0 comments on commit 282f766

Please sign in to comment.