// ----- private void ReadPatch(string gzipName, out JsonPatchInfo json) { json = null; string jsonStr = null; using (FileStream inStream = new FileStream(gzipName, FileMode.Open, FileAccess.Read)) { using (GZipStream decompStream = new GZipStream(inStream, CompressionMode.Decompress)) { using (StreamReader reader = new StreamReader(decompStream)) jsonStr = reader.ReadToEnd(); } } try { json = JsonConvert.DeserializeObject <JsonPatchInfo>(jsonStr); } catch (Exception) { return; } }
private void FromJson(JsonPatchInfo json, out BxVec3F min, out BxVec3F max, out BxCmSeparatePatch_Object patch) { bool success; min = null; max = null; patch = new BxCmSeparatePatch_Object(); if (json == null || json.surface == null || json.minMax == null) { patch = null; return; } FromJson_MinMax(json.minMax, out min, out max); uint numSurface = 0; foreach (JsonPatchInfo_Surface jsonSurface in json.surface) { numSurface++; } patch = new BxCmSeparatePatch_Object(); patch.Alloc(numSurface); uint cntSurface = 0; foreach (JsonPatchInfo_Surface jsonSurface in json.surface) { if (jsonSurface.vertex == null || jsonSurface.surfaceEdge == null) { patch = null; return; } patch[cntSurface].Alloc(); FromJson_Vertex(jsonSurface.vertex, patch[cntSurface]); success = FromJson_SurfaceEdge(jsonSurface.surfaceEdge, patch[cntSurface]); if (success == false) { patch = null; return; } success = FromJson_TNodeType(jsonSurface.tNodeType, patch[cntSurface]); if (success == false) { patch = null; return; } success = FromJson_PreDivided(jsonSurface.preDivided, patch[cntSurface]); if (success == false) { patch = null; return; } cntSurface++; } Debug.Assert(cntSurface == numSurface); }