DHART
|
Generate a graph of accessible space from a given start point. More...
#include <graph_generator.h>
Public Member Functions | |
GraphGenerator (HF::RayTracer::EmbreeRayTracer &ray_tracer, const std::vector< int > &obstacle_ids=std::vector< int >(0), const std::vector< int > &walkable_ids=std::vector< int >(0)) | |
Construct a new graph generator with a specific raytracer. More... | |
GraphGenerator (HF::RayTracer::NanoRTRayTracer &ray_tracer, const std::vector< int > &obstacle_ids=std::vector< int >(0), const std::vector< int > &walkable_ids=std::vector< int >(0)) | |
Construct a new graph generator with a specific raytracer. More... | |
GraphGenerator (HF::RayTracer::MultiRT &ray_tracer, const std::vector< int > &obstacle_ids=std::vector< int >(0), const std::vector< int > &walkable_ids=std::vector< int >(0)) | |
Construct a new graph generator with a specific raytracer. More... | |
template<typename node_type , typename node2_type , typename up_step_type , typename up_slope_type , typename down_step_type , typename down_slope_type , typename z_precision_type = real_t, typename connect_offset_type = real_t, typename spacing_precision_type = real_t> | |
SpatialStructures::Graph | BuildNetwork (const node_type &start_point, const node2_type &Spacing, int MaxNodes, up_step_type UpStep, up_slope_type UpSlope, down_step_type DownStep, down_slope_type DownSlope, int max_step_connections, int min_connections=1, int cores=-1, z_precision_type node_z_precision=default_z_precision, connect_offset_type node_spacing_precision=default_spacing_precision, spacing_precision_type ground_offset=default_ground_offset) |
Generate a graph of accessible space. More... | |
SpatialStructures::Graph | IMPL_BuildNetwork (const real3 &start_point, const real3 &Spacing, int MaxNodes, real_t UpStep, real_t UpSlope, real_t DownStep, real_t DownSlope, int max_step_connections, int min_connections, int cores=-1, real_t node_z_precision=default_z_precision, real_t node_spacing_precision=default_spacing_precision, real_t ground_offset=default_ground_offset) |
Generate a graph of accessible space. More... | |
SpatialStructures::Graph | CrawlGeom (UniqueQueue &todo) |
Perform breadth first search to populate the graph with with nodes and edges. More... | |
SpatialStructures::Graph | CrawlGeomParallel (UniqueQueue &todo) |
Perform breadth first search to populate the graph with nodes and edges using multiple cores. More... | |
Public Attributes | |
int | max_nodes |
Maximum number of nodes to generate. If less than zero, generate nodes without a limit. More... | |
int | core_count |
Number of cores to use for graph generation. More... | |
int | min_connections |
Minimum number of step connections for a node to be valid (minimum out degree of node) More... | |
int | max_step_connection |
Multiplier for number of children to generate. The higher this is, the more directions there will be. More... | |
real3 | spacing |
Spacing between nodes. New nodes will be generated with atleast this much distance between them. More... | |
GraphParams | params |
Parameters to run the graph generator. More... | |
RayTracer | ray_tracer |
A pointer to the raytracer to use for ray intersections. More... | |
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.
Definition at line 344 of file graph_generator.h.
HF::GraphGenerator::GraphGenerator::GraphGenerator | ( | HF::RayTracer::EmbreeRayTracer & | ray_tracer, |
const std::vector< int > & | obstacle_ids = std::vector<int>(0) , |
||
const std::vector< int > & | walkable_ids = std::vector<int>(0) |
||
) |
Construct a new graph generator with a specific raytracer.
ray_tracer | Raytracer to use for performing ray intersctions |
walkable_id | IDs of geometry to be considered as obstacles |
obstacle_id | IDs of geometry to be considered as walkable surfaces |
Stores a pointer to RT. This could be dangerous in the case that the raytracer is destroyed before the graph generator is called again. It's not likely to occur in our codebase since GraphGenerators are mostly disposed of before this has a chance to become a problem.
Definition at line 55 of file graph_generator.cpp.
HF::GraphGenerator::GraphGenerator::GraphGenerator | ( | HF::RayTracer::NanoRTRayTracer & | ray_tracer, |
const std::vector< int > & | obstacle_ids = std::vector<int>(0) , |
||
const std::vector< int > & | walkable_ids = std::vector<int>(0) |
||
) |
Construct a new graph generator with a specific raytracer.
ray_tracer | Raytracer to use for performing ray intersctions |
walkable_id | IDs of geometry to be considered as obstacles |
obstacle_id | IDs of geometry to be considered as walkable surfaces |
Stores a pointer to RT. This could be dangerous in the case that the raytracer is destroyed before the graph generator is called again. It's not likely to occur in our codebase since GraphGenerators are mostly disposed of before this has a chance to become a problem.
Definition at line 59 of file graph_generator.cpp.
HF::GraphGenerator::GraphGenerator::GraphGenerator | ( | HF::RayTracer::MultiRT & | ray_tracer, |
const std::vector< int > & | obstacle_ids = std::vector<int>(0) , |
||
const std::vector< int > & | walkable_ids = std::vector<int>(0) |
||
) |
Construct a new graph generator with a specific raytracer.
ray_tracer | Raytracer to use for performing ray intersctions |
walkable_id | IDs of geometry to be considered as obstacles |
obstacle_id | IDs of geometry to be considered as walkable surfaces |
Stores a pointer to RT. This could be dangerous in the case that the raytracer is destroyed before the graph generator is called again. It's not likely to occur in our codebase since GraphGenerators are mostly disposed of before this has a chance to become a problem.
Definition at line 63 of file graph_generator.cpp.
References HF::GraphGenerator::GraphParams::geom_ids, params, ray_tracer, and HF::GraphGenerator::GeometryFlagMap::SetGeometryIds().
|
inline |
Generate a graph of accessible space.
start_point | The starting point for the graph generator. If this isn't above solid ground, no nodes will be generated. |
Spacing | Space between nodes. Lower values will yield more nodes for a higher resolution graph. |
MaxNodes | The maximum amount of nodes to generate. |
UpStep | Maximum height of a step the graph can traverse. Any steps higher this will be considered inaccessible. |
UpSlope | Maximum upward slope the graph can traverse in degrees. Any slopes steeper than this will be considered inaccessible. |
DownStep | Maximum step down the graph can traverse. Any steps steeper than this will be considered inaccessible. |
DownSlope | The maximum downward slope the graph can traverse. Any slopes steeper than this will be considered inaccessible. |
max_step_connections | Multiplier for number of children to generate for each node. Increasing this value will increase the number of edges in the graph, and as a result the amount of memory the algorithm requires. |
min_connections | The required out-degree for a node to be valid and stored. This must be greater than 0 and equal or less than the total connections created from max_step_connections. Default is 1. A value of 8 when max_step_connections=1 would be a grid. |
cores | Number of cores to use. -1 will use all available cores, and 0 will run a serialized version of the algorithm. |
node_z_precision | Precision to round the z-component of nodes after a raycast is performed |
node_spacing_precision | Precision to round nodes after spacing is calculated |
ground_offset | Distance to offset nodes from the ground before checking line of sight |
The extensive use of templating on this function is to allow any numeric type to be used for any one of the template arguments. For example node_1_type could be a vector of floats while up_step_type could be an integer, and down_slope_type could be a float, etc.
[(0, 0, -0),(-1, -1, -0),(-1, 0, -0),(-1, 1, 0),(0, -1, -0),(0, 1, 0),(1, -1, -0),(1, 0, -0),(1, 1, 0),(-2, -2, -0),(-2, -1, -0),(-2, 0, -0),(-1, -2, -0),(0, -2, -0),(-2, 1, 0),(-2, 2, 0),(-1, 2, 0),(0, 2, 0),(1, -2, -0)]
Definition at line 464 of file graph_generator.h.
References HF::GraphGenerator::CastToReal(), HF::GraphGenerator::CastToReal3(), IMPL_BuildNetwork(), and min_connections.
Referenced by GenerateGraph(), and GenerateGraphObstacles().
Graph HF::GraphGenerator::GraphGenerator::CrawlGeom | ( | UniqueQueue & | todo | ) |
Perform breadth first search to populate the graph with with nodes and edges.
todo | Todo list to hold unchecked nodes. Must atleast contain a single start point. |
[(0, 1, 0),(-1, 0, -0),(-1, 1, 0),(-1, 2, 0),(0, 0, -0),(0, 2, 0),(1, 0, -0),(1, 1, 0),(1, 2, 0),(-2, -1, -0),(-2, 0, -0),(-2, 1, 0),(-1, -1, -0),(0, -1, -0),(-2, 2, 0),(-2, 3, 0),(-1, 3, 0),(0, 3, 0),(1, -1, -0)]
Definition at line 222 of file graph_generator.cpp.
References HF::SpatialStructures::Graph::addEdge(), HF::GraphGenerator::CastToReal3(), HF::GraphGenerator::CreateDirecs(), HF::GraphGenerator::UniqueQueue::empty(), HF::GraphGenerator::GeneratePotentialChildren(), HF::GraphGenerator::GetChildren(), max_nodes, max_step_connection, params, HF::GraphGenerator::UniqueQueue::pop(), HF::GraphGenerator::UniqueQueue::PushAny(), ray_tracer, and spacing.
Referenced by IMPL_BuildNetwork().
Graph HF::GraphGenerator::GraphGenerator::CrawlGeomParallel | ( | UniqueQueue & | todo | ) |
Perform breadth first search to populate the graph with nodes and edges using multiple cores.
todo | Todo list to hold unchecked nodes. Must atleast contain a single start point. |
[(0, 2, 0),(-1, 1, -0),(-1, 2, 0),(-1, 3, 0),(0, 1, -0),(0, 3, 0),(1, 1, -0),(1, 2, 0),(1, 3, 0),(1, 0, -0),(0, -1, -0),(0, 0, -0),(1, -1, -0),(2, -1, -0),(2, 0, -0),(2, 1, -0),(2, 2, 0),(2, 3, 0),(-2, -1, -0),(-3, -2, -0),(-3, -1, -0),(-3, 0, -0),(-2, -2, -0),(-2, 0, -0),(-1, -2, -0),(-1, -1, -0),(-1, 0, -0)]
Definition at line 141 of file graph_generator.cpp.
References HF::SpatialStructures::Graph::addEdge(), HF::GraphGenerator::CastToReal3(), HF::GraphGenerator::CreateDirecs(), HF::GraphGenerator::UniqueQueue::empty(), HF::GraphGenerator::GeneratePotentialChildren(), HF::GraphGenerator::GetChildren(), max_nodes, max_step_connection, min_connections, params, HF::GraphGenerator::UniqueQueue::popMany(), HF::GraphGenerator::UniqueQueue::push(), ray_tracer, HF::GraphGenerator::UniqueQueue::size(), and spacing.
Referenced by IMPL_BuildNetwork().
SpatialStructures::Graph HF::GraphGenerator::GraphGenerator::IMPL_BuildNetwork | ( | const real3 & | start_point, |
const real3 & | Spacing, | ||
int | MaxNodes, | ||
real_t | UpStep, | ||
real_t | UpSlope, | ||
real_t | DownStep, | ||
real_t | DownSlope, | ||
int | max_step_connections, | ||
int | min_connections, | ||
int | cores = -1 , |
||
real_t | node_z_precision = default_z_precision , |
||
real_t | node_spacing_precision = default_spacing_precision , |
||
real_t | ground_offset = default_ground_offset |
||
) |
Generate a graph of accessible space.
start_point | The starting point for the graph generator. If this isn't above solid ground, no nodes will be generated. |
Spacing | Space between nodes. Lower values will yield more nodes for a higher resolution graph. |
MaxNodes | The maximum amount of nodes to generate. |
UpStep | Maximum height of a step the graph can traverse. Any steps higher this will be considered inaccessible. |
UpSlope | Maximum upward slope the graph can traverse in degrees. Any slopes steeper than this will be considered inaccessible. |
DownStep | Maximum step down the graph can traverse. Any steps steeper than this will be considered inaccessible. |
DownSlope | The maximum downward slope the graph can traverse. Any slopes steeper than this will be considered inaccessible. |
max_step_connections | Multiplier for number of children to generate for each node. Increasing this value will increase the number of edges in the graph, and as a result the amount of memory the algorithm requires. |
min_connections | The required out-degree for a node to be valid and stored. This must be greater than 0 and equal or less than the total connections created from max_step_connections. Default is 1. A value of 8 when max_step_connections=1 would be a grid. |
cores | Number of cores to use. -1 will use all available cores, and 0 will run a serialized version of the algorithm. |
node_z_precision | Precision to round the z-component of nodes after a raycast is performed |
node_spacing_precision | Precision to round nodes after spacing is calculated |
ground_offset | Distance to offset nodes from the ground before checking line of sight |
Definition at line 69 of file graph_generator.cpp.
References core_count, CrawlGeom(), CrawlGeomParallel(), HF::GraphGenerator::GraphParams::down_slope, HF::GraphGenerator::GraphParams::down_step, HF::GraphGenerator::Precision::ground_offset, max_nodes, max_step_connection, min_connections, HF::GraphGenerator::Precision::node_spacing, HF::GraphGenerator::Precision::node_z, params, HF::GraphGenerator::GraphParams::precision, HF::GraphGenerator::UniqueQueue::PushAny(), ray_tracer, HF::GraphGenerator::SetupCoreCount(), spacing, HF::GraphGenerator::GraphParams::up_slope, HF::GraphGenerator::GraphParams::up_step, and HF::GraphGenerator::ValidateStartPoint().
Referenced by BuildNetwork().
int HF::GraphGenerator::GraphGenerator::core_count |
Number of cores to use for graph generation.
Definition at line 348 of file graph_generator.h.
Referenced by IMPL_BuildNetwork().
int HF::GraphGenerator::GraphGenerator::max_nodes |
Maximum number of nodes to generate. If less than zero, generate nodes without a limit.
Definition at line 347 of file graph_generator.h.
Referenced by CrawlGeom(), CrawlGeomParallel(), and IMPL_BuildNetwork().
int HF::GraphGenerator::GraphGenerator::max_step_connection |
Multiplier for number of children to generate. The higher this is, the more directions there will be.
Definition at line 351 of file graph_generator.h.
Referenced by CrawlGeom(), CrawlGeomParallel(), and IMPL_BuildNetwork().
int HF::GraphGenerator::GraphGenerator::min_connections |
Minimum number of step connections for a node to be valid (minimum out degree of node)
Definition at line 350 of file graph_generator.h.
Referenced by BuildNetwork(), CrawlGeomParallel(), and IMPL_BuildNetwork().
GraphParams HF::GraphGenerator::GraphGenerator::params |
Parameters to run the graph generator.
Definition at line 354 of file graph_generator.h.
Referenced by GraphGenerator(), CrawlGeom(), CrawlGeomParallel(), IMPL_BuildNetwork(), and HF::GraphGenerator::setupRT().
RayTracer HF::GraphGenerator::GraphGenerator::ray_tracer |
A pointer to the raytracer to use for ray intersections.
Definition at line 356 of file graph_generator.h.
Referenced by GraphGenerator(), CrawlGeom(), CrawlGeomParallel(), IMPL_BuildNetwork(), and HF::GraphGenerator::setupRT().
real3 HF::GraphGenerator::GraphGenerator::spacing |
Spacing between nodes. New nodes will be generated with atleast this much distance between them.
Definition at line 352 of file graph_generator.h.
Referenced by CrawlGeom(), CrawlGeomParallel(), and IMPL_BuildNetwork().