Esempio n. 1
0
bool
Action::ValueDescConnect::is_candidate(const ParamList &x)
{
	if(candidate_check(get_param_vocab(),x))
	{
	    ValueDesc value_desc(x.find("dest")->second.get_value_desc());
	    ValueNode::Handle value_node(x.find("src")->second.get_value_node());

	    //! forbid recursive linking (fix #48)
	    if (value_desc.parent_is_value_node())
	    {
	        ValueNode* vn = dynamic_cast<ValueNode*>(value_node.get());
	        if (vn && vn->is_descendant(value_desc.get_parent_value_node()))
	            return false;
	    }


		// don't show the option of connecting to an existing Index parameter of the Duplicate layer
		if(x.count("dest"))
		{
			if (value_desc.parent_is_layer() &&
				value_desc.get_layer()->get_name() == "duplicate" &&
				value_desc.get_param_name() == "index")
				return false;
		}

		if(x.count("src"))
		{
			if(value_desc.get_value_type()==value_node->get_type())
				return true;
		}
		return true;
	}
	return false;
}
status_t
ValueNodeManager::AddChildNodes(ValueNodeChild* nodeChild)
{
	AutoLocker<ValueNodeContainer> containerLocker(fContainer);

	// create a value node for the value node child, if doesn't have one yet
	ValueNode* valueNode = nodeChild->Node();
	if (valueNode == NULL) {
		status_t error = _CreateValueNode(nodeChild);
		if (error != B_OK)
			return error;
		valueNode = nodeChild->Node();
	}

	// check if this node requires child creation
	// to be deferred until after its location/value have been resolved
	if (valueNode->ChildCreationNeedsValue())
		return B_OK;

	// create the children, if not done yet
	if (valueNode->ChildrenCreated())
		return B_OK;

	return valueNode->CreateChildren();
}
Esempio n. 3
0
void
VariablesView::_RequestNodeValue(ModelNode* node)
{
	// get the node child and its container
	ValueNodeChild* nodeChild = node->NodeChild();
	ValueNodeContainer* container = nodeChild->Container();

	BReference<ValueNodeContainer> containerReference(container);
	AutoLocker<ValueNodeContainer> containerLocker(container);

	if (container == NULL || nodeChild->Container() != container)
		return;

	// get the value node and check whether its value has not yet been resolved
	ValueNode* valueNode = nodeChild->Node();
	if (valueNode == NULL
		|| valueNode->LocationAndValueResolutionState()
			!= VALUE_NODE_UNRESOLVED) {
		return;
	}

	BReference<ValueNode> valueNodeReference(valueNode);
	containerLocker.Unlock();

	// request resolution of the value
	fListener->ValueNodeValueRequested(fStackFrame->GetCpuState(), container,
		valueNode);
}
Esempio n. 4
0
status_t
VariablesView::VariableTableModel::_AddNode(Variable* variable,
	ModelNode* parent, ValueNodeChild* nodeChild, bool isPresentationNode)
{
	// Don't create nodes for unspecified types -- we can't get/show their
	// value anyway.
	Type* nodeChildRawType = nodeChild->GetType()->ResolveRawType(false);
	if (nodeChildRawType->Kind() == TYPE_UNSPECIFIED)
		return B_OK;

	ModelNode* node = new(std::nothrow) ModelNode(parent, variable, nodeChild,
		isPresentationNode);
	BReference<ModelNode> nodeReference(node, true);
	if (node == NULL || node->Init() != B_OK)
		return B_NO_MEMORY;

	int32 childIndex;

	if (parent != NULL) {
		childIndex = parent->CountChildren();

		if (!parent->AddChild(node))
			return B_NO_MEMORY;
		// the parent has a reference, now
	} else {
		childIndex = fNodes.CountItems();

		if (!fNodes.AddItem(node))
			return B_NO_MEMORY;
		nodeReference.Detach();
			// the fNodes list has a reference, now
	}

	fNodeTable.Insert(node);

	// mark a compound type child of a address type parent hidden
	if (parent != NULL) {
		ValueNode* parentValueNode = parent->NodeChild()->Node();
		if (parentValueNode != NULL
			&& parentValueNode->GetType()->ResolveRawType(false)->Kind()
				== TYPE_ADDRESS
			&& nodeChildRawType->Kind() == TYPE_COMPOUND) {
			node->SetHidden(true);
		}
	}

	// notify table model listeners
	if (!node->IsHidden()) {
		TreeTablePath path;
		if (parent == NULL || _GetTreePath(parent, path))
			NotifyNodesAdded(path, childIndex, 1);
	}

	// if the node is hidden, add its children
	if (node->IsHidden())
		_AddChildNodes(nodeChild);

	return B_OK;
}
Esempio n. 5
0
TLCIter
Reduce(ValueNode& node, TLCIter b, TLCIter e)
{
	while(b != e && *b != ")")
		if(*b == "(")
		{
			auto nd(MakeNode(to_string(node.GetSize())));
			auto res(Reduce(nd, ++b, e));

			if(res == e || *res != ")")
				throw LoggedEvent("Redundant '(' found.", Alert);
			node += std::move(nd);
			b = ++res;
		}
		else
			node += {0, to_string(node.GetSize()), *b++};
	return b;
}
Esempio n. 6
0
status_t
VariablesView::VariableTableModel::_AddChildNodes(ValueNodeChild* nodeChild)
{
	// create a value node for the value node child, if doesn't have one yet
	ValueNode* valueNode = nodeChild->Node();
	if (valueNode == NULL) {
		status_t error = _CreateValueNode(nodeChild);
		if (error != B_OK)
			return error;
		valueNode = nodeChild->Node();
	}

	// create the children, if not done yet
	if (valueNode->ChildrenCreated())
		return B_OK;

	return valueNode->CreateChildren();
}
Esempio n. 7
0
void YAMLReaderImpl::addNode(ValueNode* node, yaml_event_t& event)
{
    NodeInfo& info = nodeStack.top();
    ValueNode* parent = info.node;

    if(parent->isListing()){
        Listing* listing = static_cast<Listing*>(parent);
        listing->append(node);

    } else if(parent->isMapping()){

        Mapping* mapping = static_cast<Mapping*>(parent);

        if(info.key == "<<"){
            if(node->isMapping()){
                mapping->insert(static_cast<Mapping*>(node));
            } else if(node->isListing()){
                Listing* listing = static_cast<Listing*>(node);
                for(auto& element : *listing){
                    if(element->isMapping()){
                        mapping->insert(static_cast<Mapping*>(element.get()));
                    } else {
                        ValueNode::SyntaxException ex;
                        ex.setMessage(_("An element to merge by the \"<<\" key must be a mapping"));
                        const yaml_mark_t& start_mark = event.start_mark;
                        ex.setPosition(start_mark.line, start_mark.column);
                        throw ex;
                    }
                }
            } else {
                ValueNode::SyntaxException ex;
                ex.setMessage(_("A value to merge by the \"<<\" key must be mapping or listing"));
                const yaml_mark_t& start_mark = event.start_mark;
                ex.setPosition(start_mark.line, start_mark.column);
                throw ex;
            }
        }
        
        mapping->insert(info.key, node);
        info.key.clear();
    }
}
Esempio n. 8
0
ValueNode
TransformNPLA1(const ValueNode& node, std::function<NodeMapper> mapper)
{
	auto s(node.GetSize());

	if(s == 0)
		return {0, "", node ? Deliteralize(Access<string>(node)) : string()};

	auto i(node.begin());

	if(s == 1)
		return TransformNPLA1(*i, mapper);

	const auto& name(ParseNPLANodeString(*i));

	if(!name.empty())
		yunseq(++i, --s);
	if(s == 1)
	{
		auto&& n(TransformNPLA1(*i, mapper));

		if(n.GetName().empty())
			return {0, name, std::move(n.Value)};
		return {ValueNode::Container{std::move(n)}, name};
	}

	auto p_node_con(make_unique<ValueNode::Container>());

	std::for_each(i, node.end(), [&](const ValueNode& nd){
		auto&& n(mapper ? mapper(nd) : TransformNPLA1(nd, mapper));

		p_node_con->insert(n.GetName().empty() ? ValueNode(0,
			'$' + std::to_string(p_node_con->size()), std::move(n.Value))
			: std::move(n));
	});
	return {std::move(p_node_con), name};
}
status_t
ValueNodeManager::_CreateValueNode(ValueNodeChild* nodeChild)
{
	if (nodeChild->Node() != NULL)
		return B_OK;

	// create the node
	ValueNode* valueNode;
	status_t error;
	if (nodeChild->IsInternal()) {
		error = nodeChild->CreateInternalNode(valueNode);
	} else {
		error = TypeHandlerRoster::Default()->CreateValueNode(nodeChild,
			nodeChild->GetType(), valueNode);
	}

	if (error != B_OK)
		return error;

	nodeChild->SetNode(valueNode);
	valueNode->ReleaseReference();

	return B_OK;
}
Esempio n. 10
0
void
PrintNode(std::ostream& os, const ValueNode& node, NodeToString node_to_str,
	IndentGenerator igen, size_t depth)
{
	PrintIndent(os, igen, depth);
	os << EscapeLiteral(DecodeNodeIndex(node.GetName())) << ' ';

	const auto print_node_str(std::bind(PrintNodeString, std::ref(os),
		std::placeholders::_1, std::ref(node_to_str)));

	if(print_node_str(node))
		return;
	os << '\n';
	if(node)
		TraverseNodeChildAndPrint(os, node, [&]{
			PrintIndent(os, igen, depth);
		}, print_node_str, [&](const ValueNode& nd){
			return PrintNode(os, nd, node_to_str, igen, depth + 1);
		});
}
Esempio n. 11
0
void
AddMIMEItems(MIMEBiMapping& m, const ValueNode& node,
	MIMEBiMapping::MIMEType&& pth)
{
	if(node.GetContainerPtr())
		for(auto& nd : node)
			try
			{
				pth.push_back(nd.GetName());
				AddMIMEItems(m, nd, std::move(pth));
				pth.pop_back();
			}
			catch(ystdex::bad_any_cast&)
			{}
	else
		try
		{
			m += {Access<string>(node), !pth.empty()
				&& IsPrefixedIndex(pth.back()) ? MIMEBiMapping::MIMEType{
				pth.cbegin(), std::prev(pth.cend())} : pth};
		}
		catch(ystdex::bad_any_cast&)
		{}
}
Esempio n. 12
0
void GlslGeneratorInstance::PrintNodeInit(size_t nodeIndex)
{
	Node* node = nodeInits[nodeIndex];

	switch(node->GetType())
	{
	case Node::typeFloatConst:
		PrintNodeInitBegin(nodeIndex);
		text << std::fixed << std::setprecision(10) << fast_cast<FloatConstNode*>(node)->GetValue();// << 'f';
		PrintNodeInitEnd();
		break;
	case Node::typeIntConst:
		PrintNodeInitBegin(nodeIndex);
		text << fast_cast<IntConstNode*>(node)->GetValue();
		PrintNodeInitEnd();
		break;
	case Node::typeAttribute:
		{
			AttributeNode* attributeNode = fast_cast<AttributeNode*>(node);
			PrintNodeInitBegin(nodeIndex);
			// WebGL hack for integer attributes
			// (only for case of using another hack - changing integer attributes to float)
			bool intConversion = false;
			if(glslVersion == GlslVersions::webgl)
				intConversion = PrintWebGLConversionToIntegerBegin(attributeNode->GetValueType());

			text << "a" << attributeNode->GetElementIndex();

			if(intConversion)
				PrintWebGLConversionToIntegerEnd();
			PrintNodeInitEnd();
		}
		break;
	case Node::typeUniform:
		// uniform doesn't have initialization
		break;
	case Node::typeSampler:
		// sampler doesn't have initialization
		break;
	case Node::typeReadUniform:
		{
			PrintNodeInitBegin(nodeIndex);
			ReadUniformNode* readUniformNode = fast_cast<ReadUniformNode*>(node);
			PrintUniform(readUniformNode->GetUniformNode());
			PrintNodeInitEnd();
		}
		break;
	case Node::typeIndexUniformArray:
		{
			PrintNodeInitBegin(nodeIndex);
			IndexUniformArrayNode* indexUniformArrayNode = fast_cast<IndexUniformArrayNode*>(node);
			PrintUniform(indexUniformArrayNode->GetUniformNode());
			text << '[';
			PrintNode(indexUniformArrayNode->GetIndexNode());
			text << ']';
			PrintNodeInitEnd();
		}
		break;
	case Node::typeTransformed:
		PrintNodeInitBegin(nodeIndex);
		text << "v" << fast_cast<TransformedNode*>(node)->GetSemantic();
		PrintNodeInitEnd();
		break;
	case Node::typeInterpolate:
		{
			InterpolateNode* interpolateNode = fast_cast<InterpolateNode*>(node);
			text << "\tv" << interpolateNode->GetSemantic() << " = ";
			PrintNode(interpolateNode->GetNode());
			PrintNodeInitEnd();
		}
		break;
	case Node::typeSequence:
		// sequence node doesn't have initialization
		break;
	case Node::typeSwizzle:
		{
			PrintNodeInitBegin(nodeIndex);
			SwizzleNode* swizzleNode = fast_cast<SwizzleNode*>(node);
			PrintNode(swizzleNode->GetA());
			text << '.' << swizzleNode->GetMap();
			PrintNodeInitEnd();
		}
		break;
	case Node::typeOperation:
		PrintNodeInitBegin(nodeIndex);
		PrintOperationNodeInit(fast_cast<OperationNode*>(node));
		PrintNodeInitEnd();
		break;
	case Node::typeAction:
		PrintActionNodeInit(fast_cast<ActionNode*>(node));
		break;
	case Node::typeSample:
		{
			PrintNodeInitBegin(nodeIndex);

			SampleNode* sampleNode = fast_cast<SampleNode*>(node);

			int slot = sampleNode->GetSamplerNode()->GetSlot();

			ValueNode* coordsNode = sampleNode->GetCoordsNode();
			ValueNode* offsetNode = sampleNode->GetOffsetNode();
			ValueNode* lodNode = sampleNode->GetLodNode();
			ValueNode* biasNode = sampleNode->GetBiasNode();
			ValueNode* gradXNode = sampleNode->GetGradXNode();
			ValueNode* gradYNode = sampleNode->GetGradYNode();

			auto printOffsetNode = [&]()
			{
				// offset node is required to be constant expression,
				// but AMD driver requires it also to be compile-time expression
				// so HACK: print value inline, only for known node
				// PrintNode(offsetNode);
				if(offsetNode->GetType() != Node::typeOperation)
					THROW("wrong offset node");
				OperationNode* offsetOperationNode = fast_cast<OperationNode*>(offsetNode);
				if(
					offsetOperationNode->GetOperation() != OperationNode::operationInt11to2 ||
					offsetOperationNode->GetA()->GetType() != Node::typeIntConst ||
					offsetOperationNode->GetB()->GetType() != Node::typeIntConst
					)
					THROW("wrong offset node");
				text << "ivec2("
					<< offsetOperationNode->GetA().FastCast<IntConstNode>()->GetValue() << ", "
					<< offsetOperationNode->GetB().FastCast<IntConstNode>()->GetValue() << ")";
			};

			if(lodNode)
			{
				text << "textureLod";
				if(offsetNode)
					text << "Offset";
				text << '(' << samplerPrefix << slot << ", ";
				PrintNode(coordsNode);
				text << ", ";
				PrintNode(lodNode);
				if(offsetNode)
				{
					text << ", ";
					printOffsetNode();
				}
			}
			else if(biasNode)
			{
				text << "texture";
				if(offsetNode)
					text << "Offset";
				text << '(' << samplerPrefix << slot << ", ";
				PrintNode(coordsNode);
				if(offsetNode)
				{
					text << ", ";
					printOffsetNode();
				}
				text << ", ";
				PrintNode(biasNode);
			}
			else if(gradXNode && gradYNode)
			{
				text << "textureGrad";
				if(offsetNode)
					text << "Offset";
				text << '(' << samplerPrefix << slot << ", ";
				PrintNode(coordsNode);
				text << ", ";
				PrintNode(gradXNode);
				text << ", ";
				PrintNode(gradYNode);
				if(offsetNode)
				{
					text << ", ";
					printOffsetNode();
				}
			}
			else
			{
				text << (glslVersion == GlslVersions::webgl ? "texture2D" : "texture");
				if(offsetNode && glslVersion != GlslVersions::webgl)
					text << "Offset";
				text << '(' << samplerPrefix << slot << ", ";
				PrintNode(coordsNode);
				if(offsetNode && glslVersion != GlslVersions::webgl)
				{
					text << ", ";
					printOffsetNode();
				}
			}

			// close sample call
			text << ')';

			// sample always returns four-component vector, so make some swizzle if needed
			int valueSize = GetVectorDataTypeDimensions(sampleNode->GetValueType());
			if(valueSize < 4)
			{
				text << '.';
				for(int i = 0; i < valueSize; ++i)
					text << "xyzw"[i];
			}

			PrintNodeInitEnd();
		}
		break;
	case Node::typeFragment:
		{
			FragmentNode* fragmentNode = fast_cast<FragmentNode*>(node);
			switch(glslVersion)
			{
			case GlslVersions::opengl33: text << "\tr" << fragmentNode->GetTarget(); break;
			case GlslVersions::webgl:
				if(fragmentTargetsCount > 1)
					text << "gl_FragData[" << fragmentNode->GetTarget() << ']';
				else
					text << "gl_FragColor";
				break;
			}
			text << " = ";
			PrintNode(fragmentNode->GetNode());
			PrintNodeInitEnd();
		}
		break;
	case Node::typeDualFragment:
		{
			DualFragmentNode* dualFragmentNode = fast_cast<DualFragmentNode*>(node);
			switch(glslVersion)
			{
			case GlslVersions::opengl33:
				text << "\tr0 = ";
				PrintNode(dualFragmentNode->GetNode0());
				PrintNodeInitEnd();
				text << "\tr1 = ";
				PrintNode(dualFragmentNode->GetNode1());
				PrintNodeInitEnd();
				break;
			case GlslVersions::webgl:
				text << "\tgl_FragData[0] = ";
				PrintNode(dualFragmentNode->GetNode0());
				PrintNodeInitEnd();
				text << "\tgl_FragData[1] = ";
				PrintNode(dualFragmentNode->GetNode1());
				PrintNodeInitEnd();
				break;
			}
		}
		break;
	case Node::typeCast:
		{
			PrintNodeInitBegin(nodeIndex);
			CastNode* castNode = fast_cast<CastNode*>(node);
			PrintDataType(castNode->GetValueType());
			text << '(';
			PrintNode(castNode->GetA());
			text << ')';
			PrintNodeInitEnd();
		}
		break;
	default:
		THROW("Unknown node type");
	}
}
Esempio n. 13
0
status_t
ResolveValueNodeValueJob::_ResolveNodeValue()
{
    // get the node child and parent node
    AutoLocker<ValueNodeContainer> containerLocker(fContainer);
    ValueNodeChild* nodeChild = fValueNode->NodeChild();
    BReference<ValueNodeChild> nodeChildReference(nodeChild);

    ValueNode* parentNode = nodeChild->Parent();
    BReference<ValueNode> parentNodeReference(parentNode);

    // Check whether the node child location has been resolved already
    // (successfully).
    status_t nodeChildResolutionState = nodeChild->LocationResolutionState();
    bool nodeChildDone = nodeChildResolutionState != VALUE_NODE_UNRESOLVED;
    if (nodeChildDone && nodeChildResolutionState != B_OK)
        return nodeChildResolutionState;

    // If the child node location has not been resolved yet, check whether the
    // parent node location and value have been resolved already (successfully).
    bool parentDone = true;
    if (!nodeChildDone && parentNode != NULL) {
        status_t parentResolutionState
            = parentNode->LocationAndValueResolutionState();
        parentDone = parentResolutionState != VALUE_NODE_UNRESOLVED;
        if (parentDone && parentResolutionState != B_OK)
            return parentResolutionState;
    }

    containerLocker.Unlock();

    // resolve the parent node location and value, if necessary
    if (!parentDone) {
        status_t error = _ResolveParentNodeValue(parentNode);
        if (error != B_OK) {
            TRACE_LOCALS("ResolveValueNodeValueJob::_ResolveNodeValue(): value "
                         "node: %p (\"%s\"): _ResolveParentNodeValue(%p) failed\n",
                         fValueNode, fValueNode->Name().String(), parentNode);
            return error;
        }
    }

    // resolve the node child location, if necessary
    if (!nodeChildDone) {
        status_t error = _ResolveNodeChildLocation(nodeChild);
        if (error != B_OK) {
            TRACE_LOCALS("ResolveValueNodeValueJob::_ResolveNodeValue(): value "
                         "node: %p (\"%s\"): _ResolveNodeChildLocation(%p) failed\n",
                         fValueNode, fValueNode->Name().String(), nodeChild);
            return error;
        }
    }

    // resolve the node location and value
    ValueLoader valueLoader(fArchitecture, fDebuggerInterface,
                            fTypeInformation, fCpuState);
    ValueLocation* location;
    Value* value;
    status_t error = fValueNode->ResolvedLocationAndValue(&valueLoader,
                     location, value);
    if (error != B_OK) {
        TRACE_LOCALS("ResolveValueNodeValueJob::_ResolveNodeValue(): value "
                     "node: %p (\"%s\"): fValueNode->ResolvedLocationAndValue() "
                     "failed\n", fValueNode, fValueNode->Name().String());
        return error;
    }
    BReference<ValueLocation> locationReference(location, true);
    BReference<Value> valueReference(value, true);

    // set location and value on the node
    containerLocker.Lock();
    status_t nodeResolutionState
        = fValueNode->LocationAndValueResolutionState();
    if (nodeResolutionState != VALUE_NODE_UNRESOLVED)
        return nodeResolutionState;
    fValueNode->SetLocationAndValue(location, value, B_OK);
    containerLocker.Unlock();

    return B_OK;
}
Esempio n. 14
0
bool BodyLoaderImpl::load(Body* body, const std::string& filename)
{
    bool result = false;

    filesystem::path orgpath(filename);
    string ext = getExtension(orgpath);
    string modelFilename;
    MappingPtr yamlDoc;

    try {
        if(ext != "yaml"){
            modelFilename = filename;
        } else {
            YAMLReader parser;
            yamlDoc = parser.loadDocument(filename)->toMapping();

            ValueNode* modelFileNode = yamlDoc->find("modelFile");
            if(modelFileNode->isValid()){
                filesystem::path mpath(modelFileNode->toString());
                if(mpath.has_root_path()){
                    modelFilename = getNativePathString(mpath);
                } else {
                    modelFilename = getNativePathString(orgpath.parent_path() / mpath);
                }
                ext = getExtension(mpath);
            }
        }

        LoaderMap::iterator p = loaderMap.find(ext);
        if(p != loaderMap.end()){
            loader = p->second;
        } else {
            boost::lock_guard<boost::mutex> lock(loaderFactoryMapMutex);
            LoaderFactoryMap::iterator q = loaderFactoryMap.find(ext);
            if(q != loaderFactoryMap.end()){
                LoaderFactory factory = q->second;
                loader = factory();
                loaderMap[ext] = loader;
            }
        }

        if(!loader){
            (*os) << str(boost::format(_("The file format of \"%1%\" is not supported by the body loader.\n"))
                         % getFilename(filesystem::path(modelFilename)));

        } else {
            loader->setMessageSink(*os);
            loader->setVerbose(isVerbose);
            loader->setShapeLoadingEnabled(isShapeLoadingEnabled);

            YAMLBodyLoader* yamlBodyLoader = 0;
            if(yamlDoc){
                YAMLBodyLoader* yamlBodyLoader = dynamic_cast<YAMLBodyLoader*>(loader.get());
            }

            if(yamlBodyLoader){
                result = yamlBodyLoader->read(body, yamlDoc);

            } else {
                int dn = defaultDivisionNumber;
                if(yamlDoc){
                    Mapping& geometryInfo = *yamlDoc->findMapping("geometry");
                    if(geometryInfo.isValid()){
                        geometryInfo.read("divisionNumber", dn);
                    }
                }
                if(dn > 0){
                    loader->setDefaultDivisionNumber(dn);
                }

                if(defaultCreaseAngle >= 0.0){
                    loader->setDefaultCreaseAngle(defaultCreaseAngle);
                }
            
                if(yamlDoc){
                    body->resetInfo(yamlDoc);
                } else {
                    body->info()->clear();
                }

                result = loader->load(body, modelFilename);
            }
        }
        
    } catch(const ValueNode::Exception& ex){
        (*os) << ex.message();
    } catch(const nonexistent_key_error& error){
        if(const std::string* message = boost::get_error_info<error_info_message>(error)){
            (*os) << *message;
        }
    } catch(const std::exception& ex){
        (*os) << ex.what();
    }
    os->flush();
    
    return result;
}
Esempio n. 15
0
bool PoseSeqItem::convertSub(BodyPtr orgBody, const Mapping& convInfo)
{
    bool converted = false;
    
    const Listing& jointMap = *convInfo.findListing("jointMap");
    const Mapping& linkMap = *convInfo.findMapping("linkMap");
    BodyPtr body = ownerBodyItem->body();
    
    for(PoseSeq::iterator p = seq->begin(); p != seq->end(); ++p){
        PosePtr pose = p->get<Pose>();
        if(pose){

            bool modified = false;
            seq->beginPoseModification(p);
                
            PosePtr orgPose = dynamic_cast<Pose*>(pose->duplicate());
            if(jointMap.isValid()){
                modified = true;
                pose->setNumJoints(0);
                int n = orgPose->numJoints();
                for(int i=0; i < n; ++i){
                    if(orgPose->isJointValid(i)){
                        if(i < jointMap.size()){
                            int newJointId = jointMap[i].toInt();
                            if(newJointId >= 0){
                                pose->setJointPosition(newJointId, orgPose->jointPosition(i));
                                pose->setJointStationaryPoint(newJointId, orgPose->isJointStationaryPoint(i));
                            }
                        }
                    }
                }
            }

            if(linkMap.isValid()){
                modified = true;
                pose->clearIkLinks();
                int baseLinkIndex = -1;
                for(Pose::LinkInfoMap::const_iterator q = orgPose->ikLinkBegin(); q != orgPose->ikLinkEnd(); ++q){
                    Link* orgLink = orgBody->link(q->first);
                    string linkName;
                    ValueNode* linkNameNode = linkMap.find(orgLink->name());
                    if(linkNameNode->isValid()){
                        linkName = linkNameNode->toString();
                    } else {
                        linkName = orgLink->name();
                    }
                    Link* link = body->link(linkName);
                    if(link){
                        const Pose::LinkInfo& orgLinkInfo = q->second;
                        Pose::LinkInfo* linkInfo = pose->addIkLink(link->index());
                        linkInfo->p = orgLinkInfo.p;
                        linkInfo->R = orgLinkInfo.R;
                        linkInfo->setStationaryPoint(orgLinkInfo.isStationaryPoint());
                        if(orgLinkInfo.isTouching()){
                            linkInfo->setTouching(orgLinkInfo.partingDirection());
                        }
                        linkInfo->setSlave(orgLinkInfo.isSlave());
                        if(orgLinkInfo.isBaseLink()){
                            baseLinkIndex = link->index();
                        }
                    }
                }
                if(baseLinkIndex >= 0){
                    pose->setBaseLink(baseLinkIndex);
                }
            }

            if(modified){
                seq->endPoseModification(p);
                converted = true;
            }
        }
    }

    return converted;
}