15#include <robin_hood.h>
48 const array<float, 3> up{ 0,0,1 };
54 return !ert.
Occluded(node_copy, up, height);
70 vector<int> valid_nodes;
73 for (
int i = 0; i < nodes_to_filter.size(); i++) {
77 const auto& node = nodes_to_filter[i];
79 valid_nodes.push_back(i);
108 float pre_calculated_distance = 0.0f
111 auto heightened_node = node_a;
112 heightened_node[2] += height;
116 if (pre_calculated_distance == 0.0f)
119 distance = pre_calculated_distance;
125 return ert.
Occluded(heightened_node, direction, distance);
131 const int n = nodes.
size();
132 vector<vector<int>> edges(n);
133 vector<vector<float>> costs(n);
138 cores = std::thread::hardware_concurrency();
139 omp_set_num_threads(cores);
142 omp_set_num_threads(cores);
148#pragma omp parallel for schedule(static)
149 for (
int i = 0; i < valid_nodes.size(); i++) {
152 int node_id = valid_nodes[i];
155 const Node& node_a = nodes[node_id];
159 vector<int>& edge_list = edges[node_id];
160 vector<float>& cost_list = costs[node_id];
163 for (
int k = 0; k < valid_nodes.size(); k++) {
166 if (i == k)
continue;
169 int node_b_id = valid_nodes[k];
172 const Node& node_b = nodes[node_b_id];
178 edge_list.push_back(node_b_id);
179 cost_list.push_back(distance);
185 return Graph(edges, costs, nodes);
191 const int from_count = from.
size();
192 const int to_count = to.size();
197 vector<vector<int>> edges(from_count + to_count);
198 vector<vector<float>> costs(from_count + to_count);
204 cores = std::thread::hardware_concurrency();
205 omp_set_num_threads(cores);
207 else if (cores > 0) omp_set_num_threads(cores);
214#pragma omp parallel for schedule(static)
215 for (
int i = 0; i < valid_nodes.size(); i++) {
218 int id = valid_nodes[i];
219 const Node& node_a = from[id];
220 vector<int>& edge_list = edges[id];
221 vector<float>& cost_list = costs[id];
224 for (
int k = 0; k < valid_to_nodes.size(); k++) {
227 int to_id = valid_to_nodes[k];
228 const Node& node_b = to[to_id];
237 edge_list.push_back(to_id + from_count);
238 cost_list.push_back(distance);
244 vector<Node> graph_nodes(from.size() + to.size());
245 std::copy(from.begin(), from.end(), graph_nodes.begin());
246 std::copy(to.begin(), to.end(), graph_nodes.begin() + from.size());
249 return Graph(edges, costs, graph_nodes);
253 const int n = nodes.
size();
254 vector<vector<int>> edges(n);
255 vector<vector<float>> costs(n);
259 cores = std::thread::hardware_concurrency();
260 omp_set_num_threads(cores);
263 omp_set_num_threads(cores);
271#pragma omp for schedule(dynamic)
272 for (
int i = 0; i < valid_nodes.size(); i++) {
275 int node_a_id = valid_nodes[i];
276 const Node& node_a = nodes[node_a_id];
277 vector<int>& edge_list = edges[node_a_id];
278 vector<float>& cost_list = costs[node_a_id];
283 for (
int k = i + 1; k < valid_nodes.size(); k++) {
286 int node_b_id = valid_nodes[k];
287 const Node& node_b = nodes[node_b_id];
292 edge_list.emplace_back(node_b_id);
293 cost_list.emplace_back(distance);
299 return Graph(edges, costs, nodes);
Contains definitions for the VisibilityGraph class.
Contains definitions for the EmbreeRayTracer
Contains definitions for the HF::SpatialStructures namespace.
Contains definitions for the Edge structure.
Contains definitions for the Graph class.
Contains definitions for the Node structure.
Perform human scale analysis on 3D environments.
Contains standard fundamental data structures for representing space used throughout DHARTAPI.
constexpr float ROUNDING_PRECISION
Minimum value that can be represented in DHART_API.
Evaluate visibility between points in a set of locations.
vector< int > HeightCheckAllNodes(const vector< Node > &nodes_to_filter, float height, EmbreeRayTracer &ert)
Obtain the indexes of all nodes that pass the HeightCheck.
Graph AllToAll(EmbreeRayTracer &ert, const vector< Node > &nodes, float height)
Generate a Visibility Graph between every node in a set of nodes in parallel.
bool IsOcclusionBetween(const Node &node_a, const Node &node_b, EmbreeRayTracer &ert, float height=1.7f, float pre_calculated_distance=0.0f)
Perform a line of sight check between two nodes.
Graph AllToAllUndirected(EmbreeRayTracer &ert, const vector< Node > &nodes, float height, int cores)
Generate a Visibility Graph with every edge stored twice.
Graph GroupToGroup(EmbreeRayTracer &ert, const vector< Node > &from, const vector< Node > &to, float height)
Generate a Visibility Graph from a set of nodes to another set of nodes.
bool HeightCheck(const Node &Node, float height, EmbreeRayTracer &ert)
Check if Node can be raised by height without clipping into any geometry.
A wrapper for Intel's Embree Library.
bool Occluded(const N &origin, const V &direction, float max_distance=-1.0f, int mesh_id=-1)
Determine if there is an intersection with any geometry.
A Graph of nodes connected by edges that supports both integers and HF::SpatialStructures::Node.
int size() const
Determine how many nodes are in the graph.
A point in space with an ID.
float distanceTo(const Node &n2) const
Calculate the distance between this node and n2.
std::array< float, 3 > directionTo(const Node &n2) const
Get the direction between this node and another node