DHART
|
Generate a graph of accessible space from a given start point. More...
Classes | |
struct | GeometryFlagMap |
Manages rules and ids for different types of geometry in the graph generator. More... | |
class | GraphGenerator |
Generate a graph of accessible space from a given start point. More... | |
struct | GraphParams |
Holds parameters for the GraphGenerator. More... | |
struct | optional_real3 |
A simple wrapper for real3 that is able to determine whether or not it's defined. More... | |
struct | Precision |
Various parameters to set the precision of certain parts of the graph generator. More... | |
class | UniqueQueue |
A queue that remembers every object inserted, and prevents the addition of nodes that have already been inserted even if they've been popped. More... | |
Typedefs | |
using | real_t = double |
Internal decimal type of the graph generator. More... | |
using | real3 = std::array< real_t, 3 > |
Type used for the standard coordinate set of the graph generator. More... | |
using | graph_edge = HF::SpatialStructures::Edge |
Type of edge for the graph generator to use internally. More... | |
using | RayTracer = HF::RayTracer::MultiRT |
Type of raytracer to be used internally. More... | |
using | pair = std::pair< int, int > |
Type for Directions to be stored as. More... | |
using | hashmap = std::unordered_map< int, HIT_FLAG > |
Hashmap used for assigning and storing hitflags for IDs. More... | |
Enumerations | |
enum | HIT_FLAG { NO_FLAG = 0 , FLOORS = 1 , OBSTACLES = 2 , BOTH = 3 } |
Determines which geometry the ray will collide with. More... | |
enum class | GeometryFilterMode { ALL_INTERSECTIONS = 0 , OBSTACLES_ONLY = 1 , OBSTACLES_AND_FLOORS } |
Different rules for how geometry is filtered by the graph generator. More... | |
Functions | |
void | SetupCoreCount (int cores=-1) |
Sets the core count of OpenMP. More... | |
template<typename raytracer_type > | |
void | setupRT (GraphGenerator *gg, raytracer_type &rt, const std::vector< int > &obs_ids, const std::vector< int > &walk_ids) |
Converts the raytracer to a multiRT if required, then map geometry ids to hitflags. More... | |
template<typename real_type > | |
real_t | CastToReal (real_type t) |
Cast an input value to real_t using static cast. More... | |
template<typename real_3_type > | |
real3 | CastToReal3 (real_3_type t) |
Cast an array of 3 values to the graph_generator's real_3 type. More... | |
std::set< std::pair< int, int > > | permutations (int limit) |
Calculate P(n,r) as an array with each unique permutaton of 2 values being a pair. More... | |
optional_real3 | ValidateStartPoint (RayTracer &RT, const real3 &start_point, const GraphParams &Params) |
Determine if the start point of the graph is over valid ground. More... | |
optional_real3 | CheckRay (RayTracer &RT, const real3 &origin, const real3 &direction, real_t node_z_tolerance, HIT_FLAG flag=BOTH, const GeometryFlagMap &geometry_dict=GeometryFlagMap()) |
Cast a ray and get the point of intersection if it connects. More... | |
std::vector< pair > | CreateDirecs (int max_step_connections) |
Create a set of directions based on max_step_connections. More... | |
std::vector< graph_edge > | GetChildren (const real3 &parent, const std::vector< real3 > &possible_children, RayTracer &rt, const GraphParams &GP) |
Calculate all possible edges between parent and possible_children. More... | |
std::vector< real3 > | GeneratePotentialChildren (const real3 &parent, const std::vector< pair > &direcs, const real3 &spacing, const GraphParams &gp) |
Populare out_children with a potential child position for every direction in directions. More... | |
template<typename A , typename D , typename N > | |
void | MoveNode (const A &dist, const D &direction, N &node) |
Move a node in direction by dist units. More... | |
std::vector< real3 > | CheckChildren (const real3 &parent, const std::vector< real3 > &possible_children, RayTracer &rt, const GraphParams ¶ms) |
Determine whether children are over valid ground, and and meet upstep/downstep requirements. More... | |
HF::SpatialStructures::STEP | CheckConnection (const real3 &parent, const real3 &child, RayTracer &rt, const GraphParams ¶ms) |
Determine what kind of step (if any) is between parent and child. More... | |
bool | OcclusionCheck (const real3 &parent, const real3 &child, RayTracer &RT) |
Determine if there is a valid line of sight between parent and child. More... | |
bool | CheckSlope (const real3 &parent, const real3 &child, const GraphParams &gp) |
Determine if the slope between parent and child is traversable according to the graph parameters. More... | |
template<typename point_type > | |
Node | ToNode (const point_type &ct) |
Convert a point_type to a node. More... | |
template<typename n1_type , typename n2_type > | |
real_t | DistanceTo (const n1_type &n1, const n2_type &n2) |
Calculate the distance between two nodes. More... | |
template<typename vector_type > | |
void | Normalize (vector_type &v) |
Normalize a vector. More... | |
template<typename vector_type > | |
vector_type | DirectionTo (const vector_type &n1, const vector_type &n2) |
Calculate the normalized direction from one node to another. More... | |
bool | CheckGeometryID (HIT_FLAG goal, int id, const GeometryFlagMap &geom_dict) |
Determine if a hit is against the geometry type specified. More... | |
Variables | |
constexpr real_t | default_z_precision = 0.0001 |
constexpr real_t | default_ground_offset = 0.01 |
constexpr real_t | default_spacing_precision = 0.00001 |
static const real3 | down = { 0,0,-1 } |
Constant used as a direction for downwards raycasts. More... | |
static const vector< pair > | init_directs |
Generate a graph of accessible space from a given start point.
The Graph Generator maps out "accessible" space on a model from a given starting point. In graphs created by this algorithm, node represents a point in space that a human can occupy, and each edge between nodes indicates that a human can traverse from one node to another node. The Graph Generator is a powerful tool for analyzing space, since the graph or nodes it outputs can be used as input to all the analysis methods offered by DHARTAPI, allowing for it to be the starting point of other analysis methods within DHARTAPI.
struct HF::GraphGenerator::GraphParams |
Holds parameters for the GraphGenerator.
Definition at line 255 of file graph_generator.h.
Class Members | ||
---|---|---|
real_t | down_slope | The maximum downward slope the graph can traverse. Any slopes steeper than this will be considered inaccessible. |
real_t | down_step | Maximum step down the graph can traverse.Any steps steeper than this will be considered inaccessible. |
GeometryFlagMap | geom_ids | Stores a map of geometry IDs to their HIT_FLAGS and the current filter mode of the graph. |
Precision | precision | Tolerances for the graph. |
real_t | up_slope | Maximum upward slope the graph can traverse in degrees.Any slopes steeper than this will be considered inaccessible. |
real_t | up_step | Maximum height of a step the graph can traverse.Any steps higher this will be considered inaccessible. |
struct HF::GraphGenerator::Precision |
Various parameters to set the precision of certain parts of the graph generator.
Definition at line 111 of file graph_generator.h.
Class Members | ||
---|---|---|
real_t | ground_offset | Distance to offset nodes from the ground before checking line of sight. |
real_t | node_spacing | Precision to round nodes after spacing is calculated. |
real_t | node_z | Precision to round the z-component of nodes after a raycast is performed. |
using HF::GraphGenerator::graph_edge = typedef HF::SpatialStructures::Edge |
Type of edge for the graph generator to use internally.
Definition at line 75 of file graph_generator.h.
using HF::GraphGenerator::hashmap = typedef std::unordered_map<int, HIT_FLAG> |
Hashmap used for assigning and storing hitflags for IDs.
Definition at line 134 of file graph_generator.h.
using HF::GraphGenerator::pair = typedef std::pair<int, int> |
Type for Directions to be stored as.
Definition at line 82 of file graph_generator.h.
using HF::GraphGenerator::RayTracer = typedef HF::RayTracer::MultiRT |
Type of raytracer to be used internally.
Definition at line 81 of file graph_generator.h.
using HF::GraphGenerator::real3 = typedef std::array<real_t, 3> |
Type used for the standard coordinate set of the graph generator.
Definition at line 74 of file graph_generator.h.
using HF::GraphGenerator::real_t = typedef double |
Internal decimal type of the graph generator.
Definition at line 73 of file graph_generator.h.
|
strong |
Different rules for how geometry is filtered by the graph generator.
Definition at line 144 of file graph_generator.h.
Determines which geometry the ray will collide with.
Enumerator | |
---|---|
NO_FLAG | No flag set. |
FLOORS | Floors only. |
OBSTACLES | Obstacles only. |
BOTH | Collide with floors and obstacles. |
Definition at line 123 of file graph_generator.h.
|
inline |
Cast an input value to real_t using static cast.
static_cast<real_t>(t)
Definition at line 91 of file graph_generator.h.
Referenced by HF::GraphGenerator::GraphGenerator::BuildNetwork(), and CastToReal3().
|
inline |
Cast an array of 3 values to the graph_generator's real_3 type.
real_3_type | A vector type that is indexable with square brackets for up to 3 elements (pointlike concept) |
t | X,Y,Z coordinates to convert to a real3 |
t
Definition at line 104 of file graph_generator.h.
References CastToReal().
Referenced by HF::GraphGenerator::GraphGenerator::BuildNetwork(), HF::GraphGenerator::GraphGenerator::CrawlGeom(), and HF::GraphGenerator::GraphGenerator::CrawlGeomParallel().
std::vector< real3 > HF::GraphGenerator::CheckChildren | ( | const real3 & | parent, |
const std::vector< real3 > & | possible_children, | ||
RayTracer & | rt, | ||
const GraphParams & | params | ||
) |
Determine whether children are over valid ground, and and meet upstep/downstep requirements.
parent | Parent of all children in possible_children |
possible_children | Children of parent that may or may not be over valid ground |
rt | Raytracer to use for all ray intersections |
params | Parameters to use for upstep/downstep limits and rounding |
possible_children
that are over valid ground and meet the upstep/downstep requirements in params
. Any child that didn't meet these requirements will not have been included. Each child in the return will have been moved to be directly over the valid ground they're above.[(0, 2, 0),(1, 0, -0),(0, 1, 0),(2, 0, -0)]
Definition at line 248 of file graph_utils.cpp.
References CheckRay(), down, HF::GraphGenerator::GraphParams::down_step, FLOORS, HF::GraphGenerator::GraphParams::geom_ids, HF::GraphGenerator::Precision::node_z, HF::GraphGenerator::GraphParams::precision, HF::GraphGenerator::optional_real3::pt, and HF::GraphGenerator::GraphParams::up_step.
Referenced by GetChildren().
HF::SpatialStructures::STEP HF::GraphGenerator::CheckConnection | ( | const real3 & | parent, |
const real3 & | child, | ||
RayTracer & | rt, | ||
const GraphParams & | params | ||
) |
Determine what kind of step (if any) is between parent and child.
parent | Node being traversed from |
child | Node being traversed to |
rt | Raytracer to use for all ray intersections |
params | Parameters to use for upstep/downstep and upslope/downslope |
[1,0,0,1]
Definition at line 303 of file graph_utils.cpp.
References CheckSlope(), HF::GraphGenerator::GraphParams::down_step, HF::GraphGenerator::Precision::ground_offset, OcclusionCheck(), HF::GraphGenerator::GraphParams::precision, and HF::GraphGenerator::GraphParams::up_step.
Referenced by GetChildren().
|
inline |
Determine if a hit is against the geometry type specified.
goal | Hitflag that the intersection is being cheecked against |
ID | id of the mesh that was intesected |
geom_dict | Rules to use for determining if the intersection was successful |
Definition at line 126 of file graph_utils.cpp.
References ALL_INTERSECTIONS, BOTH, HF::GraphGenerator::GeometryFlagMap::Mode, OBSTACLES, OBSTACLES_AND_FLOORS, and OBSTACLES_ONLY.
Referenced by CheckRay().
optional_real3 HF::GraphGenerator::CheckRay | ( | RayTracer & | RT, |
const real3 & | origin, | ||
const real3 & | direction, | ||
real_t | node_z_tolerance, | ||
HIT_FLAG | flag = BOTH , |
||
const GeometryFlagMap & | geometry_dict = GeometryFlagMap() |
||
) |
Cast a ray and get the point of intersection if it connects.
RT | Raytracer to use for intersection. |
origin | Origin point of the ray. |
direction | direction to cast the ray in. |
node_z_tolerance | Precision to round the point of intersection's z-component to |
flag | Which category of geometry will be intersected with. In general, any intersections with geometry other than this type will be discarded unless the type is BOTH, NONE, or the geometry dictionary is empty. |
geometry_dict | Dictionary containing rules for filtering ray intersections. If not specified, this will not filter any intersections. |
(1, 1, 0)
Definition at line 146 of file graph_utils.cpp.
References CheckGeometryID(), HF::RayTracer::HitStruct< numeric_type >::DidHit(), HF::RayTracer::HitStruct< numeric_type >::distance, HF::RayTracer::MultiRT::Intersect(), HF::RayTracer::HitStruct< numeric_type >::meshid, MoveNode(), and HF::GraphGenerator::optional_real3::pt.
Referenced by CheckChildren(), and ValidateStartPoint().
bool HF::GraphGenerator::CheckSlope | ( | const real3 & | parent, |
const real3 & | child, | ||
const GraphParams & | gp | ||
) |
Determine if the slope between parent and child is traversable according to the graph parameters.
parent | Node being traversed from |
child | Node being traversed to |
GP | Parameters to use for up_slope/down_slope |
true
if the slope from parent to child meets upstep/downstep requirements in graph_params. false
otherwise. Slope Check For Child 1 = True
Slope Check For Child 2 = False
Definition at line 290 of file graph_utils.cpp.
References HF::GraphGenerator::GraphParams::down_slope, and HF::GraphGenerator::GraphParams::up_slope.
Referenced by CheckConnection().
vector< pair > HF::GraphGenerator::CreateDirecs | ( | int | max_step_connections | ) |
Create a set of directions based on max_step_connections.
max_step_conenctions | Multiplier for directions to generate. |
[(-1, -1),(-1, 0),(-1, 1),(0, -1),(0, 1),(1, -1),(1, 0),(1, 1),(-2, -1),(-2, 1),(-1, -2),(-1, 2),(1, -2),(1, 2),(2, -1),(2, 1)]
Definition at line 201 of file graph_utils.cpp.
References init_directs, and permutations().
Referenced by HF::GraphGenerator::GraphGenerator::CrawlGeom(), and HF::GraphGenerator::GraphGenerator::CrawlGeomParallel().
|
inline |
Calculate the normalized direction from one node to another.
vector_type | The type of vectors used to hold the coordinates of n1 and `n2. Each element should be indexable with square brackets up to 3 values. |
n1 | Node to calcualte direction from |
n2 | Node to calculate direction to |
n1
to n2
. Directions that are used always used by the graph generator. Definition at line 88 of file graph_utils.cpp.
References Normalize().
Referenced by OcclusionCheck().
|
inline |
Calculate the distance between two nodes.
n1_type | A vector type that is indexable with square brackets for up to 3 elements (pointlike concept) |
n2_type | n1_type A vector type that is indexable with square brackets for up to 3 elements (pointlike concept) |
n1 | Location to calculate distance from |
n2 | Location to calculate distance to |
Definition at line 54 of file graph_utils.cpp.
Referenced by GetChildren(), and OcclusionCheck().
std::vector< real3 > HF::GraphGenerator::GeneratePotentialChildren | ( | const real3 & | parent, |
const std::vector< pair > & | direcs, | ||
const real3 & | spacing, | ||
const GraphParams & | gp | ||
) |
Populare out_children with a potential child position for every direction in directions.
parent | Parent to generate children from. |
directions | X,Y pairs to use for generating children. I.E. A pair of {1,2} would create a child at {parent.x + 1*spacing.x, parent.y + 2*spacing.y, parent.z + spacing.z}. |
spacing | Magnitude to offset children in the x,y,z direction for each direction in directions |
gp | Parameters to use for rounding offset nodes. |
[(0, 2, 4),(0, 4, 4),(1, 0, 4),(2, 0, 4),(1, 2, 4),(2, 2, 4)]
Definition at line 381 of file graph_utils.cpp.
References HF::GraphGenerator::Precision::node_spacing, HF::GraphGenerator::Precision::node_z, and HF::GraphGenerator::GraphParams::precision.
Referenced by HF::GraphGenerator::GraphGenerator::CrawlGeom(), and HF::GraphGenerator::GraphGenerator::CrawlGeomParallel().
vector< graph_edge > HF::GraphGenerator::GetChildren | ( | const real3 & | parent, |
const std::vector< real3 > & | possible_children, | ||
RayTracer & | rt, | ||
const GraphParams & | GP | ||
) |
Calculate all possible edges between parent and possible_children.
parent | Parent of all children in possible_children |
possible_children | Children that may have an edge with Parent |
rt | Raytracer to use for ray intersections |
GP | parameters to use for rounding and discarding nodes |
[((0, 2, 0), 2.23607, 1),((2, 0, -0), 2.23607, 1)]
Definition at line 218 of file graph_utils.cpp.
References CheckChildren(), CheckConnection(), DistanceTo(), and ToNode().
Referenced by HF::GraphGenerator::GraphGenerator::CrawlGeom(), and HF::GraphGenerator::GraphGenerator::CrawlGeomParallel().
|
inline |
Move a node in direction
by dist
units.
D | Must have [0], [1], [2] defined. |
N | Must have [0], [1], [2] defined. |
dist | Distance to move the node. |
direction | Direction to move the node in. |
node | Node to move |
direction
by dist
units. Definition at line 731 of file graph_generator.h.
Referenced by CheckRay().
|
inline |
Normalize a vector.
vector_type | Must be indexable with square brackets for up to 3 elements. (pointlike concept) |
v | The vector to normalize |
Definition at line 68 of file graph_utils.cpp.
Referenced by DirectionTo().
bool HF::GraphGenerator::OcclusionCheck | ( | const real3 & | parent, |
const real3 & | child, | ||
RayTracer & | RT | ||
) |
Determine if there is a valid line of sight between parent and child.
parent | Node to perform the line of sight check from |
child | Node to perform the line of sight check to |
RT | raytracer to use for the line of sight check |
True
The line of sight between parent and child is obstructed False
There is a clear line of sight between parent and child Occlusion Check For Child 1 = True
Occlusion Check For Child 2 = False
Definition at line 283 of file graph_utils.cpp.
References DirectionTo(), DistanceTo(), and HF::RayTracer::MultiRT::Occluded().
Referenced by CheckConnection().
std::set< std::pair< int, int > > HF::GraphGenerator::permutations | ( | int | limit | ) |
Calculate P(n,r) as an array with each unique permutaton of 2 values being a pair.
limit | Highest number in the set |
Definition at line 180 of file graph_utils.cpp.
Referenced by CreateDirecs().
|
inline |
Sets the core count of OpenMP.
cores | Number of cores to use. If -1, use every as many cores as possible |
Definition at line 35 of file graph_generator.cpp.
Referenced by HF::GraphGenerator::GraphGenerator::IMPL_BuildNetwork().
|
inline |
Converts the raytracer to a multiRT if required, then map geometry ids to hitflags.
gg | Pointer to the graph generator to update |
obs_ids | array of geometry ids to set as obstacles |
walk_ids | Array of geometry ids to set as walkable |
gg
will have it's geometry map populated with the passed geometry ids and it's raytracer set to a MultiRT containing gg
Definition at line 50 of file graph_generator.cpp.
References HF::GraphGenerator::GraphParams::geom_ids, HF::GraphGenerator::GraphGenerator::params, HF::GraphGenerator::GraphGenerator::ray_tracer, and HF::GraphGenerator::GeometryFlagMap::SetGeometryIds().
|
inline |
Convert a point_type to a node.
point_type | An array-like type that meets the pointlike concept |
ct | x,y,z coordinates to create the new node with. |
ct
Definition at line 36 of file graph_utils.cpp.
Referenced by GetChildren().
optional_real3 HF::GraphGenerator::ValidateStartPoint | ( | RayTracer & | RT, |
const real3 & | start_point, | ||
const GraphParams & | Params | ||
) |
Determine if the start point of the graph is over valid ground.
RT | Raytracer to use for ray intersection |
start_point | the x,y,z coordinates of the starting point |
Params | parameters to use for precision. |
(0, 0, 0)
Definition at line 107 of file graph_utils.cpp.
References CheckRay(), down, FLOORS, HF::GraphGenerator::GraphParams::geom_ids, HF::GraphGenerator::Precision::node_z, and HF::GraphGenerator::GraphParams::precision.
Referenced by HF::GraphGenerator::GraphGenerator::IMPL_BuildNetwork().
|
constexpr |
Definition at line 78 of file graph_generator.h.
|
constexpr |
Definition at line 79 of file graph_generator.h.
|
constexpr |
Definition at line 77 of file graph_generator.h.
|
static |
Constant used as a direction for downwards raycasts.
Definition at line 13 of file graph_utils.cpp.
Referenced by CheckChildren(), and ValidateStartPoint().
|
static |
Definition at line 101 of file graph_utils.cpp.
Referenced by CreateDirecs().