Пример #1
0
        //----------------------------------------------//
        void showLayer(int layerIndex=-1)
        {
            //- don't run this more then once the same time
            if (m_doingRender) return;
            m_doingRender = true;

            if (layerIndex == -1) layerIndex = sliceLayer.Value;

            //- get Position of the layer
            labLayerIndex.Text = i2s(layerIndex);
            labLayerPos.Text = d2s(layerIndex * sliFile.getLayerThickness()) + " mm";

            float layerPos = layerIndex * sliFile.getLayerThickness();

            //- get Part Count
            int partCount = sliFile.getPartCount();

            for (int part = 0; part < partCount; part++)
            {
                if (isPartEnabled(part))
                {
                    //- find layerIndex for this position
                    int index = sliFile.getLayerIndexByPos(part, layerPos);

                    //- read layer data (ToDo: only do this if layer-index for this part has changed)
                    sliFile.readSliceData(index, part);
                }
            }

            //- create transformations Matrix (only 2d but Homogeneous coordinates)
            clSliceDataLib.clMatrix3x2 m = new clSliceDataLib.clMatrix3x2();

            m.m.m11 = (float)s2d(txt_m11.Text);
            m.m.m12 = (float)s2d(txt_m12.Text);
            m.m.m13 = (float)s2d(txt_m13.Text);

            m.m.m21 = (float)s2d(txt_m21.Text);
            m.m.m22 = (float)s2d(txt_m22.Text);
            m.m.m23 = (float)s2d(txt_m23.Text);

            //- Homogeneous coordinates
            //- m31 = 0;
            //- m32 = 0;
            //- m33 = 1;

            //- output image
            int w = picOutput.Width;
            int h = picOutput.Height;

            int[,] img_polyline = null;
            int[,] img_filled = null;

            //- create img Buffer
            if (chkFill.Checked)
            {
                img_filled = new int[w, h];
            }
            else
            {
                img_polyline = new int[w, h];
            }

            //- rander slice
            for (int part = 0; part < partCount; part++)
            {
                int color = colorTable[part % colorTable.Length];

                //- because it is faster to do both (fild and outline)
                if (isPartEnabled(part)) sliFile.addRasterObject(img_filled, img_polyline, part, m, color);
            }

            //- show randered slice
            if (chkFill.Checked)
            {
                picOutput.Image = getBitmap(img_filled);
            }
            else
            {
                picOutput.Image = getBitmap(img_polyline);
            }

            for (int part = 0; part < partCount; part++)
            {
                int index = sliFile.getLayerIndexByPos(part, layerPos);

                lstPartNames.Items[part] = getPartListName(part, index);
            }

            m_doingRender = false;
        }
Пример #2
0
        //----------------------------------------------//
        void showLayer(int layerIndex = -1)
        {
            if (sliFile == null)
            {
                return;
            }

            //- don't run this more then once the same time
            if (m_doingRender)
            {
                return;
            }
            m_doingRender = true;

            if (layerIndex == -1)
            {
                layerIndex = sliceLayer.Value;
            }


            //- get Position of the layer
            labLayerIndex.Text = i2s(layerIndex);
            labLayerPos.Text   = d2s(layerIndex * sliFile.getLayerThickness()) + " mm";


            float layerPos = layerIndex * sliFile.getLayerThickness();

            //- get Part Count
            int partCount = sliFile.getPartCount();

            for (int part = 0; part < partCount; part++)
            {
                if (isPartEnabled(part))
                {
                    //- find layerIndex for this position
                    int index = sliFile.getLayerIndexByPos(part, layerPos);

                    //- read layer data (ToDo: only do this if layer-index for this part has changed)
                    sliFile.readSliceData(index, part);
                }
            }



            //- create transformations Matrix (only 2d but Homogeneous coordinates)
            clSliceDataLib.clMatrix3x2 m = new clSliceDataLib.clMatrix3x2();

            m.m.m11 = (float)s2d(txt_m11.Text);
            m.m.m12 = (float)s2d(txt_m12.Text);
            m.m.m13 = (float)s2d(txt_m13.Text);

            m.m.m21 = (float)s2d(txt_m21.Text);
            m.m.m22 = (float)s2d(txt_m22.Text);
            m.m.m23 = (float)s2d(txt_m23.Text);

            //- Homogeneous coordinates
            //- m31 = 0;
            //- m32 = 0;
            //- m33 = 1;

            //- output image
            int w = picOutput.Width;
            int h = picOutput.Height;

            int[,] img_polyline = null;
            int[,] img_filled   = null;

            //- create img Buffer
            if (chkFill.Checked)
            {
                img_filled = new int[w, h];
            }
            else
            {
                img_polyline = new int[w, h];
            }



            //- rander slice
            for (int part = 0; part < partCount; part++)
            {
                int color = colorTable[part % colorTable.Length];

                //- because it is faster to do both (fild and outline)
                if (isPartEnabled(part))
                {
                    sliFile.addRasterObject(img_filled, img_polyline, part, m, color);
                }
            }

            //- show randered slice
            if (chkFill.Checked)
            {
                picOutput.Image = getBitmap(img_filled);
            }
            else
            {
                picOutput.Image = getBitmap(img_polyline);
            }



            for (int part = 0; part < partCount; part++)
            {
                int index = sliFile.getLayerIndexByPos(part, layerPos);

                lstPartNames.Items[part] = getPartListName(part, index);
            }

            m_doingRender = false;
        }