VR-Vantage 2.8 API Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Objects.h
Go to the documentation of this file.
1 /* © 1998 JRM Technologies, Inc.*/
2 
3 
4 
5 /***********************************
6 Copyright JRM Enterprises, Inc. 1998
7 All rights reserved.
8 
9 This code is the intellectual property of JRM Enterprises, Inc.
10 It may not be used or released as source or compiled binary form
11 without the prior written consent of JRM Enterprises, Inc.
12 ***********************************/
13 
14 
15 #ifndef OBJECTS_H_
16 #define OBJECTS_H_
17 
18 #include "sigsimDLLstub.h"
19 #include "CTDR-CPDR.h"
20 #include "Sonar.h"
21 
22 
23 #ifdef __cplusplus
24 extern "C"
25 {
26 #endif
27 
28 
29 
30  /* ------------ DEFINITIONS, ENUMERANTS, and DATA STRUCTURES ------------------ */
31 
32 
33  //--------------Grabbed UPLIM #define and - Stuck in SigSimDefines-----------------//
34  //--------------Grabbed HITTOL #define and - Stuck in objects.c file-----------------//
35 
36  typedef enum
37  {
44  } OBJECT_TYPE;
45 
46  typedef struct
47  {
49  double thrust; // [kg/hr] engine thrust
50  } OBJECT_STATE; // stub
51 
52  typedef struct
53  {
54  VECTOR Rview; // unit vector tangent to refracted path (at sensor location) to ID [unitless cosines, in sensor-local (North, East, Down) system]
55  VECTOR Rtarget; // Orientation of path away from target in target local NED system. [unitless cosines]
56  double Range; // Path length [m]
57  double Rdot; // rate of change of Refracted LOS path length [m/s].
58  } Rpath;
59 
60 
61  typedef struct
62  {
63  char imagefile[SIGSIM_STRING_SIZE];
64  double Rmax,Rmin;
66 
67  typedef struct
68  {
69  char object_id[SIGSIM_STRING_SIZE];
70  char object_subdirectory[SIGSIM_STRING_SIZE];
73 
74  int ntracks; // Number of TRACKS in track array
75  TRACK *track; // Expected trajectory
76  GEODETIC_LOCATION geod_loc; // Position of origin of local FRD system
77  GEOCENTRIC_LOCATION geoc_loc; // Position of origin of local FRD system
78  EULERzyx FRD_orientation; // Relates object body FRD to instantaneous local NED.
79  VECTOR ned_linear_velocity; // [m/s] Current linear velocity
80  VECTOR ned_linear_acceleration; // [m/s2] Curent linear acceleration
81  VECTOR ned_angular_velocity; // [rad/s] Current angular velocity. Magnitude gives speed clockwise about direction
82  VECTOR ned_angular_acceleration; // [rad/s2] Current angular acceleration. Magnitude gives accel clockwise about direction
83 
84  long num_polys; // [unitless]
86  double length, width, height; // [m] calculated, if polys exist.
87 
88  char *openflight; // OpenFlight Geometry file
89 
90  long nmatls; // number of materials in the mp_table array
91  MATL_PROP_TABLE *mp_table; // array of material property data (BRDF and areal RCS)
92 
93  SPIRITS_TABLE *spirits_table; // SPIRITS surface temp
94  PLUME_FLOWFIELD *spf_table; // SPF plume flowfield
95  PLUME_RADIANCE_MAP *spurc_table; // SPURC plume radiance projection LUT
96  MUSES_TABLE *muses_table; // Muses surface temp
97  SCATTER_TABLE *scat_table; // scatter center table for all the sensor center frequencies to be played
98  SCATTER_VECTOR_TABLE *scat_vector_table;// scatter center table for all the sensor center frequencies to be played
99  RCS_TABLE *rcs_table; // holder for polarized RCS 2D LUT
100  USCSET *uscset; // JRM Universal Scatter Center set
101  SMOKE_PROJECTION_MAP *combic_table; // holds smoke cloud projection for given FOV
102  PARTICLEINPUT *pinput; // Particle System Input
103  PARTICLESYSTEM *psystem; // Particle System Parameters (derived from pinput)
104 
105  TARGET *target; // Target Properties
107  RF_JAMMER *rfjammer; // RF Jammer
108  RF_DECOY *rfdecoy; // RF Chaff/decoy
109 
110  OLD_RCS_TABLE *old_rcs_table; // Let's do something about this soon, huh?
111  double rcs_sigma; // [unitless] Unused as of 020715. Let's get rid of this too.
112 
113  // Note: the following is used only if UseRadImage=TRUE :
114  jrmbool UseRadImage; // TRUE=Uses radiance image BMP files (for ComputeAcquireParams only as of 12/12/02)
115  char rcs_file[SIGSIM_STRING_SIZE]; // Radar Cross section file
116  char front_rad_file[SIGSIM_STRING_SIZE]; // Front radiance image file
117  char back_rad_file[SIGSIM_STRING_SIZE]; // Back radiance image file
118  char left_rad_file[SIGSIM_STRING_SIZE]; // Left radiance image file
119  char right_rad_file[SIGSIM_STRING_SIZE]; // Right radiance image file
120  char up_rad_file[SIGSIM_STRING_SIZE]; // Up radiance image file
121  char down_rad_file[SIGSIM_STRING_SIZE]; // Down radiance image file
122  double radf, radb, radl, radr, radu, radd; // [W/cm2] image ave emittances
123  double rmaxf, rmaxb, rmaxl, rmaxr, rmaxu, rmaxd;// [W/cm2] image max emittances
124  double rminf, rminb, rminl, rminr, rminu, rmind;// [W/cm2] image min emittances
125  double axf,bxf,axb,bxb,axl,bxl,axr,bxr,axu,bxu,axd,bxd; // [um] image wavebands
126 
127  } OBJECT;
128 
129  typedef struct
130  {
131  long polyID; // ID of polygon hit
132  VECTOR norm_g; // Normal in global space
133  jrmbool inout; // TRUE = ray enters face, FALSE = ray exits face
134  VECTOR v1,v2,v3;// Vertices in global space
135  VECTOR hit_g; // Position of hitpoint in global space
136  VECTOR hit_b; // Position of hitpoint in body space
137  VECTOR hit_v; // Distances from vertices {v1, v2, v3}
138  double dist; // Distance along global +x from global origin.
139  } OBJHIT; // Object hitpoint
140 
141 
142  /* ------------------- BASIC VERTEX FUNCTIONS ---------------------- */
143  SIGSIM49_API VERTEX Makevertex(double x, double y, double z);
146 
147  /* ---------- BASIC MULTI-VERTEX / POLYGON FUNCTIONS -------------------- */
148  SIGSIM49_API double area(VERTEX P1, VERTEX P2, VERTEX P3);
149  SIGSIM49_API double determ(VERTEX P1, VERTEX P2);
150  SIGSIM49_API VECTOR coss(VERTEX P1, VERTEX P2, VERTEX P3); /* Auxiliary function calculating normal vector to plane passing through three points */
151  SIGSIM49_API double polyarea(MS_POLYGON *polyin);
152 
153  /* ------------------ ALLOCATION / DEALLOCATION / COMBINATION ----------------------- */
156 
157  // AllocateObjects allocates (but does not fill) an array of OBJECTs of length nobjects.
158  // Inputs : nobjects = number of OBJECTs to be allocated.
159  // Outputs: Object = Pointer to array of OBJECTs to be allocated.
160  // UseRadImage will be set to FALSE by default.
161  // ms_poly_array and rcs_table will be NULL by default.
162  // Returns: SIGSIM_MEMORY_ALLOCATION_ERROR if Object array already allocated or otherwise cannot be allocated.
163  // SIGSIM_SUCCESS on successful completion.
164  SIGSIM49_API int AllocateObjects(int nobjects, OBJECT **Object); // Allocates general array of objects
165 
166  // AllocateObjectArray allocates (but does not fill) an array of OBJECTs of length num_objects, and also allocates the ms_poly_array for each.
167  // Inputs : num_objects = number of OBJECTs to be allocated.
168  // polys_per_object = array of integers, each specifying the number of polygons in the corresponding OBJECT's ms_poly_array.
169  // Outputs: object = Pointer to array of OBJECTs to be allocated.
170  // UseRadImage will be set to FALSE by default.
171  // rcs_table will be NULL by default.
172  // Returns: SIGSIM_MEMORY_ALLOCATION_ERROR if Object array or ms_poly_array already allocated or otherwise cannot be allocated.
173  // SIGSIM_SUCCESS on successful completion.
174  SIGSIM49_API int AllocateObjectArray(int num_objects, int *polys_per_object, OBJECT **object);
175 
176  // Free_Objects frees the memory allocated to an array of OBJECTs.
177  // Inputs : object = pointer to array of OBJECTs
178  // nobjects = size of object array
179  // Returns: SIGSIM_FUNCTION_FAILURE if object array is already NULL,
180  // SIGSIM_SUCCESS upon successful completion.
181  SIGSIM49_API int Free_Objects(OBJECT **object, int nobjects);
182 
183  // Free_Object_Arrays frees the memory allocated to the arrays within an array of OBJECTs,
184  // but not that associated with the object array itself.
185  // Inputs : object = array of OBJECTs
186  // nobjects = size of object array
187  // Returns: SIGSIM_FUNCTION_FAILURE if object array is already NULL,
188  // SIGSIM_SUCCESS upon successful completion.
189  SIGSIM49_API int Free_Object_Arrays(OBJECT *object, int nobjects);
190 
191 
192  // AddToObject() modifies composite OBJECT to add new OBJECTs according to placement/orientation in corresponding TRACK array.
193  // Inputs : composite = pointer to pre-allocated OBJECT to be added to.
194  // nobjects = number of OBJECTs in object array to be added. Should also equal number of TRACKs in track array.
195  // object = array of OBJECTs to be added to composite OBJECT.
196  // track = array of TRACKs on a one-to-one correspondence with the object array. Each TRACK gives the position and orientation of the corresponding OBJECT to be added, as measured in the composite OBJECT's body FRD system.
197  // Returns: The number of polygons in the final composite OBJECT's ms_poly_array, after all OBJECTs have been added. int i;
198  SIGSIM49_API long AddToObject(OBJECT *composite, int nobjects, OBJECT *object, TRACK *track);
199 
200  /* ----------------- COORDINATE TRANSFORMATIONS ----------------------------- */
201  SIGSIM49_API int MSPolygonRFU2FRD(MS_POLYGON *polyin, int npolys);
203  // Translates object's polygons to sensor NED system.
204  // "obj" contains the polygons to be translated.
205  // "proj" is the output array of translated NED polygons
206  // "nmb_tr" is the number of polygons in the output "proj" array.
208  // Inputs single polygon, and vector toward sensor FRONT direction,
209  // and outputs that polygon as seen in new coordinate system defined by :
210  // new xhat = sensor RIGHT (+y)
211  // new yhat = sensor UP (-z)
212  // new zhat = 0.0 [in sensor FRONT direction (+x)]
213 
214  /* ----------------------- PROJECTIONS AND INTERSECTIONS ----------------------- */
215  SIGSIM49_API void GetObjectBoundingBox(OBJECT *obj, VECTOR FRDright, VECTOR FRDdown, double *up, double *down, double *left, double *right);
216  SIGSIM49_API int PolyNirt(OBJECT *object, TRACK track, OBJHIT **hit);
217  // PolyNirt inputs an object placed at a certain track.position within a global space at arbitrary track.orientation.
218  // A ray is then fired along the x-axis of the global space, and intersects the object at certain points.
219  // PolyNirt allocates and returns an array of nhit "OBJHIT" structures containing the intersection data.
220  // NOTE : Assumes track.position is in same units as poly vertices !!!
221  SIGSIM49_API int Free_OBJHITs(OBJHIT *hits);
222  SIGSIM49_API int GetTargetNEDBoundingBox(OBJECT *obj, VECTOR Rtarget, int *nvecs, VECTOR *corner);
223  SIGSIM49_API int GetBackgroundHits(ellipsoid E, OBJECT obj, VECTOR Rtarget, double delta, int ngeoC, VECTOR *TNED, GEOCENTRIC_LOCATION *geoC);
226  SIGSIM49_API int TargetTransverseDimensions(VECTOR right, VECTOR down, int nvecs, VECTOR *corner, double *horizontal, double *vertical);
227  SIGSIM49_API void ObjectDimensions(OBJECT *objectin);
228 
229  /* -------------------- RADIANCE CALCULATION -------------------------- */
230  SIGSIM49_API double computerad(OBJECT *objectin, SENSOR *sens, VECTOR direction);
231 
232  // SetMinMaxObjectRadiances() can be used to set the OBJECT structure minimum and maximum radiances and passbands for use with the UseRadImage switch,
233  // but note that all passbands will be the SAME, all maximum radiances will be the SAME, and all minimum radiances will be the SAME, for all faces of the object cube.
234  // For specification of different parameters for each face, the user is expected to either use GetScenario, or use a call to rademit_approx as follows:
235  // Given a passband ax and bx [in microns], and a face temperature T [in degK], the associated radiance is given by:
236  // double itd;
237  // rad = rademit_approx(ax, bx, T, 10, &itd);
238  // This should be done for Tmin and Tmax, for each face.
239  //
240  // Inputs: object = pointer to OBJECT whose passband and radiances are to be calculated.
241  // bmpax = wavelength [um] of start of passband associated with the image.
242  // bmpbx = wavelength [um] of end of passband associated with the image.
243  // bmptlo = temperature [degC] of start of image dynamic range.
244  // bmpthi = temperature [degC] of end of image dynamic range.
245  // Outputs: Passband starting wavelengths object->{axf,axb,axl,axr,axu,axd}.
246  // Passband ending wavelengths object->{bxf,bxb,bxl,bxr,bxu,bxd}.
247  // Minimum radiances object->{rminf, rminb, rminl, rminr, rminu, rmind}.
248  // Maximum radiances object->{rmaxf, rmaxb, rmaxl, rmaxr, rmaxu, rmaxd}.
249  // Returns: SIGSIM_SUCCESS upon successful completion.
250  SIGSIM49_API int SetMinMaxObjectRadiances(OBJECT *object, double bmpax, double bmpbx, double bmptlo, double bmpthi);
251 
252  // FillObjectRCSandRadianceFromImages() fills OBJECT RCS table and radiance images.
253  // If object->UseRadImage=TRUE, then object->rcs_file will be read into
254  // object->old_rcs_table, and object->xxx_rad_file(s) will be read and converted
255  // to radiances stored in object->radx. Here 'xxx' and 'x' denote a particular face {u,d,r,l,f,b}.
256  // Inputs : sigsim_data_dir = string containing the name of the main data directory (this routine will look for the object/rcs subdirectory).
257  // object = pointer to OBJECT whose RCS and radiance tables are to be filled.
258  // Uses: object->rcs_file
259  // object->{front,back,left,right,up,down}_rad_file.
260  // object->{rmaxf,rmaxb,rmaxl,rmaxr,rmaxu,rmaxd}
261  // object->{rminf,rminb,rminl,rminr,rminu,rmind}
262  // Outputs: object->old_rcs_table
263  // object->{radf,radb,radl,radr,radu,radd}
264  // Returns: SIGSIM_FILE_NOT_FOUND if sigsim_data_dir/object/rcs/object->rcs_file is not found or can't be read.
265  // SIGSIM_FILE_NOT_FOUND*(-1) if sigsim_data_dir/object/bmp/object->{front,back,left,right,up,down}_rad_file is not found or can't be read.
266  // SIGSIM_SUCCESS upon successful completion.
267  SIGSIM49_API int FillObjectRCSandRadianceFromImages(char *sigsim_data_dir, OBJECT *object);
268 
269  SIGSIM49_API double ObjectRadianceFromImage(OBJECT *object, SENSOR *sens, VECTOR NED);
270 
271  SIGSIM49_API int UpdateObjectParticleEffects(char *sigsim_atm_dir, OBJECT *object, METIN *metin);
272 
273  SIGSIM49_API int PrintParticleSystem(OBJECT *object, SPECTRAL_DOMAIN *spectrum);
274 
275 
276  /* -------------------------- OBJECT CREATION --------------------------- */
277  SIGSIM49_API int CreateCone(int nmb_faces, double length, double angle, VERTEX base_center, VECTOR dir, OBJECT* cone);
278  // "nmb_faces" specifies the number of MS_POLYGONs to use in construction of the cone.
279  // "length" is in meters
280  // "angle" is in radians and is half of the angle at the cone apex
281  // "base_center" is in meters, and refers to the location of the center of the cone base relative to the object local origin in object-local FRD.
282  // "dir" is a vector specifying the direction from base center to the apex vertex in object-local FRD.
283  SIGSIM49_API int CreateCyl(int nmb_faces, double length, double radius, VERTEX center, VECTOR dir, OBJECT* cyl);
284  // "nmb_faces" specifies the number of MS_POLYGONs to use in construction of the cylinder.
285  // "length" is in meters
286  // "radius" is in meters
287  // "center" is in meters, and refers to the location of the center of the cylinder relative to the object local origin in object-local FRD.
288  // "dir" is a vector specifying the direction of the cylinder axis in object-local FRD, and has bi-directional ambiguity.
289  SIGSIM49_API int BoxTestObject(OBJECT *object, double length, double width, double height, double patch);
290  SIGSIM49_API double CreatePlane(double length_x, double width_y, VECTOR default_normal, long default_ms_index, double degK, MS_POLYGON *poly1, MS_POLYGON *poly2);
291 
292  /* --------------- IMPORT / EXPORT -------------------------- */
293  SIGSIM49_API int Geo2MSPolygon(char *sigsim_data_dir, char *objgeo_file, MS_POLYGON **returnpoly, long *npolys);
294  SIGSIM49_API int AppendGeo2MSPolygon(char *sigsim_data_dir, char *objgeo_file, MS_POLYGON **returnpoly, long *npolys);
295  SIGSIM49_API int MSPolygon2Geo(char *sigsim_data_dir, char *objgeo_file, MS_POLYGON **returnpoly, long *npolys);
296 
297  /* --------------- PHOTOGRAMMETRY --------------------------- */
298 
299  typedef struct
300  {
301  VECTOR V; // vertex
302  int p1,p2; // self-plane identifiers
303  int pi; // other-plane identifier
304  int f; // self-frustrum identifier
305  } INTERSECT;
306 
307  typedef struct
308  {
309  VECTOR V; // observer position
310  VECTOR ul; // upper-left unit direction
311  VECTOR ur; // upper-right unit direction
312  VECTOR lr; // lower-right unit direction
313  VECTOR ll; // lower-left unit direction
314  } FRUSTUM; // frustum definition. Plane IDs : 0=upper, 1=right, 2=lower, 3=left
315 
316  typedef struct
317  {
320  int p1,p2; // plane identifiers of form 4*f+p (so that 0-3 are from A and 4-7 are from B in GetFrustumIntersects)
321  int t; // triangle index
322  } EDGE;
323 
324  typedef struct
325  {
326  int lh, lv; // left-image pixel location
327  int rh, rv; // right-image pixel location
329 
331  SIGSIM49_API VECTOR RotateVectorToPixelCorner(FOV fov, int hpixel, int vpixel, jrmbool up, jrmbool left);
332  SIGSIM49_API void FillPixelFrustumDirections(FOV fov, int hpixel, int vpixel, FRUSTUM *F);
334  SIGSIM49_API int AddIntersect(int *NI, INTERSECT **I, INTERSECT toadd);
335  SIGSIM49_API void RidIntersect(INTERSECT **I, int *NI, int which);
337  SIGSIM49_API void RidDuplicateIntersects(INTERSECT **I, int *NI);
340  SIGSIM49_API int AddEdge(int *NE, EDGE **E, INTERSECT *a, INTERSECT *b, int p1, int p2);
341  SIGSIM49_API void RidEdge(EDGE **E, int *NE, int which);
343  SIGSIM49_API void RidDuplicateEdges(EDGE **E, int *NE);
345  SIGSIM49_API int CreateVolumeEdges(INTERSECT *I, int NI, EDGE **E);
346  SIGSIM49_API int CreateFinalFacetization(EDGE **E, int *NE);
347  SIGSIM49_API int AddMSPolygon(int *NP, MS_POLYGON **P, INTERSECT *I1, INTERSECT *I2, INTERSECT *I3);
348  SIGSIM49_API int CreateMSPolygonsFromEdges(EDGE *E, int NE, MS_POLYGON **P, int *NP);
350  SIGSIM49_API void RidPoly(MS_POLYGON **P, int *NP, int which);
353  SIGSIM49_API void RidDuplicatePolys(MS_POLYGON **P, int *NP);
354  SIGSIM49_API void CenterMSPolyArray(MS_POLYGON *P, int NP);
356  SIGSIM49_API void GetNecessaryFOVExtentsToViewIntersects(INTERSECT *I, int NI, VECTOR viewposition, EULERzyx orientation, double *vfov, double *hfov);
358  SIGSIM49_API double CreatePhotogrammetricMSPolyArray(FOV left, FOV right, ellipsoid e, PIXEL_CORRELATION *C, int NC, MS_POLYGON **ALLP, int *NALLP, FOV *center);
360  SIGSIM49_API int AddPixelCorrelation(int *NC, PIXEL_CORRELATION **C, int lh, int lv, int rh, int rv);
361  SIGSIM49_API double PixelCorrelation(RGB A, RGB B);
362  SIGSIM49_API double SubImagePairCorrelation(RGB *left, RGB *right, iVEC_HV lul, iVEC_HV rul, int hsubsize, int vsubsize, iVEC_HV leftfullsize, iVEC_HV rightfullsize);
363  SIGSIM49_API int GetImagePairPixelCorrelation(RGB *left, iVEC_HV leftsize, RGB *right, iVEC_HV rightsize, int windowsize, double corthresh, PIXEL_CORRELATION **C, int *NC);
365  SIGSIM49_API int WriteCorrelationFPFImage(char *filepath, RGB *left, int hsize, int vsize, PIXEL_CORRELATION *C, int NC);
366  SIGSIM49_API int WriteImagePairCorrelationsToFile(char *filepath, PIXEL_CORRELATION *C, int NC);
367  SIGSIM49_API int ReadImagePairCorrelationsFromFile(char *filepath, PIXEL_CORRELATION **C, int *NC);
368  SIGSIM49_API int ReadBMPIntoRGBArray(char *filepath, RGB **image, iVEC_HV *size, unsigned short *bit_depth);
369  SIGSIM49_API int WriteBMPFromRGBArray(char *filepath, RGB *image, iVEC_HV size, unsigned short bit_depth);
370  SIGSIM49_API int ConvertDoubleArrayToRGB(double *d, RGB **rgb, int size);
371  SIGSIM49_API int ConvertRGBArrayToDouble(double **d, RGB *rgb, int size);
372  SIGSIM49_API void FreeRGBArray(RGB **rgb);
373 
374  /* --------------- RENDERING --------------------------- */
375 
376  SIGSIM49_API int RenderObjectToFile(char *basename, OBJECT *object, METIN *metin, SENSOR *sens, unsigned short bit_depth);
377 
378 
379 
380 #ifdef __cplusplus
381 }
382 #endif
383 
384 #endif //OBJECTS_H_
385 
386 


Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)