Commit ac74072f authored by Lukas Werner's avatar Lukas Werner
Browse files

WIP commit

parent a5803345
Pipeline #6983 failed with stage
in 942 minutes and 35 seconds
......@@ -116,7 +116,7 @@ void Raytracer::setupView_() {
/*!\brief Writes the tBuffer to a file in the tBuffer output directory.
* \param tBuffer Buffer with t values as generated in rayTrace(...).
*/
void Raytracer::writeTBufferToFile(const std::map<Coordinates, real_t, CoordinatesComparator>& tBuffer, const size_t timestep) const {
void Raytracer::writeTBufferToFile(const std::vector<real_t>& tBuffer, const size_t timestep) const {
mpi::MPIRank rank = mpi::MPIManager::instance()->rank();
std::string fileName = "tbuffer_" + std::to_string(timestep) + "+" + std::to_string(rank) + ".ppm";
writeTBufferToFile(tBuffer, fileName);
......@@ -126,7 +126,7 @@ void Raytracer::writeTBufferToFile(const std::map<Coordinates, real_t, Coordinat
* \param tBuffer Buffer with t values as generated in rayTrace(...).
* \param fileName Name of the output file.
*/
void Raytracer::writeTBufferToFile(const std::map<Coordinates, real_t, CoordinatesComparator>& tBuffer, const std::string& fileName) const {
void Raytracer::writeTBufferToFile(const std::vector<real_t>& tBuffer, const std::string& fileName) const {
namespace fs = boost::filesystem;
real_t inf = std::numeric_limits<real_t>::max();
......@@ -135,8 +135,8 @@ void Raytracer::writeTBufferToFile(const std::map<Coordinates, real_t, Coordinat
real_t t_min = inf;
for (size_t x = 0; x < pixelsHorizontal_; x++) {
for (size_t y = 0; y < pixelsVertical_; y++) {
Coordinates c = {x, y};
real_t t = tBuffer.at(c);
size_t i = coordinateToArrayIndex(x, y);
real_t t = tBuffer[i];
if (t > t_max && !realIsIdentical(t, inf)) {
t_max = t;
}
......@@ -155,9 +155,9 @@ void Raytracer::writeTBufferToFile(const std::map<Coordinates, real_t, Coordinat
ofs << "P6\n" << pixelsHorizontal_ << " " << pixelsVertical_ << "\n255\n";
for (size_t y = pixelsVertical_-1; y > 0; y--) {
for (size_t x = 0; x < pixelsHorizontal_; x++) {
Coordinates c = {x, y};
size_t i = coordinateToArrayIndex(x, y);
char r = 0, g = 0, b = 0;
real_t t = tBuffer.at(c);
real_t t = tBuffer[i];
if (realIsIdentical(t, inf)) {
r = g = b = (char)0;
} else {
......
......@@ -137,8 +137,8 @@ public:
void rayTrace(const size_t timestep);
private:
void writeTBufferToFile(const std::map<Coordinates, real_t, CoordinatesComparator>& tBuffer, const size_t timestep) const;
void writeTBufferToFile(const std::map<Coordinates, real_t, CoordinatesComparator>& tBuffer, const std::string& fileName) const;
void writeTBufferToFile(const std::vector<real_t>& tBuffer, const size_t timestep) const;
void writeTBufferToFile(const std::vector<real_t>& tBuffer, const std::string& fileName) const;
bool isPlaneVisible(const PlaneID plane, const Ray& ray) const;
size_t coordinateToArrayIndex(size_t x, size_t y) const;
//@}
......@@ -243,11 +243,13 @@ inline void Raytracer::setTBufferOutputDirectory(const std::string& path) {
*/
template <typename BodyTypeTuple>
void Raytracer::rayTrace(const size_t timestep) {
real_t inf = std::numeric_limits<real_t>::max();
std::vector<real_t> tBuffer_vector(pixelsVertical_ * pixelsHorizontal_, inf);
std::map<Coordinates, real_t, CoordinatesComparator> tBuffer; // t values for each pixel
std::vector<BodyIntersectionInfo> intersections; // contains for each pixel information about an intersection, if existent
//std::map<Coordinates, BodyIntersectionInfo, CoordinatesComparator> localPixelIntersectionMap; // contains intersection info indexed by the coordinate of the pixel which was hit
real_t inf = std::numeric_limits<real_t>::max();
real_t t, t_closest;
walberla::id_t id_closest;
RigidBody* body_closest = NULL;
......@@ -330,7 +332,9 @@ void Raytracer::rayTrace(const size_t timestep) {
//localPixelIntersectionMap[c] = intersectionInfo;
}
tBuffer[c] = t_closest;
tBuffer_vector[coordinateToArrayIndex(x, y)] = t_closest;
//tBuffer[c] = t_closest;
}
//std::cout << std::endl;
}
......@@ -378,7 +382,7 @@ void Raytracer::rayTrace(const size_t timestep) {
}
if (getTBufferOutputEnabled()) {
writeTBufferToFile(tBuffer, timestep);
writeTBufferToFile(tBuffer_vector, timestep);
}
}
......
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