protected override void SolveInstance(IGH_DataAccess DA)
        {
            MeshProps meshProps0 = DA.Fetch <MeshProps>("MeshProp0");

            NGonsCore.Nexorades.Nexors nexors0 = DA.Fetch <NGonsCore.Nexorades.Nexors>("Nexors0");

            MeshProps meshProps1 = DA.Fetch <MeshProps>("MeshProp1");

            NGonsCore.Nexorades.Nexors nexors1 = DA.Fetch <NGonsCore.Nexorades.Nexors>("Nexors1");

            try
            {
                DA.SetDataTree(0, nexors0.Beams2(meshProps0));
                DA.SetDataTree(1, nexors0.Panels(meshProps0));
                nexors0.RoundBeams(meshProps0, 0.06);
                DA.SetDataTree(2, nexors0.GetNexorPipesBreps());
                DA.SetDataTree(3, nexors0.Cuts());
                DA.SetDataTree(4, nexors0.GetCNC_Cuts());


                DA.SetDataTree(5, nexors1.Beams2(meshProps1));
                DA.SetDataTree(6, nexors1.Panels(meshProps1));
                nexors1.RoundBeams(meshProps1, 0.06);
                DA.SetDataTree(7, nexors1.GetNexorPipesBreps());
                DA.SetDataTree(8, nexors1.Cuts());
                DA.SetDataTree(9, nexors1.GetCNC_Cuts());

                DA.SetDataTree(10, nexors0.GetDowels(0.03, 10));
                DA.SetDataTree(11, nexors1.GetDowels(0.03, 10));
            }
            catch (Exception e)
            {
                Rhino.RhinoApp.WriteLine(e.ToString());
            }
        }
Пример #2
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            MeshProps meshProps = DA.Fetch <MeshProps>("MeshProp");
            //GH_Structure<GH_Number> D = DA.FetchTree<GH_Number>("Dist");
            List <double> D = DA.FetchList <double>("Dist");

            try
            {
                double     firstDist = (D.Count > 0) ? D[0] : 0.01;
                double[][] DArray    = new double[][] { new double[1] {
                                                            D[0]
                                                        } };


                if (D.Count > 0)
                {
                    DArray = new double[meshProps.FEFlatten.Length][];
                    for (int i = 0; i < meshProps.FEFlatten.Length; i++)
                    {
                        DArray[i] = new double[meshProps.FEFlatten[i].Length];
                    }

                    for (int i = 0; i < meshProps._FlattenFE.Count; i++)
                    {
                        DArray[meshProps._FlattenFE[i][0]][meshProps._FlattenFE[i][1]] = D[i % D.Count];
                    }
                }


                //Compute translation
                //Create Nexors
                NGonsCore.Nexorades.Nexors nexors = new NGonsCore.Nexorades.Nexors();
                for (int i = 0; i < meshProps.M._countF(); i++)
                {
                    for (int j = 0; j < meshProps.M._countE(i); j++)
                    {
                        nexors.Add(meshProps.EFLines[i][j], i, j);
                        nexors[i, j].translation = DArray[i][j];
                    }
                }



                Line[][] translatedLines = meshProps.NexorTranslateLines(ref nexors, DArray);



                //Output
                DA.SetDataTree(0, nexors.GetNexorLines());
                DA.SetDataTree(1, nexors.GetNexorEccentricities());
                DA.SetData(2, nexors);
                DA.SetData(3, meshProps);
                DA.SetDataTree(4, nexors.GetNexorLines(-1));
            }
            catch (Exception e)
            {
                Rhino.RhinoApp.WriteLine(e.ToString());
            }
        }
Пример #3
0
        public Line[][] NexorTranslateLines(Line[][] EFLines, ref NGonsCore.Nexorades.Nexors nexors, Mesh M, Dictionary <int, int> edgeColors, int[][] FEFlatten, double[][] D_, bool scale = false)
        {
            double[][] D = new double[EFLines.Length][];

            Line[][] EFLinesCopy = new Line[EFLines.Length][];

            for (int i = 0; i < EFLines.Length; i++)
            {
                EFLinesCopy[i] = new Line[EFLines[i].Length];
                for (int j = 0; j < EFLines[i].Length; j++)
                {
                    EFLinesCopy[i][j] = EFLines[i][j];
                }
            }


            D = D_;

            //Translate lines
            for (int i = 0; i < M._countF(); i++)
            {
                Point3d c = M._FCenter(i);

                for (int j = 0; j < FEFlatten[i].Length; j++)
                {
                    Vector3d v0 = EFLinesCopy[i].next(j).Direction.UnitVector();
                    Vector3d v1 = -EFLinesCopy[i].prev(j).Direction.UnitVector();
                    Vector3d v  = (v0 + v1) * 0.5;


                    int id = FEFlatten[i][j];

                    if (edgeColors[id] == 0)
                    {
                        if (scale)
                        {
                            EFLinesCopy[i][j].Transform(Transform.Scale(c, Math.Abs(D[i][j])));
                        }
                        else
                        {
                            EFLinesCopy[i][j].Transform(Transform.Translation(v * D[i][j]));
                        }
                    }
                }
            }


            for (int i = 0; i < M._countF(); i++)
            {
                for (int j = 0; j < M._countE(i); j++)
                {
                    int id = FEFlatten[i][j];

                    int[] op = M._OppositeFE(i, (j), -1);
                    int[] on = M._OppositeFE(i, (j), 1);

                    if (edgeColors[id] == 0)
                    {
                        Line line = EFLinesCopy[i][j];

                        //Next line to interesect
                        int[]    no     = M._OppositeFE(i, (j + 1).Wrap(M._countE(i)));
                        int[]    pairNO = (no[0] != -1) ? new int[] { no[0], no[1] } : new int[] { i, (j + 1).Wrap(EFLinesCopy[i].Length) };
                        Line     lineNO = EFLinesCopy[pairNO[0]][pairNO[1]];
                        double[] tn;
                        Line     cpNext = line.LineLineCP(lineNO, out tn);
                        EFLinesCopy[i][j] = new Line(EFLinesCopy[i][j].From, cpNext.From);


                        //Prev line to intersect
                        int[]    po     = M._OppositeFE(i, (j - 1).Wrap(M._countE(i)));
                        int[]    pairPO = (po[0] != -1) ? new int[] { po[0], po[1] } : new int[] { i, (j - 1).Wrap(EFLinesCopy[i].Length) };
                        Line     linePO = EFLinesCopy[pairPO[0]][pairPO[1]];
                        double[] tp;
                        Line     cpPrev = line.LineLineCP(linePO, out tp);
                        EFLinesCopy[i][j] = new Line(cpPrev.From, EFLinesCopy[i][j].To);



                        //Nexor properties
                        nexors[i, j].line    = EFLinesCopy[i][j];
                        nexors[i, j].isNexor = 1;
                        nexors[pairNO[0], pairNO[1]].isNexor = (M._OppositeFE(pairNO[0], pairNO[1])[0] == -1) ?-1 : 1;  //enable naked edges
                        nexors[pairPO[0], pairPO[1]].isNexor = (M._OppositeFE(pairPO[0], pairPO[1])[0] == -1) ? -1 : 1; //enable naked edges
                        nexors[i, j].AddEcc(FEFlatten[pairNO[0]][pairNO[1]], tn[0], tn[1], cpNext);
                        nexors[i, j].AddEcc(FEFlatten[pairPO[0]][pairPO[1]], tp[0], tp[1], cpPrev);

                        //End nexors
                        nexors[i, j].adjE0 = pairNO;
                        nexors[i, j].adjE1 = pairPO;
                        //Side nexors

                        nexors[i, j].adjE0S = op; //(op[0] == -1)  ? new int[] { i, (j - 1).Wrap(EFLinesCopy[i].Length) } :
                        nexors[i, j].adjE1S = on; //(on[0] == -1) ?  new int[] { i, (j + 1).Wrap(EFLinesCopy[i].Length) } :
                    }
                    else if (op[0] == -1)
                    {
                        nexors[i, j].isNexor = -1;
                        nexors[i, j].adjE0S  = new int[] { i, (j + 1).Wrap(EFLinesCopy[i].Length) };
                        nexors[i, j].adjE1S  = new int[] { i, (j - 1).Wrap(EFLinesCopy[i].Length) };
                    }
                }
            }


            return(EFLinesCopy);
        }
Пример #4
0
 public Line[][] NexorTranslateLines(ref NGonsCore.Nexorades.Nexors nexors, double[][] D_, bool scale = false)
 {
     return(NexorTranslateLines(this.EFLines, ref nexors, this.M, this.edgeColors, this.FEFlatten, D_, scale));
 }