/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object can be used to retrieve data from input parameters and /// to store data in output parameters.</param> protected override void SolveInstance(IGH_DataAccess DA) { IntPtr topoData = IntPtr.Zero; List <Curve> parts = new List <Curve>(); List <Curve> boundaries = new List <Curve>(); if (!DA.GetData(0, ref topoData)) { return; } if (!DA.GetDataList(1, parts)) { return; } DA.GetDataList(2, boundaries); CPolyLines polyLines = new CPolyLines(); TopoCreator.RhinoPolylinesToCPolyline(parts, boundaries, ref polyLines, true); if (boundaries.Count == 0) { TopoCreator.setCrossMesh(ref polyLines, topoData, false); } else { TopoCreator.setCrossMesh(ref polyLines, topoData, true); } Marshal.FreeHGlobal(polyLines.atBoundary); Marshal.FreeHGlobal(polyLines.points); Marshal.FreeHGlobal(polyLines.sta_ends); DA.SetData(0, topoData); return; }
/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object can be used to retrieve data from input parameters and /// to store data in output parameters.</param> protected override void SolveInstance(IGH_DataAccess DA) { IntPtr topoData = IntPtr.Zero; Mesh refMesh = new Mesh(); if (!DA.GetData(0, ref topoData)) { return; } if (!DA.GetData(1, ref refMesh)) { return; } CMesh crefMesh = new CMesh(); String errorMessage = ""; if (TopoCreator.RhinoMeshToCMesh(refMesh, ref crefMesh, true, out errorMessage)) { TopoCreator.setReferenceSurface(ref crefMesh, topoData); } else { AddRuntimeMessage(GH_RuntimeMessageLevel.Error, errorMessage); return; } Marshal.FreeHGlobal(crefMesh.points); Marshal.FreeHGlobal(crefMesh.faces); DA.SetData(0, topoData); }
/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object can be used to retrieve data from input parameters and /// to store data in output parameters.</param> protected override void SolveInstance(IGH_DataAccess DA) { List <Mesh> parts = new List <Mesh>(); List <Mesh> brdies = new List <Mesh>(); if (!DA.GetDataList(0, parts)) { return; } DA.GetDataList(1, brdies); IntPtr graphData = TopoCreator.initContactGraph(); for (int kd = 0; kd < parts.Count; kd++) { var mesh = parts[kd]; addToContactGraph(mesh, false, graphData); } for (int kd = 0; kd < brdies.Count; kd++) { var mesh = brdies[kd]; addToContactGraph(mesh, true, graphData); } Rhino.Geometry.Mesh rhmesh = new Rhino.Geometry.Mesh(); TopoCreator.getContactMesh(rhmesh, graphData); DA.SetData(0, rhmesh); TopoCreator.deleteContactGraph(graphData); return; }
/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object can be used to retrieve data from input parameters and /// to store data in output parameters.</param> protected override void SolveInstance(IGH_DataAccess DA) { IntPtr topoData = IntPtr.Zero; List <Curve> pattern = new List <Curve>(); List <Curve> empty = new List <Curve>(); if (!DA.GetData(0, ref topoData)) { return; } if (!DA.GetDataList(1, pattern)) { return; } CPolyLines polylines = new CPolyLines(); TopoCreator.RhinoPolylinesToCPolyline(pattern, empty, ref polylines, false); TopoCreator.setPattern(ref polylines, topoData); Marshal.FreeHGlobal(polylines.atBoundary); Marshal.FreeHGlobal(polylines.points); Marshal.FreeHGlobal(polylines.sta_ends); DA.SetData(0, topoData); }
/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object can be used to retrieve data from input parameters and /// to store data in output parameters.</param> protected override void SolveInstance(IGH_DataAccess DA) { IntPtr topoData = IntPtr.Zero; if (!DA.GetData(0, ref topoData)) { return; } List <Polyline> polylines = new List <Polyline>(); IntPtr textureMesh = TopoCreator.initTextureMeshPtr(topoData); TopoCreator.getPolyLines(polylines, textureMesh, false); TopoCreator.deletePolyLineRhino(textureMesh); DA.SetDataList(0, polylines); }
/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object can be used to retrieve data from input parameters and /// to store data in output parameters.</param> protected override void SolveInstance(IGH_DataAccess DA) { bool resetCommand = false; DA.GetData(0, ref resetCommand); if (resetCommand) { if (topoData != IntPtr.Zero) { TopoCreator.deleteStructure(topoData); } topoData = TopoCreator.initStructure(); } DA.SetData(0, topoData); }
private void addToContactGraph(Mesh mesh, bool atBoundary, IntPtr graphData) { CMesh cmesh = new CMesh(); String errorMessage; if (TopoCreator.RhinoMeshToCMesh(mesh, ref cmesh, false, out errorMessage)) { TopoCreator.addMeshesToContactGraph(graphData, ref cmesh, atBoundary); } else { AddRuntimeMessage(GH_RuntimeMessageLevel.Error, errorMessage); return; } Marshal.FreeHGlobal(cmesh.points); Marshal.FreeHGlobal(cmesh.faces); }
/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object can be used to retrieve data from input parameters and /// to store data in output parameters.</param> protected override void SolveInstance(IGH_DataAccess DA) { IntPtr topoData = IntPtr.Zero; bool preview_mode = false; if (!DA.GetData(0, ref topoData)) { return; } if (!DA.GetData(1, ref preview_mode)) { return; } int n_part = TopoCreator.partNumber(topoData); if (preview_mode) { TopoCreator.preview(topoData); } else { TopoCreator.refresh(topoData); } List <Mesh> parts = new List <Mesh>(); List <Mesh> boundary = new List <Mesh>(); for (int partID = 0; partID < n_part; partID++) { Rhino.Geometry.Mesh mesh = new Rhino.Geometry.Mesh(); TopoCreator.getPartMesh(partID, mesh, topoData); if (TopoCreator.isBoundary(partID, topoData) == 1) { boundary.Add(mesh); } else { parts.Add(mesh); } } DA.SetDataList(0, parts); DA.SetDataList(1, boundary); }
/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object can be used to retrieve data from input parameters and /// to store data in output parameters.</param> protected override void SolveInstance(IGH_DataAccess DA) { List <Mesh> parts = new List <Mesh>(); List <Mesh> brdies = new List <Mesh>(); bool runProgram = false; if (!DA.GetDataList(0, parts)) { return; } if (!DA.GetDataList(1, brdies)) { return; } if (!DA.GetData(2, ref runProgram)) { return; } if (runProgram) { IntPtr graphData = TopoCreator.initContactGraph(); for (int kd = 0; kd < parts.Count; kd++) { var mesh = parts[kd]; addToContactGraph(mesh, false, graphData); } for (int kd = 0; kd < brdies.Count; kd++) { var mesh = brdies[kd]; addToContactGraph(mesh, true, graphData); } result = (TopoCreator.testInterlocking(graphData) == 1); DA.SetData(0, result); TopoCreator.deleteContactGraph(graphData); } DA.SetData(0, result); return; }
/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object can be used to retrieve data from input parameters and /// to store data in output parameters.</param> protected override void SolveInstance(IGH_DataAccess DA) { String xml_file = ""; IntPtr topoData = IntPtr.Zero; bool runProgram = false; if (!DA.GetData(0, ref topoData)) { return; } if (!DA.GetData(1, ref xml_file)) { return; } if (!DA.GetData(2, ref runProgram)) { return; } if (runProgram) { TopoCreator.writeXML(topoData, xml_file); } }
/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object can be used to retrieve data from input parameters and /// to store data in output parameters.</param> protected override void SolveInstance(IGH_DataAccess DA) { String xml_file = ""; // Then we need to access the input parameters individually. // When data cannot be extracted from a parameter, we should abort this method. if (!DA.GetData(0, ref xml_file)) { return; } // We should now validate the data and warn the user if invalid data is supplied. if (Path.GetExtension(xml_file.ToString()) != ".xml") { AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Input File must be xml file"); return; } //if (tilt_angle < 0 || tilt_angle > 90) //{ // AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Invalid Tilt Angle"); // return; //} if (xmlPath != xml_file || xmlPath == "") { if (topoData != IntPtr.Zero) { TopoCreator.deleteStructure(topoData); } topoData = TopoCreator.readXML(xml_file); xmlPath = xml_file; } DA.SetData(0, topoData); }
/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object can be used to retrieve data from input parameters and /// to store data in output parameters.</param> protected override void SolveInstance(IGH_DataAccess DA) { IntPtr topoData = IntPtr.Zero; string name = ""; if (!DA.GetData(0, ref topoData)) { return; } if (!DA.GetData(1, ref name)) { return; } if (name == "tiltAngle") { double tilt_angle = 0; if (!DA.GetData(2, ref tilt_angle)) { return; } if (tilt_angle < 0 || tilt_angle > 90) { AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Invalid Tilt Angle"); return; } TopoCreator.setParaDouble(name, tilt_angle, topoData); } else if (name == "cutUpper" || name == "cutLower") { double cut_height = 0; if (!DA.GetData(2, ref cut_height)) { return; } if (cut_height < 0 || cut_height > 0.2) { AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Invalid " + name); return; } TopoCreator.setParaDouble(name, cut_height, topoData); } else if (name == "patternID") { double type = 0; if (!DA.GetData(2, ref type)) { return; } if (type < 0 || type > 15) { AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Invalid " + name); return; } TopoCreator.setParaInt(name, (int)type, topoData); } else if (name == "patternAngle") { double angle = 0; if (!DA.GetData(2, ref angle)) { return; } if (angle < -180 || angle > 180) { AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Invalid " + name); return; } TopoCreator.setPatternAngle(angle, topoData); } else if (name == "patternXY") { Rhino.Geometry.Vector3d pos = new Rhino.Geometry.Vector3d(); if (!DA.GetData(2, ref pos)) { return; } TopoCreator.setPatternXY(pos.X, pos.Y, topoData); } else if (name == "patternScale") { double scale = 0; if (!DA.GetData(2, ref scale)) { return; } if (scale < 0 || scale > 5) { AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Invalid " + name); return; } TopoCreator.setPatternScale(scale, topoData); } DA.SetData(0, topoData); }