Example #1
0
        public static List <MolData> ShiftAll(bool hasWalls, int wallsType, bool onlyPolymer, double density, double[] sizes, double[] shifts, double[] centerPoint, List <double[]> data)
        {
            var system = new List <MolData>();

            foreach (var c in data)
            {
                for (int i = 0; i <= 2; i++)
                {
                    if (c[3] != 1.08 && c[3] != 1.09)
                    {
                        c[i] += shifts[i];
                        if (c[i] <= centerPoint[i] - sizes[i] / 2.0)
                        {
                            c[i] += sizes[i];
                        }
                        if (c[i] >= centerPoint[i] + sizes[i] / 2.0)
                        {
                            c[i] -= sizes[i];
                        }
                    }
                }
            }
            double maxNum = sizes[0] * sizes[1] * sizes[2] * density;

            if (data.Count < Math.Abs(maxNum))
            {
                maxNum = data.Count;
            }
            for (int i = 0; (double)i < maxNum; i++)
            {
                var newAtom = new MolData(data[i][3], i + 1, Convert.ToInt32(data[i][4]), data[i][0], data[i][1], data[i][2]);
                system.Add(newAtom);
            }
            if (onlyPolymer)
            {
                system = system.Where(x => x.AtomType.Equals(1.00) ||
                                      x.AtomType.Equals(1.01) ||
                                      x.AtomType.Equals(1.04) ||
                                      x.AtomType.Equals(1.09)).ToList();
            }

            if (hasWalls)
            {
                StructFormer fFormer = new StructFormer(hasWalls, wallsType, sizes[0], sizes[1], sizes[2], density, centerPoint, data);
                if (wallsType == 1 && system.Where(x => x.AtomType.Equals(1.09)).ToList().Count == 0)
                {
                    fFormer.AddWalls(system);
                }
            }
            return(system);
        }
Example #2
0
        private void btnRecolor_Click(object sender, EventArgs e)
        {
            int molOneAmount = Convert.ToInt32(tbNonLinMolAmount.Text);
            int nonLinLength = Convert.ToInt32(tbNonLinLength.Text);
            int linLength    = Convert.ToInt32(tbLinMolLenght_Page8_2.Text);
            int molTwoCount  = 0;

            if (linLength > 0)
            {
                molTwoCount = (InputColorData.Where <double[]>((x => x[3] <= 1.01)).Count() - molOneAmount * nonLinLength) / linLength;
            }

            RecoloredComposition = StructFormer.Recolor(chbLeftOnlyPolymer_2.Checked, true, chbAllDiff.Checked, chbIsDb.Checked,
                                                        cmbNonLinPlace.SelectedIndex, nonLinLength, molOneAmount, linLength, molTwoCount, InputColorData);
            btnSaveStruct_Page2.Enabled = true;
        }
Example #3
0
        private void btnCutSlice_Click(object sender, EventArgs e)
        {
            try
            {
                if (cmbCutAxis.SelectedIndex == -1)
                {
                    MessageBox.Show(null, "Вы не выбрали плоскость среза!", "Внимание!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;
                }
                else if (tbCutCoord.Text == "")
                {
                    MessageBox.Show(null, "Вы не выбрали координату среза!", "Внимание!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;
                }
                else
                {
                    double coord = replaceValue(tbCutCoord.Text);
                    if (cmbCutAxis.SelectedIndex == 0)
                    {
                        double sizeZ = replaceValue(tbZ_Page1.Text);
                        if (Math.Abs(coord) > sizeZ / 2.0)
                        {
                            MessageBox.Show(null, "Координата среза больше размеров ящика!", "Внимание!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                            return;
                        }
                    }
                    if (cmbCutAxis.SelectedIndex == 1)
                    {
                        double sizeY = replaceValue(tbY_Page1.Text);
                        if (Math.Abs(coord) > sizeY / 2.0)
                        {
                            MessageBox.Show(null, "Координата среза больше размеров ящика!", "Внимание!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                            return;
                        }
                    }
                    if (cmbCutAxis.SelectedIndex == 2)
                    {
                        double sizeX = replaceValue(tbX_Page1.Text);
                        if (Math.Abs(coord) > sizeX / 2.0)
                        {
                            MessageBox.Show(null, "Координата среза больше размеров ящика!", "Внимание!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                            return;
                        }
                    }
                    double xSize   = replaceValue(tbX_Page1.Text);
                    double ySize   = replaceValue(tbY_Page1.Text);
                    double zSize   = replaceValue(tbZ_Page1.Text);
                    double density = replaceValue(tbDensity_Page1.Text);
                    if (chbBySphere.Checked)
                    {
                        coord = replaceValue(tbSphereRad.Text);
                    }

                    EditedComposition = StructFormer.MakeSlice(chbCutOnlyPolymer.Checked, chbBySphere.Checked, density,
                                                               xSize, ySize, zSize, cmbCutAxis.SelectedIndex, coord, InputCut);
                    if (btnSaveStruct_Page1.Enabled)
                    {
                        return;
                    }

                    btnSaveStruct_Page1.Enabled = true;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(null, ex.ToString(), "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                return;
            }
        }