Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions Sofa/Component/Collision/Geometry/tests/Sphere_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ using sofa::helper::logging::MessageDispatcher ;
#include <sofa/helper/logging/ClangMessageHandler.h>
using sofa::helper::logging::ClangMessageHandler ;

#include <sofa/simulation/graph/DAGNode.h>
#include <sofa/simulation/Node.h>

#include <sofa/testing/BaseSimulationTest.h>
using sofa::testing::BaseSimulationTest;
Expand Down Expand Up @@ -101,7 +101,7 @@ bool TestSphere::rigidRigid1(){
angles[1] = 0;
angles[2] = 0;

Node::SPtr scn = New<sofa::simulation::graph::DAGNode>();
Node::SPtr scn = New<sofa::simulation::Node>();
//the center of this OBB is (0,0,-1) and its extent is 1

//we construct the falling sphere
Expand Down Expand Up @@ -157,7 +157,7 @@ bool TestSphere::rigidRigid2(){
angles_2[1] = 0;
angles_2[2] = 0;

Node::SPtr scn = New<sofa::simulation::graph::DAGNode>();
Node::SPtr scn = New<sofa::simulation::Node>();
//the center of this OBB is (0,0,-1) and its extent is 1

//we construct the falling sphere
Expand Down Expand Up @@ -204,7 +204,7 @@ bool TestSphere::rigidSoft2(){
angles[1] = M_PI/4;
angles[2] = M_PI/3;

Node::SPtr scn = New<sofa::simulation::graph::DAGNode>();
Node::SPtr scn = New<sofa::simulation::Node>();
//the center of this OBB is (0,0,-1) and its extent is 1

//we construct the falling sphere
Expand Down Expand Up @@ -251,7 +251,7 @@ bool TestSphere::rigidSoft1(){
angles[1] = 0;
angles[2] = 0;

Node::SPtr scn = New<sofa::simulation::graph::DAGNode>();
Node::SPtr scn = New<sofa::simulation::Node>();
//the center of this OBB is (0,0,-1) and its extent is 1

//we construct the falling sphere
Expand Down Expand Up @@ -299,7 +299,7 @@ bool TestSphere::rigidSoft3(){
angles[1] = M_PI/4;
angles[2] = M_PI/3;

Node::SPtr scn = New<sofa::simulation::graph::DAGNode>();
Node::SPtr scn = New<sofa::simulation::Node>();
//the center of this OBB is (0,0,-1) and its extent is 1

//we construct the falling sphere
Expand Down Expand Up @@ -346,7 +346,7 @@ bool TestSphere::rigidSoft4(){
angles[1] = 0;
angles[2] = 0;

Node::SPtr scn = New<sofa::simulation::graph::DAGNode>();
Node::SPtr scn = New<sofa::simulation::Node>();
//the center of this OBB is (0,0,-1) and its extent is 1

//we construct the falling sphere
Expand Down Expand Up @@ -384,7 +384,7 @@ bool TestSphere::rigidSoft4(){


bool TestSphere::softSoft1(){
Node::SPtr scn = New<sofa::simulation::graph::DAGNode>();
Node::SPtr scn = New<sofa::simulation::Node>();
//the center of this OBB is (0,0,-1) and its extent is 1

//we construct the falling sphere
Expand Down
6 changes: 3 additions & 3 deletions Sofa/Component/Collision/Geometry/tests/Triangle_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ using sofa::helper::logging::MessageDispatcher;
#include <sofa/testing/BaseTest.h>
using sofa::testing::BaseTest;

#include <sofa/simulation/graph/DAGNode.h>
#include <sofa/simulation/Node.h>

#include <sofa/component/collision/testing/MeshPrimitiveCreator.h>
#include <sofa/component/collision/testing/SpherePrimitiveCreator.h>
Expand Down Expand Up @@ -82,7 +82,7 @@ bool TestTriangle::rigidTriangle(sofa::component::collision::detection::intersec
angles[1] = 0;
angles[2] = 0;

Node::SPtr scn = New<sofa::simulation::graph::DAGNode>();
Node::SPtr scn = New<sofa::simulation::Node>();
//the center of this OBB is (0,0,-1) and its extent is 1

//we construct the falling sphere
Expand Down Expand Up @@ -121,7 +121,7 @@ bool TestTriangle::rigidTriangle(sofa::component::collision::detection::intersec

template <class Intersector>
bool TestTriangle::softTriangle(sofa::component::collision::detection::intersection::BaseProximityIntersection::SPtr intersectionMethod, Intersector& bi) {
Node::SPtr scn = New<sofa::simulation::graph::DAGNode>();
Node::SPtr scn = New<sofa::simulation::Node>();
//the center of this OBB is (0,0,-1) and its extent is 1

//we construct the falling sphere
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* Contact information: [email protected] *
******************************************************************************/

#include <sofa/simulation/graph/DAGNode.h>
#include <sofa/simulation/Node.h>
#include <sofa/component/collision/response/mapper/BarycentricContactMapper.h>
#include <sofa/component/mapping/linear/BarycentricMappers/BarycentricMapperMeshTopology.h>
#include <sofa/component/topology/container/dynamic/PointSetTopologyContainer.h>
Expand Down Expand Up @@ -84,7 +84,7 @@ MeshTopology* BaryMapperTest::initMesh(NodePtr &father){

bool BaryMapperTest::test_inside(SReal alpha,SReal beta){
initTriPts();
sofa::simulation::Node::SPtr father = New<sofa::simulation::graph::DAGNode>();
sofa::simulation::Node::SPtr father = New<sofa::simulation::Node>();
MeshTopology * topo = initMesh(father);
//makeTri()
const component::mapping::linear::BarycentricMapperMeshTopology<DataTypes, DataTypes>::SPtr mapper = sofa::core::objectmodel::New<component::mapping::linear::BarycentricMapperMeshTopology<DataTypes, DataTypes> >(topo, (component::topology::container::dynamic::PointSetTopologyContainer*)0x0);
Expand All @@ -103,7 +103,7 @@ bool BaryMapperTest::test_inside(SReal alpha,SReal beta){

bool BaryMapperTest::test_outside(int index){
initTriPts();
sofa::simulation::Node::SPtr father = New<sofa::simulation::graph::DAGNode>();
sofa::simulation::Node::SPtr father = New<sofa::simulation::Node>();
MeshTopology * topo = initMesh(father);
//makeTri()
const component::mapping::linear::BarycentricMapperMeshTopology<DataTypes, DataTypes>::SPtr mapper = sofa::core::objectmodel::New<component::mapping::linear::BarycentricMapperMeshTopology<DataTypes, DataTypes> >(topo,(component::topology::container::dynamic::PointSetTopologyContainer*)0x0);
Expand Down
10 changes: 5 additions & 5 deletions Sofa/Component/LinearSystem/tests/MappingGraph_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include <sofa/testing/BaseTest.h>
#include <sofa/component/linearsystem/MappingGraph.h>
#include <sofa/core/MechanicalParams.h>
#include <sofa/simulation/graph/DAGNode.h>
#include <sofa/simulation/Node.h>
#include <sofa/simpleapi/SimpleApi.h>
#include <sofa/component/statecontainer/MechanicalObject.h>
#include <sofa/component/mapping/linear/SubsetMapping.h>
Expand Down Expand Up @@ -65,7 +65,7 @@ TEST(MappingGraph, nullRootNode)

TEST(MappingGraph, emptyRootNode)
{
const sofa::simulation::Node::SPtr root = sofa::core::objectmodel::New<sofa::simulation::graph::DAGNode>();
const sofa::simulation::Node::SPtr root = sofa::core::objectmodel::New<sofa::simulation::Node>();

sofa::component::linearsystem::MappingGraph graph;
graph.build(sofa::core::MechanicalParams::defaultInstance(), root.get());
Expand All @@ -85,7 +85,7 @@ TEST(MappingGraph, emptyRootNode)

TEST(MappingGraph, oneMechanicalObject)
{
const sofa::simulation::Node::SPtr root = sofa::core::objectmodel::New<sofa::simulation::graph::DAGNode>();
const sofa::simulation::Node::SPtr root = sofa::core::objectmodel::New<sofa::simulation::Node>();

const auto mstate = sofa::core::objectmodel::New<sofa::component::statecontainer::MechanicalObject<sofa::defaulttype::Vec3Types> >();
root->addObject(mstate);
Expand All @@ -107,7 +107,7 @@ TEST(MappingGraph, oneMechanicalObject)

TEST(MappingGraph, twoMechanicalObject)
{
const sofa::simulation::Node::SPtr root = sofa::core::objectmodel::New<sofa::simulation::graph::DAGNode>();
const sofa::simulation::Node::SPtr root = sofa::core::objectmodel::New<sofa::simulation::Node>();

const auto mstate1 = sofa::core::objectmodel::New<sofa::component::statecontainer::MechanicalObject<sofa::defaulttype::Vec3Types> >();
root->addObject(mstate1);
Expand Down Expand Up @@ -135,7 +135,7 @@ TEST(MappingGraph, twoMechanicalObject)

TEST(MappingGraph, oneMapping)
{
const sofa::simulation::Node::SPtr root = sofa::core::objectmodel::New<sofa::simulation::graph::DAGNode>();
const sofa::simulation::Node::SPtr root = sofa::core::objectmodel::New<sofa::simulation::Node>();

const auto mstate1 = sofa::core::objectmodel::New<sofa::component::statecontainer::MechanicalObject<sofa::defaulttype::Vec3Types> >();
root->addObject(mstate1);
Expand Down
8 changes: 4 additions & 4 deletions Sofa/Component/LinearSystem/tests/MatrixLinearSystem_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#include <sofa/simulation/Node.h>

#include <sofa/component/statecontainer/MechanicalObject.h>
#include <sofa/simulation/graph/DAGNode.h>
#include <sofa/simulation/Node.h>
#include <sofa/component/solidmechanics/spring/SpringForceField.h>
#include <sofa/core/behavior/ForceField.h>

Expand Down Expand Up @@ -62,7 +62,7 @@ TEST(LinearSystem, MatrixSystem_noContext)

TEST(LinearSystem, MatrixSystem)
{
const sofa::simulation::Node::SPtr root = sofa::core::objectmodel::New<sofa::simulation::graph::DAGNode>();
const sofa::simulation::Node::SPtr root = sofa::core::objectmodel::New<sofa::simulation::Node>();

using MatrixType = sofa::linearalgebra::CompressedRowSparseMatrix<SReal>;
using MatrixSystem = sofa::component::linearsystem::MatrixLinearSystem<MatrixType, sofa::linearalgebra::FullVector<SReal> >;
Expand Down Expand Up @@ -92,7 +92,7 @@ TEST(LinearSystem, MatrixSystem_springForceField)
// required to be able to use EXPECT_MSG_NOEMIT and EXPECT_MSG_EMIT
sofa::helper::logging::MessageDispatcher::addHandler(sofa::testing::MainGtestMessageHandler::getInstance() ) ;

sofa::simulation::Node::SPtr root = sofa::core::objectmodel::New<sofa::simulation::graph::DAGNode>();
sofa::simulation::Node::SPtr root = sofa::core::objectmodel::New<sofa::simulation::Node>();

using MatrixType = sofa::linearalgebra::FullMatrix<SReal>;
using MatrixSystem = sofa::component::linearsystem::MatrixLinearSystem<MatrixType, sofa::linearalgebra::FullVector<SReal> >;
Expand Down Expand Up @@ -332,7 +332,7 @@ TEST(LinearSystem, MatrixSystem_buggyForceField)
// required to be able to use EXPECT_MSG_NOEMIT and EXPECT_MSG_EMIT
sofa::helper::logging::MessageDispatcher::addHandler(sofa::testing::MainGtestMessageHandler::getInstance() ) ;

const sofa::simulation::Node::SPtr root = sofa::core::objectmodel::New<sofa::simulation::graph::DAGNode>();
const sofa::simulation::Node::SPtr root = sofa::core::objectmodel::New<sofa::simulation::Node>();

using MatrixSystem = sofa::component::linearsystem::MatrixLinearSystem<EmptyMatrix, sofa::linearalgebra::FullVector<SReal> >;
const MatrixSystem::SPtr linearSystem = sofa::core::objectmodel::New<MatrixSystem>();
Expand Down
1 change: 1 addition & 0 deletions Sofa/framework/Core/src/sofa/core/fwd.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ class BaseInteractionForceField;
class BaseProjectiveConstraintSet;
class BaseInteractionProjectiveConstraintSet;
class BaseInteractionConstraint;
class BaseMechanicalState;
class LinearSolver;
class MultiMatrixAccessor;

Expand Down
90 changes: 79 additions & 11 deletions Sofa/framework/Core/src/sofa/core/objectmodel/BaseContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,19 @@ namespace sofa::core::objectmodel
{

BaseContext::BaseContext()
{}
: is_activated(initData(&is_activated, true, "activated", "To Activate a node"))
, worldGravity_(initData(&worldGravity_, Vec3(SReal(0),SReal(-9.81),SReal(0)),"gravity","Gravity in the world coordinate system"))
, dt_(initData(&dt_,SReal(0.01),"dt","Time step"))
, time_(initData(&time_,SReal(0.),"time","Current time"))
, animate_(initData(&animate_,false,"animate","Animate the Simulation(applied at initialization only)"))
, d_isSleeping(initData(&d_isSleeping, false, "sleeping", "The node is sleeping, and thus ignored by visitors."))
, d_canChangeSleepingState(initData(&d_canChangeSleepingState, false, "canChangeSleepingState", "The node can change its sleeping state."))
{
animate_.setReadOnly(true);
dt_.setReadOnly(true);
time_.setReadOnly(true);
}


BaseContext::~BaseContext()
{}
Expand All @@ -44,53 +56,109 @@ BaseContext* BaseContext::getDefault()
return &defaultContext;
}



////////////////
// Parameters //
////////////////

/// State of the context
void BaseContext::setActive(bool val) { is_activated.setValue(val); }

/// The Context is active
bool BaseContext::isActive() const { return true; }
bool BaseContext::isActive() const { return is_activated.getValue(); }


/// Sleeping state of the context
void BaseContext::setSleeping(bool val){ d_isSleeping.setValue(val); }

/// The Context is not sleeping by default
bool BaseContext::isSleeping() const { return false; }
bool BaseContext::isSleeping() const { return d_isSleeping.getValue(); }

/// The Context can not change its sleeping state by default
bool BaseContext::canChangeSleepingState() const { return false; }
bool BaseContext::canChangeSleepingState() const { return d_canChangeSleepingState.getValue(); }

/// Sleeping state change of the context
void BaseContext::setChangeSleepingState(bool val)
{
d_canChangeSleepingState.setValue(val);
}

/// Gravity vector
void BaseContext::setGravity(const Vec3& g)
{
worldGravity_ .setValue(g);
}

/// Gravity in the world coordinate system
const BaseContext::Vec3& BaseContext::getGravity() const
{
static const Vec3 G(SReal(0),SReal(-9.81), SReal(0));
return G;
return worldGravity_.getValue();
}

/// Simulation timestep
void BaseContext::setDt(SReal dt)
{
dt_.setValue(dt);
}

/// Simulation timestep
SReal BaseContext::getDt() const
{
return 0.01;
return dt_.getValue();
}

/// Simulation time
void BaseContext::setTime(SReal t)
{
time_.setValue(t);
}

/// Simulation time
SReal BaseContext::getTime() const
{
return 0.0;
return time_.getValue();
}

/// Animation flag
void BaseContext::setAnimate(const bool val)
{
animate_.setValue(val);
}

/// Animation flag
bool BaseContext::getAnimate() const
{
return true;
return animate_.getValue();
}

/// Display flags: Gravity
void BaseContext::setDisplayWorldGravity(bool val)
{
worldGravity_.setDisplayed(val);
}

BaseContext* BaseContext::getRootContext() const
{
return const_cast<BaseContext*>(this);
}

//======================
void BaseContext::copyContext(const BaseContext& c)
{
// BUGFIX 12/01/06 (Jeremie A.): Can't use operator= on the class as it will copy other data in the BaseContext class (such as name)...
// *this = c;
copySimulationContext(c);
}


void BaseContext::copySimulationContext(const BaseContext& c)
{
worldGravity_.setValue(c.getGravity()); ///< Gravity IN THE WORLD COORDINATE SYSTEM.
setDt(c.getDt());
setTime(c.getTime());
setAnimate(c.getAnimate());
}


////////////////
// Containers //
////////////////
Expand Down
Loading
Loading