Ejemplo n.º 1
0
        public void DrawSignature()
        {
            if (ListWells == null) return;

            g = this.panelForDesignDisplay.CreateGraphics();

            g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
            g.Clear(Color.White);

            int SizeWell = 8;
            CurrBrush = new SolidBrush(Color.Fuchsia);

            PosXMin = int.MaxValue;
            PosYMin = int.MaxValue;
            PosXMax = int.MinValue;
            PosYMax = int.MinValue;

            foreach (cWell TmpWell in ListWells)
            {
                if (TmpWell == null) continue;
                if (TmpWell.GetPosX() > PosXMax) PosXMax = TmpWell.GetPosX();
                if (TmpWell.GetPosY() > PosYMax) PosYMax = TmpWell.GetPosY();

                if (TmpWell.GetPosX() < PosXMin) PosXMin = TmpWell.GetPosX();
                if (TmpWell.GetPosY() < PosYMin) PosYMin = TmpWell.GetPosY();
            }

            int SizeX = PosXMax - PosXMin + 1;
            int SizeY = PosYMax - PosYMin + 1;

            if (this.radioButtonOrientationLine.Checked)
            {
                this.numericUpDownConcentrationNumber.Value = (decimal)SizeX;
                this.numericUpDownReplication.Value = (decimal)SizeY;
                if (PosXMin > PosXMax) return;
                TemplateRegion = new cDRC_Region(ListWells[0].AssociatedPlate, (int)this.numericUpDownConcentrationNumber.Value, (int)this.numericUpDownReplication.Value, PosXMin, PosYMin, true);
            }
            else
            {
                this.numericUpDownConcentrationNumber.Value = (decimal)SizeY;
                this.numericUpDownReplication.Value = (decimal)SizeX;
                if (PosXMin > PosXMax) return;
                TemplateRegion = new cDRC_Region(ListWells[0].AssociatedPlate, (int)this.numericUpDownConcentrationNumber.Value, (int)this.numericUpDownReplication.Value, PosXMin, PosYMin, false);
            }
            DrawSingleRegion(0, 0, 0);

            for (int j = 1; j <= ListWells[0].AssociatedPlate.ParentScreening.Columns + 1; j++)
                g.DrawLine(new Pen(Color.Black), new Point(j * SizeWell, SizeWell), new Point(j * SizeWell, (ListWells[0].AssociatedPlate.ParentScreening.Rows + 1) * SizeWell));
            for (int i = 1; i <= ListWells[0].AssociatedPlate.ParentScreening.Rows + 1; i++)
                g.DrawLine(new Pen(Color.Black), new Point(SizeWell, i * SizeWell), new Point((ListWells[0].AssociatedPlate.ParentScreening.Columns + 1) * SizeWell, i * SizeWell));
        }
Ejemplo n.º 2
0
        private void Create(cDRC_Region AssociatedRegion, Color Color, double Regularization)
        {
            Position = new cPoint3D(AssociatedRegion.PosXMin + 1, AssociatedRegion.PosYMin + 0.7, 0);

            List<cPoint3D> ListPtSigma = new List<cPoint3D> ( );

            double GlobalMin = double.MaxValue;
            double GlobalMax = double.MinValue;
            for (int j = 0; j < AssociatedRegion.SizeY; j++)
                for (int i = 0; i < AssociatedRegion.SizeX; i++)
                {
                    cWell TmpWell = AssociatedRegion.GetListWells()[j][i];
                    if (TmpWell == null) continue;
                    double PosZ = TmpWell.ListDescriptors[TmpWell.AssociatedPlate.ParentScreening.ListDescriptors.CurrentSelectedDescriptor].GetValue();
                    if (PosZ >= GlobalMax) GlobalMax = PosZ;
                    if (PosZ <= GlobalMin) GlobalMin = PosZ;

                    ListPtSigma.Add(new cPoint3D(i/(double)AssociatedRegion.SizeX,PosZ,j/(double)AssociatedRegion.SizeY));
                }

            if (GlobalMax == GlobalMin) return;

            double[,] ResultThinPlate = calc_tps(ListPtSigma, AssociatedRegion, Regularization);

            if (ResultThinPlate == null)
            {
               // MessageBox.Show("Error in computing the associated thinplate !", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

              //  Position = new cPoint3D(0, 0, 0);
            this.Colour = Color;
            vtkPoints points = vtkPoints.New();
               // vtkPoints points0 = vtkPoints.New();

            //vtkUnsignedCharArray colors = vtkUnsignedCharArray.New();
            //colors.SetName("Colors");
            //colors.SetNumberOfComponents(3);
            //colors.SetNumberOfTuples(AssociatedRegion.SizeX * AssociatedRegion.SizeY);

            int Idx = 0;
            for(int j=0;j<AssociatedRegion.SizeY;j++)
                for (int i = 0; i < AssociatedRegion.SizeX; i++)
            {
                cWell TmpWell = AssociatedRegion.GetListWells()[j][i];

                double PosZ  = 8 - ( (ResultThinPlate[i,j]-GlobalMin)/(GlobalMax-GlobalMin))*8;

                //points.InsertPoint(Idx,TmpWell.GetPosX(), TmpWell.GetPosY(), PosZ);

                    //  points.InsertPoint(Idx, TmpWell.GetPosX(), TmpWell.GetPosY(), 0);
                points.InsertPoint(Idx++, i, j, PosZ);
              //  colors.InsertTuple3(Idx++, 1, 1, 1);

            }

              vtkPolyData profile = vtkPolyData.New();
            profile.SetPoints(points);

            vtkDelaunay2D del = vtkDelaunay2D.New();
            del.SetInput(profile);
            del.SetTolerance(0.001);

            vtkButterflySubdivisionFilter subdivisionFilter = vtkButterflySubdivisionFilter.New();
            subdivisionFilter.SetInput(del.GetOutput());
            subdivisionFilter.SetNumberOfSubdivisions(2);
            subdivisionFilter.Update();

            vtk_PolyDataMapper = vtkPolyDataMapper.New();

            AlgoOutPut = subdivisionFilter.GetOutputPort();

            vtk_PolyDataMapper.SetInputConnection(AlgoOutPut);
               // vtk_PolyDataMapper.GetInput().GetPointData().AddArray(colors);
               // vtk_PolyDataMapper.ScalarVisibilityOn();
               // vtk_PolyDataMapper.SetScalarModeToUsePointFieldData();
               // vtk_PolyDataMapper.SelectColorArray("Colors");

             //         vtkLinearExtrusionFilter  extrude = vtkLinearExtrusionFilter.New();
             //         extrude.SetInput(cutter.GetOutput());
             //extrude.SetScaleFactor(1);
             //extrude.SetExtrusionTypeToNormalExtrusion();
             //extrude.SetVector(1, 1, 1);

              //vtkRotationalExtrusionFilter extrude = vtkRotationalExtrusionFilter.New();
              //extrude.SetInput(cutter.GetOutput());
              //extrude.SetResolution(60);
              //extrude.Update();

            //vtk_PolyDataMapper.SetInputConnection(tubeFilter.GetOutputPort());

            CreateVTK3DObject(3);

            SetColor(Color);
               // SetOpacity(1);
            SetToSurface();
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Compute the Thin Plate Spline of the image, return a 2D tab
        /// </summary>
        /// <param name="control_points">Control points  </param>    
        /// <param name="input">Input image to get the dim xy</param>
        public double[,] calc_tps(List<cPoint3D> control_points, cDRC_Region AssociatedRegion, double Regularization)
        {
            int p = control_points.Count;
            if (p < 3) return null;
            double[,] grid = new double[AssociatedRegion.SizeX, AssociatedRegion.SizeY];
            Matrix mtx_l = new Matrix(p + 3, p + 3);
            Matrix mtx_v = new Matrix(p + 3, 1);
            Matrix mtx_orig_k = new Matrix(p, p);
            double a = 0.0;
            for (int i = 0; i < p; ++i)
            {
                for (int j = i + 1; j < p; ++j)
                {
                    cPoint3D pt_i = new cPoint3D(control_points[i].X, control_points[i].Y, control_points[i].Z);
                    cPoint3D pt_j = new cPoint3D(control_points[j].X, control_points[j].Y, control_points[j].Z);

                    pt_i.Y = pt_j.Y = 0;

                    //double elen = Math.Sqrt((pt_i.X - pt_j.X) * (pt_i.X - pt_j.X) + (pt_i.Z - pt_j.Z) * (pt_i.Z - pt_j.Z));
                    double elen = pt_i.DistTo(pt_j);
                    mtx_l[i, j] = mtx_l[j, i] = mtx_orig_k[i, j] = mtx_orig_k[j, i] = tps_base_func(elen);
                    a += elen * 2; // same for upper & lower tri
                }
            }
            a /= (double)(p * p);
            //regularization = 0.3f;
            //Fill the rest of L
            for (int i = 0; i < p; ++i)
            {
                //diagonal: reqularization parameters (lambda * a^2)

                mtx_l[i, i] = mtx_orig_k[i, i] = Regularization * (a * a);

                // P (p x 3, upper right)
                mtx_l[i, p + 0] = 1.0;
                mtx_l[i, p + 1] = control_points[i].X;
                mtx_l[i, p + 2] = control_points[i].Z;

                // P transposed (3 x p, bottom left)
                mtx_l[p + 0, i] = 1.0;
                mtx_l[p + 1, i] = control_points[i].X;
                mtx_l[p + 2, i] = control_points[i].Z;
            }
            // O (3 x 3, lower right)
            for (int i = p; i < p + 3; ++i)
                for (int j = p; j < p + 3; ++j)
                    mtx_l[i, j] = 0.0;

            // Fill the right hand vector V
            for (int i = 0; i < p; ++i)
                mtx_v[i, 0] = control_points[i].Y;

            mtx_v[p + 0, 0] = mtx_v[p + 1, 0] = mtx_v[p + 2, 0] = 0.0;
            // Solve the linear system "inplace"
            Matrix mtx_v_res = new Matrix(p + 3, 1);

            LuDecomposition ty = new LuDecomposition(mtx_l);

            mtx_v_res = ty.Solve(mtx_v);
            if (mtx_v_res == null)
            {
                return null;
            }

            // Interpolate grid heights
            for (int x = 0; x < AssociatedRegion.SizeX; ++x)
            {
                for (int z = 0; z < AssociatedRegion.SizeY; ++z)
                {

                    //float x = 0f; float z = 0.5f;
                    double h = mtx_v_res[p + 0, 0] + mtx_v_res[p + 1, 0] * (float)x / (float)AssociatedRegion.SizeX + mtx_v_res[p + 2, 0] * (float)z / (float)AssociatedRegion.SizeY;
                    //double h = mtx_v[p + 0, 0] + mtx_v[p + 1, 0] * (float)x + mtx_v[p + 2, 0] * (float)z ;
                    cPoint3D pt_ia;
                    cPoint3D pt_cur = new cPoint3D((float)x / (float)AssociatedRegion.SizeX, 0, (float)z / (float)AssociatedRegion.SizeY);
                    //Vector3 pt_cur = new Vector3((float)x , 0, (float)z);
                    for (int i = 0; i < p; ++i)
                    {
                        pt_ia = control_points[i];
                        pt_ia.Y = 0;
                        h += mtx_v_res[i, 0] * tps_base_func(pt_ia.DistTo(pt_cur));
                    }

                    grid[x, z] = h;
                }
            }
            // Calc bending energy
            Matrix w = new Matrix(p, 1);
            for (int i = 0; i < p; ++i)
                w[i, 0] = mtx_v_res[i, 0];

            Matrix be;

            be = Matrix.Multiply(Matrix.Multiply(w.Transpose(), mtx_orig_k), w);
            bending_energy = be[0, 0];

            Console.WriteLine("be= " + be[0, 0]);
            return grid;
        }
Ejemplo n.º 4
0
 public c3DThinPlate(cDRC_Region AssociatedRegion, double Regularization)
 {
     Create(AssociatedRegion, Color.White, Regularization);
 }
Ejemplo n.º 5
0
        private void Create3DDRC(cDRC DRCToDraw, cDRC_Region AssociatedRegion, Color Color, double Min, double Max)
        {
            if (DRCToDraw.ResultFit == null) return;

            Position = new cPoint3D(AssociatedRegion.PosXMin + 0.5, AssociatedRegion.PosYMin + 0.2, 0);
            this.Colour = Color;
            vtkPoints points = vtkPoints.New();

            vtkUnsignedCharArray colors = vtkUnsignedCharArray.New();
            colors.SetName("Colors");
            colors.SetNumberOfComponents(3);
            colors.SetNumberOfTuples(AssociatedRegion.NumConcentrations);

            for (int i = 0; i < AssociatedRegion.NumConcentrations; i++)
            {
                if (i >= DRCToDraw.ResultFit.Y_Estimated.Count) continue;
                double PosZ = 8 - ((DRCToDraw.ResultFit.GetNormalizedY_Estimated()[i]) * 8);

                points.InsertPoint(i, i, 0, PosZ);
                colors.InsertTuple3(i / AssociatedRegion.NumConcentrations, i / AssociatedRegion.NumConcentrations, 255, i / AssociatedRegion.NumConcentrations);
            }

            Spline = vtkParametricSpline.New();
            Spline.SetPoints(points);
            Spline.ClosedOff();

            vtkParametricFunctionSource SplineSource = vtkParametricFunctionSource.New();
            SplineSource.SetParametricFunction(Spline);

            //     SplineSource.GetPolyDataInput(0).GetPointData().AddArray(colors);

            vtkLinearExtrusionFilter extrude = vtkLinearExtrusionFilter.New();
            extrude.SetInputConnection(SplineSource.GetOutputPort());

            //extrude.GetPolyDataInput(0).GetPointData().AddArray(colors);
            extrude.SetScaleFactor(AssociatedRegion.NumReplicate - 0.2);
            //extrude.SetExtrusionTypeToNormalExtrusion();

            extrude.SetExtrusionTypeToVectorExtrusion();
            extrude.SetVector(0, 1, 0);

            vtk_PolyDataMapper = vtkPolyDataMapper.New();
            vtk_PolyDataMapper.SetInputConnection(extrude.GetOutputPort()/*SplineSource.GetOutputPort()*/);
            vtk_PolyDataMapper.GetInput().GetPointData().AddArray(colors);
            vtk_PolyDataMapper.ScalarVisibilityOn();
            vtk_PolyDataMapper.SetScalarModeToUsePointFieldData();
            vtk_PolyDataMapper.SelectColorArray("Colors");

            CreateVTK3DObject(3);
        }
Ejemplo n.º 6
0
 public c3DDRC(cDRC DRCToDraw, cDRC_Region AssociatedRegion, double Min, double Max)
 {
     Create3DDRC(DRCToDraw, AssociatedRegion, Color.White, Min, Max);
 }
Ejemplo n.º 7
0
        private void buttonApply_Click(object sender, EventArgs e)
        {
            FormForDRCDesignValidation FFDRCVal = new FormForDRCDesignValidation();

            PanelForPlatesSelection PanelForPlates = new PanelForPlatesSelection(true, null, false);
            PanelForPlates.Width = FFDRCVal.panelForPlatesName.Width;
            PanelForPlates.Height = FFDRCVal.panelForPlatesName.Height;
            FFDRCVal.panelForPlatesName.Controls.Add(PanelForPlates);

            if (!this.radioButtonConcentrationsManual.Checked) FFDRCVal.label.Text = "";

            if (FFDRCVal.ShowDialog() != System.Windows.Forms.DialogResult.OK) return;

            this.Visible = false;

            //cScreening CurrentScreen = cGlobalInfo.CurrentScreening;
            int IdxGroup = 0;

            foreach (cPlate TmpPlate in PanelForPlates.GetListSelectedPlates())
            {
                TmpPlate.ListDRCRegions = new cListDRCRegion();

                int SizeX, SizeY;
                if (TemplateRegion.IsConcentrationHorizontal)
                {
                    SizeX = TemplateRegion.NumConcentrations;
                    SizeY = TemplateRegion.NumReplicate;
                }
                else
                {
                    SizeX = TemplateRegion.NumReplicate;
                    SizeY = TemplateRegion.NumConcentrations;
                }

                int NumRepeatX = (AssociatedPlate.ParentScreening.Columns - (TemplateRegion.PosXMin - 1)) / SizeX;
                int NumRepeatY = (AssociatedPlate.ParentScreening.Rows - (TemplateRegion.PosYMin - 1)) / SizeY;

                if (!this.radioButtonOrientationColumn.Checked)
                {
                    for (int j = 0; j < NumRepeatY; j++)
                        for (int i = 0; i < NumRepeatX; i++)
                        {
                            cDRC_Region TempRegion = new cDRC_Region(TmpPlate, (int)this.numericUpDownConcentrationNumber.Value, (int)this.numericUpDownReplication.Value, i * SizeX + (TemplateRegion.PosXMin - 1), j * SizeY + (TemplateRegion.PosYMin - 1), true);
                            TmpPlate.ListDRCRegions.AddNewRegion(TempRegion);

                            // Update the concentration from the manual entry

                            for (int Replicate = 0; Replicate < TempRegion.NumReplicate; Replicate++)
                            {
                                cWell[] TmpList = TempRegion.GetlistReplicate(Replicate);
                                for (int IdxConc = 0; IdxConc < TmpList.Length; IdxConc++)
                                {

                                    if ((this.radioButtonConcentrationsManual.Checked) && (TmpList[IdxConc] != null))
                                        TmpList[IdxConc].ListProperties.UpdateValueByName("Concentration", (double)Convert.ToDouble(dataGridViewForConcentration.Rows[IdxConc].Cells[1].Value.ToString(), CultureInfo.CreateSpecificCulture("en-US")));

                                    if ((FFDRCVal.checkBoxUpdateGroupID.Checked) && (TmpList[IdxConc] != null))
                                        TmpList[IdxConc].ListProperties.UpdateValueByName("Group", (int)IdxGroup);

                                }
                            }

                            IdxGroup++;

                        }
                }
                else
                {
                    for (int j = 0; j < NumRepeatY; j++)
                        for (int i = 0; i < NumRepeatX; i++)
                        {
                            cDRC_Region TempRegion = new cDRC_Region(TmpPlate, (int)this.numericUpDownConcentrationNumber.Value, (int)this.numericUpDownReplication.Value, i * SizeX + (TemplateRegion.PosXMin - 1), j * SizeY + (TemplateRegion.PosYMin - 1), false);
                            TmpPlate.ListDRCRegions.AddNewRegion(TempRegion);

                            // Update the concentration from the manual entry
                            //   if (this.radioButtonConcentrationsManual.Checked)
                            {
                                for (int Replicate = 0; Replicate < TempRegion.NumReplicate; Replicate++)
                                {
                                    cWell[] TmpList = TempRegion.GetlistReplicate(Replicate);
                                    for (int IdxConc = 0; IdxConc < TmpList.Length; IdxConc++)
                                    {
                                        if ((this.radioButtonConcentrationsManual.Checked) && (TmpList[IdxConc] != null))
                                            TmpList[IdxConc].ListProperties.UpdateValueByName("Concentration", Convert.ToDouble(dataGridViewForConcentration.Rows[IdxConc].Cells[1].Value.ToString()));

                                        if ((FFDRCVal.checkBoxUpdateGroupID.Checked) && (TmpList[IdxConc] != null))
                                            TmpList[IdxConc].ListProperties.UpdateValueByName("Group", (int)IdxGroup);
                                    }
                                }
                            }
                            IdxGroup++;
                        }
                }
            }

            //cGlobalInfo.CurrentScreening.GetCurrentDisplayPlate().Refresh3D(cGlobalInfo.CurrentScreening.ListDescriptors.CurrentSelectedDescriptorIdx);
            cGlobalInfo.CurrentScreening.GetCurrentDisplayPlate().DisplayDistribution(cGlobalInfo.CurrentScreening.ListDescriptors.GetActiveDescriptor(), false);
        }
Ejemplo n.º 8
0
 public void Reset()
 {
     if(!panelForDesignDisplay.IsDisposed)
     panelForDesignDisplay.CreateGraphics().Clear(Color.White);
     this.TemplateRegion = null;
     this.ListWells = null;
 }
Ejemplo n.º 9
0
        private void buttonApply_Click(object sender, EventArgs e)
        {
            this.Visible = false;

            if (this.radioButtonConcentrationsManual.Checked)
            {
                System.Windows.Forms.DialogResult ResWin = MessageBox.Show("By applying this process, concentration values of the concerned wells will be modified ! Proceed ?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                if (ResWin == System.Windows.Forms.DialogResult.No) return;
            }

            cScreening CurrentScreen = this.ListWells[0].AssociatedPlate.ParentScreening;

            //this.ListWells[0].AssociatedPlate.ListDRCRegions = new cListDRCRegion();

            foreach (cPlate TmpPlate in CurrentScreen.ListPlatesActive)
            {
                TmpPlate.ListDRCRegions = new cListDRCRegion();

                int SizeX, SizeY;
                if (TemplateRegion.IsConcentrationHorizontal)
                {
                    SizeX = TemplateRegion.NumConcentrations;
                    SizeY = TemplateRegion.NumReplicate;
                }
                else
                {
                    SizeX = TemplateRegion.NumReplicate;
                    SizeY = TemplateRegion.NumConcentrations;
                }

                int NumRepeatX = (this.ListWells[0].AssociatedPlate.ParentScreening.Columns - (TemplateRegion.PosXMin - 1)) / SizeX;
                int NumRepeatY = (this.ListWells[0].AssociatedPlate.ParentScreening.Rows - (TemplateRegion.PosYMin - 1)) / SizeY;

                if (!this.radioButtonOrientationColumn.Checked)
                {
                    for (int j = 0; j < NumRepeatY; j++)
                        for (int i = 0; i < NumRepeatX; i++)
                        {
                            cDRC_Region TempRegion = new cDRC_Region(TmpPlate, (int)this.numericUpDownConcentrationNumber.Value, (int)this.numericUpDownReplication.Value, i * SizeX + (TemplateRegion.PosXMin - 1), j * SizeY + (TemplateRegion.PosYMin - 1), true);
                            TmpPlate.ListDRCRegions.AddNewRegion(TempRegion);

                            // Update the concentration from the manual entry
                            if (this.radioButtonConcentrationsManual.Checked)
                            {
                                for (int Replicate = 0; Replicate < TempRegion.NumReplicate; Replicate++)
                                {
                                    cWell[] TmpList = TempRegion.GetlistReplicate(Replicate);
                                    for (int IdxConc = 0; IdxConc < TmpList.Length; IdxConc++)
                                        if (TmpList[IdxConc] != null) TmpList[IdxConc].Concentration = Convert.ToDouble(dataGridViewForConcentration.Rows[IdxConc].Cells[1].Value.ToString());
                                }
                            }
                        }
                }
                else
                {
                    for (int j = 0; j < NumRepeatY; j++)
                        for (int i = 0; i < NumRepeatX; i++)
                        {
                            cDRC_Region TempRegion = new cDRC_Region(TmpPlate, (int)this.numericUpDownConcentrationNumber.Value, (int)this.numericUpDownReplication.Value, i * SizeX + (TemplateRegion.PosXMin - 1), j * SizeY + (TemplateRegion.PosYMin - 1), false);
                            TmpPlate.ListDRCRegions.AddNewRegion(TempRegion);

                            // Update the concentration from the manual entry
                            if (this.radioButtonConcentrationsManual.Checked)
                            {
                                for (int Replicate = 0; Replicate < TempRegion.NumReplicate; Replicate++)
                                {
                                    cWell[] TmpList = TempRegion.GetlistReplicate(Replicate);
                                    for (int IdxConc = 0; IdxConc < TmpList.Length; IdxConc++)
                                        if (TmpList[IdxConc] != null) TmpList[IdxConc].Concentration = Convert.ToDouble(dataGridViewForConcentration.Rows[IdxConc].Cells[1].Value.ToString());
                                }
                            }
                        }
                }
            }

            CurrentScreen.GetCurrentDisplayPlate().Refresh3D(CurrentScreen.ListDescriptors.CurrentSelectedDescriptor);
        }
Ejemplo n.º 10
0
        private void Create(cGeometric3DObject AssociatedObject, cDRC_Region AssociatedRegion, Color Color, double ZPosition, bool IsIsoboles)
        {
            if (AssociatedObject.AlgoOutPut == null) return;

               SetPosition(new cPoint3D(AssociatedObject.GetActor().GetPosition()[0], AssociatedObject.GetActor().GetPosition()[1], 0));// AssociatedObject.GetActor().GetPosition()[2]);
            //Position = new cPoint3D(0, 0, 0);// AssociatedObject.GetActor().GetPosition()[2]);

            vtkPlane plane = vtkPlane.New();

            // isoboles
            if (IsIsoboles)
            {
                plane.SetOrigin(AssociatedObject.GetActor().GetPosition()[0], AssociatedObject.GetActor().GetPosition()[1], ZPosition);
                plane.SetNormal(0, 0, 1);
            }
            else
            {
                plane.SetOrigin(AssociatedObject.GetPosition().X - AssociatedObject.GetActor().GetPosition()[0], AssociatedObject.GetPosition().Y - AssociatedObject.GetActor().GetPosition()[1], 0);
                plane.SetNormal(AssociatedRegion.SizeY - 1 + 2 * ZPosition, -AssociatedRegion.SizeX, 0);

                // vtkPlaneSource PlaneSource = vtkPlaneSource.New();
                //PlaneSource.SetOrigin(AssociatedObject.Position.X, AssociatedObject.Position.Y, 0);
                //PlaneSource.SetNormal(5, -10, 0);
            }

            // Create cutter
            vtkCutter cutter = vtkCutter.New();

            cutter.SetCutFunction(plane);
            cutter.SetInputConnection(AssociatedObject.AlgoOutPut);
            cutter.Update();

            vtkPoints Pts = cutter.GetOutput().GetPoints();
            int NumPts = (int)Pts.GetNumberOfPoints();
            for (int IdxPt = 0; IdxPt < NumPts; IdxPt++)
            {

                double[] Pt = Pts.GetPoint(IdxPt);
                cPoint3D NewPt = new cPoint3D(Pt[0], Pt[1], Pt[2]);
                ListPtContour.Add(NewPt);
            }

            vtkTubeFilter tubeFilter = vtkTubeFilter.New();

            tubeFilter.SetInputConnection(cutter.GetOutputPort());
            tubeFilter.SetRadius(.035); //default is .5
            tubeFilter.SetNumberOfSides(50);
            tubeFilter.Update();

            //     vtkPolyDataMapper cutterMapper = vtkPolyDataMapper.New();

            vtk_PolyDataMapper = vtkPolyDataMapper.New();
            vtk_PolyDataMapper.SetInputConnection(/*PlaneSource.GetOutputPort());*/ tubeFilter.GetOutputPort());

            // Create plane actor
            //vtkActor planeActor = vtkActor.New();

            //planeActor.SetMapper(vtk_PolyDataMapper);

            CreateVTK3DObject(0);

            SetColor(Color);
            SetOpacity(1);
            SetToSurface();
        }
Ejemplo n.º 11
0
 public c3DIsoContours(cGeometric3DObject AssociatedObject, cDRC_Region AssociatedRegion, double Zposition, bool IsIsoboles)
 {
     Create(AssociatedObject, AssociatedRegion, Color.White, Zposition, IsIsoboles);
 }