/// <summary> /// returns true if the bounding box for the specified polyline /// overlaps with this bounding box /// </summary> /// <param name="pl"></param> /// <returns></returns> public bool BBoxISect(PolyLine3d pl) { /* * function DoBoundingBoxesIntersect(bb1, bb2) { * * //First bounding box, top left corner, bottom right corner * var ATLx = bb1.TopLeftLatLong.Longitude; * var ATLy = bb1.TopLeftLatLong.Latitude; * var ABRx = bb1.BottomRightLatLong.Longitude; * var ABRy = bb1.BottomRightLatLong.Latitude; * * //Second bounding box, top left corner, bottom right corner * var BTLx = bb2.TopLeftLatLong.Longitude; * var BTLy = bb2.TopLeftLatLong.Latitude; * var BBRx = bb2.BottomRightLatLong.Longitude; * var BBRy = bb2.BottomRightLatLong.Latitude; * * var rabx = Math.abs(ATLx + ABRx – BTLx – BBRx); * var raby = Math.abs(ATLy + ABRy – BTLy – BBRy); * * //rAx + rBx * var raxPrbx = ABRx – ATLx + BBRx – BTLx; * * //rAy + rBy * var rayPrby = ATLy – ABRy + BTLy – BBRy; * * if(rabx <= raxPrbx && raby <= rayPrby) * { * return true; * } * return false; * } */ return(false); }
public eCLASSIFICATION Classify2(PolyLine3d test) { int incnt, outcnt; incnt = 0; outcnt = 0; foreach (Point3d pnt in test.m_points) { //iterate through each point if (PointInPolygon(pnt.x, pnt.y)) { incnt++; } else { outcnt++; } } if (incnt == test.m_points.Count) { return(eCLASSIFICATION.eIsContained); } if (outcnt == test.m_points.Count) { return(eCLASSIFICATION.eNone); } return(eCLASSIFICATION.eCrosses); }
public void UpdateBoundingBox() { m_boundingBox = new List <PolyLine3d>(); PolyLine3d face = new PolyLine3d(); face.AddPoint(new Point3d(m_min.x, m_min.y, m_min.z)); face.AddPoint(new Point3d(m_max.x, m_min.y, m_min.z)); face.AddPoint(new Point3d(m_max.x, m_max.y, m_min.z)); face.AddPoint(new Point3d(m_min.x, m_max.y, m_min.z)); face.AddPoint(new Point3d(m_min.x, m_min.y, m_min.z)); m_boundingBox.Add(face); face = new PolyLine3d(); face.AddPoint(new Point3d(m_min.x, m_min.y, m_max.z)); face.AddPoint(new Point3d(m_max.x, m_min.y, m_max.z)); face.AddPoint(new Point3d(m_max.x, m_max.y, m_max.z)); face.AddPoint(new Point3d(m_min.x, m_max.y, m_max.z)); face.AddPoint(new Point3d(m_min.x, m_min.y, m_max.z)); m_boundingBox.Add(face); face = new PolyLine3d(); face.AddPoint(new Point3d(m_min.x, m_min.y, m_min.z)); face.AddPoint(new Point3d(m_min.x, m_min.y, m_max.z)); m_boundingBox.Add(face); face = new PolyLine3d(); face.AddPoint(new Point3d(m_max.x, m_min.y, m_min.z)); face.AddPoint(new Point3d(m_max.x, m_min.y, m_max.z)); m_boundingBox.Add(face); face = new PolyLine3d(); face.AddPoint(new Point3d(m_max.x, m_max.y, m_min.z)); face.AddPoint(new Point3d(m_max.x, m_max.y, m_max.z)); m_boundingBox.Add(face); face = new PolyLine3d(); face.AddPoint(new Point3d(m_min.x, m_max.y, m_min.z)); face.AddPoint(new Point3d(m_min.x, m_max.y, m_max.z)); m_boundingBox.Add(face); }
public PolyLine3d(PolyLine3d src) { m_color = src.m_color; minx = src.minx; miny = src.miny; minz = src.minz; maxx = src.maxx; maxy = src.maxy; maxz = src.maxz; linewidth = 1; visible = true; m_points = new List<Point3d>(); foreach (Point3d pnt in src.m_points) { Point3d p = new Point3d(pnt.x, pnt.y, pnt.z); m_points.Add(p); } }
public PolyLine3d(PolyLine3d src) { tag = 0; m_color = src.m_color; m_derived = src.m_derived; minx = src.minx; miny = src.miny; minz = src.minz; maxx = src.maxx; maxy = src.maxy; maxz = src.maxz; linewidth = 1; visible = true; m_points = new List <Point3d>(); foreach (Point3d pnt in src.m_points) { Point3d p = new Point3d(pnt.x, pnt.y, pnt.z); m_points.Add(p); } }
/// <summary> /// Split this long polyline into a list of shorter segments /// </summary> /// <returns></returns> public List <PolyLine3d> Split() { List <PolyLine3d> segments = new List <PolyLine3d>(); try { for (int c = 0; c < m_points.Count - 1; c++) { PolyLine3d ply = new PolyLine3d(); ply.m_points.Add(m_points[c]); ply.m_points.Add(m_points[c + 1]); segments.Add(ply); } } catch (Exception ex) { DebugLogger.Instance().LogError(ex.Message); } return(segments); }
/// <summary> /// This function returns a classification to see if this polyline /// contains wholly the 'test' polyline, /// is contained by the 'test' polyline, /// crosses the 'test' polyline, /// or does not intersect the contained polyline /// </summary> /// <param name="test"></param> /// <returns></returns> public eCLASSIFICATION Classify(PolyLine3d test) { // as a first pass, we're going to simply check bounding boxes //CalcBBox(); //test.CalcBBox(); bool p1, p2, p3, p4; bool t1, t2, t3, t4; t1 = BBOXContains(test.minx, test.miny); t2 = BBOXContains(test.minx, test.maxy); t3 = BBOXContains(test.maxx, test.miny); t4 = BBOXContains(test.maxx, test.maxy); //check to see if this contains all 4 points of test OR if (t1 && t2 && t3 && t4) { return(eCLASSIFICATION.eContaining); } // check to see if test contains all points of this p1 = test.BBOXContains(minx, miny); p2 = test.BBOXContains(minx, maxy); p3 = test.BBOXContains(maxx, miny); p4 = test.BBOXContains(maxx, maxy); if (p1 && p2 && p3 && p4) { return(eCLASSIFICATION.eIsContained); } //no overlap between any points - disjoint if ((t1 == false && t2 == false && t3 == false && t4 == false) && (p1 == false && p2 == false && p3 == false && p4 == false)) { return(eCLASSIFICATION.eNone); } //otherwise, we must be crossing somehow. return(eCLASSIFICATION.eCrosses); }
/// <summary> /// returns true if the bounding box for the specified polyline /// overlaps with this bounding box /// </summary> /// <param name="pl"></param> /// <returns></returns> public bool BBoxISect(PolyLine3d pl) { /* function DoBoundingBoxesIntersect(bb1, bb2) { //First bounding box, top left corner, bottom right corner var ATLx = bb1.TopLeftLatLong.Longitude; var ATLy = bb1.TopLeftLatLong.Latitude; var ABRx = bb1.BottomRightLatLong.Longitude; var ABRy = bb1.BottomRightLatLong.Latitude; //Second bounding box, top left corner, bottom right corner var BTLx = bb2.TopLeftLatLong.Longitude; var BTLy = bb2.TopLeftLatLong.Latitude; var BBRx = bb2.BottomRightLatLong.Longitude; var BBRy = bb2.BottomRightLatLong.Latitude; var rabx = Math.abs(ATLx + ABRx – BTLx – BBRx); var raby = Math.abs(ATLy + ABRy – BTLy – BBRy); //rAx + rBx var raxPrbx = ABRx – ATLx + BBRx – BTLx; //rAy + rBy var rayPrby = ATLy – ABRy + BTLy – BBRy; if(rabx <= raxPrbx && raby <= rayPrby) { return true; } return false; } */ return false; }
public UnsupportedRegions(PolyLine3d p) { ply = p; }
public void AddLine(PolyLine3d ply) { m_lines.Add(ply); }
public void SetParent(PolyLine3d parent) { m_parent = parent; p1.m_parent = parent; p2.m_parent = parent; }
public PolyLine3d IntersectZPlane(double zcur) { try { PolyLine3d segment = new PolyLine3d(); //Intersect the polygon with the specified Z-Plane // this will return 0,1,2 intersections. // using the returns, impose several rules //iterate through the poly vertices // to create 3d line segments // foreach (Point3d p3d in m_points) // { //use a polyline to do the intersections //Since there are only 3d points, this is easier than a loop PolyLine3d lineseg1 = new PolyLine3d(); PolyLine3d lineseg2 = new PolyLine3d(); PolyLine3d lineseg3 = new PolyLine3d(); lineseg1.AddPoint(m_points[0]); // 0-1 lineseg1.AddPoint(m_points[1]); lineseg2.AddPoint(m_points[1]); // 1-2 lineseg2.AddPoint(m_points[2]); lineseg3.AddPoint(m_points[2]); // 2-0 lineseg3.AddPoint(m_points[0]); Point3d p1, p2, p3; // intersection points for the 3 3d line segments p1 = lineseg1.IntersectZ(zcur); p2 = lineseg2.IntersectZ(zcur); p3 = lineseg3.IntersectZ(zcur); int count = 0; Point3d []lst = new Point3d[3]; if (p1 != null) lst[count++] = p1; if (p2 != null) lst[count++] = p2; if (p3 != null) lst[count++] = p3; if (count == 3) { //co-planer return null; } if (count != 2) return null; segment.AddPoint(lst[0]); segment.AddPoint(lst[1]); segment.m_color = Color.Red; return segment; } catch (Exception) { return null; } }
public PolyLine3d IntersectZPlane(float zcur) { try { PolyLine3d segment = new PolyLine3d(); //Intersect the polygon with the specified Z-Plane // this will return 0,1,2 intersections. // using the returns, impose several rules //use a polyline to do the intersections Point3d p1, p2, p3; // intersection points for the 3 3d line segments int count = 0; Point3d[] lst = new Point3d[3]; PolyLine3d lineseg1 = null; PolyLine3d lineseg2 = null; PolyLine3d lineseg3 = null; lineseg1 = new PolyLine3d(); lineseg1.AddPoint(m_points[0]); // 0-1 lineseg1.AddPoint(m_points[1]); p1 = lineseg1.IntersectZ(zcur); if (p1 != null) { count++; segment.AddPoint(p1); } lineseg2 = new PolyLine3d(); lineseg2.AddPoint(m_points[1]); // 1-2 lineseg2.AddPoint(m_points[2]); p2 = lineseg2.IntersectZ(zcur); if (p2 != null) { count++; segment.AddPoint(p2); } if (count == 0) return null; // there is no sense in doing the 3rd intersection if we don't have // at least 1 point at this stage lineseg3 = new PolyLine3d(); lineseg3.AddPoint(m_points[2]); // 2-0 lineseg3.AddPoint(m_points[0]); p3 = lineseg3.IntersectZ(zcur); if (p3 != null) { count++; segment.AddPoint(p3); } if (count != 2) // might be 0,1 or 3 return null; segment.m_color = Color.Red; return segment; } catch (Exception) { return null; } }
public PolyLine3d IntersectZPlane(double zcur) { try { PolyLine3d segment = new PolyLine3d(); //Intersect the polygon with the specified Z-Plane // this will return 0,1,2 intersections. // using the returns, impose several rules //use a polyline to do the intersections Point3d p1, p2, p3; // intersection points for the 3 3d line segments int count = 0; Point3d[] lst = new Point3d[3]; if (lineseg1 == null) { lineseg1 = new PolyLine3d(); lineseg1.AddPoint(m_points[0]); // 0-1 lineseg1.AddPoint(m_points[1]); } p1 = lineseg1.IntersectZ(zcur); if (p1 != null) { count++; segment.AddPoint(p1); } if (lineseg2 == null) { lineseg2 = new PolyLine3d(); lineseg2.AddPoint(m_points[1]); // 1-2 lineseg2.AddPoint(m_points[2]); } p2 = lineseg2.IntersectZ(zcur); if (p2 != null) { count++; segment.AddPoint(p2); } if (count == 0) { return(null); } // there is no sense in doing the 3rd intersection if we don't have // at least 1 point at this stage if (lineseg3 == null) { lineseg3 = new PolyLine3d(); lineseg3.AddPoint(m_points[2]); // 2-0 lineseg3.AddPoint(m_points[0]); } p3 = lineseg3.IntersectZ(zcur); if (p3 != null) { count++; segment.AddPoint(p3); } if (count != 2) // might be 0,1 or 3 { return(null); } segment.m_color = Color.Red; return(segment); } catch (Exception) { return(null); } }
/// <summary> /// Split this long polyline into a list of shorter segments /// </summary> /// <returns></returns> public List<PolyLine3d> Split() { List<PolyLine3d> segments = new List<PolyLine3d>(); try { for (int c = 0; c < m_points.Count - 1; c++) { PolyLine3d ply = new PolyLine3d(); ply.m_plyderived = this; // make all these children of the main ply.m_points.Add(m_points[c]); ply.m_points.Add(m_points[c + 1]); segments.Add(ply); } } catch (Exception ex) { DebugLogger.Instance().LogError(ex.Message); } return segments; }
public void UpdateBoundingBox() { m_boundingBox = new List<PolyLine3d>(); PolyLine3d face = new PolyLine3d(); face.AddPoint(new Point3d(m_min.x, m_min.y, m_min.z)); face.AddPoint(new Point3d(m_max.x, m_min.y, m_min.z)); face.AddPoint(new Point3d(m_max.x, m_max.y, m_min.z)); face.AddPoint(new Point3d(m_min.x, m_max.y, m_min.z)); face.AddPoint(new Point3d(m_min.x, m_min.y, m_min.z)); m_boundingBox.Add(face); face = new PolyLine3d(); face.AddPoint(new Point3d(m_min.x, m_min.y, m_max.z)); face.AddPoint(new Point3d(m_max.x, m_min.y, m_max.z)); face.AddPoint(new Point3d(m_max.x, m_max.y, m_max.z)); face.AddPoint(new Point3d(m_min.x, m_max.y, m_max.z)); face.AddPoint(new Point3d(m_min.x, m_min.y, m_max.z)); m_boundingBox.Add(face); face = new PolyLine3d(); face.AddPoint(new Point3d(m_min.x, m_min.y, m_min.z)); face.AddPoint(new Point3d(m_min.x, m_min.y, m_max.z)); m_boundingBox.Add(face); face = new PolyLine3d(); face.AddPoint(new Point3d(m_max.x, m_min.y, m_min.z)); face.AddPoint(new Point3d(m_max.x, m_min.y, m_max.z)); m_boundingBox.Add(face); face = new PolyLine3d(); face.AddPoint(new Point3d(m_max.x, m_max.y, m_min.z)); face.AddPoint(new Point3d(m_max.x, m_max.y, m_max.z)); m_boundingBox.Add(face); face = new PolyLine3d(); face.AddPoint(new Point3d(m_min.x, m_max.y, m_min.z)); face.AddPoint(new Point3d(m_min.x, m_max.y, m_max.z)); m_boundingBox.Add(face); }
public void ClearCached() { lineseg1 = null; lineseg2 = null; lineseg3 = null; }
public bool Load(StreamReader sr) { try { int numplys = int.Parse(sr.ReadLine()); for (int c = 0; c < numplys; c++) { PolyLine3d pl = new PolyLine3d(); pl.Load(sr); m_segments.Add(pl); } return true; } catch (Exception ) { return false; } }
public PolyLine3d IntersectZPlane(double zcur) { try { PolyLine3d segment = new PolyLine3d(); //Intersect the polygon with the specified Z-Plane // this will return 0,1,2 intersections. // using the returns, impose several rules //iterate through the poly vertices // to create 3d line segments // foreach (Point3d p3d in m_points) // { //use a polyline to do the intersections //Since there are only 3d points, this is easier than a loop PolyLine3d lineseg1 = new PolyLine3d(); PolyLine3d lineseg2 = new PolyLine3d(); PolyLine3d lineseg3 = new PolyLine3d(); lineseg1.AddPoint(m_points[0]); // 0-1 lineseg1.AddPoint(m_points[1]); lineseg2.AddPoint(m_points[1]); // 1-2 lineseg2.AddPoint(m_points[2]); lineseg3.AddPoint(m_points[2]); // 2-0 lineseg3.AddPoint(m_points[0]); Point3d p1, p2, p3; // intersection points for the 3 3d line segments p1 = lineseg1.IntersectZ(zcur); p2 = lineseg2.IntersectZ(zcur); p3 = lineseg3.IntersectZ(zcur); int count = 0; Point3d [] lst = new Point3d[3]; if (p1 != null) { lst[count++] = p1; } if (p2 != null) { lst[count++] = p2; } if (p3 != null) { lst[count++] = p3; } if (count == 3) { //co-planer return(null); } if (count != 2) { return(null); } segment.AddPoint(lst[0]); segment.AddPoint(lst[1]); segment.m_color = Color.Red; return(segment); } catch (Exception) { return(null); } }