Index: kernel/include/IMP/score_states/GravityCenterScoreState.h =================================================================== --- kernel/include/IMP/score_states/GravityCenterScoreState.h (revision 533) +++ kernel/include/IMP/score_states/GravityCenterScoreState.h (working copy) @@ -35,10 +35,7 @@ \param[in] ps Original particles used to calculate the center. */ GravityCenterScoreState(Particle *center, FloatKey weightkey=FloatKey(), - const Particles &ps= Particles()) - : center_(center), weightkey_(weightkey) { - add_particles(ps); - } + const Particles &ps= Particles()); virtual ~GravityCenterScoreState() {} //! Set the position of the center particle from the original points. @@ -59,7 +56,6 @@ void transform_derivatives(DerivativeAccumulator *accpt); Particle *center_; - Particles ps_; FloatKey weightkey_; IMP_LIST(public, Particle, particle, Particle*); Index: kernel/src/score_states/GravityCenterScoreState.cpp =================================================================== --- kernel/src/score_states/GravityCenterScoreState.cpp (revision 533) +++ kernel/src/score_states/GravityCenterScoreState.cpp (working copy) @@ -12,8 +12,17 @@ namespace IMP { +GravityCenterScoreState::GravityCenterScoreState(Particle *center, + FloatKey weightkey, + const Particles &ps) + : center_(center), weightkey_(weightkey) { + XYZDecorator::cast(center); + add_particles(ps); +} + +// check that the particle is an xyz particle IMP_LIST_IMPL(GravityCenterScoreState, Particle, particle, Particle*, - {if (0) std::cout << *obj << index;}, set_position()); + XYZDecorator::cast(obj), set_position()); void GravityCenterScoreState::set_position() { @@ -24,7 +33,7 @@ for (ParticleIterator iter = particles_begin(); iter != particles_end(); ++iter) { Particle *p = *iter; - XYZDecorator d = XYZDecorator::cast(p); + XYZDecorator d(p); Float weight = do_weighting ? p->get_value(weightkey_) : 1.0; total_weight += weight; for (int i = 0; i < 3; ++i) { @@ -37,7 +46,7 @@ cvect[i] /= total_weight; } } - XYZDecorator d = XYZDecorator::cast(center_); + XYZDecorator d(center_); d.set_coordinates_are_optimized(false); for (int i = 0; i < 3; ++i) { d.set_coordinate(i, cvect[i]); @@ -49,7 +58,8 @@ { size_t nchildren = number_of_particles(); if (nchildren > 0) { - XYZDecorator d = XYZDecorator::cast(center_); + // we know center is OK since update was called + XYZDecorator d(center_); Vector3D deriv; // divide derivatives equally between all children for (int i = 0; i < 3; ++i) {