public void LoadJson(string path) { using (StreamReader r = new StreamReader(path)) { string json = r.ReadToEnd(); result = new JavaScriptSerializer().Deserialize <AllCollections>(json); } ParseLoadedObject(); }
public AllCollections PrepareToSave() { result = new AllCollections(); int PointsCounter = 0; foreach (var item in TorusCollection1) { TorusExchange temp = new TorusExchange(item.r, item.R, item._division_fi, item.Division_teta, item.Center, item.Center, item.Center); result.toruses.Add(temp); } foreach (var item in BezierPatchC2Collection1) { int[][] pointIndices = new int[item.VerticalPatches + 3][]; for (int i = 0; i < item.PatchPoints.GetLength(0); i++) { pointIndices[i] = new int[item.HorizontalPatches + 3]; for (int j = 0; j < item.PatchPoints.GetLength(1); j++) { result.points.Add(new PointExchange(item.PatchPoints[i, j].Name, item.PatchPoints[i, j].X, item.PatchPoints[i, j].Y, item.PatchPoints[i, j].Z)); pointIndices[i][j] = PointsCounter; PointsCounter++; } } Surface temp = new Surface(item.PatchesAreCylinder, item.HorizontalPatches, item.VerticalPatches, item.Name, pointIndices, item.u, item.v); result.surfacesC2.Add(temp); } List <Point> AllPoints = new List <Point>(); foreach (var item in BezierPatchCollection1) { Point[,] PatchPoints; PatchPoints = item.GetAllPointsInOneArray(); int[][] pointIndices = new int[PatchPoints.GetLength(0)][]; for (int i = 0; i < PatchPoints.GetLength(0); i++) { pointIndices[i] = new int[PatchPoints.GetLength(1)]; for (int j = 0; j < PatchPoints.GetLength(1); j++) { int a = AllPoints.IndexOf(PatchPoints[i, j]); if (a == -1) { AllPoints.Add(PatchPoints[i, j]); result.points.Add(new PointExchange(PatchPoints[i, j].Name, PatchPoints[i, j].X, PatchPoints[i, j].Y, PatchPoints[i, j].Z)); pointIndices[i][j] = PointsCounter; PointsCounter++; } else { pointIndices[i][j] = a; //MessageBox.Show(a.ToString()); } } } Surface temp = new Surface(item.PatchesAreCylinder, item.HorizontalPatches, item.VerticalPatches, item.Name, pointIndices, item._patchHorizontalDivision, item._patchVerticalDivision); result.surfacesC0.Add(temp); } foreach (var item in _bezierCurveCollection1) { int[] pointIndices = new int[item.PointsCollection.Count]; for (int j = 0; j < item.PointsCollection.Count; j++) { result.points.Add(new PointExchange(item.PointsCollection[j].Name, item.PointsCollection[j].X, item.PointsCollection[j].Y, item.PointsCollection[j].Z)); pointIndices[j] = PointsCounter; PointsCounter++; } CurveExchange temp = new CurveExchange(item.Name, pointIndices); if (item.CurveType == "C0") { result.curvesC0.Add(temp); } else if (item.CurveType == "C2") { result.curvesC2.Add(temp); } else if (item.CurveType == "C2Interpolation") { result.curvesC2I.Add(temp); } else { } } return(result); }