private absPostion getabsP(string str) { JObject jObject = JObject.Parse(str); absPostion abs = new absPostion(); abs.x = double.Parse(jObject["x"].ToString()); abs.y = double.Parse(jObject["y"].ToString()); abs.z = double.Parse(jObject["z"].ToString()); return(abs); }
//获取空间极限坐标 public CaulModel getCaulModel(absPostion abs, absRotation abr, double D, double W, double H) { CaulModel caulModel = new CaulModel(); Cuboid cb = new Cuboid(); BoardModel board = new BoardModel(); cb = board.getBoardPoint(abs, H, W, D, abr); caulModel.minX = cb.points[0].x; caulModel.minY = cb.points[0].y; caulModel.minZ = cb.points[0].z; caulModel.maxX = cb.points[0].x; caulModel.maxY = cb.points[0].y; caulModel.maxZ = cb.points[0].z; foreach (Point3D point in cb.points) { if (point.x <= caulModel.minX) { caulModel.minX = point.x; } if (point.x >= caulModel.maxX) { caulModel.maxX = point.x; } if (point.y <= caulModel.minY) { caulModel.minY = point.y; } if (point.y >= caulModel.maxY) { caulModel.maxY = point.y; } if (point.z <= caulModel.minZ) { caulModel.minZ = point.z; } if (point.z >= caulModel.maxZ) { caulModel.maxZ = point.z; } } return(caulModel); }
private void getFurnitureObj(string str, int Type, absPostion absPostion) { JArray jar = JArray.Parse(str); int count = jar.Count; foreach (JObject jss in jar) { KJLobject kJLobject = new KJLobject(); kJLobject.modelTypeId = int.Parse(jss["modelTypeId"].ToString()); kJLobject.OrderType = Type; if (jss.Property("modelName") != null) { kJLobject.modelName = jss["modelName"].ToString(); } if (jss.Property("customCode") != null) { kJLobject.customCode = jss["customCode"].ToString(); } if (jss.Property("modelNumber") != null) { kJLobject.modelNumber = jss["modelNumber"].ToString(); } if (jss.Property("obsBrandGoodId") != null) { kJLobject.obsBrandGoodId = jss["obsBrandGoodId"].ToString(); } if (jss.Property("obsModelAccountId") != null) { kJLobject.obsModelAccountId = jss["obsModelAccountId"].ToString(); } if (jss.Property("modelAvailable") != null) { kJLobject.modelAvailable = jss["modelAvailable"].ToString(); } if (jss.Property("needQuotation") != null) { kJLobject.needQuotation = bool.Parse(jss["needQuotation"].ToString()); } if (jss.Property("displayInCostList") != null) { kJLobject.displayInCostList = bool.Parse(jss["displayInCostList"].ToString()); } if (jss.Property("textureName") != null) { kJLobject.textureName = jss["textureName"].ToString(); } if (jss.Property("textureBrandGoodCode") != null) { kJLobject.textureBrandGoodCode = jss["textureBrandGoodCode"].ToString(); } if (jss.Property("textureAvailable") != null) { kJLobject.textureAvailable = bool.Parse(jss["textureAvailable"].ToString()); } if (jss.Property("obsTextureAccountId") != null) { kJLobject.obsTextureAccountId = jss["obsTextureAccountId"].ToString(); } if (jss.Property("id") != null) { kJLobject.id = jss["id"].ToString(); } if (jss.Property("parentId") != null) { kJLobject.parentid = jss["parentId"].ToString(); } List <parameter> lstParm = new List <parameter>(); double W = 0; double H = 0; double D = 0; if (jss.Property("parameters") != null) { string parmstrs = jss["parameters"].ToString(); JArray parmJar = JArray.Parse(parmstrs); foreach (JObject js in parmJar) { parameter pr = new parameter(); if (js.Property("simpleName") != null) { pr.parmName = js["simpleName"].ToString(); pr.parmValue = js["value"].ToString(); } if (pr.parmName == "") { pr.parmName = js["name"].ToString(); pr.parmValue = js["value"].ToString(); } if (pr.parmName != "") { lstParm.Add(pr); } if (pr.parmName == "H") { H = double.Parse(pr.parmValue); } else if (pr.parmName == "W") { W = double.Parse(pr.parmValue); } else if (pr.parmName == "D") { D = double.Parse(pr.parmValue); } } } if (jss.Property("ignoreParameters") != null) { string ignoreparmstrs = jss["ignoreParameters"].ToString(); JArray ignoreparmJar = JArray.Parse(ignoreparmstrs); foreach (JObject js in ignoreparmJar) { parameter pr = new parameter(); if (js.Property("simpleName") != null) { pr.parmName = js["simpleName"].ToString(); pr.parmValue = js["value"].ToString(); } if (pr.parmName == "") { pr.parmName = js["name"].ToString(); pr.parmValue = js["value"].ToString(); } if (pr.parmName != "") { lstParm.Add(pr); } if (pr.parmName == "H") { H = double.Parse(pr.parmValue); } else if (pr.parmName == "W") { W = double.Parse(pr.parmValue); } else if (pr.parmName == "D") { D = double.Parse(pr.parmValue); } } } kJLobject.parameters = lstParm; kJLobject.parameters.Add(new parameter("color", kJLobject.textureBrandGoodCode + "H|")); kJLobject.absP = getabsP(jss["absPosition"].ToString()); kJLobject.absR = getabsR(jss["absRotation"].ToString()); CaulModel caul = new CaulModel(); caul = caul.getCaulModel(kJLobject.absP, kJLobject.absR, D, W, H); kJLobject.caulModel = caul; if (kJLobject.customCode == "F") { boxseq += 1; kJLobject.boxPostion = kJLobject.absP; kJLobject.HoleGroup = boxseq.ToString(); } else { kJLobject.boxPostion = absPostion; kJLobject.HoleGroup = boxseq.ToString(); } if (kJLobject.modelNumber != null && kJLobject.modelNumber != "0") { kobj.Add(kJLobject); } count += -1; if (jss.Property("subModels") != null) { string jschid = jss["subModels"].ToString(); getFurnitureObj(jschid, Type, kJLobject.boxPostion); } else { if (count == 0) { return; } else { continue; } } } }
public Cuboid getBoardPoint(absPostion abs, double H, double W, double D, absRotation abr) { double x = abs.x; double y = abs.y; double z = abs.z; Cuboid cuboid = new Cuboid(); List <Point3D> points = new List <Point3D>(); if (abr.z == 0 || abr.z == 180) { points.Add(new Point3D(x, y, z)); points.Add(new Point3D(x, y - D, z)); points.Add(new Point3D(x + W, y - D, z)); points.Add(new Point3D(x + W, y, z)); points.Add(new Point3D(x, y, z + H)); points.Add(new Point3D(x, y - D, z + H)); points.Add(new Point3D(x + W, y - D, z + H)); points.Add(new Point3D(x + W, y, z + H)); } else if (abr.z == 180) { points.Add(new Point3D(x, y, z)); points.Add(new Point3D(x, y - D, z)); points.Add(new Point3D(x + W, y - D, z)); points.Add(new Point3D(x + W, y, z)); points.Add(new Point3D(x, y, z + H)); points.Add(new Point3D(x, y - D, z + H)); points.Add(new Point3D(x + W, y - D, z + H)); points.Add(new Point3D(x + W, y, z + H)); } else if (abr.z == 90) { points.Add(new Point3D(x, y, z)); points.Add(new Point3D(x, y + W, z)); points.Add(new Point3D(x + D, y, z)); points.Add(new Point3D(x + D, y + W, z)); points.Add(new Point3D(x, y, z + H)); points.Add(new Point3D(x, y + W, z + H)); points.Add(new Point3D(x + D, y, z + H)); points.Add(new Point3D(x + D, y + W, z + H)); } else if (abr.z == -90 || abr.z == 270) { points.Add(new Point3D(x, y, z)); points.Add(new Point3D(x, y - W, z)); points.Add(new Point3D(x - D, y, z)); points.Add(new Point3D(x - D, y - W, z)); points.Add(new Point3D(x, y, z + H)); points.Add(new Point3D(x, y - W, z + H)); points.Add(new Point3D(x - D, y, z + H)); points.Add(new Point3D(x - D, y - W, z + H)); } else if (abr.z == -180) { points.Add(new Point3D(x, y, z)); points.Add(new Point3D(x, y + D, z)); points.Add(new Point3D(x - W, y + D, z)); points.Add(new Point3D(x - W, y, z)); points.Add(new Point3D(x, y, z + H)); points.Add(new Point3D(x, y + D, z + H)); points.Add(new Point3D(x - W, y + D, z + H)); points.Add(new Point3D(x - W, y, z + H)); } cuboid.points = points; return(cuboid); }