public static CadMesh CreateFrom(VertexList vl) { if (vl.Count < 2) { return(null); } CadMesh m = new CadMesh(vl.Count, 1); m.VertexStore.AddRange(vl); int i; FlexArray <int> nl = new FlexArray <int>(vl.Count); for (i = 0; i < vl.Count; i++) { nl.Add(i); } CadFace face = new CadFace(nl); m.FaceStore.Add(face); return(m); }
// 全てのFaceを3角形に分割する public static void SplitAllFace(CadMesh mesh) { FlexArray <CadFace> faceStore = new FlexArray <CadFace>(); for (int i = 0; i < mesh.FaceStore.Count; i++) { CadFace face = mesh.FaceStore[i]; if (face.VList.Count < 3) { continue; } if (face.VList.Count == 3) { faceStore.Add(face); continue; } List <CadFace> flist = Split(face, mesh); faceStore.AddRange(flist); } mesh.FaceStore = faceStore; }
private void UpdateSegList() { SegList.Clear(); for (int i = 0; i < mHeModel.FaceStore.Count; i++) { HeFace f = mHeModel.FaceStore[i]; HalfEdge head = f.Head; HalfEdge c = head; for (; ;) { HalfEdge next = c.Next; SegList.Add(new IndexPair(c.Vertex, next.Vertex)); c = next; if (c == head) { break; } } } }
public CadFace(params int[] args) { VList = new FlexArray <int>(args.Length); for (int i = 0; i < args.Length; i++) { VList.Add(args[i]); } }
public FlexArray <int> GetOuterEdge() { // Pairを持たないHalfEdgeのリストを作成 List <HalfEdge> heList = new List <HalfEdge>(); ForEachHalfEdge(he => { if (he.Pair == null) { heList.Add(he); } }); FlexArray <int> ret = new FlexArray <int>(); if (heList.Count <= 1) { return(ret); } int s = FindMaxDistantHalfEdge(CadVertex.Zero, heList); if (s == -1) { DOut.pl("HeModel.GetOuterEdge not found start HalfEdge"); return(ret); } int t = s; HalfEdge whe = heList[t]; int vi = whe.Vertex; heList.RemoveAt(t); while (true) { ret.Add(vi); vi = whe.Next.Vertex; t = FindHalfEdge(vi, heList); if (t == -1) { break; } whe = heList[t]; heList.RemoveAt(t); } return(ret); }
public void Clear() { var ary = new FlexArray <int>(); ary.Count.Is(0); ary.Clear(); ary.Count.Is(0); ary.Add(10); ary[0] = 10; ary[0].Is(10); ary.Clear(); ary.Count.Is(0); ary[0].Is(default(int)); ary.Add(10); ary.Add(20); ary.Clear(); ary.Count.Is(0); ary[0].Is(default(int)); ary[1].Is(default(int)); }
public static FlexArray <HeFace> HeFaceListFromMp( List <MpHeFace_v1002> list, Dictionary <uint, HalfEdge> dic ) { FlexArray <HeFace> ret = new FlexArray <HeFace>(); for (int i = 0; i < list.Count; i++) { ret.Add(list[i].Restore(dic)); } return(ret); }
public void Count() { var ary = new FlexArray <int>(); ary.Count.Is(0); for (int i = 1; i < 3; i++) { ary.Add(i); ary.Count.Is(i); } ary = new FlexArray <int>(); ary[2] = 10; ary.Count.Is(3); }
public void Add() { var ary = new FlexArray <int>(); for (int i = 0; i < 10; i++) { ary.Count.Is(i); ary.Add(i); ary.Count.Is(i + 1); } ary = new FlexArray <int>(); ary[2] = 10; ary.Count.Is(3); ary.Add(20); ary.Count.Is(4); ary[3].Is(20); }
protected void DrawFigures(DrawContext dc) { if (dc == null) { return; } DrawParams pale_dp = default; DrawParams test_dp = default; DrawParams current_dp = default; DrawParams measure_dp = default; DrawParams empty_dp = default; empty_dp.Empty = true; pale_dp.LinePen = dc.GetPen(DrawTools.PEN_PALE_FIGURE); pale_dp.EdgePen = dc.GetPen(DrawTools.PEN_PALE_FIGURE); pale_dp.FillBrush = DrawBrush.NullBrush; pale_dp.TextBrush = dc.GetBrush(DrawTools.BRUSH_PALE_TEXT); test_dp.LinePen = dc.GetPen(DrawTools.PEN_TEST_FIGURE); test_dp.EdgePen = dc.GetPen(DrawTools.PEN_TEST_FIGURE); test_dp.FillBrush = DrawBrush.NullBrush; test_dp.TextBrush = dc.GetBrush(DrawTools.BRUSH_TEXT); current_dp.LinePen = dc.GetPen(DrawTools.PEN_FIGURE_HIGHLIGHT); current_dp.EdgePen = dc.GetPen(DrawTools.PEN_FIGURE_HIGHLIGHT); current_dp.FillBrush = DrawBrush.NullBrush; current_dp.TextBrush = dc.GetBrush(DrawTools.BRUSH_TEXT); measure_dp.LinePen = dc.GetPen(DrawTools.PEN_MEASURE_FIGURE); measure_dp.EdgePen = dc.GetPen(DrawTools.PEN_MEASURE_FIGURE); measure_dp.FillBrush = DrawBrush.NullBrush; measure_dp.TextBrush = dc.GetBrush(DrawTools.BRUSH_TEXT); AlphaFigList.Clear(); AlphaFigListCurrentLayer.Clear(); lock (DB) { foreach (CadLayer layer in mDB.LayerList) { if (!layer.Visible) { continue; } // Skip current layer. // It will be drawn at the end of this loop. if (layer == CurrentLayer) { continue; } foreach (CadFigure fig in layer.FigureList) { if (fig.Type == CadFigure.Types.DIMENTION_LINE) { AlphaFigList.Add(fig); continue; } if (fig.Current) { fig.DrawEach(dc, current_dp); } else { fig.DrawEach(dc, pale_dp); } } } // Draw current layer at last if (CurrentLayer != null && CurrentLayer.Visible) { foreach (CadFigure fig in CurrentLayer.FigureList) { if (fig.Type == CadFigure.Types.DIMENTION_LINE) { AlphaFigListCurrentLayer.Add(fig); continue; } if (fig.Current) { fig.DrawEach(dc, current_dp); } else { fig.DrawEach(dc); } } } foreach (CadFigure fig in TempFigureList) { if (fig.Type == CadFigure.Types.DIMENTION_LINE) { continue; } fig.DrawEach(dc, test_dp); } if (MeasureFigureCreator != null) { if (MeasureFigureCreator.Figure.Type != CadFigure.Types.DIMENTION_LINE) { MeasureFigureCreator.Figure.Draw(dc, measure_dp); } } // Alpha指定があるFigureを描画 foreach (CadFigure fig in AlphaFigList) { if (fig.Current) { fig.DrawEach(dc, current_dp); } else { fig.DrawEach(dc, pale_dp); } } foreach (CadFigure fig in AlphaFigListCurrentLayer) { if (fig.Current) { fig.DrawEach(dc, current_dp); } else { fig.DrawEach(dc); } } foreach (CadFigure fig in TempFigureList) { if (fig.Type != CadFigure.Types.DIMENTION_LINE) { continue; } fig.DrawEach(dc, test_dp); } if (MeasureFigureCreator != null) { if (MeasureFigureCreator.Figure.Type == CadFigure.Types.DIMENTION_LINE) { MeasureFigureCreator.Figure.Draw(dc, measure_dp); } } } }