DHART
Loading...
Searching...
No Matches
cinterface_utils.h File Reference
#include <vector>
#include <array>
+ Include dependency graph for cinterface_utils.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

namespace  HF
 Perform human scale analysis on 3D environments.
 

Macros

#define C_INTERFACE   extern "C" __declspec(dllexport) int
 

Functions

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 More...
 
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 More...
 
C_INTERFACE DestroyFloatVector (std::vector< float > *float_vector)
 Delete a float vector that's pointed to by float_vector More...
 
C_INTERFACE DestroyIntVector (std::vector< int > *int_vector)
 Delete a vector of integers. More...
 
C_INTERFACE DestroyCharArray (char *char_array)
 
template<typename T >
void DeleteRawPtr (T *ptr)
 Delete some object pointed to by ptr More...
 

Macro Definition Documentation

◆ C_INTERFACE

#define C_INTERFACE   extern "C" __declspec(dllexport) int

Definition at line 18 of file cinterface_utils.h.

Function Documentation

◆ ConvertRawFloatArrayToPoints()

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

Parameters
raw_arrayPointer to the external array
sizeThe number of points stored in the raw array, equal to the total number of floats / 3
Returns
A list of points
// Requires #include "cinterface_utils.h"
float vertices[] = { 34.1, 63.9, 16.5, 23.5, 85.7, 45.2, 12.0, 24.6, 99.4 };
const int size = 9;
std::vector<std::array<float, 3>> points = ConvertRawFloatArrayToPoints(vertices, size);
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
Parameters
raw_arrayPointer to the external array
sizeThe number of points stored in the raw array, equal to the total number of floats / 3
Returns

Definition at line 24 of file CInterface.cpp.

Referenced by CastMultipleDirectionsOneOrigin(), CastMultipleOriginsOneDirection(), CastMultipleRays(), CastOcclusionRays(), CastRaysDistance(), CreateVisibilityGraphAllToAll(), CreateVisibilityGraphAllToAllUndirected(), CreateVisibilityGraphGroupToGroup(), SphereicalViewAnalysisAggregateFlat(), and SphericalViewAnalysisNoAggregateFlat().

+ Here is the caller graph for this function:

◆ ConvertRawIntArrayToPoints()

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

Parameters
raw_arrayPointer to the external array
sizeThe number of points stored in the raw array, equal to the total number of ints / 3
Returns
A list of points
// Requires #include "cinterface_utils.h"
int raw_array = { 0, 1, 2, 3, 4, 5, 6, 7, 8 };
const int size = 9;
std::vector<std::array<int, 3>> points = ConvertRawIntArrayToPoints(raw_array, size);
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

Definition at line 35 of file CInterface.cpp.

◆ DeleteRawPtr()

template<typename T >
void DeleteRawPtr ( T *  ptr)
inline

Delete some object pointed to by ptr

Template Parameters
Tdatatype of ptr
// Requires #include "cinterface_utils.h"
std::vector<int>* vec = new std::vector<int>{ 6, 3, 1, 0, 5, 0 };
DeleteRawPtr<std::vector<int>>(vec);
// At this point here, we assume DeleteRawPtr was successful.
// We set vec to nullptr to eliminate a dangling pointer.
if (vec) {
vec = nullptr;
}

Definition at line 112 of file cinterface_utils.h.

Referenced by DestroyFloatVector(), DestroyIntVector(), DestroyMeshInfo(), DestroyPath(), and DestroyRayResultVector().

+ Here is the caller graph for this function:

◆ DestroyCharArray()

C_INTERFACE DestroyCharArray ( char *  char_array)

Definition at line 39 of file cinterface_utils.cpp.

References HF::Exceptions::OK.

◆ DestroyFloatVector()

C_INTERFACE DestroyFloatVector ( std::vector< float > *  float_vector)

Delete a float vector that's pointed to by float_vector

// Requires #include "cinterface_utils.h"
std::vector<float>* vec = new std::vector<float>{ 3, 6, 9 };
// operator delete called on vec within DestroyFloatVector
if (DestroyFloatVector(vec)) {
std::cout << "DestroyFloatVector was successful" << std::endl;
}
else {
std::cout << "DestroyFloatVector unsuccessful" << std::endl;
}
C_INTERFACE DestroyFloatVector(std::vector< float > *float_vector)
Delete a float vector that's pointed to by float_vector

Definition at line 27 of file cinterface_utils.cpp.

References DeleteRawPtr(), and HF::Exceptions::OK.

+ Here is the call graph for this function:

◆ DestroyIntVector()

C_INTERFACE DestroyIntVector ( std::vector< int > *  int_vector)

Delete a vector of integers.

Parameters
int_vectorA pointer to a vector of integers to delete.
Returns
HF_STATUS.OK on completion.

Definition at line 33 of file cinterface_utils.cpp.

References DeleteRawPtr(), and HF::Exceptions::OK.

+ Here is the call graph for this function: