// 11 group private int makeGroup(Mesh newMesh, PRIM prim, int startIndex) { int cp = 0; foreach (Vertices vertices in prim.VerticesList) { if (vertices.VertexList.Count < 3) { continue; } List <Vector4> controlPoints = new List <Vector4>(); foreach (RVMUtility.Data.Vertex v in vertices.VertexList) { Vector4 vector = this.CalcMatrix(prim, v.X, v.Y, v.Z); controlPoints.Add(vector); } newMesh.ControlPoints.AddRange(controlPoints); PolygonBuilder builder = new PolygonBuilder(newMesh); builder.Begin(); for (int i = 0; i < controlPoints.Count; i++) { builder.AddVertex(startIndex + i + cp); } builder.End(); cp += controlPoints.Count; } return(cp); }
private int makeRTorus(Mesh newMesh, PRIM prim, int startIndex) { double bRadius = prim.Length[0, 0]; double sRadius = prim.Length[0, 1]; double radian = prim.Length[0, 3]; double degree = Math.Round((180 * radian) / Math.PI); return(0); }
private Vector4 CalcMatrix(PRIM prim, double x, double y, double z) { Vector4 v = new Vector4(); v.x = (prim.Rotation[0, 0] * x) + (prim.Rotation[0, 1] * y) + (prim.Rotation[0, 2] * z) + prim.Rotation[0, 3]; v.y = (prim.Rotation[1, 0] * x) + (prim.Rotation[1, 1] * y) + (prim.Rotation[1, 2] * z) + prim.Rotation[1, 3]; v.z = (prim.Rotation[2, 0] * x) + (prim.Rotation[2, 1] * y) + (prim.Rotation[2, 2] * z) + prim.Rotation[2, 3]; return(v); }
bool chekupdate() { if (!(PRIM.Replace('#', '"').Replace('$', ';').Replace('@', ',').Replace('№', '/').Replace('^', ' ').Replace('|', ';').Trim() == tb1.Text.Trim()) || autoprimisred || EDIT != (cb1.IsChecked.Value?"1":"0")) { Title = "Примечание*"; return(true); } else { Title = "Примечание"; return(false); } }
private int addObject(Mesh mesh, PRIM prim, int startIndex) { int pointIdx = 0; this.PartCount[prim.Type - 1]++; switch (prim.Type) { case 1: //pointIdx = this.makePyramid(mesh, prim, startIndex); break; case 2: // pointIdx = this.makeBox(mesh, prim, startIndex); break; case 3: pointIdx = this.makeRTorus(mesh, prim, startIndex); break; case 4: //pointIdx = this.makeTorus(mesh, prim, startIndex); break; case 5: case 6: //pointIdx = this.makeDish(mesh, prim, startIndex); break; case 7: // pointIdx = this.makeCylinder(mesh, prim, startIndex); break; case 8: //pointIdx = this.makeCylinder(mesh, prim, startIndex); break; case 9: //pointIdx = this.makeSphere(mesh, prim, startIndex); break; case 10: break; case 11: //pointIdx = this.makeGroup(mesh, prim, startIndex); break; } return(pointIdx); }
public Prim3(string path, string text) { InitializeComponent(); BD.path = path; //укажем файл бд this.text_otvet = text.Trim(); //PRIM=a2131231232321;AVTO=asdasdasda // MessageBox.Show(this.text_otvet); if (text_otvet.Contains("PRIM=") && text_otvet.Contains(";AVTO=") && text_otvet.Contains(";EDIT=")) { try { PRIM = (text_otvet.Split(';'))[0].Substring(5); } catch { PRIM = ""; } try { AUTO = (text_otvet.Split(';'))[1].Substring(5).Trim('^'); } catch { AUTO = ""; } try { EDIT = (text_otvet.Split(';'))[2].Substring(5); } catch { EDIT = "0"; } try { SAUTO = (text_otvet.Split(';'))[3].Substring(6).Trim('^'); } catch { SAUTO = ""; } } else { PRIM = text_otvet; AUTO = ""; SAUTO = ""; EDIT = "0"; } // if (EDIT.Equals("1")) { tb3.IsEnabled = true; cb1.IsChecked = true; } else { tb3.IsEnabled = false; cb1.IsChecked = false; } OleDbDataReader reader = BD.conn("SELECT STCommentD.Name, STCommentD.ID, STCommentDchasto.Chastota FROM STCommentD LEFT JOIN STCommentDchasto ON STCommentD.ID = STCommentDchasto.IDComment ORDER BY STCommentDchasto.Chastota DESC"); while (reader.Read()) { int Chasto = 0; if (reader["Chastota"].ToString() != "") { Chasto = Convert.ToInt32(reader["Chastota"]); } result.Add(new MyTable() { ID = reader["ID"].ToString(), Name = reader["Name"].ToString(), Chasto = Chasto }); } reader.Close(); loadpage(); //загрузка полож окна proverka_uhoda_za_granicu(); //проверка ухода за границу tb2.Focus(); string t = PRIM.Replace('#', '"').Replace('$', ';').Replace('@', ',').Replace('№', '/').Replace('^', ' ').Replace('|', ';'); tb1.Text = t; tb3.Text = AUTO; if (!AUTO.Equals("")) { string[] split_AUTO = AUTO.Split('^'); foreach (string elem in split_AUTO) { var splitelemrech = elem.Split('#'); btn_spis elemnew; if (splitelemrech.Length == 2) { elemnew = new btn_spis() { name = splitelemrech[1].Trim(), id = splitelemrech[0].Trim() }; } else { elemnew = new btn_spis() { name = elem.Trim() }; } /* * string[] splitenable = elem.Split('#'); * var elemnew = new btn_spis() { * name = splitenable[0], * vibran = splitenable.Length==2? splitenable[1]=="1":true * };*/ spisbtn.Add(elemnew); lbbutton.Items.Add(elemnew); } } // MessageBox.Show(SAUTO); if (!SAUTO.Equals("")) { string[] split_SAUTO = SAUTO.Split('^'); foreach (string elem in split_SAUTO) { // var elemnew = new btn_spis() { name = elem.Trim() }; var splitelemrech = elem.Split('#'); var elemnew = new btn_spis() { name = splitelemrech[1].Trim(), id = splitelemrech[0].Trim() }; /* * string[] splitenable = elem.Split('#'); * var elemnew = new btn_spis() { * name = splitenable[0], * vibran = splitenable.Length==2? splitenable[1]=="1":true * };*/ var findelem = spisbtn.Find(x => x.id == elemnew.id); if (findelem != null) { // MessageBox.Show(findelem.name +" "+ elemnew.name); if (findelem.name.Trim().ToLower() == elemnew.name.Trim().ToLower()) //просто крести { findelem.setvibran(false); //показываес что элемент крестик } else //крестик и указываем что изменен1 { findelem.setvibran(false, true); //показываес что элемент крестик lvstalo.Items.Add(new bilostalo() { bilo = elemnew.name, stalo = findelem.name, deystvie = "Изменено", colorbg = "#66FFF500" }); // bilo.Items.Add(elemnew); // stalo.Items.Add(findelem); spisbtnSAUTO.Add(elemnew); } } else { logdlas += elemnew.name + " - АВТОПРИМЕЧАНИЕ УДАЛЕНО" + Environment.NewLine; spisbtnSAUTO.Add(elemnew); lvstalo.Items.Add(new bilostalo() { bilo = elemnew.name, stalo = "", deystvie = "Удалено", colorbg = "#66FF0000" }); // bilo.Items.Add(elemnew); // stalo.Items.Add(null); } // lbbutton.Items.Add(elemnew); } } if (spisbtnSAUTO.Count == 0) { ddddd.Height = new GridLength(0); } // tbizmen.Text= logdlas; tb1.CaretIndex = tb1.Text.Length; }
public Prim2(string path, string text) { InitializeComponent(); BD.path = path; //укажем файл бд this.text_otvet = text.Trim(); // MessageBox.Show(this.text_otvet); //PRIM=a2131231232321;AVTO=asdasdasda// if (text_otvet.Contains("PRIM=") && text_otvet.Contains(";AVTO=") && text_otvet.Contains(";EDIT=")) { try { PRIM = (text_otvet.Split(';'))[0].Substring(5); } catch { PRIM = ""; } try { AUTO = (text_otvet.Split(';'))[1].Substring(5).Trim('^'); } catch { AUTO = ""; } try { EDIT = (text_otvet.Split(';'))[2].Substring(5); } catch { EDIT = "0"; } } else { PRIM = text_otvet; AUTO = ""; EDIT = "0"; } if (EDIT.Equals("1")) { tb3.IsEnabled = true; cb1.IsChecked = true; } else { tb3.IsEnabled = false; cb1.IsChecked = false; } OleDbDataReader reader = BD.conn("SELECT STCommentD.Name, STCommentD.ID, STCommentDchasto.Chastota FROM STCommentD LEFT JOIN STCommentDchasto ON STCommentD.ID = STCommentDchasto.IDComment ORDER BY STCommentDchasto.Chastota DESC"); while (reader.Read()) { int Chasto = 0; if (reader["Chastota"].ToString() != "") { Chasto = Convert.ToInt32(reader["Chastota"]); } result.Add(new MyTable() { ID = reader["ID"].ToString(), Name = reader["Name"].ToString(), Chasto = Chasto }); } loadpage(); //загрузка полож окна proverka_uhoda_za_granicu(); //проверка ухода за границу tb2.Focus(); string t = PRIM.Replace('#', '"').Replace('$', ';').Replace('@', ',').Replace('№', '/').Replace('^', ' ').Replace('|', ';'); tb1.Text = t; tb3.Text = AUTO; if (!AUTO.Equals("")) { string[] split_AUTO = AUTO.Split('^'); foreach (string elem in split_AUTO) { var splitelemrech = elem.Split('#'); var elemnew = new btn_spis() { name = splitelemrech.Length == 2? splitelemrech [1]: elem }; spisbtn.Add(elemnew); lbbutton.Items.Add(elemnew); } } // lbbutton.ItemsSource = spisbtn; tb1.CaretIndex = tb1.Text.Length; }
public void Parse(object args) { string path = (string)args; //내용 임시저장 Queue <string> lines = new Queue <string>(); Stack <CNT> stackCNT = new Stack <CNT>(); List <CNT> CntList = new List <CNT>(); FileStream fs = new FileStream(path, FileMode.OpenOrCreate, FileAccess.Read, FileShare.ReadWrite); StreamReader reader = new StreamReader(fs); string strLine = string.Empty; string siteName = string.Empty; CNT currentCNT = null; bool isEnd = false; int primCnt = 0; while (reader.EndOfStream == false) { strLine = ReadLine(reader, lines); if (strLine == "CNTB") { //시작 체크 isEnd = false; strLine = ReadLine(reader, lines, 2); //이름으로 생성 CNT newCNT = new CNT(strLine); //root 표시 if (this.CheckSiteName(strLine)) // 파일 이름이면. { this.rootList.Add(newCNT); CntList = new List <CNT>(); this.allCNTList.Add(CntList); } //xyz좌표가져오기 strLine = ReadLine(reader, lines, 1); newCNT.AddXYZ(strLine); //스택에 추가 stackCNT.Push(newCNT); CntList.Add(newCNT); //현재 노드 갱신 if (currentCNT != null && isEnd == false) { currentCNT.AddCNT(newCNT); } currentCNT = newCNT; } else if (strLine == "CNTE") { //그룹 끝 체크 isEnd = true; //부모 노드로 교체 try { currentCNT = stackCNT.Pop().Parent; } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } } else if (strLine == "PRIM") { primCnt++; //타입 읽기 strLine = ReadLine(reader, lines, 2); PRIM newPRIM = new PRIM(strLine); //prim 추가 currentCNT.AddPRIM(newPRIM); //회전 string[] rotationArr = new string[3]; for (int i = 0; i < 3; i++) { rotationArr[i] = ReadLine(reader, lines, 1); } newPRIM.SetRotation(rotationArr); //바운드 string[] boundArr = new string[2]; for (int i = 0; i < 2; i++) { boundArr[i] = ReadLine(reader, lines, 1); } newPRIM.SetBound(boundArr); if (newPRIM.Type == 7 || newPRIM.Type == 1) { //길이 7번( 콘은) 2줄 string[] lengthArr = new string[2]; for (int i = 0; i < 2; i++) { lengthArr[i] = ReadLine(reader, lines, 1); } newPRIM.SetLength(lengthArr); } else if (newPRIM.Type == 11) { //strLine = ReadLine(reader, lines, 6); strLine = ReadLine(reader, lines, 1); int faceCnt = -1; int.TryParse(strLine, out faceCnt); int subfaceCnt = -1; for (int fi = 0; fi < faceCnt; fi++) { subfaceCnt = -1; strLine = ReadLine(reader, lines, 1); int.TryParse(strLine, out subfaceCnt); //보통 1 for (int sfi = 0; sfi < subfaceCnt; sfi++) { int vertaxCnt = -1; strLine = ReadLine(reader, lines, 1); int.TryParse(strLine, out vertaxCnt); newPRIM.AddVertextCount(vertaxCnt); Vertices newVertices = new Vertices(); for (int vi = 0; vi < vertaxCnt; vi++) { strLine = ReadLine(reader, lines, 1); string v = strLine; strLine = ReadLine(reader, lines, 1); string r = strLine; newVertices.AddVertex(v, r); } newPRIM.AddVertices(newVertices); } } } else { //길이 1~8, 9번 1줄 string[] lengthArr = new string[1]; lengthArr[0] = ReadLine(reader, lines, 1); newPRIM.SetLength(lengthArr); } } } }
// 9 sphere private int makeSphere(Mesh newMesh, PRIM prim, int startIndex) { double radius = prim.Length[0, 0]; double sliceCount = 8; double stackCount = 6; double phiStep = Math.PI / stackCount; double thetaStep = 2.0 * Math.PI / sliceCount; List <Vector4> controlPoints = new List <Vector4>(); for (int i = 0; i < stackCount + 1; i++) { double phi = i * phiStep; for (int j = 0; j < sliceCount; j++) { double theta = j * thetaStep; double x = radius * Math.Sin(phi) * Math.Cos(theta); double y = radius * Math.Cos(phi); double z = radius * Math.Sin(phi) * Math.Sin(theta); Vector4 v = this.CalcMatrix(prim, x, y, z); controlPoints.Add(v); if (i == 0 || i == stackCount) { break; } } } newMesh.ControlPoints.AddRange(controlPoints); PolygonBuilder builder = new PolygonBuilder(newMesh); int sc = (int)sliceCount; for (int i = 0; i < sc - 1; i++) { builder.Begin(); builder.AddVertex(startIndex + 0); builder.AddVertex(startIndex + i + 2); builder.AddVertex(startIndex + i + 1); builder.End(); } builder.Begin(); builder.AddVertex(startIndex + 0); builder.AddVertex(startIndex + 1); builder.AddVertex(startIndex + sc); builder.End(); for (int i = 0; i < stackCount - 2; i++) { for (int j = 0; j < sc - 1; j++) { builder.Begin(); builder.AddVertex(startIndex + (i * sc) + j + 1); builder.AddVertex(startIndex + (i * sc) + j + 2); builder.AddVertex(startIndex + (i * sc) + j + sc + 2); builder.AddVertex(startIndex + (i * sc) + j + sc + 1); builder.End(); } builder.Begin(); builder.AddVertex(startIndex + (i * sc) + 1); builder.AddVertex(startIndex + (i * sc) + sc + 1); builder.AddVertex(startIndex + (i * sc) + sc + sc); builder.AddVertex(startIndex + (i * sc) + sc); builder.End(); } return(controlPoints.Count); }
// 7, 8 cylinder private int makeCylinder(Mesh newMesh, PRIM prim, int startIndex) { double radiusTop = 0; double radiusBottom = radiusTop; double height = 0; if (prim.Type == 7) { radiusBottom = prim.Length[0, 0]; radiusTop = prim.Length[0, 1]; height = prim.Length[0, 2]; } else if (prim.Type == 8) { radiusBottom = prim.Length[0, 0]; radiusTop = prim.Length[0, 0]; height = prim.Length[0, 1]; } int sliceCount = 8; int stackCount = 1; int ringCount = stackCount + 1; double stackHeight = height / stackCount; double radiusStep = (radiusTop - radiusBottom) / stackCount; List <Vector4> controlPoints = new List <Vector4>(); for (int i = 0; i < ringCount; i++) { double z = (-0.5f * height) + (i * stackHeight); double r = radiusBottom + (i * radiusStep); double dTheta = (2.0f * Math.PI) / sliceCount; for (int j = 0; j < sliceCount; j++) { double c = Math.Cos(j * dTheta); double s = Math.Sin(j * dTheta); Vector4 v = this.CalcMatrix(prim, r * c, r * s, z); controlPoints.Add(v); } } newMesh.ControlPoints.AddRange(controlPoints); PolygonBuilder builder = new PolygonBuilder(newMesh); for (int i = 0; i < sliceCount - 1; i++) { builder.Begin(); builder.AddVertex(startIndex + i); builder.AddVertex(startIndex + i + 1); builder.AddVertex(startIndex + i + sliceCount + 1); builder.AddVertex(startIndex + i + sliceCount); builder.End(); } builder.Begin(); builder.AddVertex(startIndex + 0); builder.AddVertex(startIndex + sliceCount); builder.AddVertex(startIndex + sliceCount + sliceCount - 1); builder.AddVertex(startIndex + sliceCount - 1); builder.End(); if (prim.Type == 8) { builder.Begin(); for (int i = 0; i < sliceCount; i++) { builder.AddVertex(startIndex + sliceCount - 1 - i); } builder.End(); builder.Begin(); for (int i = 0; i < sliceCount; i++) { builder.AddVertex(startIndex + sliceCount + i); } builder.End(); } return(controlPoints.Count); }
// 2 private int makeBox(Mesh newMesh, PRIM prim, int startIndex) { double xlen = prim.Length[0, 0] / 2; double ylen = prim.Length[0, 1] / 2; double zlen = prim.Length[0, 2] / 2; //Console.WriteLine(string.Format("{0} {1} {2} {3}", xtlen, xblen, ylen, zlen)); Vector4 v1 = this.CalcMatrix(prim, xlen, ylen, zlen); Vector4 v2 = this.CalcMatrix(prim, xlen * -1, ylen, zlen); Vector4 v3 = this.CalcMatrix(prim, xlen * -1, ylen * -1, zlen); Vector4 v4 = this.CalcMatrix(prim, xlen, ylen * -1, zlen); Vector4 v5 = this.CalcMatrix(prim, xlen, ylen, zlen * -1); Vector4 v6 = this.CalcMatrix(prim, xlen * -1, ylen, zlen * -1); Vector4 v7 = this.CalcMatrix(prim, xlen * -1, ylen * -1, zlen * -1); Vector4 v8 = this.CalcMatrix(prim, xlen, ylen * -1, zlen * -1); List <Vector4> controlPoints = new List <Vector4>(); controlPoints.Add(v1); controlPoints.Add(v2); controlPoints.Add(v3); controlPoints.Add(v4); controlPoints.Add(v5); controlPoints.Add(v6); controlPoints.Add(v7); controlPoints.Add(v8); newMesh.ControlPoints.AddRange(controlPoints); PolygonBuilder builder = new PolygonBuilder(newMesh); builder.Begin(); for (int i = 0; i < 4; i++) { builder.AddVertex(startIndex + i); } builder.End(); builder.Begin(); for (int i = 0; i < 4; i++) { builder.AddVertex(startIndex + i + 4); } builder.End(); for (int i = 0; i < 3; i++) { builder.Begin(); builder.AddVertex(startIndex + i); builder.AddVertex(startIndex + i + 4); builder.AddVertex(startIndex + i + 5); builder.AddVertex(startIndex + i + 1); builder.End(); } builder.Begin(); builder.AddVertex(startIndex + 3); builder.AddVertex(startIndex + 7); builder.AddVertex(startIndex + 4); builder.AddVertex(startIndex + 0); builder.End(); return(controlPoints.Count); }