本文整理汇总了C++中node::SPtr类的典型用法代码示例。如果您正苦于以下问题:C++ SPtr类的具体用法?C++ SPtr怎么用?C++ SPtr使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SPtr类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: checkDeprecatedAttribute
void checkDeprecatedAttribute()
{
EXPECT_MSG_EMIT(Deprecated) ;
std::stringstream scene ;
scene << "<?xml version='1.0'?>"
"<Node name='Root' gravity='0 -9.81 0' time='0' animate='0' > \n"
" <OglLabel name='label1' color='contrast' printLog='true'/> \n"
"</Node> \n" ;
Node::SPtr root = SceneLoaderXML::loadFromMemory ("testscene",
scene.str().c_str(),
scene.str().size()) ;
ASSERT_NE(nullptr, root.get()) ;
root->init(ExecParams::defaultInstance()) ;
BaseObject* lm = root->getObject("label1") ;
ASSERT_NE(nullptr, lm) ;
OglLabel* ogllabel = dynamic_cast<OglLabel*>(lm);
ASSERT_NE(nullptr, ogllabel) ;
EXPECT_TRUE(ogllabel->d_selectContrastingColor.getValue()) ;
EXPECT_EQ(RGBAColor::fromFloat(1,1,1,1), ogllabel->d_color.getValue()) ;
}
开发者ID:david-cazier,项目名称:sofa,代码行数:27,代码来源:OglLabel_test.cpp
示例2: addNew
typename Component::SPtr addNew( Node::SPtr parentNode, std::string name="" )
{
typename Component::SPtr component = New<Component>();
parentNode->addObject(component);
component->setName(parentNode->getName()+"_"+name);
return component;
}
开发者ID:ricortiz,项目名称:SOFAFramework,代码行数:7,代码来源:compositeObject.cpp
示例3: fileOpen
void SofaModeler::fileOpen(std::string filename)
{
if ( sofa::helper::system::DataRepository.findFile ( filename ) )
{
filename = sofa::helper::system::DataRepository.getFile ( filename );
openPath = sofa::helper::system::SetDirectory::GetParentDir(filename.c_str());
Node::SPtr root = NULL;
root = down_cast<sofa::simulation::Node>( sofa::simulation::getSimulation()->load(filename.c_str()).get() );
if (root)
{
createTab();
fileNew(root.get());
sceneTab->setCurrentIndex(sceneTab->count()-1);
graph->setFilename(filename);
changeTabName(graph,QString(sofa::helper::system::SetDirectory::GetFileName(filename.c_str()).c_str()));
changeNameWindow(graph->getFilename());
QAction* act = windowMenu->addAction(graph->getFilename().c_str());
mapWindow.insert(std::make_pair(act, tabGraph));
recentlyOpenedFilesManager.openFile(filename);
}
}
displayHelpModeler();
}
开发者ID:151706061,项目名称:sofa,代码行数:25,代码来源:SofaModeler.cpp
示例4: checkAttributes
void checkAttributes()
{
std::stringstream scene ;
scene << "<?xml version='1.0'?>"
"<Node name='Root' gravity='0 -9.81 0' time='0' animate='0' > \n"
" <OglLabel name='label1'/> \n"
"</Node> \n" ;
Node::SPtr root = SceneLoaderXML::loadFromMemory ("testscene",
scene.str().c_str(),
scene.str().size()) ;
ASSERT_NE(root.get(), nullptr) ;
root->init(ExecParams::defaultInstance()) ;
BaseObject* lm = root->getObject("label1") ;
ASSERT_NE(lm, nullptr) ;
/// List of the supported attributes the user expect to find
/// This list needs to be updated if you add an attribute.
vector<string> attrnames = {
"prefix", "label", "suffix", "x", "y", "fontsize", "color",
"selectContrastingColor", "updateLabelEveryNbSteps",
"visible"};
for(auto& attrname : attrnames)
EXPECT_NE( lm->findData(attrname), nullptr ) << "Missing attribute with name '" << attrname << "'." ;
}
开发者ID:david-cazier,项目名称:sofa,代码行数:28,代码来源:OglLabel_test.cpp
示例5: buildNodeFromBaseElement
Node::SPtr GraphModeler::buildNodeFromBaseElement(Node::SPtr node,xml::BaseElement *elem, bool saveHistory)
{
const bool displayWarning=true;
Node::SPtr newNode = Node::create("");
//Configure the new Node
configureElement(newNode.get(), elem);
if (newNode->getName() == "Group")
{
//We can't use the parent node, as it is null
if (!node) return NULL;
//delete newNode;
newNode = node;
}
else
{
// if (node)
{
//Add as a child
addNode(node,newNode,saveHistory);
}
}
typedef xml::BaseElement::child_iterator<> elem_iterator;
for (elem_iterator it=elem->begin(); it != elem->end(); ++it)
{
if (std::string(it->getClass()) == std::string("Node"))
{
buildNodeFromBaseElement(newNode, it,true);
}
else
{
const ComponentLibrary *component = sofaLibrary->getComponent(it->getType());
//Configure the new Component
const std::string templateAttribute("template");
std::string templatename;
templatename = it->getAttribute(templateAttribute, "");
const ClassEntry::SPtr info = component->getEntry();
BaseObject::SPtr newComponent=addComponent(newNode, info, templatename, saveHistory,displayWarning);
if (!newComponent) continue;
configureElement(newComponent.get(), it);
QTreeWidgetItem* itemGraph = graphListener->items[newComponent.get()];
std::string name=itemGraph->text(0).toStdString();
std::string::size_type pos = name.find(' ');
if (pos != std::string::npos) name.resize(pos);
name += " ";
name+=newComponent->getName();
itemGraph->setText(0,name.c_str());
}
}
newNode->clearWarnings();
return newNode;
}
开发者ID:FabienPean,项目名称:sofa,代码行数:59,代码来源:GraphModeler.cpp
示例6: build
OSG::NodeTransitPtr OSGSofaShadowGraph::build(
Node::SPtr root,
bool ignoreLights )
{
_scene = NULL;
_chunkOverrideGroup = NULL;
_shadowStage = NULL;
VisualParams* vparams = VisualParams::defaultInstance();
OSG::NodeUnrecPtr shadowStageNode;
_chunkOverrideGroup = OSG::ChunkOverrideGroup::create();
_scene = OSG::makeNodeFor(_chunkOverrideGroup);
sofa::simulation::OSGVisualUpdateVisitor vm_visitor( vparams);
vm_visitor.setChunkOverrideGroupNode(_scene);
// get lights
if (!ignoreLights)
{
if (!_shadowStage)
_shadowStage = OSG::ShadowStage::create();
_shadowStage->setMapSize(1024);
_shadowStage->setShadowSmoothness(0.5f);
_shadowStage->setShadowMode(OSG::ShadowStage::NO_SHADOW);
_shadowStage->setAutoSearchForLights(true);
shadowStageNode = OSG::makeNodeFor(_shadowStage);
sofa::simulation::OSGLightVisitor light_visitor( vparams);
//light_visitor.setTurnOffLights(ignoreLights);
light_visitor.setOSG2Parent(_scene);
light_visitor.setOSG2ShadowStage(_shadowStage);
light_visitor.setAttachNode(_scene);
root->execute(&light_visitor);
if (light_visitor.getAttachNode())
{
vm_visitor.setOSG2Parent(light_visitor.getAttachNode());
root->execute(&vm_visitor);
}
}
else
{
vm_visitor.setOSG2Parent(_scene);
root->execute(&vm_visitor);
}
if (shadowStageNode && !ignoreLights)
{
shadowStageNode->addChild(_scene);
return OSG::NodeTransitPtr(shadowStageNode);
}
return OSG::NodeTransitPtr(_scene);
}
开发者ID:chengzg,项目名称:OSGAddOnsGV,代码行数:58,代码来源:OSGSofaShadowGraph.cpp
示例7: loadFromAFileForNonRigid
void loadFromAFileForNonRigid(){
string scene =
"<?xml version='1.0'?>"
"<Node name='Root' gravity='0 0 0' time='0' animate='0' > "
" <MechanicalObject position='0 0 0'/> "
" <UniformMass filename='BehaviorModels/card.rigid'/> "
"</Node> " ;
Node::SPtr root = SceneLoaderXML::loadFromMemory ("loadFromAValidFile",
scene.c_str(), (int)scene.size()) ;
root->init(ExecParams::defaultInstance()) ;
}
开发者ID:FabienPean,项目名称:sofa,代码行数:11,代码来源:UniformMass_test.cpp
示例8: loadFromAnInvalidPathname
void loadFromAnInvalidPathname(){
string scene =
"<?xml version='1.0'?>"
"<Node name='Root' gravity='0 0 0' time='0' animate='0' > "
" <MechanicalObject position='0 0 0'/> "
" <UniformMass filename='invalid_uniformmatrix.txt'/> "
"</Node> " ;
Node::SPtr root = SceneLoaderXML::loadFromMemory ("loadFromAnInValidFile",
scene.c_str(), (int)scene.size()) ;
root->init(ExecParams::defaultInstance()) ;
}
开发者ID:FabienPean,项目名称:sofa,代码行数:11,代码来源:UniformMass_test.cpp
示例9: createRootNode
Node::SPtr createRootNode(Simulation::SPtr s, const std::string& name,
const std::map<std::string, std::string>& params)
{
Node::SPtr root = s->createNewNode(name) ;
BaseObjectDescription desc(name.c_str(), "Node");
for(auto& kv : params)
{
desc.setAttribute(kv.first.c_str(), kv.second);
}
root->parse(&desc) ;
return root ;
}
开发者ID:fredroy,项目名称:sofa,代码行数:14,代码来源:SimpleApi.cpp
示例10: processXML
/// Load a scene from a file
Node::SPtr SceneLoaderXML::processXML(xml::BaseElement* xml, const char *filename)
{
loadSucceed = true;
if ( xml==NULL )
{
return NULL;
}
sofa::core::ExecParams* params = sofa::core::ExecParams::defaultInstance();
// We go the the current file's directory so that all relative path are correct
helper::system::SetDirectory chdir ( filename );
// Temporarily set the numeric formatting locale to ensure that
// floating-point values are interpreted correctly by tinyXML. (I.e. the
// decimal separator is a dot '.').
helper::system::TemporaryLocale locale(LC_NUMERIC, "C");
sofa::simulation::xml::NodeElement* nodeElt = dynamic_cast<sofa::simulation::xml::NodeElement *>(xml);
if( nodeElt==NULL )
{
std::cerr << "LOAD ERROR: XML Root Node is not an Element."<<std::endl;
loadSucceed = false;
std::exit(EXIT_FAILURE);
}
else if( !(nodeElt->init()) )
{
std::cerr << "LOAD ERROR: Node initialization failed."<<std::endl;
loadSucceed = false;
}
core::objectmodel::BaseNode* baseroot = xml->getObject()->toBaseNode();
if ( baseroot == NULL )
{
std::cerr << "LOAD ERROR: Objects initialization failed."<<std::endl;
loadSucceed = false;
return NULL;
}
Node::SPtr root = down_cast<Node> ( baseroot );
// Find the Simulation component in the scene
FindByTypeVisitor<Simulation> findSimu(params);
findSimu.execute(root.get());
if( !findSimu.found.empty() )
setSimulation( findSimu.found[0] );
return root;
}
开发者ID:ejeanvoi,项目名称:sofa-kernel-cleaned,代码行数:50,代码来源:SceneLoaderXML.cpp
示例11: processNodeBottomUp
void DeleteVisitor::processNodeBottomUp(Node* node)
{
while (!node->child.empty())
{
Node::SPtr child = *node->child.begin();
node->removeChild(child);
child.reset();
}
while (!node->object.empty())
{
core::objectmodel::BaseObject::SPtr object = *node->object.begin();
node->removeObject(object);
object.reset();
}
}
开发者ID:david-cazier,项目名称:sofa,代码行数:15,代码来源:DeleteVisitor.cpp
示例12: createObject
BaseObject::SPtr createObject(Node::SPtr parent, BaseObjectDescription& desc)
{
/// Create the object.
BaseObject::SPtr obj = ObjectFactory::getInstance()->createObject(parent.get(), &desc);
if (obj==nullptr)
{
std::stringstream msg;
msg << "Component '" << desc.getName() << "' of type '" << desc.getAttribute("type","") << "' failed:" << msgendl ;
for (std::vector< std::string >::const_iterator it = desc.getErrors().begin(); it != desc.getErrors().end(); ++it)
msg << " " << *it << msgendl ;
msg_error(parent.get()) << msg.str() ;
return nullptr;
}
return obj ;
}
开发者ID:fredroy,项目名称:sofa,代码行数:16,代码来源:SimpleApi.cpp
示例13: testNoParameter
void testNoParameter()
{
EXPECT_MSG_EMIT(Error) ;
std::stringstream scene ;
scene << "<?xml version='1.0'?>"
"<Node name='Root' gravity='0 -9.81 0' time='0' animate='0' > \n"
" <RequiredPlugin /> \n"
"</Node> \n" ;
Node::SPtr root = SceneLoaderXML::loadFromMemory ("testscene",
scene.str().c_str(),
scene.str().size()) ;
ASSERT_NE(root.get(), nullptr) ;
root->init(ExecParams::defaultInstance()) ;
}
开发者ID:FabienPean,项目名称:sofa,代码行数:17,代码来源:RequiredPlugin_test.cpp
示例14: loadFromAFileForRigid
void loadFromAFileForRigid(){
string scene =
"<?xml version='1.0'?>"
"<Node name='Root' gravity='0 0 0' time='0' animate='0' > "
" <MechanicalObject template='Rigid3' position='0 0 0 1 0 0 1 0 0 0 1 0 0 1'/> "
" <UniformMass filename='BehaviorModels/card.rigid'/> "
"</Node> " ;
Node::SPtr root = SceneLoaderXML::loadFromMemory ("loadFromAValidFile",
scene.c_str(), (int)scene.size()) ;
root->init(ExecParams::defaultInstance()) ;
UniformMassRigid* mass = root->getTreeObject<UniformMassRigid>() ;
EXPECT_TRUE( mass != nullptr ) ;
if(mass!=nullptr){
EXPECT_EQ( mass->getMass(), 40.0 ) ;
EXPECT_EQ( mass->getTotalMass(), 80.0 ) ;
}
}
开发者ID:FabienPean,项目名称:sofa,代码行数:19,代码来源:UniformMass_test.cpp
示例15: RemoveNode
void QSofaListView::RemoveNode()
{
if( object_.type == typeNode)
{
emit Lock(true);
Node::SPtr node = object_.ptr.Node;
if ( node == node->getRoot() )
{
if ( QMessageBox::warning ( this, "Removing root", "root node cannot be removed" ) )
return;
}
else
{
node->detachFromGraph();
node->execute<simulation::DeleteVisitor>(sofa::core::ExecParams::defaultInstance());
emit NodeRemoved();
}
emit Lock(false);
}
}
开发者ID:david-cazier,项目名称:sofa,代码行数:21,代码来源:QSofaListView.cpp
示例16: checkNegativeMassNotAllowed
/// if masses are negative we refuse them and use the default values.
void checkNegativeMassNotAllowed(){
string scene =
"<?xml version='1.0'?>"
"<Node name='Root' gravity='0 0 0' time='0' animate='0' > "
" <MechanicalObject position='0 0 0 4 5 6'/> "
" <UniformMass name='m_mass' totalmass='-1.0' mass=-3.0/> "
"</Node> " ;
Node::SPtr root = SceneLoaderXML::loadFromMemory ("loadWithNoParam",
scene.c_str(),
scene.size()) ;
root->init(ExecParams::defaultInstance()) ;
TheUniformMass* mass = root->getTreeObject<TheUniformMass>() ;
EXPECT_TRUE( mass != nullptr ) ;
if(mass!=nullptr){
EXPECT_EQ( mass->getMass(), 1.0 ) ;
EXPECT_EQ( mass->getTotalMass(), 2.0 ) ;
}
}
开发者ID:FabienPean,项目名称:sofa,代码行数:23,代码来源:UniformMass_test.cpp
示例17: checkDefaultPipelineWithMonkeyValueForDepth
int TestDefaultPipeLine::checkDefaultPipelineWithMonkeyValueForDepth(int dvalue)
{
std::stringstream scene ;
scene << "<?xml version='1.0'?> \n"
"<Node name='Root' gravity='0 -9.81 0' time='0' animate='0' > \n"
" <DefaultPipeline name='pipeline' depth='"<< dvalue <<"'/> \n"
" <DiscreteIntersection name='interaction'/> \n"
"</Node> \n" ;
Node::SPtr root = SceneLoaderXML::loadFromMemory ("testscene",
scene.str().c_str(),
scene.str().size()) ;
//EXPECT_NE( (root.get()), NULL) ;
root->init(ExecParams::defaultInstance()) ;
DefaultPipeline* clp = dynamic_cast<DefaultPipeline*>(root->getObject("pipeline")) ;
//ASSERT_NE( (clp), nullptr) ;
int rv = clp->d_depth.getValue() ;
clearSceneGraph();
return rv;
}
开发者ID:david-cazier,项目名称:sofa,代码行数:23,代码来源:DefaultPipeline_test.cpp
示例18: RemoveNode
void QSofaListView::RemoveNode()
{
if( object_.type == typeNode)
{
emit Lock(true);
Node* node = object_.ptr.Node;
if ( node == node->getRoot() )
{
//Attempt to destroy the Root node : create an empty node to handle new graph interaction
Node::SPtr root = simulation::getSimulation()->createNewGraph( "Root" );
graphListener_->removeChild ( NULL, node);
graphListener_->addChild ( NULL, root.get() );
emit RootNodeChanged(root.get(),NULL);
}
else
{
node->detachFromGraph();
node->execute<simulation::DeleteVisitor>(sofa::core::ExecParams::defaultInstance());
emit NodeRemoved();
}
emit Lock(false);
}
}
开发者ID:mhdsedighi,项目名称:SOFA,代码行数:23,代码来源:QSofaListView.cpp
示例19: checkDefaultPipelineWithMissingIntersection
void TestDefaultPipeLine::checkDefaultPipelineWithMissingIntersection()
{
EXPECT_MSG_EMIT(Warning) ;
EXPECT_MSG_NOEMIT(Error) ;
std::stringstream scene ;
scene << "<?xml version='1.0'?> \n"
"<Node name='Root' gravity='0 -9.81 0' time='0' animate='0' > \n"
" <DefaultPipeline name='pipeline'/> \n"
"</Node> \n" ;
Node::SPtr root = SceneLoaderXML::loadFromMemory ("testscene",
scene.str().c_str(),
scene.str().size()) ;
ASSERT_NE(root.get(), nullptr) ;
root->init(ExecParams::defaultInstance()) ;
BaseObject* clp = root->getObject("pipeline") ;
ASSERT_NE(clp, nullptr) ;
clearSceneGraph();
}
开发者ID:david-cazier,项目名称:sofa,代码行数:23,代码来源:DefaultPipeline_test.cpp
示例20: createCard
Node::SPtr createCard(Node::SPtr parent, const Coord3& position, const Coord3& rotation)
{
const std::string visualModel="mesh/card.obj";
const std::string collisionModel="mesh/cardCollision.obj";
const std::string inertiaMatrix="BehaviorModels/card.rigid";
static int colorIdx=0;
std::vector<std::string> modelTypes;
modelTypes.push_back("Triangle");
modelTypes.push_back("Line");
modelTypes.push_back("Point");
Node::SPtr card = sofa::modeling::createEulerSolverNode(parent,"Rigid","Implicit");
sofa::component::odesolver::EulerImplicitSolver *odeSolver; card->get(odeSolver);
odeSolver->f_rayleighStiffness.setValue(0.1);
odeSolver->f_rayleighMass.setValue(0.1);
CGLinearSolverGraph *cgLinearSolver; card->get(cgLinearSolver);
cgLinearSolver->f_maxIter.setValue(15);
cgLinearSolver->f_tolerance.setValue(1e-5);
cgLinearSolver->f_smallDenominatorThreshold.setValue(1e-5);
sofa::component::constraintset::LMConstraintSolver::SPtr constraintSolver = sofa::core::objectmodel::New<sofa::component::constraintset::LMConstraintSolver>();
constraintSolver->constraintVel.setValue(true);
constraintSolver->constraintPos.setValue(true);
constraintSolver->numIterations.setValue(25);
card->addObject(constraintSolver);
MechanicalObjectRigid3::SPtr dofRigid = sofa::core::objectmodel::New<MechanicalObjectRigid3>(); dofRigid->setName("Rigid Object");
dofRigid->setTranslation(position[0],position[1],position[2]);
dofRigid->setRotation(rotation[0],rotation[1],rotation[2]);
card->addObject(dofRigid);
UniformMassRigid3::SPtr uniMassRigid = sofa::core::objectmodel::New<UniformMassRigid3>();
uniMassRigid->setTotalMass(0.5);
uniMassRigid->setFileMass(inertiaMatrix);
card->addObject(uniMassRigid);
//Node VISUAL
Node::SPtr RigidVisualNode = sofa::modeling::createVisualNodeRigid(card, dofRigid.get(), visualModel,colors[(colorIdx++)%7]);
//Node COLLISION
Node::SPtr RigidCollisionNode = sofa::modeling::createCollisionNodeRigid(card, dofRigid.get(),collisionModel,modelTypes);
return card;
}
开发者ID:FabienPean,项目名称:sofa,代码行数:49,代码来源:houseOfCards.cpp
注:本文中的node::SPtr类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论