Пример #1
0
 /// <summary>
 /// Creates a Rhino Vector3f from a Plankton vector.
 /// </summary>
 /// <param name="vector">A Plankton vector.</param>
 /// <returns>A Vector3f with the same XYZ components as the vector.</returns>
 public static Vector3f ToVector3f(this PlanktonXYZ vector)
 {
     return(new Vector3f(vector.X, vector.Y, vector.Z));
 }
Пример #2
0
 /// <summary>
 /// Creates a Rhino Point3f from a Plankton vector.
 /// </summary>
 /// <param name="vector">A Plankton vector.</param>
 /// <returns>A Point3f with the same XYZ components as the vector.</returns>
 public static Point3f ToPoint3f(this PlanktonXYZ vector)
 {
     return(new Point3f(vector.X, vector.Y, vector.Z));
 }
Пример #3
0
 public static Point3d ToPoint3d(this PlanktonXYZ pPt)
 {
     return(new Point3d(pPt.X, pPt.Y, pPt.Z));
 }
Пример #4
0
 public static Vector3 ToUnity(this PlanktonXYZ v)
 {
     return(new Vector3(v.X, v.Y, v.Z));
 }
Пример #5
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            GH_Structure <IGH_GeometricGoo> iMeshTree = new GH_Structure <IGH_GeometricGoo>();

            DA.GetDataTree <IGH_GeometricGoo>(0, out iMeshTree);

            GH_Structure <IGH_Goo>    oFaceCentersTree   = new GH_Structure <IGH_Goo>();
            GH_Structure <IGH_Goo>    oFaceBoundarysTree = new GH_Structure <IGH_Goo>();
            GH_Structure <IGH_Goo>    oNakedFacesTree    = new GH_Structure <IGH_Goo>();
            GH_Structure <GH_Integer> oNakedIndicesTree  = new GH_Structure <GH_Integer>();
            GH_Structure <IGH_Goo>    oClosedFacesTree   = new GH_Structure <IGH_Goo>();
            GH_Structure <GH_Integer> oClosedIndicesTree = new GH_Structure <GH_Integer>();


            for (int i = 0; i < iMeshTree.PathCount; i++)
            {
                GH_Path path = iMeshTree.get_Path(i);

                for (int j = 0; j < iMeshTree.Branches[i].Count; j++)
                {
                    Mesh mesh;
                    if (!iMeshTree.Branches[i][j].CastTo <Mesh>(out mesh))
                    {
                        continue;
                    }
                    else
                    {
                        PlanktonMesh pMesh = mesh.ToPlanktonMesh();

                        for (int f = 0; f < pMesh.Faces.Count; f++)
                        {
                            // get face centers
                            PlanktonXYZ center = pMesh.Faces.GetFaceCenter(f);
                            oFaceCentersTree.Append(GH_Convert.ToGeometricGoo(center.ToPoint3d()), path);
                        }

                        // get face boundarys
                        Polyline[] boundaryCurves = pMesh.ToPolylines();

                        for (int p = 0; p < boundaryCurves.Length; p++)
                        {
                            oFaceBoundarysTree.Append(GH_Convert.ToGeometricGoo(boundaryCurves[p]), path);
                            if (pMesh.Faces.NakedEdgeCount(p) > 0)
                            {
                                oNakedFacesTree.Append(GH_Convert.ToGeometricGoo(boundaryCurves[p]), path);
                                oNakedIndicesTree.Append(new GH_Integer(p), path);
                            }
                            else
                            {
                                oClosedFacesTree.Append(GH_Convert.ToGeometricGoo(boundaryCurves[p]), path);
                                oClosedIndicesTree.Append(new GH_Integer(p), path);
                            }
                        }

                        //for (int e = 0; e < pMesh.Halfedges.Count; e++)
                        //{
                        //    if (pMesh.Halfedges.GetPairHalfedge(e) > e) continue;

                        //    int[] vts = pMesh.Halfedges.GetVertices(e);
                        //    oEdgesTree.Append(
                        //        GH_Convert.ToGeometricGoo(new LineCurve(
                        //            pMesh.Vertices[vts[0]].ToPoint3d(),
                        //            pMesh.Vertices[vts[1]].ToPoint3d())), path);

                        //    if (pMesh.Halfedges.IsBoundary(e))
                        //    {
                        //        oNakedEdgesTree.Append(
                        //            GH_Convert.ToGeometricGoo(new LineCurve(
                        //            pMesh.Vertices[vts[0]].ToPoint3d(),
                        //            pMesh.Vertices[vts[1]].ToPoint3d())), path);

                        //        oNakedIndicesTree.Append(new GH_Integer(e / 2), path);
                        //    }
                        //    else
                        //    {
                        //        oClosedEdgesTree.Append(
                        //            GH_Convert.ToGeometricGoo(new LineCurve(
                        //            pMesh.Vertices[vts[0]].ToPoint3d(),
                        //            pMesh.Vertices[vts[1]].ToPoint3d())), path);

                        //        oClosedIndicesTree.Append(new GH_Integer(e / 2), path);
                        //    }
                        //}
                    }
                }
            }

            DA.SetDataTree(0, oFaceCentersTree);
            DA.SetDataTree(1, oFaceBoundarysTree);
            DA.SetDataTree(2, oNakedFacesTree);
            DA.SetDataTree(3, oNakedIndicesTree);
            DA.SetDataTree(4, oClosedFacesTree);
            DA.SetDataTree(5, oClosedIndicesTree);

            //DA.GetData<Mesh>("Mesh", ref iMesh);

            //pMesh = iMesh.ToPlanktonMesh();

            //for (int i = 0; i < pMesh.Faces.Count; i++)
            //{
            //    // get face centers
            //    PlanktonXYZ center = pMesh.Faces.GetFaceCenter(i);
            //    oFaceCenters.Add(center.ToPoint3d());

            //}

            //// get face boundarys
            //Polyline[] boundaryCurves = pMesh.ToPolylines();

            //for (int p = 0; p < boundaryCurves.Length; p++)
            //{
            //    oFaceBoundarys.Add(boundaryCurves[p]);
            //    if (pMesh.Faces.NakedEdgeCount(p) > 0)
            //        oNakedFaces.Add(boundaryCurves[p]);
            //    else
            //        oClosedFaces.Add(boundaryCurves[p]);
            //}


            //DA.SetDataList("Face Centers", oFaceCenters);
            //DA.SetDataList("Face Boundary Curves", oFaceBoundarys);
            //DA.SetDataList("Face Naked", oNakedFaces);
            //DA.SetDataList("Face Closed", oClosedFaces);
        }