Skip to content

Commit

Permalink
[PlayBack] Add option to set period in the WriteStateCreator visitor (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
epernod committed May 20, 2024
1 parent b11f9b8 commit 651e7a3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,15 @@ WriteStateCreator::WriteStateCreator(const core::ExecParams* params)
#endif
, recordX(true)
, recordV(true)
, recordF(false)
, createInMapping(false)
, counterWriteState(0)
{
}

WriteStateCreator::WriteStateCreator(const core::ExecParams* params, const std::string &n, bool _recordX, bool _recordV, bool _recordF, bool _createInMapping, int c)
WriteStateCreator::WriteStateCreator(const core::ExecParams* params, const std::string & _sceneName, bool _recordX, bool _recordV, bool _recordF, bool _createInMapping, int _counterState)
:simulation::Visitor(params)
, sceneName(n)
, sceneName(_sceneName)
#if SOFA_COMPONENT_PLAYBACK_HAVE_ZLIB
, extension(".txt.gz")
#else
Expand All @@ -60,7 +61,7 @@ WriteStateCreator::WriteStateCreator(const core::ExecParams* params, const std::
, recordV(_recordV)
, recordF(_recordF)
, createInMapping(_createInMapping)
, counterWriteState(c)
, counterWriteState(_counterState)
{
}

Expand Down Expand Up @@ -108,6 +109,8 @@ void WriteStateCreator::addWriteState(sofa::core::behavior::BaseMechanicalState
if (!m_times.empty())
ws->d_time.setValue(m_times);

ws->d_period.setValue(m_period);

ws->init();
ws->f_listening.setValue(true); //Activated at init

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ class SOFA_COMPONENT_PLAYBACK_API WriteStateCreator: public simulation::Visitor
{
public:
WriteStateCreator(const core::ExecParams* params);
WriteStateCreator(const core::ExecParams* params, const std::string &n, bool _recordX, bool _recordV, bool _recordF, bool _createInMapping, int c=0);
WriteStateCreator(const core::ExecParams* params, const std::string &_sceneName, bool _recordX, bool _recordV, bool _recordF, bool _createInMapping, int _counterState=0);
Result processNodeTopDown( simulation::Node* ) override;

void setSceneName(std::string &n) { sceneName = n; }
Expand All @@ -124,7 +124,8 @@ class SOFA_COMPONENT_PLAYBACK_API WriteStateCreator: public simulation::Visitor
void setCounter(int c) { counterWriteState = c; }
const char* getClassName() const override { return "WriteStateCreator"; }

void setExportTimes(const type::vector<double> times) { m_times = times; }
void setExportTimes(const type::vector<double>& times) { m_times = times; }
void setPeriod(double period) { m_period = period; }
protected:
std::string sceneName;
std::string extension;
Expand All @@ -134,6 +135,7 @@ class SOFA_COMPONENT_PLAYBACK_API WriteStateCreator: public simulation::Visitor
bool createInMapping;

int counterWriteState; //avoid to have two same files if two mechanical objects has the same name
double m_period = 0.0;

void addWriteState(sofa::core::behavior::BaseMechanicalState*ms, simulation::Node* gnode);

Expand Down

0 comments on commit 651e7a3

Please sign in to comment.