/* * This function calculates the min and max x/y coordinates of this slice */ public MinMax_XY CalcMinMax_XY(ArrayList lines2d) { Line2d l1 = (Line2d)lines2d[0]; MinMax_XY mm = new MinMax_XY(); //start the min / max off with some valid values mm.xmin = mm.xmax = l1.p1.x; mm.ymin = mm.ymax = l1.p1.y; foreach (Line2d ln in lines2d) { if (ln.p1.x < mm.xmin) { mm.xmin = ln.p1.x; } if (ln.p2.x < mm.xmin) { mm.xmin = ln.p2.x; } if (ln.p1.x > mm.xmax) { mm.xmax = ln.p1.x; } if (ln.p2.x > mm.xmax) { mm.xmax = ln.p2.x; } if (ln.p1.y < mm.ymin) { mm.ymin = ln.p1.y; } if (ln.p2.y < mm.ymin) { mm.ymin = ln.p2.y; } if (ln.p1.y > mm.ymax) { mm.ymax = ln.p1.y; } if (ln.p2.y > mm.ymax) { mm.ymax = ln.p2.y; } } return(mm); }
// this function converts all the 3d polyines to 2d lines so we can process everything private ArrayList Get2dLines(SliceBuildConfig sp) { ArrayList lst = new ArrayList(); foreach (PolyLine3d ply in m_segments) { Line2d ln = new Line2d(); //get the 3d points of the line Point3d p3d1 = (Point3d)ply.m_points[0]; Point3d p3d2 = (Point3d)ply.m_points[1]; //convert them to 2d (probably should add an offset to center them) ln.p1.x = (int)(p3d1.x * sp.dpmmX); // +hxres; ln.p1.y = (int)(p3d1.y * sp.dpmmY); // +hyres; ln.p2.x = (int)(p3d2.x * sp.dpmmX); // +hxres; ln.p2.y = (int)(p3d2.y * sp.dpmmY); // +hyres; lst.Add(ln); } return(lst); // return the list }
/// <summary> /// This is a helper function that converts 3d polylines to 2d /// </summary> /// <param name="sp"></param> /// <returns></returns> private List <Line2d> Get2dLines(SliceBuildConfig sp, List <PolyLine3d> segments) { List <Line2d> lst = new List <Line2d>(); // this can be changed at some point to assume that the 3d polyline has more than 2 points // I'll need to do this when I want to properly generate inside / outside countours foreach (PolyLine3d ply in segments) { Line2d ln = new Line2d(); //get the 3d points of the line Point3d p3d1 = (Point3d)ply.m_points[0]; Point3d p3d2 = (Point3d)ply.m_points[1]; //convert them to 2d (probably should add an offset to center them) ln.p1.x = (int)(p3d1.x * sp.dpmmX); // +hxres; ln.p1.y = (int)(p3d1.y * sp.dpmmY); // +hyres; ln.p2.x = (int)(p3d2.x * sp.dpmmX); // +hxres; ln.p2.y = (int)(p3d2.y * sp.dpmmY); // +hyres; lst.Add(ln); } return(lst); // return the list }
/// <summary> /// this function converts all the 3d polyines to 2d lines so we can process everything /// This is the equivanlant of a 3d->2d projection function /// </summary> /// <param name="sp"></param> /// <returns></returns> private List <Line2d> Get2dLines(SliceBuildConfig sp, List <PolyLine3d> segments) { List <Line2d> lst = new List <Line2d>(); foreach (PolyLine3d ply in segments) { for (int c = 0; c < ply.m_points.Count - 1; c++) { Line2d ln = new Line2d(); ln.SetParent(ply); //get the 3d points of the line Point3d p3d1 = (Point3d)ply.m_points[c]; Point3d p3d2 = (Point3d)ply.m_points[c + 1]; //convert them to 2d (probably should add an offset to center them) ln.p1.x = (int)(p3d1.x * sp.dpmmX); ln.p1.y = (int)(p3d1.y * sp.dpmmY); ln.p2.x = (int)(p3d2.x * sp.dpmmX); ln.p2.y = (int)(p3d2.y * sp.dpmmY); lst.Add(ln); } } return(lst); // return the list }
// this function converts all the 3d polyines to 2d lines so we can process everything private ArrayList Get2dLines(SliceBuildConfig sp) { ArrayList lst = new ArrayList(); // this can be changed at some point to assume that the 3d polyline has more than 2 points // I'll need to do this when I want to properly generate inside / outside countours foreach (PolyLine3d ply in m_segments) { Line2d ln = new Line2d(); //get the 3d points of the line Point3d p3d1 = (Point3d)ply.m_points[0]; Point3d p3d2 = (Point3d)ply.m_points[1]; //convert them to 2d (probably should add an offset to center them) ln.p1.x = (int)(p3d1.x * sp.dpmmX);// +hxres; ln.p1.y = (int)(p3d1.y * sp.dpmmY);// +hyres; ln.p2.x = (int)(p3d2.x * sp.dpmmX);// +hxres; ln.p2.y = (int)(p3d2.y * sp.dpmmY);// +hyres; lst.Add(ln); } return lst; // return the list }
// this function converts all the 3d polyines to 2d lines so we can process everything private ArrayList Get2dLines(SliceBuildConfig sp) { ArrayList lst = new ArrayList(); foreach (PolyLine3d ply in m_segments) { Line2d ln = new Line2d(); //get the 3d points of the line Point3d p3d1 = (Point3d)ply.m_points[0]; Point3d p3d2 = (Point3d)ply.m_points[1]; //convert them to 2d (probably should add an offset to center them) ln.p1.x = (int)(p3d1.x * sp.dpmmX);// +hxres; ln.p1.y = (int)(p3d1.y * sp.dpmmY);// +hyres; ln.p2.x = (int)(p3d2.x * sp.dpmmX);// +hxres; ln.p2.y = (int)(p3d2.y * sp.dpmmY);// +hyres; lst.Add(ln); } return lst; // return the list }
/// <summary> /// this function converts all the 3d polyines to 2d lines so we can process everything /// This is the equivanlant of a 3d->2d projection function /// </summary> /// <param name="sp"></param> /// <returns></returns> private List<Line2d> Get2dLines(SliceBuildConfig sp, List<PolyLine3d> segments) { List<Line2d> lst = new List<Line2d>(); foreach (PolyLine3d ply in segments) { for (int c = 0; c < ply.m_points.Count - 1; c++ ) { Line2d ln = new Line2d(); ln.SetParent(ply); //get the 3d points of the line Point3d p3d1 = (Point3d)ply.m_points[c]; Point3d p3d2 = (Point3d)ply.m_points[c + 1]; //convert them to 2d (probably should add an offset to center them) ln.p1.x = (int)(p3d1.x * sp.dpmmX); ln.p1.y = (int)(p3d1.y * sp.dpmmY); ln.p2.x = (int)(p3d2.x * sp.dpmmX); ln.p2.y = (int)(p3d2.y * sp.dpmmY); lst.Add(ln); } } return lst; // return the list }