Esempio n. 1
0
            public DataTableCrystalDatabaseRow CreateRow(Crystal2 c)
            {
                var elementList = new StringBuilder();

                foreach (var n in c.atoms.Select(a => a.AtomNo).Distinct())
                {
                    elementList.Append($"{n:000} ");
                }

                var d = new float[8];

                if (c.d != null)
                {
                    Array.Copy(c.d, d, c.d.Length);
                }

                DataTableCrystalDatabaseRow dr;

                try
                {
                    rwlock.EnterWriteLock();
                    dr = NewDataTableCrystalDatabaseRow();
                }
                finally { rwlock.ExitWriteLock(); }

                var(cellValues, _) = c.Cell;

                dr.SerializedCrystal2 = serialize(c);
                dr.Name          = c.name;
                dr.Formula       = c.formula;
                dr.Density       = c.density;
                dr.A             = cellValues.A;
                dr.B             = cellValues.B;
                dr.C             = cellValues.C;
                dr.Alpha         = cellValues.Alpha;
                dr.Beta          = cellValues.Beta;
                dr.Gamma         = cellValues.Gamma;
                dr.CrystalSystem = SymmetryStatic.StrArray[c.sym][16];//s.CrystalSystemStr;
                dr.PointGroup    = SymmetryStatic.StrArray[c.sym][13];
                dr.SpaceGroup    = SymmetryStatic.StrArray[c.sym][3];
                dr.Authors       = c.auth;
                dr.Title         = Crystal2.GetFullTitle(c.sect);
                dr.Journal       = Crystal2.GetFullJournal(c.jour);
                dr.Elements      = elementList.ToString();
                dr.D1            = d[0];
                dr.D2            = d[1];
                dr.D3            = d[2];
                dr.D4            = d[3];
                dr.D5            = d[4];
                dr.D6            = d[5];
                dr.D7            = d[6];
                dr.D8            = d[7];

                return(dr);
            }
Esempio n. 2
0
            public DataTableCrystalDatabaseRow CreateRow(Crystal2 c)
            {
                DataTableCrystalDatabaseRow dr;

                lock (lockObj)
                    dr = NewDataTableCrystalDatabaseRow();

                dr.SerializedCrystal2 = serialize(c);
                dr.Name    = c.name;
                dr.Formula = c.formula;
                dr.Density = c.density;
                (dr.A, dr.B, dr.C, dr.Alpha, dr.Beta, dr.Gamma) = c.Cell.Values;
                dr.CrystalSystem = SymmetryStatic.StrArray[c.sym][16];//s.CrystalSystemStr;
                dr.PointGroup    = SymmetryStatic.StrArray[c.sym][13];
                dr.SpaceGroup    = SymmetryStatic.StrArray[c.sym][3];
                dr.Authors       = c.auth;
                dr.Title         = Crystal2.GetFullTitle(c.sect);
                dr.Journal       = Crystal2.GetFullJournal(c.jour);
                dr.Elements      = string.Join(' ', c.atoms.Select(a => a.AtomNo).Distinct().Select(b => b.ToString("000")));


                var d = ArrayPool <float> .Shared.Rent(8);

                if (c.d != null)
                {
                    Array.Copy(c.d, d, c.d.Length);
                }
                dr.D1 = d[0] * 10;
                dr.D2 = d[1] * 10;
                dr.D3 = d[2] * 10;
                dr.D4 = d[3] * 10;
                dr.D5 = d[4] * 10;
                dr.D6 = d[5] * 10;
                dr.D7 = d[6] * 10;
                dr.D8 = d[7] * 10;
                ArrayPool <float> .Shared.Return(d);

                return(dr);
            }