public void Create(cPoint3D MinPt, cPoint3D MaxPt, Color Colour) { Position = new cPoint3D(0, 0, 0); this.Colour = Colour; BoundingBox = vtkCubeSource.New(); BoundingBox.SetBounds(MinPt.X, MaxPt.X, MinPt.Y, MaxPt.Y, MinPt.Z, MaxPt.Z); vtk_PolyDataMapper = vtkPolyDataMapper.New(); vtk_PolyDataMapper.SetInputConnection(BoundingBox.GetOutputPort()); CreateVTK3DObject(0); }
private void CreateDelaunay(List<cPoint3D> ListPts, Color Colour, bool IsWire) { Position = new cPoint3D(0, 0, 0); this.Colour = Colour; vtkPoints ListCentroid = vtkPoints.New(); for (int i = 0; i < ListPts.Count; i++) ListCentroid.InsertPoint(i, ListPts[i].X, ListPts[i].Y, ListPts[i].Z); vtkPolyData profile = vtkPolyData.New(); profile.SetPoints(ListCentroid); vtkDelaunay2D del = vtkDelaunay2D.New(); del.SetInput(profile); del.SetTolerance(0.001); vtk_PolyDataMapper = vtkPolyDataMapper.New(); vtk_PolyDataMapper.SetInputConnection(del.GetOutputPort()); CreateVTK3DObject(0); if (IsWire) SetToWireFrame(); else SetToSurface(); }
public c3DSphere(cPoint3D Center, double Radius, Color Colour) { CreateSphere(Center, Radius, Colour, 16); }
public PanelForParamCellPopulations(cPoint3D WorldDims, FormForSimuGenerator Parent) { InitializeComponent(); this.WorldDims = WorldDims; this.Parent = Parent; }
private void CreatePlane(cPoint3D Axis1, cPoint3D Axis2, cPoint3D Origin, Color Colour) { Position = new cPoint3D(Origin.X, Origin.Y, Origin.Z); this.Colour = Colour; Plane = vtkPlaneSource.New(); Plane.SetPoint1(Axis1.X, Axis1.Y, Axis1.Z); Plane.SetPoint2(Axis2.X, Axis2.Y, Axis2.Z); Plane.SetOrigin(0, 0, 0); Plane.SetXResolution(1); Plane.SetYResolution(1); vtk_PolyDataMapper = vtkPolyDataMapper.New(); vtk_PolyDataMapper.SetInputConnection(Plane.GetOutputPort()); CreateVTK3DObject(0); }
private void spiralToolStripMenuItem_Click(object sender, EventArgs e) { // first let's define all the stimuli #region Build the stimuli cStimuli ListCellStimuli = new cStimuli(); cStimulus_Physical Gravity = new cStimulus_Physical("Gravity"); ListCellStimuli.Add(Gravity); //cStimulus_Physical WorldEdges = new cStimulus_Physical("World Edges"); //ListCellStimuli.Add(WorldEdges); cStimulus_Physical BrownianMotion = new cStimulus_Physical("Brownian Motion"); ListCellStimuli.Add(BrownianMotion); cStimulus_Chemical ToxicCompound1 = new cStimulus_Chemical("ToxicCompound1"); ListCellStimuli.Add(ToxicCompound1); #endregion #region build the cell agents #endregion cNewAgent BiologicalExperiment_DRC = new cNewAgent(new cPoint3D(0, 0, 0), new cPoint3D(5, 5, 5), "DRC"); double Concentration = 0.01; for (int i = 0; i < 2; i++) { double WellSpacing = 1; cNewAgent BiologicalExperiment_Well = new cNewAgent(new cPoint3D(WellSpacing, 0, 0), new cPoint3D(1, 1, 1), "Well " + i); // add a new Property to the well cInternalProperty Cpd1Concentration = new cInternalProperty(); Cpd1Concentration.Name = "Compound 1 Concentration"; BiologicalExperiment_Well.AddProperty(Cpd1Concentration); // add the cellular agents in the well int RegularCellsNumber = 20; for (int CellIdx = 0; CellIdx < RegularCellsNumber; CellIdx++) { cAgent_Cell Agent_RegularCell = new cAgent_Cell(new cPoint3D(0.02 * CellIdx, 0.2, 0.0200 * i), new cPoint3D(0.0100, 0.0100, 0.0100), "Regular Cell " + CellIdx); Agent_RegularCell.AssociatedStimuli = ListCellStimuli; BiologicalExperiment_Well.AddNewAgent(Agent_RegularCell); } int CancerCellsNumber = 30; for (int CellIdx = 0; CellIdx < CancerCellsNumber; CellIdx++) { cAgent_Cell Agent_CancerCell = new cAgent_Cell(new cPoint3D(0.0100 * i, 0.0100 * CellIdx, 0.1000), new cPoint3D(0.0200, 0.0200, 0.0200), "Cancer Cell " + CellIdx); Agent_CancerCell.AssociatedStimuli = ListCellStimuli; BiologicalExperiment_Well.AddNewAgent(Agent_CancerCell); } // add the well agent in the DRC BiologicalExperiment_DRC.AddNewAgent(BiologicalExperiment_Well); Concentration *= 2; } for (int Iteration = 0; Iteration < 1; Iteration++) { BiologicalExperiment_DRC.Run(); } // display objects in 3D cViewer3D V3D = new cViewer3D(); // c3DNewWorld MyWorld = new c3DNewWorld((cPoint3D)BiologicalExperiment_DRC.InternalProperties["Volume"], new cPoint3D(1, 1, 1)); c3DNewWorld MyWorld = new c3DNewWorld(new cPoint3D(1, 1, 1), new cPoint3D(1, 1, 1)); V3D.SetInputData(MyWorld); V3D.Run(); cDesignerSinglePanel CD = new cDesignerSinglePanel(); CD.SetInputData(V3D.GetOutPut()); if (CD.Run().IsSucceed == false) return; cListGeometric3DObject GlobalList = new cListGeometric3DObject("Global List"); cListGeometric3DObject CellsList = new cListGeometric3DObject("Cells"); cInternalProperty TmpProp; foreach (cNewAgent TmpWell in BiologicalExperiment_DRC) { cPoint3D ObjectPos = TmpWell.GetAbsoluteGetPosition(); c3DCube SpaceCube = new c3DCube(); TmpProp = TmpWell.InternalProperties["Volume"]; cPoint3D VOlume = new cPoint3D(0, 0, 0); SpaceCube.Create(ObjectPos, VOlume, Color.Blue); SpaceCube.SetOpacity(0.2); GlobalList.AddObject(SpaceCube); foreach (cNewAgent TmpCell in TmpWell) { ObjectPos = TmpCell.GetAbsoluteGetPosition(); c3DSphere _3DSphere = new c3DSphere(ObjectPos, 0.05, Color.Red); TmpProp = TmpCell.InternalProperties["Volume"]; VOlume = new cPoint3D(0, 0, 0);// (cPoint3D)TmpCell.InternalProperties["Volume"]; //_3DSphere.(ObjectPos, 0.5, Color.Red); _3DSphere.SetName(TmpCell.GetName()); _3DSphere.SetOpacity(1); CellsList.AddObject(_3DSphere); } } GlobalList.AddRange(CellsList); foreach (var item in GlobalList) MyWorld.AddGeometric3DObject(item); cDisplayToWindow CDW = new cDisplayToWindow(); CDW.SetInputData(CD.GetOutPut()); CDW.Title = "3D world"; if (CDW.Run().IsSucceed == false) return; CDW.Display(); return; }
//public c3DWorld(Kitware.VTK.RenderWindowControl CurrentrenderWindowControl, Sequence Seq) //{ // this.ren1 = CurrentrenderWindowControl.RenderWindow.GetRenderers().GetFirstRenderer(); // this.renWin = CurrentrenderWindowControl.RenderWindow; // if (Seq == null) // { // Xres = Yres = Zres = 0; // } // else // { // Xres = Seq.XResolution; // Yres = Seq.YResolution; // Zres = Seq.ZResolution; // } // ListPolyDataMapper = new List<vtkPolyDataMapper>(); // ListObject = new List<cObject3D>(); // ListVolume = new List<cVolume3D>(); //} /// <summary> /// Create a 3D world /// </summary> /// <param name="CurrentrenderWindowControl">vtk Control</param> /// <param name="Dimensions">in pixels</param> /// <param name="Resolution">spatial resolutions</param> public c3DWorld(cPoint3D Dimensions, cPoint3D Resolution, RenderWindowControl CurrentrenderWindowControl, int[] WinPos) { // int[] Pos = renWin.GetPosition(); //, if (CurrentrenderWindowControl == null) { renWin = vtkRenderWindow.New(); renWin.LineSmoothingOn(); renWin.PointSmoothingOn(); renWin.SetWindowName("3D World"); renWin.BordersOn(); renWin.DoubleBufferOn(); renWin.SetSize(750, 500); // if(WinPos!=null) renWin.SetPosition(WinPos[0], WinPos[1]); // this.ren1 = CurrentrenderWindowControl.RenderWindow.GetRenderers().GetFirstRenderer(); //CurrentrenderWindowControl.RenderWindow; } //// Menu Strip Construction //this.contextMenuStripActorPicker = new ContextMenuStrip(); //ToolStripMenuItem StripMenuItemDisplay = new ToolStripMenuItem("Display"); //contextMenuStripActorPicker.Items.Add(StripMenuItemDisplay); this.ren1 = vtkRenderer.New(); //renWin = CurrentrenderWindowControl.RenderWindow;//vtkRenderWindow.New(); renWin.AddRenderer(ren1); iren = new vtkRenderWindowInteractor(); iren.SetRenderWindow(renWin); //iren.SetInteractorStyle(vtkInteractorStyleJoystickCamera.New()); iren.SetInteractorStyle(vtkInteractorStyleTrackballCamera.New()); // iren.SetInteractorStyle(vtkInteractorStyleTerrain.New()); // iren.LeftButtonPressEvt += new vtkObject.vtkObjectEventHandler(RenderWindow_LeftButtonPressEvt); iren.KeyPressEvt += new vtkObject.vtkObjectEventHandler(RenderWindow_KeyPressEvt); iren.RightButtonPressEvt += new vtkObject.vtkObjectEventHandler(RenderWindow_RightButtonPressEvt); //Render(); //this.ren1 = Xres = Resolution.X; Yres = Resolution.Y; Zres = Resolution.Z; SizeX = (int)Dimensions.X; SizeY = (int)Dimensions.Y; SizeZ = (int)Dimensions.Z; // double[] fp = ren1.GetActiveCamera().GetFocalPoint(); // double[] p = ren1.GetActiveCamera().GetPosition(); // ren1.GetActiveCamera().ParallelProjectionOn(); // double dist = Math.Sqrt((p[0] - fp[0]) * (p[0] - fp[0]) + (p[1] - fp[1]) * (p[1] - fp[1]) + (p[2] - fp[2]) * (p[2] - fp[2])); // ren1.GetActiveCamera().SetPosition(fp[0], fp[1], fp[2] + dist*1000); // ren1.GetActiveCamera().Zoom(2); //ren1.Render(); // this.Render(); ListPolyDataMapper = new List<vtkPolyDataMapper>(); ListObject = new List<cObject3D>(); // Vtk_CameraViewOrientation = ren1.GetActiveCamera(); }
private void CreateSphere(cPoint3D Center, double Radius, Color Colour, int Precision) { Position = new cPoint3D(Center.X, Center.Y, Center.Z); this.Radius = Radius; this.Colour = Colour; sphere = vtkSphereSource.New(); sphere.SetThetaResolution(Precision); sphere.SetPhiResolution(Precision); sphere.SetRadius(Radius); vtk_PolyDataMapper = vtkPolyDataMapper.New(); vtk_PolyDataMapper.SetInputConnection(sphere.GetOutputPort()); CreateVTK3DObject(2); }
private void buttonOK_Click(object sender, EventArgs e) { CellPopulation = new cListAgents(this.textBoxName.Text); string CellType = comboBoxCellType.Text; cCellCycle ClassicCellCycle = new cCellCycle(); // default cell cycle cPoint3D InitialPos = null; if (radioButtonPosWorldCenter.Checked) InitialPos = new cPoint3D(this.WorldDim.X / 2, this.WorldDim.Y / 2, this.WorldDim.Z / 2); for (int i = 0; i < (int)numericUpDownInitialCellNumber.Value; i++) { if (radioButtonPosManual.Checked) { InitialPos = new cPoint3D((double)numericUpDownManualX.Value, (double)numericUpDownManualY.Value, (double)numericUpDownManualZ.Value); } else if (radioButtonPosRandom.Checked) { InitialPos = new cPoint3D(RND.NextDouble() * this.WorldDim.X, RND.NextDouble() * this.WorldDim.Y, RND.NextDouble() * this.WorldDim.Z); } cCellType CurrentCellType = Parent.ListCellTypes.FindType(CellType); if (CurrentCellType == null) continue; cAgent NewCell = new cAgent(Parent.ListCellTypes.FindType(CellType), InitialPos, RND.NextDouble() /** ClassicCellCycle.ListProba.Count*/); //new cCell( // InitialPos, // 2, // RND.NextDouble() * ClassicCellCycle.ListProba.Count); CellPopulation.Add(NewCell); } List<cClassForVariable> ListToReturn = new List<cClassForVariable>(); this.v_CellNumber.Cst_Value = (double)numericUpDownInitialCellNumber.Value; ListToReturn.Add(this.v_CellNumber); this.v_InitPosX.Cst_Value = (double)numericUpDownManualX.Value; ListToReturn.Add(this.v_InitPosX); this.v_InitPosY.Cst_Value = (double)numericUpDownManualY.Value; ListToReturn.Add(this.v_InitPosY); this.v_InitPosZ.Cst_Value = (double)numericUpDownManualZ.Value; ListToReturn.Add(this.v_InitPosZ); if (this.radioButtonVolumeFixed.Checked) this.v_InitVol.IsConstant = true; else this.v_InitVol.IsConstant = false; this.v_InitVol.Cst_Value = (double)numericUpDownInitialVolumeManual.Value; ListToReturn.Add(this.v_InitVol); ListToReturn.Add(this.v_InitPosType); ListToReturn.Add(this.v_InitVolType); this.ListVariables = new cListVariables(ListToReturn); }
public void DisplayXYZ() { if (CompleteScreening == null) return; int DescX = this.comboBoxDescriptorX.SelectedIndex; int DescY = this.comboBoxDescriptorY.SelectedIndex; int DescZ = this.comboBoxDescriptorZ.SelectedIndex; if (DescX < 0) DescX = 0; if (DescY < 0) DescY = 0; if (DescZ < 0) DescZ = 0; int[] Pos = new int[2]; Pos[0] = 0; Pos[1] = 0; if (CurrentWorld == null) { CurrentWorld = new c3DWorld(new cPoint3D(1000, 1000, 1000), new cPoint3D(ListScales[DescX], ListScales[DescY], ListScales[DescZ]), this.renderWindowControl1, Pos, CompleteScreening); } CurrentWorld.SetBackgroundColor(Color.Black); CurrentWorld.ren1.RemoveAllViewProps(); // if (widget != null) widget.SetEnabled(0); Series CurrentSeries = new Series("ScatterPoints"); double MinX = double.MaxValue; double MinY = double.MaxValue; double MinZ = double.MaxValue; double MaxZ = double.MinValue; double MaxX = double.MinValue; double MaxY = double.MinValue; double TempX, TempY, TempZ; int Idx = 0; cExtendPlateList ListPlate = new cExtendPlateList(); cMetaBiologicalObjectList ListMeta = new cMetaBiologicalObjectList("Test"); cBiologicalSpot CurrentSpot1 = new cBiologicalSpot(Color.White, new cPoint3D(0, 0, 0), 1, 4); cMetaBiologicalObject Plate3D = new cMetaBiologicalObject("Data", ListMeta, CurrentSpot1); if (!IsFullScreen) ListPlate.Add(CompleteScreening.GetCurrentDisplayPlate()); else ListPlate = CompleteScreening.ListPlatesActive; vtkUnsignedCharArray colors = vtkUnsignedCharArray.New(); colors.SetName("colors"); colors.SetNumberOfComponents(3); vtkPoints Allpoints = vtkPoints.New(); cExtendedList ListPtX = new cExtendedList(); cExtendedList ListPtY = new cExtendedList(); cExtendedList ListPtZ = new cExtendedList(); for (int i = 0; i < ListPlate.Count; i++) { cPlate CurrentPlate = ListPlate[i]; for (int IdxValue = 0; IdxValue < CompleteScreening.Columns; IdxValue++) for (int IdxValue0 = 0; IdxValue0 < CompleteScreening.Rows; IdxValue0++) { cWell TmpWell = CurrentPlate.GetWell(IdxValue, IdxValue0, true); if (TmpWell != null) { TempX = TmpWell.ListDescriptors[DescX].GetValue(); if (TempX < MinX) MinX = TempX; if (TempX > MaxX) MaxX = TempX; TempY = TmpWell.ListDescriptors[DescY].GetValue(); if (TempY < MinY) MinY = TempY; if (TempY > MaxY) MaxY = TempY; TempZ = TmpWell.ListDescriptors[DescZ].GetValue(); if (TempZ < MinZ) MinZ = TempZ; if (TempZ > MaxZ) MaxZ = TempZ; // cBiologicalSpot CurrentSpot = new cBiologicalSpot(TmpWell.GetColor(), new cPoint3D(TempX, TempY, TempZ), 1, 4); List<char> Col = new List<char>(); Col.Add((char)(TmpWell.GetColor().R)); Col.Add((char)(TmpWell.GetColor().G)); Col.Add((char)(TmpWell.GetColor().B)); // IntPtr unmanagedPointer = Marshal.UnsafeAddrOfPinnedArrayElement(Col.ToArray(), 0); //colors.InsertNextTupleValue(unmanagedPointer); colors.InsertNextTuple3(Col[0], Col[1], Col[2]); ListPtX.Add(TempX); ListPtY.Add(TempY); ListPtZ.Add(TempZ); // CurrentSpot.Name = TmpWell.AssociatedPlate.Name + " - " + TmpWell.GetPosX() + "x" + TmpWell.GetPosY() + " :" + TmpWell.Name; // CurrentSpot.ObjectType = TmpWell.AssociatedPlate.Name + " - " + TmpWell.GetPosX() + "x" + TmpWell.GetPosY() + " :" + TmpWell.Name; // Plate3D.AddObject(CurrentSpot); // CurrentWorld.AddBiological3DObject(CurrentSpot); //CurrentSeries.Points.Add(TempX, TempY); // if (IsFullScreen) // CurrentSeries.Points[Idx].ToolTip = TmpWell.AssociatedPlate.Name + "\n" + TmpWell.GetPosX() + "x" + TmpWell.GetPosY() + " :" + TmpWell.Name; // else // CurrentSeries.Points[Idx].ToolTip = TmpWell.GetPosX() + "x" + TmpWell.GetPosY() + " :" + TmpWell.Name; Idx++; } } } double MinValueX = ListPtX.Min(); double MaxValueX = ListPtX.Max(); cExtendedList NormX = ListPtX.Normalize(MinValueX, MaxValueX); double MinValueY = ListPtY.Min(); double MaxValueY = ListPtY.Max(); cExtendedList NormY = ListPtY.Normalize(MinValueY, MaxValueY); double MinValueZ = ListPtZ.Min(); double MaxValueZ = ListPtZ.Max(); cExtendedList NormZ = ListPtZ.Normalize(MinValueZ, MaxValueZ); for (int IdxPt = 0; IdxPt < ListPtX.Count; IdxPt++) Allpoints.InsertNextPoint(NormX[IdxPt], NormY[IdxPt], NormZ[IdxPt]); vtkPolyData polydata = vtkPolyData.New(); polydata.SetPoints(Allpoints); polydata.GetPointData().SetScalars(colors); vtkSphereSource SphereSource = vtkSphereSource.New(); SphereSource.SetRadius(RadiusSphere); vtkGlyph3D glyph3D = vtkGlyph3D.New(); glyph3D.SetColorModeToColorByScalar(); glyph3D.SetSourceConnection(SphereSource.GetOutputPort()); glyph3D.SetInput(polydata); glyph3D.ScalingOff(); glyph3D.Update(); vtkPolyDataMapper mapper = vtkPolyDataMapper.New(); mapper.SetInputConnection(glyph3D.GetOutputPort()); vtkActor actor = vtkActor.New(); actor.SetMapper(mapper); CurrentWorld.ren1.AddActor(actor); if ((CompleteScreening.GetCurrentDisplayPlate().ListDRCRegions != null) && (CompleteScreening.GlobalInfo.OptionsWindow.checkBoxConnectDRCPts.Checked)) { foreach (cDRC_Region TmpRegion in CompleteScreening.GetCurrentDisplayPlate().ListDRCRegions) { int cpt = 0; cWell[][] ListWells = TmpRegion.GetListWells(); foreach (cWell[] item in ListWells) { for (int IdxWell = 0; IdxWell < item.Length - 1; IdxWell++) { //cWell TmpWell0 = CompleteScreening.GetCurrentDisplayPlate().GetWell(item[IdxWell], IdxValue0, true); if ((item[IdxWell] != null) && (item[IdxWell + 1] != null) && (item[IdxWell].GetClass() >= -1)) { double StartX = (item[IdxWell].ListDescriptors[DescX].GetValue() - MinValueX) / (MaxValueX - MinValueX); double StartY = (item[IdxWell].ListDescriptors[DescY].GetValue() - MinValueY) / (MaxValueY - MinValueY); double StartZ = (item[IdxWell].ListDescriptors[DescZ].GetValue() - MinValueZ) / (MaxValueZ - MinValueZ); double EndX = (item[IdxWell + 1].ListDescriptors[DescX].GetValue() - MinValueX) / (MaxValueX - MinValueX); double EndY = (item[IdxWell + 1].ListDescriptors[DescY].GetValue() - MinValueY) / (MaxValueY - MinValueY); double EndZ = (item[IdxWell + 1].ListDescriptors[DescZ].GetValue() - MinValueZ) / (MaxValueZ - MinValueZ); cPoint3D StartPt = new cPoint3D(StartX, StartY, StartZ); cPoint3D EndPt = new cPoint3D(EndX, EndY, EndZ); c3DLine NewLine = new c3DLine(StartPt, EndPt); CurrentWorld.AddGeometric3DObject(NewLine); } } } /*List<cDRC> ListDRC = new List<cDRC>(); for (int i = 0; i < CompleteScreening.ListDescriptors.Count; i++) { if (CompleteScreening.ListDescriptors[i].IsActive()) { cDRC CurrentDRC = new cDRC(TmpRegion, CompleteScreening.ListDescriptors[i]); ListDRC.Add(CurrentDRC); cpt++; } } */ //cDRCDisplay DRCDisplay = new cDRCDisplay(ListDRC, GlobalInfo); //if (DRCDisplay.CurrentChart.Series.Count == 0) continue; //DRCDisplay.CurrentChart.Location = new Point((DRCDisplay.CurrentChart.Width + 50) * 0, (DRCDisplay.CurrentChart.Height + 10 + DRCDisplay.CurrentRichTextBox.Height) * h++); //DRCDisplay.CurrentRichTextBox.Location = new Point(DRCDisplay.CurrentChart.Location.X, DRCDisplay.CurrentChart.Location.Y + DRCDisplay.CurrentChart.Height + 5); //WindowforDRCsDisplay.LChart.Add(DRCDisplay.CurrentChart); //WindowforDRCsDisplay.LRichTextBox.Add(DRCDisplay.CurrentRichTextBox); } } // vtkAxesActor axis = vtkAxesActor.New(); vtkAxisActor axisX = vtkAxisActor.New(); axisX.SetPoint1(0, 0, 0); axisX.SetPoint2(1, 0, 0); axisX.SetTickLocationToBoth(); axisX.SetDeltaMajor(0.1); axisX.SetMajorTickSize(0); axisX.MinorTicksVisibleOff(); //axisX.Maj CurrentWorld.ren1.AddActor(axisX); vtkAxisActor axisY = vtkAxisActor.New(); axisY.SetPoint1(0, 0, 0); axisY.SetPoint2(0, 1, 0); axisY.SetTickLocationToBoth(); axisY.SetDeltaMajor(0.1); axisY.SetMajorTickSize(0.05); axisY.MinorTicksVisibleOff(); CurrentWorld.ren1.AddActor(axisY); vtkAxisActor axisZ = vtkAxisActor.New(); axisZ.SetPoint1(0, 0, 0); axisZ.SetPoint2(0, 0, 1); axisZ.SetTickLocationToBoth(); axisZ.SetDeltaMajor(0.1); axisZ.SetMajorTickSize(0.05); axisZ.MinorTicksVisibleOff(); CurrentWorld.ren1.AddActor(axisZ); if (widget == null) { widget = vtkOrientationMarkerWidget.New(); axes = vtkAxesActor.New(); widget.SetOutlineColor(0.9300, 0.5700, 0.1300); widget.SetInteractor(CurrentWorld.iren); widget.SetViewport(0.0, 0.0, 0.4, 0.4); widget.SetEnabled(0); // widget.InteractiveOn(); if (this.comboBoxDescriptorX.SelectedItem == null) axes.SetXAxisLabelText(this.comboBoxDescriptorX.Items[0].ToString()); else axes.SetXAxisLabelText(this.comboBoxDescriptorX.SelectedItem.ToString()); if (this.comboBoxDescriptorY.SelectedItem == null) axes.SetYAxisLabelText(this.comboBoxDescriptorY.Items[0].ToString()); else axes.SetYAxisLabelText(this.comboBoxDescriptorY.SelectedItem.ToString()); if (this.comboBoxDescriptorZ.SelectedItem == null) axes.SetZAxisLabelText(this.comboBoxDescriptorZ.Items[0].ToString()); else axes.SetZAxisLabelText(this.comboBoxDescriptorZ.SelectedItem.ToString()); widget.SetOrientationMarker(axes); } else { if(this.comboBoxDescriptorX.SelectedItem!=null) axes.SetXAxisLabelText(this.comboBoxDescriptorX.SelectedItem.ToString()); if (this.comboBoxDescriptorY.SelectedItem != null) axes.SetYAxisLabelText(this.comboBoxDescriptorY.SelectedItem.ToString()); if (this.comboBoxDescriptorZ.SelectedItem != null) axes.SetZAxisLabelText(this.comboBoxDescriptorZ.SelectedItem.ToString()); widget.SetOrientationMarker(axes); } // //vtkCameraWidget Wid = vtkCameraWidget.New(); //Wid.SetInteractor(CurrentWorld.iren); //Wid.SetEnabled(1); // Wid.InteractiveOn(); //vtkDistanceWidget distanceWidget = vtkDistanceWidget.New(); //distanceWidget.SetInteractor(CurrentWorld.iren); //distanceWidget.SetEnabled(1); //distanceWidget.CreateDefaultRepresentation(); //((vtkDistanceRepresentation)distanceWidget.GetRepresentation()).SetLabelFormat("%-#6.3g mm"); /*static_cast<vtkDistanceRepresentation*>(distanceWidget->GetRepresentation()) ->SetLabelFormat("%-#6.3g mm"); */ // Plate3D.GenerateAndDisplayBoundingBox(1, Color.White, false, CurrentWorld); //c3DText CaptionX = new c3DText(CurrentWorld, CompleteScreening.ListDescriptors[DescX].GetName(), new cPoint3D(MaxX, MinY, MinZ), Color.DarkRed, this.FontSize); //c3DLine LineX = new c3DLine(new cPoint3D(MinX, MinY, MinZ), new cPoint3D(MaxX, MinY, MinZ), Color.DarkRed); //CurrentWorld.AddGeometric3DObject(LineX); //c3DText CaptionY = new c3DText(CurrentWorld, CompleteScreening.ListDescriptors[DescY].GetName(), new cPoint3D(MinX, MaxY, MinZ), Color.DarkGreen, this.FontSize); //c3DLine LineY = new c3DLine(new cPoint3D(MinX, MinY, MinZ), new cPoint3D(MinX, MaxY, MinZ), Color.DarkGreen); //CurrentWorld.AddGeometric3DObject(LineY); //c3DText CaptionZ = new c3DText(CurrentWorld, CompleteScreening.ListDescriptors[DescZ].GetName(), new cPoint3D(MinX, MinY, MaxZ), Color.DarkBlue, this.FontSize); //c3DLine LineZ = new c3DLine(new cPoint3D(MinX, MinY, MinZ), new cPoint3D(MinX, MinY, MaxZ), Color.DarkBlue); //CurrentWorld.AddGeometric3DObject(LineZ); CurrentWorld.SimpleRender();// Render(); }
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); }
public cFeedBackMessage Run(c3DNewWorld _3DWorld) { if (base.Start() == false) { base.FeedBackMessage.IsSucceed = false; return base.FeedBackMessage; } //if (this.Input == null) //{ // FeedBackMessage.IsSucceed = false; // FeedBackMessage.Message = "No input data table defined."; // return FeedBackMessage; //} #region Properties Management object _firstValue = base.ListProperties.FindByName("Normalized ?"); bool IsNormalized = false; if (_firstValue == null) { base.GenerateError("-Normalized ?- not found !"); return base.FeedBackMessage; } try { cProperty TmpProp = (cProperty)_firstValue; IsNormalized = (bool)TmpProp.GetValue(); } catch (Exception) { base.GenerateError("-Normalized ?- cast didn't work"); return base.FeedBackMessage; } _firstValue = base.ListProperties.FindByName("Draw Axis ?"); bool IsdrawAxis = true; if (_firstValue == null) { base.GenerateError("-Draw Axis ?- not found !"); return base.FeedBackMessage; } try { cProperty TmpProp = (cProperty)_firstValue; IsdrawAxis = (bool)TmpProp.GetValue(); } catch (Exception) { base.GenerateError("-Draw Axis ?- cast didn't work"); return base.FeedBackMessage; } _firstValue = base.ListProperties.FindByName("Link Points ?"); bool IsLinked = false; if (_firstValue == null) { base.GenerateError("-Link Points ?- not found !"); return base.FeedBackMessage; } try { cProperty TmpProp = (cProperty)_firstValue; IsLinked = (bool)TmpProp.GetValue(); } catch (Exception) { base.GenerateError("-Link Points ?- cast didn't work"); return base.FeedBackMessage; } #endregion cExtendedList ListLenghtsMax = new cExtendedList(); ListObjects = new cListGeometric3DObject("Scatter Plot MetaObject"); double MinX = this.Input.Min(0); double MaxX = this.Input.Max(0); double DeltaX = MaxX - MinX; ListLenghtsMax.Add(DeltaX); if (DeltaX == 0) DeltaX = 1; double MinY = this.Input.Min(1); double MaxY = this.Input.Max(1); double DeltaY = MaxY - MinY; ListLenghtsMax.Add(DeltaY); if (DeltaY == 0) DeltaY = 1; double MinZ = this.Input.Min(2); double MaxZ = this.Input.Max(2); double DeltaZ = MaxZ - MinZ; ListLenghtsMax.Add(DeltaZ); if (DeltaZ == 0) DeltaZ = 1; double MinRad = 0; double MaxRad = 0; double DeltaRad = 1; double MaxLenght = ListLenghtsMax.Min(); if (MaxLenght <= 0) MaxLenght = 1; for (int CurrentSerie = 0; CurrentSerie < this.Input.Count; CurrentSerie++) { cExtendedTable CurrentTable = this.Input[CurrentSerie]; if ((IndexColumnForSphereRadius > 0) && (IndexColumnForSphereRadius < CurrentTable.Count)) { MinRad = CurrentTable[IndexColumnForSphereRadius].Min(); MaxRad = CurrentTable[IndexColumnForSphereRadius].Max(); if (MaxRad != MinRad) DeltaRad = MaxRad - MinRad; } if (CurrentTable.Count == 0) continue; cListGeometric3DObject TmpListObjects = new cListGeometric3DObject("Scatter MetaObject"); TmpListObjects.Tag = CurrentTable.Tag; cPoint3D Pt = null; for (int IdxPt = 0; IdxPt < CurrentTable[0].Count; IdxPt++) { if(IsNormalized) Pt = new cPoint3D((CurrentTable[0][IdxPt] - MinX) / DeltaX, (CurrentTable[1][IdxPt] - MinY) / DeltaY, (CurrentTable[2][IdxPt] - MinZ) / DeltaZ); else Pt = new cPoint3D(CurrentTable[0][IdxPt], CurrentTable[1][IdxPt], CurrentTable[2][IdxPt]); double Rad = this.Radius; if ((IndexColumnForSphereRadius > 0) && (IndexColumnForSphereRadius < CurrentTable.Count)) { Rad = this.Radius * ((CurrentTable[IndexColumnForSphereRadius][IdxPt] - MinRad)) / DeltaRad; Rad /= 200; } if(IndexColumnForSphereRadius>-1) Rad = CurrentTable[IndexColumnForSphereRadius][IdxPt]; if (IsNormalized) Rad /= 300.0; else { Rad = MaxLenght / 100.0; } c3DSphere Sphere = new c3DSphere(Pt, Rad); //c3DPoint Sphere = new c3DPoint(Pt); if ((CurrentTable.ListRowNames != null) && (CurrentTable.ListRowNames.Count > IdxPt)) { if (CurrentTable.ListRowNames[IdxPt] != null) Sphere.SetName(CurrentTable.ListRowNames[IdxPt]); else Sphere.SetName("Sphere " + IdxPt); } else { Sphere.SetName("Sphere " + IdxPt); } if ((CurrentTable.ListTags != null) && (CurrentTable.ListTags[IdxPt] != null) && (CurrentTable.ListTags[IdxPt].GetType() == typeof(cWell))) { if (CurrentTable.ListTags[IdxPt].GetType() == typeof(cWell)) { Sphere.Colour = ((cWell)(CurrentTable.ListTags[IdxPt])).GetClassType().ColourForDisplay; Sphere.Tag = CurrentTable.ListTags[IdxPt]; } } else //if (this.GlobalInfo != null) { Sphere.Colour = cGlobalInfo.ListCellularPhenotypes[CurrentSerie % cGlobalInfo.ListCellularPhenotypes.Count].ColourForDisplay; } TmpListObjects.AddObject(Sphere); if ((ValueToBeDisplayed > 0) && (ValueToBeDisplayed < CurrentTable.Count)) { if (_3DWorld != null) TmpListObjects.Add(new c3DText(_3DWorld, CurrentTable[ValueToBeDisplayed][IdxPt].ToString("N3"), new cPoint3D(Pt.X + 0.02, Pt.Y + 0.02, Pt.Z + 0.02), Color.White, 0.01)); } } ListObjects.AddRange(TmpListObjects); #region Draw Links if (IsLinked) { cListGeometric3DObject ListLinks = new cListGeometric3DObject( "Links MetaObject"); for (int IdxPt = 1; IdxPt < CurrentTable[0].Count; IdxPt++) { cPoint3D Pt1 = null; cPoint3D Pt0 = null; if (IsNormalized) { Pt1 = new cPoint3D((CurrentTable[0][IdxPt] - MinX) / DeltaX, (CurrentTable[1][IdxPt] - MinY) / DeltaY, (CurrentTable[2][IdxPt] - MinZ) / DeltaZ); Pt0 = new cPoint3D((CurrentTable[0][IdxPt - 1] - MinX) / DeltaX, (CurrentTable[1][IdxPt - 1] - MinY) / DeltaY, (CurrentTable[2][IdxPt - 1] - MinZ) / DeltaZ); } else { Pt1 = new cPoint3D(CurrentTable[0][IdxPt], CurrentTable[1][IdxPt] , CurrentTable[2][IdxPt] ); Pt0 = new cPoint3D(CurrentTable[0][IdxPt - 1] , CurrentTable[1][IdxPt - 1] , CurrentTable[2][IdxPt - 1] ); } // new cPoint3D((CurrentTable[0][IdxPt] - MinX) / DeltaX, (CurrentTable[1][IdxPt] - MinY) / DeltaY, (CurrentTable[2][IdxPt] - MinZ) / DeltaZ); //cPoint3D Pt0 = new cPoint3D((CurrentTable[0][IdxPt - 1] - MinX) / DeltaX, (CurrentTable[1][IdxPt - 1] - MinY) / DeltaY, (CurrentTable[2][IdxPt - 1] - MinZ) / DeltaZ); c3DLine Line = new c3DLine(Pt0, Pt1); Line.SetName("Link ["+(IdxPt-1)+";"+IdxPt+"]"); ListLinks.AddObject(Line); } ListObjects.AddRange(ListLinks); } #endregion } #region Draw Axis if (IsdrawAxis && (this.Input[0].Count > 2)) { c3DObject_Axis Axis = new c3DObject_Axis(); cExtendedTable T = new cExtendedTable(); T.Add(new cExtendedList(Input[0][0].Name)); if (IsNormalized) { T[0].Tag = Input[0][0].Tag; T[0].Add(0); T[0].Add(1); T.Add(new cExtendedList(Input[0][1].Name)); T[1].Tag = Input[0][1].Tag; T[1].Add(0); T[1].Add(1); T.Add(new cExtendedList(Input[0][2].Name)); T[2].Tag = Input[0][2].Tag; T[2].Add(0); T[2].Add(1); } else { T[0].Tag = Input[0][0].Tag; T[0].Add(MinX); T[0].Add(MaxX); T.Add(new cExtendedList(Input[0][1].Name)); T[1].Tag = Input[0][1].Tag; T[1].Add(MinY); T[1].Add(MaxY); T.Add(new cExtendedList(Input[0][2].Name)); T[2].Tag = Input[0][2].Tag; T[2].Add(MinZ); T[2].Add(MaxZ); } Axis.SetInputData(T); Axis.Run(_3DWorld); ListObjects.AddRange(Axis.GetOutPut()); } #endregion // _3DWorld.AddGeometric3DObjects(this.ListObjects); return base.FeedBackMessage; }
public double DistTo(cPoint3D DestPoint) { return Math.Sqrt((DestPoint.X - this.X) * (DestPoint.X - this.X) + (DestPoint.Y - this.Y) * (DestPoint.Y - this.Y) + (DestPoint.Z - this.Z) * (DestPoint.Z - this.Z)); }
public cPoint3D GetPosition() { cDescriptorType DescTypeForPosX = cGlobalInfo.CurrentScreening.ListDescriptors.GetDescriptorByName(cGlobalInfo.OptionsWindow.comboBoxDescriptorForPosX.Text); cDescriptorType DescTypeForPosY = cGlobalInfo.CurrentScreening.ListDescriptors.GetDescriptorByName(cGlobalInfo.OptionsWindow.comboBoxDescriptorForPosY.Text); if ((DescTypeForPosX == null) || (DescTypeForPosY == null)) { this.Position = new cPoint3D(-1, -1, -1); return this.Position; } return this.Position; }
public cFeedBackMessage Run(c3DNewWorld _3DWorld) { if (this.Input == null) { FeedBackMessage.IsSucceed = false; FeedBackMessage.Message = "No input data table defined."; return FeedBackMessage; } ListObjects = new cListGeometric3DObject("Axis MetaObject"); cExtendedList ListLenghts = new cExtendedList(); double MinLenght; cPoint3D Pt1 = null; cPoint3D Pt2 = null; cPoint3D Pt3 = null; if (this.Input.Count == 1) { cPoint3D Pt0 = new cPoint3D(this.Input[0][0], 0, 0); Pt1 = new cPoint3D(this.Input[0][1], 0, 0); ListLenghts.Add(Pt0.DistTo(Pt1)); MinLenght = ListLenghts.Min(); if (MinLenght == 0) MinLenght = 1; c3DLine XAxis = new c3DLine(Pt0, Pt1); XAxis.Tag = this.Input[0].Tag; XAxis.SetName("Axis - " + this.Input[0].Name); ListObjects.AddObject(XAxis); } else if (this.Input.Count == 2) { cPoint3D Pt0 = new cPoint3D(this.Input[0][0], this.Input[1][0], 0); Pt1 = new cPoint3D(this.Input[0][1], this.Input[1][0], 0); ListLenghts.Add(Pt0.DistTo(Pt1)); Pt2 = new cPoint3D(this.Input[0][0], this.Input[1][1], 0); ListLenghts.Add(Pt0.DistTo(Pt2)); MinLenght = ListLenghts.Min(); if (MinLenght == 0) MinLenght = 1; c3DLine XAxis = new c3DLine(Pt0, Pt1); XAxis.Tag = this.Input[0].Tag; XAxis.SetName("Axis - " + this.Input[0].Name); ListObjects.AddObject(XAxis); c3DLine YAxis = new c3DLine(Pt0, Pt2); YAxis.Tag = this.Input[1].Tag; YAxis.SetName("Axis - " + this.Input[1].Name); ListObjects.AddObject(YAxis); } else { cPoint3D Pt0 = new cPoint3D(this.Input[0][0], this.Input[1][0], this.Input[2][0]); Pt1 = new cPoint3D(this.Input[0][1], this.Input[1][0], this.Input[2][0]); ListLenghts.Add(Pt0.DistTo(Pt1)); Pt2 = new cPoint3D(this.Input[0][0], this.Input[1][1], this.Input[2][0]); ListLenghts.Add(Pt0.DistTo(Pt2)); Pt3 = new cPoint3D(this.Input[0][0], this.Input[1][0], this.Input[2][1]); ListLenghts.Add(Pt0.DistTo(Pt3)); MinLenght = ListLenghts.Min(); if (MinLenght == 0) MinLenght = 1; c3DLine XAxis = new c3DLine(Pt0, Pt1,Color.Black); XAxis.Tag = this.Input[0].Tag; XAxis.SetName("Axis - " + this.Input[0].Name); ListObjects.AddObject(XAxis); c3DLine YAxis = new c3DLine(Pt0, Pt2,Color.Black); YAxis.Tag = this.Input[1].Tag; YAxis.SetName("Axis - " + this.Input[1].Name); ListObjects.AddObject(YAxis); c3DLine ZAxis = new c3DLine(Pt0, Pt3,Color.Black); ZAxis.Tag = this.Input[2].Tag; ZAxis.SetName("Axis - " + this.Input[2].Name); ListObjects.AddObject(ZAxis); } #region draw text double TextScale = MinLenght; if (MinLenght == 1) TextScale = 1; cPoint3D PosText = Pt1; // display the axis name c3DText TmpText = new c3DText(_3DWorld, this.Input[0].Name, PosText, Color.Black, 0.02 * TextScale); TmpText.Tag = this.Input[0].Tag; ListObjects.AddObject(TmpText); // MinX PosText = new cPoint3D(0, 0, 0); PosText.X = this.Input[0][0]; if (this.Input.Count > 1) PosText.Y = this.Input[1][0]; if (this.Input.Count > 2) PosText.Z = this.Input[2][0] - TextScale * 0.03; ListObjects.AddObject(new c3DText(_3DWorld, this.Input[0][0].ToString("N3"), PosText, Color.DimGray, 0.01 * TextScale)); // MaxX PosText.X = this.Input[0][1]; if (this.Input.Count > 1) PosText.Y = this.Input[1][0]; if (this.Input.Count > 2) PosText.Z = this.Input[2][0] - TextScale * 0.03; if (this.Input.Count > 1) ListObjects.AddObject(new c3DText(_3DWorld, this.Input[0][1].ToString("N3"), PosText, Color.DimGray, 0.01 * TextScale)); if (Pt2 != null) { PosText = Pt2; TmpText = new c3DText(_3DWorld, this.Input[1].Name, PosText, Color.Black, 0.02 * TextScale); TmpText.Tag = this.Input[1].Tag; ListObjects.AddObject(TmpText); // MinY PosText.X = this.Input[0][0] - TextScale * 0.03;// + TextScale*0.02; if (this.Input.Count > 1) PosText.Y = this.Input[1][0];// -TextScale * 0.03; if (this.Input.Count > 2) PosText.Z = this.Input[2][0] - TextScale * 0.03; ListObjects.AddObject(new c3DText(_3DWorld, this.Input[1][0].ToString("N3"), PosText, Color.DimGray, 0.01 * TextScale)); PosText.X = this.Input[0][0] - TextScale * 0.03;// + TextScale*0.02; if (this.Input.Count > 1) PosText.Y = this.Input[1][1];// -TextScale * 0.03; if (this.Input.Count > 2) PosText.Z = this.Input[2][0] - TextScale * 0.03; ListObjects.AddObject(new c3DText(_3DWorld, this.Input[1][1].ToString("N3"), PosText, Color.DimGray, 0.01 * TextScale)); } if (Pt3 != null) { PosText = Pt3; TmpText = new c3DText(_3DWorld, this.Input[2].Name, /*new cPoint3D(-0.04, -0.04, 0.45)*/ PosText, Color.Black, 0.02 * TextScale); TmpText.Tag = this.Input[2].Tag; ListObjects.AddObject(TmpText); PosText.X = this.Input[0][0] - TextScale * 0.03;// + TextScale*0.02; PosText.Y = this.Input[1][0];// -TextScale * 0.03; PosText.Z = this.Input[2][0]; ListObjects.AddObject(new c3DText(_3DWorld, this.Input[2][0].ToString("N3"), PosText, Color.DimGray, 0.01 * TextScale)); PosText.X = this.Input[0][0] - TextScale * 0.03;// + TextScale*0.02; PosText.Y = this.Input[1][0];// -TextScale * 0.03; PosText.Z = this.Input[2][1]; ListObjects.AddObject(new c3DText(_3DWorld, this.Input[2][1].ToString("N3"), PosText, Color.DimGray, 0.01 * TextScale)); } #endregion return base.FeedBackMessage; }
public FormForInfoSingleCellPopInit_Simulator(cPoint3D WorldDim, cListVariables ListVariablesInput, FormForSimuGenerator Parent, cListAgents CellPopulation) { InitializeComponent(); if (CellPopulation == null) { this.comboBoxCellType.Text = "Regular"; this.ListVariables = ListVariablesInput; this.textBoxName.Text = "Population_" + Parent.MyPanelForParamCellPopulations.listViewForCellPopulations.Items.Count; } else { this.comboBoxCellType.Text = CellPopulation[0].Type.Name; this.textBoxName.Text = CellPopulation.Name; ListVariables = CellPopulation.AssociatedVariables; } this.WorldDim = WorldDim; this.Parent = Parent; this.v_CellNumber = ListVariables.FindVariable("v_CellNumber"); this.v_InitPosX = ListVariables.FindVariable("v_InitPosX"); this.v_InitPosY = ListVariables.FindVariable("v_InitPosY"); this.v_InitPosZ = ListVariables.FindVariable("v_InitPosZ"); this.v_InitPosType = ListVariables.FindVariable("v_InitPosType"); this.v_InitVolType = ListVariables.FindVariable("v_InitVolType"); this.v_InitVol = ListVariables.FindVariable("v_InitVol"); if (v_InitVolType.Cst_Value == 0) { this.radioButtonVolumeRandom.Checked = false; this.radioButtonVolumeFixed.Checked = true; } else if (v_InitVolType.Cst_Value == 10) { this.radioButtonVolumeRandom.Checked = true; this.radioButtonVolumeFixed.Checked = false; } if (v_InitPosType.Cst_Value == 0) { this.radioButtonPosWorldCenter.Checked = true; this.radioButtonPosRandom.Checked = false; this.radioButtonPosManual.Checked = false; } else if (v_InitPosType.Cst_Value == 1) { this.radioButtonPosWorldCenter.Checked = false; this.radioButtonPosRandom.Checked = true; this.radioButtonPosManual.Checked = false; } else { this.radioButtonPosWorldCenter.Checked = false; this.radioButtonPosRandom.Checked = false; this.radioButtonPosManual.Checked = true; } this.numericUpDownInitialCellNumber.Value = (decimal)v_CellNumber.Cst_Value; this.numericUpDownManualX.Value = (decimal)v_InitPosX.Cst_Value; this.numericUpDownManualY.Value = (decimal)v_InitPosY.Cst_Value; this.numericUpDownManualZ.Value = (decimal)v_InitPosZ.Cst_Value; this.numericUpDownInitialVolumeManual.Value = (decimal)v_InitVol.Cst_Value; if (v_InitVol.IsConstant) { this.radioButtonVolumeFixed.Checked = true; this.radioButtonVolumeRandom.Checked = false; } else { this.radioButtonVolumeFixed.Checked = false; this.radioButtonVolumeRandom.Checked = true; } this.comboBoxCellType.Items.Clear(); foreach (cCellType item in Parent.ListCellTypes) this.comboBoxCellType.Items.Add(item.Name); }
public c3DSphere(cPoint3D Center, double Radius, Color Colour, int Precision) { CreateSphere(Center, Radius, Colour, Precision); }
// private cPoint3D Point2; //private void CreateLine(cPoint3D Point1, cPoint3D Point2, Color Colour) //{ // Position = new cPoint3D(Point1.X, Point1.Y, Point1.Z); // Position = new cPoint3D(0, 0, 0); // this.Colour = Colour; // Line = vtkLineSource.New(); // this.Point1 = new cPoint3D(Point1.X, Point1.Y, Point1.Z); // this.Point2 = new cPoint3D(Point2.X, Point2.Y, Point2.Z); // Line.SetPoint1(Point1.X, Point1.Y, Point1.Z); // Line.SetPoint2(Point2.X, Point2.Y, Point2.Z); // vtk_PolyDataMapper = vtkPolyDataMapper.New(); // vtk_PolyDataMapper.SetInputConnection(Line.GetOutputPort()); // CreateVTK3DObject(0); //} public c3DText(c3DWorld CurrentWorld, string TextToDisplay, cPoint3D Position, Color Colour, double Scale) { // CreateLine(Point1, Point2, Colour); vtkFollower TextActor = vtkFollower.New(); vtkPolyDataMapper TextMapper = vtkPolyDataMapper.New(); vtkVectorText TextVTK = vtkVectorText.New(); // double Dist = Point1.DistTo(Point2); TextVTK.SetText(TextToDisplay); TextMapper.SetInputConnection(TextVTK.GetOutputPort()); TextActor.SetMapper(TextMapper); TextActor.SetPosition(Position.X, Position.Y, Position.Z); TextActor.SetPickable(0); TextActor.SetScale(Scale); CurrentWorld.ren1.AddActor(TextActor); TextActor.SetCamera(CurrentWorld.ren1.GetActiveCamera()); }
public c3DSphere(cPoint3D Center, double Radius) { CreateSphere(Center, Radius, Color.Red, 16); }
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(); }
public c3DLine(cPoint3D Point1, cPoint3D Point2, Color Colour) { CreateLine(Point1, Point2, Colour); }
public cWorld(cPoint3D Dimensions, FormForSimuGenerator Parent) { this.Dimensions = new cPoint3D(Dimensions.X, Dimensions.Y, Dimensions.Z); this.Parent = Parent; }
/// <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; }
public c3DLine(cPoint3D Point1, cPoint3D Point2) { CreateLine(Point1, Point2, Color.White); }
private void CreateLine(cPoint3D Point1, cPoint3D Point2, Color Colour) { Position = new cPoint3D(Point1.X, Point1.Y, Point1.Z); Position = new cPoint3D(0, 0, 0); this.Colour = Colour; Line = vtkLineSource.New(); this.Point1 = new cPoint3D(Point1.X, Point1.Y, Point1.Z); this.Point2 = new cPoint3D(Point2.X, Point2.Y, Point2.Z); Line.SetPoint1(Point1.X, Point1.Y, Point1.Z); Line.SetPoint2(Point2.X, Point2.Y, Point2.Z); vtk_PolyDataMapper = vtkPolyDataMapper.New(); vtk_PolyDataMapper.SetInputConnection(Line.GetOutputPort()); CreateVTK3DObject(0); }
public c3DPlane(cPoint3D Point1, cPoint3D Point2, cPoint3D Origin, Color Colour) { CreatePlane(Point1, Point2, Origin, Colour); }
public int KeepOnlyObjectsInsideTheOthers(List<cInteractive3DObject> ListContent, List<cInteractive3DObject> ListContainer) { int RemovedObjects = 0; for (int IdxContent = 0; IdxContent < ListContent.Count; ) { cInteractive3DObject CurrentContent = ListContent[IdxContent]; cPoint3D TestCentriolPt = new cPoint3D(CurrentContent.GetCentroid().X, CurrentContent.GetCentroid().Y, CurrentContent.GetCentroid().Z); for (int IdxContainer = 0; IdxContainer < ListContainer.Count; IdxContainer++) { cBiological3DVolume CurrentVol = (cBiological3DVolume)ListContainer[IdxContainer]; // cPoint3D TestPt1 = new cPoint3D(CurrentVol.GetCentroid().X, CurrentVol.GetCentroid().Y, CurrentVol.GetCentroid().Z); if (CurrentVol.IsPointInside(TestCentriolPt)) { ListContent.Remove(CurrentContent); RemovedObjects++; } } } return RemovedObjects; }
public c3DPlane(cPoint3D Point1, cPoint3D Point2, cPoint3D Origin) { CreatePlane(Point1, Point2, Origin, Color.White); }
private void AnalyseSequence(cImage SeqToAnalyse) { // //FormForThumbnails WindThumbnail = new FormForThumbnails(); // //for (int k = 0; k < ListFormForControl.Count; k++) // //{ // // FormForControl Obj = ListFormForControl.ElementAt(ListFormForControl.Count - k-1); // // Obj.DisplayThumbnail(WindThumbnail); // //} // //WindThumbnail.Show(); // //return; #region initialization if (SeqToAnalyse == null) return; // create World if (Current3DWorld == null) { Current3DWorld = new c3DNewWorld(new cPoint3D(SeqToAnalyse.Width, SeqToAnalyse.Height, SeqToAnalyse.Depth), new cPoint3D(SeqToAnalyse.Resolution)); } else { // // Current3DWorld.ren1. // Current3DWorld.Terminate(); Current3DWorld = null; Current3DWorld = new c3DNewWorld(new cPoint3D(SeqToAnalyse.Width, SeqToAnalyse.Height, SeqToAnalyse.Depth), new cPoint3D(SeqToAnalyse.Resolution)); } for (int k = 0; k < ListFormForControl.Count; k++) { FormForControl Obj = ListFormForControl.ElementAt(ListFormForControl.Count - k-1); if (Obj.numericUpDownChannel.Value >= SeqToAnalyse.GetNumChannels()) { MessageBox.Show("Wrong number of channels", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } // // Current3DWorld.ListObjControl = ListFormForControl; // // dataGridViewForClassif.DataSource = CurrentTable; // if (DataGrid == null) // { // DataGrid = new FormForDataGridView(); // DataGrid.Show(); // } // Current3DWorld.SetLinkToDataGridView(DataGrid.dataGridViewForResults); Current3DWorld.ListMetaObjectList = new List<cMetaBiologicalObjectList>(); cMetaBiologicalObjectList ListMetacells = new cMetaBiologicalObjectList("List Meta Objects"); Current3DWorld.ListMetaObjectList.Add(ListMetacells); #endregion #region Detection for (int k = 0; k < ListFormForControl.Count; k++) { FormForControl Obj = ListFormForControl.ElementAt(ListFormForControl.Count - k -1); if (Obj.radioButtonIsVolume.Checked) // we have to detect a volume ! { cVolumeDetection Detection = new cVolumeDetection(SeqToAnalyse, (int)Obj.numericUpDownChannel.Value, Obj.WindowForVolumeDetection.checkBoxIsBorderKill.Checked); Detection.SetShift(new cPoint3D((float)Obj.WindowForPreProcessing.numericUpDownShiftX.Value, (float)Obj.WindowForPreProcessing.numericUpDownShiftY.Value, (float)Obj.WindowForPreProcessing.numericUpDownShiftZ.Value)); if ((Obj.checkBoxPreProcessings.Checked == false) || (Obj.WindowForPreProcessing.checkBoxMedianIsDisabled.Checked)) { Detection.SetMedian(-1); Detection.SetShift(new cPoint3D(0, 0, 0)); } else { Detection.SetMedian((int)Obj.WindowForPreProcessing.numericUpDownMedianKernel.Value); Detection.SetShift(new cPoint3D((float)Obj.WindowForPreProcessing.numericUpDownShiftX.Value, (float)Obj.WindowForPreProcessing.numericUpDownShiftY.Value, (float)Obj.WindowForPreProcessing.numericUpDownShiftZ.Value)); } if (Obj.WindowForVolumeDetection.checkBoxVolumeSmooth.Checked) Detection.MeshSmoother = new cMeshSmoother((int)Obj.WindowForVolumeDetection.numericUpDownSmoothIterations.Value); if ((Obj.comboBoxContainer.SelectedItem !=null) && (Obj.comboBoxContainer.SelectedItem.ToString() != "")) { Detection.SetContainers(Current3DWorld.GetListBiologicalObjectsOfType(Obj.comboBoxContainer.Items[0].ToString())); if (Obj.InOrOut.radioButtonIn.Checked) Detection.SetContainersMode(0); else Detection.SetContainersMode(1); } else Detection.SetContainers(null); if (Obj.WindowForVolumeDetection.checkBoxIsRegionGrowing.Checked == false) // no region growing direct detection { Obj.AssociatedBiologicalObjectList = Detection.IntensityThreshold((float)Obj.WindowForVolumeDetection.numericUpDownIntensityThreshold.Value, (float)Obj.WindowForVolumeDetection.numericUpDownVolumeMinVol.Value, (float)Obj.WindowForVolumeDetection.numericUpDownVolumeMaxVol.Value); } else // region growing { if (Obj.WindowForVolumeDetection.radioButtonRegionsBased.Checked) // start from a segmentation { if (Obj.WindowForVolumeDetection.radioButtonVolumeDetectionNew.Checked) // a new segmentation has to be performed { // // Image3D CurrentPatch = new Image3D(2 * Radius, 2 * Radius, 1, CurrentImageToProcess.NumBands); cImage CurrentBinary = new cImage(SeqToAnalyse.Width, SeqToAnalyse.Height, SeqToAnalyse.Depth, 1); for (int i = 0; i < CurrentBinary.ImageSize; i++) { if (SeqToAnalyse.SingleChannelImage[(int)Obj.numericUpDownChannel.Value].Data[i] >= (float)Obj.WindowForVolumeDetection.numericUpDownIntensityThreshold.Value) CurrentBinary.SingleChannelImage[0].Data[i] = 1; } eConnectivity CurrentConnectivity = eConnectivity.TWOD_4; if (CurrentBinary.Depth > 1) CurrentConnectivity = eConnectivity.THREED_6; ConnectedComponentSet OFNucleus = new ConnectedComponentSet(CurrentBinary, null, null, 0, CurrentConnectivity, (int)Obj.WindowForVolumeDetection.numericUpDownRegionBasedMinArea.Value, (int)Obj.WindowForVolumeDetection.numericUpDownRegionBasedMaxArea.Value); // // RegionGrowing = new cRegionGrowing(OFNucleus, NewSeq[0], (int)numericUpDownChannelForRegionGrowing.Value, (float)numericUpDownIntensityForRegionGrowing.Value, (int)numericUpDownMaxNucleusArea.Value); int NumIterations = -1; if (Obj.WindowForVolumeDetection.checkBoxIsConvergence.Checked == false) NumIterations = (int)Obj.WindowForVolumeDetection.numericUpDownIterationNumber.Value; float MergingRatio = (float)((Obj.WindowForVolumeDetection.trackBarMergingStrength.Maximum - Obj.WindowForVolumeDetection.trackBarMergingStrength.Value) / 100.0); Obj.AssociatedBiologicalObjectList = Detection.RegionGrowing(OFNucleus, (float)Obj.WindowForVolumeDetection.numericUpDownIntensityForRegionGrowing.Value, (float)Obj.WindowForVolumeDetection.numericUpDownVolumeMinVol.Value, (float)Obj.WindowForVolumeDetection.numericUpDownVolumeMaxVol.Value, NumIterations, MergingRatio); } // else // { // throw new System.ArgumentException("Not implemented", "Error"); // } // } // else // start from seeds points // { // // first gather the seeds // if (Obj.WindowForVolumeDetection.comboBoxExistingSpotsDetected.Items.Count == 0) break; // List<cBiological3DObject> ListSeeds = Current3DWorld.GetListBiologicalObjectsOfType(Obj.WindowForVolumeDetection.comboBoxExistingSpotsDetected.Items[0].ToString()); // int NumIterations = -1; // if (Obj.WindowForVolumeDetection.checkBoxIsConvergence.Checked == false) NumIterations = (int)Obj.WindowForVolumeDetection.numericUpDownIterationNumber.Value; // float MergingRatio = (float)((Obj.WindowForVolumeDetection.trackBarMergingStrength.Maximum - Obj.WindowForVolumeDetection.trackBarMergingStrength.Value) / 100.0); // Obj.AssociatedBiologicalObjectList = Detection.RegionGrowing(ListSeeds, // (float)Obj.WindowForVolumeDetection.numericUpDownIntensityForRegionGrowing.Value, // (float)Obj.WindowForVolumeDetection.numericUpDownVolumeMinVol.Value, // (float)Obj.WindowForVolumeDetection.numericUpDownVolumeMaxVol.Value, NumIterations, MergingRatio); } } if (Obj.AssociatedBiologicalObjectList != null) { Obj.richTextBoxInfo.AppendText(Obj.AssociatedBiologicalObjectList.Count + " objects detected."); for (int i = 0; i < Obj.AssociatedBiologicalObjectList.Count; i++) { cBiological3DVolume TmpVol = (cBiological3DVolume)Obj.AssociatedBiologicalObjectList[i]; Obj.AssociatedBiologicalObjectList[i].SetType(Obj.textBoxName.Text); // TmpVol.ThumbnailnewImage = imageListForThumbnail.Images[Obj.AssociatedBiologicalObjectList[i].GetType() + ".jpg"]; Obj.AssociatedBiologicalObjectList[i].Name = Obj.textBoxName.Text + " " + i; // Obj.AssociatedBiologicalObjectList[i].IsMaster = Obj.IsMasterObject(); // List<double> Res = TmpVol.Information.GetInformation(); if (Obj.checkBoxIsDisplayName.Checked) { cGeometric3DObject AssociatedText = TmpVol.AttachText(TmpVol.Name, 10, Color.White); AssociatedText.IsStayInFrontOfCamera = true; Current3DWorld.AddGeometric3DObject(AssociatedText); // TmpVol.AddText(TmpVol.Name, Current3DWorld, (double)Obj.ForText.numericUpDownArrowScale.Value, Obj.ForText.buttonChangeColorPositive.BackColor); } if (Obj.checkIsBoxPointingArrow.Checked) { cGeometric3DObject AssociatedArrow = TmpVol.AttachPointingArrow((double)Obj.ForArrow.numericUpDownArrowScale.Value, Obj.ForArrow.buttonChangeColorPositive.BackColor); Current3DWorld.AddGeometric3DObject(AssociatedArrow); } Obj.AssociatedBiologicalObjectList[i].SetOpacity((double)Obj.ColorOpacity.numericUpDownValue.Value); // if the object it the Master then create a meta-object and put it inside if (Obj.IsMasterObject()) { cMetaBiologicalObject Cell = new cMetaBiologicalObject(Obj.WindowForMaster.textBoxName.Text + i, Current3DWorld.ListMetaObjectList[0], Obj.AssociatedBiologicalObjectList[i]); // // Cell.AddObject(Obj.AssociatedBiologicalObjectList[i]); Current3DWorld.ListMetaObjectList[0].Add(Cell); } } if (Obj.radioButtonColorSingle.Checked) Current3DWorld.AddBiological3DObjects(Obj.AssociatedBiologicalObjectList, Obj.buttonChangeColorPositive.BackColor, eColorMode.Regular); else if (Obj.radioButtonColorRandom.Checked) Current3DWorld.AddBiological3DObjects(Obj.AssociatedBiologicalObjectList, Obj.buttonChangeColorPositive.BackColor, eColorMode.Random); else if (Obj.radioButtonColorIndexed.Checked) Current3DWorld.AddBiological3DObjects(Obj.AssociatedBiologicalObjectList, Obj.buttonChangeColorPositive.BackColor, eColorMode.Indexed); } } else if (Obj.RadioButtonIsSpot.Checked) { cSpotDetection Detection = new cSpotDetection(SeqToAnalyse, (int)Obj.numericUpDownChannel.Value); if ((Obj.checkBoxPreProcessings.Checked == false) || (Obj.WindowForPreProcessing.checkBoxMedianIsDisabled.Checked)) { Detection.SetMedian(-1); Detection.SetShift(new cPoint3D(0, 0, 0)); } else { Detection.SetMedian((int)Obj.WindowForPreProcessing.numericUpDownMedianKernel.Value); Detection.SetShift(new cPoint3D((float)Obj.WindowForPreProcessing.numericUpDownShiftX.Value, (float)Obj.WindowForPreProcessing.numericUpDownShiftY.Value, (float)Obj.WindowForPreProcessing.numericUpDownShiftZ.Value)); } if ((Obj.comboBoxContainer.Items.Count > 0) && (Obj.comboBoxContainer.SelectedItem != null)) { Detection.SetContainers(Current3DWorld.GetListBiologicalObjectsOfType(Obj.comboBoxContainer.SelectedItem.ToString())); if (Obj.InOrOut.radioButtonIn.Checked) Detection.SetContainersMode(0); else Detection.SetContainersMode(1); } Obj.AssociatedBiologicalObjectList = Detection.HessianDetection((float)Obj.WindowForSpotDetection.numericUpDownSpotRadius.Value, (float)Obj.WindowForSpotDetection.numericUpDownIntensityThreshold.Value, (int)Obj.WindowForSpotDetection.numericUpDownSpotLocality.Value, (double)Obj.WindowForSpotDetection.numericUpDownSphereDisplayRadius.Value); Obj.richTextBoxInfo.AppendText(Obj.AssociatedBiologicalObjectList.Count + " objects detected."); for (int i = 0; i < Obj.AssociatedBiologicalObjectList.Count; i++) { cBiologicalSpot TmpSpot = (cBiologicalSpot)Obj.AssociatedBiologicalObjectList[i]; TmpSpot.Name = Obj.textBoxName.Text + " " + i; TmpSpot.SetType(Obj.textBoxName.Text); // TmpSpot.ThumbnailnewImage = imageListForThumbnail.Images[Obj.AssociatedBiologicalObjectList[i].GetType() + ".jpg"]; // if (Obj.checkBoxIsDisplayName.Checked) // TmpSpot.AddText(TmpSpot.Name, Current3DWorld, (double)Obj.ForText.numericUpDownArrowScale.Value, Obj.ForText.buttonChangeColorPositive.BackColor); if (Obj.checkIsBoxPointingArrow.Checked) { cGeometric3DObject AssociatedArrow = TmpSpot.AttachPointingArrow((double)Obj.ForArrow.numericUpDownArrowScale.Value, Obj.ForArrow.buttonChangeColorPositive.BackColor); Current3DWorld.AddGeometric3DObject(AssociatedArrow); } // TmpSpot.SetOpacity((double)Obj.ColorOpacity.numericUpDownValue.Value); // // if the object it the Master then create a meta-object and put it inside if (Obj.IsMasterObject()) { cMetaBiologicalObject Cell = new cMetaBiologicalObject("Cell " + i, Current3DWorld.ListMetaObjectList[0], Obj.AssociatedBiologicalObjectList[i]); // // Cell.AddObject(Obj.AssociatedBiologicalObjectList[i]); Current3DWorld.ListMetaObjectList[0].Add(Cell); } // /*cMetaBiologicalObject Cell = */ // //Current3DWorld.ListMetaObjectList[0].AssociateWith(Current3DWorld.ListMetaObjectList[0].FindTheClosestVolumeFrom(TmpSpot.GetCentroid(), 20), TmpSpot); } // if (Obj.radioButtonColorSingle.Checked) // Current3DWorld.AddBiological3DObjects(Obj.AssociatedBiologicalObjectList, Obj.buttonChangeColorPositive.BackColor, eColorMode.Regular); // else if (Obj.radioButtonColorRandom.Checked) // Current3DWorld.AddBiological3DObjects(Obj.AssociatedBiologicalObjectList, Obj.buttonChangeColorPositive.BackColor, eColorMode.Random); // else if (Obj.radioButtonColorIndexed.Checked) // Current3DWorld.AddBiological3DObjects(Obj.AssociatedBiologicalObjectList, Obj.buttonChangeColorPositive.BackColor, eColorMode.Indexed); } else if (Obj.radioButtonIsVolumeRendering.Checked) { Current3DWorld.AddVolume3D(new cVolumeRendering3D(this.AssociatedImage.SingleChannelImage[(int)Obj.numericUpDownChannel.Value], new cPoint3D((float)Obj.WindowForPreProcessing.numericUpDownShiftX.Value, (float)Obj.WindowForPreProcessing.numericUpDownShiftY.Value, (float)Obj.WindowForPreProcessing.numericUpDownShiftZ.Value), null, Current3DWorld)); // cVolume3D Volume = new cVolume3D(SeqToAnalyse, (int)Obj.numericUpDownChannel.Value, new cPoint3D((float)Obj.WindowForPreProcessing.numericUpDownShiftX.Value, (float)Obj.WindowForPreProcessing.numericUpDownShiftY.Value, (float)Obj.WindowForPreProcessing.numericUpDownShiftZ.Value)); // Current3DWorld.AddVolume3D(Volume, Color.Black, Obj.buttonChangeColorPositive.BackColor); } // Thread oThread = new Thread(new ThreadStart(Obj.DisplayDone)); } #endregion #region Objects Association cMetaBiologicalObjectList MetaCellList = Current3DWorld.ListMetaObjectList[0]; // let's associate the objects for (int k = 0; k < ListFormForControl.Count; k++) { FormForControl Obj = ListFormForControl.ElementAt(ListFormForControl.Count - k -1); // that's a volume rendering ... no connection if (Obj.radioButtonIsVolumeRendering.Checked) continue; // the object is the master if (Obj.IsMasterObject()) continue; // this object has not connections ... is not associated to the master if (Obj.comboBoxLinkToTheMaster.SelectedIndex == 0) continue; cPoint3D ClosestPt = new cPoint3D(0, 0, 0); foreach (cBiological3DVolume CurrentSubObj in Obj.AssociatedBiologicalObjectList) { cBiological3DVolume ObjectToIdentify = null; switch (Obj.comboBoxLinkToTheMaster.SelectedIndex) { case 1: // association by distance to the master centroid ObjectToIdentify = MetaCellList.FindTheClosestVolumeCentroidFrom(CurrentSubObj.GetCentroid(), (double)Obj.WindowDistanceToMaster.numericUpDownDistanceMaxToMaster.Value); break; case 2: // //cBiological3DVolume CurrentVolume ObjectToIdentify = MetaCellList.FindTheClosestVolumeFrom(CurrentSubObj, (double)Obj.WindowDistanceToMaster.numericUpDownDistanceMaxToMaster.Value, out ClosestPt); break; default: break; } if (ObjectToIdentify == null) continue; cMetaBiologicalObject Cell = MetaCellList.AssociateWith(ObjectToIdentify, CurrentSubObj); // // -------------- draw information and links between the objects --------------------- if (Obj.WindowDistanceToMaster.checkBoxDrawLinkToMasterCenter.Checked) { c3DLine CurrLine = new c3DLine(CurrentSubObj.GetCentroid(), ObjectToIdentify.GetCentroid()); Current3DWorld.AddGeometric3DObject(CurrLine); //if (Obj.WindowDistanceToMaster.checkBoxDisplayBranchToCenterDistance.Checked) // CurrLine.DisplayLenght(Current3DWorld, 0.4); } // // -------------- draw information and links between the objects --------------------- if (Obj.WindowDistanceToMaster.checkBoxDrawLinkToMasterEdges.Checked) { c3DLine CurrLine1 = new c3DLine(CurrentSubObj.GetCentroid(), ClosestPt); Current3DWorld.AddGeometric3DObject(CurrLine1); //if(Obj.WindowDistanceToMaster.checkBoxDisplayBranchToEdgesDistance.Checked) // CurrLine1.DisplayLenght(Current3DWorld, 0.4); } } } #endregion #region Post Processings for (int k = 0; k < ListFormForControl.Count; k++) { FormForControl Obj = ListFormForControl.ElementAt(ListFormForControl.Count - k - 1); // the object is the master // // if (!Obj.IsMasterObject()) continue; if (!Obj.WindowForMaster.checkBoxDrawAssociatedDelaunay.Checked) continue; foreach (cMetaBiologicalObject CurrentMeta in MetaCellList) { Current3DWorld.AddGeometric3DObject(CurrentMeta.GenerateDelaunay(2.0f,true)); } } if (PostProcessWindow.checkBoxRemoveUnAssociatedObjects.Checked) { int RemovedObjects = Current3DWorld.RemoveNonAssociatedObjects(); Console.WriteLine(RemovedObjects + " objects removed."); } // if (PostProcessWindow.checkBoxExportMetaObjectSignatures.Checked) // { // if (CurrentTable == null) // { // CurrentTable = new DataTable(); // if (CurrentExperiment == null) // CurrentTable.Columns.Add(new DataColumn("Image Idx", typeof(int))); // else // { // CurrentTable.Columns.Add(new DataColumn("Image Col.", typeof(int))); // CurrentTable.Columns.Add(new DataColumn("Image Row", typeof(int))); // } // CurrentTable.Columns.Add(new DataColumn("Meta Object Name", typeof(string))); // foreach (string DescName in MetaCellList[0].GetSignatureNames()) // CurrentTable.Columns.Add(new DataColumn(DescName, typeof(double))); // CurrentTable.Columns.Add(new DataColumn("Class", typeof(double))); // } // foreach (cMetaBiologicalObject CurrentMeta in MetaCellList) // { // List<double> CurrentSignature = CurrentMeta.GetSignature(); // CurrentTable.Rows.Add(); // if (CurrentExperiment == null) // { // CurrentTable.Rows[CurrentTable.Rows.Count - 1][0] = IdxImageProcessed; // CurrentTable.Rows[CurrentTable.Rows.Count - 1][1] = CurrentMeta.Name; // for (int Idx = 0; Idx < CurrentSignature.Count; Idx++) // CurrentTable.Rows[CurrentTable.Rows.Count - 1][Idx + 2] = CurrentSignature[Idx]; // } // else // { // CurrentTable.Rows[CurrentTable.Rows.Count - 1][0] = CurrentExperiment.Column; // CurrentTable.Rows[CurrentTable.Rows.Count - 1][1] = CurrentExperiment.Row; // CurrentTable.Rows[CurrentTable.Rows.Count - 1][2] = CurrentMeta.Name; // for (int Idx = 0; Idx < CurrentSignature.Count; Idx++) // CurrentTable.Rows[CurrentTable.Rows.Count - 1][Idx + 3] = CurrentSignature[Idx]; // } // // Current3DWorld.CopyMetaObjectSignatureToTable(CurrentMeta, 0); // } // if (DataGrid != null) // { // DataGrid.dataGridViewForResults.DataSource = CurrentTable; // DataGrid.Update(); // IdxImageProcessed++; // } // } #endregion // //CurrentTable = new DataTable(); // if (CurrentExperiment == null) // { // if (PostProcessWindow.checkBoxDisplayBottomPlate.Checked) Current3DWorld.DisplayBottom(Color.FromArgb(255, 255, 255)); // Current3DWorld.SetBackgroundColor(PostProcessWindow.buttonChangeColorPositive.BackColor); // Current3DWorld.Render(); // } // // Current3DWorld.SetLinkToDataGridView(dataGridViewForClassif); cViewer3D V3D = new cViewer3D(); V3D.SetInputData(Current3DWorld); V3D.Run(); cDisplayToWindow DTW = new cDisplayToWindow(); DTW.SetInputData(V3D.GetOutPut()); DTW.Run(); DTW.Display(); }
public void SetInputData(vtkExtractVOI Input, cPoint3D Pos) { this.VTKInput = Input; this.Pos = Pos; }