Skip to content

Commit d2f48ee

Browse files
authored
[SceneChecking] Add checks for PenalityContactForceField (#5603)
1 parent 72621bd commit d2f48ee

2 files changed

Lines changed: 23 additions & 2 deletions

File tree

applications/projects/SceneChecking/src/SceneChecking/SceneCheckCollisionResponse.cpp

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ void SceneCheckCollisionResponse::doCheckOn(Node* node)
6464
{
6565
if( nbContactManager!= 1 )
6666
{
67-
m_message << "Only one CollisionResponse is needed."<< msgendl;
67+
m_message << "Only one CollisionResponse is allowed in the scene."<< msgendl;
6868
}
6969
else
7070
{
@@ -101,6 +101,11 @@ void SceneCheckCollisionResponse::doCheckOn(Node* node)
101101
checkIfContactStiffnessIsSet(root);
102102
}
103103
}
104+
/// If PenalityContactForceField make sure that contactStiffness is defined
105+
else if ( response == "PenalityContactForceField")
106+
{
107+
checkIfContactStiffnessIsNotSet(root);
108+
}
104109
}
105110
}
106111
}
@@ -113,9 +118,24 @@ void SceneCheckCollisionResponse::checkIfContactStiffnessIsSet(const sofa::core:
113118
{
114119
if(model->isContactStiffnessSet())
115120
{
116-
m_message <<"The data \"contactStiffness\" is set in the component " << model->getClassName() <<" named " << model->getName() << msgendl;
121+
m_message <<"The data \"contactStiffness\" is set in the component " << model->getClassName() <<", named \"" << model->getName() << "\"";
117122
m_message <<"This data is not used when using a FrictionContactConstraint collision response." << msgendl;
118123
m_message <<"Remove the data \"contactStiffness\" to remove this warning" << msgendl;
124+
break;
125+
}
126+
}
127+
}
128+
129+
void SceneCheckCollisionResponse::checkIfContactStiffnessIsNotSet(const sofa::core::objectmodel::BaseContext* root)
130+
{
131+
type::vector<core::CollisionModel*> colModels;
132+
root->get<core::CollisionModel>(&colModels, core::objectmodel::BaseContext::SearchDown);
133+
for (const auto model : colModels)
134+
{
135+
if(!model->isContactStiffnessSet())
136+
{
137+
m_message <<"Using PenalityContactForceField, the contactStiffness should be defined for each CollisionModel" << msgendl;
138+
break;
119139
}
120140
}
121141
}

applications/projects/SceneChecking/src/SceneChecking/SceneCheckCollisionResponse.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ class SOFA_SCENECHECKING_API SceneCheckCollisionResponse : public sofa::simulati
4747
std::stringstream m_message;
4848

4949
void checkIfContactStiffnessIsSet(const core::objectmodel::BaseContext *root);
50+
void checkIfContactStiffnessIsNotSet(const core::objectmodel::BaseContext *root);
5051
};
5152

5253
} // namespace sofa::_scenechecking_

0 commit comments

Comments
 (0)