private Topologic.Wire ByPolyCurve(PolyCurve ghPolyCurve) { Curve[] ghCurves = ghPolyCurve.Explode(); List <Topologic.Edge> edges = new List <Topologic.Edge>(); foreach (Curve ghCurve in ghCurves) { Topologic.Topology topology = ByCurve(ghCurve); Topologic.Edge edge = topology as Topologic.Edge; if (edge != null) { edges.Add(edge); continue; } Topologic.Wire wire = topology as Topologic.Wire; if (wire != null) { edges.AddRange(wire.Edges); continue; } } return(Topologic.Wire.ByEdges(edges)); }
/// <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 a variable for the input String Topologic.Topology topology = null; double tolerance = 0.0001; // Use the DA object to retrieve the data inside the first input parameter. // If the retieval fails (for example if there is no data) we need to abort. if (!DA.GetData(0, ref topology)) { return; } if (!DA.GetData(1, ref tolerance)) { return; } // If the retrieved data is Nothing, we need to abort. // We're also going to abort on a zero-length String. if (topology == null) { return; } List <Object> geometries = ToGeometry(topology, tolerance); DA.SetDataList(0, geometries); }
/// <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) { Object ghGeometryBase = null; double tolerance = 0.0001; if (!DA.GetData(0, ref ghGeometryBase)) { return; } if (!DA.GetData(1, ref tolerance)) { return; } if (ghGeometryBase == null) { return; } Type type = ghGeometryBase.GetType(); Topologic.Topology topology = null; GH_Point ghPoint = ghGeometryBase as GH_Point; if (ghPoint != null) { topology = ByPoint(ghPoint.Value); DA.SetData(0, topology); return; } GH_Line ghLine = ghGeometryBase as GH_Line; if (ghLine != null) { topology = ByLine(ghLine.Value); DA.SetData(0, topology); return; } GH_Curve ghCurve = ghGeometryBase as GH_Curve; if (ghCurve != null) { topology = ByCurve(ghCurve.Value); DA.SetData(0, topology); return; } GH_Surface ghSurface = ghGeometryBase as GH_Surface; if (ghSurface != null) { //topology = ByBrep(ghSurface.Value.Faces[0].ToBrep(), tolerance); //topology = ByBrepFace(ghSurface.Value.Faces[0]); topology = ByBrep(ghSurface.Value, tolerance); DA.SetData(0, topology); return; } GH_Brep ghBrep = ghGeometryBase as GH_Brep; if (ghBrep != null) { topology = ByBrep(ghBrep.Value, tolerance); DA.SetData(0, topology); return; } GH_Box ghBox = ghGeometryBase as GH_Box; if (ghBox != null) { topology = ByBox(ghBox.Value); DA.SetData(0, topology); return; } GH_Mesh ghMesh = ghGeometryBase as GH_Mesh; if (ghMesh != null) { topology = ByMesh(ghMesh.Value); DA.SetData(0, topology); return; } //BrepLoop ghBrepLoop = ghGeometryBase as BrepLoop; //if (ghBrepLoop != null) //{ // topology = ByBrepLoop(ghBrepLoop); // DA.SetData(0, topology); // return; //} throw new Exception("This type of geometry is not yet supported."); }