Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 24 additions & 24 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -111,32 +111,32 @@ if (XDG_ENABLE_GPRT)
endif()

list(APPEND xdg_sources
src/geometry/measure.cpp
src/geometry/plucker.cpp
src/geometry/closest.cpp
src/error.cpp
src/mesh_manager_interface.cpp
src/ray_tracing_interface.cpp
src/triangle_intersect.cpp
src/util/str_utils.cpp
src/tetrahedron_contain.cpp
src/config.cpp
src/xdg.cpp
src/overlap_check/overlap.cpp
src/element_face_accessor.cpp
src/timer.cpp
src/xdg.cpp
src/geometry/measure.cpp
src/geometry/closest.cpp
src/geometry/contain.cpp
src/geometry/plucker.cpp
src/error.cpp
src/mesh_manager_interface.cpp
src/ray_tracing_interface.cpp
src/util/str_utils.cpp
src/overlap_check/overlap.cpp
src/element_face_accessor.cpp
src/config.cpp
src/timer.cpp
src/xdg.cpp
)

if (XDG_ENABLE_EMBREE)
list(APPEND xdg_sources
src/embree/ray_tracer.cpp
src/embree/ray_tracer.cpp
src/embree/triangle_intersect.cpp
src/embree/tetrahedron_contain.cpp
)
endif()

if (XDG_ENABLE_GPRT)
list(APPEND xdg_sources
src/gprt/ray_tracer.cpp
src/gprt/ray_tracer.cpp
)
list(APPEND xdg_device_codes
dbl_deviceCode
Expand All @@ -146,16 +146,15 @@ endif()

if (XDG_ENABLE_LIBMESH)
list(APPEND xdg_sources
src/libmesh/mesh_manager.cpp
src/libmesh/mesh_manager.cpp
)
endif()

if (XDG_ENABLE_MOAB)
list(APPEND xdg_sources
# MOAB
src/moab/mesh_manager.cpp
src/moab/direct_access.cpp
src/moab/metadata.cpp
src/moab/mesh_manager.cpp
src/moab/direct_access.cpp
src/moab/metadata.cpp
)
endif()

Expand Down Expand Up @@ -191,6 +190,7 @@ endif()
add_library(xdg SHARED ${xdg_sources})

target_link_libraries(xdg indicators::indicators)
target_link_libraries(xdg fmt::fmt)

if(XDG_ENABLE_EMBREE)
# pass precompile definition depending on embree version
Expand All @@ -205,7 +205,7 @@ if (${CMAKE_BUILD_TYPE} MATCHES "Debug")
target_compile_definitions(xdg PUBLIC XDG_DEBUG)
endif()

target_link_libraries(xdg embree fmt::fmt)
target_link_libraries(xdg fmt::fmt)

# attempt to find OpenMP and include it if found
find_package(OpenMP)
Expand Down Expand Up @@ -251,7 +251,7 @@ endif()
# ==========================

if (XDG_ENABLE_EMBREE)
target_link_libraries(xdg embree fmt::fmt)
target_link_libraries(xdg embree)
endif()

if (XDG_ENABLE_GPRT)
Expand Down
5 changes: 4 additions & 1 deletion cmake/XDGConfig.cmake.in
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
get_filename_component(XDG_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" DIRECTORY)

find_package(fmt REQUIRED HINTS ${XDG_CMAKE_DIR}/../fmt)
find_package(embree @EMBREE_VERSION@ REQUIRED HINTS @EMBREE_ROOT_DIR@)

if (@XDG_ENABLE_EMBREE@)
find_package(embree @EMBREE_VERSION@ REQUIRED HINTS @EMBREE_ROOT_DIR@)
endif()

if(@XDG_ENABLE_MOAB@)
find_package(MOAB REQUIRED HINTS @MOAB_DIR@)
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
namespace xdg
{

struct MeshManager; // Forward declaration
class MeshManager; // Forward declaration
struct PrimitiveRef; // Forward declaration

struct SurfaceUserData {
Expand Down
10 changes: 10 additions & 0 deletions include/xdg/embree/interface.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

#ifdef XDG_EMBREE4

#include "xdg/embree/embree4.h"

#elif defined(XDG_EMBREE3)

#include "xdg/embree/embree3.h"

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
#define _XDG_TRIANGLE_REF_H

#include "xdg/constants.h"
#include "xdg/embree_interface.h"
#include "xdg/mesh_manager_interface.h"
#include "xdg/embree/interface.h"

namespace xdg {

Expand Down
4 changes: 2 additions & 2 deletions include/xdg/ray.h → include/xdg/embree/ray.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
#include "xdg/vec3da.h"

#include "xdg/constants.h"
#include "xdg/embree_interface.h"
#include "xdg/primitive_ref.h"
#include "xdg/embree/interface.h"
#include "xdg/embree/primitive_ref.h"

namespace xdg {

Expand Down
9 changes: 5 additions & 4 deletions include/xdg/embree/ray_tracer.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
#include <unordered_map>

#include "xdg/constants.h"
#include "xdg/embree_interface.h"
#include "xdg/embree/interface.h"
#include "xdg/mesh_manager_interface.h"
#include "xdg/primitive_ref.h"
#include "xdg/geometry_data.h"
#include "xdg/embree/primitive_ref.h"
#include "xdg/embree/geometry_data.h"
#include "xdg/ray_tracing_interface.h"
#include "xdg/ray.h"
#include "xdg/embree/ray.h"
#include "xdg/error.h"

namespace xdg {
Expand All @@ -21,6 +21,7 @@ class EmbreeRayTracer : public RayTracer {
public:
EmbreeRayTracer();
~EmbreeRayTracer();

RTLibrary library() const override { return RTLibrary::EMBREE; }

void init() override;
Expand Down
16 changes: 16 additions & 0 deletions include/xdg/embree/tetrahedron_contain.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#ifndef XDG_TETRAHEDRON_INTERSECT_H
#define XDG_TETRAHEDRON_INTERSECT_H


#include "xdg/embree/interface.h"
#include "xdg/vec3da.h"

namespace xdg
{
// Embree call back functions for element search
void VolumeElementBoundsFunc(RTCBoundsFunctionArguments* args);
void TetrahedronIntersectionFunc(RTCIntersectFunctionNArguments* args);
void TetrahedronOcclusionFunc(RTCOccludedFunctionNArguments* args);
} // namespace xdg

#endif // include guard
14 changes: 0 additions & 14 deletions include/xdg/embree_interface.h

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#ifndef XDG_TETRAHEDRON_INTERSECT_H
#define XDG_TETRAHEDRON_INTERSECT_H

#ifndef XDG_GEOMETRY_CONTAIN_H
#define XDG_GEOMETRY_CONTAIN_H

#include "xdg/vec3da.h"

#include "xdg/geometry/contain.h"

namespace xdg
{
/**
Expand Down Expand Up @@ -35,12 +36,5 @@ bool plucker_tet_containment_test(const Position& point,
const Vertex& v1,
const Vertex& v2,
const Vertex& v3);

// Embree call back functions for element search
void VolumeElementBoundsFunc(RTCBoundsFunctionArguments* args);
void TetrahedronIntersectionFunc(RTCIntersectFunctionNArguments* args);
void TetrahedronOcclusionFunc(RTCOccludedFunctionNArguments* args);

} // namespace xdg

#endif // include guard
3 changes: 0 additions & 3 deletions include/xdg/gprt/ray_tracer.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@

#include "xdg/constants.h"
#include "xdg/mesh_manager_interface.h"
#include "xdg/primitive_ref.h"
#include "xdg/geometry_data.h"
#include "xdg/ray_tracing_interface.h"
#include "xdg/ray.h"
#include "xdg/error.h"
#include "gprt/gprt.h"
#include "shared_structs.h"
Expand Down
3 changes: 0 additions & 3 deletions include/xdg/ray_tracing_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@
#include <unordered_map>

#include "xdg/constants.h"
#include "xdg/embree_interface.h"
#include "xdg/mesh_manager_interface.h"
#include "xdg/primitive_ref.h"
#include "xdg/geometry_data.h"

namespace xdg
{
Expand Down
2 changes: 0 additions & 2 deletions include/xdg/xdg.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,6 @@ Direction surface_normal(MeshID surface,
}
// Private methods
private:
double _triangle_volume_contribution(const PrimitiveRef& triangle) const;
double _triangle_area_contribution(const PrimitiveRef& triangle) const;

// Data members
std::shared_ptr<RayTracer> ray_tracing_interface_ {nullptr};
Expand Down
6 changes: 3 additions & 3 deletions src/embree/ray_tracer.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#include "xdg/embree/ray_tracer.h"
#include "xdg/error.h"
#include "xdg/geometry_data.h"
#include "xdg/ray.h"
#include "xdg/tetrahedron_contain.h"
#include "xdg/embree/geometry_data.h"
#include "xdg/embree/ray.h"
#include "xdg/embree/tetrahedron_contain.h"


namespace xdg {
Expand Down
43 changes: 3 additions & 40 deletions src/tetrahedron_contain.cpp → src/embree/tetrahedron_contain.cpp
Original file line number Diff line number Diff line change
@@ -1,49 +1,12 @@
#include "xdg/constants.h"
#include "xdg/geometry/contain.h"
#include "xdg/ray_tracing_interface.h"
#include "xdg/ray.h"
#include "xdg/vec3da.h"

#include "xdg/util/linalg.h"
#include "xdg/embree/geometry_data.h"
#include "xdg/embree/ray.h"

namespace xdg
{

bool plucker_tet_containment_test(const Position& point,
const Position& v0,
const Position& v1,
const Position& v2,
const Position& v3) {
using namespace linalg::aliases;
// Create matrix T = [v1 - v0, v2 - v0, v3 - v0]
Vec3da e0 = v1 - v0;
Vec3da e1 = v2 - v0;
Vec3da e2 = v3 - v0;
double3x3 T = { {e0.x, e0.y, e0.z},
{e1.x, e1.y, e1.z},
{e2.x, e2.y, e2.z}};

// Vector from v0 to point
Vec3da rhs = point - v0;

// Solve T * [λ1, λ2, λ3] = rhs
double3 lambda123 = mul(inverse(T),{rhs.x, rhs.y, rhs.z});

// Compute λ0
double lambda0 = 1.0f - (lambda123.x + lambda123.y + lambda123.z);

// Final barycentric coordinate vector
double4 bary = { lambda0, lambda123.x, lambda123.y, lambda123.z };

// Check all λ_i in [0, 1]
for (int i = 0; i < 4; ++i) {
if (bary[i] < -PLUCKER_ZERO_TOL || bary[i] > 1.0f + PLUCKER_ZERO_TOL)
return false;
}
return true;
}

// Embree callbacks

void VolumeElementBoundsFunc(RTCBoundsFunctionArguments* args)
{
const VolumeElementsUserData* user_data = (const VolumeElementsUserData*)args->geometryUserPtr;
Expand Down
11 changes: 7 additions & 4 deletions src/triangle_intersect.cpp → src/embree/triangle_intersect.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
#include <algorithm> // for find

#include "xdg/bbox.h"
#include "xdg/mesh_managers.h"
#include "xdg/geometry/closest.h"
#include "xdg/primitive_ref.h"
#include "xdg/geometry_data.h"
#include "xdg/geometry/plucker.h"
#include "xdg/ray.h"

#include "xdg/embree/primitive_ref.h"
#include "xdg/embree/geometry_data.h"
#include "xdg/embree/ray.h"

namespace xdg
{
Expand Down Expand Up @@ -77,7 +80,7 @@ void TriangleIntersectionFunc(RTCIntersectFunctionNArguments* args) {
// Check if ray is entering or exiting the volume it was fired against
// if this is a normal ray fire, flip the normal as needed
if (ray.volume_tree == user_data->reverse_vol && rayhit->ray.rf_type != RayFireType::FIND_VOLUME)
{
{
normal = -normal;
}

Expand Down
Loading
Loading