@@ -292,14 +292,28 @@ class Radiation: public RefinableObj
292292* This class only computes structure factor, but no intensity. i.e. it does
293293* not include any correction such as absorption, Lorentz or Polarization.
294294*
295- * Does this really need to be a RefinableObj ?
296295* \todo Optimize computation for Bijvoet/Friedel mates. To do this, generate
297296* an internal list of 'true independent reflections', with two entries for each,
298297* for both mates, and make the 'real' reflections only a reference to these reflections.
299298*
300299* \todo a \b lot of cleaning is necessary in the computing of structure
301300* factors, for (1) the 'preparation' part (deciding what needs to be recomputed)
302301* and (2) to allow anisotropic temperature factors (or other anisotropic parts)
302+ *
303+ * \note
304+ * all H,K,L related parameters are mutable so that a PowderPatternDiffraction
305+ * list of reflections can be updated whenever the spacegroup or
306+ * lattice parameters are changed, and this needs to automatically happen
307+ * even when calling const-functions like PowderPatternDiffraction::CalcPowderPattern().
308+ *
309+ * \par
310+ * Nevertheless this 'const' modification of HKL's are meant to be purely internal,
311+ * so the const functions are all protected, and the non-const ones (such as
312+ * SetHKL or GenHKLFullSpace) are public.
313+ *
314+ * \par
315+ * Single crystal classes should not make use of the new const functions since
316+ * changing the list of HKL's is effectively mutating the object.
303317*/
304318// ######################################################################
305319class ScatteringData : virtual public RefinableObj
@@ -463,13 +477,58 @@ class ScatteringData: virtual public RefinableObj
463477 // / Clock the last time the number of reflections used was changed
464478 const RefinableObjClock& GetClockNbReflBelowMaxSinThetaOvLambda ()const ;
465479 protected:
480+ /* * \brief \internal input H,K,L
481+ *
482+ * \param h,k,l: REAL arrays (vectors with NbRefl elements -same size),
483+ *with the h, k and l coordinates of all reflections.
484+ */
485+ virtual void SetHKL ( const CrystVector_REAL &h,
486+ const CrystVector_REAL &k,
487+ const CrystVector_REAL &l) const ;
488+ /* * \brief Generate a list of h,k,l to describe a full reciprocal space,
489+ * up to a given maximum theta value
490+ *
491+ * \param maxTheta:maximum theta value
492+ * \param unique: if set to true, only unique reflections will be listed.
493+ * Bijvoet (Friedel) pairs
494+ * are NOT merged, for 'anomalous' reasons, unless you have chosen to ignore the
495+ * imaginary part of the scattering factor.
496+ *
497+ * The multiplicity is always stored in ScatteringData::mMultiplicity.
498+ *
499+ * \warning The ScatteringData object must already have been assigned
500+ * a crystal object using SetCrystal(), and the experimental wavelength
501+ * must also have been set before calling this function.
502+ */
503+ virtual void GenHKLFullSpace2 (const REAL maxsithsl,
504+ const bool unique=false ) const ;
505+ /* * \brief \internal Generate a list of h,k,l to describe a full reciprocal space,
506+ * up to a given maximum theta value
507+ *
508+ * \param maxsithsl:maximum sin(theta)/lambda=1/2d value
509+ * \param unique: if set to true, only unique reflections will be listed.
510+ * Bijvoet (Friedel) pairs
511+ * are NOT merged, for 'anomalous' reasons, unless you have chosen to ignore the
512+ * imaginary part of the scattering factor.
513+ *
514+ * The multiplicity is always stored in ScatteringData::mMultiplicity.
515+ *
516+ * \warning The ScatteringData object must already have been assigned
517+ * a crystal object using SetCrystal(), and the experimental wavelength
518+ * must also have been set before calling this function.
519+ *
520+ * \deprecated Rather use PowderPattern::GenHKLFullSpace2,
521+ * with a maximum sin(theta)/lambda value, which also works for dispersive experiments.
522+ */
523+ virtual void GenHKLFullSpace (const REAL maxTheta,
524+ const bool unique=false ) const ;
466525 // / \internal This function is called after H,K and L arrays have
467526 // / been initialized or modified.
468- virtual void PrepareHKLarrays () ;
527+ virtual void PrepareHKLarrays () const ;
469528 // / \internal sort reflections by theta values (also get rid of [0,0,0] if present)
470529 // / If maxSTOL >0, then only reflections where sin(theta)/lambda<maxSTOL are kept
471530 // / \return an array with the subscript of the kept reflections (for inherited classes)
472- virtual CrystVector_long SortReflectionBySinThetaOverLambda (const REAL maxSTOL=-1 .);
531+ virtual CrystVector_long SortReflectionBySinThetaOverLambda (const REAL maxSTOL=-1 .) const ;
473532 // / \internal Get rid of extinct reflections. Useful after GenHKLFullSpace().
474533 // / Do not use this if you have a list of observed reflections !
475534 // /
@@ -532,9 +591,9 @@ class ScatteringData: virtual public RefinableObj
532591 void CalcStructFactVariance ()const ;
533592
534593 // / Number of H,K,L reflections
535- long mNbRefl ;
594+ mutable long mNbRefl ;
536595 // / H,K,L coordinates
537- CrystVector_REAL mH , mK , mL ;
596+ mutable CrystVector_REAL mH , mK , mL ;
538597 // / H,K,L integer coordinates
539598 mutable CrystVector_long mIntH , mIntK , mIntL ;
540599 // / H,K,L coordinates, multiplied by 2PI
@@ -543,13 +602,13 @@ class ScatteringData: virtual public RefinableObj
543602 mutable CrystVector_REAL mX , mY , mZ ;
544603
545604 // /Multiplicity for each reflections (mostly for powder diffraction)
546- CrystVector_int mMultiplicity ;
605+ mutable CrystVector_int mMultiplicity ;
547606
548607 /* * Expected intensity factor for all reflections.
549608 *
550609 * See SpaceGroup::GetExpectedIntensityFactor()
551610 */
552- CrystVector_int mExpectedIntensityFactor ;
611+ mutable CrystVector_int mExpectedIntensityFactor ;
553612
554613 // / real &imaginary parts of F(HKL)calc
555614 mutable CrystVector_REAL mFhklCalcReal , mFhklCalcImag ;
@@ -609,7 +668,7 @@ class ScatteringData: virtual public RefinableObj
609668
610669 // Public Clocks
611670 // / Clock for the list of hkl
612- RefinableObjClock mClockHKL ;
671+ mutable RefinableObjClock mClockHKL ;
613672 // / Clock for the structure factor
614673 mutable RefinableObjClock mClockStructFactor ;
615674 // / Clock for the square modulus of the structure factor
@@ -676,9 +735,9 @@ class ScatteringData: virtual public RefinableObj
676735 mutable RefinableObjClock mClockLuzzatiFactor ;
677736 mutable RefinableObjClock mClockFhklCalcVariance ;
678737 // / Observed squared structure factors (zero-sized if none)
679- CrystVector_REAL mFhklObsSq ;
738+ mutable CrystVector_REAL mFhklObsSq ;
680739 // / Last time observed squared structure factors were altered
681- RefinableObjClock mClockFhklObsSq ;
740+ mutable RefinableObjClock mClockFhklObsSq ;
682741 #ifdef __WX__CRYST__
683742 // to access mMaxSinThetaOvLambda
684743 friend class WXDiffractionSingleCrystal ;
0 commit comments