Follow this link to skip to the main content

I/O
[Motion Package]

Collaboration diagram for I/O:


Classes

class  claraty::Mechanism_Model_IO

Mechanism_Model_IO constructors/destructors

enum  claraty::Mechanism_Model_IO::ATTRIBUTE { claraty::Mechanism_Model_IO::NAME = 0, claraty::Mechanism_Model_IO::VERSION, claraty::Mechanism_Model_IO::ZERO_POSITION }
enum  claraty::Mechanism_Model_IO::MODEL_FILE_TYPE { claraty::Mechanism_Model_IO::ME_BODY_DATA, claraty::Mechanism_Model_IO::DH_CRAIG_DATA, claraty::Mechanism_Model_IO::DH_PAUL_DATA, claraty::Mechanism_Model_IO::UNSPECIFIED }
static const int claraty::Mechanism_Model_IO::MECHANISM_MODEL_ATTRIBUTES = 3

Mechanism_Model private members

static Parameter_Parser * claraty::Mechanism_Model_IO::_p_parser
static MODEL_FILE_TYPE claraty::Mechanism_Model_IO::_model_file_type
static bool claraty::Mechanism_Model_IO::_zero_position

Mechanism_Model file I/O

static bool claraty::Mechanism_Model_IO::load (std::string filename, Mechanism_Model &mm, std::string mount_node="", Transform mount_offset=Transform::identity)
static void claraty::Mechanism_Model_IO::_attach_body_to_tree (ME_Body *p_me_body, Tree< ME_Body > &temp_body_tree, std::string parent_name)
static void claraty::Mechanism_Model_IO::_insert_tree_in_mechanism_model (Mechanism_Model &mm, std::string nodename, Tree< ME_Body > &temp_body_tree)
static bool claraty::Mechanism_Model_IO::_are_attributes_compatible (Mechanism_Model &mm)
static void claraty::Mechanism_Model_IO::_extract_parse_tree_data (Mechanism_Model &mm, std::string nodename, Transform &offset)
static void claraty::Mechanism_Model_IO::_add_ME_Body_model_data (Mechanism_Model &mm, std::string attach_to_node, Transform &offset)
static bool claraty::Mechanism_Model_IO::_add_DH_parameter_model_data (Mechanism_Model &mm, std::string attach_to_node, Transform &offset)
static bool claraty::Mechanism_Model_IO::_extract_model_type (pug::xml_node dh_param_elem)

Detailed Description

CLARAty File I/O Package The CLARAty File I/O Package, as part of the Motion Package implements file I/O for Mechanism_Model objects.

 Mechanism_Model mech_model;
 Mechanism_Model_IO sample_model("sample1.xml", mech_model);         
 sample_model.load("sample2.xml", mech_model);
 sample_model.save("sampleCopy.xml", mech_model);

Enumeration Type Documentation

Enumerator:
NAME 
VERSION 
ZERO_POSITION 

Definition at line 92 of file mechanism_model_io.h.

00093     { NAME    = 0,
00094       VERSION,
00095       ZERO_POSITION};

Enumerator:
ME_BODY_DATA 
DH_CRAIG_DATA 
DH_PAUL_DATA 
UNSPECIFIED 

Definition at line 97 of file mechanism_model_io.h.

00098     { ME_BODY_DATA,
00099       DH_CRAIG_DATA,
00100       DH_PAUL_DATA,
00101       UNSPECIFIED};


Function Documentation

static bool claraty::Mechanism_Model_IO::_add_DH_parameter_model_data ( Mechanism_Model mm,
std::string  attach_to_node,
Transform offset 
) [static, private, inherited]

static void claraty::Mechanism_Model_IO::_add_ME_Body_model_data ( Mechanism_Model mm,
std::string  attach_to_node,
Transform offset 
) [static, private, inherited]

bool claraty::Mechanism_Model_IO::_are_attributes_compatible ( Mechanism_Model mm  )  [static, private, inherited]

Compare the version in the current XML file data to the version in the mech_model object. Return false if the mech_model version is incompatible with the current file.

Returns:
TRUE is successful, FALSE if not

Definition at line 99 of file mechanism_model_io.cc.

References claraty::Mechanism_Model_IO::MECHANISM_MODEL_ATTRIBUTES.

00101 {
00102 
00103   //string mechanism_model_tag("Mechanism_Model");
00104   string attribute_values[MECHANISM_MODEL_ATTRIBUTES];
00105   string attribute_names [MECHANISM_MODEL_ATTRIBUTES];
00106   /*
00107   if (!_p_parser->has_tag_name(mechanism_model_tag))
00108     return false;             // Not a Mechanism_Model file
00109 
00110   // Get the Mechanism_Model node
00111   pug::xml_node mech_model_elem =
00112     _p_parser->document().first_element_by_name("Mechanism_Model");
00113   // Get the Mechanism_Model attributes
00114 
00115   attribute_names[NAME] = "name"; 
00116   attribute_names[VERSION] = "version";
00117   attribute_values[NAME] = "";
00118   attribute_values[VERSION] = "";
00119   attribute_values[ZERO_POSITION] = "false";
00120 
00121   if (!mech_model_elem.empty()) {
00122     _p_parser->attribute_values_by_name(attribute_names,
00123                                         mech_model_elem,
00124                                         MECHANISM_MODEL_ATTRIBUTES,
00125                                         attribute_values);
00126     if ((mm.get_version() != "")
00127         && (attribute_values[1] != mm.get_version()))
00128       return false;
00129     else {
00130       mm.set_name(attribute_values[NAME]);
00131       mm.set_version(attribute_values[VERSION]);
00132       return string_eat_bool(attribute_values[ZERO_POSITION], _zero_position);
00133     }
00134 
00135   }
00136   else
00137     return false; 
00138   */
00139   return true;
00140 }

static void claraty::Mechanism_Model_IO::_attach_body_to_tree ( ME_Body p_me_body,
Tree< ME_Body > &  temp_body_tree,
std::string  parent_name 
) [static, private, inherited]

bool claraty::Mechanism_Model_IO::_extract_model_type ( pug::xml_node  dh_param_elem  )  [static, private, inherited]

Set the DH model type: Craig or Paul

Parameters:
[in] dh_param_elem pug xml node in parser containing DH data
Returns:
If inconsistant return false, other returns true.

Definition at line 480 of file mechanism_model_io.cc.

References claraty::Mechanism_Model_IO::_model_file_type, claraty::Mechanism_Model_IO::_p_parser, claraty::Mechanism_Model_IO::DH_CRAIG_DATA, claraty::Mechanism_Model_IO::DH_PAUL_DATA, claraty::Parameter_Parser::has_attribute_match(), and claraty::Mechanism_Model_IO::UNSPECIFIED.

00481 {
00482   if (_p_parser->has_attribute_match(dh_param_elem, "type", "DH_Craig"))
00483   {
00484     // Using Craig's DH model format
00485     // Check for inconsistant model formats in DH_Block
00486     if ((_model_file_type != Mechanism_Model_IO::DH_CRAIG_DATA)
00487         && (_model_file_type != Mechanism_Model_IO::UNSPECIFIED)) 
00488     {
00489       return false;
00490     }
00491     _model_file_type = Mechanism_Model_IO::DH_CRAIG_DATA;
00492   }
00493   else  // Using Paul's DH model format
00494   {
00495     // Check for inconsistant model formats in DH_Block
00496     if ((_model_file_type != Mechanism_Model_IO::DH_PAUL_DATA)
00497         && (_model_file_type != Mechanism_Model_IO::UNSPECIFIED)) 
00498     {
00499       return false;
00500     }
00501     _model_file_type = Mechanism_Model_IO::DH_PAUL_DATA;
00502   }
00503   return true;
00504 }

Here is the call graph for this function:

static void claraty::Mechanism_Model_IO::_extract_parse_tree_data ( Mechanism_Model mm,
std::string  nodename,
Transform offset 
) [static, private, inherited]

static void claraty::Mechanism_Model_IO::_insert_tree_in_mechanism_model ( Mechanism_Model mm,
std::string  nodename,
Tree< ME_Body > &  temp_body_tree 
) [static, private, inherited]

static bool claraty::Mechanism_Model_IO::load ( std::string  filename,
Mechanism_Model mm,
std::string  mount_node = "",
Transform  mount_offset = Transform::identity 
) [static, inherited]


Variable Documentation

Mechanism_Model_IO::MODEL_FILE_TYPE claraty::Mechanism_Model_IO::_model_file_type [static, private, inherited]

Type of model file: ME_BODY_DATA, DH_CRAIG_DATA or DH_PAUL_DATA

Definition at line 137 of file mechanism_model_io.h.

Referenced by claraty::Mechanism_Model_IO::_extract_model_type().