claraty::Bounding_Shape_IO Class Reference
#include <me_body_io.h>
Bounding_Shape file I/O | |
| static void | extract_from_parse_tree (pug::xml_node &bounding_shape_elem, Bounding_Shape &bounding_shape) |
| static CHILD_TYPES | _get_child_type (const char *child_name) |
| static N_3D_Object::SHAPE_TYPE | _get_shape_type (CHILD_TYPES child_type) |
Public Types | |
| enum | CHILD_TYPES { BOX, CYLINDER, SPHERE, TRANSFORM, OTHER_TYPE } |
Static Public Attributes | |
Bounding_Shape constructor/destructor | |
| static const int | NUM_ATTRIBUTES = 6 |
Detailed Description
Bounding_Shape_IO class The Bounding_Shape_IO class performs file I/O for the Bounding_Shape class that is part of the Mechanism_Model package.
Definition at line 133 of file me_body_io.h.
Member Enumeration Documentation
Definition at line 135 of file me_body_io.h.
00136 {BOX, 00137 CYLINDER, 00138 SPHERE, 00139 TRANSFORM, 00140 OTHER_TYPE};
Member Function Documentation
| void claraty::Bounding_Shape_IO::extract_from_parse_tree | ( | pug::xml_node & | bounding_shape_elem, | |
| Bounding_Shape & | bounding_shape | |||
| ) | [static] |
Extract Bounding_shape_IO data from the XML parse tree
- Parameters:
-
[in] bounding_shape_elem [in] bounding_shape
Definition at line 302 of file me_body_io.cc.
References _get_child_type(), _get_shape_type(), claraty::Mechanism_Model_IO::_p_parser, claraty::Parameter_Parser::attributes_by_name(), BOX, pug::xml_node::children_begin(), pug::xml_node::children_end(), CYLINDER, pug::xml_node::empty(), claraty::N_3D_Object_IO::extract_from_parse_tree(), claraty::Transform_IO::extract_from_parse_tree(), claraty::Bounding_Shape::get_transform(), NUM_ATTRIBUTES, claraty::Bounding_Shape::set_alignment(), claraty::Bounding_Shape::set_collision(), claraty::Bounding_Shape::set_containment(), claraty::Bounding_Shape::set_name(), claraty::Bounding_Shape::set_parent_name(), claraty::Bounding_Shape::set_tolerance(), SPHERE, claraty::string_eat_bool(), and TRANSFORM.
Referenced by claraty::ME_Body_IO::extract_from_parse_tree().
00305 { 00306 string attribute_names[NUM_ATTRIBUTES]; 00307 string attribute_values[NUM_ATTRIBUTES]; 00308 00309 if (!bounding_shape_elem.empty()) // Get the body attributes 00310 { 00311 Mechanism_Model_IO::_p_parser->attribute_values_by_name( 00312 attribute_names, 00313 bounding_shape_elem, 00314 NUM_ATTRIBUTES, 00315 attribute_values); 00316 pug::xml_attribute attributes[NUM_ATTRIBUTES]; 00317 for (int i=0; i<NUM_ATTRIBUTES; ++i) 00318 attributes[i] = 0; 00319 Mechanism_Model_IO::_p_parser->attributes_by_name( 00320 attributes, 00321 bounding_shape_elem, 00322 NUM_ATTRIBUTES, 00323 attribute_names); 00324 00325 //Bounding_Shape & bounding_shape = me_body.create_bounding_shape(); 00326 00327 bounding_shape.set_name(attribute_values[0]); 00328 bounding_shape.set_parent_name(attribute_values[1]); 00329 00330 // Convert the next 3 boolean-value attributes into bools 00331 bool boolean_value; 00332 00333 string_eat_bool(attribute_values[2], boolean_value); 00334 bounding_shape.set_containment(boolean_value); 00335 00336 string_eat_bool(attribute_values[3], boolean_value); 00337 bounding_shape.set_alignment(boolean_value); 00338 00339 string_eat_bool(attribute_values[4], boolean_value); 00340 bounding_shape.set_collision(boolean_value); 00341 00342 if (!attributes[5].empty()) 00343 bounding_shape.set_tolerance( 00344 Mechanism_Model_IO::_p_parser->evaluate_expression( 00345 attributes[5])); 00346 else 00347 bounding_shape.set_tolerance(0.0); 00348 00349 //For each child. 00350 pug::xml_node::child_iterator i = bounding_shape_elem.children_begin(); 00351 pug::xml_node::child_iterator m = bounding_shape_elem.children_end(); 00352 for(; i < m; ++i) 00353 { 00354 switch (_get_child_type(i->name())) 00355 { 00356 case Bounding_Shape_IO::TRANSFORM: // Fill in transform data 00357 { 00358 //Transform * _transform = new Transform(); 00359 Transform_IO::extract_from_parse_tree(*i, 00360 bounding_shape.get_transform()); 00361 break; 00362 } 00363 case Bounding_Shape_IO::BOX: // Fill in box data 00364 case Bounding_Shape_IO::CYLINDER: // Fill in cylinderdata 00365 case Bounding_Shape_IO::SPHERE: // Fill in sphere data 00366 { 00367 N_3D_Object_IO::extract_from_parse_tree(*i, 00368 bounding_shape, 00369 _get_shape_type(_get_child_type(i->name()))); 00370 break; 00371 } 00372 default: 00373 break; 00374 } // end switch 00375 } 00376 } 00377 }
Here is the call graph for this function:

| Bounding_Shape_IO::CHILD_TYPES claraty::Bounding_Shape_IO::_get_child_type | ( | const char * | child_name | ) | [static, private] |
Return child enumeration type from child name.
- Parameters:
-
[in] child_name
- Returns:
- Child type.
Definition at line 427 of file me_body_io.cc.
References BOX, CYLINDER, OTHER_TYPE, SPHERE, and TRANSFORM.
Referenced by extract_from_parse_tree().
00428 { 00429 if (strcmp(child_name, "Transform") == 0) 00430 return TRANSFORM; 00431 00432 if (strcmp(child_name, "Box") == 0) 00433 return BOX; 00434 00435 if (strcmp(child_name, "Cylinder") == 0) 00436 return CYLINDER; 00437 00438 if (strcmp(child_name, "Sphere") == 0) 00439 return SPHERE; 00440 00441 00442 return OTHER_TYPE; 00443 }
| N_3D_Object::SHAPE_TYPE claraty::Bounding_Shape_IO::_get_shape_type | ( | CHILD_TYPES | child_type | ) | [static, private] |
Return shape type corresponding to bounding shape child type
- Parameters:
-
[in] child_type
- Returns:
- Shape type
Definition at line 389 of file me_body_io.cc.
References claraty::N_3D_Object::BOX, BOX, claraty::N_3D_Object::CYLINDER, CYLINDER, claraty::N_3D_Object::OTHER, claraty::N_3D_Object::SPHERE, and SPHERE.
Referenced by extract_from_parse_tree().
00390 { 00391 N_3D_Object::SHAPE_TYPE return_value; 00392 00393 switch(child_type) 00394 { 00395 case Bounding_Shape_IO::BOX: 00396 return_value = N_3D_Object::BOX; 00397 break; 00398 00399 case Bounding_Shape_IO::CYLINDER: 00400 return_value = N_3D_Object::CYLINDER; 00401 break; 00402 00403 case Bounding_Shape_IO::SPHERE: 00404 return_value = N_3D_Object::SPHERE; 00405 break; 00406 00407 default: 00408 return_value = N_3D_Object::OTHER; 00409 break; 00410 00411 } 00412 00413 return return_value; 00414 00415 }
Member Data Documentation
const int claraty::Bounding_Shape_IO::NUM_ATTRIBUTES = 6 [static] |
The documentation for this class was generated from the following files: