slot in GTE for our bot oriented bbox calculations

This commit is contained in:
f4alt committed 2025-01-22 09:42:12 -05:00
1 parent 005ac4c3db
commit 9dceba97f5
2 files changed
+46 -2

No files matched your search

+2 -1
View File
@@ -2,6 +2,7 @@ brlcad_find_package(MANIFOLD REQUIRED)
brlcad_find_package(OPENNURBS REQUIRED SYSPATTERN openNURBS)
brlcad_find_package(REGEX REQUIRED)
brlcad_find_package(GEOGRAM REQUIRED SYSPATTERN geogram)
find_package_gte(REQUIRED)
add_definitions(-DUSE_GEOGRAM)
if(NOT BRLCAD_ENABLE_GCT)
@@ -371,7 +372,7 @@ set(
)
# Include directories needed by librt users
set(RT_INCLUDE_DIRS ${OPENNURBS_INCLUDE_DIRS} ${OPENCL_INCLUDE_DIRS})
set(RT_INCLUDE_DIRS ${OPENNURBS_INCLUDE_DIRS} ${OPENCL_INCLUDE_DIRS} ${GTE_INCLUDE_DIR})
# locally used but not needed by users of the library
set(
+44 -1
View File
@@ -24,13 +24,15 @@
#include "common.h"
#include "Mathematics/ContOrientedBox3.h"
#include "raytrace.h"
#include "rt/geom.h"
#include "gdiam.hpp"
extern "C" int
rt_bot_oriented_bbox(struct rt_arb_internal *bbox, struct rt_db_internal *ip, const fastf_t UNUSED(tol))
rt_bot_oriented_bbox_GDIAM(struct rt_arb_internal *bbox, struct rt_db_internal *ip, const fastf_t UNUSED(tol))
{
struct rt_bot_internal *bot_ip;
@@ -70,6 +72,47 @@ rt_bot_oriented_bbox(struct rt_arb_internal *bbox, struct rt_db_internal *ip, co
return 0;
}
/* calc oriented bounding box using GTE */
extern "C" int
rt_bot_oriented_bbox(struct rt_arb_internal *bbox, struct rt_db_internal *ip, const fastf_t UNUSED(tol))
{
// make sure we have a bot
struct rt_bot_internal *bot_ip;
RT_CK_DB_INTERNAL(ip);
bot_ip = (struct rt_bot_internal *)ip->idb_ptr;
RT_BOT_CK_MAGIC(bot_ip);
// BoT vertices to gte::OrientedBox3
gte::OrientedBox3<fastf_t> gte_bb;
if (gte::GetContainer(bot_ip->num_vertices, (gte::Vector3<fastf_t> *)bot_ip->vertices, gte_bb)) {
// success: convert gte calculated -> rt_arb_internal
std::array<gte::Vector3<fastf_t>, 8> calculated_bb;
gte_bb.GetVertices(calculated_bb);
// V0: 0,0,0
VSET(bbox->pt[0], calculated_bb[0][0], calculated_bb[0][1], calculated_bb[0][2]);
// V1: 0,1,0
VSET(bbox->pt[1], calculated_bb[1][0], calculated_bb[1][1], calculated_bb[1][2]);
// V2: 0,1,1
VSET(bbox->pt[2], calculated_bb[3][0], calculated_bb[3][1], calculated_bb[3][2]);
// V3: 0,0,1
VSET(bbox->pt[3], calculated_bb[2][0], calculated_bb[2][1], calculated_bb[2][2]);
// V4: 1,0,0
VSET(bbox->pt[4], calculated_bb[4][0], calculated_bb[4][1], calculated_bb[4][2]);
// V5: 1,1,0
VSET(bbox->pt[5], calculated_bb[5][0], calculated_bb[5][1], calculated_bb[5][2]);
// V6: 1,1,1
VSET(bbox->pt[6], calculated_bb[7][0], calculated_bb[7][1], calculated_bb[7][2]);
// V7: 1,0,1
VSET(bbox->pt[7], calculated_bb[6][0], calculated_bb[6][1], calculated_bb[6][2]);
// calling code is expecting -1 on failure, 0 on success
return 0;
}
return -1;
}
// Local Variables:
// tab-width: 8