本文整理汇总了C++中BodyPart::getSurface方法的典型用法代码示例。如果您正苦于以下问题:C++ BodyPart::getSurface方法的具体用法?C++ BodyPart::getSurface怎么用?C++ BodyPart::getSurface使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BodyPart
的用法示例。
在下文中一共展示了BodyPart::getSurface方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: enter
string Body::enter(rapidxml::xml_node<> *node, std::map<string, string>* child_map, std::map<string, string>* organ_link_map) {
using namespace rapidxml;
int organ_count, bodyparts, it;
xml_node<> *temp;
xml_node<> **organ_node_list;
char *id = nullptr, *name = nullptr, *_name = nullptr;
float surface = 0.0f;
//Make a count of the body_part nodes in this node and parse all standard
// nodes for the bodypart of this node
temp = node->first_node();
bodyparts = 0;
while (temp != nullptr){
_name = temp->name();
if (!strcmp(_name, "body_part")) { bodyparts++; }
if (!strcmp(_name, "id")) { id = temp->value(); }
if (!strcmp(_name, "name")) { name = temp->value(); }
if (!strcmp(_name, "surface")) { surface = atof(temp->value()); }
temp = temp->next_sibling();
}
//if any of the mandatory vars for bodyparts are NULL, ERROR!
if (id == nullptr || name == nullptr){
throw new bdef_parse_error("Not all mandatory BodyPart variables defined!", node);
}
//make the bodypart, make the pointer to it shared and store it in the part_map
BodyPart* bp = new BodyPart((string)id, (string)name, surface, this);
boost::shared_ptr<BodyPart> p (bp);
part_map->insert(
std::pair<std::string, boost::shared_ptr<Part>>(
bp->getUUID(), boost::static_pointer_cast<Part>(p)));
//reset temporary variables for reuse with the organs
id = nullptr; name = nullptr;
//DEBUG: Print new BodyPart
debug_print("New BodyPart created: \n\tID: %s \n\tName: %s \n\tSurface: %f\n",
bp->getId().c_str(), bp->getName().c_str(), bp->getSurface());
//If there are no body_part nodes...
if (bodyparts == 0){
//...there must be organs instead!
// variables
Organ **organs;
xml_attribute<> *attr;
xml_node<> *tdef_node;
char *connector = nullptr;
bool symmetrical = false;
it = 0;
// temp vars for tissue definitions
char *tdef_id, *tdef_custom_id, *tdef_name;
float tdef_hit_prob;
tissue_def *tdefs = nullptr;
int tdef_count = 0, tdef_it = 0;
//Reset back to the first node in the given node
temp = node->first_node();
//scan for organ nodes in the given node
organ_count = 0;
while (temp != nullptr){
if (!strcmp(temp->name(),"organ")) { organ_count++; }
temp = temp->next_sibling();
}
//If there are no organs AND no bodyparts, ERROR!
if (organ_count == 0){
throw bdef_parse_error("No body part and no organ definition!", node);
}
//compile a list of nodes holding the organ definitions
//and parse the remaining nodes to make the bodypart
organ_node_list = new xml_node<>*[organ_count];
temp = node->first_node();
while (temp != nullptr){
_name = temp->name();
if (!strcmp(_name,"organ")) {
organ_node_list[it] = temp;
it++;
}
temp = temp->next_sibling();
}
//.........这里部分代码省略.........