test.c (3160B)
1 #include "../inc/compute_paths.h" /* for compute_paths, ChannelInfo, RaysInfo */ 2 #include "../inc/scene.h" /* for Scene, scene_load */ 3 #include "../inc/vec3.h" /* for Vec3 */ 4 #include "../inc/ray.h" /* for Ray */ 5 #include "../viz/viz.h" /* for vizrays */ 6 7 #include <stdio.h> /* for fprintf */ 8 #include <stdlib.h> /* for malloc */ 9 10 int main(int argc, char **argv) 11 { 12 if (argc < 2) { 13 fprintf(stderr, "Usage: %s <path_to_mesh.ply>\n", argv[0]); 14 return 1; 15 } 16 17 uint32_t numRx = 1; 18 uint32_t numTx = 1; 19 uint32_t numPaths = 30000; 20 uint32_t numBounces = 3; 21 22 Vec3 rx_pos[1] = {{0.0, 0.0, .5}}; 23 Vec3 tx_pos[1] = {{0.0, 0.0, .5}}; 24 Vec3 rx_vel[1] = {{0.0, 0.0, 0.0}}; 25 Vec3 tx_vel[1] = {{0.0, 0.0, 0.0}}; 26 27 float carrier_frequency_ghz = 3.0; 28 29 ChannelInfo chanInfo_los = { 30 .num_rays = 1, 31 .directions_rx = (Vec3*)malloc(numRx * numTx * sizeof(Vec3)), 32 .directions_tx = (Vec3*)malloc(numRx * numTx * sizeof(Vec3)), 33 .a_te_re = (float*)malloc(numRx * numTx * sizeof(float)), 34 .a_te_im = (float*)malloc(numRx * numTx * sizeof(float)), 35 .a_tm_re = (float*)malloc(numRx * numTx * sizeof(float)), 36 .a_tm_im = (float*)malloc(numRx * numTx * sizeof(float)), 37 .tau = (float*)malloc(numRx * numTx * sizeof(float)), 38 .freq_shift = (float*)malloc(numRx * numTx * sizeof(float)), 39 }; 40 RaysInfo raysInfo_los = { 41 .rays = (Ray*)malloc(numRx * numTx * sizeof(Ray)), 42 .rays_active = (uint8_t*)malloc(numRx * numTx * sizeof(uint8_t) / 8 + 1) 43 }; 44 ChannelInfo chanInfo_scat = { 45 .num_rays = numBounces * numPaths, 46 .directions_rx = (Vec3*)malloc(numRx * numTx * numBounces * numPaths * sizeof(Vec3)), 47 .directions_tx = (Vec3*)malloc(numPaths * sizeof(Vec3)), 48 .a_te_re = (float*)malloc(numRx * numTx * numBounces * numPaths * sizeof(float)), 49 .a_te_im = (float*)malloc(numRx * numTx * numBounces * numPaths * sizeof(float)), 50 .a_tm_re = (float*)malloc(numRx * numTx * numBounces * numPaths * sizeof(float)), 51 .a_tm_im = (float*)malloc(numRx * numTx * numBounces * numPaths * sizeof(float)), 52 .tau = (float*)malloc(numRx * numTx * numBounces * numPaths * sizeof(float)), 53 .freq_shift = (float*)malloc(numRx * numTx * numBounces * numPaths * sizeof(float)), 54 }; 55 RaysInfo raysInfo_scat = { 56 .num_bounces = numBounces + 1, 57 .num_rays = numPaths, 58 .rays = (Ray*)malloc(numRx * numTx * (numBounces + 1) * numPaths * sizeof(Ray)), 59 .rays_active = (uint8_t*)malloc(numRx * numTx * (numBounces + 1) * (numPaths / 8 + 1) * sizeof(uint8_t)) 60 }; 61 62 Scene scene = scene_load(argv[1]); 63 64 compute_paths( 65 &scene, 66 rx_pos, tx_pos, 67 rx_vel, tx_vel, 68 carrier_frequency_ghz, 69 numRx, numTx, numPaths, numBounces, 70 &chanInfo_los, &raysInfo_los, 71 &chanInfo_scat, &raysInfo_scat 72 ); 73 74 vizrays(&raysInfo_scat, &scene, numTx); 75 76 /* Save the results */ 77 78 FILE *f; 79 #define WRITE_BIN(name, data, dt, size) \ 80 f = fopen(name, "wb"); \ 81 fwrite(data, sizeof(dt), size, f); \ 82 fclose(f); 83 84 /* Use this macro to write what you would like to inspect to a binary file */ 85 /* Example: */ 86 /* WRITE_BIN("los_directions_rx.bin", los.directions_rx, float, numRx * numTx * 3); */ 87 }