rtserver.h

Go to the documentation of this file.
00001 /*                      R T S E R V E R . H
00002  * BRL-CAD
00003  *
00004  * Copyright (c) 2004-2006 United States Government as represented by
00005  * the U.S. Army Research Laboratory.
00006  *
00007  * This library is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU Lesser General Public License
00009  * as published by the Free Software Foundation; either version 2.1 of
00010  * the License, or (at your option) any later version.
00011  *
00012  * This library is distributed in the hope that it will be useful, but
00013  * WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015  * Library General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU Lesser General Public
00018  * License along with this file; see the file named COPYING for more
00019  * information.
00020  */
00021 /** @addtogroup rtserver */
00022 /*@{*/
00023 /** @file rtserver.h
00024  * @brief
00025  *      header file for the rtserver
00026  *
00027  *  @author: John R. Anderson
00028  *
00029  *  In order to use the rtserver, the BRL-CAD model must include an opaque binary object named "rtserver_data"
00030  *  This object must contain ASCII data consisting of lines of the form:
00031  *      assembly_name1 { object1 object2 object3 ...} key1 value1 key2 value2 ...
00032  *  Where assembly names are names of assemblies to be used for raytracing or articulation and
00033  *  the list of objects for each assembly specifies the BRL-CAD objects in that assembly. The
00034  *  assembly names do not need to be names of objects that already exist in the BRL-CAD model.
00035  *  At least one assembly named "rtserver_tops" must exist (this will be used for raytracing when
00036  *  no articulation is to be done. Each assembly must appear on its own line and must have at least
00037  *  one object in its list of objects.  If the assembly name has embedded spaces, it must be surrounded
00038  *  by "{" and "}". Each line is a series of key/value pairs with the first key being the assembly name.
00039  *  optional keys are:
00040  *      key_pt - value is the center of rotation for this assembly
00041  *      xrotate - values are the rotation limits (max min initial) about the x-axis (degrees). Default is no rotation allowed
00042  *      yrotate - values are the rotation limits (max min initial) about the y-axis (degrees). Default is no rotation allowed
00043  *      zrotate - values are the rotation limits (max min initial) about the z-axis (degrees). Default is no rotation allowed
00044  *      xtranslate - values are the limits (max min) of translation along the x-axis (mm). Default is no translation allowed.
00045  *      ytranslate - values are the limits (max min) of translation along the y-axis (mm). Default is no translation allowed.
00046  *      ztranslate - values are the limits (max min) of translation along the z-axis (mm). Default is no translation allowed.
00047  *      children - values are other assemblies that are rigidly attached to this assembly (The children will move
00048  *              with their parent).
00049  *
00050  *  An empty value for the translation keys implies unlimited translation is allowed.
00051  *
00052  */
00053 
00054 
00055 struct rtserver_job {
00056         struct bu_list l;               /* for linking */
00057         int exit_flag;                  /* flag, non-zero means the running thread should exit */
00058         int sessionid;                  /* index into sessions (rts_geometry array) */
00059         int rtjob_id;                   /* identifying number, assigned by the rt server */
00060         int maxHits;                    /* Max number of hits to consider along each ray (zero means take all of them) */
00061         struct bu_ptbl rtjob_rays;      /* list of pointers to rays to be fired */
00062 };
00063 
00064 struct ray_hit {
00065         struct bu_list l;
00066         struct region *regp;            /* pointer to containing region */
00067         int comp_id;                    /* index into component list */
00068         fastf_t hit_dist;               /* distance along ray to hit point */
00069         fastf_t los;                    /* line of sight distance through this component */
00070         vect_t enter_normal;            /* normal vector at entrance hit */
00071         vect_t exit_normal;             /* normal vector at exit hit */
00072 };
00073 
00074 struct ray_result {
00075         struct bu_list l;
00076         struct xray the_ray;            /* the originating ray */
00077         struct ray_hit hitHead;         /* the list of components hit along this ray */
00078 };
00079 
00080 struct rtserver_result {
00081         struct bu_list l;               /* for linked list */
00082         int got_some_hits;              /* flag 0-> no hits in results */
00083         struct rtserver_job *the_job;   /* the originating job */
00084         struct ray_result resultHead;   /* the list of results, one for each ray */
00085 };
00086 
00087 struct rtserver_rti {
00088         struct rt_i *rtrti_rtip;        /* pointer to an rti structure */
00089         char *rtrti_name;               /* name of this "assembly" (bu_malloc'd storage) */
00090         int rtrti_num_trees;            /* number of trees in this rti structure */
00091         char **rtrti_trees;             /* array of pointers to tree-top names trees[num_trees] (bu_malloc'd storage) */
00092         matp_t rtrti_xform;             /* transformation matrix from global coords to this rt instance (NULL -> identity) */
00093         matp_t rtrti_inv_xform;         /* inverse of above xform (NULL -> identity) */
00094 };
00095 
00096 struct rtserver_geometry {
00097         int rts_number_of_rtis;         /* number of rtserver_rti structures */
00098         struct rtserver_rti **rts_rtis; /* array of pointers to rtserver_rti
00099                                            structures rts_rtis[rts_number_of_rtis] (bu_malloc'd storage ) */
00100         point_t         rts_mdl_min;    /* min corner of model bounding RPP */
00101         point_t         rts_mdl_max;    /* max corner of model bounding RPP */
00102         double          rts_radius;     /* radius of model bounding sphere */
00103         Tcl_HashTable   *rts_comp_names;        /* A Tcl hash table containing ident numbers as keys
00104                                                    and component names as values */
00105 };
00106 
00107 extern void get_model_extents( int sessionid, point_t min, point_t max );
00108 
00109 extern struct rtserver_result *rts_submit_job_and_wait( struct rtserver_job *ajob );
00110 
00111 extern struct rtserver_result *rts_get_any_waiting_result( int sessionid );
00112 
00113 extern struct rtserver_job *rts_get_rtserver_job();
00114 
00115 extern struct xray *rts_get_xray();
00116 
00117 extern int get_max_working_threads();
00118 /*@}*/
00119 /*
00120  * Local Variables:
00121  * mode: C
00122  * tab-width: 8
00123  * c-basic-offset: 4
00124  * indent-tabs-mode: t
00125  * End:
00126  * ex: shiftwidth=4 tabstop=8
00127  */
00128 

Generated on Mon Sep 18 01:24:42 2006 for BRL-CAD by  doxygen 1.4.6