Ejemplo n.º 1
0
        static String CreateMessage(SliceType type, string specify, params Type[] declaringTypes)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("Must give ");
            if (specify != null)
            {
                sb.Append(specify);
                sb.Append(" ");
            }
            for (int i = 0; i < declaringTypes.Length; i++)
            {
                if (i > 0)
                {
                    sb.Append(" or ");
                }
                sb.Append(declaringTypes[i].Name);
            }
            sb.Append(" for ");
            sb.Append(type.ToString());
            return(sb.ToString());
        }
Ejemplo n.º 2
0
        public override void ForeWork()
        {
            // Загрузка и сортировка модели
            if (!LoadModel(ModelFileName))
            {
                Console.WriteLine("Can't load model " + ModelFileName + ", exiting");
                ForeWorkResult = false;
                return;
            }
            Console.WriteLine("\nModel " + ModelFileName + " loaded:");
            Console.WriteLine("a=" + a.ToString("####0.00") + "A  b=" + b.ToString("####0.00") + "A  c=" + c.ToString("####0.00") + "A  gam=" + gam.ToString("####0.00") + "  NAtoms=" + NAtoms);

            // Разрезка на слои
            Console.WriteLine("Slicing scheme is " + SliceType.ToString());
            SliceModel();
            Console.WriteLine(NSlices + " slices");

            // Сохранение слоев
            if (!SaveSlices())
            {
                Console.WriteLine("Can't save slices, exiting");
                ForeWorkResult = false;
                return;
            }

            long allbytes = GC.GetTotalMemory(false);

            Atoms = null;            // free a memory occupied by the model
            GC.Collect();
            allbytes = GC.GetTotalMemory(true);
            Console.WriteLine("\n>>>>>Allocated in managed heap after Atoms free and GC3 " + allbytes);


            //выделение памяти под картинки STEM, если считается STEM
            if (IniWaveType == IniWaveTypes.STEMshift)
            {
                STEMimages = new double[Emat.Length, Math.Max(BeamTilt.Length, 1), Math.Max(ConvAngles.Length, 1),
                                        Math.Max(Dfmat.Length, 1), Math.Max(Csmat.Length, 1), Math.Max(CrystalTilt.Length, 1), (IsCalcAll?1:ThWaves.Length), DetectorAngles.Length][];



                for (iE = 0; iE < Emat.Length; iE++)
                {
                    for (iBT = 0; iBT < Math.Max(BeamTilt.Length, 1); iBT++)
                    {
                        for (iCA = 0; iCA < Math.Max(ConvAngles.Length, 1); iCA++)
                        {
                            for (iDf = 0; iDf < Math.Max(Dfmat.Length, 1); iDf++)
                            {
                                for (iCs = 0; iCs < Math.Max(Csmat.Length, 1); iCs++)
                                {
                                    for (iCT = 0; iCT < Math.Max(CrystalTilt.Length, 1); iCT++)
                                    {
                                        for (int iTW = 0; iTW < (IsCalcAll?1:ThWaves.Length); iTW++)
                                        {
                                            for (int iDA = 0; iDA < DetectorAngles.Length; iDA++)
                                            {
                                                STEMimages[iE, iBT, iCA, iDf, iCs, iCT, iTW, iDA] = new double[BeamShift.Length];
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }


            ForeWorkResult = true;
        }
Ejemplo n.º 3
0
        public override void ForeWork()
        {
            // Загрузка и сортировка модели
            if (!LoadModel(ModelFileName))
            {
                Console.WriteLine("Can't load model " + ModelFileName + ", exiting");
                ForeWorkResult = false;
                return;
            }
            Console.WriteLine("\nModel " + ModelFileName + " loaded:");
            Console.WriteLine("a=" + a.ToString("####0.00") + "A  b=" + b.ToString("####0.00") + "A  c=" + c.ToString("####0.00") + "A  gam=" + gam.ToString("####0.00") + "  NAtoms=" + NAtoms);

            // Создание кривых рассеяния при необходимости (если не надо - возвращается из функции обратно)
            if (!PrepareCurves())
            {
                Console.WriteLine("Can't create curves, exiting");
                ForeWorkResult = false;
                return;
            }

            // Разрезка на слои
            Console.WriteLine("Slicing scheme is " + SliceType.ToString());
            SliceModel();
            Console.WriteLine(NSlices + " slices");


            //выделение памяти под картинки STEM, если считается STEM
            if (IniWaveType == IniWaveTypes.STEMshift)
            {
                STEMimages = new double[Emat.Length, Math.Max(BeamTilt.Length, 1), Math.Max(ConvAngles.Length, 1),
                                        Math.Max(Dfmat.Length, 1), Math.Max(Csmat.Length, 1), Math.Max(CrystalTilt.Length, 1), (IsCalcAll?1:ThWaves.Length), DetectorAngles.Length][];



                for (iE = 0; iE < Emat.Length; iE++)
                {
                    for (iBT = 0; iBT < Math.Max(BeamTilt.Length, 1); iBT++)
                    {
                        for (iCA = 0; iCA < Math.Max(ConvAngles.Length, 1); iCA++)
                        {
                            for (iDf = 0; iDf < Math.Max(Dfmat.Length, 1); iDf++)
                            {
                                for (iCs = 0; iCs < Math.Max(Csmat.Length, 1); iCs++)
                                {
                                    for (iCT = 0; iCT < Math.Max(CrystalTilt.Length, 1); iCT++)
                                    {
                                        for (int iTW = 0; iTW < (IsCalcAll?1:ThWaves.Length); iTW++)
                                        {
                                            for (int iDA = 0; iDA < DetectorAngles.Length; iDA++)
                                            {
                                                STEMimages[iE, iBT, iCA, iDf, iCs, iCT, iTW, iDA] = new double[BeamShift.Length];
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }

            ForeWorkResult = true;
        }