// // Silently collect data from the input sources. // internal void collectVolatileData_Silent() { try { // Choose input. IGH_Structure orig = new GH_Structure <IGH_Goo>(); if (this.Sources.Count > 0 && !isNullOrEmpty(this.Sources[0].VolatileData)) { orig = this.Sources[0].VolatileData; } else if (m_param.Sources.Count > 0 && !isNullOrEmpty(m_param.Sources[0].VolatileData)) { orig = m_param.Sources[0].VolatileData; } GH_Structure <IGH_Goo> TempCopy = DuplicateStructure(orig); localCopy = TempCopy.Duplicate(); int minh = PathIndex(history, "min"); int maxnew = PathIndex(TempCopy, "max"); history = shiftPaths(history, Math.Max(0, maxnew - minh + 1), true); TempCopy.MergeStructure(history); history = TempCopy; this.m_data = localCopy.Duplicate(); } catch (Exception e) { m_owner.attr.Panel.Message("err", m_owner.NickName, "Error while collecting data: " + e.Message); } }
/// <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) { GH_Structure <IGH_Goo> telepathy = null; bool stop = false; DA.GetDataTree(0, out telepathy); DA.GetData(1, ref stop); if (stop) { return; } OutComponents = FindTelepathyOut(NickName); foreach (GH_TelepathyOut c in OutComponents) { if (deepDuplicate) { c.telepathy = telepathy.Duplicate(); } else { c.telepathy = telepathy; } c.ExpireSolution(true); } }
/// <summary> /// Match the number of values of two given data structure, modifing the one with less elements. GH_Curve => GH_Plane /// </summary> /// <param name="refGhCurves"></param> /// <param name="inputPlanes"></param> /// <param name="outputPlanes"></param> /// <returns></returns> public static GH_Structure <GH_Plane> PlanesDSFromCurves(GH_Structure <GH_Curve> refGhCurves, GH_Structure <GH_Plane> inputPlanes, GH_Structure <GH_Plane> outputPlanes) { bool planesTopoEqualCurvesTopo = refGhCurves.TopologyDescription.Equals(inputPlanes.TopologyDescription); if (planesTopoEqualCurvesTopo) { outputPlanes = inputPlanes.Duplicate(); } else { foreach (GH_Path ghPath in refGhCurves.Paths) { for (int i = 0; i < refGhCurves.get_Branch(ghPath).Count; i++) { outputPlanes.Insert(inputPlanes.get_LastItem(true), ghPath, i); } } } return(outputPlanes); }
/// <summary> /// Match the number of values of two given data structure, modifing the one with less elements. GH_Breps => GH_Numbers /// </summary> /// <param name="inGhBreps"></param> /// <param name="inGhNums"></param> /// <param name="outGhNums"></param> /// <returns></returns> public static GH_Structure <GH_Number> NumbersDSFromBreps(GH_Structure <GH_Brep> inGhBreps, GH_Structure <GH_Number> inGhNums, GH_Structure <GH_Number> outGhNums) { bool brepTopoEqualNumsTopo = inGhNums.TopologyDescription.Equals(inGhBreps.TopologyDescription); if (brepTopoEqualNumsTopo) { outGhNums = inGhNums.Duplicate(); } else { foreach (GH_Path ghPath in inGhBreps.Paths) { for (int i = 0; i < inGhBreps.get_Branch(ghPath).Count; i++) { outGhNums.Insert(inGhNums.get_LastItem(true), ghPath, i); } } } return(outGhNums); }
/// <summary> /// Match the number of values of two given data structure, modifing the one with less elements. GH_Breps => GH_Boolean /// </summary> /// <param name="inGhBreps"></param> /// <param name="inGhBool"></param> /// <param name="outGhBool"></param> /// <returns></returns> public static GH_Structure <GH_Boolean> BoolDSFromBreps(GH_Structure <GH_Brep> inGhBreps, GH_Structure <GH_Boolean> inGhBool, GH_Structure <GH_Boolean> outGhBool) { bool brepTopologyEqualBoolTopology = inGhBool.TopologyDescription.Equals(inGhBreps.TopologyDescription); if (brepTopologyEqualBoolTopology) { outGhBool = inGhBool.Duplicate(); } else { foreach (GH_Path ghPath in inGhBreps.Paths) { for (int i = 0; i < inGhBreps.get_Branch(ghPath).Count; i++) { outGhBool.Insert(inGhBool.get_LastItem(true), ghPath, i); } } } return(outGhBool); }
/// <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) { InputChecker inputChecker = new InputChecker(this); #region get Input From GH Canvas GH_Structure <GH_Curve> inCurves = new GH_Structure <GH_Curve>(); bool areCurvesOK = DA.GetDataTree(0, out inCurves); inputChecker.StopIfConversionIsFailed(areCurvesOK); GH_Structure <GH_Curve> ghCurves = new GH_Structure <GH_Curve>(); ghCurves = inCurves.Duplicate(); ghCurves.Graft(GH_GraftMode.GraftAll); ghCurves.Simplify(GH_SimplificationMode.CollapseAllOverlaps); GH_Structure <GH_Number> inDistances = new GH_Structure <GH_Number>(); bool areDistancesOk = DA.GetDataTree(1, out inDistances); inputChecker.StopIfConversionIsFailed(areDistancesOk); GH_Structure <GH_Number> ghDistances = new GH_Structure <GH_Number>(); ghDistances = ValuesAllocator.NumsDSFromCurves(ghCurves, inDistances, ghDistances); GH_Structure <GH_Plane> inPlanes = new GH_Structure <GH_Plane>(); bool arePlanesOk = DA.GetDataTree(2, out inPlanes); inputChecker.StopIfConversionIsFailed(arePlanesOk); GH_Structure <GH_Plane> ghPlanes = new GH_Structure <GH_Plane>(); ghPlanes = ValuesAllocator.PlanesDSFromCurves(ghCurves, inPlanes, ghPlanes); GH_Structure <GH_Integer> inCorners = new GH_Structure <GH_Integer>(); bool areCornerssOk = DA.GetDataTree(3, out inCorners); inputChecker.StopIfConversionIsFailed(areCornerssOk); GH_Structure <GH_Integer> ghCorners = new GH_Structure <GH_Integer>(); ghCorners = ValuesAllocator.IntegerDSFromCurves(ghCurves, inCorners, ghCorners); #endregion GH_Structure <GH_Curve> ghCurveOffset = new GH_Structure <GH_Curve>(); double docTollerance = DocumentTolerance(); int pathIndex = 0; foreach (GH_Path ghPath in ghCurves.Paths) { for (int i = 0; i < ghCurves.get_Branch(ghPath).Count; i++) { CurveOffsetCornerStyle cornerStyle = CurveOffsetCornerStyle.None; int cornerStyleInInt = ghCorners.get_DataItem(ghPath, i).Value; GetCornerStyleFromInt(ref cornerStyleInInt, ref cornerStyle); Curve crv = ghCurves.get_DataItem(ghPath, i).Value; Plane plane = ghPlanes.get_DataItem(ghPath, i).Value; double dist = ghDistances.get_DataItem(ghPath, i).Value; List <Curve> resultingCurves = new List <Curve>(); resultingCurves.AddRange(crv.Offset(plane, dist, docTollerance, cornerStyle)); resultingCurves.AddRange(crv.Offset(plane, dist *= -1, docTollerance, cornerStyle)); foreach (Curve resultingCrv in resultingCurves) { GH_Curve ghResultingCrv = null; if (GH_Convert.ToGHCurve(resultingCrv, GH_Conversion.Both, ref ghResultingCrv)) { ghCurveOffset.Append(ghResultingCrv, ghPath); } } } pathIndex++; } DA.SetDataTree(0, ghCurveOffset); }
internal void clearAllData() { localCopy = new GH_Structure <IGH_Goo>(); history = new GH_Structure <IGH_Goo>(); this.m_data = localCopy.Duplicate(); }
protected override void CollectVolatileData_FromSources() { this.m_data = localCopy.Duplicate(); }