From 4fd8acc96194cea1d6c43ca3906f9d57a9543b98 Mon Sep 17 00:00:00 2001 From: COEVOET Eulalie Date: Fri, 18 May 2018 15:21:47 +0200 Subject: [PATCH 1/3] [component] WIP: added component state management to avoid segmentation fault, following the work of Damien on SoftRobots.Inverse/SlidingActuator --- component/constraint/CableConstraint.h | 1 + component/constraint/CableConstraint.inl | 16 +++-- .../PartialRigidificationConstraint.inl | 24 +------ .../constraint/SurfacePressureConstraint.h | 1 + .../constraint/SurfacePressureConstraint.inl | 14 ++-- .../constraint/UnilateralPlaneConstraint.h | 1 + .../constraint/UnilateralPlaneConstraint.inl | 22 +++++- component/constraint/model/CableModel.h | 1 + component/constraint/model/CableModel.inl | 27 ++++++++ .../constraint/model/SurfacePressureModel.h | 1 + .../constraint/model/SurfacePressureModel.inl | 25 +++++++ component/controller/AnimationEditor.inl | 68 +++++++------------ .../controller/CommunicationController.inl | 6 +- component/controller/DataVariationLimiter.inl | 6 +- .../controller/SerialPortBridgeGeneric.cpp | 17 ++--- component/engine/CenterOfMass.inl | 33 +++++++-- component/engine/VolumeFromTetrahedrons.inl | 26 +++++-- component/engine/VolumeFromTriangles.inl | 29 ++++++-- .../PREquivalentStiffnessForceField.h | 1 + .../PREquivalentStiffnessForceField.inl | 55 +++++++-------- .../PartialRigidificationForceField.inl | 43 ++---------- component/forcefield/PipeForceField.inl | 36 ++++++---- .../SurfacePressureConstraintTest.cpp | 10 ++- 23 files changed, 268 insertions(+), 195 deletions(-) diff --git a/component/constraint/CableConstraint.h b/component/constraint/CableConstraint.h index b696e5d6..63c14234 100644 --- a/component/constraint/CableConstraint.h +++ b/component/constraint/CableConstraint.h @@ -148,6 +148,7 @@ class CableConstraint : public CableModel using CableModel::d_maxDispVariation ; using CableModel::d_force ; using CableModel::d_displacement ; +// using CableModel::m_componentstate ; /////////////////////////////////////////////////////////////////////////// protected: diff --git a/component/constraint/CableConstraint.inl b/component/constraint/CableConstraint.inl index e37def43..c95bd257 100644 --- a/component/constraint/CableConstraint.inl +++ b/component/constraint/CableConstraint.inl @@ -44,6 +44,7 @@ namespace component namespace constraintset { +using sofa::core::objectmodel::ComponentState; using sofa::helper::WriteAccessor; template @@ -110,16 +111,18 @@ void CableConstraint::reinit() template void CableConstraint::internalInit() { - // check for errors in the initialization if(d_value.getValue().size()==0) { - WriteAccessor>> inputValue = d_value; - inputValue.resize(1,0.); + WriteAccessor>> value = d_value; + value.resize(1,0.); } + // check for errors in the initialization if(d_value.getValue().size() @@ -127,6 +130,9 @@ void CableConstraint::getConstraintResolution(const ConstraintParams* std::vector& resTab, unsigned int& offset) { +// if(this->m_componentstate != ComponentState::Valid) +// return ; + SOFA_UNUSED(cParam); double imposed_value=d_value.getValue()[d_valueIndex.getValue()]; diff --git a/component/constraint/PartialRigidificationConstraint.inl b/component/constraint/PartialRigidificationConstraint.inl index 8a5497cd..cca77e88 100644 --- a/component/constraint/PartialRigidificationConstraint.inl +++ b/component/constraint/PartialRigidificationConstraint.inl @@ -88,58 +88,40 @@ void PartialRigidificationConstraint::buildConstraintMatrix(const Con { SOFA_UNUSED(cParams); - std::cout<<"step0"<getName()< void PartialRigidificationConstraint::getConstraintResolution(std::vector& resTab, unsigned int& offset) { -// for(size_t i = 0 ; i < 6 ; ++i) resTab[offset] = new PartialRigidificationConstraintResolution6Dof(); - // indicates the size of the block on which the constraint resoluation works + // Indicates the size of the block on which the constraint resoluation works offset += 6; } diff --git a/component/constraint/SurfacePressureConstraint.h b/component/constraint/SurfacePressureConstraint.h index 6957eacd..957d4675 100644 --- a/component/constraint/SurfacePressureConstraint.h +++ b/component/constraint/SurfacePressureConstraint.h @@ -149,6 +149,7 @@ class SOFA_SOFTROBOTS_API SurfacePressureConstraint : public SurfacePressureMode using SurfacePressureModel::m_displayedValue ; using SurfacePressureModel::m_columnId; using SurfacePressureModel::m_visualization; +// using SoftRobotsConstraint::m_componentstate; //////////////////////////////////////////////////////////////////////////// private: diff --git a/component/constraint/SurfacePressureConstraint.inl b/component/constraint/SurfacePressureConstraint.inl index 881683ec..27a021fd 100644 --- a/component/constraint/SurfacePressureConstraint.inl +++ b/component/constraint/SurfacePressureConstraint.inl @@ -144,15 +144,18 @@ void SurfacePressureConstraint::reset() template void SurfacePressureConstraint::initData() { - // check for errors in the initialization if(d_value.getValue().size()==0) { - WriteAccessor>> inputValue = d_value; - inputValue.resize(1,0.); + WriteAccessor>> value = d_value; + value.resize(1,0.); } + // check for errors in the initialization if(d_value.getValue().size() void SurfacePressureConstraint::getConstraintResolution(std::vector& resTab, unsigned int& offset) { +// if(m_componentstate != ComponentState::Valid) +// return ; + double imposed_value = d_value.getValue()[d_valueIndex.getValue()]; m_displayedValue = d_value.getValue()[d_valueIndex.getValue()]; diff --git a/component/constraint/UnilateralPlaneConstraint.h b/component/constraint/UnilateralPlaneConstraint.h index 86744636..6e658d7d 100644 --- a/component/constraint/UnilateralPlaneConstraint.h +++ b/component/constraint/UnilateralPlaneConstraint.h @@ -145,6 +145,7 @@ class SOFA_SOFTROBOTS_API UnilateralPlaneConstraint : public Constraint" approach. using Constraint::mstate ; + using Constraint::m_componentstate ; //////////////////////////////////////////////////////////////////////////// }; diff --git a/component/constraint/UnilateralPlaneConstraint.inl b/component/constraint/UnilateralPlaneConstraint.inl index 0891972e..96a0498a 100644 --- a/component/constraint/UnilateralPlaneConstraint.inl +++ b/component/constraint/UnilateralPlaneConstraint.inl @@ -46,6 +46,7 @@ namespace component namespace constraintset { +using sofa::core::objectmodel::ComponentState; using sofa::core::VecCoordId; using sofa::core::ConstVecCoordId ; using sofa::helper::WriteAccessor ; @@ -91,20 +92,28 @@ UnilateralPlaneConstraint::~UnilateralPlaneConstraint() template void UnilateralPlaneConstraint::init() { + m_componentstate = ComponentState::Invalid; Inherit::init(); if(mstate == nullptr) - msg_error(this) << "There is no mechanical state associated with this node. " + { + msg_error(this) << "There is no mechanical state associated with this node. Component deactivated." "To remove this error message, fix your scene possibly by " "adding a MechanicalObject." ; + return; + } checkIndicesRegardingState(); + m_componentstate = ComponentState::Valid; } template void UnilateralPlaneConstraint::reinit() { + if(m_componentstate != ComponentState::Valid) + return ; + checkIndicesRegardingState(); } @@ -130,6 +139,9 @@ void UnilateralPlaneConstraint::buildConstraintMatrix(const core::Con unsigned int &cIndex, const DataVecCoord &x) { + if(m_componentstate != ComponentState::Valid) + return ; + SOFA_UNUSED(cParams); SOFA_UNUSED(x); @@ -164,6 +176,9 @@ void UnilateralPlaneConstraint::getConstraintViolation(const core::Co const DataVecCoord &xfree, const DataVecDeriv &vfree) { + if(m_componentstate != ComponentState::Valid) + return ; + SOFA_UNUSED(cParams); SOFA_UNUSED(vfree); @@ -187,6 +202,9 @@ void UnilateralPlaneConstraint::getConstraintResolution(const Constra std::vector& resTab, unsigned int& offset) { + if(m_componentstate != ComponentState::Valid) + return ; + SOFA_UNUSED(cParams); resTab[offset] = new UnilateralPlaneConstraintResolution(1); @@ -197,6 +215,8 @@ void UnilateralPlaneConstraint::getConstraintResolution(const Constra template void UnilateralPlaneConstraint::draw(const VisualParams* vparams) { + if(m_componentstate != ComponentState::Valid) + return ; if (!vparams->displayFlags().getShowCollisionModels()) return; diff --git a/component/constraint/model/CableModel.h b/component/constraint/model/CableModel.h index 3a3a8bf0..cd3b53de 100644 --- a/component/constraint/model/CableModel.h +++ b/component/constraint/model/CableModel.h @@ -157,6 +157,7 @@ class SOFA_SOFTROBOTS_API CableModel : virtual public SoftRobotsConstraint::m_deltaMax ; using SoftRobotsConstraint::m_lambdaMax ; using SoftRobotsConstraint::addAlias ; + using SoftRobotsConstraint::m_componentstate ; //////////////////////////////////////////////////////////////////////////// }; diff --git a/component/constraint/model/CableModel.inl b/component/constraint/model/CableModel.inl index acac5018..63d36ab5 100644 --- a/component/constraint/model/CableModel.inl +++ b/component/constraint/model/CableModel.inl @@ -48,6 +48,7 @@ namespace component namespace constraintset { +using sofa::core::objectmodel::ComponentState; using sofa::core::visual::VisualParams; using sofa::defaulttype::BaseVector; using sofa::helper::ReadAccessor; @@ -200,6 +201,7 @@ CableModel::~CableModel() template void CableModel::init() { + m_componentstate = ComponentState::Invalid; SoftRobotsConstraint::init(); if(d_indexDeprecated.isSet()) @@ -208,22 +210,32 @@ void CableModel::init() "'index' should be replaced by the field 'indices'." ; if(m_state==nullptr) + { msg_error(this) << "There is no mechanical state associated with this node. " "The object is then deactivated. " "To remove this error message, fix your scene possibly by " "adding a MechanicalObject." ; + return; + } if(m_state->read(VecCoordId::position())==nullptr) + { msg_error(this) << "There is no position vector in the MechanicalState. " "The object is deactivated. " ; + return; + } internalInit(); + m_componentstate = ComponentState::Valid; } template void CableModel::bwdInit() { + if(m_componentstate != ComponentState::Valid) + return ; + // The initial length of the cable is computed in bwdInit so the mapping (if there is any) // will be considered VecCoord positions = (*m_state->read(VecCoordId::position())).getValue(); @@ -239,6 +251,9 @@ void CableModel::bwdInit() template void CableModel::reinit() { + if(m_componentstate != ComponentState::Valid) + return ; + internalInit(); } @@ -246,6 +261,9 @@ void CableModel::reinit() template void CableModel::reset() { + if(m_componentstate != ComponentState::Valid) + return ; + VecCoord positions = (*m_state->read(VecCoordId::position())).getValue(); Real cableLength = getCableLength(positions); d_cableLength.setValue(cableLength); @@ -333,6 +351,9 @@ SReal CableModel::getCableLength(const VecCoord &positions) template void CableModel::buildConstraintMatrix(const ConstraintParams* cParams, DataMatrixDeriv &cMatrix, unsigned int &cIndex, const DataVecCoord &x) { + if(m_componentstate != ComponentState::Valid) + return ; + SOFA_UNUSED(cParams); m_columnIndex = cIndex; @@ -437,6 +458,9 @@ void CableModel::buildConstraintMatrix(const ConstraintParams* cParam template void CableModel::getConstraintViolation(const ConstraintParams* cParams, BaseVector *resV, const DataVecCoord &xfree, const DataVecDeriv &vfree) { + if(m_componentstate != ComponentState::Valid) + return ; + SOFA_UNUSED(cParams); SOFA_UNUSED(vfree); const VecCoord& positions = xfree.getValue(); @@ -467,6 +491,9 @@ void CableModel::getConstraintViolation(const ConstraintParams* cPara template void CableModel::draw(const VisualParams* vparams) { + if(m_componentstate != ComponentState::Valid) + return ; + if (!vparams->displayFlags().getShowInteractionForceFields()) return; drawLinesBetweenPoints(vparams); diff --git a/component/constraint/model/SurfacePressureModel.h b/component/constraint/model/SurfacePressureModel.h index a0d03ce6..c17f4966 100644 --- a/component/constraint/model/SurfacePressureModel.h +++ b/component/constraint/model/SurfacePressureModel.h @@ -148,6 +148,7 @@ class SOFA_SOFTROBOTS_API SurfacePressureModel : virtual public SoftRobotsConstr using SoftRobotsConstraint::m_state ; using SoftRobotsConstraint::getContext ; using SoftRobotsConstraint::m_nbLines ; + using SoftRobotsConstraint::m_componentstate ; //////////////////////////////////////////////////////////////////////////// }; diff --git a/component/constraint/model/SurfacePressureModel.inl b/component/constraint/model/SurfacePressureModel.inl index 1ff10d5a..542beaf8 100644 --- a/component/constraint/model/SurfacePressureModel.inl +++ b/component/constraint/model/SurfacePressureModel.inl @@ -49,6 +49,7 @@ namespace component namespace constraintset { +using sofa::core::objectmodel::ComponentState; using sofa::core::visual::VisualParams; using sofa::helper::vector; using core::ConstVecCoordId; @@ -141,17 +142,24 @@ SurfacePressureModel::~SurfacePressureModel() template void SurfacePressureModel::init() { + m_componentstate = ComponentState::Invalid; SoftRobotsConstraint::init(); if(m_state==nullptr) + { msg_error(this) << "There is no mechanical state associated with this node. " "The object is then deactivated. " "To remove this error message, fix your scene possibly by " "adding a MechanicalObject." ; + return; + } if(m_state->read(VecCoordId::position())==nullptr) + { msg_error(this) << "There is no position vector in the MechanicalState. " "The object is deactivated. " ; + return; + } /// Check that the triangles and quads datafield contain something, otherwise get context /// topology @@ -161,10 +169,13 @@ void SurfacePressureModel::init() BaseMeshTopology* topology = getContext()->getMeshTopology(); if(topology==nullptr) + { msg_error(this) << "There is no topology state associated with this node. " "To remove this error message, fix your scene possibly by " "adding a Topology in the parent node or by giving a list of triangles" "indices or a list of quads indices as nodes parameters ." ; + return; + } d_triangles.setValue(topology->getTriangles()); d_quads.setValue(topology->getQuads()); @@ -214,12 +225,17 @@ void SurfacePressureModel::init() Real volume = getCavityVolume(positions.ref()); d_initialCavityVolume.setValue(volume); d_cavityVolume.setValue(volume); + + m_componentstate = ComponentState::Valid; } template void SurfacePressureModel::reset() { + if(m_componentstate != ComponentState::Valid) + return ; + d_cavityVolume.setValue(d_initialCavityVolume.getValue()); } @@ -273,6 +289,9 @@ void SurfacePressureModel::getConstraintViolation(const ConstraintPar const DataVecCoord &xfree, const DataVecDeriv &vfree) { + if(m_componentstate != ComponentState::Valid) + return ; + SOFA_UNUSED(cParams); SOFA_UNUSED(vfree); @@ -286,6 +305,9 @@ void SurfacePressureModel::buildConstraintMatrix(const ConstraintPara unsigned int &columnIndex, const DataVecCoord &x) { +// if(m_componentstate != ComponentState::Valid) +// return ; + SOFA_UNUSED(cParams); m_columnId = columnIndex; @@ -338,6 +360,9 @@ void SurfacePressureModel::buildConstraintMatrix(const ConstraintPara template void SurfacePressureModel::draw(const VisualParams* vparams) { + if(m_componentstate != ComponentState::Valid) + return ; + if (m_visualization) drawValue(vparams); if (!vparams->displayFlags().getShowInteractionForceFields()) return; diff --git a/component/controller/AnimationEditor.inl b/component/controller/AnimationEditor.inl index b49f0995..28e52346 100644 --- a/component/controller/AnimationEditor.inl +++ b/component/controller/AnimationEditor.inl @@ -64,6 +64,8 @@ namespace controller namespace _animationeditor_ { +using sofa::core::objectmodel::ComponentState; + using sofa::core::objectmodel::KeypressedEvent; using sofa::simulation::AnimateBeginEvent; @@ -115,6 +117,8 @@ AnimationEditor::~AnimationEditor() template void AnimationEditor::init() { + m_componentstate = ComponentState::Invalid; + m_keyFramesID.clear(); if(d_maxKeyFrame.getValue()<=0) @@ -123,23 +127,26 @@ void AnimationEditor::init() m_state = dynamic_cast*>(getContext()->getMechanicalState()); if(m_state == nullptr) { - msg_warning() <<"This component needs a mechanical state in its context with the correct template. Abort."; + msg_error() <<"This component needs a mechanical state in its context with the correct template. Abort."; return; } - else //Store initial state - { - m_keyFramesID.push_back(0); - m_animation.resize(1,m_state->read(core::ConstVecCoordId::position())->getValue()); - } + + m_keyFramesID.push_back(0); + m_animation.resize(1,m_state->read(core::ConstVecCoordId::position())->getValue()); if(d_load.getValue()) loadAnimation(); + + m_componentstate = ComponentState::Valid; } template void AnimationEditor::reinit() { + if(m_componentstate != ComponentState::Valid) + return ; + if(d_maxKeyFrame.getValue()<=0) d_maxKeyFrame.setValue(1); @@ -164,6 +171,9 @@ void AnimationEditor::bwdInit(){} template void AnimationEditor::reset() { + if(m_componentstate != ComponentState::Valid) + return ; + d_cursor.setValue(0); m_isFrameDirty = true; m_time = 0.; @@ -174,12 +184,6 @@ void AnimationEditor::reset() template void AnimationEditor::loadAnimation() { - if(m_state == nullptr) - { - msg_warning() <<"Failed to fetch a mechanical state, abort."; - return; - } - ifstream file; file.open(d_filename.getValue(), ifstream::in); if (file.is_open()) @@ -267,12 +271,6 @@ void AnimationEditor::loadAnimation() template void AnimationEditor::saveAnimation() { - if(m_state == nullptr) - { - msg_warning() <<"Failed to fetch a mechanical state, abort."; - return; - } - msg_info() <<"Saved animation of "<::saveAnimation() template void AnimationEditor::onBeginAnimationStep(const double dt) { - if(m_state == nullptr) - { - msg_warning() <<"Failed to fetch a mechanical state, abort."; - return; - } + if(m_componentstate != ComponentState::Valid) + return ; if(d_dx.isSet()) { @@ -356,6 +351,9 @@ void AnimationEditor::onEndAnimationStep(const double dt) template void AnimationEditor::handleEvent(Event *event) { + if(m_componentstate != ComponentState::Valid) + return ; + if(!d_dx.isSet()) { if (KeypressedEvent* keyEvent = dynamic_cast(event)) @@ -747,6 +745,9 @@ void AnimationEditor::updateAnimationWithInterpolation(const int star template void AnimationEditor::draw(const VisualParams* vparams) { + if(m_componentstate != ComponentState::Valid) + return ; + if(!d_drawTimeline.getValue()) return; #ifdef SOFA_WITH_DACCORD @@ -759,27 +760,6 @@ void AnimationEditor::draw(const VisualParams* vparams) glDisable(GL_LIGHTING); int ratio = round(vparams->viewport()[2]/d_maxKeyFrame.getValue()); - - //////////////////////////////VALUES///////////////////////////// -// string min = "0"; -// string max = std::to_string(d_maxKeyFrame.getValue()); -// string cursor = std::to_string(d_cursor.getValue()); -// const char* value= min.c_str(); -// vparams->drawTool()->writeOverlayText(ratio-1,vparams->viewport()[3]/12*11+5 //Coordinate -// ,10 //Size -// ,Vec4f(0.6,0.6,0.6,1.) //Color -// ,min.c_str()); //Text -// vparams->drawTool()->writeOverlayText(d_maxKeyFrame.getValue()*ratio,vparams->viewport()[3]/12*11+5 -// ,10 -// ,Vec4f(0.6,0.,0.,1.) -// ,max.c_str()); -// vparams->drawTool()->writeOverlayText(d_cursor.getValue()*ratio+10,vparams->viewport()[3]/10*9-25 -// ,10 -// ,Vec4f(0.8,0.8,0.8,1.) -// ,cursor.c_str()); - /////////////////////////////////////////////////////////////////// - - glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadIdentity(); diff --git a/component/controller/CommunicationController.inl b/component/controller/CommunicationController.inl index 82aef645..2eb60b7e 100644 --- a/component/controller/CommunicationController.inl +++ b/component/controller/CommunicationController.inl @@ -255,7 +255,7 @@ template void CommunicationController::checkDataSize(const unsigned int& nbDataFieldReceived) { if(nbDataFieldReceived!=d_nbDataField.getValue()) - msg_warning(this) << "Something wrong with the size of data received. Please check template."; + msg_warning() << "Something wrong with the size of data received. Please check template."; } @@ -274,7 +274,7 @@ void CommunicationController::sendData() bool status = m_socket->send(message); if(!status) - msg_warning(this) << "Problem with communication"; + msg_warning() << "Problem with communication"; } @@ -308,7 +308,7 @@ void CommunicationController::receiveData() checkDataSize(nbDataFieldReceived); } else - msg_warning(this) << "Problem with communication"; + msg_warning() << "Problem with communication"; } diff --git a/component/controller/DataVariationLimiter.inl b/component/controller/DataVariationLimiter.inl index 6235edfb..8c19afdb 100644 --- a/component/controller/DataVariationLimiter.inl +++ b/component/controller/DataVariationLimiter.inl @@ -82,7 +82,7 @@ void DataVariationLimiter::initData() { //Init data if(!d_input.isSet()) - msg_warning(this) << "Input not set."; + msg_warning() << "Input not set."; else { d_inputSize.setValue(d_input.getValue().size()); @@ -152,7 +152,7 @@ void DataVariationLimiter::onBeginAnimationStep(const double dt) if(input.size()::interpolate(const int index) if(d_inputSize.getValue() != output.size() || d_inputSize.getValue() != m_step.size() || d_inputSize.getValue() != m_isStabilizing.size()) { - dmsg_warning(this) << "Size problem in interpolate(), size="< Finish implementation using them or remove them definitely } @@ -111,9 +106,9 @@ void SerialPortBridgeGeneric::checkConnection() int status = m_serial.Open(d_port.getValue().c_str() , d_baudRate.getValue()); if (status!=1) - msg_warning(this) <<"No serial port found"; + msg_warning() <<"No serial port found"; else - msg_info(this) <<"Serial port found"; + msg_info() <<"Serial port found"; } @@ -151,7 +146,7 @@ void SerialPortBridgeGeneric::sendPacketPrecise() int packetlength=d_size.getValue(); m_packetOut.resize(packetlength*2+1); - m_packetOut[0] = (unsigned char)245; //first half + m_packetOut[0] = (unsigned char)245; //first half for (int i=0; i::~CenterOfMass() template void CenterOfMass::init() { + m_componentstate = ComponentState::Invalid; + m_state = dynamic_cast(getContext()->getMechanicalState()); m_mass = dynamic_cast(getContext()->getMass()); if(m_state == nullptr) - msg_warning(this) << "No mechanical state found in the context. The component can not work."; + { + msg_error() << "No mechanical state found in the context. The component is deactivated."; + return; + } if(m_mass == nullptr) - msg_warning(this) << "No mass found in the context. The component can not work."; + { + msg_error() << "No mass found in the context. The component is deactivated."; + return; + } computeCenterOfMass(); + m_componentstate = ComponentState::Valid; } template void CenterOfMass::reinit() { + if(m_componentstate != ComponentState::Valid) + return ; + computeCenterOfMass(); } @@ -99,11 +112,11 @@ void CenterOfMass::reinit() template void CenterOfMass::update() { - if(m_state) - { - cleanDirty(); - computeCenterOfMass(); - } + if(m_componentstate != ComponentState::Valid) + return ; + + cleanDirty(); + computeCenterOfMass(); } @@ -129,6 +142,9 @@ void CenterOfMass::computeCenterOfMass() template void CenterOfMass::handleEvent(Event *event) { + if(m_componentstate != ComponentState::Valid) + return ; + if (AnimateBeginEvent::checkEventType(event)) { setDirtyValue(); @@ -140,6 +156,9 @@ void CenterOfMass::handleEvent(Event *event) template void CenterOfMass::draw(const VisualParams *vparams) { + if(m_componentstate != ComponentState::Valid) + return ; + vector points; points.push_back(d_centerOfMass.getValue()); if(d_visualization.getValue()) diff --git a/component/engine/VolumeFromTetrahedrons.inl b/component/engine/VolumeFromTetrahedrons.inl index 644560f6..1022f7f4 100644 --- a/component/engine/VolumeFromTetrahedrons.inl +++ b/component/engine/VolumeFromTetrahedrons.inl @@ -45,6 +45,7 @@ namespace component namespace engine { +using sofa::core::objectmodel::ComponentState; using helper::ReadAccessor; using helper::vector; using sofa::core::ConstVecCoordId; @@ -74,6 +75,8 @@ VolumeFromTetrahedrons::~VolumeFromTetrahedrons() template void VolumeFromTetrahedrons::init() { + m_componentstate = ComponentState::Invalid; + addInput(&d_positions); addInput(&d_tetras); addInput(&d_hexas); @@ -86,7 +89,7 @@ void VolumeFromTetrahedrons::init() if(m_state == nullptr) { - msg_warning(this) << "No positions given by the user and no mechanical state found in the context. Abort."; + msg_error() << "No positions given by the user and no mechanical state found in the context. The component is deactivated."; return; } @@ -97,6 +100,8 @@ void VolumeFromTetrahedrons::init() initTopology(); checkTopology(); updateVolume(); + + m_componentstate = ComponentState::Valid; } @@ -104,6 +109,9 @@ void VolumeFromTetrahedrons::init() template void VolumeFromTetrahedrons::reinit() { + if(m_componentstate != ComponentState::Valid) + return ; + updateVolume(); } @@ -120,7 +128,7 @@ void VolumeFromTetrahedrons::initTopology() d_hexas.setValue(m_topology->getHexas()); if(!d_hexas.isSet() && !d_tetras.isSet() && !m_topology) - msg_warning(this) << "No tetras or hexas given by the user and no topology context. Abort"; + msg_warning() << "No tetras or hexas given by the user and no topology context. Abort"; } @@ -137,11 +145,11 @@ void VolumeFromTetrahedrons::checkTopology() for(int i=0;i= positions.size() ) - msg_error(this) << "tetras[" << i << "]["<< j << "]="<< tetras[i][j] + msg_error() << "tetras[" << i << "]["<< j << "]="<< tetras[i][j] <<". is too large regarding positions size of(" << positions.size() << ")" ; } } @@ -152,12 +160,12 @@ void VolumeFromTetrahedrons::checkTopology() for(int i=0;i= positions.size() ) - msg_error(this) << "hexas [" <::checkTopology() template void VolumeFromTetrahedrons::update() { + if(m_componentstate != ComponentState::Valid) + return ; + if(m_state && d_doUpdate.getValue()) { ReadAccessor > positions = m_state->read(ConstVecCoordId::position()); @@ -257,6 +268,9 @@ SReal VolumeFromTetrahedrons::getElementVolume(const Hexa& hexa) template void VolumeFromTetrahedrons::handleEvent(Event *event) { + if(m_componentstate != ComponentState::Valid) + return ; + if (AnimateBeginEvent::checkEventType(event)) { setDirtyValue(); diff --git a/component/engine/VolumeFromTriangles.inl b/component/engine/VolumeFromTriangles.inl index 864c6f91..661d8501 100644 --- a/component/engine/VolumeFromTriangles.inl +++ b/component/engine/VolumeFromTriangles.inl @@ -45,6 +45,7 @@ namespace component namespace engine { +using sofa::core::objectmodel::ComponentState; using helper::ReadAccessor; using helper::vector; using sofa::core::ConstVecCoordId; @@ -73,6 +74,8 @@ VolumeFromTriangles::~VolumeFromTriangles() template void VolumeFromTriangles::init() { + m_componentstate = ComponentState::Invalid; + addInput(&d_positions); addInput(&d_triangles); addInput(&d_quads); @@ -84,7 +87,10 @@ void VolumeFromTriangles::init() m_state = dynamic_cast(getContext()->getMechanicalState()); if(m_state == nullptr) - msg_warning(this) << "No positions given by the user and no mechanical state found in the context."; + { + msg_error() << "No positions given by the user and no mechanical state found in the context. The component is deactivated."; + return; + } ReadAccessor > positions = m_state->read(ConstVecCoordId::position()); d_positions.setValue(positions.ref()); @@ -93,12 +99,17 @@ void VolumeFromTriangles::init() initTopology(); checkTopology(); updateVolume(); + + m_componentstate = ComponentState::Valid; } template void VolumeFromTriangles::reinit() { + if(m_componentstate != ComponentState::Valid) + return ; + updateVolume(); } @@ -115,7 +126,7 @@ void VolumeFromTriangles::initTopology() d_quads.setValue(m_topology->getQuads()); if(!d_quads.isSet() && !d_triangles.isSet() && !m_topology) - msg_warning(this) << "No quads or triangles given by the user and no topology context"; + msg_warning() << "No quads or triangles given by the user and no topology context"; } @@ -132,11 +143,11 @@ void VolumeFromTriangles::checkTopology() for(int i=0;i= positions.size() ) - msg_error(this) << "triangles[" << i << "]["<< j << "]="<< triangles[i][j] + msg_error() << "triangles[" << i << "]["<< j << "]="<< triangles[i][j] <<". is too large regarding positions size of(" << positions.size() << ")" ; } } @@ -147,12 +158,12 @@ void VolumeFromTriangles::checkTopology() for(int i=0;i= positions.size() ) - msg_error(this) << "quads [" <::checkTopology() template void VolumeFromTriangles::update() { + if(m_componentstate != ComponentState::Valid) + return ; + if(m_state && d_doUpdate.getValue()) { ReadAccessor > positions = m_state->read(ConstVecCoordId::position()); @@ -218,6 +232,9 @@ void VolumeFromTriangles::updateVolume() template void VolumeFromTriangles::handleEvent(Event *event) { + if(m_componentstate != ComponentState::Valid) + return ; + if (AnimateBeginEvent::checkEventType(event)) { setDirtyValue(); diff --git a/component/forcefield/PREquivalentStiffnessForceField.h b/component/forcefield/PREquivalentStiffnessForceField.h index 8819ac11..47de7f5d 100644 --- a/component/forcefield/PREquivalentStiffnessForceField.h +++ b/component/forcefield/PREquivalentStiffnessForceField.h @@ -144,6 +144,7 @@ private : /// otherwise any access to the base::attribute would require /// the "this->" approach. using ForceField::getContext ; + using ForceField::m_componentstate; //////////////////////////////////////////////////////////////////////////// }; diff --git a/component/forcefield/PREquivalentStiffnessForceField.inl b/component/forcefield/PREquivalentStiffnessForceField.inl index 4a048b8b..f8ffc8e2 100644 --- a/component/forcefield/PREquivalentStiffnessForceField.inl +++ b/component/forcefield/PREquivalentStiffnessForceField.inl @@ -44,8 +44,6 @@ using sofa::helper::WriteAccessor ; #include using std::string ; - - #include using std::filebuf ; @@ -65,6 +63,8 @@ namespace component namespace forcefield { +using sofa::core::objectmodel::ComponentState; + template PREquivalentStiffnessForceField::PREquivalentStiffnessForceField() : Inherit(), @@ -87,6 +87,8 @@ PREquivalentStiffnessForceField::~PREquivalentStiffnessForceField() template void PREquivalentStiffnessForceField::init() { + m_componentstate = ComponentState::Invalid; + Inherit::init(); const string& filename = d_complianceFile.getValue(); @@ -96,10 +98,16 @@ void PREquivalentStiffnessForceField::init() // getting mstate bound to this forcefield MechanicalState* mstate; getContext()->get(mstate, BaseContext::Local); + if(mstate==nullptr) + { + msg_error() << "No mechanical state associated with this component. The component is deactivated."; + return; + } // Read rest positions WriteAccessor restPosWriter(m_restPos); ReadAccessor restPosReader(*mstate->read(core::ConstVecCoordId::restPosition())); + size_t nFrames = restPosReader.size(); restPosWriter.resize(nFrames); m_pos.resize(nFrames); @@ -119,18 +127,19 @@ void PREquivalentStiffnessForceField::init() std::istream file(&filebuffer); for(size_t n = 0 ; n < nFrames - 1 ; ++n) { if( ! (file >> m_complianceMat[n]) ) { - serr << "Unable to read compliance matrix for frames [" << n << " | " << n + 1 << "]" << sendl; + msg_warning() << "Unable to read compliance matrix for frames [" << n << " | " << n + 1 << "]"; } else { m_CInv[n].invert(m_complianceMat[n]); - cout << "Inverting compliance #" << n << "\n"< @@ -139,6 +148,9 @@ void PREquivalentStiffnessForceField::addForce(const MechanicalParams const DataVecCoord& x, const DataVecDeriv& v) { + if(m_componentstate != ComponentState::Valid) + return ; + SOFA_UNUSED(v); const VecCoord& X = x.getValue(); @@ -229,7 +241,6 @@ void PREquivalentStiffnessForceField::addForce(const MechanicalParams F1 = q0Current.rotate(F1); tau1 = q0Current.rotate(tau1); - //Vec6 f1(F1, tau1); // compute transport matrix Vec3 p0p1; @@ -257,7 +268,6 @@ void PREquivalentStiffnessForceField::addForce(const MechanicalParams F0 = q0Current.rotate(F0); tau0 = q0Current.rotate(tau0); - //Vec6 f0(F0, tau0); Vec6 f0( F0atX0inWorld.getForce(), F0atX0inWorld.getTorque()); Vec6 f1(-F1atX1inWorld.getForce(), -F1atX1inWorld.getTorque()); @@ -275,13 +285,6 @@ void PREquivalentStiffnessForceField::addForce(const MechanicalParams m_K[n + start].setsub(6, 6, m_CInv[n]); - Vec12 U_test; - for (unsigned int i=0; i<6; i++) - U_test[i+6] = Uloc[i]; - - Vec12 F_test = m_K[n + start]*U_test; - - // build rotation matrix 4 3x3 blocks on diagonal Mat33 Rn; q0Current.toMatrix(Rn); @@ -300,30 +303,20 @@ template void PREquivalentStiffnessForceField::addDForce(const MechanicalParams* mparams, DataVecDeriv& d_f , const DataVecDeriv& d_x) -{ +{ + if(m_componentstate != ComponentState::Valid) + return ; + const VecDeriv& dx = d_x.getValue(); VecDeriv& dfdq = *d_f.beginEdit(); const size_t nFrames = dx.size(); - VecCoord displaced(dx.size()); - - const Real epsilon = 1e-8; const Real kFact = mparams->kFactor(); - const Real coef = d_coeff.getValue(); const unsigned int& start = d_startIndex.getValue(); for(size_t n = 0 ; n < nFrames - (1 + start) ; ++n) { Vec12 dq; - /* sometimes doesn't work... - // convert to Vec6 using getVAll() then grab the pointer - Real* dq0 = dx[n + 0 + start].getVAll().ptr(); - Real* dq1 = dx[n + 1 + start].getVAll().ptr(); - - // concatenate the two Vec6 - std::copy(dq0, dq0 + 6, dq.ptr()); - std::copy(dq1, dq1 + 6, dq.ptr() + 6); - */ for (unsigned int i=0; i<6; i++) { dq[i ] = dx[n + 0 + start][i]; @@ -355,7 +348,10 @@ template void PREquivalentStiffnessForceField::addKToMatrix(BaseMatrix* matrix, double kFact, unsigned int& offset) -{ +{ + if(m_componentstate != ComponentState::Valid) + return ; + if( CSRMatB66* csrMat = dynamic_cast(matrix) ) { for(size_t n = 0 ; n < m_K.size() ; ++n) { const Mat12x12& K = m_K[n]; @@ -417,7 +413,6 @@ void PREquivalentStiffnessForceField::computeForce(const VecCoord& po const VecCoord& restPos, VecDeriv& f) { - const size_t nFrames = pos.size(); const Real coef = d_coeff.getValue(); diff --git a/component/forcefield/PartialRigidificationForceField.inl b/component/forcefield/PartialRigidificationForceField.inl index ffad187f..42542b8d 100644 --- a/component/forcefield/PartialRigidificationForceField.inl +++ b/component/forcefield/PartialRigidificationForceField.inl @@ -72,11 +72,6 @@ template void PartialRigidificationForceField::addKToMatrix(const MechanicalParams* mparams, const MultiMatrixAccessor* matrix) { - - if(f_printLog.getValue()) - sout << "entering addKToMatrix" << sendl; - - MultiMatrixAccessor::MatrixRef mat11 = matrix->getMatrix(mstate1); MultiMatrixAccessor::MatrixRef mat22 = matrix->getMatrix(mstate2); MultiMatrixAccessor::InteractionMatrixRef mat12 = matrix->getMatrix(mstate1, mstate2); @@ -85,18 +80,11 @@ void PartialRigidificationForceField::addKToMatrix(const const helper::vector* J0J1 = d_subsetMultiMapping.get()->getJs(); if(J0J1 == NULL) - serr<<" WARNING J0J1 null"; - else - { - std::cout<<" J0J1 ok"<size() != 2) { - serr << "subsetMultiMapping doesn't have 2 output mechanical states. This is not handled in PartialRigidification. AddKToMatrix not computed " << sendl; + msg_error() << "SubsetMultiMapping does not have two output mechanical states. This is not handled in PartialRigidification. AddKToMatrix not computed."; return; } CompressedRowSparseMatrix<_3_3_Matrix_Type>* J0; @@ -110,16 +98,16 @@ void PartialRigidificationForceField::addKToMatrix(const Jr = dynamic_cast *> (d_rigidMapping.get()->getJ() ); if(J0 == NULL) { - serr << "J0 null" << sendl; + dmsg_error() << "J0 null"; } if(J1 == NULL) { - serr << "J1 null" << sendl; + dmsg_error() << "J1 null"; } if(Jr == NULL) { - serr << "Jr null" << sendl; + dmsg_error() << "Jr null"; } if((J0 == NULL) || (J1 == NULL) || (Jr == NULL) ) { - serr << "a jacobian matrix from Mapping is missing. AddKToMatrix not computed" << sendl; + msg_error() << "A jacobian matrix from Mapping is missing. AddKToMatrix not computed"; return; } @@ -236,10 +224,6 @@ void PartialRigidificationForceField::addKToMatrix(const delete K; delete mappedFFMatrix; delete mappedFFMatrixAccessor; - - if(f_printLog.getValue()) - sout << "exit addKToMatrix" << sendl; - } template @@ -265,21 +249,6 @@ void PartialRigidificationForceField::testBuildJacobian( d_mappedForceField.get()->addKToMatrix(mparams, mappedFFMatrixAccessor); - // CompressedRowSparseMatrix<_3_6_Matrix_Type> J1Jr ; - // CompressedRowSparseMatrix<_3_3_Matrix_Type> J0tK ; - // CompressedRowSparseMatrix<_3_3_Matrix_Type> J0tKJ0 ; - // CompressedRowSparseMatrix<_3_6_Matrix_Type> J0tKJ1Jr ; - // CompressedRowSparseMatrix<_6_6_Matrix_Type> JrtJ1tKJ1Jr ; - // CompressedRowSparseMatrix<_6_3_Matrix_Type> JrtJ1tK ; - // CompressedRowSparseMatrix<_6_3_Matrix_Type> JrtJ1tKJ0 ; - - //--Warning K set but unused : TODO clean or refactorize - - //CompressedRowSparseMatrix<_3_3_Matrix_Type>* K ; - //K = dynamic_cast*>(r.matrix); - - //-- - sofa::core::State * state = dynamic_cast *>(mstate); unsigned int stateSize = mstate->getSize(); diff --git a/component/forcefield/PipeForceField.inl b/component/forcefield/PipeForceField.inl index 8260383a..8759afc6 100644 --- a/component/forcefield/PipeForceField.inl +++ b/component/forcefield/PipeForceField.inl @@ -44,8 +44,6 @@ using sofa::helper::WriteAccessor ; #include using std::string ; - - #include using std::filebuf ; @@ -122,29 +120,39 @@ template void PipeForceField::addKToMatrix(const MechanicalParams* mparams, const MultiMatrixAccessor* matrix) { - sout << "Entering addKToMatrix" << sendl; - - - if (d_barycentricMapping.get() == NULL ) {serr << "Mapping is missing. AddKToMatrix not computed" << sendl; return;} - else sout << "Got mapping" << sendl; - if (d_mappedForceField.get() == NULL ) {serr << "MappedFF is missing. AddKToMatrix not computed" << sendl; return;} - else sout << "Got mappedFF" << sendl; + if (d_barycentricMapping.get() == NULL ) + { + msg_error() << "Mapping is missing. AddKToMatrix not computed"; + return; + } + if (d_mappedForceField.get() == NULL ) + { + msg_error() << "MappedFF is missing. AddKToMatrix not computed"; + return; + } //Get the jacobian matrix from the BarycentricMapping const CompressedRowSparseMatrix<_3_3_Matrix_Type>* J; J = dynamic_cast *> (d_barycentricMapping.get()->getJ() ); - if (J == NULL ) {serr << "Jacobian matrix from Mapping is missing. AddKToMatrix not computed" << sendl; return;} - else sout << "Got Jacobian matrix from Mapping" << sendl; + if (J == NULL ) + { + msg_error() << "Jacobian matrix from Mapping is missing. AddKToMatrix not computed"; + return; + } //Get the stiffness matrix from the mapped ForceField CompressedRowSparseMatrix< _3_3_Matrix_Type >* mappedFFMatrix = new CompressedRowSparseMatrix< _3_3_Matrix_Type > ( ); BaseMechanicalState* springState = d_mappedForceField.get()->getContext()->getMechanicalState(); - if (springState == NULL ) {serr << "Mstate from mappedFF is missing. AddKToMatrix not computed" << sendl; delete mappedFFMatrix; return;} - else sout << "Got mstate matrix from mappedFF" << sendl; + if (springState == NULL ) + { + msg_error() << "Mstate from mappedFF is missing. AddKToMatrix not computed"; + delete mappedFFMatrix; + return; + } DefaultMultiMatrixAccessor* mappedFFMatrixAccessor = new DefaultMultiMatrixAccessor; mappedFFMatrixAccessor->addMechanicalState(springState); @@ -185,8 +193,6 @@ void PipeForceField::addKToMatrix(const MechanicalParams* mparams, delete K; delete mappedFFMatrix; delete mappedFFMatrixAccessor; - - sout << "exit addKToMatrix" << sendl; } diff --git a/tests/component/constraint/SurfacePressureConstraintTest.cpp b/tests/component/constraint/SurfacePressureConstraintTest.cpp index d572e971..70172eb7 100644 --- a/tests/component/constraint/SurfacePressureConstraintTest.cpp +++ b/tests/component/constraint/SurfacePressureConstraintTest.cpp @@ -31,6 +31,8 @@ #include #include "../../../component/constraint/SurfacePressureConstraint.h" +using sofa::component::constraintset::SurfacePressureConstraint; + #include #include #include @@ -49,16 +51,19 @@ using std::string; using std::fabs; using std::stof; +using sofa::core::objectmodel::ComponentState; + namespace sofa { template - struct SurfacePressureConstraintTest : public Sofa_test, sofa::component::constraintset::SurfacePressureConstraint<_DataTypes> + struct SurfacePressureConstraintTest : public Sofa_test, SurfacePressureConstraint<_DataTypes> { +// using SurfacePressureConstraint<_DataTypes>::m_componentstate; + simulation::Node::SPtr m_root; ///< Root of the scene graph, created by the constructor an re-used in the tests simulation::Simulation* m_simulation; ///< created by the constructor an re-used in the tests - typedef _DataTypes DataTypes; typedef typename DataTypes::Deriv Deriv; typedef typename DataTypes::VecDeriv VecDeriv; @@ -102,6 +107,7 @@ namespace sofa { MatrixDeriv& column = *columns.beginEdit(); columns.endEdit(); +// m_componentstate = ComponentState::Valid; this->buildConstraintMatrix(cparams, columns, columnsIndex, x); MatrixDeriv columnExpected; From 0da0c6d481ca81b987f648ebeee7dc33314de5f4 Mon Sep 17 00:00:00 2001 From: COEVOET Eulalie Date: Tue, 22 May 2018 12:05:33 +0200 Subject: [PATCH 2/3] fix --- component/constraint/CableConstraint.h | 2 +- component/constraint/CableConstraint.inl | 4 ++-- .../constraint/SurfacePressureConstraint.h | 2 +- .../constraint/SurfacePressureConstraint.inl | 5 +++-- component/constraint/model/CableModel.h | 20 +++++++++---------- .../constraint/model/SurfacePressureModel.h | 10 +++++----- .../SurfacePressureConstraintTest.cpp | 4 ++-- 7 files changed, 24 insertions(+), 23 deletions(-) diff --git a/component/constraint/CableConstraint.h b/component/constraint/CableConstraint.h index 63c14234..b4248c12 100644 --- a/component/constraint/CableConstraint.h +++ b/component/constraint/CableConstraint.h @@ -148,7 +148,7 @@ class CableConstraint : public CableModel using CableModel::d_maxDispVariation ; using CableModel::d_force ; using CableModel::d_displacement ; -// using CableModel::m_componentstate ; + using CableModel::m_componentstate ; /////////////////////////////////////////////////////////////////////////// protected: diff --git a/component/constraint/CableConstraint.inl b/component/constraint/CableConstraint.inl index c95bd257..335453d4 100644 --- a/component/constraint/CableConstraint.inl +++ b/component/constraint/CableConstraint.inl @@ -130,8 +130,8 @@ void CableConstraint::getConstraintResolution(const ConstraintParams* std::vector& resTab, unsigned int& offset) { -// if(this->m_componentstate != ComponentState::Valid) -// return ; + if(m_componentstate != ComponentState::Valid) + return ; SOFA_UNUSED(cParam); diff --git a/component/constraint/SurfacePressureConstraint.h b/component/constraint/SurfacePressureConstraint.h index 957d4675..7db86fe4 100644 --- a/component/constraint/SurfacePressureConstraint.h +++ b/component/constraint/SurfacePressureConstraint.h @@ -149,7 +149,7 @@ class SOFA_SOFTROBOTS_API SurfacePressureConstraint : public SurfacePressureMode using SurfacePressureModel::m_displayedValue ; using SurfacePressureModel::m_columnId; using SurfacePressureModel::m_visualization; -// using SoftRobotsConstraint::m_componentstate; + using SoftRobotsConstraint::m_componentstate; //////////////////////////////////////////////////////////////////////////// private: diff --git a/component/constraint/SurfacePressureConstraint.inl b/component/constraint/SurfacePressureConstraint.inl index 27a021fd..266cc239 100644 --- a/component/constraint/SurfacePressureConstraint.inl +++ b/component/constraint/SurfacePressureConstraint.inl @@ -47,6 +47,7 @@ namespace constraintset namespace _surfacepressureconstraint_ { +using sofa::core::objectmodel::ComponentState ; using sofa::helper::WriteAccessor ; using sofa::defaulttype::Vec3d; using sofa::helper::vector ; @@ -165,8 +166,8 @@ template void SurfacePressureConstraint::getConstraintResolution(std::vector& resTab, unsigned int& offset) { -// if(m_componentstate != ComponentState::Valid) -// return ; + if(m_componentstate != ComponentState::Valid) + return ; double imposed_value = d_value.getValue()[d_valueIndex.getValue()]; m_displayedValue = d_value.getValue()[d_valueIndex.getValue()]; diff --git a/component/constraint/model/CableModel.h b/component/constraint/model/CableModel.h index cd3b53de..ba412c77 100644 --- a/component/constraint/model/CableModel.h +++ b/component/constraint/model/CableModel.h @@ -135,16 +135,6 @@ class SOFA_SOFTROBOTS_API CableModel : virtual public SoftRobotsConstraint::addAlias ; using SoftRobotsConstraint::m_componentstate ; //////////////////////////////////////////////////////////////////////////// + +private: + void internalInit(); + + void checkIndicesRegardingState(); + void initActuatedPoints(); + + void drawPullPoint(const VisualParams* vparams); + void drawPoints(const VisualParams* vparams); + void drawLinesBetweenPoints(const VisualParams* vparams); }; // Declares template as extern to avoid the code generation of the template for diff --git a/component/constraint/model/SurfacePressureModel.h b/component/constraint/model/SurfacePressureModel.h index c17f4966..52c0c1fe 100644 --- a/component/constraint/model/SurfacePressureModel.h +++ b/component/constraint/model/SurfacePressureModel.h @@ -135,11 +135,6 @@ class SOFA_SOFTROBOTS_API SurfacePressureModel : virtual public SoftRobotsConstr void drawLines(const VisualParams* vparams, float red, float green, float blue); std::string getValueString(Real pressure); -private: - - void drawValue(const core::visual::VisualParams* vparams); - void computeEdges(); - ////////////////////////// Inherited attributes //////////////////////////// /// https://gcc.gnu.org/onlinedocs/gcc/Name-lookup.html /// Bring m_state in the current lookup context. @@ -150,6 +145,11 @@ class SOFA_SOFTROBOTS_API SurfacePressureModel : virtual public SoftRobotsConstr using SoftRobotsConstraint::m_nbLines ; using SoftRobotsConstraint::m_componentstate ; //////////////////////////////////////////////////////////////////////////// + +private: + + void drawValue(const core::visual::VisualParams* vparams); + void computeEdges(); }; // Declares template as extern to avoid the code generation of the template for diff --git a/tests/component/constraint/SurfacePressureConstraintTest.cpp b/tests/component/constraint/SurfacePressureConstraintTest.cpp index 70172eb7..b1c96a56 100644 --- a/tests/component/constraint/SurfacePressureConstraintTest.cpp +++ b/tests/component/constraint/SurfacePressureConstraintTest.cpp @@ -59,7 +59,7 @@ namespace sofa { struct SurfacePressureConstraintTest : public Sofa_test, SurfacePressureConstraint<_DataTypes> { -// using SurfacePressureConstraint<_DataTypes>::m_componentstate; + using SurfacePressureConstraint<_DataTypes>::m_componentstate; simulation::Node::SPtr m_root; ///< Root of the scene graph, created by the constructor an re-used in the tests simulation::Simulation* m_simulation; ///< created by the constructor an re-used in the tests @@ -107,7 +107,7 @@ namespace sofa { MatrixDeriv& column = *columns.beginEdit(); columns.endEdit(); -// m_componentstate = ComponentState::Valid; + m_componentstate = ComponentState::Valid; this->buildConstraintMatrix(cparams, columns, columnsIndex, x); MatrixDeriv columnExpected; From 9a45f32b198965ce3249ab6245ea0d76a9ed2151 Mon Sep 17 00:00:00 2001 From: COEVOET Eulalie Date: Tue, 22 May 2018 12:13:45 +0200 Subject: [PATCH 3/3] forgotten changes --- component/constraint/model/SurfacePressureModel.inl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/component/constraint/model/SurfacePressureModel.inl b/component/constraint/model/SurfacePressureModel.inl index 542beaf8..53827cb7 100644 --- a/component/constraint/model/SurfacePressureModel.inl +++ b/component/constraint/model/SurfacePressureModel.inl @@ -305,8 +305,8 @@ void SurfacePressureModel::buildConstraintMatrix(const ConstraintPara unsigned int &columnIndex, const DataVecCoord &x) { -// if(m_componentstate != ComponentState::Valid) -// return ; + if(m_componentstate != ComponentState::Valid) + return ; SOFA_UNUSED(cParams);