Commit 77a654fb authored by Lukas Werner's avatar Lukas Werner
Browse files

Better config reading of vectors, check validity of tbuffer output path in setter

parent d9cedca6
......@@ -19,7 +19,6 @@
#include "Raytracer.h"
#include <boost/filesystem.hpp>
using namespace walberla;
......@@ -61,39 +60,27 @@ Raytracer::Raytracer(const shared_ptr<BlockStorage> forest, BlockDataID storageI
* \param config Config block for the raytracer.
* The config block has to contain image_x (int), image_y (int), fov_vertical (real, in degrees)
* and tbuffer_output_directory (string) parameters. Additionally one block with x, y and z values (real)
* for each of camera, lookAt and the upVector.
* and tbuffer_output_directory (string) parameters. Additionally a vector of reals
* for each of cameraPosition, lookAt and the upVector.
Raytracer::Raytracer(const shared_ptr<BlockStorage> forest, BlockDataID storageID,
const Config::BlockHandle& config) : forest_(forest), storageID_(storageID) {
WALBERLA_CHECK(config.isValid(), "No valid config passed to raytracer");
pixelsHorizontal_ = config.getParameter<size_t>("image_x");
pixelsVertical_ = config.getParameter<size_t>("image_y");
fov_vertical_ = config.getParameter<real_t>("fov_vertical");
if (config.isDefined("tbuffer_output_directory")) {
WALBERLA_LOG_INFO_ON_ROOT("t buffers will be written to " << getTBufferOutputDirectory() << ".");
const Config::BlockHandle cameraConf = config.getBlock("camera");
WALBERLA_CHECK(cameraConf.isValid(), "No camera block found in config");
cameraPosition_ = Vec3(cameraConf.getParameter<real_t>("x"),
const Config::BlockHandle lookAtConf = config.getBlock("lookAt");
WALBERLA_CHECK(lookAtConf.isValid(), "No lookAt block found in config");
lookAtPoint_ = Vec3(lookAtConf.getParameter<real_t>("x"),
const Config::BlockHandle upVectorConf = config.getBlock("upVector");
WALBERLA_CHECK(upVectorConf.isValid(), "No upVector block found in config");
upVector_ = Vec3(upVectorConf.getParameter<real_t>("x"),
cameraPosition_ = config.getParameter<Vec3>("cameraPosition");
lookAtPoint_ = config.getParameter<Vec3>("lookAt");
upVector_ = config.getParameter<Vec3>("upVector");
......@@ -149,7 +136,6 @@ void Raytracer::writeTBufferToFile(const std::map<Coordinates, real_t, Coordinat
if (realIsIdentical(t_min, INFINITY)) t_min = 0;
fs::path dir (getTBufferOutputDirectory());
WALBERLA_CHECK(fs::exists(dir) && fs::is_directory(dir), "Tbuffer output directory is invalid.");
fs::path file (fileName);
fs::path fullPath = dir / file;
......@@ -25,6 +25,7 @@
#include <core/math/Vector3.h>
#include <core/mpi/all.h>
#include <core/config/Config.h>
#include <boost/filesystem.hpp>
#include "Ray.h"
#include "Intersects.h"
......@@ -205,10 +206,15 @@ inline void Raytracer::setTBufferOutputEnabled(const bool enabled) {
tBufferOutputEnabled_ = enabled;
/*!\brief Enabled / disable outputting the tBuffer to a file in the specified directory.
/*!\brief Enable / disable outputting the tBuffer to a file in the specified directory.
* \param enabled Set to true / false to enable / disable tbuffer output.
inline void Raytracer::setTBufferOutputDirectory(const std::string& path) {
namespace fs = boost::filesystem;
fs::path dir (path);
WALBERLA_CHECK(fs::exists(dir) && fs::is_directory(dir), "Tbuffer output directory is invalid.");
tBufferOutputDirectory_ = path;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment