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 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); } }
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 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(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); } }