private static GeometryBase ReadGeometryBase(GH_IReader reader) { var bytes = reader.GetByteArray("Data"); var valueInstance = GH_Convert.ByteArrayToCommonObject <GeometryBase>(bytes); return(valueInstance); }
public static Brep ReadHouseGeometry(string houseType) { string fileName = ReadResourceFile("Engine.Resources." + houseType + ".txt"); GeometryBase geometry = GH_Convert.ByteArrayToCommonObject <GeometryBase>(System.Convert.FromBase64String(fileName)); return(geometry as Brep); }
/// <summary> /// Initializes a new instance of the ObjController class. /// </summary> public ObjController1() : base("Controller1", "Controller1", "Tracking of HTC Vive Controller", "ViveTrack", "Tracking Device") { controller = GH_Convert.ByteArrayToCommonObject <GeometryBase>(System.Convert.FromBase64String(Resources.controller)); CurrenTrackedDevice = new VrTrackedDevice(); //(this as IGH_PreviewObject).Hidden = true; }
/// <summary> /// Initializes a new instance of the ObjHMD class. /// </summary> public ObjHMD() : base("Vive HMD", "HMD", "Tracking of HTC Vive HMD", "ViveTrack", "Tracking Device") { HMD = GH_Convert.ByteArrayToCommonObject <GeometryBase>(System.Convert.FromBase64String(Resources.HMD)); CurrenTrackedDevice = new VrTrackedDevice(); //(this as IGH_PreviewObject).Hidden = true; }
/// <summary> /// Initializes a new instance of the ObjTracker class. /// </summary> public ObjTracker() : base("Tracker", "Tracker", "HTC Vive Tracker 3D model", "ViveTrack", "Tracking Device") { tracker = GH_Convert.ByteArrayToCommonObject <GeometryBase>(System.Convert.FromBase64String(Resources.tracker)); CurrenTrackedDevice = new VrTrackedDevice(); //(this as IGH_PreviewObject).Hidden = true; }
/// <summary> /// Initializes a new instance of the ObjLighthouse class. /// </summary> public ObjLighthouse1() : base("Lighthouse1", "Lighthouse1", "Tracking of HTC Vive Lighthouse", "ViveTrack", "Tracking Device") { lighthouse = GH_Convert.ByteArrayToCommonObject <GeometryBase>(System.Convert.FromBase64String(Resources.lighthouse)); CurrenTrackedDevice = new VrTrackedDevice(); //(this as IGH_PreviewObject).Hidden = true; }
/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param> protected override void SolveInstance(IGH_DataAccess DA) { double d01 = 400; double d12 = 25; double d23 = 455; double d34 = 25; double d45 = 420; double d56 = 90; List <double> RobotData = new List <double>(); List <GeometryBase> RobotModel = new List <GeometryBase>(); RobotData.Add(d01); RobotData.Add(d12); RobotData.Add(d23); RobotData.Add(d34); RobotData.Add(d45); RobotData.Add(d56); string Axis1ModelString = Properties.Resources.axis1; string Axis12ModelString = Properties.Resources.axis12; string Axis23ModelString = Properties.Resources.axis23; string Axis34ModelString = Properties.Resources.axis34; string Axis45ModelString = Properties.Resources.axis45; string Axis56ModelString = Properties.Resources.axis56; string Axis6ModelString = Properties.Resources.axis6; GeometryBase Axis1Model = GH_Convert.ByteArrayToCommonObject <GeometryBase>(System.Convert.FromBase64String(Axis1ModelString)); GeometryBase Axis12Model = GH_Convert.ByteArrayToCommonObject <GeometryBase>(System.Convert.FromBase64String(Axis12ModelString)); GeometryBase Axis23Model = GH_Convert.ByteArrayToCommonObject <GeometryBase>(System.Convert.FromBase64String(Axis23ModelString)); GeometryBase Axis34Model = GH_Convert.ByteArrayToCommonObject <GeometryBase>(System.Convert.FromBase64String(Axis34ModelString)); GeometryBase Axis45Model = GH_Convert.ByteArrayToCommonObject <GeometryBase>(System.Convert.FromBase64String(Axis45ModelString)); GeometryBase Axis56Model = GH_Convert.ByteArrayToCommonObject <GeometryBase>(System.Convert.FromBase64String(Axis56ModelString)); GeometryBase Axis6Model = GH_Convert.ByteArrayToCommonObject <GeometryBase>(System.Convert.FromBase64String(Axis6ModelString)); RobotModel.Add(Axis1Model); RobotModel.Add(Axis12Model); RobotModel.Add(Axis23Model); RobotModel.Add(Axis34Model); RobotModel.Add(Axis45Model); RobotModel.Add(Axis56Model); RobotModel.Add(Axis6Model); DA.SetDataList(0, RobotData); DA.SetDataList(1, RobotModel); }
public static CrossSectionOrientation ReadCrossSectionOrientation(GH_IReader reader) { var type = reader.GetString("orientation"); switch (type) { case "RmfOrientation": return(new RmfOrientation()); case "PlanarOrientation": var plane = reader.GetPlane("orientation_plane"); return(new PlanarOrientation(new Plane( new Point3d(plane.Origin.x, plane.Origin.y, plane.Origin.z), new Vector3d(plane.XAxis.x, plane.XAxis.y, plane.XAxis.z), new Vector3d(plane.YAxis.x, plane.YAxis.y, plane.YAxis.z)))); case "VectorOrientation": var pt = reader.GetPoint3D("orientation_vector"); return(new VectorOrientation(new Vector3d(pt.x, pt.y, pt.z))); case "SurfaceOrientation": var srf_bytes = reader.GetByteArray("orientation_surface"); var srf = GH_Convert.ByteArrayToCommonObject <Brep>(srf_bytes); return(new SurfaceOrientation(srf)); case "VectorListOrientation": var vlguide = reader.GetByteArray("orientation_guide"); var num_vecs = reader.GetInt32("orientation_num_vectors"); List <Vector3d> vectors = new List <Vector3d>(); List <double> parameters = new List <double>(); for (int i = 0; i < num_vecs; ++i) { var v = reader.GetPoint3D("orientation_vector", i); var t = reader.GetDouble("orientation_parameter", i); vectors.Add(new Vector3d(v.x, v.y, v.z)); } return(new VectorListOrientation(GH_Convert.ByteArrayToCommonObject <Curve>(vlguide), parameters, vectors)); default: return(new RmfOrientation()); } }
public override bool Read(GH_IReader reader) { if (!reader.ItemExists("guide")) { Value = null; throw new Exception("Couldn't retrieve 'guide'."); } Curve guide = GH_Convert.ByteArrayToCommonObject <Curve>(reader.GetByteArray("guide")); if (guide == null) { throw new Exception("Failed to convert 'guide'."); } CrossSectionOrientation ori = GH_Glulam.ReadCrossSectionOrientation(reader); GlulamData data = GH_GlulamData.ReadGlulamData(reader); Value = Glulam.CreateGlulam(guide, ori, data); return(base.Read(reader)); }
public override bool Read(GH_IReader reader) { if (!reader.ItemExists("guide")) { Value = null; throw new Exception("Couldn't retrieve 'guide'."); } byte[] rawGuide = reader.GetByteArray("guide"); Curve guide = GH_Convert.ByteArrayToCommonObject <Curve>(rawGuide); if (guide == null) { throw new Exception("Failed to convert 'guide'."); } int N = reader.GetInt32("num_frames"); Plane[] frames = new Plane[N]; for (int i = 0; i < N; ++i) { var gp = reader.GetPlane("frames", i); frames[i] = new Plane( new Point3d( gp.Origin.x, gp.Origin.y, gp.Origin.z), new Vector3d( gp.XAxis.x, gp.XAxis.y, gp.XAxis.z), new Vector3d( gp.YAxis.x, gp.YAxis.y, gp.YAxis.z) ); } int lcx = reader.GetInt32("lcx"); int lcy = reader.GetInt32("lcy"); double lsx = reader.GetDouble("lsx"); double lsy = reader.GetDouble("lsy"); int interpolation = reader.GetInt32("interpolation"); int samples = reader.GetInt32("samples"); GlulamData data = new GlulamData(lcx, lcy, lsx, lsy, samples); data.InterpolationType = (GlulamData.Interpolation)interpolation; Value = Glulam.CreateGlulam(guide, frames, data); if (Value == null) { throw new Exception("What in the Lord's name..."); } //DisplayMesh = Value.GetBoundingMesh(); return(true); }