Revision: 47159 http://brlcad.svn.sourceforge.net/brlcad/?rev=47159&view=rev Author: abhi2011 Date: 2011-10-06 21:11:04 +0000 (Thu, 06 Oct 2011) Log Message: ----------- Trying to get the overlap points by shooting raysat the AABB overlap region
Modified Paths: -------------- brlcad/trunk/src/libged/simulate/simrt.c brlcad/trunk/src/libged/simulate/simrt.h brlcad/trunk/src/libged/simulate/simutils.c Modified: brlcad/trunk/src/libged/simulate/simrt.c =================================================================== --- brlcad/trunk/src/libged/simulate/simrt.c 2011-10-06 18:26:30 UTC (rev 47158) +++ brlcad/trunk/src/libged/simulate/simrt.c 2011-10-06 21:11:04 UTC (rev 47159) @@ -78,7 +78,7 @@ point_t pt; /* will contain normal vector where ray enters geometry */ - vect_t inormal; + vect_t inormal; /* will contain normal vector where ray exits geometry */ vect_t onormal; @@ -189,9 +189,26 @@ * */ int -if_overlap(struct application *ap, struct partition *pp, struct region *reg1, struct region *reg2, struct partition *InputHdp) +if_overlap(struct application *ap, struct partition *pp, struct region *reg1, + struct region *reg2, struct partition *InputHdp) { - bu_log("OVERLAP"); + bu_log("if_overlap: OVERLAP between %s and %s", reg1->reg_name, reg2->reg_name); + fastf_t in_dist; + fastf_t out_dist; + point_t in_point; + point_t out_point; + + in_dist = pp->pt_inhit->hit_dist; + out_dist = pp->pt_outhit->hit_dist; + VJOIN1(in_point, ap->a_ray.r_pt, pp->pt_inhit->hit_dist, + ap->a_ray.r_dir); + VJOIN1(out_point, ap->a_ray.r_pt, pp->pt_outhit->hit_dist, + ap->a_ray.r_dir); + + bu_log("if_overlap: Entering at (%f,%f,%f) at distance of %f", V3ARGS(in_point), in_dist); + bu_log("if_overlap: Exiting at (%f,%f,%f) at distance of %f", V3ARGS(out_point), out_dist); + + return rt_defoverlap (ap, pp, reg1, reg2, InputHdp); } @@ -208,8 +225,6 @@ /* Raytrace related stuff */ struct rt_i *rtip; struct application ap; - struct resource res_tab; - attr_table a_tab; /* Add all sim objects to raytrace instance */ /* Make a new rt_i instance from the existing db_i sructure */ @@ -238,21 +253,19 @@ V3ARGS(rtip->mdl_min), V3ARGS(rtip->mdl_max)); /* Initialize the table of resource structures */ - rt_init_resource(&res_tab, 0, rtip); + /* rt_init_resource(&res_tab, 0, rtip); */ /* initialization of the application structure */ RT_APPLICATION_INIT(&ap); ap.a_hit = if_hit; /* branch to if_hit routine */ ap.a_miss = if_miss; /* branch to if_miss routine */ ap.a_overlap = if_overlap;/* branch to if_overlap routine */ - ap.a_logoverlap = rt_silent_logoverlap; + /*ap.a_logoverlap = rt_silent_logoverlap;*/ ap.a_onehit = 0; /* continue through shotline after hit */ - ap.a_resource = &res_tab; ap.a_purpose = "Manifold ray"; ap.a_rt_i = rtip; /* rt_i pointer */ ap.a_zero1 = 0; /* sanity check, sayth raytrace.h */ ap.a_zero2 = 0; /* sanity check, sayth raytrace.h */ - ap.a_uptr = (genptr_t)a_tab.attrib; /* Set the ray start point and direction rt_shootray() uses these * two to determine what ray to fire. In this case we simply Modified: brlcad/trunk/src/libged/simulate/simrt.h =================================================================== --- brlcad/trunk/src/libged/simulate/simrt.h 2011-10-06 18:26:30 UTC (rev 47158) +++ brlcad/trunk/src/libged/simulate/simrt.h 2011-10-06 21:11:04 UTC (rev 47159) @@ -51,11 +51,6 @@ */ #define GRID_GRANULARITY 0.04 -typedef struct attributes { - int attrib_use; - int attrib_cnt; - char **attrib; -} attr_table; /** * Shoots rays within the AABB overlap regions only to allow more rays to be shot Modified: brlcad/trunk/src/libged/simulate/simutils.c =================================================================== --- brlcad/trunk/src/libged/simulate/simutils.c 2011-10-06 18:26:30 UTC (rev 47158) +++ brlcad/trunk/src/libged/simulate/simutils.c 2011-10-06 21:11:04 UTC (rev 47159) @@ -187,6 +187,114 @@ int +line(struct ged *gedp, char* name, point_t from, point_t to, + unsigned char r, + unsigned char g, + unsigned char b) +{ + char *cmd_args[20]; + int rv; + char buffer_str[MAX_FLOATING_POINT_STRLEN]; + char *prefix_arrow_line = "arrow_line_"; + char *prefix_arrow_head = "arrow_head_"; + struct bu_vls arrow_line_vls = BU_VLS_INIT_ZERO, arrow_head_vls = BU_VLS_INIT_ZERO; + char *prefixed_arrow_line, *prefixed_arrow_head; + vect_t v; + + /* Arrow line primitive name */ + bu_vls_sprintf(&arrow_line_vls, "%s%s", prefix_arrow_line, name); + prefixed_arrow_line = bu_vls_addr(&arrow_line_vls); + + /* Arrow line primitive name */ + bu_vls_sprintf(&arrow_head_vls, "%s%s", prefix_arrow_head, name); + prefixed_arrow_head = bu_vls_addr(&arrow_head_vls); + + if (kill(gedp, prefixed_arrow_line) != GED_OK) { + bu_log("line: ERROR Could not delete existing \"%s\"\n", prefixed_arrow_line); + return GED_ERROR; + } + + if (kill(gedp, prefixed_arrow_head) != GED_OK) { + bu_log("line: ERROR Could not delete existing \"%s\"\n", prefixed_arrow_head); + return GED_ERROR; + } + + cmd_args[0] = "in"; + cmd_args[1] = prefixed_arrow_line; + cmd_args[2] = "bot"; + cmd_args[3] = "3"; + cmd_args[4] = "1"; + cmd_args[5] = "1"; + cmd_args[6] = "1"; + + sprintf(buffer_str, "%f", from[0]); cmd_args[7] = bu_strdup(buffer_str); + sprintf(buffer_str, "%f", from[1]); cmd_args[8] = bu_strdup(buffer_str); + sprintf(buffer_str, "%f", from[2]); cmd_args[9] = bu_strdup(buffer_str); + + sprintf(buffer_str, "%f", to[0]); cmd_args[10] = bu_strdup(buffer_str); + sprintf(buffer_str, "%f", to[1]); cmd_args[11] = bu_strdup(buffer_str); + sprintf(buffer_str, "%f", to[2]); cmd_args[12] = bu_strdup(buffer_str); + + sprintf(buffer_str, "%f", from[0]); cmd_args[13] = bu_strdup(buffer_str); + sprintf(buffer_str, "%f", from[1]); cmd_args[14] = bu_strdup(buffer_str); + sprintf(buffer_str, "%f", from[2]); cmd_args[15] = bu_strdup(buffer_str); + + cmd_args[16] = "0"; + cmd_args[17] = "1"; + cmd_args[18] = "2"; + + cmd_args[19] = (char *)0; + + print_command(cmd_args, 19); + + rv = ged_in(gedp, 19, (const char **)cmd_args); + if (rv != GED_OK) { + bu_log("line: ERROR Could not draw arrow line \"%s\" (%f,%f,%f)-(%f,%f,%f) \n", + prefixed_arrow_line, V3ARGS(from), V3ARGS(to)); + return GED_ERROR; + } + + add_to_comb(gedp, name, prefixed_arrow_line); + + VSUB2(v, to, from); + VUNITIZE(v); + VSCALE(v, v, 0.1); + bu_log("line: Unit vector (%f,%f,%f)\n", V3ARGS(v)); + + cmd_args[0] = "in"; + cmd_args[1] = prefixed_arrow_head; + cmd_args[2] = "trc"; + + sprintf(buffer_str, "%f", to[0]); cmd_args[3] = bu_strdup(buffer_str); + sprintf(buffer_str, "%f", to[1]); cmd_args[4] = bu_strdup(buffer_str); + sprintf(buffer_str, "%f", to[2]); cmd_args[5] = bu_strdup(buffer_str); + + sprintf(buffer_str, "%f", v[0]); cmd_args[6] = bu_strdup(buffer_str); + sprintf(buffer_str, "%f", v[1]); cmd_args[7] = bu_strdup(buffer_str); + sprintf(buffer_str, "%f", v[2]); cmd_args[8] = bu_strdup(buffer_str); + + + sprintf(buffer_str, "%f", ARROW_BASE_RADIUS); cmd_args[9] = bu_strdup(buffer_str); + sprintf(buffer_str, "%f", ARROW_TIP_RADIUS); cmd_args[10] = bu_strdup(buffer_str); + + cmd_args[11] = (char *)0; + + print_command(cmd_args, 11); + + rv = ged_in(gedp, 11, (const char **)cmd_args); + if (rv != GED_OK) { + bu_log("line: ERROR Could not draw arrow head \"%s\" (%f,%f,%f)-(%f,%f,%f) \n", + prefixed_arrow_head, V3ARGS(from), V3ARGS(to)); + return GED_ERROR; + } + + add_to_comb(gedp, name, prefixed_arrow_head); + + return GED_OK; +} + + +int arrow(struct ged *gedp, char* name, point_t from, point_t to) { char *cmd_args[20]; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ All the data continuously generated in your IT infrastructure contains a definitive record of customers, application performance, security threats, fraudulent activity and more. Splunk takes this data and makes sense of it. Business sense. IT sense. Common sense. http://p.sf.net/sfu/splunk-d2dcopy1 _______________________________________________ BRL-CAD Source Commits mailing list brlcad-commits@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/brlcad-commits