public void GpIsoline() { Document doc = Application.DocumentManager.MdiActiveDocument; if (doc == null) { return; } Logger.Log.Info("Start Command: GP-Isoline"); Editor ed = doc.Editor; Options = IsolineOptions.Load(); var optKeywords = new PromptKeywordOptions( $"Отрисовка бергштрихов для полилиний {(_overruleIsolineDraw == null ? "Отключена" : "Включена")}"); optKeywords.Keywords.Add($"{(_overruleIsolineDraw == null ? "Включить" : "Отключить")}"); optKeywords.Keywords.Add($"{(_overruleIsolineDraw == null ? "Разморозить" : "Заморозить")}"); optKeywords.Keywords.Add("Настройки"); var resPrompt = ed.GetKeywords(optKeywords); if (resPrompt.Status == PromptStatus.OK) { if (resPrompt.StringResult == "Включить") { IsolinesOn(); } else if (resPrompt.StringResult == "Отключить") { IsolinesOff(); } else if (resPrompt.StringResult == "Разморозить") { // Удалить отдельные штрихи Isoline.UnfreezeAll(); // Включить изолинии IsolinesOn(); } else if (resPrompt.StringResult == "Заморозить") { // Превратить все штрихи в отдельные линии Isoline.FreezeAll(); // выключение изолиний IsolinesOff(); } else if (resPrompt.StringResult == "Настройки") { Options = Options.Show(); } } Application.DocumentManager.MdiActiveDocument.Editor.Regen(); }
private void DrawIsoline(Isoline line, Color linecolor) { GL.glPushAttrib(GL.GL_LINE_BIT | GL.GL_ENABLE_BIT); GL.glLineWidth(2.0f); GL.glEnable(GL.GL_LINE_SMOOTH); GL.glEnable(GL.GL_LIGHTING); GL.glEnable(GL.GL_NORMALIZE); GL.glPolygonMode(GL.GL_FRONT_AND_BACK, GL.GL_LINE); GL.glDisable(GL.GL_POLYGON_OFFSET_FILL); GL.glEnable(GL.GL_CULL_FACE); GL.glColor3ub(linecolor.R, linecolor.G, linecolor.B); GL.glBegin(GL.GL_LINES); foreach (FaceRecord rec in line.faces) { Vector3d p = rec.pq.p, q = rec.pq.q, normal = rec.pq.n; GL.glNormal3d(normal.x, normal.y, normal.z); GL.glVertex3d(p.x, p.y, p.z); GL.glVertex3d(q.x, q.y, q.z); } GL.glEnd(); GL.glPopAttrib(); GL.glEnable(GL.GL_POLYGON_OFFSET_FILL); GL.glEnable(GL.GL_CULL_FACE); GL.glDisable(GL.GL_LIGHTING); GL.glDisable(GL.GL_NORMALIZE); }
private void ObtainIsolineProperties(Isoline line) { // -- obtain radius -- double C = 0; foreach (FaceRecord f in line.faces) { if (f.face.valid == false) throw new ArgumentException(); PQPairs pair = f.pq; C += (pair.p - pair.q).Length(); } line.radious = C / (2 * Math.PI); }
private void LocateIsoContours() { // -- find out all the faces belong to a group (with the same iso-value) int n = mesh.FaceCount, m = opt.NumberOfIsolines; List<FaceRecord>[] faces = new List<FaceRecord>[m]; for (int i = 0; i < m; ++i) { faces[i] = new List<FaceRecord>(); } for (int i = 0; i < isofaces.Length; ++i) { if (isofaces[i] != null && isofaces[i].valid) { foreach (PQPairs pq in isofaces[i].pqPairs) { int idx = pq.lindex; faces[idx].Add(new FaceRecord(isofaces[i], pq)); } } } // -- further divid each set into connected groups --> isocontours bool[] tag = new bool[mesh.FaceCount]; int lineIndex = 0; this.fullIsolineList.Clear(); for (int i = 0; i < m; ++i) { List<FaceRecord> s = faces[i]; foreach (FaceRecord rec in s) tag[rec.face.index] = true; FaceRecord prev = null; foreach (FaceRecord rec in s) { int v = rec.face.index; if (tag[v]) { List<FaceRecord> flist = new List<FaceRecord>(); int next = v; flist.Add(rec); tag[next] = false; prev = rec; // visited bool nextExist = true; while (nextExist) { nextExist = false; foreach (int adj in mesh.AdjFF[next]) { if (tag[adj]) { next = adj; FaceRecord fr = null; foreach (FaceRecord r in s) { if (adj == r.face.index) { fr = r; break; } } if (fr == null) throw new Exception(); if (!HasCommonPorQ(prev, fr)) { continue; } flist.Add(fr); prev = fr; tag[next] = false; nextExist = true; break; } } } Isoline line = new Isoline(lineIndex++); line.faces = flist; line.value = isovalues[i]; this.fullIsolineList.Add(line); } } } }