@@ -41,15 +41,15 @@ ProximityOscillatorConstraint<DataTypes>::ProximityOscillatorConstraint()
4141 , d_outputPositions(initData(&d_outputPositions, " outputPositions" , " List of output coordinates points" ))
4242 , d_centers(initData(&d_centers, " centers" , " List of center coordinates points" ))
4343 , d_pace(initData(&d_pace, 1 .0_sreal, " pace" , " Time to perform a full Pace (deflate + inflate). Same scale as the simulation time." ))
44- , d_amplitude(initData(&d_amplitude, 0 .8_sreal, " amplitude" , " Amplitude of the oscillation" ))
44+ , d_amplitude(initData(&d_amplitude, 0 .8_sreal, " amplitude" , " Amplitude of the oscillation" ))
4545 , p_showMotion(initData(&p_showMotion, bool (false ), " showMotion" , " Parameter to display the force direction" ))
4646 , m_startTime()
47- {
47+ {
4848 addInput (&d_positions);
4949 addInput (&d_centers);
5050
5151 addOutput (&d_outputPositions);
52- this ->f_listening .setValue (true );
52+ this ->f_listening .setValue (true );
5353}
5454
5555
@@ -75,7 +75,7 @@ void ProximityOscillatorConstraint<DataTypes>::init()
7575
7676 m_startTime = std::chrono::system_clock::now ();
7777 sofa::core::objectmodel::BaseObject::d_componentState.setValue (sofa::core::objectmodel::ComponentState::Valid);
78- nextStart = d_pace.getValue () / length;
78+ nextStart = d_pace.getValue () / length;
7979}
8080
8181
@@ -84,12 +84,12 @@ void ProximityOscillatorConstraint<DataTypes>::computeDistribution()
8484{
8585 sofa::helper::ReadAccessor< core::objectmodel::Data< VecCoord > > _x = d_positions;
8686 sofa::helper::ReadAccessor< core::objectmodel::Data< VecCoord > > _centers = d_centers;
87-
88- m_centersOrdered = _centers;
89- std::sort (m_centersOrdered.begin (), m_centersOrdered.end (),
90- [](const Coord& a, const Coord& b) {
87+
88+ m_centersOrdered = _centers;
89+ std::sort (m_centersOrdered.begin (), m_centersOrdered.end (),
90+ [](const Coord& a, const Coord& b) {
9191 return a[1 ] > b[1 ];
92- });
92+ });
9393
9494 if (f_printLog.getValue ())
9595 {
@@ -105,14 +105,14 @@ void ProximityOscillatorConstraint<DataTypes>::computeDistribution()
105105 auto dist = [](const Coord& a, const Coord& b) { return (b - a).norm (); };
106106 auto cmp = [&pt2, &dist](const Coord& a, const Coord& b) {
107107 return dist (a, pt2) < dist (b, pt2);
108- };
108+ };
109109
110110 for (size_t i = 0 ; i < _x.size (); ++i)
111111 {
112112 pt2 = _x[i];
113113 auto it = std::min_element (m_centersOrdered.begin (), m_centersOrdered.end (), cmp);
114114 m_distribution[i] = std::distance (m_centersOrdered.begin (), it);
115- }
115+ }
116116}
117117
118118
@@ -133,46 +133,46 @@ void ProximityOscillatorConstraint<DataTypes>::doUpdate()
133133
134134 // we apply a force proportional to the pace rate. 0 Force at start of pace, 0 at end, F at half pace
135135 const Real pacePercent = std::fmod (time, pace) / pace;
136-
137- if (time >= nextStart) // at every pace/2 we start moving a new center and stop previous one
136+
137+ if (time >= nextStart) // at every pace/2 we start moving a new center and stop previous one
138138 {
139139 centerStart++;
140140 centerDone++;
141- nextStart += pace / length;
141+ nextStart += pace / length;
142142 }
143143
144144 // G ---- X -- X0
145145
146146 const Real amplitude = d_amplitude.getValue ();
147- const Real frequency = pace;
147+ const Real frequency = pace;
148148
149149 for (size_t i = 0 ; i < inX.size (); ++i)
150150 {
151151 int centerId = m_distribution[i];
152- if (centerId > centerStart || centerId <= centerDone )
152+ if (centerId > centerStart || centerId <= centerDone)
153153 {
154- outX[i] = inX[i];
155- continue ;
154+ outX[i] = inX[i];
155+ continue ;
156156 }
157157
158- const Coord& center = m_centersOrdered[centerId];
158+ const Coord& center = m_centersOrdered[centerId];
159159 const Coord& p0 = inX[i];
160160 Coord dir = center - p0;
161161
162162 // Real omega = centerId * i;//2.0 * M_PI * frequency;
163163 // Real omega = Real(centerId) / Real(_centers.size()) * M_PI * 12;
164164 Real omega = centerId * 2.0 * M_PI / length;
165- Real oscillation = amplitude * std::cos (pacePercent * 2.0 * M_PI - omega);
165+ Real oscillation = amplitude * std::cos (pacePercent * 2.0 * M_PI - omega);
166166 oscillation = amplitude - (oscillation + amplitude) / 2 .0_sreal; // normalize between 0 and 0.9
167167
168168 outX[i] = p0 + dir * oscillation;
169169 }
170170
171171 if (centerDone >= int (m_centersOrdered.size ()) && pacePercent >= 0.99 )
172172 {
173- if (f_printLog.getValue ())
173+ if (f_printLog.getValue ())
174174 std::cout << " centerDone " << centerDone << " | " << m_centersOrdered.size () << std::endl;
175-
175+
176176 centerDone = -4 ;
177177 centerStart = 0 ;
178178 nextStart = time + pace / length;
@@ -197,7 +197,7 @@ void ProximityOscillatorConstraint<DataTypes>::draw(const core::visual::VisualPa
197197 return ;
198198 }
199199 const auto stateLifeCycle = vparams->drawTool ()->makeStateLifeCycle ();
200-
200+
201201 sofa::helper::ReadAccessor< core::objectmodel::Data< VecCoord > > _x = d_outputPositions;
202202 // sofa::helper::ReadAccessor< core::objectmodel::Data< VecCoord > > _centers = d_centers;
203203
0 commit comments