25 using namespace boost;
35 ProtoInfo(
int id, ProtoCheckFunc func) : id(id), protoCheckFunc(func) { }
37 ProtoCheckFunc protoCheckFunc;
40 typedef map<string,ProtoInfo> ProtoNameToInfoMap;
41 ProtoNameToInfoMap protoNameToInfoMap;
52 bool loadModelFile(
const std::string&
filename);
84 void addFloatField(
const std::string&
name,
double defaultValue);
86 void checkHumanoidProto();
87 void checkJointProto();
88 void checkSegmentProto();
89 void checkSensorProtoCommon();
90 void checkHardwareComponentProto();
91 void extractJointNodes();
92 void checkExtraJointProto();
94 void extractChildNodes
97 void putMessage(
const std::string& message);
113 if(protoNameToInfoMap.empty()){
115 protoNameToInfoMap[
"Humanoid"]
118 protoNameToInfoMap[
"Joint"]
121 protoNameToInfoMap[
"Segment"]
124 protoNameToInfoMap[
"ForceSensor"]
127 protoNameToInfoMap[
"Gyro"]
130 protoNameToInfoMap[
"AccelerationSensor"]
133 protoNameToInfoMap[
"VisionSensor"]
136 protoNameToInfoMap[
"RangeSensor"]
139 protoNameToInfoMap[
"HardwareComponent"]
142 protoNameToInfoMap[
"ExtraJoint"]
156 return impl->numJointNodes;
162 return impl->humanoidNode;
168 return impl->rootJointNodeSet;
173 return impl->extraJointNodes.size();
178 return impl->extraJointNodes[index];
183 return impl->loadModelFile(filename);
197 parser.
load(filename);
216 ProtoNameToInfoMap::iterator p = protoNameToInfoMap.find(
protoToCheck->protoName);
217 if(p != protoNameToInfoMap.end()){
218 ProtoInfo&
info = p->second;
219 (this->*info.protoCheckFunc)();
225 if(instance->proto->protoName ==
"Humanoid") {
227 }
else if(instance->proto->protoName ==
"ExtraJoint") {
245 message +=
protoToCheck->protoName +
"\" must have the \"" + name +
"\" field of " +
254 if(!field || field->
typeId() != typeId){
263 if(field && field->
typeId() != typeId){
274 }
else if(field->
typeId() != typeId){
286 field->
sfFloat() = defaultValue;
311 std::fill(scale.begin(), scale.end(), 1.0);
331 (
"Prototype of Humanoid must have the \"jointAxis\" field");
335 (
"The type of \"jointAxis\" field in \"Humanoid\" prototype must be SFString or SFVec3f");
356 std::fill(scale.begin(), scale.end(), 1.0);
360 putMessage(
"The \"equivalentInertia\" field of the Joint node is obsolete.");
404 if(nodes.size() > 1){
406 (
"The Humanoid node must have a unique Joint node in its \"humanoidBody\" field.");
408 }
else if(nodes.size() == 1){
411 if(jointNode && jointNode->proto->protoName ==
"Joint"){
419 (
"The Humanoid node does not have a Joint node in its \"humanoidBody\" field.");
428 putMessage(
string(
"Joint node ") + jointNode->defName);
432 jointNodeSet->jointNode = jointNode;
434 MFNode& childNodes = jointNode->fields[
"children"].mfNode();
451 for(
size_t i = 0;
i < childNodes.size();
i++){
452 VrmlNode* childNode = childNodes[
i].get();
469 jointNodeSet->lightNodes.push_back(std::make_pair(T,childNode));
474 bool doTraverseChildren =
false;
475 ProtoIdSet acceptableChildProtoIds(acceptableProtoIds);
477 const string& protoName = protoInstance->
proto->protoName;
478 ProtoNameToInfoMap::iterator p = protoNameToInfoMap.find(protoName);
480 if(p == protoNameToInfoMap.end()){
481 doTraverseChildren =
true;
484 if(!acceptableProtoIds.test(
id)){
494 if(T != Matrix44::Identity())
496 jointNodeSet->childJointNodeSets.push_back(
addJointNodeSet(protoInstance));
500 if(T != Matrix44::Identity())
502 jointNodeSet->sensorNodes.push_back(protoInstance);
507 if(T != Matrix44::Identity())
509 jointNodeSet->hwcNodes.push_back(protoInstance);
515 jointNodeSet->segmentNodes.push_back(protoInstance);
516 jointNodeSet->transforms.push_back(T);
519 doTraverseChildren =
true;
520 acceptableChildProtoIds.reset();
529 if(doTraverseChildren){
530 if (protoInstance->
fields.count(
"children")){
531 MFNode& childNodes = protoInstance->
fields[
"children"].mfNode();
546 self->sigMessage(space + message +
"\n");
std::vector< SFNode > MFNode
VrmlProtoInstancePtr humanoidNode
png_infop png_charp png_int_32 png_int_32 int * type
Modifications controlling boost library behavior.
Abstract base class of all vrml nodes.
JointNodeSetPtr rootJointNodeSet
virtual MFNode & getChildren()
VrmlProtoInstancePtr extraJointNode(int index)
static const char * getLabelOfFieldType(int type)
png_infop png_charpp name
boost::intrusive_ptr< VrmlProtoInstance > VrmlProtoInstancePtr
void extractChildNodes(JointNodeSetPtr jointNodeSet, MFNode &childNodes, const ProtoIdSet acceptableProtoIds, const Matrix44 &T)
HRP_UTIL_EXPORT void calcTransformMatrix(VrmlTransform *transform, Matrix44 &out_T)
JointNodeSetPtr addJointNodeSet(VrmlProtoInstancePtr jointNode)
void addFloatField(const std::string &name, double defaultValue)
bool isCategoryOf(VrmlNodeCategory category)
std::vector< VrmlProtoInstancePtr > extraJointNodes
boost::intrusive_ptr< VrmlProto > VrmlProtoPtr
void checkHardwareComponentProto()
typedef void(PNGAPI *png_error_ptr) PNGARG((png_structp
void load(const std::string &filename)
void checkExtraJointProto()
std::bitset< NUM_PROTOS > ProtoIdSet
VRML node which is instance of VRML Prototype.
void checkSensorProtoCommon()
void checkFieldType(const std::string &name, VrmlFieldTypeId type)
boost::intrusive_ptr< VrmlNode > VrmlNodePtr
std::string getFullMessage()
bool loadModelFile(const std::string &filename)
void extractHumanoidNode(VrmlParser &parser)
VrmlProtoPtr protoToCheck
boost::array< SFFloat, 3 > SFVec3f
Parser for VRML97 format.
void putMessage(const std::string &message)
JointNodeSetPtr rootJointNodeSet()
VrmlProtoInstancePtr humanoidNode()
boost::shared_ptr< JointNodeSet > JointNodeSetPtr
ModelNodeSetImpl(ModelNodeSet *self)
void requireField(const std::string &name, VrmlFieldTypeId type)
boost::signal< void(const std::string &message)> sigMessage
void checkHumanoidProto()
VrmlVariantField * addField(const std::string &name, VrmlFieldTypeId type)
The header file of a text scanner class.
void throwExceptionOfIllegalField(const std::string &name, VrmlFieldTypeId typeId)
bool loadModelFile(const std::string &filename)