public bool Source(out Environment.Source[] S) { S = new Environment.Source[0]; System.Guid[] S_ID = SourceConduit.Instance.UUID.ToArray(); S = new Environment.Source[S_ID.Length]; for (int id = 0; id < S_ID.Length; id++) { if (S_ID[id] == System.Guid.Empty || S_ID[id] == System.Guid.NewGuid()) { break; } Rhino.DocObjects.RhinoObject Origin = Rhino.RhinoDoc.ActiveDoc.Objects.Find(S_ID[id]); if (Origin.ObjectType == Rhino.DocObjects.ObjectType.Point) { string S_Type = Origin.Geometry.GetUserString("SourceType"); string SWL = Origin.Geometry.GetUserString("SWL"); string D = Origin.Geometry.GetUserString("Delay"); double delay; if (D != "" && D != null) { delay = double.Parse(D) / 1000; } else { delay = 0; } string Ph = Origin.Geometry.GetUserString("Phase"); //double[] phase = new double[8]; //if (Ph != "") //{ // string[] phstr = Ph.Split(";"[0]); // for (int o = 0; o < 8; o++) phase[o] = double.Parse(phstr[o]); //} double[] SWL_Values = Utilities.PachTools.DecodeSourcePower(SWL); switch (S_Type) { case "": case "0": S[id] = new Environment.GeodesicSource(SWL_Values, Utilities.RC_PachTools.RPttoHPt(Origin.Geometry.GetBoundingBox(true).Min), id); break; case "1": S[id] = new Environment.RandomSource(SWL_Values, Utilities.RC_PachTools.RPttoHPt(Origin.Geometry.GetBoundingBox(true).Min), id); break; case "2": case "3": string Bands = Origin.Geometry.GetUserString("Bands"); string[] B; if (Bands != "") { B = Bands.Split(';'); } else { B = new string[2] { "0", "7" } }; SourceConduit SC = SourceConduit.Instance; S[id] = new Environment.DirectionalSource(SC.m_Balloons[id], SWL_Values, Utilities.RC_PachTools.RPttoHPt(Origin.Geometry.GetBoundingBox(true).Min), new int[] { int.Parse(B[0]), int.Parse(B[1]) }, id); break; } } else if (Origin.ObjectType == Rhino.DocObjects.ObjectType.Brep) { //string SWL = Origin.Geometry.GetUserString("SWL"); //string Ph = Origin.Geometry.GetUserString("Phase"); //double[] phase = new double[8]; //if (Ph != "") //{ // string[] phstr = Ph.Split(";"[0]); // for (int o = 0; o < 8; o++) phase[o] = double.Parse(phstr[o]); //} //double el_m; //double area = Brep.GetArea(); //Hare.Geometry.Topology t = new Hare.Geometry.Topology(); //Hare.Geometry.Point Samples; ////TODO: develope discretization of surface ////new Brep[] { (Origin.Geometry as Brep) }; //S[id] = new Environment.SurfaceSource(Samples, t, SWL, area, el_m, id, Environment.Source.Phase_Regime.Random); } else if (Origin.ObjectType == Rhino.DocObjects.ObjectType.Curve) { string SWL = Origin.Geometry.GetUserString("SWL"); //string Ph = Origin.Geometry.GetUserString("Phase"); //double[] phase = new double[8]; //if (Ph != "") //{ // string[] phstr = Ph.Split(";"[0]); // for (int o = 0; o < 8; o++) phase[o] = double.Parse(phstr[o]); //} Rhino.Geometry.Point3d[] pts = (Origin.Geometry as Curve).DivideEquidistant(1d / 4d); if (pts == null || pts.Length == 0) { pts = new Point3d[1] { (Origin.Geometry as Curve).PointAtNormalizedLength(0.5) } } ; Hare.Geometry.Point[] Samples = new Hare.Geometry.Point[pts.Length]; for (int i = 0; i < pts.Length; i++) { //Rhino.RhinoDoc.ActiveDoc.Objects.AddPoint(pts[i]); Samples[i] = Utilities.RC_PachTools.RPttoHPt(pts[i]); } S[id] = new Environment.LineSource(Samples, (Origin.Geometry as Curve).GetLength(), SWL, 4, id); } } if (S.Length > 0) { return(true); } return(false); }
public Pach_SourceControl() { SC = SourceConduit.Instance; InitializeComponent(); }
public bool Source(out Environment.Source[] S) { S = new Environment.Source[0]; if (Check_Special(ref S)) { return(true); } //UI.Pach_Source_Object S_command = UI.Pach_Source_Object.Instance; //S_command = UI.Pach_Source_Object.Instance; System.Guid[] S_ID = SourceConduit.Instance.UUID.ToArray(); S = new Environment.Source[S_ID.Length]; for (int id = 0; id < S_ID.Length; id++) { if (S_ID[id] == System.Guid.Empty || S_ID[id] == System.Guid.NewGuid()) { break; } Rhino.DocObjects.RhinoObject Origin = Rhino.RhinoDoc.ActiveDoc.Objects.Find(S_ID[id]); if (Origin.ObjectType == Rhino.DocObjects.ObjectType.Point) { string S_Type = Origin.Geometry.GetUserString("SourceType"); string SWL = Origin.Geometry.GetUserString("SWL"); string D = Origin.Geometry.GetUserString("Delay"); double delay; if (D != "") { delay = double.Parse(D) / 1000; } else { delay = 0; } string Ph = Origin.Geometry.GetUserString("Phase"); double[] phase = new double[8]; if (Ph != "") { string[] phstr = Ph.Split(";"[0]); for (int o = 0; o < 8; o++) { phase[o] = double.Parse(phstr[o]); } } double[] SWL_Values = Utilities.PachTools.DecodeSourcePower(SWL); switch (S_Type) { case "": case "0": S[id] = new Environment.GeodesicSource(SWL_Values, phase, Origin.Geometry.GetBoundingBox(true).Min, delay, id); break; case "1": S[id] = new Environment.RandomSource(SWL_Values, phase, Origin.Geometry.GetBoundingBox(true).Min, delay, id); break; case "2": string Bands = Origin.Geometry.GetUserString("Bands"); string[] B = Bands.Split(';'); SourceConduit SC = SourceConduit.Instance; S[id] = new Environment.SpeakerSource(SC.m_Balloons[id], SWL_Values, phase, Origin.Geometry.GetBoundingBox(true).Min, new int[] { int.Parse(B[0]), int.Parse(B[1]) }, delay, id); break; } } else if (Origin.ObjectType == Rhino.DocObjects.ObjectType.Brep) { string SWL = Origin.Geometry.GetUserString("SWL"); string Ph = Origin.Geometry.GetUserString("Phase"); double[] phase = new double[8]; if (Ph != "") { string[] phstr = Ph.Split(";"[0]); for (int o = 0; o < 8; o++) { phase[o] = double.Parse(phstr[o]); } } S[id] = new Environment.SurfaceSource(new Brep[] { (Origin.Geometry as Brep) }, new List <string> { SWL }, 1, id, Environment.Source.Phase_Regime.Random); } else if (Origin.ObjectType == Rhino.DocObjects.ObjectType.Curve) { string SWL = Origin.Geometry.GetUserString("SWL"); string Ph = Origin.Geometry.GetUserString("Phase"); double[] phase = new double[8]; if (Ph != "") { string[] phstr = Ph.Split(";"[0]); for (int o = 0; o < 8; o++) { phase[o] = double.Parse(phstr[o]); } } S[id] = new Environment.LineSource(Origin.Geometry as Curve, SWL, 1, id, Environment.Source.Phase_Regime.Random); } } if (S == null) { return(false); } return(true); }