本文整理汇总了C++中node::SPtr::reset方法的典型用法代码示例。如果您正苦于以下问题:C++ SPtr::reset方法的具体用法?C++ SPtr::reset怎么用?C++ SPtr::reset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类node::SPtr
的用法示例。
在下文中一共展示了SPtr::reset方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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();
}
}
示例2: main
int main(int argc, char** argv)
{
sofa::simulation::tree::init();
sofa::component::initComponentBase();
sofa::component::initComponentCommon();
sofa::component::initComponentGeneral();
sofa::component::initComponentAdvanced();
sofa::component::initComponentMisc();
sofa::gui::initMain();
unsigned int sizeHouseOfCards=4;
SReal angle=20.0;
SReal distanceInBetween=0.1;
SReal friction=0.8;
SReal contactDistance=0.03;
std::string gui = "";
std::string gui_help = "choose the UI (";
gui_help += sofa::gui::GUIManager::ListSupportedGUI('|');
gui_help += ")";
sofa::helper::parse("This is a SOFA application. Here are the command line arguments")
.option(&sizeHouseOfCards,'l',"level","number of level of the house of cards")
.option(&angle,'a',"angle","angle formed by two cards")
.option(&distanceInBetween,'d',"distance","distance between two cards")
.option(&friction,'f',"friction","friction coeff")
.option(&contactDistance,'c',"contactDistance","contact distance")
.option(&gui,'g',"gui",gui_help.c_str())
(argc,argv);
sofa::simulation::setSimulation(new sofa::simulation::tree::TreeSimulation());
// The graph root node
Node::SPtr root = sofa::modeling::createRootWithCollisionPipeline("distanceLMConstraint");
root->setGravity( Coord3(0,-10,0) );
root->setDt(0.001);
sofa::component::collision::MinProximityIntersection *intersection;
root->get(intersection, sofa::core::objectmodel::BaseContext::SearchDown);
intersection->alarmDistance.setValue(contactDistance);
intersection->contactDistance.setValue(contactDistance*0.5);
//************************************
//Floor
Node::SPtr torusFixed = sofa::modeling::createObstacle(root.get(),"mesh/floor.obj", "mesh/floor.obj", "gray");
//Add the objects
createHouseOfCards(root.get(),sizeHouseOfCards,distanceInBetween, angle);
const SReal contactFriction=sqrt(friction);
sofa::helper::vector< sofa::core::CollisionModel* > listCollisionModels;
root->getTreeObjects<sofa::core::CollisionModel>(&listCollisionModels);
for (unsigned int i=0; i<listCollisionModels.size(); ++i) listCollisionModels[i]->setContactFriction(contactFriction);
root->setAnimate(false);
//=======================================
// Export the scene to file
const std::string fileName="HouseOfCards.xml";
sofa::simulation::getSimulation()->exportXML(root.get(),fileName.c_str());
//=======================================
// Destroy created scene: step needed, as I can't get rid of the locales (the mass can't init correctly as 0.1 is not considered as a floating point).
sofa::simulation::DeleteVisitor deleteScene(sofa::core::ExecParams::defaultInstance() );
root->execute(deleteScene);
root.reset();
//=======================================
// Create the GUI
if (int err=sofa::gui::GUIManager::Init(argv[0],gui.c_str()))
return err;
if (int err=sofa::gui::GUIManager::createGUI(NULL))
return err;
sofa::gui::GUIManager::SetDimension(800,600);
//=======================================
// Load the Scene
sofa::simulation::Node::SPtr groot = sofa::core::objectmodel::SPtr_dynamic_cast<sofa::simulation::Node>( sofa::simulation::getSimulation()->load(fileName.c_str()));
if (groot==NULL)
{
groot = sofa::simulation::getSimulation()->createNewGraph("");
}
sofa::simulation::getSimulation()->init(groot.get());
sofa::gui::GUIManager::SetScene(groot,fileName.c_str());
//=======================================
// Run the main loop
if (int err=sofa::gui::GUIManager::MainLoop(groot,fileName.c_str()))
return err;
Node* ggroot = sofa::gui::GUIManager::CurrentSimulation();
if (ggroot!=NULL) sofa::simulation::getSimulation()->unload(groot);
//.........这里部分代码省略.........