private Point3d GetNextFlowStepOnMesh(Mesh FLOW_MESH, Point3d startPoint, double MOVE_DISTANCE) { double maximumDistance = 0; // TD: setting this as +ve speeds up the search? Vector3d closestNormal; Point3d closestPoint; // Get closest point FLOW_MESH.ClosestPoint(startPoint, out closestPoint, out closestNormal, maximumDistance); // Get the next point following the vector var nextFlowPoint = FlowCalculations.MoveFlowPoint(closestNormal, closestPoint, MOVE_DISTANCE); // Need to snap back to the surface (the vector may be pointing off the edge) return(FLOW_MESH.ClosestPoint(nextFlowPoint)); }
private Point3d GetNextFlowStepOnSurface(Brep FLOW_SURFACE, Point3d startPoint, double MOVE_DISTANCE) { double closestS, closestT; double maximumDistance = 0; // TD: setting this as +ve speeds up the search? Vector3d closestNormal; ComponentIndex closestCI; Point3d closestPoint; // Get closest point FLOW_SURFACE.ClosestPoint(startPoint, out closestPoint, out closestCI, out closestS, out closestT, maximumDistance, out closestNormal); // Get the next point following the vector var nextFlowPoint = FlowCalculations.MoveFlowPoint(closestNormal, closestPoint, MOVE_DISTANCE); // Need to snap back to the surface (the vector may be pointing off the edge) return(FLOW_SURFACE.ClosestPoint(nextFlowPoint)); }
protected override void GroundHogSolveInstance(IGH_DataAccess DA) { // Create holder variables for input parameters var FLOW_SURFACE = default(Surface); var FLOW_ORIGINS = new List <Point3d>(); var FLOW_FIDELITY = 1000.0; // Default Value var FLOW_LIMIT = 0; // Default Value var THREAD = false; // Access and extract data from the input parameters individually DA.GetData(0, ref FLOW_SURFACE); if (!DA.GetDataList(1, FLOW_ORIGINS)) { return; } if (!DA.GetData(2, ref FLOW_FIDELITY)) { return; } if (!DA.GetData(3, ref FLOW_LIMIT)) { return; } if (!DA.GetData(4, ref THREAD)) { return; } // Validation if (FLOW_SURFACE == null) { AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "A null item has been provided as the Surface input; please correct this input."); return; } // TODO: properly cull nulls; they come through as 0,0,0 however if (FLOW_ORIGINS.Count == 0) { AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "No valid points have been provided; perhaps check that you have not provided null or invalid points?"); return; } if (FLOW_FIDELITY == 0) { FLOW_FIDELITY = FlowCalculations.getSensibleFidelity(FLOW_ORIGINS, null, FLOW_SURFACE); } var startPoints = FLOW_ORIGINS.ToArray(); // Array for multithreading var allFlowPathPoints = new List <Point3d> [startPoints.Length]; // Array of all the paths var flowPoints = new List <Point3d>(); var FLOW_BREP = default(Brep); if (FLOW_SURFACE != default(Surface)) { FLOW_BREP = FLOW_SURFACE.ToBrep(); } if (THREAD) { Parallel.For(0, startPoints.Length, i => // Shitty multithreading { allFlowPathPoints[i] = DispatchFlowPoints(FLOW_BREP, startPoints[i], FLOW_FIDELITY, FLOW_LIMIT); } ); } else { for (var i = 0; i < startPoints.Length; i = i + 1) { allFlowPathPoints[i] = DispatchFlowPoints(FLOW_BREP, startPoints[i], FLOW_FIDELITY, FLOW_LIMIT); } } var outputs = FlowCalculations.MakeOutputs(allFlowPathPoints); // Assign variables to output parameters DA.SetDataTree(0, outputs.Item1); DA.SetDataList(1, outputs.Item2); }