Exemple #1
0
/// Get parent node (or NULL if no hierarchy or for root node)
sofa::core::objectmodel::BaseNode::Children Node::getChildren() const
{
    Children list_children;
    list_children.reserve(child.size());
    for (ChildIterator it = child.begin(), itend = child.end(); it != itend; ++it)
        list_children.push_back(it->get());
    return list_children;
}
Exemple #2
0
/// Find a child node given its name
Node* Node::getChild(const std::string& name) const
{
//    cerr<<"Node::getChild, in "<< getName() << ", looking for " << name << endl;
    for (ChildIterator it = child.begin(), itend = child.end(); it != itend; ++it)
    {
//        cerr<<"Node::getChild, see " << (*it)->getName() << endl;
        if ((*it)->getName() == name)
            return it->get();
    }
    return NULL;
}
Exemple #3
0
void Box::exportForReference( const std::string &fileName ) const
{
	const ScriptNode *script = scriptNode();
	if( !script )
	{
		throw IECore::Exception( "Box::exportForReference called without ScriptNode" );
	}

	// we only want to save out our child nodes and plugs that are visible in the UI, so we build a filter
	// to specify just the things to export.

	boost::regex invisiblePlug( "^__.*$" );
	StandardSetPtr toExport = new StandardSet;
	for( ChildIterator it = children().begin(), eIt = children().end(); it != eIt; ++it )
	{
		if( (*it)->isInstanceOf( Node::staticTypeId() ) )
		{
			toExport->add( *it );
		}
		else if( const Plug *plug = IECore::runTimeCast<Plug>( it->get() ) )
		{
			if( !boost::regex_match( plug->getName().c_str(), invisiblePlug ) )
			{
				toExport->add( *it );
			}
		}
	}

	ContextPtr context = new Context;
	context->set( "valuePlugSerialiser:resetParentPlugDefaults", true );
	context->set( "serialiser:includeParentMetadata", true );
	context->set( "serialiser:includeVersionMetadata", true );
	Context::Scope scopedContext( context.get() );

	script->serialiseToFile( fileName, this, toExport.get() );
}