DHART
Loading...
Searching...
No Matches
view_analysis_C.cpp
Go to the documentation of this file.
1#include <view_analysis_C.h>
2#include <robin_hood.h>
3
4#include <HFExceptions.h>
5#include <view_analysis.h>
6#include <embree_raytracer.h>
7#include <graph.h>
8#include <node.h>
9
11using namespace HF::Exceptions;
13using std::vector;
15using namespace HF;
16
18 EmbreeRayTracer* ERT,
19 Node * node_ptr,
20 int node_size,
21 int max_rays,
22 float upward_fov,
23 float downward_fov,
24 float height,
26 vector<float>** out_scores,
27 float** out_scores_ptr,
28 int* out_scores_size)
29{
30 vector<float>* scores = new vector<float>();
31 vector<Node> nodes(node_ptr, node_ptr + node_size);
32
34 *ERT,
35 nodes,
36 max_rays,
37 upward_fov,
38 downward_fov,
39 height,
41 );
42
43 *out_scores = scores;
44 *out_scores_ptr = scores->data();
45 *out_scores_size = scores->size(); // Shouldn't this always be the same?
46
47 return OK;
48}
49
50C_INTERFACE SphereicalViewAnalysisAggregateFlat(HF::RayTracer::EmbreeRayTracer* ERT, const float* node_ptr, int node_size, int max_rays, float upward_fov, float downward_fov, float height, AGGREGATE_TYPE AT, std::vector<float>** out_scores, float** out_scores_ptr, int* out_scores_size)
51{
52 vector<float>* scores = new vector<float>();
53 vector<std::array<float, 3>> nodes = ConvertRawFloatArrayToPoints(node_ptr, node_size);
54
56 *ERT,
57 nodes,
58 max_rays,
59 upward_fov,
60 downward_fov,
61 height,
63 );
64
65 *out_scores = scores;
66 *out_scores_ptr = scores->data();
67 *out_scores_size = scores->size(); // Shouldn't this always be the same?
68
69 return OK;
70}
71
72
75 const HF::SpatialStructures::Node* node_ptr,
76 int node_size,
77 int * max_rays,
78 float upward_fov,
79 float downward_fov,
80 float height,
81 std::vector<RayResult> ** out_results,
82 RayResult ** out_results_ptr
83 //std::vector<float>** out_directions
84 )
85{
86
87 vector<RayResult> * scores = new vector<RayResult>();
88 vector<Node> nodes(node_ptr, node_ptr + node_size);
89
90 *scores = ViewAnalysis::SphericalViewAnalysis<RayResult>(
91 *ERT,
92 nodes,
93 *max_rays,
94 upward_fov,
95 downward_fov,
96 height
97 );
98
99 *out_results = scores;
100 *out_results_ptr = scores->data();
101 *max_rays = scores->size()/node_size;
102 //printf("Score size: %d\n", *max_rays);
103 return OK;
104}
105
106C_INTERFACE SphericalViewAnalysisNoAggregateFlat(HF::RayTracer::EmbreeRayTracer* ERT, const float* node_ptr, int node_size, int* max_rays, float upward_fov, float downward_fov, float height, std::vector<RayResult>** out_results, RayResult** out_results_ptr)
107{
108 vector<RayResult>* scores = new vector<RayResult>();
109 auto nodes = ConvertRawFloatArrayToPoints(node_ptr,node_size);
110
111 *scores = ViewAnalysis::SphericalViewAnalysis<RayResult>(
112 *ERT,
113 nodes,
114 *max_rays,
115 upward_fov,
116 downward_fov,
117 height
118 );
119
120 *out_results = scores;
121 *out_results_ptr = scores->data();
122 *max_rays = scores->size() / node_size;
123 return OK;
124}
125
127 int * num_rays,
128 vector<float>** out_direction_vector,
129 float** out_direction_data,
130 float upward_fov,
131 float downward_fov)
132{
133 *out_direction_vector = new vector<float>();
134 auto array_array = ViewAnalysis::FibbonacciDistributePoints(*num_rays, upward_fov, downward_fov);
135
136 auto& out_directions = **out_direction_vector;
137
138 out_directions.resize(array_array.size()*3);
139 for (int i = 0; i < array_array.size(); i += 1)
140 {
141 int os = i * 3;
142 int y_idx = os + 1;
143 int z_idx = os + 2;
144 const auto& arr = array_array[i];
145 out_directions[os] = arr[0];
146 out_directions[y_idx] = arr[1];
147 out_directions[z_idx] = arr[2];
148 }
149
150 *out_direction_data = out_directions.data();
151 *num_rays = array_array.size();
152 return OK;
153}
154
155
Contains definitions for the ViewAnalysis namespace.
Contains definitions for the Exceptions namespace.
Contains definitions for the EmbreeRayTracer
std::vector< std::array< float, 3 > > ConvertRawFloatArrayToPoints(const float *raw_array, int size)
Convert a raw array from an external caller to an organized vector of points
Definition: CInterface.cpp:24
Contains definitions for the Graph class.
Contains definitions for the Node structure.
#define C_INTERFACE
Definition: analysis_C.h:16
Header file for conducting view analysis via the C Interface.
AGGREGATE_TYPE
Determines how to aggregate edges from the results of view analysis.
C_INTERFACE SphericalViewAnalysisNoAggregateFlat(HF::RayTracer::EmbreeRayTracer *ERT, const float *node_ptr, int node_size, int *max_rays, float upward_fov, float downward_fov, float height, std::vector< RayResult > **out_results, RayResult **out_results_ptr)
Perform view analysis, and get the distance and meshid for each individual ray casted.
vector< std::array< float, 3 > > FibbonacciDistributePoints(int num_points, float upwards_fov, float downward_fov)
Evenly distribute a set of points around a sphere centered at the origin.
std::vector< float > SphericalRayshootWithAnyRTForDistance(RT &ray_tracer, const std::vector< N > &Nodes, int num_rays, float upward_limit=50.0f, float downward_limit=70.0f, float height=1.7f, const AGGREGATE_TYPE aggregation=AGGREGATE_TYPE::SUM)
Conduct view analysis and recieve a summarized set of results for each node.
C_INTERFACE SphericalViewAnalysisNoAggregate(HF::RayTracer::EmbreeRayTracer *ERT, const HF::SpatialStructures::Node *node_ptr, int node_size, int *max_rays, float upward_fov, float downward_fov, float height, std::vector< RayResult > **out_results, RayResult **out_results_ptr)
Perform view analysis, then get the distance and meshid for each individual ray casted.
C_INTERFACE SphereicalViewAnalysisAggregateFlat(HF::RayTracer::EmbreeRayTracer *ERT, const float *node_ptr, int node_size, int max_rays, float upward_fov, float downward_fov, float height, AGGREGATE_TYPE AT, std::vector< float > **out_scores, float **out_scores_ptr, int *out_scores_size)
Conduct view analysis, and aggregate the results.
C_INTERFACE SphereicalViewAnalysisAggregate(EmbreeRayTracer *ERT, Node *node_ptr, int node_size, int max_rays, float upward_fov, float downward_fov, float height, AGGREGATE_TYPE AT, vector< float > **out_scores, float **out_scores_ptr, int *out_scores_size)
Conduct view analysis, then aggregate the results.
C_INTERFACE SphericalDistribute(int *num_rays, vector< float > **out_direction_vector, float **out_direction_data, float upward_fov, float downward_fov)
Equally distribute points around a unit sphere.
Perform human scale analysis on 3D environments.
AGGREGATE_TYPE
The type of aggregation to use for ViewAnalysisAggregate
Definition: view_analysis.h:49
Custom exceptions and error codes used interally by DHARTAPI.
Definition: HFExceptions.h:22
@ OK
Operation was successful.
Definition: HFExceptions.h:32
A wrapper for Intel's Embree Library.
A Graph of nodes connected by edges that supports both integers and HF::SpatialStructures::Node.
Definition: graph.h:486
A point in space with an ID.
Definition: node.h:38
The result of casting a ray at an object. Contains distance to the hitpoint and the ID of the mesh.
Definition: raytracer_C.h:89