DHART
Loading...
Searching...
No Matches
CInterface.cpp
Go to the documentation of this file.
1
7
9#include <iostream>
10#include <Constants.h>
11
12#include <HFExceptions.h>
13#include <graph.h>
14#include <node.h>
15#include <edge.h>
16
17// TODO: Use a template for this
24std::vector<std::array<float, 3>> ConvertRawFloatArrayToPoints(const float* raw_array, int size) {
25 std::vector<std::array<float, 3>> out_array(size);
26 for (int i = 0; i < size; i++) {
27 const int os = i * 3;
28 out_array[i][0] = raw_array[os];
29 out_array[i][1] = raw_array[os + 1];
30 out_array[i][2] = raw_array[os + 2];
31 }
32 return out_array;
33}
34
35std::vector<std::array<int, 3>> ConvertRawIntArrayToPoints(const int* raw_array, int size) {
36 std::vector<std::array<int, 3>> out_array(size);
37 for (int i = 0; i < size; i++) {
38 const int os = i * 3;
39 out_array[i][0] = raw_array[os];
40 out_array[i][1] = raw_array[os + 1];
41 out_array[i][2] = raw_array[os + 2];
42 }
43 return out_array;
44}
45
46C_INTERFACE GetEdgesForNode(const Graph* graph, const Node* Node, vector<Edge>** out_vector_ptr, Edge** out_edge_list_ptr, int* out_edge_list_size) {
47 // This can't function if the node isn't a parent
48 if (!(graph->hasKey(*Node))) {
49 return HF_STATUS::OUT_OF_RANGE;
50 }
51
52 vector<Edge>* Edges = new vector<Edge>();
53 *Edges = (*graph)[*Node];
54 *out_edge_list_ptr = Edges->data();
55 *out_edge_list_size = Edges->size();
56 *out_vector_ptr = Edges;
57 return OK;
58}
59
60C_INTERFACE GetSizeOfNodeVector(const std::vector<HF::SpatialStructures::Node>* node_list, int* out_size) {
61 *out_size = node_list->size();
62 return OK;
63}
64
65C_INTERFACE GetSizeOfEdgeVector(const std::vector<HF::SpatialStructures::Edge>* edge_list, int* out_size) {
66 *out_size = edge_list->size();
67 return OK;
68}
69
70C_INTERFACE DestroyNodes(std::vector<HF::SpatialStructures::Node>* nodelist_to_destroy) {
71 if (nodelist_to_destroy) delete nodelist_to_destroy;
72 return OK;
73}
74
75C_INTERFACE DestroyEdges(std::vector<HF::SpatialStructures::Edge>* edgelist_to_destroy) {
76 if (edgelist_to_destroy) delete edgelist_to_destroy;
77 return OK;
78}
79
81 if (graph_to_destroy) delete graph_to_destroy;
82 return OK;
83}
Contains definitions for the Exceptions namespace.
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
C_INTERFACE GetEdgesForNode(const Graph *graph, const Node *Node, vector< Edge > **out_vector_ptr, Edge **out_edge_list_ptr, int *out_edge_list_size)
Definition: CInterface.cpp:46
std::vector< std::array< int, 3 > > ConvertRawIntArrayToPoints(const int *raw_array, int size)
Convert a raw array from an external caller to an organized vector of points
Definition: CInterface.cpp:35
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.
#define C_INTERFACE
Definition: analysis_C.h:16
Header file related to manipulating nodes, edges, and graphs via CInterface.
C_INTERFACE DestroyGraph(HF::SpatialStructures::Graph *graph_to_destroy)
Delete a graph.
Definition: CInterface.cpp:80
C_INTERFACE GetSizeOfEdgeVector(const std::vector< HF::SpatialStructures::Edge > *edge_list, int *out_size)
Get the size of an edge vector.
Definition: CInterface.cpp:65
C_INTERFACE DestroyNodes(std::vector< HF::SpatialStructures::Node > *nodelist_to_destroy)
Delete the vector of nodes at the given pointer.
Definition: CInterface.cpp:70
C_INTERFACE GetSizeOfNodeVector(const std::vector< HF::SpatialStructures::Node > *node_list, int *out_size)
Get the size of a node vector.
Definition: CInterface.cpp:60
C_INTERFACE DestroyEdges(std::vector< HF::SpatialStructures::Edge > *edgelist_to_destroy)
Delete the vector of edges at the given pointer.
Definition: CInterface.cpp:75
A Graph of nodes connected by edges that supports both integers and HF::SpatialStructures::Node.
Definition: graph.h:486