Revision: 40896
http://brlcad.svn.sourceforge.net/brlcad/?rev=40896&view=rev
Author: indianlarry
Date: 2010-10-04 14:36:20 +0000 (Mon, 04 Oct 2010)
Log Message:
-----------
Adding bundle ray shotliner rt_shootrays() as plural version of rt_shootray().
Follows design aspects of rt_shootray() with user definable callbacks for
bundle hit/miss functions. Also added a couple of ray pattern generators
rt_gen_circular_grid() and rt_gen_elliptical_grid(). Added bundle capability to
'rtshot', to test simply supply "-R (bundle radius in mm)" and optionally "-g
(bundle grid size in mm)". A "-X 0x80000000" will produce an "rtshot.plot" file
of the bundle that can be overlaid onto a target in 'mged'. Ex:
rtshot -X 0x80000000 -R 25.4 -g 1 -d -0.5 -0.5 -0.7071 -a -5821.27 618.726
3678.75 target.g all
Modified Paths:
--------------
brlcad/trunk/include/raytrace.h
brlcad/trunk/src/librt/bundle.c
brlcad/trunk/src/librt/mkbundle.c
brlcad/trunk/src/rt/rtshot.c
Modified: brlcad/trunk/include/raytrace.h
===================================================================
--- brlcad/trunk/include/raytrace.h 2010-10-01 17:30:52 UTC (rev 40895)
+++ brlcad/trunk/include/raytrace.h 2010-10-04 14:36:20 UTC (rev 40896)
@@ -250,6 +250,20 @@
#define RT_CK_RAY(_p) BU_CKMAG(_p, RT_RAY_MAGIC, "struct xray");
/**
+ * X R A Y S
+ *
+ * This plural xrays structure is a bu_list based container designed
+ * to hold a list or bundle of xray(s). This bundle is utilized by
+ * rt_shootrays() through its application bundle input.
+ *
+ */
+struct xrays
+{
+ struct bu_list l;
+ struct xray ray;
+};
+
+/**
* H I T
*
* Information about where a ray hits the surface
@@ -680,6 +694,35 @@
#define DEQUEUE_PT(_cur) BU_LIST_DEQUEUE((struct bu_list *)_cur)
/**
+ * P A R T I T I O N _ L I S T
+ *
+ * The partition_list structure - bu_list based structure for
+ * holding ray bundles.
+ *
+ */
+struct partition_list {
+ struct bu_list l;
+ struct application *ap;
+ struct partition PartHeadp;
+ struct seg segHeadp;
+ genptr_t userptr;
+};
+
+/**
+ * P A R T I T I O N _ B U N D L E
+ *
+ * Partition bundle. Passed from rt_shootrays() into user's bundle_hit()
+ * function.
+ *
+ */
+struct partition_bundle {
+ int hits;
+ int misses;
+ struct partition_list *list;
+ struct application *ap;
+};
+
+/**
* C U T
*
* Structure for space subdivision.
@@ -1560,6 +1603,48 @@
int a_flag; /**< @brief
application-specific flag */
int a_zero2; /**< @brief must be zero
(sanity check) */
};
+
+/**
+ * A P P L I C A T I O N _ B U N D L E
+ *
+ * This structure is the only parameter to rt_shootrays(). The entire
+ * structure should be zeroed (e.g. by memset) before it is used the
+ * first time.
+ *
+ * When calling rt_shootrays(), these fields are mandatory:
+ *
+ * - b_ap Members in this single ray application structure should
be set
+ * in a similar fashion as when used with rt_shootray()
with the
+ * exception of a_hit() and a_miss(). Default
implementaions of
+ * these routines are provided that simple update hit/miss
counters
+ * and attach the hit partitions and segments to the
+ * partition_bundle structure. Users can still override
this default
+ * functionality but have to make sure to move the
partition and
+ * segment list to the new partition_bundle structure.
+ * - b_hit() Routine to call when something is hit by the ray bundle.
+ * - b_miss() Routine to call when ray bundle misses everything.
+ *
+ * Note that rt_shootrays() returns the (int) return of the
+ * b_hit()/b_miss() function called, as well as placing it in
+ * b_return.
+ *
+ * An integer field b_user and a genptr_t field b_uptr are
+ * provided in the structure for custome user data.
+ *
+ */
+struct application_bundle
+{
+ unsigned long b_magic;
+ /* THESE ELEMENTS ARE MANDATORY */
+ struct xrays b_rays; /**< @brief Actual bundle of rays to be shot */
+ struct application b_ap; /**< @brief application setting to be applied to
each ray */
+ int (*b_hit)BU_ARGS((struct application_bundle *, struct partition_bundle
*)); /**< @brief called when bundle hits model */
+ int (*b_miss)BU_ARGS((struct application_bundle *)); /**< @brief called
when entire bundle misses */
+ int b_user; /**< @brief application_bundle-specific value */
+ genptr_t b_uptr; /**< @brief application_bundle-specific pointer */
+ int b_return;
+};
+
#define RT_AFN_NULL ((int (*)(struct application *, struct partition *,
struct region *, struct region *, struct partition *))NULL)
#define RT_CK_AP(_p) BU_CKMAG(_p, RT_AP_MAGIC, "struct application")
#define RT_CK_APPLICATION(_p) BU_CKMAG(_p, RT_AP_MAGIC, "struct application")
@@ -2287,9 +2372,30 @@
const struct partition *pp,
const struct bu_ptbl *regiontable,
const struct partition *InputHdp));
+
+/**
+ * Initial set of 'xrays' pattern generators that can
+ * used to feed a bundle set of rays to rt_shootrays()
+ */
+RT_EXPORT BU_EXTERN(int rt_gen_elliptical_grid,
+ (struct xrays *rays,
+ const struct xray *center_ray,
+ const fastf_t *avec,
+ const fastf_t *bvec,
+ fastf_t gridsize));
+RT_EXPORT BU_EXTERN(int rt_gen_circular_grid,
+ (struct xrays *ray_bundle,
+ const struct xray *center_ray,
+ fastf_t radius,
+ const fastf_t *up_vector,
+ fastf_t gridsize));
+
/* Shoot a ray */
RT_EXPORT BU_EXTERN(int rt_shootray,
(struct application *ap));
+/* Shoot a bundle of rays */
+RT_EXPORT BU_EXTERN(int rt_shootrays,
+ (struct application_bundle *bundle));
/* Get expr tree for object */
RT_EXPORT BU_EXTERN(void rt_free_soltab,
(struct soltab *stp));
Modified: brlcad/trunk/src/librt/bundle.c
===================================================================
--- brlcad/trunk/src/librt/bundle.c 2010-10-01 17:30:52 UTC (rev 40895)
+++ brlcad/trunk/src/librt/bundle.c 2010-10-04 14:36:20 UTC (rev 40896)
@@ -55,6 +55,18 @@
extern const union cutter *rt_advance_to_next_cell(register struct
rt_shootray_status *ssp);
/*
+ * Static hit/miss function declarations used as default a_hit()/a_miss()
single
+ * ray hit functions by rt_shootrays(). Along with updating some bundle
hit/miss
+ * counters these functions differ from their general user defined counterparts
+ * by dettaching the ray hit partition list and segment list and attaching it
to
+ * a partition bundle. Users can define there own functions but should
remember to
+ * hi-jack the partition and segment list or the single ray handling funtion
will
+ * return memory allocated to these list prior to the bundle b_hit() routine.
+ */
+static int bundle_hit(register struct application *ap, struct partition
*PartHeadp, struct seg *segp);
+static int bundle_miss(register struct application *ap);
+
+/*
* R T _ S H O O T R A Y _ B U N D L E
*
* Note that the direction vector r_dir
@@ -543,6 +555,181 @@
}
/*
+ * R T _ S H O O T R A Y S
+ *
+ * Function for shooting a bundle of rays. Iteratively walks list of rays
+ * contained in the application bundles xrays field 'b_rays' passing each
+ * single ray to r_shootray().
+ *
+ * Input:
+ * bundle Pointer to an application_bundle structure.
+ * b_ap Members in this single ray application
structure should be set
+ * in a similar fashion as when used with
rt_shootray() with the
+ * exception of a_hit() and a_miss().
Default implementaions of
+ * these routines are provided that simple
update hit/miss counters
+ * and attach the hit partitions and
segments to the
+ * partition_bundle structure. Users can
still override this default
+ * functionality but have to make sure to
move the partition and
+ * segment list to the new
partition_bundle structure.
+ * b_hit() Routine to call when something is hit by the
ray bundle.
+ * b_miss() Routine to call when ray bundle misses
everything.
+ *
+ */
+int rt_shootrays(struct application_bundle *bundle)
+{
+ char *status;
+ static int callcnt=0;
+ struct partition_bundle *pb = NULL;
+ genptr_t a_uptr_backup = NULL;
+ struct xray a_ray;
+ int (*a_hit)BU_ARGS((struct application *, struct partition *, struct seg
*));
+ int (*a_miss)BU_ARGS((struct application *));
+ /*
+ * temporarily hijack ap->a_uptr,ap->a_ray,ap->a_hit(),ap->a_miss()
+ */
+ a_uptr_backup = bundle->b_ap.a_uptr;
+ a_ray = bundle->b_ap.a_ray;
+ a_hit = bundle->b_ap.a_hit;
+ a_miss = bundle->b_ap.a_miss;
+
+ /* Shoot bundle of Rays */
+ bundle->b_ap.a_purpose = "bundled ray";
+ if (!bundle->b_ap.a_hit)
+ bundle->b_ap.a_hit = bundle_hit;
+ if (!bundle->b_ap.a_miss)
+ bundle->b_ap.a_miss = bundle_miss;
+
+ callcnt++;
+ pb = (struct partition_bundle *)bu_calloc( 1, sizeof( struct
partition_bundle), "partition bundle" );
+ pb->ap = &bundle->b_ap;
+ pb->hits = pb->misses = 0;
+
+ bundle->b_uptr = (genptr_t)pb;
+
+ struct application *ray_ap = NULL;
+ int ray_index;
+ int hit;
+ struct rt_i * rt_i = bundle->b_ap.a_rt_i; /**<
@brief this librt instance */
+ struct resource * resource = bundle->b_ap.a_resource; /**< @brief
dynamic memory resources */
+ struct xrays *r;
+ for (BU_LIST_FOR (r,xrays,&bundle->b_rays.l)) {
+ ray_ap = (struct application *)bu_calloc( 1, sizeof( struct
application), "ray application structure" );
+ *ray_ap = bundle->b_ap; /* structure copy */
+
+ ray_ap->a_ray = r->ray;
+ ray_ap->a_ray.magic = RT_RAY_MAGIC;
+ ray_ap->a_uptr = (genptr_t)pb;
+ ray_ap->a_rt_i = rt_i;
+ ray_ap->a_resource = resource;
+
+ hit = rt_shootray(ray_ap);
+
+ rt_i = ray_ap->a_rt_i;
+ resource = ray_ap->a_resource;
+
+ if (hit == 0)
+ bu_free((genptr_t)(ray_ap), "ray application
structure");
+ }
+
+ if ((bundle->b_hit) && (pb->hits > 0)) {
+ bundle->b_return = bundle->b_hit(bundle, pb);
+ status = "HIT";
+ } else if (bundle->b_miss) {
+ bundle->b_return = bundle->b_miss(bundle);
+ status = "MISS";
+ } else {
+ bundle->b_return = 0;
+ status = "MISS (unexpected)";
+ }
+
+ struct partition_list *pl;
+ if (pb->list != NULL) {
+ while (BU_LIST_WHILE(pl, partition_list, &(pb->list->l))) {
+ BU_LIST_DEQUEUE(&(pl->l));
+ RT_FREE_SEG_LIST(&pl->segHeadp, resource);
+ RT_FREE_PT_LIST(&pl->PartHeadp, resource);
+ bu_free(pl->ap, "ray application structure");
+ bu_free(pl, "free partition_list pl");
+ }
+ bu_free(pb->list,"free partition_list header");
+ }
+ bu_free(pb, "partition bundle" );
+ /*
+ * set back to original values before exiting
+ */
+ bundle->b_ap.a_uptr = a_uptr_backup;
+ bundle->b_ap.a_ray = a_ray;
+ bundle->b_ap.a_hit = a_hit;
+ bundle->b_ap.a_miss = a_miss;
+
+ return bundle->b_return;
+}
+
+/*
+ * B U N D L E _ H I T
+ *
+ * 'static' local hit function that simply adds hit partition to a ray bundle
structure
+ * passed in through ap->a_uptr and updates hit/miss stats.
+ *
+ */
+static int
+bundle_hit(register struct application *ap, struct partition *PartHeadp,
struct seg *segp)
+{
+ register struct partition *pp;
+ struct partition_bundle *bundle = (struct partition_bundle *)ap->a_uptr;
+
+ if ( (pp=PartHeadp->pt_forw) == PartHeadp ) {
+ bundle->misses++;
+ return 0; /* Nothing hit?? */
+ }
+
+ bundle->hits++;
+
+ if (bundle->list == NULL) {
+ /*
+ * setup partition collection
+ */
+ BU_GETSTRUCT(bundle->list, partition_list);
+ BU_LIST_INIT(&(bundle->list->l));
+ }
+
+ /* add a new partition to list */
+ struct partition_list *new_shotline;
+ BU_GETSTRUCT(new_shotline, partition_list);
+
+ /* steal partition list */
+ BU_LIST_INIT((struct bu_list *)&new_shotline->PartHeadp);
+ BU_LIST_MAGIC_SET((struct bu_list *)&new_shotline->PartHeadp, PT_HD_MAGIC);
+ BU_LIST_APPEND_LIST((struct bu_list *)&new_shotline->PartHeadp, (struct
bu_list *)PartHeadp);
+
+ BU_LIST_INIT(&new_shotline->segHeadp.l);
+ BU_LIST_MAGIC_SET(&new_shotline->segHeadp.l, RT_SEG_MAGIC);
+ BU_LIST_APPEND_LIST(&new_shotline->segHeadp.l, &segp->l);
+
+ new_shotline->ap = ap;
+ BU_LIST_PUSH(&(bundle->list->l), &(new_shotline->l));
+
+ return 1;
+
+}
+
+/*
+ * B U N D L E _ M I S S
+ *
+ * 'static' local hit function that simply miss stats for bundled rays.
+ *
+ */
+static int
+bundle_miss(register struct application *ap)
+{
+ struct partition_bundle *bundle = (struct partition_bundle *)ap->a_uptr;
+
+ bundle->misses++;
+
+ return 0;
+}
+
+/*
* Local Variables:
* mode: C
* tab-width: 8
Modified: brlcad/trunk/src/librt/mkbundle.c
===================================================================
--- brlcad/trunk/src/librt/mkbundle.c 2010-10-01 17:30:52 UTC (rev 40895)
+++ brlcad/trunk/src/librt/mkbundle.c 2010-10-04 14:36:20 UTC (rev 40896)
@@ -90,6 +90,95 @@
return count;
}
+/**
+ * R T _ G E N _ C I R C U L A R _ G R I D
+ *
+ * Make a bundle of rays around a main ray using a uniform rectangular grid
pattern with a circular extent.
+ * The radius, gridsize is given in mm.
+ *
+ * rp[0].r_dir must have unit length.
+ *
+ */
+int
+rt_gen_circular_grid(struct xrays *rays, const struct xray *center_ray,
fastf_t radius, const fastf_t *up_vector, fastf_t gridsize)
+{
+ int count = 0;
+ point_t C;
+ vect_t dir;
+ vect_t avec;
+ vect_t bvec;
+ vect_t uvec;
+
+ VMOVE(dir,center_ray->r_dir);
+ VMOVE(uvec, up_vector);
+ VUNITIZE(uvec);
+ VSCALE(bvec,uvec,radius);
+
+ VCROSS(avec, dir, up_vector);
+ VUNITIZE(avec);
+ VSCALE(avec,avec,radius);
+
+ return rt_gen_elliptical_grid(rays,center_ray,avec,bvec,gridsize);
+}
+
+/**
+ * R T _ G E N _ E L L I P T I C A L _ G R I D
+ *
+ * Make a bundle of rays around a main ray using a uniform rectangular grid
pattern with an elliptical extent.
+ *
+ * avec and bvec a. The gridsize is
+ * given in mm.
+ *
+ * rp[0].r_dir must have unit length.
+ *
+ */
+int
+rt_gen_elliptical_grid(struct xrays *rays, const struct xray *center_ray,
const fastf_t *avec, const fastf_t *bvec, fastf_t gridsize)
+{
+ register struct xrays *xrayp;
+ int count = 0;
+ point_t C;
+ vect_t dir;
+ vect_t a_dir;
+ vect_t b_dir;
+
+ fastf_t a = MAGNITUDE(avec);
+ VMOVE(a_dir,avec);
+ VUNITIZE(a_dir);
+
+ fastf_t b = MAGNITUDE(bvec);
+ VMOVE(b_dir,bvec);
+ VUNITIZE(b_dir);
+ fastf_t x,y;
+
+ VMOVE(C,center_ray->r_pt);
+ VMOVE(dir,center_ray->r_dir);
+ /* make sure avec perpendicular to bvec perpendicular to ray direction */
+ BU_ASSERT(NEAR_ZERO(VDOT(avec,bvec), VUNITIZE_TOL));
+ BU_ASSERT(NEAR_ZERO(VDOT(avec,dir), VUNITIZE_TOL));
+
+ int numrays = ((int)((2.0 * a) / gridsize) + 1)*((int)((2.0 * b) /
gridsize) + 1);
+
+ int first = 1;
+ int acpr = a / gridsize;
+ int bcpr = b / gridsize;
+ for ( y=gridsize * (-bcpr); y <= b; y=y+gridsize ) {
+ for ( x= gridsize * (-acpr); x <= a; x=x+gridsize ) {
+ if (((x*x)/(a*a) + (y*y)/(b*b)) < 1) {
+ xrayp = (struct xrays *)bu_calloc( sizeof( struct xrays ),
+ 1,
+ "bundled ray" );
+ VJOIN2( xrayp->ray.r_pt, C, x, a_dir, y, b_dir );
+ VMOVE( xrayp->ray.r_dir, dir );
+ xrayp->ray.index = count++;
+ xrayp->ray.magic = RT_RAY_MAGIC;
+ BU_LIST_APPEND(&rays->l,&xrayp->l);
+ }
+ }
+ }
+ return count;
+}
+
/*
* Test driver.
*/
Modified: brlcad/trunk/src/rt/rtshot.c
===================================================================
--- brlcad/trunk/src/rt/rtshot.c 2010-10-01 17:30:52 UTC (rev 40895)
+++ brlcad/trunk/src/rt/rtshot.c 2010-10-04 14:36:20 UTC (rev 40896)
@@ -69,7 +69,8 @@
-r # Set ray length\n\
-n # Set number of rings for ray bundle\n\
-c # Set number of rays per ring for ray bundle\n\
- -R # Set radius for ray bundle\n\
+ -R # Set radius for ray bundle in mm\n\
+ -g # Set ray bundle grid size in mm(default 1mm)\n\
-v \"attribute_name1 attribute_name2 ...\" Show attribute values\n";
static FILE *plotfp; /* For plotting into */
@@ -82,6 +83,7 @@
fastf_t set_ray_length = 0.0;
vect_t at_vect;
int overlap_claimant_handling = 0;
+fastf_t grid_size = -1.0; /* gridsize in mm */
int rays_per_ring = 0;
int num_rings = 0;
fastf_t bundle_radius = 0.0;
@@ -91,6 +93,9 @@
extern int rt_bot_tri_per_piece;
extern int rt_bot_minpieces;
+int bundle_hit(register struct application_bundle *bundle, struct
partition_bundle *PartBundlep);
+int bundle_miss(register struct application_bundle *bundle);
+
/*
* M A I N
*/
@@ -98,7 +103,6 @@
main(int argc, char **argv)
{
struct application ap;
-
static struct rt_i *rtip;
char *title_file;
char idbuf[RT_BUFSIZE] = {0}; /* First ID record info */
@@ -125,6 +129,11 @@
argc -= 2;
argv += 2;
break;
+ case 'g':
+ grid_size = atof( argv[1] );
+ argc -= 2;
+ argv += 2;
+ break;
case 'c':
rays_per_ring = atoi( argv[1] );
argc -= 2;
@@ -280,7 +289,7 @@
if ( set_dir + set_pt + set_at != 2 ) goto err;
- if ( num_rings != 0 || rays_per_ring != 0 || bundle_radius != 0.0 ) {
+ if ( num_rings != 0 || rays_per_ring != 0 ) {
if ( num_rings <= 0 || rays_per_ring <= 0 || bundle_radius <= 0.0 ) {
fprintf( stderr, "Must have all of \"-R\", \"-n\", and \"-c\"
set\n" );
goto err;
@@ -356,22 +365,63 @@
ap.a_miss = miss;
if ( rays_per_ring ) {
- vect_t avec, bvec;
- struct xray *rp;
+ vect_t avec, bvec;
+ struct xray *rp;
- /* create orthogonal rays for basis of bundle */
- bn_vec_ortho( avec, ap.a_ray.r_dir );
- VCROSS( bvec, ap.a_ray.r_dir, avec );
- VUNITIZE( bvec );
+ /* create orthogonal rays for basis of bundle */
+ bn_vec_ortho( avec, ap.a_ray.r_dir );
+ VCROSS( bvec, ap.a_ray.r_dir, avec );
+ VUNITIZE( bvec );
- rp = (struct xray *)bu_calloc( sizeof( struct xray ),
- (rays_per_ring * num_rings) + 1,
- "ray bundle" );
- rp[0] = ap.a_ray; /* struct copy */
- rp[0].magic = RT_RAY_MAGIC;
- rt_raybundle_maker( rp, bundle_radius, avec, bvec, rays_per_ring,
num_rings );
- (void)rt_shootray_bundle( &ap, rp, (rays_per_ring * num_rings) + 1 );
- } else {
+ rp = (struct xray *)bu_calloc( sizeof( struct xray ),
+ (rays_per_ring * num_rings)
+ 1,
+ "ray bundle" );
+ rp[0] = ap.a_ray; /* struct copy */
+ rp[0].magic = RT_RAY_MAGIC;
+ rt_raybundle_maker( rp, bundle_radius, avec, bvec,
rays_per_ring, num_rings );
+ (void)rt_shootray_bundle( &ap, rp, (rays_per_ring * num_rings)
+ 1 );
+ } else if (bundle_radius > 0.0 ) {
+ vect_t avec, bvec;
+ struct xray center_ray;
+ struct xray *rp;
+ struct xray *rays=NULL;
+ struct xrays *ray_bundle;
+ struct application_bundle b;
+ int numrays;
+
+ b.b_ap = ap;
+
+ /* to use default bundling routines set b.b_ap.a_hit
+ * and b.b_ap.a_miss to NULL */
+ b.b_ap.a_hit = NULL;
+ b.b_ap.a_miss = NULL;
+
+ BU_LIST_INIT(&b.b_rays.l);
+ b.b_hit = bundle_hit;
+ b.b_miss = bundle_miss;
+
+ if (grid_size <= 0.0)
+ grid_size = 1.0;
+
+ /* create orthogonal rays for basis of bundle */
+ bn_vec_ortho( avec, ap.a_ray.r_dir );
+ VCROSS( bvec, ap.a_ray.r_dir, avec );
+ VUNITIZE( bvec );
+
+ center_ray = ap.a_ray; /* struct copy */
+ numrays = rt_gen_circular_grid(&b.b_rays, ¢er_ray,
bundle_radius, avec, grid_size);
+
+ int testres = rt_shootrays(&b);
+
+ struct xrays *xr;
+ while (BU_LIST_WHILE(xr, xrays, &(b.b_rays.l))) {
+ BU_LIST_DEQUEUE(&(xr->l));
+ bu_free(xr,"bundled ray" );
+ }
+
+ rt_clean(rtip);
+ }
+ else {
(void)rt_shootray( &ap );
}
@@ -525,6 +575,160 @@
return 0;
}
+int bundle_hit(register struct application_bundle *bundle, struct
partition_bundle *PartBundlep)
+{
+ register struct partition *pp;
+ register struct soltab *stp;
+ struct curvature cur;
+ fastf_t out;
+ point_t inpt, outpt;
+ vect_t inormal, onormal;
+ int raycnt=1;
+
+ bu_log("------------------- bundle hit -------------------\n");
+
+ /* First, plot bundle's application ray */
+ if (R_DEBUG & RDEBUG_RAYPLOT) {
+ vect_t out;
+
+ VJOIN1(out, bundle->b_ap.a_ray.r_pt, 10000,
bundle->b_ap.a_ray.r_dir); /* to imply direction */
+ pl_color(plotfp, 0, 0, 255);
+ pdv_3line(plotfp, bundle->b_ap.a_ray.r_pt, out);
+ }
+
+ struct partition_list *pl;
+ for (BU_LIST_FOR(pl, partition_list, &(PartBundlep->list->l))) {
+ bu_log("------------------- partition %d
-------------------\n",raycnt++);
+ /* First, plot ray start to inhit */
+ pp = pl->PartHeadp.pt_forw;
+ if (R_DEBUG & RDEBUG_RAYPLOT) {
+ if (pp->pt_inhit->hit_dist > 0.0001) {
+ VJOIN1(inpt, pl->ap->a_ray.r_pt,
pp->pt_inhit->hit_dist,
+ pl->ap->a_ray.r_dir);
+ pl_color(plotfp, 0, 0, 255);
+ pdv_3line(plotfp, pl->ap->a_ray.r_pt, inpt);
+ }
+ }
+ for (; pp != &pl->PartHeadp; pp = pp->pt_forw) {
+ matp_t inv_mat;
+ Tcl_HashEntry *entry;
+
+ bu_log("\n--- Hit region %s (in %s, out %s) reg_bit =
%d\n",
+ pp->pt_regionp->reg_name,
pp->pt_inseg->seg_stp->st_name,
+ pp->pt_outseg->seg_stp->st_name,
pp->pt_regionp->reg_bit);
+
+ entry = Tcl_FindHashEntry(
+ (Tcl_HashTable *)
pl->ap->a_rt_i->Orca_hash_tbl,
+ (const char *) (size_t)
pp->pt_regionp->reg_bit);
+ if (!entry) {
+ inv_mat = (matp_t) NULL;
+ } else {
+ inv_mat = (matp_t) Tcl_GetHashValue(entry);
+ bn_mat_print("inv_mat", inv_mat);
+ }
+
+ if (pp->pt_overlap_reg) {
+ struct region *pp_reg;
+ int j = -1;
+
+ bu_log(" Claiming regions:\n");
+ while ((pp_reg = pp->pt_overlap_reg[++j]))
+ bu_log(" %s\n",
pp_reg->reg_name);
+ }
+
+ /* inhit info */
+ stp = pp->pt_inseg->seg_stp;
+ VJOIN1(inpt, pl->ap->a_ray.r_pt, pp->pt_inhit->hit_dist,
+ pl->ap->a_ray.r_dir);
+ RT_HIT_NORMAL(inormal, pp->pt_inhit, stp,
&(pl->ap->a_ray),
+ pp->pt_inflip);
+ RT_CURVATURE(&cur, pp->pt_inhit, pp->pt_inflip, stp);
+
+ rt_pr_hit(" In", pp->pt_inhit);
+ VPRINT(" Ipoint", inpt);
+ VPRINT(" Inormal", inormal);
+ bu_log(" PDir (%g, %g, %g) c1=%g, c2=%g\n",
V3ARGS(cur.crv_pdir),
+ cur.crv_c1, cur.crv_c2);
+
+ if (inv_mat) {
+ point_t in_trans;
+
+ MAT4X3PNT(in_trans, inv_mat, inpt);
+ bu_log("\ttransformed ORCA inhit = (%g %g
%g)\n", V3ARGS(
+ in_trans));
+ }
+
+ /* outhit info */
+ stp = pp->pt_outseg->seg_stp;
+ VJOIN1(outpt, pl->ap->a_ray.r_pt,
pp->pt_outhit->hit_dist,
+ pl->ap->a_ray.r_dir);
+ RT_HIT_NORMAL(onormal, pp->pt_outhit, stp,
&(pl->ap->a_ray),
+ pp->pt_outflip);
+ RT_CURVATURE(&cur, pp->pt_outhit, pp->pt_outflip, stp);
+
+ rt_pr_hit(" Out", pp->pt_outhit);
+ VPRINT(" Opoint", outpt);
+ VPRINT(" Onormal", onormal);
+ bu_log(" PDir (%g, %g, %g) c1=%g, c2=%g\n",
V3ARGS(cur.crv_pdir),
+ cur.crv_c1, cur.crv_c2);
+
+ if (inv_mat) {
+ point_t out_trans;
+ vect_t dir_trans;
+
+ MAT4X3PNT(out_trans, inv_mat, outpt);
+ MAT4X3VEC(dir_trans, inv_mat,
pl->ap->a_ray.r_dir);
+ VUNITIZE(dir_trans);
+ bu_log("\ttranformed ORCA outhit = (%g %g
%g)\n", V3ARGS(
+ out_trans));
+ bu_log("\ttransformed ORCA ray direction = (%g
%g %g)\n",
+ V3ARGS(dir_trans));
+ }
+
+ /* Plot inhit to outhit */
+ if (R_DEBUG & RDEBUG_RAYPLOT) {
+ if ((out = pp->pt_outhit->hit_dist) >= INFINITY)
+ out = 10000; /* to imply the direction
*/
+
+ VJOIN1(outpt, pl->ap->a_ray.r_pt, out,
pl->ap->a_ray.r_dir);
+ pl_color(plotfp, 0, 255, 255);
+ pdv_3line(plotfp, inpt, outpt);
+ }
+
+ {
+ struct region *regp = pp->pt_regionp;
+ int i;
+
+ if (pl->ap->attrs) {
+ bu_log("\tattribute values:\n");
+ i = 0;
+ while (pl->ap->attrs[i] &&
regp->attr_values[i]) {
+ bu_log("\t\t%s:\n",
pl->ap->attrs[i]);
+ bu_log("\t\t\tstring rep =
%s\n", BU_MRO_GETSTRING(
+
regp->attr_values[i]));
+ bu_log("\t\t\tlong rep = %d\n",
BU_MRO_GETLONG(
+
regp->attr_values[i]));
+ bu_log("\t\t\tdouble rep =
%f\n", BU_MRO_GETDOUBLE(
+
regp->attr_values[i]));
+ i++;
+ }
+ }
+ }
+ }
+ }
+ return 1;
+}
+int bundle_miss(register struct application_bundle *bundle) {
+ bu_log("bundle missed\n");
+ if (R_DEBUG & RDEBUG_RAYPLOT) {
+ vect_t out;
+
+ VJOIN1(out, bundle->b_ap.a_ray.r_pt, 10000,
bundle->b_ap.a_ray.r_dir); /* to imply direction */
+ pl_color(plotfp, 190, 0, 0);
+ pdv_3line(plotfp, bundle->b_ap.a_ray.r_pt, out);
+ }
+ return 0;
+}
/*
* Local Variables:
* mode: C
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Virtualization is moving to the mainstream and overtaking non-virtualized
environment for deploying applications. Does it make network security
easier or more difficult to achieve? Read this whitepaper to separate the
two and get a better understanding.
http://p.sf.net/sfu/hp-phase2-d2d
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits