Пример #1
0
        public void SetCellParameters(double[] parameters, double[] error)
        {
            if (parameters == null || parameters.Length != 6)
            {
                throw new ApplicationException("Must have 6 cell parameters");
            }
            var cellParamVector = this.Elements(XName_CML_scalar);
            var count           = cellParamVector.Count();

            if (count == 0)
            {
                for (int i = 0; i < 6; i++)
                {
                    CMLScalar cellParam = CMLCrystal.CreateScalar(
                        CRYSTAL_DICT_REFS[i], parameters[i], CRYSTAL_DICT_UNITS[i],
                        double.NaN);
                    this.Add(cellParam);
                }
            }
            else if (count == 6)
            {
                int i = 0;
                foreach (var e in cellParamVector)
                {
                    CMLScalar cellParam = (CMLScalar)e;
                    cellParam.SetValue(parameters[i]);
                    if (error != null)
                    {
                        cellParam.ErrorValue = parameters[i];
                    }
                    cellParam.DictRef = CRYSTAL_DICT_REFS[i];
                    i++;
                }
            }
            else
            {
                throw new ApplicationException(
                          "Corrupted cell parameters: must be exactly 6 (found: "
                          + cellParamVector.Count());
            }
        }
Пример #2
0
        private CMLMolecule CDKCrystalToCMLMolecule(ICrystal crystal, bool setIDs)
        {
            var molecule   = CDKAtomContainerToCMLMolecule(crystal, false, false);
            var cmlCrystal = new CMLCrystal();

            if (useCMLIDs && setIDs)
            {
                IDCreator.CreateIDs(crystal);
            }
            if (!string.IsNullOrEmpty(crystal.Id))
            {
                cmlCrystal.Id = crystal.Id;
            }

            this.CheckPrefix(cmlCrystal);
            cmlCrystal.Z = crystal.Z.Value;
            var params_ = CrystalGeometryTools.CartesianToNotional(crystal.A, crystal.B, crystal.C);

            Debug.WriteLine($"Number of cell params: {params_.Length}");
            cmlCrystal.SetCellParameters(params_);
            molecule.Add(cmlCrystal);
            return(molecule);
        }