Skip to content

Commit

Permalink
Merge pull request #4 from esa/osx-fix
Browse files Browse the repository at this point in the history
Version 1.2.1
  • Loading branch information
schuhmaj authored Nov 18, 2022
2 parents f42cd51 + 471335d commit 5404d05
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
6 changes: 3 additions & 3 deletions cmake/spdlog.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ include(FetchContent)

message(STATUS "Setting up spdlog")

find_package(spdlog 1.10.0 QUIET)
find_package(spdlog 1.11.0 QUIET)

if (${spdlog_FOUND})

Expand All @@ -12,10 +12,10 @@ else()

message(STATUS "Using spdlog from git repository")

#Fetches the version 1.10.0 for spdlog
#Fetches the version 1.11.0 for spdlog
FetchContent_Declare(spdlog
GIT_REPOSITORY https://github.com/gabime/spdlog.git
GIT_TAG v1.10.0
GIT_TAG v1.11.0
)

# Disable stuff we don't need
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def build_extension(self, ext):
# --------------------------------------------------------------------------------
setup(
name="polyhedral_gravity",
version="1.2",
version="1.2.1",
author="Jonas Schuhmacher",
author_email="[email protected]",
description="Package to compute full gravity tensor of a given constant density polyhedron for arbitrary points",
Expand Down
16 changes: 8 additions & 8 deletions src/polyhedralGravity/calculation/MeshChecking.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@ namespace polyhedralGravity::MeshChecking {
// Count every triangular face which is intersected by the ray
std::for_each(it.first, it.second, [&rayOrigin, &rayVector, &intersections](const Array3Triplet &triangle) {
const auto intersection = rayIntersectsTriangle(rayOrigin, rayVector, triangle);
if (intersection.has_value()) {
intersections.insert(intersection.value());
if (intersection != nullptr) {
intersections.insert(*intersection);
}
});
return intersections.size();
}

std::optional<Array3>
std::unique_ptr<Array3>
detail::rayIntersectsTriangle(const Array3 &rayOrigin, const Array3 &rayVector, const Array3Triplet &triangle) {
// Adapted Möller–Trumbore intersection algorithm
// see https://en.wikipedia.org/wiki/Möller–Trumbore_intersection_algorithm
Expand All @@ -60,27 +60,27 @@ namespace polyhedralGravity::MeshChecking {
const Array3 h = cross(rayVector, edge2);
const double a = dot(edge1, h);
if (a > -EPSILON && a < EPSILON) {
return std::nullopt;
return nullptr;
}

const double f = 1.0 / a;
const Array3 s = rayOrigin - triangle[0];
const double u = f * dot(s, h);
if (u < 0.0 || u > 1.0) {
return std::nullopt;
return nullptr;
}

const Array3 q = cross(s, edge1);
const double v = f * dot(rayVector, q);
if (v < 0.0 || u + v > 1.0) {
return std::nullopt;
return nullptr;
}

const double t = f * dot(edge2, q);
if (t > EPSILON) {
return rayOrigin + rayVector * t;
return std::make_unique<Array3>(rayOrigin + rayVector * t);
} else {
return std::nullopt;
return nullptr;
}
}
}
6 changes: 3 additions & 3 deletions src/polyhedralGravity/calculation/MeshChecking.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once

#include <set>
#include <optional>
#include <memory>
#include "thrust/transform_reduce.h"
#include "thrust/execution_policy.h"
#include "polyhedralGravity/model/Polyhedron.h"
Expand Down Expand Up @@ -50,11 +50,11 @@ namespace polyhedralGravity::MeshChecking {
* @param rayOrigin - the origin of the ray
* @param rayVector - the vector describing the ray
* @param triangle - a triangular face
* @return true if the ray intersects the triangle
* @return intersection point or null
*
* @related Adapted from https://en.wikipedia.org/wiki/Möller–Trumbore_intersection_algorithm
*/
std::optional<Array3>
std::unique_ptr<Array3>
rayIntersectsTriangle(const Array3 &rayOrigin, const Array3 &rayVector, const Array3Triplet &triangle);

}
Expand Down

0 comments on commit 5404d05

Please sign in to comment.