SDFormat Editor
Loading...
Searching...
No Matches
Private Member Functions | Private Attributes | List of all members
SDFormatParser Class Reference

Implementation of SDFormatParserI. More...

#include <sdformat_parser.h>

Inheritance diagram for SDFormatParser:
Inheritance graph
Collaboration diagram for SDFormatParser:
Collaboration graph

Private Member Functions

void Initialize (const std::string file_path, bool &success) override
 Implementation of interface method.
 
sdf::SDFPtr GetSDFElement () override
 Implementation of interface method.
 
std::vector< sdf::ElementPtr > LookupElementsByAttributeType (const std::string &attribute_type) override
 Implementation of interface method.
 
std::vector< sdf::ElementPtr > LookupElementsByAttributeTypeAndValue (const std::string &attribute_type, const std::string &attribute_value) override
 Implementation of interface method.
 
std::vector< sdf::ElementPtr > LookupElementsInternal (const std::string &attribute_type, const std::string &attribute_value, sdf::ElementPtr scope, sdf::ElementPtr scope_to_exclude)
 Attempts to find an element containing the given attribute type and attribute value within an inital scope. The method will continue expanding the scope until it reaches the root element.
 
sdf::ElementPtr FindScope (sdf::ElementPtr element)
 Finds the nearest world, model, or root element parent of the given element.
 
sdf::ElementPtr FindCanonical (sdf::ElementPtr element)
 Finds the canonical link of a model and, if that doesn't exist, the first child nested model.
 
std::vector< sdf::ElementPtr > LookupElementsByType (const std::string &type) override
 Implementation of interface method.
 
Mentions FindMentions (std::string key) override
 Implementation of interface method.
 
Mentions FindMentions (std::string key, sdf::ElementPtr element_to_exclude) override
 Implementation of interface method.
 
Mentions FindMentions (std::string key, sdf::ParamPtr attribute_to_exclude) override
 Implementation of interface method.
 
Mentions FindMentions (std::string key, sdf::ElementPtr element_to_exclude, sdf::ParamPtr attribute_to_exclude) override
 Implementation of interface method.
 
std::string GetSDFTreePathToElement (sdf::ElementPtr element) override
 Implementation of interface method.
 
std::pair< glm::dvec3, glm::dquat > FindAbsolutePose (sdf::ElementPtr element, std::vector< sdf::ElementPtr > previously_visited_elements={})
 Finds the absolute pose (translation and rotation) of a given mesh/geometry-containing element.
 
std::pair< glm::dvec3, glm::dquat > ParsePoseElement (sdf::ElementPtr element, std::string &relative_to)
 Parses a given pose element to get the pose values, and also indicates if this pose is relative to anything else.
 
bool HandleRelativeToSpecificationSpecialcases (sdf::ElementPtr element, std::string &relative_to)
 Considers if this is a special case of "relative_to" and approperiately handles it.
 
std::vector< double > ParseStringDoubleVector (const std::string &string_of_doubles, bool &success)
 Given a string containing doubles seperated by spaces, this method returns a vector a doubles.
 
std::pair< std::vector< ModelViewerI::ModelInfo >, std::vector< ModelViewerI::PresetModelInfo > > GetModelsFromSDFTree (bool render_collisions=false) override
 Implementation of interface method.
 

Private Attributes

sdf::SDFPtr sdfElement
 The main sdfElement associated this this SDFormatParser instance.
 
std::string sdf_file_path
 Store the file path of the sdf file.
 

Additional Inherited Members

Detailed Description

Implementation of SDFormatParserI.

Member Function Documentation

◆ FindAbsolutePose()

std::pair< glm::dvec3, glm::dquat > SDFormatParser::FindAbsolutePose ( sdf::ElementPtr  element,
std::vector< sdf::ElementPtr >  previously_visited_elements = {} 
)
private

Finds the absolute pose (translation and rotation) of a given mesh/geometry-containing element.

Parameters
[in]elementThe element for which we want to find absolute position
[in]previously_visited_elementsindicates elements that were previously visited as we are trying to compute absolute pose. Used to detect a reference cycle in "relative_to" mentions.
Returns
A pair datatype containing the absolute translation and rotation of the given element

◆ FindCanonical()

sdf::ElementPtr SDFormatParser::FindCanonical ( sdf::ElementPtr  element)
private

Finds the canonical link of a model and, if that doesn't exist, the first child nested model.

Parameters
[in]elementwe want to the "canonical" of, must be a model element
Returns
The canonical link. If that does not exist in the immediate scope, the first nested model. If that does not exist, a null pointer. Also returns a null pointer if the given element is not a model

◆ FindMentions() [1/4]

SDFormatParser::Mentions SDFormatParser::FindMentions ( std::string  key)
overrideprivatevirtual

Implementation of interface method.

Parameters
[in]keythe string to search for
Returns
The elements and attributes that mention this given key

Implements SDFormatParserI.

◆ FindMentions() [2/4]

SDFormatParser::Mentions SDFormatParser::FindMentions ( std::string  key,
sdf::ElementPtr  element_to_exclude 
)
overrideprivatevirtual

Implementation of interface method.

Parameters
[in]keythe string to search for
[in]element_to_excludethe element to exclude in the search
Returns
The elements and attributes that mention this given key

Implements SDFormatParserI.

◆ FindMentions() [3/4]

SDFormatParser::Mentions SDFormatParser::FindMentions ( std::string  key,
sdf::ElementPtr  element_to_exclude,
sdf::ParamPtr  attribute_to_exclude 
)
overrideprivatevirtual

Implementation of interface method.

Parameters
[in]keythe string to search for
[in]element_to_excludethe element to exclude in the search; Can be nullptr
[in]attribute_to_excludethe attribute to exclude in the search; Can be nullptr
Returns
The elements and attributes that mention this given key

Implements SDFormatParserI.

◆ FindMentions() [4/4]

SDFormatParser::Mentions SDFormatParser::FindMentions ( std::string  key,
sdf::ParamPtr  attribute_to_exclude 
)
overrideprivatevirtual

Implementation of interface method.

Parameters
[in]keythe string to search for
[in]attribute_to_excludethe attribute to exclude in the search
Returns
The elements and attributes that mention this given key

Implements SDFormatParserI.

◆ FindScope()

sdf::ElementPtr SDFormatParser::FindScope ( sdf::ElementPtr  element)
private

Finds the nearest world, model, or root element parent of the given element.

Parameters
[in]elementwe want to get the scope for
Returns
The world, model, or root element defining the given element's scope

◆ GetModelsFromSDFTree()

std::pair< std::vector< ModelViewerI::ModelInfo >, std::vector< ModelViewerI::PresetModelInfo > > SDFormatParser::GetModelsFromSDFTree ( bool  render_collisions = false)
overrideprivatevirtual

Implementation of interface method.

Parameters
[in]render_collisionsindicates if collision meshes and shapes are included as well
Returns
A pair of vectors condaining structs of the model viewer interfaces's ModelInfo and Preset Model Info, which in turn contain the necessary information to render models

Implements SDFormatParserI.

◆ GetSDFElement()

sdf::SDFPtr SDFormatParser::GetSDFElement ( )
overrideprivatevirtual

Implementation of interface method.

Returns
The main sdfElement associated this this SDFormatParser instance

Implements SDFormatParserI.

◆ GetSDFTreePathToElement()

std::string SDFormatParser::GetSDFTreePathToElement ( sdf::ElementPtr  element)
overrideprivatevirtual

Implementation of interface method.

Parameters
[in]elementelement that we want a tree path for
Returns
Tree path as a string

Implements SDFormatParserI.

◆ HandleRelativeToSpecificationSpecialcases()

bool SDFormatParser::HandleRelativeToSpecificationSpecialcases ( sdf::ElementPtr  element,
std::string &  relative_to 
)
private

Considers if this is a special case of "relative_to" and approperiately handles it.

Parameters
[in]elementThe element to consider
[out]relative_toThe "relative_to" specification
Returns
Returns true if successful

◆ Initialize()

void SDFormatParser::Initialize ( const std::string  file_path,
bool &  success 
)
overrideprivatevirtual

Implementation of interface method.

Implements SDFormatParserI.

◆ LookupElementsByAttributeType()

std::vector< sdf::ElementPtr > SDFormatParser::LookupElementsByAttributeType ( const std::string &  attribute_type)
overrideprivatevirtual

Implementation of interface method.

Parameters
[in]attribute_typeThe attribute type to use for lookup
Returns
A list of elements with a given attribute type

Implements SDFormatParserI.

◆ LookupElementsByAttributeTypeAndValue()

std::vector< sdf::ElementPtr > SDFormatParser::LookupElementsByAttributeTypeAndValue ( const std::string &  attribute_type,
const std::string &  attribute_value 
)
overrideprivatevirtual

Implementation of interface method.

Parameters
[in]attribute_typeThe attribute type to use for lookup
[in]attribute_valueThe attribute type to use for lookup
Returns
A list of elements with the given attribute type and the given attribute value

Implements SDFormatParserI.

◆ LookupElementsByType()

std::vector< sdf::ElementPtr > SDFormatParser::LookupElementsByType ( const std::string &  type)
overrideprivatevirtual

Implementation of interface method.

Parameters
[in]typeThe type by which to lookup elements
Returns
A list of elements with a given attribute type

Implements SDFormatParserI.

◆ LookupElementsInternal()

std::vector< sdf::ElementPtr > SDFormatParser::LookupElementsInternal ( const std::string &  attribute_type,
const std::string &  attribute_value,
sdf::ElementPtr  scope,
sdf::ElementPtr  scope_to_exclude 
)
private

Attempts to find an element containing the given attribute type and attribute value within an inital scope. The method will continue expanding the scope until it reaches the root element.

Parameters
[in]attribute_typeThe attribute type to use for lookup
[in]attribute_valueThe attribute type to use for lookup
[in]scopeThe initial search scope. Must be a model or world element
[in]scope_to_excludeThe scope to exclude. Must be a model or world element
Returns
A list of elements with the given attribute type and the given attribute value, ordered by scope

◆ ParsePoseElement()

std::pair< glm::dvec3, glm::dquat > SDFormatParser::ParsePoseElement ( sdf::ElementPtr  element,
std::string &  relative_to 
)
private

Parses a given pose element to get the pose values, and also indicates if this pose is relative to anything else.

Parameters
[in]elementThe pose element which we want to parse
[out]relative_toThe name of the element that the pose is given relative to
Returns
A pair datatype containing the translation and quaternion rotation of the given element The translations and rotations will all be zero if the given element is not a pose element

◆ ParseStringDoubleVector()

std::vector< double > SDFormatParser::ParseStringDoubleVector ( const std::string &  string_of_doubles,
bool &  success 
)
private

Given a string containing doubles seperated by spaces, this method returns a vector a doubles.

Parameters
[in]string_of_doublesa string of doubles (should be parsable by std::istringstream)
[out]successTrue if the string of doubles was sucessfully parsed
Returns
Returns a vector of doubles

The documentation for this class was generated from the following files: