public void SetCornerPts(Point3dList newcornerpts) { if (cornerpts != null) { cornerpts.Clear(); } cornerpts = newcornerpts; }
/// <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) { int iterations = 3; List <Point3d> iPoints = new List <Point3d>(); GridVectors = new List <Vector3d>(); roadDensity = 0; List <Curve> outputCurves = new List <Curve>(); pointCloudStructureList = new List <PointCloudStructure>(); DA.GetDataList(0, iPoints); DA.GetDataList(1, GridVectors); DA.GetData(2, ref GridFirstPoint); DA.GetData(3, ref GridLastPoint); DA.GetData(4, ref boundary); DA.GetData(5, ref roadDensity); DA.GetData(6, ref angle); DA.GetData(7, ref iterations); DA.GetData(8, ref step); // step = blockWidth; // roadDensity = step - 10; gridRes = (int)Math.Sqrt(GridVectors.Count) - 1; pointCloud = new Point3dList(); int sign = 1; Vector3d prevTensor = new Vector3d(0, 1, 0); Point3d nextPt = new Point3d(); Vector3d nextTensor = new Vector3d(); List <Point3d> currPointList = new List <Point3d>(); List <Point3d> prevPointList = new List <Point3d>(); for (int i = 0; i < 1; i++) {///////////////////////////////////////////////////// List <Curve> currCurves = new List <Curve>(); for (int j = 0; j < iPoints.Count; j++) // J ======= iPoints { sign = 1; currPointList.Clear(); prevPointList.Clear(); for (int k = 0; k < 2; k++) { prevPointList = new List <Point3d>(currPointList); currPointList.Clear(); // prevTensor = new Vector3d((i + 1) % 2, (i) % 2, 0); prevTensor = new Vector3d(0, 0, 0); if (GetTensor(iPoints[j], prevTensor) != Vector3d.Unset) { nextPt = iPoints[j] + sign * GetTensor(iPoints[j], prevTensor); currPointList.Add(iPoints[j]); prevTensor = GetTensor(iPoints[j], prevTensor); } int f = 0; while (CheckPt(nextPt) && f < 40) { currPointList.Add(nextPt); pointCloudStructureList.Add(new PointCloudStructure(nextPt, currPointList.Count - 1)); nextTensor = GetTensor(currPointList[currPointList.Count - 1], prevTensor); nextPt = currPointList[currPointList.Count - 1] + sign * nextTensor; f++; prevTensor = nextTensor; } if (pointCloud.Count > 0) { Point3d pt = pointCloud[pointCloud.ClosestIndex(nextPt)]; // if ((pt.DistanceTo(nextPt) <= roadDensity) && f > 0) currPointList.Add(pt); } outputCurves.Add(new PolylineCurve(currPointList)); currCurves.Add(new PolylineCurve(currPointList)); sign = -1; } pointCloud.AddRange(currPointList); pointCloud.AddRange(prevPointList); } /* iPoints.Clear(); * * foreach (PolylineCurve curve in currCurves) * { * if (curve != null && curve.GetLength() > 0.1) * { * // if (curve.DivideEquidistant(blockWidth) != null) * // iPoints.AddRange(new List<Point3d>(curve.DivideEquidistant(blockWidth))); * List<Point3d> points = new List<Point3d>(); * for (int q = 0; q < curve.PointCount; q++) * points.Add(curve.Point(q)); * iPoints.AddRange(points); * } * } */ angle += 90; }////////////////////////////////////////////// Point3dList tempList1 = pointCloud; pointCloud.Clear(); for (int i = 0; i < 1; i++) {///////////////////////////////////////////////////// List <Curve> currCurves = new List <Curve>(); for (int j = 0; j < iPoints.Count; j++) // J ======= iPoints { sign = 1; currPointList.Clear(); prevPointList.Clear(); for (int k = 0; k < 2; k++) { prevPointList = new List <Point3d>(currPointList); currPointList.Clear(); // prevTensor = new Vector3d((i + 1) % 2, (i) % 2, 0); prevTensor = new Vector3d(0, 0, 0); if (GetTensor(iPoints[j], prevTensor) != Vector3d.Unset) { nextPt = iPoints[j] + sign * GetTensor(iPoints[j], prevTensor); currPointList.Add(iPoints[j]); prevTensor = GetTensor(iPoints[j], prevTensor); } int f = 0; while (CheckPt(nextPt) && f < 40) { currPointList.Add(nextPt); pointCloudStructureList.Add(new PointCloudStructure(nextPt, currPointList.Count - 1)); nextTensor = GetTensor(currPointList[currPointList.Count - 1], prevTensor); nextPt = currPointList[currPointList.Count - 1] + sign * nextTensor; f++; prevTensor = nextTensor; } if (pointCloud.Count > 0) { Point3d pt = pointCloud[pointCloud.ClosestIndex(nextPt)]; // if ((pt.DistanceTo(nextPt) <= roadDensity) && f > 0) currPointList.Add(pt); } outputCurves.Add(new PolylineCurve(currPointList)); currCurves.Add(new PolylineCurve(currPointList)); sign = -1; } pointCloud.AddRange(currPointList); pointCloud.AddRange(prevPointList); } iPoints.Clear(); foreach (PolylineCurve curve in currCurves) { if (curve != null && curve.GetLength() > 0.1) { // if (curve.DivideEquidistant(blockWidth) != null) // iPoints.AddRange(new List<Point3d>(curve.DivideEquidistant(blockWidth))); List <Point3d> points = new List <Point3d>(); for (int q = 0; q < curve.PointCount; q++) { points.Add(curve.Point(q)); } iPoints.AddRange(points); } } angle += 90; }////////////////////////////////////////////// Point3dList tempList2 = pointCloud; pointCloud.Clear(); pointCloud.AddRange(tempList1); pointCloud.AddRange(tempList2); for (int i = 0; i < 2; i++) {///////////////////////////////////////////////////// List <Curve> currCurves = new List <Curve>(); for (int j = 0; j < iPoints.Count; j++) // J ======= iPoints { sign = 1; currPointList.Clear(); prevPointList.Clear(); for (int k = 0; k < 2; k++) { prevPointList = new List <Point3d>(currPointList); currPointList.Clear(); // prevTensor = new Vector3d((i + 1) % 2, (i) % 2, 0); prevTensor = new Vector3d(0, 0, 0); if (GetTensor(iPoints[j], prevTensor) != Vector3d.Unset) { nextPt = iPoints[j] + sign * GetTensor(iPoints[j], prevTensor); currPointList.Add(iPoints[j]); prevTensor = GetTensor(iPoints[j], prevTensor); } int f = 0; while (CheckPt(nextPt) && f < 40) { currPointList.Add(nextPt); pointCloudStructureList.Add(new PointCloudStructure(nextPt, currPointList.Count - 1)); nextTensor = GetTensor(currPointList[currPointList.Count - 1], prevTensor); nextPt = currPointList[currPointList.Count - 1] + sign * nextTensor; f++; prevTensor = nextTensor; } if (pointCloud.Count > 0) { Point3d pt = pointCloud[pointCloud.ClosestIndex(nextPt)]; // if ((pt.DistanceTo(nextPt) <= roadDensity) && f > 0) currPointList.Add(pt); } outputCurves.Add(new PolylineCurve(currPointList)); currCurves.Add(new PolylineCurve(currPointList)); sign = -1; } // pointCloud.AddRange(currPointList); //pointCloud.AddRange(prevPointList); } iPoints.Clear(); PolylineCurve curve = currCurves[0] as PolylineCurve; //foreach (PolylineCurve curve in currCurves) // { if (curve != null && curve.GetLength() > 0.1) { // if (curve.DivideEquidistant(blockWidth) != null) // iPoints.AddRange(new List<Point3d>(curve.DivideEquidistant(blockWidth))); List <Point3d> points = new List <Point3d>(); for (int q = 0; q < curve.PointCount; q++) { points.Add(curve.Point(q)); } iPoints.AddRange(points); } // } angle += 90; }////////////////////////////////////////////// DA.SetDataList(0, outputCurves); }