public cFeedBackMessage Run(c3DNewWorld _3DWorld) { if (this.Input == null) { FeedBackMessage.IsSucceed = false; FeedBackMessage.Message = "No input data table defined."; return FeedBackMessage; } ListObjects = new cListGeometric3DObject("Plate MetaObject"); cImage I = this.Input.GetClassColorImage(); // cDisplaySingleImage DSI = new cDisplaySingleImage(); // DSI.SetInputData(I); // DSI.Run(); c3DTexturedPlan PlateTexture = new c3DTexturedPlan(new cPoint3D(0, 0, 0), I); //c3DTexturedPlan PlateTexture = new c3DTexturedPlan(new cPoint3D(0,0,0),this.Input.GetColorImage()); PlateTexture.SetName(Input.GetShortInfo()); PlateTexture.Tag = this.Input; // List<byte[][]> TmpLut = new List<byte[][]>(); // TmpLut.Add(cGlobalInfo.CurrentPlateLUT); // PlateTexture.LUT = TmpLut ; PlateTexture.Run(); ListObjects.AddObject(PlateTexture); ListObjects[0].Tag = ListObjects.Tag = this.Input; ListObjects.AddObject(new c3DText(this.Input.GetName(), new cPoint3D(-12-1.2, -8-1.2, 0.2), Color.Black, 70)); return base.FeedBackMessage; }
public cFeedBackMessage Run(c3DNewWorld _3DWorld) { if (this.Input == null) { FeedBackMessage.IsSucceed = false; FeedBackMessage.Message = "No input data table defined."; return FeedBackMessage; } ListObjects = new cListGeometric3DObject("Screening MetaObject"); int IdxPlate = 0; int Pos = 0; foreach (cPlate item in this.Input.ListPlatesActive) { c3DObject_Plate2D P2D = new c3DObject_Plate2D(); P2D.SetInputData(item); P2D.Run(_3DWorld); foreach (var itemObj in P2D.GetOutPut()) { cPoint3D CurrentObjPos = itemObj.GetPosition() + new cPoint3D(Pos, 0, 0); itemObj.SetPosition(CurrentObjPos); } //P2D.GetOutPut()[0].Tag = item; Pos += this.Input.Columns + 10; //c3DTexturedPlan PlateTexture = new c3DTexturedPlan(new cPoint3D(0,0,0),this.Input.GetColorImage()); //PlateTexture.SetName(Input.()); //PlateTexture.Tag = this.Input; //List<byte[][]> TmpLut = new List<byte[][]>(); //TmpLut.Add(cGlobalInfo.CurrentPlateLUT); //PlateTexture.LUT = TmpLut ; //PlateTexture.Run(); foreach (var itemObj in P2D.GetOutPut()) { ListObjects.AddObject(itemObj); } IdxPlate++; } ListObjects.Tag = this.Input; return base.FeedBackMessage; }
public void SetInputData(cListGeometric3DObject ListObjects) { this.ListObjects = ListObjects; }
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; }
private void dToolStripMenuItemScatterPlot3D_Click(object sender, EventArgs e) { int MaxNumberOfPts = (int)cGlobalInfo.OptionsWindow.FFAllOptions.numericUpDownMinNumPointForFastDisp.Value; if (cGlobalInfo.CurrentScreening.ListPlatesActive.GetListActiveWells().Count > MaxNumberOfPts) { cExtendedTable ET = cGlobalInfo.CurrentScreening.ListPlatesActive.GetListActiveWells().GetAverageDescriptorValues(cGlobalInfo.CurrentScreening.ListDescriptors.GetActiveDescriptors(), false, false); cNormalize N = new cNormalize(); N.SetInputData(ET); N.NormalizationType = eNormalizationType.MIN_MAX; N.Run(); cExtendedTable NormTable = N.GetOutPut(); cViewer3D V3D = new cViewer3D(); c3DPointCloud _3DPtCloud = new c3DPointCloud(NormTable); _3DPtCloud.AutomatedPtColorMode = 1; _3DPtCloud.Create(new cPoint3D(0, 0, 0)); _3DPtCloud.SetName("_3DPtCloud"); cListGeometric3DObject GlobalList = new cListGeometric3DObject("3D Point Cloud MetaObject"); GlobalList.Add(_3DPtCloud); c3DObject_Axis Axis = new c3DObject_Axis(); cExtendedTable T = new cExtendedTable(); T.Add(new cExtendedList(ET[0].Name)); T[0].Tag = ET[0].Tag; T[0].Add(0); T[0].Add(1); T.Add(new cExtendedList(ET[1].Name)); T[1].Tag = ET[1].Tag; T[1].Add(0); T[1].Add(1); if (ET.Count > 2) { T.Add(new cExtendedList(ET[2].Name)); T[2].Tag = ET[2].Tag; T[2].Add(0); T[2].Add(1); } Axis.SetInputData(T); c3DNewWorld MyWorld = new c3DNewWorld(new cPoint3D(1, 1, 1), new cPoint3D(1, 1, 1)); Axis.Run(MyWorld); GlobalList.AddRange(Axis.GetOutPut()); // GlobalList.Add(Axis); foreach (var item in GlobalList) { MyWorld.AddGeometric3DObject(item); } // MyWorld.BackGroundColor = cGlobalInfo.OptionsWindow.FFAllOptions.panelFor3DBackColor.BackColor; V3D.SetInputData(MyWorld); V3D.Run(); cDisplayToWindow DTW = new cDisplayToWindow(); DTW.SetInputData(V3D.GetOutPut()); DTW.Title = "3D Cloud Point - " + ET[0].Count + " points"; DTW.Run(); DTW.Display(); } else { cGlobalInfo.OptionsWindow.checkBoxConnectDRCPts.Checked = false; FormFor3DDataDisplay FormToDisplayXYZ = new FormFor3DDataDisplay(ProcessModeEntireScreeningToolStripMenuItem.Checked, cGlobalInfo.CurrentScreening); for (int i = 0; i < (int)cGlobalInfo.CurrentScreening.ListDescriptors.Count; i++) { FormToDisplayXYZ.comboBoxDescriptorX.Items.Add(cGlobalInfo.CurrentScreening.ListDescriptors[i].GetName()); FormToDisplayXYZ.comboBoxDescriptorY.Items.Add(cGlobalInfo.CurrentScreening.ListDescriptors[i].GetName()); FormToDisplayXYZ.comboBoxDescriptorZ.Items.Add(cGlobalInfo.CurrentScreening.ListDescriptors[i].GetName()); } FormToDisplayXYZ.Show(); FormToDisplayXYZ.comboBoxDescriptorX.Text = cGlobalInfo.CurrentScreening.ListDescriptors[0].GetName() + " "; FormToDisplayXYZ.comboBoxDescriptorY.Text = cGlobalInfo.CurrentScreening.ListDescriptors[0].GetName() + " "; FormToDisplayXYZ.comboBoxDescriptorZ.Text = cGlobalInfo.CurrentScreening.ListDescriptors[0].GetName() + " "; } return; }
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; }
private void ToolStripMenuItem_Display3DTexture(object sender, EventArgs e) { cViewer3D V3D = new cViewer3D(); c3DNewWorld MyWorld = new c3DNewWorld(new cPoint3D(1, 1, 1), new cPoint3D(1, 1, 1)); cListGeometric3DObject GlobalList = new cListGeometric3DObject("2D Texture Metaobject"); c3DTexturedPlan _3DPlan = new c3DTexturedPlan(new cPoint3D(0, 0, 0), this.AssociatedImage); // c3DElevationMap _3DMap = new c3DElevationMap(new cPoint3D(0, 0, 0), this.Input, this.LUT); _3DPlan.SetName("2D Texture"); _3DPlan.Run(); GlobalList.Add(_3DPlan); foreach (var item in GlobalList) MyWorld.AddGeometric3DObject(item); // MyWorld.AddLight(Color.White); V3D.SetInputData(MyWorld); V3D.Run(); cDisplayToWindow DTW = new cDisplayToWindow(); DTW.SetInputData(V3D.GetOutPut()); DTW.Title = "2D texture (" + this.AssociatedImage.Name + ")"; DTW.Run(); DTW.Display(); }
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 cFeedBackMessage Run(c3DNewWorld _3DWorld) { if (base.Start() == false) { base.FeedBackMessage.IsSucceed = false; return base.FeedBackMessage; } #region Properties Management object _firstValue = base.ListProperties.FindByName("Thresold"); double Thresold = 0.5; if (_firstValue == null) { base.GenerateError("-Thresold- not found !"); return base.FeedBackMessage; } try { cProperty TmpProp = (cProperty)_firstValue; Thresold = (double)TmpProp.GetValue(); } catch (Exception) { base.GenerateError("-Thresold- cast didn't work"); return base.FeedBackMessage; } _firstValue = base.ListProperties.FindByName("Split objects ?"); bool IsSplit = false; if (_firstValue == null) { base.GenerateError("-Split objects ?- not found !"); return base.FeedBackMessage; } try { cProperty TmpProp = (cProperty)_firstValue; IsSplit = (bool)TmpProp.GetValue(); } catch (Exception) { base.GenerateError("-Split objects ?- cast didn't work"); return base.FeedBackMessage; } #endregion ListObjects = new cListGeometric3DObject(""); if (IsSplit == false) { c3DMeshObject MyMesh = null; if (this.VTKInput == null) { MyMesh = new c3DMeshObject(this.Input, Thresold); } else { MyMesh = new c3DMeshObject(this.VTKInput, (int)Thresold); } MyMesh.Create(Color.Aqua, this.Pos ); ListObjects.Name = MyMesh.GetName() + " metaobject"; ListObjects.Add(MyMesh); } else { // ok that's a little bit more complicated now // first we need to binarize the image cImageSegmentationThreshold IST = new cImageSegmentationThreshold(); IST.ListProperties.FindByName("Threshold").SetNewValue(Thresold); cImage SourceImage = new cImage(this.Input, false); IST.SetInputData(SourceImage); IST.Run(); // now perform image labeling cImage BinImage = IST.GetOutPut(); cImage LabeledImage = new cImage(BinImage, false); ConnectedComponentSet CCS = new ConnectedComponentSet(BinImage,LabeledImage,SourceImage, 0, eConnectivity.THREED_6, 0, float.MaxValue); Random RD = new Random(); int IdxObj = 1; // loop over each object int NumObj = CCS.Count; ListObjects.Name = "T_" + Thresold + " [" + SourceImage.Name + " Metaobject"; for(int i = 0;i<NumObj;i++) { ConnectedVoxels item = CCS[i]; // if (item.Volume <= 1) continue; List<cPoint3D> ExtremePts = item.GetExtremaPoints(); // crop the labeled image cImage TmpIm = LabeledImage.Crop(ExtremePts[0], ExtremePts[1]); // we have to clean the cropped image to prevent any overlapping object to be segmented for (int Pix = 0; Pix < TmpIm.ImageSize; Pix++) { if ((TmpIm.SingleChannelImage[0].Data[Pix] > 0) && (TmpIm.SingleChannelImage[0].Data[Pix] != IdxObj)) TmpIm.SingleChannelImage[0].Data[Pix] = 0; } // update the position of the object cPoint3D NewPos = ExtremePts[0]*SourceImage.Resolution; c3DMeshObject MyMesh = new c3DMeshObject(TmpIm.SingleChannelImage[0], 0.5); MyMesh.Create(Color.FromArgb(RD.Next(255), RD.Next(255), RD.Next(255)), NewPos); MyMesh.SetName(MyMesh.GetName() + "_" + IdxObj); MyMesh.AssociatedConnectedComponent = item; ListObjects.AddObject(MyMesh); IdxObj++; } } return base.FeedBackMessage; }
private void GenerateGraph() { V3D = new cViewer3D(); MyWorld = new c3DNewWorld(new cPoint3D(1, 1, 1), new cPoint3D(1, 1, 1)); cListGeometric3DObject GlobalList = new cListGeometric3DObject("Elevation Map MetaObject"); if(this.Input!=null) foreach (var item in this.Input) { c3DElevationMap _3DMap = new c3DElevationMap(new cPoint3D(-this.Input[0].Count / 2, -this.Input[0][0].Count / 2, 0), item, this.LUT); _3DMap.SetName("Elevation Map [" + item.Name +"]"); GlobalList.Add(_3DMap); } if (this.InputImage != null) { for (int i = 0; i < this.InputImage.GetNumChannels(); i++) { c3DElevationMap _3DMapFromImage = new c3DElevationMap(new cPoint3D(0, 0, 0), this.InputImage, i, 0); if(this.InputImage.AssociatedImagePanel!=null) _3DMapFromImage.SetOpacity(this.InputImage.AssociatedImagePanel.LUTManager.GetImageDisplayProperties().ListOpacity[i]/100.0); _3DMapFromImage.SetName("Elevation Map [" + this.InputImage.SingleChannelImage[i].Name+"]"); GlobalList.Add(_3DMapFromImage); } } foreach (var item in GlobalList) { MyWorld.AddGeometric3DObject(item); } MyWorld.BackGroundColor = cGlobalInfo.OptionsWindow.FFAllOptions.panelFor3DBackColor.BackColor; V3D.SetInputData(MyWorld); V3D.Run(); #region obsolete //// get a reference to the renderwindow of our renderWindowControl1 //vtkRenderWindow RenderWindow = renderWindowControl1.RenderWindow; //// get a reference to the renderer //vtkRenderer Renderer = RenderWindow.GetRenderers().GetFirstRenderer(); //vtkPoints points = vtkPoints.New(); //double MaxZ = this.Input.Max(); //double MinZ = this.Input.Min(); //for (int IdxX = 0; IdxX < this.Input.Count; IdxX++) // for (int IdxY = 0; IdxY < this.Input[IdxX].Count; IdxY++) // { // double Value = ((this.Input[IdxX][this.Input[IdxX].Count- IdxY-1] - MinZ) / (MaxZ - MinZ) * this.Input.Count) / 5; // points.InsertNextPoint(IdxX, IdxY, Value); // } //double[] bounds = points.GetBounds(); //// Add the grid points to a polydata object //vtkPolyData inputPolyData = vtkPolyData.New(); //inputPolyData.SetPoints(points); //// Triangulate the grid points //vtkDelaunay2D delaunay = vtkDelaunay2D.New(); //delaunay.SetInput(inputPolyData); //delaunay.Update(); //vtkElevationFilter elevationFilter = vtkElevationFilter.New(); //elevationFilter.SetInputConnection(delaunay.GetOutputPort()); //elevationFilter.SetLowPoint(0.0, 0.0, bounds[5]); //elevationFilter.SetHighPoint(0.0, 0.0, bounds[4]); //elevationFilter.Update(); //vtkPolyData output = vtkPolyData.New(); //output.ShallowCopy(vtkPolyData.SafeDownCast(elevationFilter.GetOutput())); //// Generate the colors for each point based on the color map //vtkUnsignedCharArray colors = vtkUnsignedCharArray.New(); //colors.SetNumberOfComponents(3); //colors.SetName("Colors"); //output.GetPointData().AddArray(colors); //// Visualize //vtkPolyDataMapper mapper = vtkPolyDataMapper.New(); //mapper.SetInput(output); //// Create the color map //vtkLookupTable colorLookupTable = vtkLookupTable.New(); //colorLookupTable.Build(); //if (LUT == null) //{ // cLUT MyLut = new cLUT(); // LUT = MyLut.LUT_JET; //} ////colorLookupTable.SetValueRange(1,0);//bounds[0], bounds[1]); //double LUTSize = LUT[0].Length; //colorLookupTable.SetNumberOfTableValues((int)LUTSize - 1); //for (int i = 0; i < (int)LUTSize - 1; i++) //{ // colorLookupTable.SetTableValue((int)LUTSize - 1 - i-1, this.LUT[0][i] / LUTSize, this.LUT[1][i] / LUTSize, this.LUT[2][i] / LUTSize, 1); //} ////colorLookupTable.SetSaturationRange(0, 0); ////colorLookupTable.SetTableRange(bounds[4], bounds[5]); ////table.SetRange(range[0], range[1]); //shoul here not be the minimum/maximum possible of "data"? //// colorLookupTable.SetRampToLinear(); //colorLookupTable.Build(); //mapper.SetLookupTable(colorLookupTable); //vtkActor NewActor = vtkActor.New(); //NewActor.SetMapper(mapper); //Renderer.AddActor(NewActor); //// set background color //Renderer.SetBackground(BackGroundColor.R / 255.0, BackGroundColor.G / 255.0, BackGroundColor.B / 255.0); //// ensure all actors are visible (in this example not necessarely needed, //// but in case more than one actor needs to be shown it might be a good idea) //Renderer.ResetCamera(); #endregion }