Example #1
0
bool SofaCarving_test::doCarvingWithPenetration()
{
    bool res = createScene("-0.02");
    if (!res)
        return false;

    // init scene
    m_simu->init(m_root.get());

    // get node of the mesh
    sofa::simulation::Node* cylinder = m_root->getChild("cylinder");
    EXPECT_NE(cylinder, nullptr);

    // getting topology
    sofa::core::topology::BaseMeshTopology* topo = cylinder->getMeshTopology();
    EXPECT_NE(topo, nullptr);

    // perform some steps
    for (unsigned int i = 0; i < 100; ++i)
    {
        m_simu->animate(m_root.get());
    }

    // checking topo after carving
    EXPECT_LT(topo->getNbPoints(), 510);
    EXPECT_LT(topo->getNbEdges(), 3119);
    EXPECT_LT(topo->getNbTriangles(), 5040);
    EXPECT_LT(topo->getNbTetrahedra(), 2430);

    return true;
}
Example #2
0
void BaseGUI::configureGUI(sofa::simulation::Node::SPtr groot)
{

    sofa::component::configurationsetting::SofaDefaultPathSetting *defaultPath;
    groot->get(defaultPath, sofa::core::objectmodel::BaseContext::SearchRoot);
    if (defaultPath)
    {
        if (!defaultPath->recordPath.getValue().empty())
        {
            setRecordPath(defaultPath->recordPath.getValue());
        }

        if (!defaultPath->gnuplotPath.getValue().empty())
            setGnuplotPath(defaultPath->gnuplotPath.getValue());
    }


    //Background
    sofa::component::configurationsetting::BackgroundSetting *background;
    groot->get(background, sofa::core::objectmodel::BaseContext::SearchRoot);
    if (background)
    {
        if (background->image.getValue().empty())
            setBackgroundColor(background->color.getValue());
        else
            setBackgroundImage(background->image.getFullPath());
    }

    //Stats
    sofa::component::configurationsetting::StatsSetting *stats;
    groot->get(stats, sofa::core::objectmodel::BaseContext::SearchRoot);
    if (stats)
    {
        setDumpState(stats->dumpState.getValue());
        setLogTime(stats->logTime.getValue());
        setExportState(stats->exportState.getValue());
#ifdef SOFA_DUMP_VISITOR_INFO
        setTraceVisitors(stats->traceVisitors.getValue());
#endif
    }

    //Viewer Dimension TODO in viewer !
    sofa::component::configurationsetting::ViewerSetting *viewerConf;
    groot->get(viewerConf, sofa::core::objectmodel::BaseContext::SearchRoot);
    if (viewerConf) setViewerConfiguration(viewerConf);

    //TODO: Video Recorder Configuration

    //Mouse Manager using ConfigurationSetting component...
    sofa::helper::vector< sofa::component::configurationsetting::MouseButtonSetting*> mouseConfiguration;
    groot->get<sofa::component::configurationsetting::MouseButtonSetting>(&mouseConfiguration, sofa::core::objectmodel::BaseContext::SearchRoot);

    for (unsigned int i=0; i<mouseConfiguration.size(); ++i)  setMouseButtonConfiguration(mouseConfiguration[i]);

}
Example #3
0
bool SofaCarving_test::ManagerInit()
{
    bool res = createScene("0.0");
    if (!res)
        return false;

    // init scene
    m_simu->init(m_root.get());
    
    // get node of the mesh
    sofa::simulation::Node* cylinder = m_root->getChild("cylinder");
    EXPECT_NE(cylinder, nullptr);

    // getting topology
    sofa::core::topology::BaseMeshTopology* topo = cylinder->getMeshTopology();
    EXPECT_NE(topo, nullptr);

    // checking topo at start
    EXPECT_EQ(topo->getNbPoints(), 510);
    EXPECT_EQ(topo->getNbEdges(), 3119);
    EXPECT_EQ(topo->getNbTriangles(), 5040);
    EXPECT_EQ(topo->getNbTetrahedra(), 2430);

    return res;
}
Example #4
0
    void testModif()
    {
        std::string str_x =
                "# Gnuplot File : positions of 1 particle(s) Monitored\n# 1st Column : "
                "time, others : particle(s) number 0 \n1	-3.5 -12.4182 -3.5 0 0 "
                "0 1	\n2	-3.5 -29.4438 -3.5 0 0 0 1	\n3	-3.5 -53.8398 "
                "-3.5 0 0 0 1	\n4	-3.5 -84.9362 -3.5 0 0 0 1	\n5	-3.5 "
                "-122.124 -3.5 0 0 0 1	\n6	-3.5 -164.849 -3.5 0 0 0 1	"
                "\n7	"
                "-3.5 -212.608 -3.5 0 0 0 1	\n8	-3.5 -264.944 -3.5 0 0 0 "
                "1	"
                "\n9	-3.5 -321.44 -3.5 0 0 0 1	\n10	-3.5 -381.718 -3.5 0 0 "
                "0 1	\n";
        std::string str_f =
                "# Gnuplot File : forces of 1 particle(s) Monitored\n# 1st Column : "
                "time, others : particle(s) number 0 \n1	0 -0.363333 0 0 0 "
                "0	"
                "\n2	0 -0.363333 0 0 0 0	\n3	0 -0.363333 0 0 0 0	"
                "\n4	"
                "0 -0.363333 0 0 0 0	\n5	0 -0.363333 0 0 0 0	\n6	0 "
                "-0.363333 0 0 0 0	\n7	0 -0.363333 0 0 0 0	\n8	0 "
                "-0.363333 0 0 0 0	\n9	0 -0.363333 0 0 0 0	\n10	0 "
                "-0.363333 0 0 0 0	\n";
        std::string str_v =
                "# Gnuplot File : velocities of 1 particle(s) Monitored\n# 1st Column "
                ": time, others : particle(s) number 0 \n1	0 -8.91818 0 0 0 "
                "0	"
                "\n2	0 -17.0256 0 0 0 0	\n3	0 -24.396 0 0 0 0	"
                "\n4	"
                "0 -31.0964 0 0 0 0	\n5	0 -37.1876 0 0 0 0	\n6	0 "
                "-42.7251 0 0 0 0	\n7	0 -47.7592 0 0 0 0	\n8	0 "
                "-52.3356 0 0 0 0	\n9	0 -56.496 0 0 0 0	\n10	0 "
                "-60.2782 0 0 0 0	\n";

        // make a few steps before checkinf if values are correctly updated in
        // Monitor
        for (int i = 0; i < 10; ++i)
            simulation::getSimulation()->animate(root.get(), 1.0);

        monitor->testModif(mo.get());

        std::string s_x = readWholeFile(monitor->d_fileName.getFullPath() + "_x.txt");
        std::string s_f = readWholeFile(monitor->d_fileName.getFullPath() + "_f.txt");
        std::string s_v = readWholeFile(monitor->d_fileName.getFullPath() + "_v.txt");
        EXPECT_EQ(s_x, str_x);
        EXPECT_EQ(s_f, str_f);
        EXPECT_EQ(s_v, str_v);
        std::remove(std::string(monitor->d_fileName.getFullPath() + "_x.txt").c_str());
        std::remove(std::string(monitor->d_fileName.getFullPath() + "_f.txt").c_str());
        std::remove(std::string(monitor->d_fileName.getFullPath() + "_v.txt").c_str());
    }