/// <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) { // Declare variables IGH_Goo Z = null; int M = 0; Interval U = new Interval(50, 1000); Interval V = new Interval(50, 1000); // Access the input parameters if (!DA.GetData(0, ref Z)) return; if (!DA.GetData(1, ref M)) return; if (!DA.GetData(2, ref U)) return; if (!DA.GetData(3, ref V)) return; Bitmap A = null; if (Z != null) { Z.CastTo(out A); } Bitmap B = new Bitmap(A); mFilter Filter = new mFilter(); wDomain X = new wDomain(U.T0,U.T1); wDomain Y = new wDomain(V.T0, V.T1); switch (M) { case 0: Filter = new mFigureUnique(X, Y); break; case 1: Filter = new mFigureFilter(X, Y); break; case 2: Filter = new mFigureCorners(Color.Red); break; } B = new mApply(A, Filter).ModifiedBitmap; wObject W = new wObject(Filter, "Macaw", Filter.Type); DA.SetData(0, B); DA.SetData(1, W); }
/// <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) { // Declare variables IGH_Goo Z = null; int I = 0; int J = 0; bool C = true; bool D = true; Interval X = new Interval(0, 20); Interval Y = new Interval(0, 20); // Access the input parameters if (!DA.GetData(0, ref Z)) { return; } Bitmap A = new Bitmap(10, 10); if (Z != null) { Z.CastTo(out A); } mFilter Filter = new mFilter(); switch (ModeIndex) { case 0: Filter = new mErosionSimple(); break; case 1: Filter = new mErosionDilation(); break; case 2: Filter = new mErosionOpening(); break; case 3: Filter = new mErosionClosing(); break; case 4: Filter = new mErosionHatTop(); break; case 5: Filter = new mErosionHatBottom(); break; case 6: if (!DA.GetData(1, ref I)) { return; } if (!DA.GetData(2, ref J)) { return; } Filter = new mErosionSkeleton(I, J); break; case 7: if (!DA.GetData(1, ref I)) { return; } if (!DA.GetData(2, ref C)) { return; } Filter = new mStreakHorizontal(I, C); break; case 8: if (!DA.GetData(1, ref I)) { return; } if (!DA.GetData(2, ref C)) { return; } Filter = new mStreakVertical(I, C); break; case 9: if (!DA.GetData(1, ref I)) { return; } if (!DA.GetData(2, ref J)) { return; } if (!DA.GetData(3, ref C)) { return; } Filter = new mErosionFill(I, J, C); break; case 10: if (!DA.GetData(1, ref X)) { return; } if (!DA.GetData(2, ref Y)) { return; } if (!DA.GetData(3, ref C)) { return; } Filter = new mFigureFilter(new wDomain(X.T0, X.T1), new wDomain(Y.T0, Y.T1), C); break; case 11: if (!DA.GetData(1, ref X)) { return; } if (!DA.GetData(2, ref Y)) { return; } if (!DA.GetData(3, ref C)) { return; } if (!DA.GetData(3, ref D)) { return; } Filter = new mFigureUnique(new wDomain(X.T0, X.T1), new wDomain(Y.T0, Y.T1), C, D); break; } Bitmap B = new mApply(A, Filter).ModifiedBitmap; wObject W = new wObject(Filter, "Macaw", Filter.Type); DA.SetData(0, B); DA.SetData(1, W); }