private bool ParseModel(ref BrickMesh brickMesh, string[] readText) { eCertified certified = eCertified.NA; eWinding winding = eWinding.CCW; bool invertNext = false; brickMesh.CreateMeshInfo(); for (int i = 0; i < readText.Length; ++i) { string line = readText[i]; line.Replace("\t", " "); line = line.Trim(); if (line.Length == 0) { continue; } int lineType = (int)Char.GetNumericValue(line[0]); switch (lineType) { case 0: ParseBFCInfo(line, ref certified, ref winding, ref invertNext); break; case 1: if (!ParseSubFileInfo(ref brickMesh, line, invertNext)) { Debug.Log(string.Format("ParseSubFileInfo failed: {0}", line)); return(false); } invertNext = false; break; case 3: if (!ParseTriInfo(ref brickMesh, line, winding)) { Debug.Log(string.Format("ParseTriInfo failed: {0}", line)); return(false); } break; case 4: if (!ParseQuadInfo(ref brickMesh, line, winding)) { Debug.Log(string.Format("ParseQuadInfo failed: {0}", line)); return(false); } break; default: break; } } brickMesh.FinalizeBrickMeshInfo(certified == eCertified.TRUE); return(true); }
private bool ParseBFCInfo(string line, ref eCertified certified, ref eWinding winding, ref bool invertNext) { string[] words = line.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); if (words.Length < 2) { return(false); } int offset = 1; if (!words[offset++].Equals(LdConstant.TAG_BFC, StringComparison.OrdinalIgnoreCase)) { return(false); } if (words[offset].Equals(LdConstant.TAG_NOCERTIFY, StringComparison.OrdinalIgnoreCase)) { offset++; Debug.Assert(certified != eCertified.TRUE, "Previous Certificate should not be TRUE."); if (certified == eCertified.NA) { certified = eCertified.FALSE; return(true); } } else if (words[offset].Equals(LdConstant.TAG_CERTIFY, StringComparison.OrdinalIgnoreCase)) { offset++; Debug.Assert(certified != eCertified.FALSE, "Previous Certificate should not be FALSE."); if (certified == eCertified.NA) { certified = eCertified.TRUE; } } if (offset >= words.Length) { winding = eWinding.CCW; return(true); } if (words[offset].Equals(LdConstant.TAG_CW, StringComparison.OrdinalIgnoreCase)) { offset++; winding = eWinding.CW; return(true); } else if (words[offset].Equals(LdConstant.TAG_CCW, StringComparison.OrdinalIgnoreCase)) { offset++; winding = eWinding.CCW; return(true); } else if (words[offset].Equals(LdConstant.TAG_INVERTNEXT, StringComparison.OrdinalIgnoreCase)) { offset++; invertNext = true; return(true); } return(false); }