Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a52c3a553e | ||
|
|
4cd1528daa | ||
|
|
4b04f6c261 | ||
|
|
562a74bfca | ||
|
|
ce84e56ccf | ||
|
|
431028d5df | ||
|
|
2b20a3b1cf | ||
|
|
a8046ab9c3 | ||
|
|
b4b6d84030 | ||
|
|
1e1c51d140 | ||
|
|
333b2c6239 | ||
|
|
41161be42a | ||
|
|
24cdad1b75 | ||
|
|
44325f5a64 | ||
|
|
86f615d840 | ||
|
|
c42709e554 | ||
|
|
b0794599f9 | ||
|
|
659889d0d0 | ||
|
|
34ce813a2d |
@@ -1,3 +0,0 @@
|
||||
/bin
|
||||
/lib
|
||||
/build
|
||||
@@ -1130,6 +1130,19 @@ if(BRLCAD_ENABLE_OPENCL)
|
||||
endif(NOT OPENCL_FOUND)
|
||||
endif(BRLCAD_ENABLE_OPENCL)
|
||||
|
||||
# Enable features requiring Embree
|
||||
option(BRLCAD_ENABLE_EMBREE "Enable features requiring Embree raytracer" ON)
|
||||
if(BRLCAD_ENABLE_EMBREE)
|
||||
find_package(EMBREE)
|
||||
if(NOT EMBREE_FOUND)
|
||||
message("Embree support enablement requested, but Embree is not found - disabling")
|
||||
set(BRLCAD_ENABLE_EMBREE OFF)
|
||||
endif(NOT EMBREE_FOUND)
|
||||
endif(BRLCAD_ENABLE_EMBREE)
|
||||
|
||||
# Enable STEP
|
||||
option(BRLCAD_ENABLE_STEP "Enable STEP" ON)
|
||||
|
||||
# Enable features requiring Screened Poisson Surface Reconstruction
|
||||
option(BRLCAD_ENABLE_SPR "Enable features requiring Screened Poisson Surface Reconstruction" OFF)
|
||||
mark_as_advanced(BRLCAD_ENABLE_SPR)
|
||||
|
||||
+3
-1
@@ -73,7 +73,9 @@ else(CMAKE_CONFIGURATION_TYPES)
|
||||
endif(CMAKE_CONFIGURATION_TYPES)
|
||||
|
||||
add_subdirectory(comgeom)
|
||||
add_subdirectory(nist)
|
||||
if(BRLCAD_ENABLE_STEP)
|
||||
add_subdirectory(nist)
|
||||
endif(BRLCAD_ENABLE_STEP)
|
||||
add_subdirectory(faa)
|
||||
|
||||
foreach(g_input ${G_BENCHMARK_MODELS})
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
# F I N D E M B R E E . C M A K E
|
||||
# BRL-CAD
|
||||
#
|
||||
# Copyright (c) 2015 United States Government as represented by
|
||||
# the U.S. Army Research Laboratory.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
#
|
||||
# 2. Redistributions in binary form must reproduce the above
|
||||
# copyright notice, this list of conditions and the following
|
||||
# disclaimer in the documentation and/or other materials provided
|
||||
# with the distribution.
|
||||
#
|
||||
# 3. The name of the author may not be used to endorse or promote
|
||||
# products derived from this software without specific prior written
|
||||
# permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
|
||||
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
###
|
||||
###########################################################################
|
||||
# Embree ray tracer
|
||||
#
|
||||
# The following variables are set:
|
||||
#
|
||||
# EMBREE_INCLUDE_DIRS - where to find rtcore.h, etc.
|
||||
# EMBREE_LIBRARIES - Embree library.
|
||||
# EMBREE_FOUND - True if Embree found.
|
||||
|
||||
# TODO - look for various versions of Embree - simd enabled vs CPU, etc.
|
||||
|
||||
# If 'EMBREE_HOME' not set, use the env variable of that name if available
|
||||
if(NOT DEFINED EMBREE_HOME)
|
||||
if(NOT $ENV{EMBREE_HOME} STREQUAL "")
|
||||
set (EMBREE_HOME $ENV{EMBREE_HOME})
|
||||
endif(NOT $ENV{EMBREE_HOME} STREQUAL "")
|
||||
endif(NOT DEFINED EMBREE_HOME)
|
||||
|
||||
find_library(EMBREE_LIBRARY
|
||||
NAMES embree
|
||||
PATHS ${EMBREE_HOME}
|
||||
PATH_SUFFIXES lib lib/x64 embree/lib/x64)
|
||||
find_path(EMBREE_INCLUDE_DIR
|
||||
embree2/rtcore.h
|
||||
PATHS ${EMBREE_HOME}
|
||||
PATH_SUFFIXES include embree/include)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(EMBREE DEFAULT_MSG EMBREE_LIBRARY EMBREE_INCLUDE_DIR)
|
||||
|
||||
if(EMBREE_FOUND)
|
||||
set(EMBREE_LIBRARIES ${EMBREE_LIBRARY})
|
||||
set(EMBREE_INCLUDE_DIRS ${EMBREE_INCLUDE_DIR})
|
||||
endif(EMBREE_FOUND)
|
||||
|
||||
###########################################################################
|
||||
|
||||
# Local Variables:
|
||||
# tab-width: 8
|
||||
# mode: cmake
|
||||
# indent-tabs-mode: t
|
||||
# End:
|
||||
# ex: shiftwidth=2 tabstop=8
|
||||
@@ -146,6 +146,12 @@ while(${current_level} LESS ${HIGHEST_TARGET_LEVEL})
|
||||
endforeach(subdir ${level_${current_level}_dirs})
|
||||
endwhile(${current_level} LESS ${HIGHEST_TARGET_LEVEL})
|
||||
|
||||
if("${HIGHEST_TARGET_LEVEL}" GREATER 2 AND BRLCAD_ENABLE_EMBREE)
|
||||
verbose_add_subdirectory(src ert)
|
||||
else("${HIGHEST_TARGET_LEVEL}" GREATER 2 AND BRLCAD_ENABLE_EMBREE)
|
||||
CMAKEFILES(ert)
|
||||
endif("${HIGHEST_TARGET_LEVEL}" GREATER 2 AND BRLCAD_ENABLE_EMBREE)
|
||||
|
||||
# This corresponds roughly to the libbrlcad definition in
|
||||
# the autotools build. It needs CMake 2.8.8 plus changes
|
||||
# to the BRLCAD_ADDLIB macro to define OBJECT add_library
|
||||
|
||||
@@ -12,7 +12,9 @@ add_definitions(
|
||||
add_subdirectory(3dm)
|
||||
add_subdirectory(asc)
|
||||
add_subdirectory(gcv)
|
||||
add_subdirectory(step)
|
||||
if(BRLCAD_ENABLE_STEP)
|
||||
add_subdirectory(step)
|
||||
endif(BRLCAD_ENABLE_STEP)
|
||||
add_subdirectory(csg)
|
||||
|
||||
add_subdirectory(iges)
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
set(ERT_INCLUDE_DIRS
|
||||
${OPTICAL_INCLUDE_DIRS}
|
||||
${FB_INCLUDE_DIRS}
|
||||
${RT_INCLUDE_DIRS}
|
||||
${EMBREE_INCLUDE_DIRS}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
)
|
||||
list(REMOVE_DUPLICATES ERT_INCLUDE_DIRS)
|
||||
BRLCAD_INCLUDE_DIRS(ERT_INCLUDE_DIRS)
|
||||
|
||||
set(ert_SRCS
|
||||
ert.cxx
|
||||
)
|
||||
|
||||
BRLCAD_ADDEXEC(ert "${ert_SRCS}" "librt;libfb;liboptical;libicv;${EMBREE_LIBRARIES}" NO_INSTALL)
|
||||
|
||||
# Local Variables:
|
||||
# tab-width: 8
|
||||
# mode: cmake
|
||||
# indent-tabs-mode: t
|
||||
# End:
|
||||
# ex: shiftwidth=2 tabstop=8
|
||||
+469
@@ -0,0 +1,469 @@
|
||||
/* E R T . C X X
|
||||
* BRL-CAD
|
||||
*
|
||||
* Copyright (c) 2004-2014 United States Government as represented by
|
||||
* the U.S. Army Research Laboratory.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public License
|
||||
* version 2.1 as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this file; see the file named COPYING for more
|
||||
* information.
|
||||
*/
|
||||
/** @file rt/rtexample.c
|
||||
*
|
||||
* This is a heavily commented example of a program that uses librt to
|
||||
* shoot a single ray at some geometry in a .g database.
|
||||
*
|
||||
* The primary BRL-CAD ray-tracing API consists of calls to the
|
||||
* function rt_shootray(). This function takes a single argument, the
|
||||
* address of a data structure called the "application" structure.
|
||||
* This data structure contains crucial information, such as the
|
||||
* origin and direction of the ray to be traced, what to do if the ray
|
||||
* hits geometry, or what to do if it misses everything. While the
|
||||
* application struct is a large and somewhat complex looking, (it is
|
||||
* defined in the raytrace.h header) there are really very few items
|
||||
* in it which the application programmer must know about. These are:
|
||||
*
|
||||
* a_rt_i The "raytrace instance" obtained via rt_dirbuild()
|
||||
* a_ray The ray origin and direction to be shot
|
||||
* a_hit A callback function for when the ray encounters geometry
|
||||
* a_miss A callback function for when the ray misses everything
|
||||
*
|
||||
* Most of the work an application performs will be done in the "hit"
|
||||
* routine. This user-supplied routine gets called deep inside the
|
||||
* raytracing library via the rt_shootray() function. It is provided
|
||||
* with 3 parameters:
|
||||
*
|
||||
* ap Pointer to the application structure passed to rt_shootray()
|
||||
* PartHeadp List of ray "partitions" which represent geometry hit
|
||||
* segp List of ray "segments" that comprised partitions
|
||||
*
|
||||
* Most applications can ignore the last parameter. The PartHeadp
|
||||
* parameter is a linked-list of "partition" structures (defined in
|
||||
* the raytrace.h header). It is the job of the "hit" routine to
|
||||
* process these ray/object intersections to do the work of the
|
||||
* application.
|
||||
*
|
||||
* This file is part of the default compile in source distributions of
|
||||
* BRL-CAD and is usually installed or provided via binary and source
|
||||
* distributions. To compile this example from a binary install:
|
||||
*
|
||||
* cc -I/usr/brlcad/include/brlcad -L/usr/brlcad/lib -o rtexample rtexample.c -lbu -lrt -lm
|
||||
*
|
||||
* Jump to the START HERE section below for main().
|
||||
*/
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
extern "C" {
|
||||
#include "vmath.h" /* vector math macros */
|
||||
#include "raytrace.h" /* librt interface definitions */
|
||||
}
|
||||
|
||||
#include <embree2/rtcore.h>
|
||||
#include <embree2/rtcore_ray.h>
|
||||
#include <embree2/rtcore_geometry_user.h>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* rt_shootray() was told to call this on a hit.
|
||||
*
|
||||
* This callback routine utilizes the application structure which
|
||||
* describes the current state of the raytrace.
|
||||
*
|
||||
* This callback routine is provided a circular linked list of
|
||||
* partitions, each one describing one in and out segment of one
|
||||
* region for each region encountered.
|
||||
*
|
||||
* The 'segs' segment list is unused in this example.
|
||||
*/
|
||||
int
|
||||
bhit(struct application *ap, struct partition *PartHeadp, struct seg *UNUSED(segs))
|
||||
{
|
||||
/* iterating over partitions, this will keep track of the current
|
||||
* partition we're working on.
|
||||
*/
|
||||
struct partition *pp;
|
||||
|
||||
/* will serve as a pointer for the entry and exit hitpoints */
|
||||
struct hit *hitp;
|
||||
|
||||
/* will serve as a pointer to the solid primitive we hit */
|
||||
struct soltab *stp;
|
||||
|
||||
/* will contain surface curvature information at the entry */
|
||||
struct curvature cur = RT_CURVATURE_INIT_ZERO;
|
||||
|
||||
/* will contain our hit point coordinate */
|
||||
point_t pt;
|
||||
|
||||
/* will contain normal vector where ray enters geometry */
|
||||
vect_t inormal;
|
||||
|
||||
/* will contain normal vector where ray exits geometry */
|
||||
vect_t onormal;
|
||||
|
||||
/* iterate over each partition until we get back to the head.
|
||||
* each partition corresponds to a specific homogeneous region of
|
||||
* material.
|
||||
*/
|
||||
for (pp=PartHeadp->pt_forw; pp != PartHeadp; pp = pp->pt_forw) {
|
||||
|
||||
/* print the name of the region we hit as well as the name of
|
||||
* the primitives encountered on entry and exit.
|
||||
*/
|
||||
bu_log("\n--- Hit region %s (in %s, out %s)\n",
|
||||
pp->pt_regionp->reg_name,
|
||||
pp->pt_inseg->seg_stp->st_name,
|
||||
pp->pt_outseg->seg_stp->st_name );
|
||||
|
||||
/* entry hit point, so we type less */
|
||||
hitp = pp->pt_inhit;
|
||||
|
||||
/* construct the actual (entry) hit-point from the ray and the
|
||||
* distance to the intersection point (i.e., the 't' value).
|
||||
*/
|
||||
VJOIN1(pt, ap->a_ray.r_pt, hitp->hit_dist, ap->a_ray.r_dir);
|
||||
|
||||
/* primitive we encountered on entry */
|
||||
stp = pp->pt_inseg->seg_stp;
|
||||
|
||||
/* compute the normal vector at the entry point, flipping the
|
||||
* normal if necessary.
|
||||
*/
|
||||
RT_HIT_NORMAL(inormal, hitp, stp, &(ap->a_ray), pp->pt_inflip);
|
||||
|
||||
/* print the entry hit point info */
|
||||
rt_pr_hit(" In", hitp);
|
||||
VPRINT( " Ipoint", pt);
|
||||
VPRINT( " Inormal", inormal);
|
||||
|
||||
/* This next macro fills in the curvature information which
|
||||
* consists on a principle direction vector, and the inverse
|
||||
* radii of curvature along that direction and perpendicular
|
||||
* to it. Positive curvature bends toward the outward
|
||||
* pointing normal.
|
||||
*/
|
||||
RT_CURVATURE(&cur, hitp, pp->pt_inflip, stp);
|
||||
|
||||
/* print the entry curvature information */
|
||||
VPRINT("PDir", cur.crv_pdir);
|
||||
bu_log(" c1=%g\n", cur.crv_c1);
|
||||
bu_log(" c2=%g\n", cur.crv_c2);
|
||||
|
||||
/* exit point, so we type less */
|
||||
hitp = pp->pt_outhit;
|
||||
|
||||
/* construct the actual (exit) hit-point from the ray and the
|
||||
* distance to the intersection point (i.e., the 't' value).
|
||||
*/
|
||||
VJOIN1(pt, ap->a_ray.r_pt, hitp->hit_dist, ap->a_ray.r_dir);
|
||||
|
||||
/* primitive we exited from */
|
||||
stp = pp->pt_outseg->seg_stp;
|
||||
|
||||
/* compute the normal vector at the exit point, flipping the
|
||||
* normal if necessary.
|
||||
*/
|
||||
RT_HIT_NORMAL(onormal, hitp, stp, &(ap->a_ray), pp->pt_outflip);
|
||||
|
||||
/* print the exit hit point info */
|
||||
rt_pr_hit(" Out", hitp);
|
||||
VPRINT( " Opoint", pt);
|
||||
VPRINT( " Onormal", onormal);
|
||||
}
|
||||
|
||||
/* A more complicated application would probably fill in a new
|
||||
* local application structure and describe, for example, a
|
||||
* reflected or refracted ray, and then call rt_shootray() for
|
||||
* those rays.
|
||||
*/
|
||||
|
||||
/* Hit routine callbacks generally return 1 on hit or 0 on miss.
|
||||
* This value is returned by rt_shootray().
|
||||
*/
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This is a callback routine that is invoked for every ray that
|
||||
* entirely misses hitting any geometry. This function is invoked by
|
||||
* rt_shootray() if the ray encounters nothing.
|
||||
*/
|
||||
int
|
||||
miss(struct application *UNUSED(ap))
|
||||
{
|
||||
bu_log("missed\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
void brlcadBoundsFunction(void *ptr, size_t i, RTCBounds &bounds)
|
||||
{
|
||||
struct rt_i *rtip = (struct rt_i *)ptr;
|
||||
|
||||
bounds.lower_x = (float)rtip->rti_Solids[i]->st_min[X];
|
||||
bounds.lower_y = (float)rtip->rti_Solids[i]->st_min[Y];
|
||||
bounds.lower_z = (float)rtip->rti_Solids[i]->st_min[Z];
|
||||
|
||||
bounds.upper_x = (float)rtip->rti_Solids[i]->st_max[X];
|
||||
bounds.upper_y = (float)rtip->rti_Solids[i]->st_max[Y];
|
||||
bounds.upper_z = (float)rtip->rti_Solids[i]->st_max[Z];
|
||||
}
|
||||
|
||||
void freeTheSegs(struct seg &seghead, struct application *ap)
|
||||
{
|
||||
struct seg *segp;
|
||||
while (BU_LIST_WHILE(segp, seg, &(seghead.l))) {
|
||||
|
||||
BU_LIST_DEQUEUE(&(segp->l));
|
||||
|
||||
segp->seg_in.hit_rayp = segp->seg_out.hit_rayp = &ap->a_ray;
|
||||
rt_pr_seg(segp);
|
||||
|
||||
RT_FREE_SEG(segp, ap->a_resource);
|
||||
}
|
||||
}
|
||||
|
||||
void basicIntersection(void * ptr, RTCRay &ray, size_t i, struct seg segHead, struct application &ap)
|
||||
{
|
||||
struct rt_i *rtip = (struct rt_i *)ptr;
|
||||
VMOVE(ap.a_ray.r_pt, ray.org);
|
||||
VMOVE(ap.a_ray.r_dir, ray.dir);
|
||||
|
||||
RT_APPLICATION_INIT(&ap);
|
||||
ap.a_rt_i = rtip;
|
||||
ap.a_resource = &rt_uniresource;
|
||||
|
||||
rtip->rti_Solids[i]->st_meth->ft_shot(rtip->rti_Solids[i],
|
||||
&ap.a_ray,
|
||||
&ap,
|
||||
&segHead);
|
||||
}
|
||||
|
||||
void brlcadIntersectFunction(void * ptr, RTCRay &ray, size_t i)
|
||||
{
|
||||
struct seg seghead;
|
||||
BU_LIST_INIT(&seghead.l);
|
||||
struct application ap;
|
||||
|
||||
basicIntersection( ptr, ray, i, seghead, ap);
|
||||
|
||||
// process the segs here to give embree what it wants, free them for later use
|
||||
// perhaps we stash the segs in the RTCRay payload ;-)
|
||||
}
|
||||
|
||||
void brlcadOccludedFunction(void * ptr, RTCRay & ray, size_t i)
|
||||
{
|
||||
struct seg seghead;
|
||||
BU_LIST_INIT(&seghead.l);
|
||||
|
||||
struct application ap;
|
||||
|
||||
basicIntersection( ptr, ray, i, seghead, ap);
|
||||
|
||||
// fi segs found, then indicate we were hit
|
||||
if ( ! BU_LIST_IS_EMPTY(&(seghead.l)) ) {
|
||||
ray.geomID = 0;
|
||||
}
|
||||
|
||||
freeTheSegs(seghead, &ap);
|
||||
}
|
||||
|
||||
void essenceOfEmbree(struct application &ap)
|
||||
{
|
||||
rtcInit();
|
||||
|
||||
RTCScene scene = rtcNewScene(RTC_SCENE_STATIC, RTC_INTERSECT1);
|
||||
|
||||
struct rt_i *rtip = ap.a_rt_i;
|
||||
|
||||
unsigned geomID = rtcNewUserGeometry(scene, rtip->nsolids);
|
||||
rtcSetUserData(scene, geomID, rtip);
|
||||
rtcSetBoundsFunction(scene, geomID, brlcadBoundsFunction);
|
||||
rtcSetIntersectFunction(scene, geomID, brlcadIntersectFunction);
|
||||
rtcSetOccludedFunction(scene, geomID, brlcadOccludedFunction);
|
||||
|
||||
RTCRay rtcRay;
|
||||
VMOVE(rtcRay.org, ap.a_ray.r_pt); // double->float
|
||||
VMOVE(rtcRay.dir, ap.a_ray.r_dir); // double->float
|
||||
rtcRay.tnear = 0.0;
|
||||
|
||||
// launch a ray
|
||||
rtcIntersect( scene, rtcRay);
|
||||
|
||||
// collect the segs
|
||||
// call boolweave
|
||||
|
||||
rtcDeleteScene(scene);
|
||||
rtcExit();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void essenceOfShootray(struct application *ap)
|
||||
{
|
||||
struct seg seghead;
|
||||
BU_LIST_INIT(&seghead.l);
|
||||
|
||||
bu_log("nsolids:%lu\n", ap->a_rt_i->nsolids);
|
||||
|
||||
// long solidbits = rt_get_solidbitv(rtip->nsolids, resp);
|
||||
|
||||
struct soltab *stp;
|
||||
RT_VISIT_ALL_SOLTABS_START(stp, ap->a_rt_i)
|
||||
|
||||
stp->st_meth->ft_shot(stp, &ap->a_ray, ap, &seghead);
|
||||
|
||||
RT_VISIT_ALL_SOLTABS_END;
|
||||
|
||||
freeTheSegs(seghead, ap);
|
||||
}
|
||||
|
||||
/**
|
||||
* START HERE
|
||||
*
|
||||
* This is where it all begins.
|
||||
*/
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
/* Every application needs one of these. The "application"
|
||||
* structure carries information about how the ray-casting should
|
||||
* be performed. Defined in the raytrace.h header.
|
||||
*/
|
||||
struct application ap;
|
||||
|
||||
/* The "raytrace instance" structure contains definitions for
|
||||
* librt which are specific to the particular model being
|
||||
* processed. One copy exists for each model. Defined in
|
||||
* the raytrace.h header and is returned by rt_dirbuild().
|
||||
*/
|
||||
static struct rt_i *rtip;
|
||||
|
||||
/* optional parameter to rt_dirbuild() that can be used to capture
|
||||
* a title if the geometry database has one set.
|
||||
*/
|
||||
char title[1024] = {0};
|
||||
|
||||
/* Check for command-line arguments. Make sure we have at least a
|
||||
* geometry file and one geometry object on the command line.
|
||||
*/
|
||||
if (argc < 3) {
|
||||
bu_exit(1, "Usage: %s model.g objects...\n", argv[0]);
|
||||
}
|
||||
|
||||
/* Load the specified geometry database (i.e., a ".g" file).
|
||||
* rt_dirbuild() returns an "instance" pointer which describes the
|
||||
* database to be raytraced. It also gives you back the title
|
||||
* string if you provide a buffer. This builds a directory of the
|
||||
* geometry (i.e., a table of contents) in the file.
|
||||
*/
|
||||
rtip = rt_dirbuild(argv[1], title, sizeof(title));
|
||||
if (rtip == RTI_NULL) {
|
||||
bu_exit(2, "Building the database directory for [%s] FAILED\n", argv[1]);
|
||||
}
|
||||
|
||||
/* Display the geometry database title obtained during
|
||||
* rt_dirbuild if a title is set.
|
||||
*/
|
||||
if (title[0]) {
|
||||
bu_log("Title:\n%s\n", title);
|
||||
}
|
||||
|
||||
/* Walk the geometry trees. Here you identify any objects in the
|
||||
* database that you want included in the ray trace by iterating
|
||||
* of the object names that were specified on the command-line.
|
||||
*/
|
||||
while (argc > 2) {
|
||||
if (rt_gettree(rtip, argv[2]) < 0)
|
||||
bu_log("Loading the geometry for [%s] FAILED\n", argv[2]);
|
||||
argc--;
|
||||
argv++;
|
||||
}
|
||||
|
||||
/* This next call gets the database ready for ray tracing. This
|
||||
* causes some values to be precomputed, sets up space
|
||||
* partitioning, computes bounding volumes, etc.
|
||||
*/
|
||||
rt_prep_parallel(rtip, 1);
|
||||
|
||||
/* initialize all values in application structure to zero */
|
||||
RT_APPLICATION_INIT(&ap);
|
||||
|
||||
/* your application uses the raytrace instance containing the
|
||||
* geometry we loaded. this describes what we're shooting at.
|
||||
*/
|
||||
ap.a_rt_i = rtip;
|
||||
|
||||
/* stop at the first point of intersection or shoot all the way
|
||||
* through (defaults to 0 to shoot all the way through).
|
||||
*/
|
||||
ap.a_onehit = 0;
|
||||
|
||||
/* Set the ray start point and direction rt_shootray() uses these
|
||||
* two to determine what ray to fire. In this case we simply
|
||||
* shoot down the z axis toward the origin from 10 meters away.
|
||||
*
|
||||
* It's worth nothing that librt assumes units of millimeters.
|
||||
* All geometry is stored as millimeters regardless of the units
|
||||
* set during editing. There are libbu routines for performing
|
||||
* unit conversions if desired.
|
||||
*/
|
||||
VSET(ap.a_ray.r_pt, 0.0, 0.0, 10000.0);
|
||||
VSET(ap.a_ray.r_dir, 0.0, 0.0, -1.0);
|
||||
|
||||
/* Simple debug printing */
|
||||
VPRINT("Pnt", ap.a_ray.r_pt);
|
||||
VPRINT("Dir", ap.a_ray.r_dir);
|
||||
|
||||
|
||||
/* This is what callback to perform on a hit. */
|
||||
ap.a_hit = bhit;
|
||||
|
||||
/* This is what callback to perform on a miss. */
|
||||
ap.a_miss = miss;
|
||||
|
||||
|
||||
rt_init_resource(&rt_uniresource, 0, rtip);
|
||||
ap.a_resource = &rt_uniresource;
|
||||
|
||||
essenceOfShootray(&ap);
|
||||
|
||||
essenceOfEmbree(ap);
|
||||
|
||||
/* Shoot the ray. */
|
||||
(void)rt_shootray(&ap);
|
||||
|
||||
/* A real application would probably set up another ray and fire
|
||||
* again or do something a lot more complex in the callbacks.
|
||||
*/
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Local Variables:
|
||||
* mode: C
|
||||
* tab-width: 8
|
||||
* indent-tabs-mode: t
|
||||
* c-file-style: "stroustrup"
|
||||
* End:
|
||||
* ex: shiftwidth=4 tabstop=8
|
||||
*/
|
||||
Regular → Executable
Regular → Executable
@@ -786,7 +786,7 @@ set(SC_BUILD_SCHEMAS "" CACHE STRING "Disable schema builds for BRL-CAD" FORCE)
|
||||
# Lots of "libraries" associated with stepcode - use "stepcode" as the
|
||||
# stand-in for the build target var.
|
||||
THIRD_PARTY(stepcode SC stepcode sc_DESCRIPTION REQUIRED_VARS LEMON_EXECUTABLE
|
||||
PERPLEX_EXECUTABLE BRLCAD_LEVEL3 ALIASES ${sc_ALIASES} RESET_VARS
|
||||
PERPLEX_EXECUTABLE BRLCAD_LEVEL3 BRLCAD_ENABLE_STEP ALIASES ${sc_ALIASES} RESET_VARS
|
||||
EXP2CXX_EXEC EXP2CXX_EXECUTABLE_TARGET FLAGS NOSYS)
|
||||
if(BRLCAD_SC_BUILD)
|
||||
set(EXP2CXX_EXEC exp2cxx CACHE STRING "Express to C++ executable" FORCE)
|
||||
|
||||
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Reference in New Issue
Block a user