DHART
Loading...
Searching...
No Matches
visibility_graph_C.cpp
Go to the documentation of this file.
2
3#include <vector>
4#include <visibility_graph.h>
5#include <embree_raytracer.h>
6#include <graph.h>
7#include <node.h>
8
9#include <HFExceptions.h>
10
11using namespace HF::RayTracer;
12using namespace HF::SpatialStructures;
13using namespace HF;
14using std::vector;
15
17 EmbreeRayTracer* ert,
18 const float* nodes,
19 int num_nodes,
20 Graph** out_graph,
21 float height
22) {
23 auto array_of_nodes = ConvertRawFloatArrayToPoints(nodes, num_nodes);
24
25 vector<Node> vector_of_nodes(num_nodes);
26 for (int i = 0; i < num_nodes; i++) {
27 const auto& arr = array_of_nodes[i];
28 auto& vec = vector_of_nodes[i];
29
30 vec[0] = arr[0]; vec[1] = arr[1]; vec[2] = arr[2];
31 }
32
33 Graph * vg = new Graph();
34 *vg = VisibilityGraph::AllToAll(*ert, vector_of_nodes, height );
35
36 *out_graph = vg;
38}
39
41 EmbreeRayTracer* ert,
42 const float* nodes,
43 int num_nodes,
44 Graph** out_graph,
45 float height,
46 const int cores
47) {
48 auto array_of_nodes = ConvertRawFloatArrayToPoints(nodes, num_nodes);
49
50 vector<Node> vector_of_nodes(num_nodes);
51 for (int i = 0; i < num_nodes; i++) {
52 const auto& arr = array_of_nodes[i];
53 auto& vec = vector_of_nodes[i];
54
55 vec[0] = arr[0]; vec[1] = arr[1]; vec[2] = arr[2];
56 }
57 Graph* vg = new Graph();
58 *vg = VisibilityGraph::AllToAllUndirected(*ert, vector_of_nodes, height, cores);
59
60 *out_graph = vg;
62}
63
66 const float* group_a,
67 const int size_a,
68 const float* group_b,
69 const int size_b,
70 Graph** out_graph,
71 float height
72) {
73 auto array_a = ConvertRawFloatArrayToPoints(group_a, size_a);
74 auto array_b = ConvertRawFloatArrayToPoints(group_b, size_b);
75
76 vector<Node> vector_a(size_a);
77 vector<Node> vector_b(size_b);
78 for (int i = 0; i < size_a; i++) {
79 const auto& arra = array_a[i];
80 auto& va = vector_a[i];
81 va[0] = arra[0]; va[1] = arra[1]; va[2] = arra[2];
82 }
83 for (int i = 0; i < size_b; i++) {
84 const auto& arrb = array_b[i];
85 auto& vb = vector_b[i];
86 vb[0] = arrb[0]; vb[1] = arrb[1]; vb[2] = arrb[2];
87 }
88 *out_graph = new Graph();
89
90 **out_graph = VisibilityGraph::GroupToGroup(*ert, vector_a, vector_b, height);
91
92 if ((*out_graph)->GetCSRPointers().AreValid()) {
94 }
95 else {
96 delete* out_graph;
98 }
99}
Contains definitions for the VisibilityGraph class.
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 functions related to creating a visibility graph.
C_INTERFACE CreateVisibilityGraphAllToAll(EmbreeRayTracer *ert, const float *nodes, int num_nodes, Graph **out_graph, float height)
Create a new directed visibility graph between all nodes in parameter nodes.
C_INTERFACE CreateVisibilityGraphAllToAllUndirected(EmbreeRayTracer *ert, const float *nodes, int num_nodes, Graph **out_graph, float height, const int cores)
Create a new undirected visibility graph between all nodes in nodes.
C_INTERFACE CreateVisibilityGraphGroupToGroup(HF::RayTracer::EmbreeRayTracer *ert, const float *group_a, const int size_a, const float *group_b, const int size_b, Graph **out_graph, float height)
Create a new visibility graph from the nodes in group_a, into the nodes of group_b.
Perform human scale analysis on 3D environments.
Cast rays to determine if and where they intersect geometry.
Contains standard fundamental data structures for representing space used throughout DHARTAPI.
Graph AllToAll(EmbreeRayTracer &ert, const vector< Node > &nodes, float height)
Generate a Visibility Graph between every node in a set of nodes in parallel.
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.
@ OK
Operation was successful.
Definition: HFExceptions.h:32
@ NO_GRAPH
This requires a valid graph in the DB to execute successfully.
Definition: HFExceptions.h:41
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