15#ifndef VIEW_ANALYSIS_G
16#define VIEW_ANALYSIS_G
20 namespace SpatialStructures {
24 class EmbreeRayTracer;
118 float upwards_fov = 50.0f,
119 float downward_fov = 70.0f
197 if (new_value > 0) out_total += 1;
200 out_total += new_value;
204 out_total = (n * (out_total)+new_value) / count;
208 out_total = std::max<float>(out_total, new_value);
212 out_total = std::min<float>(out_total, new_value);
216 throw std::out_of_range(
"Unimplemented aggregation type");
219 assert(out_total == 0 || isnormal(out_total));
334 template <
typename RES,
typename RT,
typename N>
337 const std::vector<N>& Nodes,
339 float upward_limit = 50.0f,
340 float downward_limit = 70.0f,
345 int required_vector_size = directions.size() * Nodes.size();
346 std::vector<RES> out_results;
350 if (out_results.max_size() < required_vector_size) {
351 std::cout <<
"The desired view analysis setting exceed the maximum vector size!" << std::endl;
352 throw std::bad_array_new_length();
354 out_results.resize(required_vector_size);
357 num_rays = directions.size();
362 #pragma omp for schedule(dynamic)
363 for (
int i = 0; i < Nodes.size(); i++)
366 float out_distance = 0;
369 auto node = Nodes[i];
371 int os = directions.size() * i;
374 for (
int k = 0; k < directions.size(); k++)
378 if (ray_tracer.IntersectOutputArguments(node, directions[k], out_distance, out_mid))
380 out_results[idx].SetHit(node, directions[k], out_distance, out_mid);
483 template<
typename RT,
typename N>
486 const std::vector<N>& Nodes,
488 float upward_limit = 50.0f,
489 float downward_limit = 70.0f,
494 std::vector<float> out_scores(Nodes.size());
500 #pragma omp for schedule(dynamic)
501 for (
int i = 0; i < Nodes.size(); i++)
503 const auto& node = Nodes[i];
506 float& score = out_scores[i];
511 score = std::numeric_limits<float>::max();
518 for (
const auto& direction : directions)
521 auto node_copy = node;
522 node_copy[2] += height;
527 if (ray_tracer.PointIntersection(
528 node_copy[0], node_copy[1], node_copy[2],
529 direction[0], direction[1], direction[2]))
532 float distance = sqrtf(
533 powf((node[0] - node_copy[0]), 2)
534 + powf((node[1] - node_copy[1]), 2)
535 + powf((node[2] + height - node_copy[2]), 2));
538 Aggregate(score, distance, aggregation, count);
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.
std::vector< RES > SphericalViewAnalysis(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)
Conduct view analysis with any Raytracer in parallel.
Perform human scale analysis on 3D environments.
HF::RayTracer::MultiRT RayTracer
Type of raytracer to be used internally.
Analyze space from the perspective of observers within a 3D environment.
AGGREGATE_TYPE
The type of aggregation to use for ViewAnalysisAggregate
@ AVERAGE
Average distance from the origin to every intersection.
@ MAX
Maximum distance from the origin to any intersection.
@ COUNT
Total number of intersections.
@ SUM
Sum of the distance from the origin to all intersections.
@ MIN
Minimum distance from the origin to any intersection.
void Aggregate(float &out_total, float new_value, const AGGREGATE_TYPE agg_type, int count=0)