static List<EPObj.MemorySafe_CartCoord> ConvertCoordToDouble(CartesianPoint[] points) { List<EPObj.MemorySafe_CartCoord> coords = new List<EPObj.MemorySafe_CartCoord>(); foreach (CartesianPoint pt in points) { double x = Convert.ToDouble(pt.Coordinate[0]); double y = Convert.ToDouble(pt.Coordinate[1]); double z = Convert.ToDouble(pt.Coordinate[2]); EPObj.MemorySafe_CartCoord coord = new EPObj.MemorySafe_CartCoord(x, y, z); coords.Add(coord); } return coords; }
//receives a polyloop and a list of points. //the polyloop is returned filled with cartesian points //can only create a polyloop with 100 coordinates at the most public static PolyLoop makePolyLoopsFromDbleList(PolyLoop pg, List<List<double>> pointslist) { pg.Points = new CartesianPoint[pointslist.Count()]; //culturally invariant by default int listcount = 0; foreach (List<double> ofpoints in pointslist) { //we assume that each set ofpoints has three coordinate //the first is an x coordinate, second is y, third is z //there will only be three doubles CartesianPoint pt = new CartesianPoint(); pt.Coordinate = new string[3]; CultureInfo ci = new CultureInfo(String.Empty); string xformat = string.Format(ci, "{0:0.000000}", ofpoints[0]); string yformat = string.Format(ci, "{0:0.000000}", ofpoints[1]); string zformat = string.Format(ci, "{0:0.000000}", ofpoints[2]); pt.Coordinate[0] = xformat; pt.Coordinate[1] = yformat; pt.Coordinate[2] = zformat; pg.Points[listcount] = pt; listcount++; } return pg; }
public static LLRet GetLLForRoof(List<Vector.MemorySafe_CartCoord> surfacecoords) { LLRet ll = new LLRet(); ll.indices = new List<int>(); int surfindex = -1; CartesianPoint cp = new CartesianPoint(); Vector.CartCoord llsurf = new Vector.CartCoord(); Vector.MemorySafe_CartVect RHRVector = Vector.GetMemRHR(surfacecoords); if (Math.Abs(RHRVector.X) == 0 && RHRVector.Y == 0 && RHRVector.Z == 1) { for (int sccount = 0; sccount < surfacecoords.Count; sccount++) { if (sccount == 0) { llsurf.X = surfacecoords[sccount].X; llsurf.Y = surfacecoords[sccount].Y; llsurf.Z = surfacecoords[sccount].Z; surfindex = sccount; continue; } //get lower left...most low(largest Y), then most left (smallest X) if (surfacecoords[sccount].Y >= llsurf.Y) { if (surfacecoords[sccount].X < llsurf.X) { llsurf.X = surfacecoords[sccount].X; llsurf.Y = surfacecoords[sccount].Y; llsurf.Z = surfacecoords[sccount].Z; surfindex = sccount; } } } } else { //special procedure for this type of roof } Vector.MemorySafe_CartCoord LLeft = new Vector.MemorySafe_CartCoord(llsurf.X, llsurf.Y, llsurf.Z); cp = makegbCartesianPt(LLeft); ll.cp = cp; ll.indices.Add(surfindex); return ll; }
public static CartesianPoint makegbCartesianPt(Vector.MemorySafe_CartCoord pt) { CartesianPoint cp = new CartesianPoint(); cp.Coordinate = new string[3]; cp.Coordinate[0] = gb.FormatDoubleToString(pt.X); cp.Coordinate[1] = gb.FormatDoubleToString(pt.Y); cp.Coordinate[2] = gb.FormatDoubleToString(pt.Z); return cp; }
//Reminder to factor in CADAzimuth if appropriate public static LLRet GetLLForOpening(List<Vector.MemorySafe_CartCoord> surfacecoords, List<Vector.MemorySafe_CartCoord> openingcoords) { LLRet ll = new LLRet(); ll.indices = new List<int>(); int surfindex=-1; int opindex=-1; CartesianPoint cp = new CartesianPoint(); //we want to verify that this is indeed correct //west-facing Vector.MemorySafe_CartVect RHRVector = Vector.GetMemRHR(surfacecoords); if (Math.Abs(RHRVector.X) == -1 && RHRVector.Y == 0 && RHRVector.Z == 0) { Vector.CartCoord llsurf = new Vector.CartCoord(); for (int sccount = 0; sccount < surfacecoords.Count; sccount++) { if (sccount == 0) { llsurf.X = surfacecoords[sccount].X; llsurf.Y = surfacecoords[sccount].Y; llsurf.Z = surfacecoords[sccount].Z; surfindex = sccount; continue; } //get lower left...most lowest(smallest Z), then most left (largest Y) if (surfacecoords[sccount].Z <= llsurf.Z) { if(surfacecoords[sccount].Y > llsurf.Y) { llsurf.X = surfacecoords[sccount].X; llsurf.Y = surfacecoords[sccount].Y; llsurf.Z = surfacecoords[sccount].Z; surfindex = sccount; } } } Vector.CartCoord llopening = new Vector.CartCoord(); for (int occount = 0; occount < openingcoords.Count; occount++) { if (occount == 0) { llopening.X = openingcoords[occount].X; llopening.Y = openingcoords[occount].Y; llopening.Z = openingcoords[occount].Z; opindex = occount; continue; } //get lower left...most low(lowest Z), then most left (largest Y) if (openingcoords[occount].Z <= llopening.Z) { if(openingcoords[occount].Y > llopening.Y) { llopening.X = openingcoords[occount].X; llopening.Y = openingcoords[occount].Y; llopening.Z = openingcoords[occount].Z; opindex = occount; } } } double diffX = Math.Abs(llsurf.Y - llopening.Y); double diffY = Math.Abs(llopening.Z - llsurf.Z); Vector.MemorySafe_CartCoord LLeft = new Vector.MemorySafe_CartCoord(diffX,diffY,0); cp = makegbCartesianPt(LLeft); } //north-facing else if (Math.Abs(RHRVector.X) == 0 && RHRVector.Y == 1 && RHRVector.Z == 0) { Vector.CartCoord llsurf = new Vector.CartCoord(); for (int sccount = 0; sccount < surfacecoords.Count; sccount++) { if (sccount == 0) { llsurf.X = surfacecoords[sccount].X; llsurf.Y = surfacecoords[sccount].Y; llsurf.Z = surfacecoords[sccount].Z; surfindex = sccount; continue; } //get lower left...most low(smallest Z), then most left (largest X) if (surfacecoords[sccount].Z <= llsurf.Z) { if(surfacecoords[sccount].X > llsurf.X) { llsurf.X = surfacecoords[sccount].X; llsurf.Y = surfacecoords[sccount].Y; llsurf.Z = surfacecoords[sccount].Z; surfindex = sccount; } } } Vector.CartCoord llopening = new Vector.CartCoord(); for (int occount = 0; occount < openingcoords.Count; occount++) { if (occount == 0) { llopening.X = openingcoords[occount].X; llopening.Y = openingcoords[occount].Y; llopening.Z = openingcoords[occount].Z; opindex = occount; continue; } //get lower left...most low(smallest Z), then most left (largest X) if (openingcoords[occount].Z <= llopening.Z) { if(openingcoords[occount].X > llopening.X) { llopening.X = openingcoords[occount].X; llopening.Y = openingcoords[occount].Y; llopening.Z = openingcoords[occount].Z; opindex = occount; } } } double diffX = Math.Abs(llsurf.X - llopening.X); double diffY = Math.Abs(llsurf.Z - llopening.Z); Vector.MemorySafe_CartCoord LLeft = new Vector.MemorySafe_CartCoord(diffX,diffY,0); cp= makegbCartesianPt(LLeft); } //south-facing else if (Math.Abs(RHRVector.X) == 0 && RHRVector.Y == -1 && RHRVector.Z == 0) { Vector.CartCoord llsurf = new Vector.CartCoord(); for (int sccount = 0; sccount < surfacecoords.Count; sccount++) { if (sccount == 0) { llsurf.X = surfacecoords[sccount].X; llsurf.Y = surfacecoords[sccount].Y; llsurf.Z = surfacecoords[sccount].Z; surfindex = sccount; continue; } //get lower left...most low(smaller Z), then most left (smallest X) if (surfacecoords[sccount].Z <= llsurf.Z) { if(surfacecoords[sccount].X < llsurf.X) { llsurf.X = surfacecoords[sccount].X; llsurf.Y = surfacecoords[sccount].Y; llsurf.Z = surfacecoords[sccount].Z; surfindex = sccount; } } } Vector.CartCoord llopening = new Vector.CartCoord(); for (int occount = 0; occount < openingcoords.Count; occount++) { if (occount == 0) { llopening.X = openingcoords[occount].X; llopening.Y = openingcoords[occount].Y; llopening.Z = openingcoords[occount].Z; opindex = occount; continue; } //get lower left...most low(smallest Z), then most left (smallest X) if (openingcoords[occount].Z <= llopening.Z) { if(openingcoords[occount].X < llopening.X) { llopening.X = openingcoords[occount].X; llopening.Y = openingcoords[occount].Y; llopening.Z = openingcoords[occount].Z; opindex = occount; } } } double diffX = Math.Abs(llsurf.X - llopening.X); double diffY = Math.Abs(llsurf.Z - llopening.Z); Vector.MemorySafe_CartCoord LLeft = new Vector.MemorySafe_CartCoord(diffX,diffY,0); cp = makegbCartesianPt(LLeft); } //east-facing else if (Math.Abs(RHRVector.X) == 1 && RHRVector.Y == 0 && RHRVector.Z == 0) { Vector.CartCoord llsurf = new Vector.CartCoord(); for (int sccount = 0; sccount < surfacecoords.Count; sccount++) { if (sccount == 0) { llsurf.X = surfacecoords[sccount].X; llsurf.Y = surfacecoords[sccount].Y; llsurf.Z = surfacecoords[sccount].Z; surfindex = sccount; continue; } //get lower left...most low(smaller Z), then most left (smallest Y) if (surfacecoords[sccount].Z <= llsurf.Z) { if(surfacecoords[sccount].Y < llsurf.Y) { llsurf.X = surfacecoords[sccount].X; llsurf.Y = surfacecoords[sccount].Y; llsurf.Z = surfacecoords[sccount].Z; surfindex = sccount; } } } Vector.CartCoord llopening = new Vector.CartCoord(); for (int occount = 0; occount < openingcoords.Count; occount++) { if (occount == 0) { llopening.X = openingcoords[occount].X; llopening.Y = openingcoords[occount].Y; llopening.Z = openingcoords[occount].Z; opindex = occount; continue; } //get lower left...most low(smallest Z), then most left (smallest Y) if (openingcoords[occount].Z <= llopening.Z) { if(openingcoords[occount].Y < llopening.Y) { llopening.X = openingcoords[occount].X; llopening.Y = openingcoords[occount].Y; llopening.Z = openingcoords[occount].Z; opindex = occount; } } } double diffX = Math.Abs(llsurf.Y - llopening.Y); double diffY = Math.Abs(llsurf.Z - llopening.Z); Vector.MemorySafe_CartCoord LLeft = new Vector.MemorySafe_CartCoord(diffX,diffY,0); cp = makegbCartesianPt(LLeft); } //floors else if (Math.Abs(RHRVector.X) == 0 && RHRVector.Y == 0 && RHRVector.Z == -1) { Vector.CartCoord llsurf = new Vector.CartCoord(); LLRet llroof = GetLLForFloor(surfacecoords); llsurf.X = Convert.ToDouble(llroof.cp.Coordinate[0]); llsurf.Y = Convert.ToDouble(llroof.cp.Coordinate[1]); llsurf.Z = Convert.ToDouble(llroof.cp.Coordinate[2]); surfindex = llroof.indices[0]; Vector.CartCoord llopening = new Vector.CartCoord(); for (int occount = 0; occount < openingcoords.Count; occount++) { if (occount == 0) { llopening.X = openingcoords[occount].X; llopening.Y = openingcoords[occount].Y; llopening.Z = openingcoords[occount].Z; opindex = occount; continue; } //get lower left...most low(smallest Y), then most left (largest X) if (openingcoords[occount].Y <= llopening.Y) { if (openingcoords[occount].X > llopening.X) { llopening.X = openingcoords[occount].X; llopening.Y = openingcoords[occount].Y; llopening.Z = openingcoords[occount].Z; opindex = occount; } } } double diffX = Math.Abs(llsurf.X - llopening.X); double diffY = Math.Abs(llsurf.Y - llopening.Y); Vector.MemorySafe_CartCoord LLeft = new Vector.MemorySafe_CartCoord(diffX, diffY, 0); cp = makegbCartesianPt(LLeft); } //flat roof else if (Math.Abs(RHRVector.X) == 0 && RHRVector.Y == 0 && RHRVector.Z == 1) { Vector.CartCoord llsurf = new Vector.CartCoord(); LLRet llroof = GetLLForRoof(surfacecoords); llsurf.X = Convert.ToDouble(llroof.cp.Coordinate[0]); llsurf.Y = Convert.ToDouble(llroof.cp.Coordinate[1]); llsurf.Z = Convert.ToDouble(llroof.cp.Coordinate[2]); surfindex = llroof.indices[0]; Vector.CartCoord llopening = new Vector.CartCoord(); for (int occount = 0; occount < openingcoords.Count; occount++) { if (occount == 0) { llopening.X = openingcoords[occount].X; llopening.Y = openingcoords[occount].Y; llopening.Z = openingcoords[occount].Z; opindex = occount; continue; } //get lower left...most low(largest Y), then most left (smallest X) if (openingcoords[occount].Y >= llopening.Y) { if (openingcoords[occount].X < llopening.X) { llopening.X = openingcoords[occount].X; llopening.Y = openingcoords[occount].Y; llopening.Z = openingcoords[occount].Z; opindex = occount; } } } double diffX = Math.Abs(llsurf.X - llopening.X); double diffY = Math.Abs(llsurf.Y - llopening.Y); Vector.MemorySafe_CartCoord LLeft = new Vector.MemorySafe_CartCoord(diffX, diffY, 0); cp = makegbCartesianPt(LLeft); } //plane does not reside on a primary axis else { //I will deal with this later //have to factor in what is a "roof" or "floor" or "wall" based on the default tilt settings } ll.cp = cp; ll.indices.Add(surfindex); ll.indices.Add(opindex); return ll; }